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


Python JsonSimple.getString方法代码示例

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


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

示例1: __createNew

# 需要导入模块: from com.googlecode.fascinator.common import JsonSimple [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonSimple import getString [as 别名]
    def __createNew(self):
        self.vc("log").debug("Creating a new package...")
        packageType, jsonConfigFile = self.__getPackageTypeAndJsonConfigFile()
        self.vc("log").debug("packageType = '{}'", packageType)
        self.vc("log").debug("jsonConfigFile = '{}'", jsonConfigFile)

        manifestHash = "%s.tfpackage" % uuid.uuid4()
        # store the manifest file for harvesting
        packageDir = FascinatorHome.getPathFile("packages")
        packageDir.mkdirs()
        manifestFile = File(packageDir, manifestHash)
        outStream = FileOutputStream(manifestFile)
        outWriter = OutputStreamWriter(outStream, "UTF-8")

        self.vc("sessionState").set("package/active", None)
        manifest = self.__getActiveManifest()
        manifest.setType(packageType)
        metaList = list(self.vc("formData").getValues("metaList"))
        jsonObj = manifest.getJsonObject()
        for metaName in metaList:
            value = self.vc("formData").get(metaName)
            jsonObj.put(metaName, value)
        if self.vc("formData").getValues("sequencesMetaList") != None:    
            sequenceService = ApplicationContextProvider.getApplicationContext().getBean("sequenceService")
            sequencesMetaList = list(self.vc("formData").getValues("sequencesMetaList"))
            for sequenceInfo in sequencesMetaList:   
                sequenceInfoJson = JsonSimple(sequenceInfo)
                sequenceIndex = sequenceService.getSequence(sequenceInfoJson.getString(None,"sequenceName"))
                jsonObj.put(sequenceInfoJson.getString(None,"metadataName"), String.format(sequenceInfoJson.getString(None,"stringFormat"),sequenceIndex))
        self.vc("log").debug("json object created is: %r" % jsonObj)
        outWriter.write(manifest.toString(True))
        outWriter.close()
        # adding ability to set access plugin
        accessPlugin = self.vc("formData").get("access_plugin", "derby")
        if accessPlugin is not None:
            self.vc("page").authentication.set_access_plugin(accessPlugin)
        try:
            # harvest the package as an object
            username = self.vc("sessionState").get("username")
            if username is None:
                username = "guest" # necessary?
            harvester = None
            # set up config files, creating if necessary
            workflowsDir = FascinatorHome.getPathFile("harvest/workflows")
            configFile = self.__getFile(workflowsDir, jsonConfigFile)
            self.__getFile(workflowsDir, "packaging-rules.py")
            # run the harvest client with our packaging workflow config
            harvester = HarvestClient(configFile, manifestFile, username)
            harvester.start()
            manifestId = harvester.getUploadOid()
            harvester.shutdown()
        except Exception, ex:
            error = "Packager workflow failed: %s" % str(ex)
            self.vc("log").error(error, ex)
            if harvester is not None:
                harvester.shutdown()
            return '{ "status": "failed" }'
开发者ID:the-fascinator,项目名称:fascinator-portal,代码行数:59,代码来源:packaging.py

示例2: getLabel

# 需要导入模块: from com.googlecode.fascinator.common import JsonSimple [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonSimple import getString [as 别名]
 def getLabel(self, jsonFile, key):
     value = self.metadata.get(key)
     jsonLabelFile = System.getProperty("fascinator.home") + jsonFile
     entries = JsonSimple(File(jsonLabelFile)).getJsonArray()
     for entry in entries:
         entryJson = JsonSimple(entry)
         if value == entryJson.getString("", "value"):
             return entryJson.getString("", "label")
     return None
开发者ID:greg-pendlebury,项目名称:redbox,代码行数:11,代码来源:detail.py

示例3: execProcessors

# 需要导入模块: from com.googlecode.fascinator.common import JsonSimple [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonSimple import getString [as 别名]
 def execProcessors(self, procId, configJson, dataMap, stageName):
     for procObj in configJson.getArray(stageName):
         procJson = JsonSimple(procObj)
         procClassName = procJson.getString("", "class")
         procConfigPath = procJson.getString("", "config")
         
         procInputKey = procJson.getString("", "inputKey")
         procOutputKey = procJson.getString("", "outputKey")
         procClass = Class.forName(procClassName)
         procInst = procClass.newInstance()
         
         procMethod = procClass.getMethod("process", self.get_class("java.lang.String"),self.get_class("java.lang.String"), self.get_class("java.lang.String"),self.get_class("java.lang.String"),self.get_class("java.lang.String"), self.get_class("java.util.HashMap"))
         procMethod.invoke(procInst, procId, procInputKey, procOutputKey, stageName, procConfigPath, dataMap)
开发者ID:greg-pendlebury,项目名称:redbox,代码行数:15,代码来源:launch.py

示例4: updateObjectMetadata

# 需要导入模块: from com.googlecode.fascinator.common import JsonSimple [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonSimple import getString [as 别名]
 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,代码行数:27,代码来源:TransitionWorkflow.py

示例5: getLabel

# 需要导入模块: from com.googlecode.fascinator.common import JsonSimple [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonSimple import getString [as 别名]
 def getLabel(self, jsonFile, key, listKey, valKey, labelKey):
     value = self.metadata.get(key)
     jsonLabelFile = System.getProperty("fascinator.home") + jsonFile
     jsonLabel = JsonSimple(File(jsonLabelFile))
     entries = jsonLabel.getJsonArray()
     # the structure of the json file is fun and complicated
     if entries is None:
         entries = jsonLabel.getArray(listKey)
     else:
         valKey = "value"
         labelKey = "label"
     for entry in entries:
         entryJson = JsonSimple(entry)
         if value == entryJson.getString("", valKey):
             return entryJson.getString("", labelKey)
     return None
开发者ID:nishen,项目名称:redbox,代码行数:18,代码来源:detail.py

示例6: __hotfix

# 需要导入模块: from com.googlecode.fascinator.common import JsonSimple [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonSimple import getString [as 别名]
    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,代码行数:32,代码来源:redboxMigration1.5.py

示例7: process_tags

# 需要导入模块: from com.googlecode.fascinator.common import JsonSimple [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonSimple import getString [as 别名]
    def process_tags(self, result):
        tags = []
        tagsDict = {}
        # Build a dictionary of the tags
        for doc in result:
            # Get Anotar data from Solr data
            doc = JsonSimple(doc.get("jsonString"))
            # Get actual tag text
            tag = doc.getString(None, ["content", "literal"])
            # Find out if they have locators
            locs = doc.getJsonSimpleList(["annotates", "locators"]).size()
            if locs == 0:
                # Basic tags, just aggregate counts
                if tag in tagsDict:
                    # We've seen it before, just increment the counter
                    existing = tagsDict[tag]
                    count = existing.getInteger(0, ["tagCount"])
                    existing.getJsonObject().put("tagCount", str(count + 1))
                else:
                    # First time, store this object
                    doc.getJsonObject().put("tagCount", str(1))
                    tagsDict[tag] = doc
            else:
                # Tags with a locator, special case for images etc.
                tags.append(doc.toString())

        # Push all the 'basic' counts into the list to return
        for tag in tagsDict:
            tags.append(tagsDict[tag].toString())
        return "[" + ",".join(tags) + "]"
开发者ID:kiranba,项目名称:the-fascinator,代码行数:32,代码来源:anotar.py

示例8: __formData

# 需要导入模块: from com.googlecode.fascinator.common import JsonSimple [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonSimple import getString [as 别名]
    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,代码行数:62,代码来源:redboxMigration1.5.py

示例9: updateLocalRecordRelations

# 需要导入模块: from com.googlecode.fascinator.common import JsonSimple [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonSimple import getString [as 别名]
    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,代码行数:37,代码来源:curation.py

示例10: __activate__

# 需要导入模块: from com.googlecode.fascinator.common import JsonSimple [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonSimple import getString [as 别名]
    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,代码行数:28,代码来源:proxyGet.py

示例11: __activate__

# 需要导入模块: from com.googlecode.fascinator.common import JsonSimple [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonSimple import getString [as 别名]
 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,代码行数:29,代码来源:launch.py

示例12: __getUser

# 需要导入模块: from com.googlecode.fascinator.common import JsonSimple [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonSimple import getString [as 别名]
    def __getUser(self):
        self.log.debug("baserule.py: Assign ownership: mapping id to user")
        
        mapConfig = self.config.getObject(["user-assignment"])
        if mapConfig is None:
            self.log.debug("baserule.py: no configuration has been set for mapping id to user.")
            return None

        uname = None
        try:
            userAssignment = JsonSimple(mapConfig)
            self.log.debug("baserule.py: user_id to user mapping configuration")
    
            modulePath = userAssignment.getString(None, ["module-path"])
            self.log.debug("baserule.py: module-path = {}", modulePath)
            
            className = userAssignment.getString(None, ["class-name"])
            self.log.debug("baserule.py: className = {}", className)
            
            initParams = userAssignment.getArray(["init-params"])
            self.log.debug("baserule.py: init-params (list) = {}", ' ,'.join(initParams))
            
            actionMethodName = userAssignment.getString(None, ["action-method-name"])
            self.log.debug("baserule.py: action-method-name = {}", actionMethodName)
            
            # JsonArray
            actionMethodParams = userAssignment.getArray(["action-method-params"])
      
            # This block may be used to mapping method params to internal variables?    
            try:
                self.log.debug("baserule.py: read parameters from tfpackage.")
                params = self.__getItems(actionMethodParams)
            except Exception, e:
                self.log.debug("baserule.py: read parameters failed. Reason: {}", str(e))
            
            if params is None or len(params) == 0:
                self.log.debug("baserule.py: read parameters returned None. Cannot carry on.")
                return None
                
            lookupPk = imp.load_source('', modulePath)
            lookupClass = getattr(lookupPk, className)
            lookupObj = lookupClass(*initParams)
            lookupMethod = getattr(lookupObj, actionMethodName)
            uname = lookupMethod(*params)
            
            self.log.debug("baserule.py: external lookup module returns: {}", uname)
开发者ID:ozej8y,项目名称:redbox,代码行数:48,代码来源:baserules.py

示例13: getLabel

# 需要导入模块: from com.googlecode.fascinator.common import JsonSimple [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonSimple import getString [as 别名]
 def getLabel(self, jsonFile, key):
     value = self.metadata.get(key)
     jsonLabelFile = System.getProperty("fascinator.home") + jsonFile
     jsonF = JsonSimple(File(jsonLabelFile))
     entries = jsonF.getJsonArray()
     if entries is None:
         entries = jsonF.getArray('results')
         if entries is None:
             self.log.debug("Unknown data source format: JSON file {} or its 'results' has no array.", jsonLabelFile)
             return None
     
     for entry in entries:
         entryJson = JsonSimple(entry)
         if value == entryJson.getString("", "id"):
             return entryJson.getString("", "label")
         elif value == entryJson.getString("", "value"):
             return entryJson.getString("", "label")
         
     return None
开发者ID:ozej8y,项目名称:redbox,代码行数:21,代码来源:detail.py

示例14: __init__

# 需要导入模块: from com.googlecode.fascinator.common import JsonSimple [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonSimple import getString [as 别名]
class TimNotificationData:

    def __init__(self):
        self.messaging = MessagingServices.getInstance()

    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()

        
    def __wget(self, url):
        client = BasicHttpClient(url)
        m = GetMethod(url)
        client.executeMethod(m)
        return IOUtils.toString(m.getResponseBodyAsStream(), "UTF-8")
开发者ID:Deakin,项目名称:redbox,代码行数:49,代码来源:timNotification.py

示例15: modify_json

# 需要导入模块: from com.googlecode.fascinator.common import JsonSimple [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonSimple import getString [as 别名]
    def modify_json(self):
        # print "**** anotar.py : add_json() : adding json : " + json
        jsonSimple = JsonSimple(self.json)
        jsonObj = jsonSimple.getJsonObject()
        jsonObj.put("id", self.pid)
        rootUri = jsonSimple.getString(None, ["annotates", "rootUri"])
        if rootUri is not None:
            baseUrl = "http://%s:%s/" % (self.vc("request").serverName, self.vc("serverPort"))
            myUri = baseUrl + rootUri + "#" + self.pid
            jsonObj.put("uri", myUri)

        jsonObj.put("schemaVersionUri", "http://www.purl.org/anotar/schema/0.1")
        self.json = jsonSimple.toString()
开发者ID:kiranba,项目名称:the-fascinator,代码行数:15,代码来源:anotar.py


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