from org.semanticdesktop.aperture.vocabulary import NCO; from org.semanticdesktop.aperture.vocabulary import NID3; from org.semanticdesktop.aperture.vocabulary import NIE; from org.semanticdesktop.aperture.rdf.impl import RDFContainerImpl; from org.ontoware.rdf2go.model.node.impl import URIImpl; rdfPayload = object.getPayload("aperture.rdf") rdfModel = pyUtils.getRdfModel(rdfPayload) #rdfModel.dump() #Seems like aperture only encode the spaces. Tested against special characters file name #and it's working safeOid = oid.replace(" ", "%20") rdfId = "urn:oid:%s" % safeOid.rstrip("/") container = RDFContainerImpl(rdfModel, rdfId) #1. get title only if no title returned by ICE if titleList == []: titleCollection = container.getAll(NIE.title) iterator = titleCollection.iterator() while iterator.hasNext(): node = iterator.next() result = str(node).strip() titleList.append(result) titleCollection = container.getAll(NID3.title) iterator = titleCollection.iterator() while iterator.hasNext(): node = iterator.next() result = str(node).strip()
def __aperture(self): # Extract from aperture.rdf if exist try: from org.semanticdesktop.aperture.vocabulary import NCO; from org.semanticdesktop.aperture.vocabulary import NFO; from org.semanticdesktop.aperture.vocabulary import NID3; from org.semanticdesktop.aperture.vocabulary import NIE; from org.semanticdesktop.aperture.rdf.impl import RDFContainerImpl; from org.ontoware.rdf2go.model.node.impl import URIImpl; rdfPayload = self.object.getPayload("aperture.rdf") rdfModel = self.utils.getRdfModel(rdfPayload) # Seems like aperture only encode the spaces. Tested against special # characters file name and it's working safeOid = self.oid.replace(" ", "%20") rdfId = "urn:oid:%s" % safeOid.rstrip("/") container = RDFContainerImpl(rdfModel, rdfId) # 1. get title only if no title returned by ICE if self.titleList == []: titleCollection = container.getAll(NIE.title) iterator = titleCollection.iterator() while iterator.hasNext(): node = iterator.next() result = str(node).strip() self.titleList.append(result) titleCollection = container.getAll(NID3.title) iterator = titleCollection.iterator() while iterator.hasNext(): node = iterator.next() result = str(node).strip() self.titleList.append(result) # 2. get creator only if no creator returned by ICE if self.creatorList == []: creatorCollection = container.getAll(NCO.creator); iterator = creatorCollection.iterator() while iterator.hasNext(): node = iterator.next() creatorUri = URIImpl(str(node)) creatorContainer = RDFContainerImpl(rdfModel, creatorUri); value = creatorContainer.getString(NCO.fullname); if value and value not in self.creatorList: self.creatorList.append(value) # 3. getFullText: only aperture has this information fulltextString = container.getString(NIE.plainTextContent) if fulltextString: self.fulltext.append(fulltextString.strip()) #4. description/abstract will not be returned by aperture, so if no description found # in dc.xml returned by ICE, put first 100 characters if self.descriptionList == []: descriptionString = fulltextString if len(fulltextString) > 100: descriptionString = fulltextString[:100] + "..." self.descriptionList.append(descriptionString) # 4. album title albumTitle = container.getString(NID3.albumTitle) if albumTitle: self.descriptionList.append("Album: " + albumTitle.strip()) # 5. mimeType: only aperture has this information mimeType = container.getString(NIE.mimeType) if mimeType: self.formatList.append(mimeType.strip()) # 6. contentCreated if self.creationDate == []: contentCreated = container.getString(NIE.contentCreated) if contentCreated: self.creationDate.append(contentCreated.strip()) except StorageException, e: #print "Failed to index aperture data (%s)" % str(e) pass
def __aperture(self): # Extract from aperture.rdf if exist try: from org.semanticdesktop.aperture.vocabulary import NCO from org.semanticdesktop.aperture.vocabulary import NFO from org.semanticdesktop.aperture.vocabulary import NID3 from org.semanticdesktop.aperture.vocabulary import NIE from org.semanticdesktop.aperture.rdf.impl import RDFContainerImpl from org.ontoware.rdf2go.model.node.impl import URIImpl rdfPayload = self.object.getPayload("aperture.rdf") rdfModel = self.utils.getRdfModel(rdfPayload) # Seems like aperture only encode the spaces. Tested against special # characters file name and it's working safeOid = self.oid.replace(" ", "%20") rdfId = "urn:oid:%s" % safeOid.rstrip("/") container = RDFContainerImpl(rdfModel, rdfId) # 1. get title only if no title returned by ICE if self.title is None: titleCollection = container.getAll(NIE.title) iterator = titleCollection.iterator() while iterator.hasNext() and self.title is None: node = iterator.next() self.title = str(node).strip() titleCollection = container.getAll(NID3.title) iterator = titleCollection.iterator() while iterator.hasNext() and self.title is None: node = iterator.next() self.title = str(node).strip() # 2. get creator only if no creator returned by ICE if self.creatorList == []: creatorCollection = container.getAll(NCO.creator) iterator = creatorCollection.iterator() while iterator.hasNext(): node = iterator.next() creatorUri = URIImpl(str(node)) creatorContainer = RDFContainerImpl(rdfModel, creatorUri) value = creatorContainer.getString(NCO.fullname) if value and value not in self.creatorList: self.creatorList.append(value) # 3. getFullText: only aperture has this information fulltextString = container.getString(NIE.plainTextContent) if fulltextString: self.fulltext.append(fulltextString.strip()) #4. description/abstract will not be returned by aperture, so if no description found # in dc.xml returned by ICE, put first 100 characters if self.descriptionList == []: descriptionString = fulltextString if len(fulltextString) > 100: descriptionString = fulltextString[:100] + "..." self.descriptionList.append(descriptionString) # 4. album title albumTitle = container.getString(NID3.albumTitle) if albumTitle: self.descriptionList.append("Album: " + albumTitle.strip()) # 5. mimeType: only aperture has this information mimeType = container.getString(NIE.mimeType) if mimeType: self.formatList.append(mimeType.strip()) # 6. contentCreated if self.creationDate == []: contentCreated = container.getString(NIE.contentCreated) if contentCreated: self.creationDate.append(contentCreated.strip()) except StorageException, e: #print "Failed to index aperture data (%s)" % str(e) pass