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


Python JsonSimple.get方法代码示例

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


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

示例1: _readReviewers

# 需要导入模块: from com.googlecode.fascinator.common import JsonSimple [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonSimple import get [as 别名]
 def _readReviewers(self, storedObj, tfpackage):
     """Read from TFPACKAGE for reviewer's recommendation and map to a json with short keys:
          reviewer-recommend-for : for
          reviewer-recommended-storage : storage   
     """
     reviewersPayload = storedObj.getPayload(tfpackage)
     reviewersRecommends = JsonSimple(reviewersPayload.open()).getJsonObject()
     reviewers = JsonObject()
     reviewers.put("for", reviewersRecommends.get("reviewer-recommend-for"))
     reviewers.put("storage", reviewersRecommends.get("reviewer-recommended-storage"))
     return reviewers
开发者ID:qcif,项目名称:rdsi-arms,代码行数:13,代码来源:assess.py

示例2: process_tags

# 需要导入模块: from com.googlecode.fascinator.common import JsonSimple [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonSimple import get [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

示例3: __workflow

# 需要导入模块: from com.googlecode.fascinator.common import JsonSimple [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonSimple import get [as 别名]
    def __workflow(self):
        # Workflow data
        WORKFLOW_ID = "servicesUI2"
        wfChanged = False
        workflow_security = []
        self.message_list = None
        stages = self.config.getJsonSimpleList(["stages"])
        pageTitle = "Services Record"
        displayType = "package-service"
        initialStep = 0
        try:
            wfMeta = self.__getJsonPayload("workflow.metadata")
            wfMeta.getJsonObject().put("pageTitle", pageTitle)

            # Are we indexing because of a workflow progression?
            targetStep = wfMeta.getString(None, ["targetStep"])
            if targetStep is not None and targetStep != wfMeta.getString(None, ["step"]):
                wfChanged = True
                # Step change
                wfMeta.getJsonObject().put("step", targetStep)
                wfMeta.getJsonObject().remove("targetStep")
            # This must be a re-index then
            else:
                targetStep = wfMeta.getString(None, ["step"])

            # Security change
            for stage in stages:
                if stage.getString(None, ["name"]) == targetStep:
                    wfMeta.getJsonObject().put("label", stage.getString(None, ["label"]))
                    self.item_security = stage.getStringList(["visibility"])
                    workflow_security = stage.getStringList(["security"])
                    if wfChanged == True:
                        self.message_list = stage.getStringList(["message"])
        except StorageException:
            # No workflow payload, time to create
            initialStage = stages.get(initialStep).getString(None, ["name"])
            wfChanged = True
            wfMeta = JsonSimple()
            wfMetaObj = wfMeta.getJsonObject()
            wfMetaObj.put("id", WORKFLOW_ID)
            wfMetaObj.put("step", initialStage)
            wfMetaObj.put("pageTitle", pageTitle)
            stages = self.config.getJsonSimpleList(["stages"])
            for stage in stages:
                if stage.getString(None, ["name"]) == initialStage:
                    wfMetaObj.put("label", stage.getString(None, ["label"]))
                    self.item_security = stage.getStringList(["visibility"])
                    workflow_security = stage.getStringList(["security"])
                    self.message_list = stage.getStringList(["message"])

        # Has the workflow metadata changed?
        if wfChanged == True:
            inStream = IOUtils.toInputStream(wfMeta.toString(True), "UTF-8")
            try:
                StorageUtils.createOrUpdatePayload(self.object, "workflow.metadata", inStream)
            except StorageException:
                print " ERROR updating dataset payload"

        # Form processing
        coreFields = ["title", "description", "manifest", "metaList", "relationships", "responses"]
        formData = wfMeta.getObject(["formData"])
        if formData is not None:
            formData = JsonSimple(formData)
            # Core fields
            description = formData.getStringList(["description"])
            if description:
                self.descriptionList = description
            # Non-core fields
            data = formData.getJsonObject()
            for field in data.keySet():
                if field not in coreFields:
                    self.customFields[field] = formData.getStringList([field])

        # Manifest processing (formData not present in wfMeta)
        manifest = self.__getJsonPayload(self.packagePid)
        formTitles = manifest.getStringList(["title"])
        if formTitles:
            for formTitle in formTitles:
                if self.title is None:
                    self.title = formTitle
        self.descriptionList = [manifest.getString("", ["description"])]
        formData = manifest.getJsonObject()
        for field in formData.keySet():
            if field not in coreFields:
                value = formData.get(field)
                if value is not None and value.strip() != "":
                    self.utils.add(self.index, field, value)
                    # We want to sort by date of creation, so it
                    # needs to be indexed as a date (ie. 'date_*')
                    if field == "dc:created":
                        parsedTime = time.strptime(value, "%Y-%m-%d")   
                        solrTime = time.strftime("%Y-%m-%dT%H:%M:%SZ", parsedTime)
                        self.utils.add(self.index, "date_created", solrTime)
                    # try to extract some common fields for faceting
                    if field.startswith("dc:") and \
                            not (field.endswith(".dc:identifier.rdf:PlainLiteral") \
                              or field.endswith(".dc:identifier") \
                              or field.endswith(".rdf:resource")):
                        # index dublin core fields for faceting
                        basicField = field.replace("dc:", "dc_")
#.........这里部分代码省略.........
开发者ID:qcif,项目名称:mint-multi-environment-demo,代码行数:103,代码来源:servicesUI2-rules.py

示例4: __workflow

# 需要导入模块: from com.googlecode.fascinator.common import JsonSimple [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonSimple import get [as 别名]
    def __workflow(self):
        # Workflow data
        WORKFLOW_ID = "dataset"
        wfChanged = False
        workflow_security = []
        self.message_list = None
        stages = self.config.getJsonSimpleList(["stages"])
        if self.owner == "guest":
            pageTitle = "Submission Request"
            displayType = "submission-request"
            initialStep = 0
        else:
            pageTitle = "Metadata Record"
            displayType = "package-dataset"
            initialStep = 1
        try:
            wfMeta = self.__getJsonPayload("workflow.metadata")
            wfMeta.getJsonObject().put("pageTitle", pageTitle)

            # Are we indexing because of a workflow progression?
            targetStep = wfMeta.getString(None, ["targetStep"])
            if targetStep is not None and targetStep != wfMeta.getString(None, ["step"]):
                wfChanged = True
                # Step change
                wfMeta.getJsonObject().put("step", targetStep)
                wfMeta.getJsonObject().remove("targetStep")
            # This must be a re-index then
            else:
                targetStep = wfMeta.getString(None, ["step"])

            # Security change
            for stage in stages:
                if stage.getString(None, ["name"]) == targetStep:
                    wfMeta.getJsonObject().put("label", stage.getString(None, ["label"]))
                    self.item_security = stage.getStringList(["visibility"])
                    workflow_security = stage.getStringList(["security"])
                    if wfChanged == True:
                        self.message_list = stage.getStringList(["message"])
        except StorageException:
            # No workflow payload, time to create
            initialStage = stages.get(initialStep).getString(None, ["name"])
            wfChanged = True
            wfMeta = JsonSimple()
            wfMetaObj = wfMeta.getJsonObject()
            wfMetaObj.put("id", WORKFLOW_ID)
            wfMetaObj.put("step", initialStage)
            wfMetaObj.put("pageTitle", pageTitle)
            stages = self.config.getJsonSimpleList(["stages"])
            for stage in stages:
                if stage.getString(None, ["name"]) == initialStage:
                    wfMetaObj.put("label", stage.getString(None, ["label"]))
                    self.item_security = stage.getStringList(["visibility"])
                    workflow_security = stage.getStringList(["security"])
                    self.message_list = stage.getStringList(["message"])

        # Has the workflow metadata changed?
        if wfChanged == True:
            inStream = IOUtils.toInputStream(wfMeta.toString(True), "UTF-8")
            try:
                StorageUtils.createOrUpdatePayload(self.object, "workflow.metadata", inStream)
            except StorageException:
                print " ERROR updating dataset payload"

        # Form processing
        coreFields = ["title", "description", "manifest", "metaList", "relationships", "responses"]
        formData = wfMeta.getObject(["formData"])
        if formData is not None:
            formData = JsonSimple(formData)
            # Core fields
            description = formData.getStringList(["description"])
            if description:
                self.descriptionList = description
            # Non-core fields
            data = formData.getJsonObject()
            for field in data.keySet():
                if field not in coreFields:
                    self.customFields[field] = formData.getStringList([field])

        # Manifest processing (formData not present in wfMeta)
        manifest = self.__getJsonPayload(self.packagePid)
        formTitles = manifest.getStringList(["title"])
        if formTitles:
            for formTitle in formTitles:
                if self.title is None:
                    self.title = formTitle
        self.descriptionList = [manifest.getString("", ["description"])]
        
        #Used to make sure we have a created date
        createdDateFlag  = False
        
        formData = manifest.getJsonObject()
        
        for field in formData.keySet():
            if field not in coreFields:
                value = formData.get(field)
                if value is not None and value.strip() != "":
                    self.utils.add(self.index, field, value)
                    # We want to sort by date of creation, so it
                    # needs to be indexed as a date (ie. 'date_*')
                    if field == "dc:created":
#.........这里部分代码省略.........
开发者ID:nishen,项目名称:redbox,代码行数:103,代码来源:dataset-rules.py

示例5: getResponses

# 需要导入模块: from com.googlecode.fascinator.common import JsonSimple [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonSimple import get [as 别名]
 def getResponses(self, storedObj):
     committeeResponsePayload = storedObj.getPayload(self.PAYLOAD)
     committeeResponses = JsonSimple(committeeResponsePayload.open()).getJsonObject()
     # get current assessor's assessment
     self.myResponse = committeeResponses.get(self.assessor)
     return committeeResponses
开发者ID:qcif,项目名称:rdsi-arms,代码行数:8,代码来源:Assessment.py

示例6: __activate__

# 需要导入模块: from com.googlecode.fascinator.common import JsonSimple [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonSimple import get [as 别名]
    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)
            # get relevant dc:description from new object before you overwrite it with 'from' data, as this should exist from form data created in initial object packaging (packaging.py)
            toTFPackageJson = JsonSimple(toTFPackage.open()).getJsonObject()
            relevant_description = toTFPackageJson.get("dc:description")
            fromInputStream = fromTFPackage.open()
            try:
                StorageUtils.createOrUpdatePayload(toObject, toTFPackage.getId(), fromInputStream)
            except StorageException:
                print "error setting tfPackage"
            finally:
                fromTFPackage.close()

            tfMetaPropertyValue = self.formData.get("tfMetaPropertyValue")
            if tfMetaPropertyValue == 'dmpToSelfSub':
                # fetch recently created new 'to' object from storage to get all data
                toTFPackage = self._getTFPackage(toObject)
                toTFPackageJson = JsonSimple(toTFPackage.open()).getJsonObject()
                self.setMultiDescription(toTFPackageJson, relevant_description)
                inStream = IOUtils.toInputStream(toTFPackageJson.toJSONString(), "UTF-8")
                try:
                    StorageUtils.createOrUpdatePayload(toObject, toTFPackage.getId(), inStream)
                except StorageException:
                    print "error setting description text in tfPackage"
                finally:
                    inStream.close()
                self.log.info(
                    "Completed migrating 'dc:description' to dc:decription.1.text' for oid: %s." % toTFPackage.getId())
                self.log.debug("Result: %r" % toTFPackageJson)

            fromTFPackageJson = JsonSimple(fromTFPackage.open()).getJsonObject()
            self.log.debug('from json is: %r' % fromTFPackageJson)
            if storeRelatedData != "false":
                # add relatedOid info
                fromTFPackageJson = self._addRelatedOid(JsonSimple(fromTFPackage.open()), toOid)

            self.log.debug('from tfPackage json is now: %r' % fromTFPackageJson)
            inStream = IOUtils.toInputStream(fromTFPackageJson.toJSONString(), "UTF-8")

            try:
                StorageUtils.createOrUpdatePayload(fromObject, fromTFPackage.getId(), inStream)
            except StorageException:
                print "error setting tfPackage"
            finally:
                inStream.close()

            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:redbox-mint,项目名称:redbox,代码行数:85,代码来源:copyTfPackage.py


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