def uploadImage(path, gateway): user = gateway.getLoggedInUser() ctx = SecurityContext(user.getGroupId()) sessionKey = gateway.getSessionId(user) config = ImportConfig() config.email.set("") config.sendFiles.set('true') config.sendReport.set('false') config.contOnError.set('false') config.debug.set('false') config.hostname.set(HOST) config.sessionKey.set(sessionKey) config.targetClass.set("omero.model.Dataset") config.targetId.set(datasetId) loci.common.DebugTools.enableLogging("DEBUG") store = config.createStore() reader = OMEROWrapper(config) library = ImportLibrary(store,reader) errorHandler = ErrorHandler(config) library.addObserver(LoggingImportMonitor()) candidates = ImportCandidates (reader, path, errorHandler) reader.setMetadataOptions(DefaultMetadataOptions(MetadataLevel.ALL)) success = library.importCandidates(config, candidates) return success
def upload_image(gateway, path, host, dataset_id): user = gateway.getLoggedInUser() ctx = SecurityContext(user.getGroupId()) session_key = gateway.getSessionId(user) str2d = Array.newInstance(String,[1]) str2d[0] = path config = ImportConfig() config.email.set("") config.sendFiles.set('true') config.sendReport.set('false') config.contOnError.set('false') config.debug.set('false') config.hostname.set(host) config.sessionKey.set(session_key) config.targetClass.set("omero.model.Dataset") config.targetId.set(dataset_id) loci.common.DebugTools.enableLogging("DEBUG") store = config.createStore() reader = OMEROWrapper(config) library = ImportLibrary(store,reader) error_handler = ErrorHandler(config) library.addObserver(LoggingImportMonitor()) candidates = ImportCandidates(reader, str2d, error_handler) reader.setMetadataOptions(DefaultMetadataOptions(MetadataLevel.ALL)) print('Importing image: ' + str2d[0]) success = library.importCandidates(config, candidates) return success