本文整理汇总了Python中com.googlecode.fascinator.common.JsonSimple.getArray方法的典型用法代码示例。如果您正苦于以下问题:Python JsonSimple.getArray方法的具体用法?Python JsonSimple.getArray怎么用?Python JsonSimple.getArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.googlecode.fascinator.common.JsonSimple
的用法示例。
在下文中一共展示了JsonSimple.getArray方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: updateRelationships
# 需要导入模块: from com.googlecode.fascinator.common import JsonSimple [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonSimple import getArray [as 别名]
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)
示例2: updateLocalRecordRelations
# 需要导入模块: from com.googlecode.fascinator.common import JsonSimple [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonSimple import getArray [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)
示例3: __getUser
# 需要导入模块: from com.googlecode.fascinator.common import JsonSimple [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonSimple import getArray [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)
示例4: __activate__
# 需要导入模块: from com.googlecode.fascinator.common import JsonSimple [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonSimple import getArray [as 别名]
def __activate__(self, context):
try:
self.log = context["log"]
self.response = context["response"]
self.request = context["request"]
self.systemConfig = context["systemConfig"]
self.storage = context["Services"].getStorage()
self.indexer = context["Services"].getIndexer()
self.sessionState = context["sessionState"]
self.sessionState.set("username", "admin")
out = self.response.getPrintWriter("text/plain; charset=UTF-8")
relationshipMapper = ApplicationContextProvider.getApplicationContext().getBean("relationshipMapper")
externalCurationMessageBuilder = ApplicationContextProvider.getApplicationContext().getBean("externalCurationMessageBuilder")
oid = self.request.getParameter("oid")
if oid is None :
identifier = self.request.getParameter("identifier")
oid = self.findOidByIdentifier(identifier)
relationshipType = self.request.getParameter("relationship")
curatedPid = self.request.getParameter("curatedPid")
sourceId = self.request.getParameter("sourceIdentifier")
system = self.request.getParameter("system")
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
for relationship in relationships:
if relationship.get("identifier") == sourceId:
relationship.put("isCurated",True)
relationship.put("curatedPid",curatedPid)
found = True
if not found:
relationship = JsonObject()
relationship.put("isCurated",True)
relationship.put("curatedPid",curatedPid)
relationship.put("relationship",relationshipType)
relationship.put("identifier",sourceId)
relationship.put("system",system)
relationships.add(relationship)
out.println(metadataJson.toString(True))
istream = ByteArrayInputStream(String(metadataJson.toString(True)).getBytes())
StorageUtils.createOrUpdatePayload(digitalObject,"metadata.json",istream)
out.close()
finally:
self.sessionState.remove("username")
示例5: listHomes
# 需要导入模块: from com.googlecode.fascinator.common import JsonSimple [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonSimple import getArray [as 别名]
def listHomes(self):
term = self.request.getParameter("term")
writer = self.response.getPrintWriter("application/json; charset=UTF-8")
homeJsonBlock = JsonSimple(self.homeConfigFile)
writer.println("[")
count = 0
for homeObj in homeJsonBlock.getArray("institutions"):
if term is not None:
if homeObj.get("name").lower().find(term.lower()) > -1:
count = count +1
self.printHome(writer, homeObj, count)
else:
count = count + 1
self.printHome(writer, homeObj, count)
writer.println("]")
writer.close()
示例6: getLabel
# 需要导入模块: from com.googlecode.fascinator.common import JsonSimple [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonSimple import getArray [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
示例7: getLabel
# 需要导入模块: from com.googlecode.fascinator.common import JsonSimple [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonSimple import getArray [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
示例8: __activate__
# 需要导入模块: from com.googlecode.fascinator.common import JsonSimple [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonSimple import getArray [as 别名]
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.indexer = context["Services"].getIndexer()
self.storage = context["Services"].getStorage()
self.log = context["log"]
self.sessionState.set("username","admin")
self.writer = self.response.getPrintWriter("text/plain; charset=UTF-8")
publishedRecords = self.findPublishedRecords()
for publishedRecord in publishedRecords:
self.log.info("processing record "+publishedRecord.getString(None,"storage_id"))
digitalObject = StorageUtils.getDigitalObject(self.storage, publishedRecord.getString(None,"storage_id"))
tfPackage = self.getTfPackage(digitalObject)
metadata = digitalObject.getMetadata()
configObject = StorageUtils.getDigitalObject(self.storage,metadata.getProperty("jsonConfigOid"))
payload = configObject.getPayload(metadata.getProperty("jsonConfigPid"))
inStream = payload.open()
jsonConfig = JsonSimple(inStream)
payload.close()
requiredIdentifiers = jsonConfig.getArray("curation","requiredIdentifiers")
if requiredIdentifiers is not None:
pidName = self.systemConfig.getString(None,"curation","identifier-pids",requiredIdentifiers[0])
pid = metadata.getProperty(pidName)
identifier = tfPackage.getString(pid,"metadata","dc.identifier")
relationships = tfPackage.getArray("relationships")
if relationships is not None:
for relationship in relationships:
if relationship.get("broker") is None:
if relationship.get("system") is not None and relationship.get("system") != self.systemConfig.getString(None,"system"):
self.notifyExternalRelationship(relationship,pid,relationship.get("system"),identifier)
else:
self.updateRelationships(relationship,pid,identifier)
self.writer.close()
self.sessionState.remove("username")
示例9: getStageInfo
# 需要导入模块: from com.googlecode.fascinator.common import JsonSimple [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonSimple import getArray [as 别名]
def getStageInfo(self, workflowId):
uploader = self.uploaders.get(workflowId)
config = JsonSimple(File(StrSubstitutor.replaceSystemProperties(uploader.getString("", ["json-config"]))))
return StageInfo(config.getArray(["stages"]))