示例#1
0
class TagsPayload(GenericPayload):
    def __init__(self, payload, oid):
        self.__tags = []
        self.__model = RDF2Go.getModelFactory().createModel();
        self.__model.open();
        self.__content = TaggedContent(self.__model, "urn:" + md5.new(oid).hexdigest(), True);
        if payload is None:
            self.setId("tags.rdf")
            self.setLabel("Tags")
            self.setContentType("application/rdf+xml")
            self.setType(PayloadType.Annotation)
        else:
            GenericPayload.__init__(self, payload)
            self.__model.readFrom(payload.getInputStream())
            tags = self.__content.getAllTagged_as().asArray()
            for tag in tags:
                labels = tag.getAllTaglabel_asNode_().asArray()
                for label in labels:
                    self.__tags.append(label)
        self.setType(PayloadType.Annotation)
    
    def addTag(self, tag):
        tagNode = self.__createTag(tag)
        self.__content.addTagged(tagNode);
    
    def removeTag(self, tag):
        tagNode = self.__createTag(tag)
        self.__content.removeTagged(tagNode);
    
    def __createTag(self, tag):
        encodedTag = URLEncoder.encode(tag, "UTF-8")
        tagNode = Tag(self.__model, "urn:tags:" + encodedTag, True)
        tagNode.setMeans(self.__model.createURI("urn:tags:" + encodedTag));
        tagNode.setTaglabel(self.__model.createPlainLiteral(tag))
        return tagNode
    
    def getTags(self):
        return self.__tags
    
    def getInputStream(self):
        rdf = self.__model.serialize(Syntax.RdfXml)
        return ByteArrayInputStream(array.array('b', rdf.encode("UTF-8")))
    
    def close(self):
        self.__model.close()
示例#2
0
 def __init__(self, payload, oid):
     self.__tags = []
     self.__model = RDF2Go.getModelFactory().createModel();
     self.__model.open();
     self.__content = TaggedContent(self.__model, "urn:" + md5.new(oid).hexdigest(), True);
     if payload is None:
         self.setId("tags.rdf")
         self.setLabel("Tags")
         self.setContentType("application/rdf+xml")
         self.setType(PayloadType.Annotation)
     else:
         GenericPayload.__init__(self, payload)
         self.__model.readFrom(payload.getInputStream())
         tags = self.__content.getAllTagged_as().asArray()
         for tag in tags:
             labels = tag.getAllTaglabel_asNode_().asArray()
             for label in labels:
                 self.__tags.append(label)
     self.setType(PayloadType.Annotation)
示例#3
0
                    formatList.append(allMimeTypes.next())

            # 6. contentCreated
            if creationDate == []:
                if informationElement.hasContentCreated():
                    creationDate.append(informationElement.getContentCreated().getTime().toString())

    indexList("dc_title", titleList)
    indexList("dc_creator", creatorList)  # no dc_author in schema.xml, need to check
    indexList("dc_contributor", contributorList)
    indexList("dc_description", descriptionList)
    indexList("dc_format", formatList)
    indexList("dc_date", creationDate)

    for key in relationDict:
        indexList(key, relationDict[key])

    indexList("full_text", fulltext)
    indexPath("file_path", object.getId().replace("\\", "/"), includeLastPart=False)

    tagsRdf = object.getPayload("tags.rdf")
    if tagsRdf is not None:
        tagsModel = pyUtils.getRdfModel(tagsRdf)
        hashId = md5.new(object.getId()).hexdigest()
        content = TaggedContent(tagsModel, "urn:" + hashId, False)
        tags = content.getAllTagged_as().asArray()
        for tag in tags:
            labels = tag.getAllTaglabel_asNode_().asArray()
            for label in labels:
                rules.add(AddField("tag", label.toString()))