[ome-devel] OMERO API Import

Matthias Dunda Matthias.Dunda at carus-it.com
Wed Feb 6 09:24:30 GMT 2008


Hi there,

I'm using this sample code (which is mainly an aggregation of ImportFixture and which we created during our session with Josh - thanks for this...) to import pictures via the java API:

public static void main(String[] args) throws Exception {
    ServiceFactory sf = new ServiceFactory(...);

    Project p = new Project();
    p.setName("aaaaaaaaaaaaaaa");
    p = sf.getUpdateService().saveAndReturnObject(p);

    // StartPlate
    Dataset d = new Dataset();
    d.setName("bbbbbbbbbbbbbbb");
    p.linkDataset(d);
    d = sf.getUpdateService().saveAndReturnObject(d);

    File file = new File(
            "u:\\mdu\\BPAE_cells_DAPI_MitoTrackerRed_Phallacidin_3.tif");
    ImportContainer container = new ImportContainer(file, d, "unbenutzt",
            true);

    OMEROMetadataStore store = new OMEROMetadataStore(sf);
    OMEROWrapper reader = new ODIPImportReader();
    ImportLibrary library = new ImportLibrary(store, reader,
            new ImportContainer[] { container });

    // WriteImageFile
    String fileName = file.getAbsolutePath();
    library.setDataset(d);
    library.open(fileName);
    library.calculateImageCount(fileName, 0);

    List<Pixels> pixId = library.importMetadata(file.getAbsolutePath());
    library.importData(pixId.get(0).getId(), fileName, 0,
            new ImportLibrary.Step() {
            @Override
            public void step(int arg0, int arg1) {
            System.out.println(arg0 + "," + arg1);
            }
            });

    // Get Pixels (unnecessary) & in Beta3 no more defaultPixels
    d = sf.getQueryService()
        .findByQuery("select d from Dataset d join fetch d.imageLinks dil " +
                "join fetch dil.child image join fetch image.defaultPixels where d.id = :id",
                new Parameters().addId(d.getId()));

    Image i = (Image) d.linkedImageList().get(0);
    i.setName("asdfsdafgfgsdfgd");
    Pixels px = i.getDefaultPixels(); // getPrimaryPixels

    // WriteWellData (auch anderes in Beta3)
    DatasetAnnotation da = new DatasetAnnotation();
    da.setDataset(d);
    da.setContent("cccccccccccccccc");
    sf.getUpdateService().saveObject(da);
}

My question is: where does the actual saving in the database take place? After running this code I (think I) see new models for Image and Pixels although I never do an explicit saveObject.

Does this all happen recursively due to saving the DatasetAnnotation in the last line?

What happenes in this step:
    List<Pixels> pixId = library.importMetadata(file.getAbsolutePath());
    library.importData(pixId.get(0).getId(), fileName, 0,
            new ImportLibrary.Step() {
            @Override
            public void step(int arg0, int arg1) {
            System.out.println(arg0 + "," + arg1);
            }
            });


Cheers
Matthias

--
Matthias Dunda, Dipl.-Inform.
c.a.r.u.s. HMS GmbH
Bornbarch 9, D-22848 Norderstedt
Fon: +49.(0)40.5 14 35-0
Fax: +49.(0)40.5 14 35-11 11

Amtsgericht/Register Court: Kiel, HRB 4587 NO
Sitz/Registered Office: Norderstedt
Geschäftsführer/Managing Directors: Karl-Heinz Witt, Dr. Matthias Rath




More information about the ome-devel mailing list