def rating_userA(request, userA, groupA): """ Returns new OMERO Rating """ rating = LongAnnotationI() ctx = {'omero.group': native_str(groupA.id.val)} rating.longValue = rlong(4) rating.ns = rstring(omero.constants.metadata.NSINSIGHTRATING) rating = get_update_service(userA).saveAndReturnObject(rating, ctx) return rating
def fileset_with_images_and_annotations(request, gatewaywrapper): gatewaywrapper.loginAsAuthor() update_service = gatewaywrapper.gateway.getUpdateService() fileset = create_fileset() comment_annotation = CommentAnnotationI() comment_annotation.ns = rstring("comment_annotation") comment_annotation.textValue = rstring("textValue") long_annotation = LongAnnotationI() long_annotation.ns = rstring("long_annotation") long_annotation.longValue = rlong(1L) fileset.linkAnnotation(comment_annotation) fileset.linkAnnotation(long_annotation) fileset = update_service.saveAndReturnObject(fileset) return gatewaywrapper.gateway.getObject("Fileset", fileset.id.val)
def fileset_with_images_and_annotations(request, gatewaywrapper): gatewaywrapper.loginAsAuthor() update_service = gatewaywrapper.gateway.getUpdateService() fileset = create_fileset() comment_annotation = CommentAnnotationI() comment_annotation.ns = rstring('comment_annotation') comment_annotation.textValue = rstring('textValue') long_annotation = LongAnnotationI() long_annotation.ns = rstring('long_annotation') long_annotation.longValue = rlong(1L) fileset.linkAnnotation(comment_annotation) fileset.linkAnnotation(long_annotation) fileset = update_service.saveAndReturnObject(fileset) return gatewaywrapper.gateway.getObject('Fileset', fileset.id.val)
def link_tags(conn, datasetname, image_tag_links, image_ratings): for i in range(1, 51): username = "******" % i print(username) exp = conn.getAdminService().lookupExperimenter(username) exp_id = exp.id.val dataset = conn.getObject("Dataset", attributes={'name': datasetname}, opts={'owner': exp_id}) if dataset is None: print("Dataset not found") continue links = [] for image in dataset.listChildren(): name = image.name if name in image_tag_links: for tag_id in image_tag_links[name]: link = ImageAnnotationLinkI() link.parent = ImageI(image.id, False) link.child = TagAnnotationI(tag_id, False) link.details.owner = ExperimenterI(exp_id, False) links.append(link) if name in image_ratings: link = ImageAnnotationLinkI() link.parent = ImageI(image.id, False) r = LongAnnotationI() r.ns = rstring(RATING_NS) r.longValue = rlong(image_ratings[name]) link.child = r link.details.owner = ExperimenterI(exp_id, False) links.append(link) print('links', len(links)) group_id = dataset.getDetails().getGroup().id conn.SERVICE_OPTS.setOmeroGroup(group_id) try: conn.getUpdateService().saveArray(links, conn.SERVICE_OPTS) except ValidationException: print("Failed to link for %s" % username)
def add_annotations(o): ''' Annotation BasicAnnotation BooleanAnnotation BooleanAnnotationI NumericAnnotation DoubleAnnotation DoubleAnnotationI LongAnnotation LongAnnotationI TermAnnotation TermAnnotationI TimestampAnnotation TimestampAnnotationI ListAnnotation ListAnnotationI MapAnnotation MapAnnotationI TextAnnotation CommentAnnotation CommentAnnotationI TagAnnotation TagAnnotationI XmlAnnotation XmlAnnotationI TypeAnnotation FileAnnotation FileAnnotationI ''' annotation = BooleanAnnotationI() annotation.description = rstring('the_description') annotation.ns = rstring('boolean_annotation') annotation.boolValue = rbool(True) o.linkAnnotation(annotation) annotation = CommentAnnotationI() annotation.description = rstring('the_description') annotation.ns = rstring('comment_annotation') annotation.textValue = rstring('text_value') o.linkAnnotation(annotation) annotation = DoubleAnnotationI() annotation.description = rstring('the_description') annotation.ns = rstring('double_annotation') annotation.doubleValue = rdouble(1.0) o.linkAnnotation(annotation) annotation = LongAnnotationI() annotation.description = rstring('the_description') annotation.ns = rstring('long_annotation') annotation.longValue = rlong(1L) o.linkAnnotation(annotation) annotation = MapAnnotationI() annotation.description = rstring('the_description') annotation.ns = rstring('map_annotation') annotation.setMapValue([NamedValue('a', '1'), NamedValue('b', '2')]) o.linkAnnotation(annotation) annotation = TagAnnotationI() annotation.description = rstring('the_description') annotation.ns = rstring('tag_annotation') annotation.textValue = rstring('tag_value') o.linkAnnotation(annotation) annotation = TermAnnotationI() annotation.description = rstring('the_description') annotation.ns = rstring('term_annotation') annotation.termValue = rstring('term_value') o.linkAnnotation(annotation) annotation = TimestampAnnotationI() annotation.description = rstring('the_description') annotation.ns = rstring('timestamp_annotation') annotation.timeValue = rtime(1) o.linkAnnotation(annotation) annotation = XmlAnnotationI() annotation.description = rstring('the_description') annotation.ns = rstring('xml_annotation') annotation.textValue = rstring('<xml_value></xml_value>') o.linkAnnotation(annotation)