def create_project(connection, name, description=None): new_project = gw.ProjectWrapper(connection, model.ProjectI()) new_project.setName(name) if description: new_project.setDescription(description) new_project.save() return new_project
def create_project(connection, project_name, project_description=None): new_project = model.ProjectI() new_project.setName(rtypes.rstring(project_name)) if project_description is not None: new_project.setDescription(rtypes.rstring(project_description)) new_project = connection.getUpdateService().saveAndReturnObject(new_project) return new_project
def link_dataset_to_project(connection, dataset, project): link = model.ProjectDatasetLinkI() link.setParent(model.ProjectI( project.getId(), False)) # linking to a loaded project might raise exception link.setChild(model.DatasetI(dataset.getId(), False)) connection.getUpdateService().saveObject(link) return
def create_dataset(connection, dataset_name, dataset_description=None, parent_project=None): new_dataset = model.DatasetI() new_dataset.setName(rtypes.rstring(dataset_name)) if dataset_description: new_dataset.setDescription(rtypes.rstring(dataset_description)) new_dataset = connection.getUpdateService().saveAndReturnObject(new_dataset) if parent_project: link = model.ProjectDatasetLinkI() link.setChild(model.DatasetI(new_dataset.getId(), False)) link.setParent(model.ProjectI(parent_project.getId(), False)) connection.getUpdateService().saveObject(link) return new_dataset
def add_tags(self, tag_values, object_type, object_id): update_service = self.SESSION.getUpdateService() for tag_value in tag_values: # tags shouldn't contain commas? split_tag_values = [x.strip() for x in tag_value.split(',')] # ignore empty tag strings for split_tag_value in split_tag_values: if len(split_tag_value.strip()) < 1: continue # TODO: add check here to see if tag with specific value already exists and link it if so # use stateless update service instead of blitz new_tag_anno = model.TagAnnotationI() # TODO: determine what description the tag annotation should have; e.g. date, strain # Use 'client' namespace to allow editing in Insight & web new_tag_anno.setTextValue(rtypes.rstring(split_tag_value)) tag_anno = update_service.saveAndReturnObject(new_tag_anno) # do link with parent object om_object = self.retrieve_objects(object_type, [int(object_id)]) link = None if object_type == str(OMERODataType.project): link = model.ProjectAnnotationLinkI() link.parent = model.ProjectI(object_id, False) elif object_type == str(OMERODataType.dataset): link = model.DatasetAnnotationLinkI() link.parent = model.DatasetI(object_id, False) elif object_type == str(OMERODataType.image): link = model.ImageAnnotationLinkI() link.parent = model.ImageI(object_id, False) link.child = model.TagAnnotationI(tag_anno.id, False) update_service.saveAndReturnObject(link)
def add_kvps(self, key_value_data, object_type, object_id): # use stateless update service instead of blitz new_map_anno = model.MapAnnotationI() # Use 'client' namespace to allow editing in Insight & web namespace = constants.metadata.NSCLIENTMAPANNOTATION new_map_anno.setNs(rtypes.rstring(namespace)) # key_value_data = [{i[0]: i[1:]} for i in key_value_data] key_value_data = [ model.NamedValue(i[0], str(i[1:])) for i in key_value_data ] # key_value_data = [model.NamedValue(i[0], i[1:]) for i in key_value_data] new_map_anno.setMapValue(key_value_data) update_service = self.SESSION.getUpdateService() map_anno = update_service.saveAndReturnObject(new_map_anno) # do link with parent object om_object = self.retrieve_objects(object_type, [int(object_id)]) link = None if object_type == str(OMERODataType.project): link = model.ProjectAnnotationLinkI() link.parent = model.ProjectI(object_id, False) elif object_type == str(OMERODataType.dataset): link = model.DatasetAnnotationLinkI() link.parent = model.DatasetI(object_id, False) elif object_type == str(OMERODataType.image): link = model.ImageAnnotationLinkI() link.parent = model.ImageI(object_id, False) link.child = model.MapAnnotationI(map_anno.id, False) update_service.saveAndReturnObject(link)