本文整理汇总了Python中au.edu.usq.fascinator.common.JsonSimple.toString方法的典型用法代码示例。如果您正苦于以下问题:Python JsonSimple.toString方法的具体用法?Python JsonSimple.toString怎么用?Python JsonSimple.toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类au.edu.usq.fascinator.common.JsonSimple
的用法示例。
在下文中一共展示了JsonSimple.toString方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __messages
# 需要导入模块: from au.edu.usq.fascinator.common import JsonSimple [as 别名]
# 或者: from au.edu.usq.fascinator.common.JsonSimple import toString [as 别名]
def __messages(self):
# Generic workflow messages
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)
# Camtasia integration
emailStep = self.params.getProperty("emailStep")
# First pass though... harvest queue
if emailStep is None:
emailStep = "emailOne"
# The next message
self.params.setProperty("emailStep", "emailTwo")
else:
# Second step... render queue
if emailStep == "emailTwo":
self.params.setProperty("emailStep", "completed")
if emailStep is not None and emailStep != "completed":
email = self.params.getProperty("relayEmail")
body = self.__getEmailBody(emailStep)
if email is not None and body is not None:
msg = JsonSimple()
msg.getJsonObject().put("to", email)
msg.getJsonObject().put("body", body)
message = msg.toString()
self.utils.sendMessage("emailnotification", message)
示例2: __messages
# 需要导入模块: from au.edu.usq.fascinator.common import JsonSimple [as 别名]
# 或者: from au.edu.usq.fascinator.common.JsonSimple import toString [as 别名]
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)
示例3: queryMoodle
# 需要导入模块: from au.edu.usq.fascinator.common import JsonSimple [as 别名]
# 或者: from au.edu.usq.fascinator.common.JsonSimple import toString [as 别名]
def queryMoodle(self):
username = self.vc("formData").get("username")
# We are going to bypass the authentication Jython
# object to directly access the moodle plugin.
self.roleManager.setActivePlugin("moodle")
roles = self.roleManager.getRoles(username)
if len(roles) == 0:
self.throw_error("The given user is invalid or has no courses.")
else:
roleIds = []
roleList = []
# For each role (courseId)
for role in roles:
thisRole = JsonSimple()
# Query the database for the course's name
name = self.__dbGet(role)
if name is not None:
roleIds.append("\"" + role + "\"")
thisRole.getJsonObject().put("name", name)
psData = self.__dbGetPS(role)
if psData is not None:
thisRole.getJsonObject().put("psData", psData)
roleList.append("\"" + role + "\" : " + thisRole.toString())
keys = "\"keys\" : [" + ",".join(roleIds) + "]"
data = "\"data\" : {" + ",".join(roleList) + "}"
response = "{" + keys + "," + data + "}"
self.writer.println(response)
self.writer.close()
示例4: get_image
# 需要导入模块: from au.edu.usq.fascinator.common import JsonSimple [as 别名]
# 或者: from au.edu.usq.fascinator.common.JsonSimple import toString [as 别名]
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
示例5: process_tags
# 需要导入模块: from au.edu.usq.fascinator.common import JsonSimple [as 别名]
# 或者: from au.edu.usq.fascinator.common.JsonSimple import toString [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) + "]"
示例6: modify_json
# 需要导入模块: from au.edu.usq.fascinator.common import JsonSimple [as 别名]
# 或者: from au.edu.usq.fascinator.common.JsonSimple import toString [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()
示例7: __init__
# 需要导入模块: from au.edu.usq.fascinator.common import JsonSimple [as 别名]
# 或者: from au.edu.usq.fascinator.common.JsonSimple import toString [as 别名]
class IndexData:
def __init__(self):
pass
def __activate__(self, context):
# Prepare variables
self.index = context["fields"]
self.object = context["object"]
self.payload = context["payload"]
self.params = context["params"]
self.utils = context["pyUtils"]
self.config = context["jsonConfig"]
self.wfSecurityExceptions = None
self.message_list = None
# Because the workflow messaging system wants access to this data
# BEFORE it actual hits the index we are going to cache it into an
# object payload too.
self.directIndex = JsonSimple()
# Common data
self.__newDoc()
# Real metadata
if self.itemType == "object":
self.__previews()
self.__basicData()
self.__metadata()
# Update the 'direct.index' payload - BEFORE messages are sent
directString = String(self.directIndex.toString())
inStream = ByteArrayInputStream(directString.getBytes("UTF-8"))
try:
StorageUtils.createOrUpdatePayload(self.object, "direct.index", inStream)
except StorageException, e:
print " * direct-files.py : Error updating direct payload"
self.__messages()
self.__displayType()
# Make sure security comes after workflows
self.__security()
示例8: __activate__
# 需要导入模块: from au.edu.usq.fascinator.common import JsonSimple [as 别名]
# 或者: from au.edu.usq.fascinator.common.JsonSimple import toString [as 别名]
def __activate__(self, context):
request = context["request"]
response = context["response"]
writer = response.getPrintWriter("text/javascript; charset=UTF-8")
result = JsonSimple()
## Look for the JSONP callback to use
jsonpCallback = request.getParameter("callback")
if jsonpCallback is None:
jsonpCallback = request.getParameter("jsonp_callback")
if jsonpCallback is None:
response.setStatus(403)
writer.println("Error: This interface only responds to JSONP")
writer.close()
return
if context["page"].authentication.is_logged_in():
result.getJsonObject().put("isAuthenticated", "true")
else:
result.getJsonObject().put("isAuthenticated", "false")
writer.println(jsonpCallback + "(" + result.toString() + ")")
writer.close()
示例9: str
# 需要导入模块: from au.edu.usq.fascinator.common import JsonSimple [as 别名]
# 或者: from au.edu.usq.fascinator.common.JsonSimple import toString [as 别名]
organizations = organizations.findall(ns+"organization")
organizations = [o for o in organizations if o.attrib.get("identifier")==defaultName]
organization = organizations[0]
title = organization.find(ns+"title").text
rvtMap.put("title", title)
items = organization.findall(ns+"item")
rvtMap.put("toc", self.__getJsonItems(ns, items, resources))
except Exception, e:
data["error"] = "Error - %s" % str(e)
print data["error"]
object.close()
except StorageException, e:
data["DEBUG"] = str(e.getMessage())
rvtManifest = JsonSimple(rvtMap)
return rvtManifest.toString()
def __getJsonItems(self, ns, items, resources):
rvtNodes = ArrayList()
for item in items:
attr = item.attrib
isvisible = attr.get("isvisible") == "true"
idref = attr.get("identifierref")
id = resources.get(idref)
title = item.find(ns+"title").text
if isvisible and id and id.endswith(".htm"):
rvtNode = HashMap()
rvtNode.put("visible", True)
rvtNode.put("relPath", id)
rvtNode.put("title", title)
rvtNode.put("children", self.__getJsonItems(ns, item.findall(ns+"item"), resources))