本文整理汇总了Python中au.edu.usq.fascinator.common.JsonConfigHelper类的典型用法代码示例。如果您正苦于以下问题:Python JsonConfigHelper类的具体用法?Python JsonConfigHelper怎么用?Python JsonConfigHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JsonConfigHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __search
def __search(self):
indexer = Services.getIndexer()
portalQuery = Services.getPortalManager().get(portalId).getQuery()
req = SearchRequest("last_modified:[NOW-1MONTH TO *]")
req.setParam("fq", 'item_type:"object"')
if portalQuery:
req.addParam("fq", portalQuery)
req.setParam("rows", "10")
req.setParam("sort", "last_modified desc, f_dc_title asc");
out = ByteArrayOutputStream()
indexer.search(req, out)
self.__latest = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
req = SearchRequest("*:*")
req.setParam("fq", 'item_type:"object"')
if portalQuery:
req.addParam("fq", portalQuery)
req.addParam("fq", "")
req.setParam("rows", "0")
out = ByteArrayOutputStream()
indexer.search(req, out)
sessionState.set("fq", 'item_type:"object"')
#sessionState.set("query", portalQuery.replace("\"", "'"))
self.__result = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
示例2: __messages
def __messages(self):
if self.message_list is not None and len(self.message_list) > 0:
msg = JsonConfigHelper()
msg.set("oid", self.oid)
message = msg.toString()
for target in self.message_list:
self.utils.sendMessage(target, message)
示例3: __init__
def __init__(self):
action = formData.get("verb")
portalName = formData.get("value")
sessionState.remove("fq")
if action == "delete-portal":
print " * home.py: delete portal %s" % portalName
Services.portalManager.remove(portalName)
if action == "backup-portal":
print "Backing up: ", portalName
backupPath = ""
email = ""
portal = Services.portalManager.get(portalName)
if portal:
email = portal.email
if portal.backupPaths:
for key in portal.backupPaths:
if portal.backupPaths[key]=="default":
backupPath = key
portalQuery = portal.getQuery()
#print " ***** portalQuery: ", portalQuery
#print " ***** backupPath: ", backupPath
#print " ***** email: ", email
#print " ***** description: ", description
if backupPath is None:
" ** Default backup path configured in system-config.json will be used "
Services.portalManager.backup(email, backupPath, portalQuery)
self.__latest = JsonConfigHelper()
self.__result = JsonConfigHelper()
self.__search()
示例4: __isLinked
def __isLinked(self, ids, map):
query = 'package_node_id:("' + '" OR "'.join(ids) + '")'
req = SearchRequest(query)
req.setParam("fq", 'recordtype:"master"')
req.addParam("fq", 'item_type:"object"')
req.setParam("rows", "9999")
out = ByteArrayOutputStream()
self.__indexer.search(req, out)
result = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
currentList = []
for doc in result.getJsonList("response/docs"):
currentList.extend(doc.getList("package_node_id"))
if type(map).__name__ == "LinkedHashMap":
for author in map.keySet():
authorDocs = map.get(author)
for doc in authorDocs:
if doc.get("id") in currentList:
doc.set("linked", "true")
else:
for author in map.keys():
authorList = map[author]
for count in authorList:
doc = authorList[count]
if doc.get("id") in currentList:
doc.set("linked", "true")
示例5: parseFFmpeg
def parseFFmpeg(self, parent):
if parent is not None:
object = parent.getObject()
if object is not None:
payload = None
try:
payload = object.getPayload("ffmpeg.info")
# Stream the content out to string
out = ByteArrayOutputStream()
IOUtils.copy(payload.open(), out)
payload.close()
self.__ffmpegRaw = out.toString("UTF-8")
out.close()
payload.close()
# And parse it
jsonData = JsonConfigHelper(self.__ffmpegRaw)
if jsonData is None:
return False
else:
self.__ffmpegData = jsonData.getJsonMap("/outputs")
return True
except:
if payload is not None:
payload.close()
return False
示例6: search_solr
def search_solr(self):
query = "(rootUri:"
if self.rootUriList:
query += "(" + " OR ".join(self.rootUriList) + ")"
else:
query += "\"" + self.rootUri + "\""
if self.type:
query += " AND type:\"" + self.type + "\""
query += ")"
#print "**********", query
req = SearchRequest(query)
req.setParam("facet", "false")
req.setParam("rows", str(99999))
req.setParam("sort", "dateCreated asc")
req.setParam("start", str(0))
#security_roles = page.authentication.get_roles_list();
#security_query = 'security_filter:("' + '" OR "'.join(security_roles) + '")'
#req.addParam("fq", security_query)
out = ByteArrayOutputStream()
Services.indexer.annotateSearch(req, out)
result = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
result = result.getJsonList("response/docs")
# Every annotation for this URI
if self.type == "http://www.purl.org/anotar/ns/type/0.1#Tag":
return self.process_tags(result)
else:
return self.process_response(result)
示例7: __getPackageTypes
def __getPackageTypes(self):
json = JsonConfigHelper(JsonConfig.getSystemFile())
packageTypes = json.getMap("portal/packageTypes")
packageTypes = dict(packageTypes)
if packageTypes=={}:
packageTypes["default"] = {"jsonconfig":"packaging-config.json"}
return packageTypes
示例8: __getStorageId
def __getStorageId(self, oid):
req = SearchRequest('id:"%s"' % oid)
req.addParam("fl", "storage_id")
out = ByteArrayOutputStream()
Services.indexer.search(req, out)
json = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
return json.getList("response/docs").get(0).get("storage_id")
示例9: __activate__
def __activate__(self, context):
self.velocityContext = context
self.vc("sessionState").remove("fq")
self.__latest = JsonConfigHelper()
self.__mine = JsonConfigHelper()
self.__workflows = JsonConfigHelper()
self.__result = JsonConfigHelper()
self.__search()
示例10: __getActiveManifest
def __getActiveManifest(self):
activeManifest = sessionState.get("package/active")
if not activeManifest:
activeManifest = JsonConfigHelper()
activeManifest.set("title", "New package")
activeManifest.set("viewId", portalId)
sessionState.set("package/active", activeManifest)
return activeManifest
示例11: getSuggestedNames
def getSuggestedNames(self):
# search common forms
lookupNames = []
surname = self.__metadata.getList("surname").get(0)
firstName = self.__metadata.getList("firstName").get(0)
firstInitial = firstName[0].upper()
secondName = self.__metadata.getList("secondName")
if not secondName.isEmpty():
secondName = secondName.get(0)
if secondName and secondName != "":
secondInitial = secondName[0].upper()
lookupNames.append("%s, %s. %s." % (surname, firstInitial, secondInitial))
lookupNames.append("%s, %s %s." % (surname, firstName, secondInitial))
lookupNames.append("%s, %s %s" % (surname, firstName, secondName))
lookupNames.append("%s %s %s" % (firstName, secondName, surname))
lookupNames.append("%s, %s." % (surname, firstInitial))
lookupNames.append("%s, %s" % (surname, firstName))
lookupNames.append("%s %s" % (firstName, surname))
query = '" OR dc_title:"'.join(lookupNames)
# general word search from each part of the name
parts = [p for p in self.getPackageTitle().split(" ") if len(p) > 0]
query2 = " OR dc_title:".join(parts)
req = SearchRequest('(dc_title:"%s")^2.5 OR (dc_title:%s)^0.5' % (query, query2))
self.log.info("suggestedNames query={}", req.query)
req.setParam("fq", 'recordtype:"author"')
req.addParam("fq", 'item_type:"object"')
req.setParam("rows", "9999")
req.setParam("fl", "score")
req.setParam("sort", "score desc")
# Make sure 'fq' has already been set in the session
##security_roles = self.authentication.get_roles_list();
##security_query = 'security_filter:("' + '" OR "'.join(security_roles) + '")'
##req.addParam("fq", security_query)
out = ByteArrayOutputStream()
indexer = self.services.getIndexer()
indexer.search(req, out)
result = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
# self.log.info("result={}", result.toString())
docs = result.getJsonList("response/docs")
map = LinkedHashMap()
for doc in docs:
authorName = doc.getList("dc_title").get(0)
if map.containsKey(authorName):
authorDocs = map.get(authorName)
else:
authorDocs = ArrayList()
map.put(authorName, authorDocs)
authorDocs.add(doc)
self.__maxScore = max(1.0, float(result.get("response/maxScore")))
return map
示例12: __search
def __search(self):
self.__result = JsonConfigHelper()
portal = self.services.getPortalManager().get(self.vc("portalId"))
recordsPerPage = portal.recordsPerPage
query = self.vc("formData").get("query")
if query is None or query == "":
query = "*:*"
req = SearchRequest(query)
req.setParam("facet", "true")
req.setParam("rows", str(recordsPerPage))
req.setParam("facet.field", portal.facetFieldList)
req.setParam("facet.limit", str(portal.facetCount))
req.setParam("sort", "f_dc_title asc")
portalQuery = portal.query
print " * portalQuery=%s" % portalQuery
if portalQuery:
portalQuery += "&item_type:object"
else:
portalQuery += "item_type:object"
req.addParam("fq", portalQuery)
#Check if there's resumption token exist in the formData
if self.__currentToken:
start = self.__currentToken.getStart()
totalFound = self.__currentToken.getTotalFound()
nextTokenStart = start+recordsPerPage
if nextTokenStart < totalFound:
self.__token = ResumptionToken(start=nextTokenStart, metadataPrefix=self.__metadataPrefix, sessionExpiry=self.__sessionExpiry)
else:
start = 0
metadataPrefix = self.vc("formData").get("metadataPrefix")
self.__token = ResumptionToken(start=recordsPerPage, metadataPrefix=self.__metadataPrefix, sessionExpiry=self.__sessionExpiry)
req.setParam("start", str(start))
print " * oai.py:", req.toString()
out = ByteArrayOutputStream()
self.services.indexer.search(req, out)
self.__result = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
totalFound = int(self.__result.get("response/numFound"))
if totalFound == 0:
self.__token = None
elif self.__token:
if self.__token.getStart() < totalFound:
self.__token.setTotalFound(totalFound)
else:
self.__token = None
#Storing the resumptionToken to session
if self.__token:
self.__resumptionTokenList[self.__token.getToken()] = self.__token #(totalFound, self.__token.getConstructedToken())
#Need to know how long the server need to store this token
self.sessionState.set("resumptionTokenList", self.__resumptionTokenList)
示例13: test
def test(self):
s = "data "
json = JsonConfigHelper()
try:
l = json.getList("test")
s += str(l.size())
s += " '%s' " % json.get("test1")
except Exception, e:
s += "Error '%s'" % str(e)
示例14: __metadata
def __metadata(self):
ISOCode = self.params.getProperty("ISOcode")
print "*** Processing: ", ISOCode
#Index the country metadata
metadataPayload = self.object.getPayload("%s.json" % ISOCode)
json = JsonConfigHelper(metadataPayload.open())
allMeta = json.getMap(".")
self.utils.add(self.index, "recordType", "country")
for key in allMeta.keySet():
self.utils.add(self.index, key, allMeta.get(key));
metadataPayload.close()
#Index the country detail
geoNamePayload = self.object.getPayload("%s.txt" % ISOCode)
countryName = self.params.getProperty("countryName")
countryAreaStream = geoNamePayload.open()
reader = BufferedReader(InputStreamReader(countryAreaStream, "UTF-8"));
line = reader.readLine()
headerList = ["geonameid", "name", "asciiname", "alternatenames", "latitude", "longitude", \
"feature class", "feature code", "country code", "cc2", "admin1 code", "admin2 code", \
"admin3 code", "admin4 code", "population", "elevation", "gtopo30", "timezone", "modification date"]
while (line != None):
arraySplit = line.split("\t")
geonamesId = arraySplit[0]
oid = DigestUtils.md5Hex("http://geonames.org/" + geonamesId)
if oid == self.oid:
extraIndex = self.index
else:
extraIndex = HashMap()
self.utils.add(extraIndex, "recordType", "area")
self.utils.add(extraIndex, "item_type", self.itemType)
self.utils.add(extraIndex, "dc_identifier", oid)
self.utils.add(extraIndex, "id", oid)
self.utils.add(extraIndex, "storage_id", self.oid) #Use parent object
self.utils.add(extraIndex, "last_modified", time.strftime("%Y-%m-%dT%H:%M:%SZ"))
self.utils.add(extraIndex, "display_type", "geonames")
self.utils.add(extraIndex, "countryName", countryName)
self.utils.add(extraIndex, "repository_name", self.params["repository.name"])
self.utils.add(extraIndex, "repository_type", self.params["repository.type"])
self.utils.add(extraIndex, "security_filter", "guest")
self.utils.add(extraIndex, "dc_title", arraySplit[1])
# The rest of the metadata
count = 0
for array in arraySplit:
if headerList[count] !="alternatenames" and array:
self.utils.add(extraIndex, headerList[count], array)
count +=1
self.indexer.sendIndexToBuffer(oid, extraIndex)
line = reader.readLine()
geoNamePayload.close()
示例15: __getManifest
def __getManifest(self, oid):
object = self.services.getStorage().getObject(oid)
sourceId = object.getSourceId()
payload = object.getPayload(sourceId)
payloadReader = InputStreamReader(payload.open(), "UTF-8")
manifest = JsonConfigHelper(payloadReader)
payloadReader.close()
payload.close()
object.close()
return manifest.getJsonMap("manifest")