def getFullHistory(self, oids): """Query the history and save the latest full set of workflow steps to the return JsonObject""" req = SearchRequest('context:"Workflow" AND newStep:[* TO *] AND oid:' + oids + '') req.setParam("fl",'eventTime,newStep,oid') req.setParam("rows", Dashboard.MAX_ROWS) req.setParam("sort", "oid asc, eventTime asc") events = self._packageResults(req, "eventLog") latest = JsonObject() for e in events: oid = e.get("oid") if oid not in latest: jObj = JsonObject() latest.put(oid,jObj) else: jObj = latest.get(oid) jObj.put('%s_eventTime' % e.get("newStep"), self.formatDate(e.get("eventTime"))) return latest
def __metadata(self): jsonPayload = self.object.getPayload("metadata.json") json = self.utils.getJsonObject(jsonPayload.open()) jsonPayload.close() metadata = json.getObject("metadata") self.utils.add(self.index, "dc_identifier", metadata.get("dc.identifier")) data = json.getObject("data") ####Global setting for processing data ####These will need to be changed based on you system installation. theMintHost = "http://*****:*****@example.edu.au" sock = urllib.urlopen(theMintHost + "/mint/default/opensearch/lookup?count=999&searchTerms=Email:" + email) mintData = sock.read() sock.close() jsonSimple = JsonSimple(mintData) jsonObj = jsonSimple.getJsonObject() results = jsonObj.get("results") #Ensuring that the Email identified a Party from The Mint if results: resultMetadata = JsonObject(results.get(0)) allData = resultMetadata.get("result-metadata") creator = allData.get("all") whoType = party.get("who").get("type") if ((creator is not None) and (whoType == 'people')): self.utils.add(self.index, "dc_creator.foaf_Person." + str(i) + ".dc_identifier", creator.get("dc_identifier")[0]) self.utils.add(self.index, "dc_creator.foaf_Person." + str(i) + ".foaf_name", creator.get("dc_title")) self.utils.add(self.index, "dc_creator.foaf_Person." + str(i) + ".foaf_title", creator.get("Honorific")[0]) self.utils.add(self.index, "dc_creator.foaf_Person." + str(i) + ".redbox_isCoPrimaryInvestigator", "off") self.utils.add(self.index, "dc_creator.foaf_Person." + str(i) + ".redbox_isPrimaryInvestigator", "on") self.utils.add(self.index, "dc_creator.foaf_Person." + str(i) + ".foaf_givenName", creator.get("Given_Name")[0]) self.utils.add(self.index, "dc_creator.foaf_Person." + str(i) + ".foaf_familyName", creator.get("Family_Name")[0]) ###Processing 'contactInfo.email' metadata contactInfoEmail = data.get("contactInfo").get("email") #Using the email address to obtain details from The Mint #For testing, hard coded email address #contactInfoEmail = "*****@*****.**" sock = urllib.urlopen(theMintHost + "/mint/default/opensearch/lookup?count=999&searchTerms=Email:" + contactInfoEmail) mintData = sock.read() sock.close() jsonSimple = JsonSimple(mintData) jsonObj = jsonSimple.getJsonObject() results = jsonObj.get("results") #Ensuring that the Email identified a Party from The Mint if results: resultMetadata = JsonObject(results.get(0)) allData = resultMetadata.get("result-metadata") creator = allData.get("all") if (creator is not None): self.utils.add(self.index, "locrel_prc.foaf_Person.dc_identifier", creator.get("dc_identifier").toString()) self.utils.add(self.index, "locrel_prc.foaf_Person.foaf_name", creator.get("dc_title")) self.utils.add(self.index, "locrel_prc.foaf_Person.foaf_title", creator.get("Honorific").toString()) self.utils.add(self.index, "locrel_prc.foaf_Person.foaf_givenName", creator.get("Given_Name").toString()) self.utils.add(self.index, "locrel_prc.foaf_Person.foaf_familyName", creator.get("Family_Name").toString()) ###Processing 'coinvestigators' metadata coinvestigators = data.get("coinvestigators") for i in range(len(coinvestigators)): self.utils.add(self.index, "dc_contributor.loclrel_clb." + str(i) + ".foaf_Agent" , coinvestigators[i]) ###Processing 'anzsrcFOR' metadata anzsrcFOR = data.get("anzsrcFOR") for i in range(len(anzsrcFOR)): anzsrc = anzsrcFOR[i] #Querying against The Mint, but only using the first 4 numbers from anzsrc, this ensure a result sock = urllib.urlopen(theMintHost + "/mint/ANZSRC_FOR/opensearch/lookup?count=999&level=http://purl.org/asc/1297.0/2008/for/" + anzsrc[:4]) mintData = sock.read() sock.close() jsonSimple = JsonSimple(mintData) jsonObj = jsonSimple.getJsonObject() results = jsonObj.get("results") #ensuring that anzsrc identified a record in The Mint if results: for j in range(len(results)): result = JsonObject(results.get(j)) rdfAbout = result.get("rdf:about") target = "http://purl.org/asc/1297.0/2008/for/" + anzsrc if (rdfAbout == target): self.utils.add(self.index, "dc_subject.anzsrc_for." + str(i) + ".skos_prefLabel" , result.get("skos:prefLabel")) self.utils.add(self.index, "dc_subject.anzsrc_for." + str(i) + ".rdf:resource" , rdfAbout) ###Processing 'anzsrcSEO' metadata anzsrcSEO = data.get("anzsrcSEO") for i in range(len(anzsrcSEO)): anzsrc = anzsrcSEO[i] #Querying against The Mint, but only using the first 4 numbers from anzsrc, this ensure a result sock = urllib.urlopen(theMintHost + "/mint/ANZSRC_SEO/opensearch/lookup?count=999&level=http://purl.org/asc/1297.0/2008/seo/" + anzsrc[:4]) mintData = sock.read() sock.close() jsonSimple = JsonSimple(mintData) jsonObj = jsonSimple.getJsonObject() results = jsonObj.get("results") #ensuring that anzsrc identified a record in The Mint if results: for j in range(len(results)): result = JsonObject(results.get(j)) rdfAbout = result.get("rdf:about") target = "http://purl.org/asc/1297.0/2008/seo/" + anzsrc if (rdfAbout == target): self.utils.add(self.index, "dc_subject.anzsrc_seo." + str(i) + ".skos_prefLabel" , result.get("skos:prefLabel")) self.utils.add(self.index, "dc_subject.anzsrc_seo." + str(i) + ".rdf:resource" , rdfAbout) ###Processing 'keyword' metadata keyword = data.get("keyword") for i in range(len(keyword)): self.utils.add(self.index, "dc_subject.vivo_keyword." + str(i) + ".rdf_PlainLiteral", keyword[i]) self.utils.add(self.index, "dc_accessRights.skos_prefLabel", data.get("accessRights")) self.utils.add(self.index, "dc_license.dc_identifier", data.get("license").get("url")) self.utils.add(self.index, "dc_license.skos_prefLabel", data.get("license").get("label")) self.utils.add(self.index, "dc_identifier.redbox_origin", "internal") dataLocation = data.get("dataLocation") dataLocation = dataLocation.replace("%NAME_OF_FOLDER%", species) self.utils.add(self.index, "bibo_Website.1.dc_identifier", dataLocation) #The following have been intentionally set to blank. No mapping is required for these fields. self.utils.add(self.index, "vivo_Location", "") self.utils.add(self.index, "redbox_retentionPeriod", data.get("retentionPeriod")) self.utils.add(self.index, "dc_extent", "unknown") self.utils.add(self.index, "redbox_disposalDate", "") self.utils.add(self.index, "locrel_own.foaf_Agent.1_foaf_name", "") self.utils.add(self.index, "locrel_dtm.foaf_Agent.foaf_name", "") ###Processing 'organizationalGroup' metadata organisationalGroup = data.get("organizationalGroup") for i in range(len(organisationalGroup)): organisation = organisationalGroup[i] #Querying against The Mint sock = urllib.urlopen(theMintHost + "/mint/Parties_Groups/opensearch/lookup?count=9999&searchTerms=ID:" + organisation) mintData = sock.read() sock.close() jsonSimple = JsonSimple(mintData) jsonObj = jsonSimple.getJsonObject() results = jsonObj.get("results") #ensuring that anzsrc identified a record in The Mint if results: resultMetadata = JsonObject(results.get(0)) allData = resultMetadata.get("result-metadata") orgGroup = allData.get("all") self.utils.add(self.index, "foaf_Organization.dc_identifier", orgGroup.get("dc_identifier")[0]) self.utils.add(self.index, "foaf_Organization.skos_prefLabel", orgGroup.get("Name")[0]) self.utils.add(self.index, "foaf_fundedBy.foaf_Agent", "") self.utils.add(self.index, "foaf_fundedBy.vivo_Grant", "") self.utils.add(self.index, "swrc_ResearchProject.dc_title", "") self.utils.add(self.index, "locrel_dpt.foaf_Person.foaf_name", "") self.utils.add(self.index, "dc_SizeOrDuration", "") self.utils.add(self.index, "dc_Policy", "") self.utils.add(self.index, "redbox_ManagementPlan", "")