Page 1 of 1

create a dataset for 4.3.x

PostPosted: Wed Feb 22, 2012 3:47 am
by bhcho
Code: Select all
    dataset = conn.getUpdateService().saveAndReturnObject(dataset)
    dataset_id = dataset.id.val

should do it.

Cheers,
~Josh

Re: create a dataset for 4.3.x

PostPosted: Wed Feb 22, 2012 4:27 am
by bhcho
self reply.

I just decided to use old code (which is not deprecated yet)

Code: Select all
session = conn.c.sf

gateway = session.createGateway()
dataset = omero.model.DatasetI()
dataset.name = omero.rtypes.rstring( name )
try:
   dataset2 = gateway.saveAndReturnObject( dataset )
   gateway.close()
except:
   gateway.close()

ID=dataset2.getId().getValue()

Re: create a dataset for 4.3.x

PostPosted: Wed Feb 22, 2012 8:41 am
by wmoore
Hi BK,

This is deprecated.
Code: Select all
session.createGateway()

You're also creating a stateful service, which you don't need for simply saving an object.

Use the update service instead to call saveAndReturnObject(). It does exactly the same thing.
You also don't need to access the session itself.

If you use services created by the Blitz Gateway connection "conn", these are proxies that have additional error and reconnection handling.

You also don't need to use 'dataset2'. Just reassign to 'dataset'

Code: Select all
dataset = omero.model.DatasetI()
dataset.name = omero.rtypes.rstring( name )

dataset = conn.getUpdateService().saveAndReturnObject( dataset )

ID=dataset.getId().getValue()