当前位置: 首页>>代码示例>>Python>>正文


Python common.JsonSimple类代码示例

本文整理汇总了Python中com.googlecode.fascinator.common.JsonSimple的典型用法代码示例。如果您正苦于以下问题:Python JsonSimple类的具体用法?Python JsonSimple怎么用?Python JsonSimple使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了JsonSimple类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: updateLocalRecordRelations

    def updateLocalRecordRelations(self, jobItems):
        oidIdentifierMap = HashMap()
        for jobItem in jobItems:
            oidIdentifierMap.put(jobItem.get("oid"),jobItem.get("required_identifiers")[0].get("identifier"))
            
        for jobItem in jobItems:
            type = jobItem.get("type");
            targetSystem = self.systemConfig.getString(None, "curation", "supported-types", type);
            if targetSystem == "redbox":
                oid = jobItem.get("oid")
                digitalObject = StorageUtils.getDigitalObject(self.services.getStorage(), oid)
                tfPackagePid = self.getPackageData(digitalObject)
                metadataJsonPayload = digitalObject.getPayload(tfPackagePid)
                metadataJsonInstream = metadataJsonPayload.open()
                metadataJson = JsonSimple(metadataJsonInstream)
                metadataJsonPayload.close()
                relationships = metadataJson.getArray("relationships")
                if relationships is not None:
                    for relationship in relationships:
			system = relationship.get("system")
                        if system != "redbox" or system != None:
			    url = self.systemConfig.getString("can't find it", "curation","external-system-urls","get-oid-for-identifier",system)
                            client = BasicHttpClient(url+ "&identifier="+relationship.get("identifier"))
                            get = GetMethod(url+ "&identifier="+relationship.get("identifier"))
                            client.executeMethod(get)
                            if get.getStatusCode() == 200:
                                response = JsonSimple(get.getResponseBodyAsString())
                                relationship.put("curatedPid",oidIdentifierMap.get(response.getString(None,"oid")))
                                relationship.put("isCurated",True)
                            
                            #Now update the relationship on Mint's side
                            break
                    
        istream = ByteArrayInputStream(String(metadataJson.toString(True)).getBytes())
        StorageUtils.createOrUpdatePayload(digitalObject,tfPackagePid,istream)
开发者ID:jcu-eresearch,项目名称:TDH-Research-Data-Catalogue,代码行数:35,代码来源:curation.py

示例2: __activate__

    def __activate__(self, context):
        self.None = context["log"]
        self.systemConfig = context["systemConfig"]
        self.sessionState = context["sessionState"]
        self.response = context["response"]
        self.request = context["request"]
        self.services = context["Services"]

        self.sessionState.set("username", "admin")
        self.writer = self.response.getPrintWriter("text/plain; charset=UTF-8")

        curationJobDao = ApplicationContextProvider.getApplicationContext().getBean("curationJobDao")
        publicationHandler = ApplicationContextProvider.getApplicationContext().getBean("publicationHandler")
        jobs = JsonSimple(File(FascinatorHome.getPath() + "/curation-status-responses/inProgressJobs.json")).getArray("inProgressJobs")
        self.writer.println(jobs.size())


        for curationJob in jobs:
            curationJob
            jobStatus = self.queryJobStatus(curationJob)
            self.writer.println(jobStatus.toString())
            status = jobStatus.getString("failed", "status")
            self.writeResponseToStatusResponseCache(jobStatus.getInteger(None, "job_id"), jobStatus)
            self.writer.println(status)
            if "complete" == status:
                publicationHandler.publishRecords(jobStatus.getArray("job_items"))
                self.updateLocalRecordRelations(jobStatus.getArray("job_items"))
           
            self.writer.close()
            self.sessionState.remove("username")
开发者ID:jcu-eresearch,项目名称:TDH-Research-Data-Catalogue,代码行数:30,代码来源:curation.py

示例3: __messages

 def __messages(self):
     if self.message_list is not None and len(self.message_list) > 0:
         msg = JsonSimple()
         msg.getJsonObject().put("oid", self.oid)
         message = msg.toString()
         for target in self.message_list:
             self.utils.sendMessage(target, message)
开发者ID:qcif,项目名称:mint-multi-environment-demo,代码行数:7,代码来源:servicesUI2-rules.py

示例4: __activate__

    def __activate__(self, context):
        self.velocityContext = context
        formData = self.vc("formData")

        # build the URL and query parameters to retrieve
        proxyUrls = JsonSimple(self.vc("systemConfig").getObject("proxy-urls"))
        url = ""
        key = formData.get("ns", "")
        if proxyUrls.getJsonObject().containsKey(key):
            url = proxyUrls.getString("", [key])
        queryStr = formData.get("qs")
        if queryStr == "searchTerms={searchTerms}":
            queryStr = None
        if queryStr:
            if formData.get("jaffa2autocomplete", "false") == "true":
                url += "?searchTerms=%s" % queryStr
            else:
                url += "?%s" % queryStr
        self.vc("log").debug("Proxy URL = '{}'", url)

        data = None
        try:
            data = self.__wget(url)
        except Exception, e:
            data = '{"error":"%s"}' % str(e)
            self.vc("log").error("ERROR accessing URL:", e)
开发者ID:greg-pendlebury,项目名称:redbox,代码行数:26,代码来源:proxyGet.py

示例5: get_image

 def get_image(self):
     self.type = "http://www.purl.org/anotar/ns/type/0.1#Tag"
     mediaFragType = "http://www.w3.org/TR/2009/WD-media-frags-20091217"
     result = '{"result":' + self.search_solr() + "}"
     if result:
         imageTagList = []
         imageTags = JsonSimple(result).getJsonSimpleList(["result"])
         for imageTag in imageTags:
             imageAno = JsonSimple()
             # We only want tags with locators, not basic tags
             locators = imageTag.getJsonSimpleList(["annotates", "locators"])
             if locators and not locators.isEmpty():
                 locatorValue = locators.get(0).getString(None, ["value"])
                 locatorType = locators.get(0).get(None, ["type"])
                 if locatorValue and locatorValue.find("#xywh=") > -1 and locatorType == mediaFragType:
                     _, locatorValue = locatorValue.split("#xywh=")
                     left, top, width, height = locatorValue.split(",")
                     object = imageAno.getJsonObject()
                     object.put("top", top)
                     object.put("left", left)
                     object.put("width", width)
                     object.put("height", height)
                     object.put("creator", imageTag.getString(None, ["creator", "literal"]))
                     object.put("creatorUri", imageTag.getString(None, ["creator", "uri"]))
                     object.put("id", imageTag.getString(None, ["id"]))
                     # tagCount = imageTag.getString(None, ["tagCount"])
                     object.put("text", imageTag.getString(None, ["content", "literal"]))
                     object.put("editable", "true")
                     imageTagList.append(imageAno.toString())
         result = "[" + ",".join(imageTagList) + "]"
     return result
开发者ID:kiranba,项目名称:the-fascinator,代码行数:31,代码来源:anotar.py

示例6: getCurationData

    def getCurationData(self, oid):
        json = JsonObject()
        try:
            # Get the object from storage
            storage = self.Services.getStorage()
            object = storage.getObject(oid)

            # Find the package payload
            payload = object.getPayload("metadata.json")
            # Not found?
            if payload is None:
                self.log.error(" * detail.py => Can't find package data!")
                json.put("error", True)
                return json

            # Parse the data
            data = JsonSimple(payload.open())
            payload.close()

            # Return it
            json.put("error", False)
            json.put("relationships", data.writeArray("relationships"))
            return json
        except StorageException, ex:
            self.log.error(" * detail.py => Storage Error accessing data: ", ex)
            json.put("error", True)
            return json
开发者ID:Paul-Nguyen,项目名称:mint,代码行数:27,代码来源:detail.py

示例7: __activate__

    def __activate__(self, context):
        self.auth = context["page"].authentication
        self.errorMsg = "" 
        self.request = context["request"]
        self.response = context["response"]
        self.formData = context["formData"]
        self.storage = context["Services"].getStorage()
        
        self.log = context["log"]
        self.reportManager = context["Services"].getService("reportManager")
            
        fromOid = self.formData.get("fromOid")
        fromObject = self.storage.getObject(fromOid)

        if (self.auth.is_logged_in()):
            if (self.auth.is_admin() == True):
                pass
            elif (self.__isOwner(fromObject)):
                pass
            else:
                self.errorMsg = "Requires Admin / Librarian / Reviewer / owner access." 
        else:
            self.errorMsg = "Please login."
        if self.errorMsg == "": 
             toOid = self.formData.get("toOid")
             toObject = self.storage.getObject(toOid)
             storeRelatedData = self.formData.get("relatedData")
             fromTFPackage = self._getTFPackage(fromObject)
             toTFPackage = self._getTFPackage(toObject)
             fromInputStream = fromTFPackage.open()
             
             try:
                 StorageUtils.createOrUpdatePayload(toObject, toTFPackage.getId(), fromInputStream)
             except StorageException:
                 print "error setting tfPackage"
                 
             fromTFPackage.close()
             fromTFPackageJson = JsonSimple(fromTFPackage.open()).getJsonObject()
             if storeRelatedData != "false" :
                # add relatedOid info
                fromTFPackageJson = self._addRelatedOid(JsonSimple(fromTFPackage.open()), toOid)
             
             inStream = IOUtils.toInputStream(fromTFPackageJson.toJSONString(), "UTF-8")
             
             try:
                 StorageUtils.createOrUpdatePayload(fromObject, fromTFPackage.getId(), inStream)
             except StorageException:
                 print "error setting tfPackage"
             
             tfMetaPropertyValue = self.formData.get("tfMetaPropertyValue")
             self._addPropertyValueToTFMeta(toObject, tfMetaPropertyValue)
             
             self._reharvestPackage()
                 
             result = '{"status": "ok", "url": "%s/workflow/%s", "oid": "%s" }' % (context["portalPath"], toOid , toOid)
        else:
            result = '{"status": "err", "message": "%s"}' % self.errorMsg
        writer = self.response.getPrintWriter("application/json; charset=UTF-8")
        writer.println(result)
        writer.close()
开发者ID:ozej8y,项目名称:redbox,代码行数:60,代码来源:copyTfPackage.py

示例8: __activate__

    def __activate__(self, context):
        self.log = context["log"]
        self.request = context["request"]
        self.sessionState = context["sessionState"]
        self.setting = JsonSimple(context["systemConfig"].getObject("tim.notification"))

        self.sessionState.set("username","admin")
        # read configuration and trigger processing stream sets
        # storing the return object on the map

        self.dataMap = HashMap()
        self.dataMap.put("indexer", context['Services'].getIndexer())

        url = self.setting.getString("","url")
        data = self.__wget(url)
        json = JsonSimple(data)
        if json.getInteger(0,["response","numFound"]) > 0 :
            username = self.setting.getString("",["email","username"])
            password = self.setting.getString("",["email","password"])
            body = self.setting.getString("",["email","body"])
            to = self.setting.getString("",["email","to"])
            if self.setting.getString("",["email","testmode"]) == "true" :
                body = body + "<p>TESTMODE: Was sent to " + to
                to = self.setting.getString("",["email","redirect"])
            email = HtmlEmail()
            email.setAuthenticator(DefaultAuthenticator(username, password))
            email.setHostName(self.setting.getString("localhost",["email","host"]))
            email.setSmtpPort(self.setting.getInteger(25,["email","port"]))
            email.setSSL(self.setting.getBoolean(False,["email","ssl"]))
            email.setTLS(self.setting.getBoolean(False,["email","tls"]))
            email.setFrom(self.setting.getString("",["email","from"]))
            email.setSubject(self.setting.getString("Action Required in TIM",["email","subject"]))
            email.addTo(to)
            email.setHtmlMsg(body)
            email.send()
开发者ID:Deakin,项目名称:redbox,代码行数:35,代码来源:timNotification.py

示例9: __activate__

 def __activate__(self, context):
     self.log = context["log"]
     self.request = context["request"]
     self.sessionState = context["sessionState"]
     self.sessionState.set("username","admin")
     processingSet = self.request.getParameter("processingSet")
     self.procMsg = None
     # read configuration and trigger processing stream sets
     # storing the return object on the map
     configFilePath = FascinatorHome.getPath("process")+"/processConfig.json"
     procConfigFile = File(configFilePath)
     if procConfigFile.exists() == True:
         self.dataMap = HashMap()
         self.dataMap.put("indexer", context['Services'].getIndexer())
         self.procConfigJson = JsonSimple(procConfigFile)
         for configObj in self.procConfigJson.getJsonArray():
             configJson = JsonSimple(configObj)
             procId = configJson.getString("", "id")
             if processingSet is not None: 
                 if procId == processingSet:
                     self.execProcSet(procId, configJson)
             else:
                 self.execProcSet(procId, configJson)
         if self.procMsg is None:
             self.procMsg = "Processing complete!"
     else:
         self.procMsg = "Configuration file does not exist: " + configFilePath
开发者ID:greg-pendlebury,项目名称:redbox,代码行数:27,代码来源:launch.py

示例10: updateObjectMetadata

 def updateObjectMetadata(self, objectMetaData, toWorkflowId):
     packageType, jsonConfigFile = self.__getPackageTypeAndJsonConfigFile(toWorkflowId)
     
     workflowsDir = FascinatorHome.getPathFile("harvest/workflows")
     configFile = File(workflowsDir, jsonConfigFile)
     configObject = StorageUtils.checkHarvestFile(self.storage, configFile);
     if configObject is None:
         oid = StorageUtils.generateOid(configFile);
         configObject = StorageUtils.getDigitalObject(self.storage, oid);
         
     objectMetaData.setProperty("jsonConfigPid", jsonConfigFile)
     objectMetaData.setProperty("jsonConfigOid", configObject.getId())
     
     configJson = JsonSimple(configFile)
     rulesFileName = configJson.getString(None, "indexer","script","rules")
     rulesFile = File(workflowsDir,rulesFileName)
     rulesObject = StorageUtils.checkHarvestFile(self.storage, rulesFile);
     if rulesObject is None:
         oid = StorageUtils.generateOid(rulesFile);
         rulesObject = StorageUtils.getDigitalObject(self.storage, oid);
     
     objectMetaData.setProperty("rulesPid", rulesFileName)
     objectMetaData.setProperty("rulesOid", rulesObject.getId())
     objectMetaData.setProperty("workflowTransitioned", "true")
     objectMetaData.setProperty("date_transitioned", time.strftime("%Y-%m-%dT%H:%M:%SZ", time.localtime()))
开发者ID:ozej8y,项目名称:redbox,代码行数:25,代码来源:TransitionWorkflow.py

示例11: __hotfix

    def __hotfix(self, formData):
        oldType = formData.getString(None, ["dc:type"])
        newType = formData.getString(None, ["dc:type.rdf:PlainLiteral"])
        if oldType != newType or newType is None:
            self.log.debug("Bugged Type?: v1.4: '{}', OLD: '{}'", newType, oldType)
        else:
            ## No fix required
            return None

        ## Get Backup data
        ## NOTE: The only known production system affected by this bug
        ## was caught during a v1.4 upgrade. Alter this line if required.
        pid = "1.4.workflow.backup"
        oldData = None
        try:
            payload = self.object.getPayload(pid)
            try:
                oldData = JsonSimple(payload.open())
            except Exception:
                self.log.error("Error parsing JSON '{}'", pid)
            finally:
                payload.close()
        except StorageException:
            self.log.error("Error accessing '{}'", pid)
            return None

        oldType = oldData.getString(None, ["dc:type"])
        self.log.debug("Old Type: '{}' => 'dc:type.rdf:PlainLiteral'", oldType)
        formData.getJsonObject().put("dc:type.rdf:PlainLiteral", oldType);
        return formData
开发者ID:andrewbrazzatti,项目名称:redbox-core-dev-build,代码行数:30,代码来源:redboxMigration1.5.py

示例12: __formData

    def __formData(self):
        # Find our workflow form data
        packagePid = None
        try:
            self.pidList = self.object.getPayloadIdList()
            for pid in self.pidList:
                if pid.endswith(self.packagePidSuffix):
                    packagePid = pid
        except StorageException:
            self.log.error("Error accessing object PID list for object '{}' ", self.oid)
            return
        if packagePid is None:
            self.log.debug("Object '{}' has no form data", self.oid)
            return

        # Retrieve our form data
        workflowData = None
        try:
            payload = self.object.getPayload(packagePid)
            try:
                workflowData = JsonSimple(payload.open())
            except Exception:
                self.log.error("Error parsing JSON '{}'", packagePid)
            finally:
                payload.close()
        except StorageException:
            self.log.error("Error accessing '{}'", packagePid)
            return

        # Test our version data
        self.version = workflowData.getString("{NO VERSION}", ["redbox:formVersion"])
        oldData = String(workflowData.toString(True))
        if self.version != self.redboxVersion:
            self.log.info("OID '{}' requires an upgrade: '{}' => '{}'", [self.oid, self.version, self.redboxVersion])
            # The version data is old, run our upgrade
            #   function to see if any alterations are
            #   required. Most likely at least the
            #   version number will change.
            newWorkflowData = self.__upgrade(workflowData)
        else:
            newWorkflowData = self.__hotfix(workflowData)
            if newWorkflowData is not None:
                self.log.debug("OID '{}' was hotfixed for v1.2 'dc:type' bug", self.oid)
            else:
                self.log.debug("OID '{}' requires no work, skipping", self.oid)
                return

        # Backup our data first
        backedUp = self.__backup(oldData)
        if not backedUp:
            self.log.error("Upgrade aborted, data backup failed!")
            return

        # Save the newly modified data
        jsonString = String(newWorkflowData.toString(True))
        inStream = ByteArrayInputStream(jsonString.getBytes("UTF-8"))
        try:
            self.object.updatePayload(packagePid, inStream)
        except StorageException, e:
            self.log.error("Error updating workflow payload: ", e)
开发者ID:andrewbrazzatti,项目名称:redbox-core-dev-build,代码行数:60,代码来源:redboxMigration1.5.py

示例13: __checkMetadataPayload

 def __checkMetadataPayload(self):
     try:
         # Simple check for its existance
         self.object.getPayload("formData.tfpackage")
         self.firstHarvest = False
     except Exception:
         self.firstHarvest = True
         # We need to create it
         self.log.info("Creating 'formData.tfpackage' payload for object '{}'", self.oid)
         # Prep data
         data = {
             "viewId": "default",
             "workflow_source": "Edgar Import",
             "packageType": "dataset",
             "redbox:formVersion": self.redboxVersion,
             "redbox:newForm": "true"
         }
         package = JsonSimple(JsonObject(data))
         # Store it
         inStream = IOUtils.toInputStream(package.toString(True), "UTF-8")
         try:
             self.object.createStoredPayload("formData.tfpackage", inStream)
             self.packagePid = "formData.tfpackage"
         except StorageException, e:
             self.log.error("Error creating 'formData.tfpackage' payload for object '{}'", self.oid, e)
             raise Exception("Error creating package payload: ", e)
开发者ID:DanielBaird,项目名称:TDH-Research-Data-Catalogue,代码行数:26,代码来源:directoryNames.py

示例14: updateRelationships

    def updateRelationships(self, relationship,pid,identifier):
        oid = self.findOidByIdentifier(relationship.get("identifier"))
        self.writer.println(oid)
        digitalObject = StorageUtils.getDigitalObject(self.storage, oid)
        metadataJsonPayload = digitalObject.getPayload("metadata.json")
        metadataJsonInstream = metadataJsonPayload.open()
        metadataJson = JsonSimple(metadataJsonInstream)
        metadataJsonPayload.close()
        relationships = metadataJson.getArray("relationships")


        found = False
        if relationships is None:
            relationships = JSONArray()
            metadataJson.getJsonObject().put("relationships",relationships)

        for relationship1 in relationships:
             if relationship1.get("identifier") == identifier:
                 relationship1.put("isCurated",True)
                 relationship1.put("curatedPid",pid)
                 found = True

        if not found:
            newRelationship = JsonObject()
            newRelationship.put("isCurated",True)
            newRelationship.put("curatedPid",pid)
            newRelationship.put("relationship",relationship.get("relationship"))
            newRelationship.put("identifier",identifier)
            relationships.add(newRelationship)


        istream = ByteArrayInputStream(String(metadataJson.toString(True)).getBytes())
        StorageUtils.createOrUpdatePayload(digitalObject,"metadata.json",istream)
开发者ID:ozej8y,项目名称:mint,代码行数:33,代码来源:updateRelationships.py

示例15: __activate__

    def __activate__(self, context):
        request = context["request"]
        storage = context["Services"].getStorage()
        auth = context["page"].authentication
        log = context["log"]
        
        username = auth.get_name()
        
        oid = request.getParameter("oid")
        approval = request.getParameter("approval")
        approval_comment = request.getParameter("approval_comment")
        
        storedObj = storage.getObject(oid)
        committeeResponses = None
        
        payloadList = storedObj.getPayloadIdList()
        if payloadList.contains("committee-responses.metadata"):
            committeeResponsePayload = storedObj.getPayload("committee-responses.metadata")
            committeeResponses = JsonSimple(committeeResponsePayload.open()).getJsonObject()
        else:
            committeeResponses = JsonObject()
        
        committeeResponse = JsonObject()
        committeeResponse.put("approval",approval)
        committeeResponse.put("approval_comment",approval_comment)
        
        committeeResponses.put(username,committeeResponse)

        log.debug(" %s: Committee %s, approval = %s, comment = %s"  % ( oid, username, approval, approval_comment))
        StorageUtils.createOrUpdatePayload(storedObj,"committee-responses.metadata",IOUtils.toInputStream(committeeResponses.toString(), "UTF-8"))
        context["response"].sendRedirect(context["portalPath"] +"/detail/"+oid)
开发者ID:qcif,项目名称:qcloud-arms,代码行数:31,代码来源:committee.py


注:本文中的com.googlecode.fascinator.common.JsonSimple类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。