本文整理汇总了Python中au.edu.usq.fascinator.common.JsonSimple.getString方法的典型用法代码示例。如果您正苦于以下问题:Python JsonSimple.getString方法的具体用法?Python JsonSimple.getString怎么用?Python JsonSimple.getString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类au.edu.usq.fascinator.common.JsonSimple
的用法示例。
在下文中一共展示了JsonSimple.getString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_tags
# 需要导入模块: from au.edu.usq.fascinator.common import JsonSimple [as 别名]
# 或者: from au.edu.usq.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) + "]"
示例2: modify_json
# 需要导入模块: from au.edu.usq.fascinator.common import JsonSimple [as 别名]
# 或者: from au.edu.usq.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()
示例3: __workflow
# 需要导入模块: from au.edu.usq.fascinator.common import JsonSimple [as 别名]
# 或者: from au.edu.usq.fascinator.common.JsonSimple import getString [as 别名]
def __workflow(self):
# Workflow data
WORKFLOW_ID = "usq"
wfChanged = False
workflow_security = []
try:
wfPayload = self.object.getPayload("workflow.metadata")
wfMeta = self.utils.getJsonObject(wfPayload.open())
wfPayload.close()
# 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
stages = self.config.getJsonSimpleList(["stages"])
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"])
# Form processing
formData = wfMeta.getObject(["formData"])
if formData is not None:
formData = JsonSimple(formData)
else:
formData = None
coreFields = ["title", "creator", "contributor", "description", "format", "creationDate"]
if formData is not None:
# Core fields
title = formData.getStringList(["title"])
if title:
self.titleList = title
creator = formData.getStringList(["creator"])
if creator:
self.creatorList = creator
contributor = formData.getStringList(["contributor"])
if contributor:
self.contributorList = contributor
description = formData.getStringList(["description"])
if description:
self.descriptionList = description
format = formData.getStringList(["format"])
if format:
self.formatList = format
creation = formData.getStringList(["creationDate"])
if creation:
self.creationDate = creation
# Course security - basic
course = formData.getString(None, ["course_code"])
if course:
self.item_security.add(course)
# Course security - moodle
moodle_courses = formData.getString(None, ["moodleSecurity"])
if moodle_courses:
moodleList = moodle_courses.split(",")
for course in moodleList:
if course != "":
self.item_security.add(course)
# Course facets - Peoplesoft
psMoodle_courses = formData.getString(None, ["psMoodle"])
if psMoodle_courses:
psMoodleList = psMoodle_courses.split(",")
for course in psMoodleList:
if course != "":
self.__indexCourse(course)
# Non-core fields
data = formData.getJsonObject()
for field in data.keySet():
if field not in coreFields:
data = formData.getStringList([field])
if field.startswith("dc_subject."):
subjectField = "dc_subject"
if self.customFields.has_key(subjectField):
subjectList = self.customFields[subjectField]
if subjectList:
for subject in subjectList:
data.add(subject)
field = subjectField
self.customFields[field] = data
except StorageException, e:
# No workflow payload, time to create
wfChanged = True
wfMeta = JsonSimple()
wfMetaObj = wfMeta.getJsonObject()
wfMetaObj.put("id", WORKFLOW_ID)
wfMetaObj.put("step", "pending")
#.........这里部分代码省略.........