def __metadata(self):
     self.utils.registerNamespace("dc", "http://purl.org/dc/terms/")
     self.utils.registerNamespace("foaf", "http://xmlns.com/foaf/0.1/")
     
     jsonPayload = self.object.getPayload("metadata.json")
     json = self.utils.getJsonObject(jsonPayload.open())
     jsonPayload.close()
     
     data = json.getMap("data")
     
     #ARCS data
     projectId = data.get("Project_ID")
     arcURI = "%s/%s" % (data.get("recordIDPrefix").rstrip("/"), projectId) 
     oid = DigestUtils.md5Hex(arcURI)
     
     self.utils.add(self.index, "dc_identifier", arcURI)
     self.utils.add(self.index, "dc_abstract", data.get("Project_Abstract"))
     self.utils.add(self.index, "dc_title", data.get("Project_Title"))
     self.utils.add(self.index, "foaf_name", data.get("Administering_Organisation"))  #This is under foaf:organisation
     self.utils.add(self.index, "dc_date", data.get("First_Year_of_Funding"))
     self.utils.add(self.index, "dc_dateSubmitted", data.get("Submit_Year"))
     self.utils.add(self.index, "dc_description", data.get("National/Community_Benefit"))
     subject = "%s - %s" % (data.get("4-digit_RFCD_code"), data.get("Discipline"))
     self.utils.add(self.index, "dc_subject", subject)
     
     #Investigators
     investigators = data.get("Investigators").split(";")
     for investigator in investigators:
         self.utils.add(self.index, "dc_contributor", investigator)
     self.utils.add(self.index, "dc_type", data.get("Scheme").strip())
Exemplo n.º 2
0
 def getSelectedFacetIds(self):
     ## Returns a native Python array
     ## Python has indicator of u' for unicode string which causes JS complain.
     ## Because MD5 hash is made from letters we can encode them in ascii
     return [
         DigestUtils.md5Hex(fq).encode("ascii", "ignore")
         for fq in self.__selected
     ]
Exemplo n.º 3
0
    def __metadata(self):
        ISOCode = self.params.getProperty("ISOcode")
        print "*** Processing: ", ISOCode
        #Index the country metadata
        metadataPayload = self.object.getPayload("%s.json" % ISOCode)
        json = JsonConfigHelper(metadataPayload.open())
        allMeta = json.getMap(".")
        self.utils.add(self.index, "recordType", "country")
        for key in allMeta.keySet():
            self.utils.add(self.index, key, allMeta.get(key));
        metadataPayload.close()

        #Index the country detail
        geoNamePayload = self.object.getPayload("%s.txt" % ISOCode)
        countryName = self.params.getProperty("countryName")
    
        countryAreaStream = geoNamePayload.open()
        reader = BufferedReader(InputStreamReader(countryAreaStream, "UTF-8"));
        line = reader.readLine()
        
        headerList = ["geonameid", "name", "asciiname", "alternatenames", "latitude", "longitude", \
                      "feature class", "feature code", "country code", "cc2", "admin1 code", "admin2 code", \
                      "admin3 code", "admin4 code", "population", "elevation", "gtopo30", "timezone", "modification date"]
        
        while (line != None):
            arraySplit = line.split("\t")
            geonamesId = arraySplit[0]
            oid = DigestUtils.md5Hex("http://geonames.org/" + geonamesId)

            if oid == self.oid:
                extraIndex = self.index
            else:
                extraIndex = HashMap()
                self.utils.add(extraIndex, "recordType", "area")
                self.utils.add(extraIndex, "item_type", self.itemType)
                self.utils.add(extraIndex, "dc_identifier", oid)
                self.utils.add(extraIndex, "id", oid)
                self.utils.add(extraIndex, "storage_id", self.oid)   #Use parent object
                self.utils.add(extraIndex, "last_modified", time.strftime("%Y-%m-%dT%H:%M:%SZ"))
                self.utils.add(extraIndex, "display_type", "geonames")
                self.utils.add(extraIndex, "countryName", countryName)
                self.utils.add(extraIndex, "repository_name", self.params["repository.name"])
                self.utils.add(extraIndex, "repository_type", self.params["repository.type"])
                self.utils.add(extraIndex, "security_filter", "guest")
            self.utils.add(extraIndex, "dc_title", arraySplit[1])
            # The rest of the metadata
            count = 0
            for array in arraySplit:
                if headerList[count] !="alternatenames" and array:
                    self.utils.add(extraIndex, headerList[count], array)
                count +=1
                
            self.indexer.sendIndexToBuffer(oid, extraIndex)
            line = reader.readLine()
        geoNamePayload.close()
        
Exemplo n.º 4
0
 def createReport(self):
     self.reportName = DigestUtils.md5Hex(self.formData.get("reportName") + self.formData.get("dateFrom") + RandomStringUtils.randomAlphanumeric(20));
     
     self.report = RedboxReport( self.reportName, self.formData.get("reportName")) 
     self.report.setQueryFilterVal("dateFrom",self.formData.get("dateFrom"),"dateFrom", "dateFrom")
     self.report.setQueryFilterVal("dateTo",self.formData.get("dateTo"),"dateTo", "dateTo")
     
     for fieldName in self.formData.getFormFields():
         if fieldName != "reportName":
             self.report.setQueryFilterVal(fieldName,self.formData.get(fieldName),fieldName, fieldName)           
     
     self.reportManager.addReport(self.report)
     self.reportManager.saveReport(self.report)
Exemplo n.º 5
0
    def createReport(self):
        self.reportName = DigestUtils.md5Hex(
            self.formData.get("reportName") + self.formData.get("dateFrom") +
            RandomStringUtils.randomAlphanumeric(20))

        self.report = RedboxReport(self.reportName,
                                   self.formData.get("reportName"))
        self.report.setQueryFilterVal("dateFrom",
                                      self.formData.get("dateFrom"),
                                      "dateFrom", "dateFrom")
        self.report.setQueryFilterVal("dateTo", self.formData.get("dateTo"),
                                      "dateTo", "dateTo")

        for fieldName in self.formData.getFormFields():
            if fieldName != "reportName":
                self.report.setQueryFilterVal(fieldName,
                                              self.formData.get(fieldName),
                                              fieldName, fieldName)

        self.reportManager.addReport(self.report)
        self.reportManager.saveReport(self.report)
    def __metadata(self):
        self.utils.registerNamespace("dc", "http://purl.org/dc/terms/")
        
        jsonPayload = self.object.getPayload("metadata.json")
        json = self.utils.getJsonObject(jsonPayload.open())
        jsonPayload.close()
        
        data = json.getMap("data")
        
        geonamesId = data.get("geonameid")
        oid = DigestUtils.md5Hex("http://geonames.org/" + geonamesId)
        self.utils.add(self.index, "dc_identifier", "http://geonames.org/" + geonamesId)
        self.utils.add(self.index, "recordType", "area")
        self.utils.add(self.index, "storage_id", oid)   #Use parent object
        self.utils.add(self.index, "last_modified", time.strftime("%Y-%m-%dT%H:%M:%SZ"))
        self.utils.add(self.index, "display_type", "geonames")

        self.utils.add(self.index, "name", data.get("name"))
        self.utils.add(self.index, "dc_title", data.get("name"))
        self.utils.add(self.index, "asciiname", data.get("asciiname"))
        self.utils.add(self.index, "alternatenames", data.get("alternatenames"))
        self.utils.add(self.index, "latitude", data.get("latitude"))
        self.utils.add(self.index, "longitude", data.get("longitude"))
        self.utils.add(self.index, "feature_class", data.get("featureclass"))
        self.utils.add(self.index, "feature_code", data.get("featurecode"))
        self.utils.add(self.index, "country_code", data.get("countrycode"))
        self.utils.add(self.index, "cc2", data.get("cc2"))
        self.utils.add(self.index, "admin1_code", data.get("admin1code"))
        self.utils.add(self.index, "admin2_code", data.get("admin2code"))
        self.utils.add(self.index, "admin3_code", data.get("admin3code"))
        self.utils.add(self.index, "admin4_code", data.get("admin4code"))
        self.utils.add(self.index, "population", data.get("population"))
        self.utils.add(self.index, "elevation", data.get("elevation"))
        self.utils.add(self.index, "gtopo30", data.get("gtopo30"))
        self.utils.add(self.index, "timezone", data.get("timezone"))
        self.utils.add(self.index, "modification_date", data.get("modificationdate"))
    def __metadata(self):
        self.utils.registerNamespace("dc", "http://purl.org/dc/terms/")
        self.utils.registerNamespace("foaf", "http://xmlns.com/foaf/0.1/")

        jsonPayload = self.object.getPayload("metadata.json")
        json = self.utils.getJsonObject(jsonPayload.open())
        jsonPayload.close()      

        data = json.getMap("data")      
        
        grantId = data.get("Grant_Id")
        if grantId.strip():
            nhmrcURI = "%s/%s" % (data.get("recordIDPrefix").rstrip("/"), grantId) 
            oid = DigestUtils.md5Hex(nhmrcURI)
            
            self.utils.add(self.index, "dc_identifier", nhmrcURI)
            self.utils.add(self.index, "dc_dateSubmitted", data.get("App_Year"))
            self.utils.add(self.index, "dc_date", data.get("_Start_Year"))
            self.utils.add(self.index, "dc_title", data.get("Simplified_Title"))
            self.utils.add(self.index, "foaf_name", data.get("Grant_Admin_Institution"))
            self.utils.add(self.index, "dc_type", data.get("Grant_Type"))
            self.utils.add(self.index, "dc_subject", data.get("Field_Of_Research_"))
            self.utils.add(self.index, "dc_contributor", data.get("CIA_Full_Name"))
            self.utils.add(self.index, "dc_description", data.get("Scientific_Title"))
Exemplo n.º 8
0
 def getSelectedFacetIds(self):
     ## Returns a native Python array
     ## Python has indicator of u' for unicode string which causes JS complain.
     ## Because MD5 hash is made from letters we can encode them in ascii 
     return [ DigestUtils.md5Hex(fq).encode("ascii","ignore") for fq in self.__selected]