def addTagAs(self, user, project): """ Adds and links a Tag. """ tag = TagAnnotationI() tag.setTextValue(rstring(self.tag_text)) tag.setNs(rstring(self.tag_ns)) tag = self.updateServices[user].saveAndReturnObject(tag) self.linkTagAs(user, project, tag) return tag
def load(conn, filepath): """ Import new tag(s) from json. """ if filepath: fobj = open(filepath, "r") else: sys.stderr.write("Error: No file is given.\n") sys.exit(1) p = json.load(fobj) if fobj is not sys.stdin: fobj.close() update = conn.getUpdateService() tagList2 = [] for tset in p: if "tag" in tset: tag = TagAnnotationI() tag.setTextValue(rstring(tset["tag"])) if tset["desc"]: tag.setDescription(rstring(tset["desc"])) tagList2.append(tag) #end if if "tagset" in tset: tagList = [] for t in tset['tags']: tag = TagAnnotationI() tag.setTextValue(rstring(t["name"])) if t["desc"]: tag.setDescription(rstring(t["desc"])) tagList.append(tag) #end for tagList = update.saveAndReturnArray(tagList) tag = TagAnnotationI() tag.setTextValue(rstring(tset["tagset"])) if tset["desc"]: tag.setDescription(rstring(tset["desc"])) tag.setNs(rstring(omero.constants.metadata.NSINSIGHTTAGSET)) tag = update.saveAndReturnObject(tag) links = [] for child in tagList: l = AnnotationAnnotationLinkI() l.setChild(child) l.setParent(tag) links.append(l) #end for update.saveAndReturnArray(links) #end if #end for update.saveAndReturnArray(tagList2)
def makeTag(self): tag = TagAnnotationI() tag.setTextValue(rstring(self.tag_text)) tag.setNs(rstring(self.tag_ns)) return tag