本文整理汇总了Python中java.util.HashSet.isEmpty方法的典型用法代码示例。如果您正苦于以下问题:Python HashSet.isEmpty方法的具体用法?Python HashSet.isEmpty怎么用?Python HashSet.isEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.HashSet
的用法示例。
在下文中一共展示了HashSet.isEmpty方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: findMessages
# 需要导入模块: from java.util import HashSet [as 别名]
# 或者: from java.util.HashSet import isEmpty [as 别名]
def findMessages(mc,custid,count):
print 'findMessages() find ',count
amsm = mc.getActiveMailboxStoreManager()
ids = HashSet()
msgs = HashSet()
retries = 30
while msgs.size() < count and retries > 0:
for p in mc.getPartitionManager().listPartitions():
if p.isReadOnly():
continue
print 'searching for messages to be stored in',p
tm = amsm.findMessages([SearchConstraint(IActiveMailboxStoreManager.PROP_CUST_ID, SearchConstraintOperator.CONSTRAINT_EQUALS,int(custid))],p)
if tm.size() > 0:
msgs.addAll(filter(lambda x : not ids.contains(x.getMessageId()),tm))
ids.addAll(map(lambda x : x.getMessageId(), tm))
if msgs.size() < count:
time.sleep(10)
retries = retries - 1
print 'findMessages found',msgs.size(),'ids',ids.size()
if msgs.isEmpty():
print 'Failed to find any messages in DB'
raise Exception('Failed to find any messages in DB')
if msgs.size() < count:
print 'Warning, did not find all messages expected'
return msgs
示例2: findMessages
# 需要导入模块: from java.util import HashSet [as 别名]
# 或者: from java.util.HashSet import isEmpty [as 别名]
def findMessages(mc,custid,count, includeCategorizedRecipients=False):
print 'findMessages() should find ',count
amsm = mc.getActiveMailboxStoreManager()
msgs = HashSet()
retries = 15
while msgs.size() < count and retries > 0:
for p in mc.getPartitionManager().listPartitions():
if p.isReadOnly():
continue
print 'searching for messages to be stored in',p
tm = amsm.findMessages([SearchConstraint(IActiveMailboxStoreManager.PROP_CUST_ID, SearchConstraintOperator.CONSTRAINT_EQUALS,int(custid))],p,includeCategorizedRecipients)
if tm.size() > 0:
msgs.addAll(tm)
if msgs.size() < count:
time.sleep(10)
retries = retries - 1
print 'findMessages() found',msgs.size()
if msgs.isEmpty():
print 'Failed to find any messages in DB'
raise Exception('Failed to find any messages in DB')
if msgs.size() < count:
print 'Warning, did not find all messages expected'
return msgs
示例3: completeComponentSet
# 需要导入模块: from java.util import HashSet [as 别名]
# 或者: from java.util.HashSet import isEmpty [as 别名]
def completeComponentSet(cls, componentSet):
""" generated source for method completeComponentSet """
newComponents = HashSet()
componentsToTry = HashSet(componentSet)
while not componentsToTry.isEmpty():
for c in componentsToTry:
for out in c.getOutputs():
if not componentSet.contains(out):
newComponents.add(out)
for in_ in c.getInputs():
if not componentSet.contains(in_):
newComponents.add(in_)
componentSet.addAll(newComponents)
componentsToTry = newComponents
newComponents = HashSet()
示例4: __activate__
# 需要导入模块: from java.util import HashSet [as 别名]
# 或者: from java.util.HashSet import isEmpty [as 别名]
def __activate__(self, context):
response = context["response"]
log = context["log"]
writer = response.getPrintWriter("text/plain; charset=UTF-8")
auth = context["page"].authentication
sessionState = context["sessionState"]
result = JsonObject()
result.put("status", "error")
result.put("message", "An unknown error has occurred")
if auth.is_admin():
services = context["Services"]
formData = context["formData"]
func = formData.get("func")
oid = formData.get("oid")
portalId = formData.get("portalId")
portalManager = services.portalManager
if func == "reharvest":
# One object
if oid:
log.info(" * Reharvesting object '{}'", oid)
portalManager.reharvest(oid)
result.put("status", "ok")
result.put("message", "Object '%s' queued for reharvest")
# The whole portal
elif portalId:
log.info(" * Reharvesting view '{}'", portalId)
sessionState.set("reharvest/running/" + portalId, "true")
# TODO security filter - not necessary because this requires admin anyway?
portal = portalManager.get(portalId)
query = "*:*"
if portal.query != "":
query = portal.query
if portal.searchQuery != "":
if query == "*:*":
query = portal.searchQuery
else:
query = query + " AND " + portal.searchQuery
# query solr to get the objects to reharvest
rows = 25
req = SearchRequest(query)
req.setParam("fq", 'item_type:"object"')
req.setParam("rows", str(rows))
req.setParam("fl", "id")
done = False
count = 0
while not done:
req.setParam("start", str(count))
out = ByteArrayOutputStream()
services.indexer.search(req, out)
json = SolrResult(ByteArrayInputStream(out.toByteArray()))
objectIds = HashSet(json.getFieldList("id"))
if not objectIds.isEmpty():
portalManager.reharvest(objectIds)
count = count + rows
total = json.getNumFound()
log.info(" * Queued {} of {}...", (min(count, total), total))
done = (count >= total)
sessionState.remove("reharvest/running/" + portalId)
result.put("status", "ok")
result.put("message", "Objects in '%s' queued for reharvest" % portalId)
else:
response.setStatus(500)
result.put("message", "No object or view specified for reharvest")
elif func == "reindex":
if oid:
log.info(" * Reindexing object '{}'", oid)
services.indexer.index(oid)
services.indexer.commit()
result.put("status", "ok")
result.put("message", "Object '%s' queued for reindex" % portalId)
else:
response.setStatus(500)
result.put("message", "No object specified to reindex")
else:
response.setStatus(500)
result.put("message", "Unknown action '%s'" % func)
else:
response.setStatus(500)
result.put("message", "Only administrative users can access this API")
writer.println(result.toString())
writer.close()
示例5: __init__
# 需要导入模块: from java.util import HashSet [as 别名]
# 或者: from java.util.HashSet import isEmpty [as 别名]
def __init__(self):
print "formData=%s" % formData
func = formData.get("func")
result = "{}"
resultType = "text/plain; charset=UTF-8"
oid = formData.get("oid")
portalId = formData.get("portalId")
portalManager = Services.getPortalManager()
if func == "reharvest":
if oid:
print "Reharvesting single object: %s" % oid
portalManager.reharvest(oid)
result = '{ status: "ok" }'
elif portalId:
portal = portalManager.get(portalId)
print " Reharvesting portal: %s" % portal.getName()
indexer = Services.getIndexer()
# TODO security filter
# TODO this should loop through the whole portal,
# not just the first page of results
if portal.getQuery() == "":
searchRequest = SearchRequest("item_type:object")
else:
searchRequest = SearchRequest(portal.getQuery())
result = ByteArrayOutputStream();
Services.getIndexer().search(searchRequest, result)
json = JsonConfigHelper(ByteArrayInputStream(result.toByteArray()))
objectIds = HashSet()
for doc in json.getJsonList("response/docs"):
objectIds.add(doc.get("id"))
if not objectIds.isEmpty():
portalManager.reharvest(objectIds)
result = '{ status: "ok" }'
else:
result = '{ status: "failed" }'
elif func == "get-state":
result = '{ running: "%s", lastResult: "%s" }' % \
(sessionState.get("reharvest/running"),
sessionState.get("reharvest/lastResult"))
elif func == "get-log":
context = LoggerFactory.getILoggerFactory()
logger = context.getLogger("au.edu.usq.fascinator.HarvestClient")
appender = logger.getAppender("CYCLIC")
layout = HTMLLayout()
layout.setContext(context)
layout.setPattern("%d%msg")
layout.setTitle("Reharvest log")
layout.start()
result = "<table>"
count = appender.getLength()
if count == -1:
result += "<tr><td>Failed</td></tr>"
elif count == 0:
result += "<tr><td>No logging events</td></tr>"
else:
for i in range(0, count):
event = appender.get(i)
result += layout.doLayout(event)
result += "</table>"
resultType = "text/html; charset=UTF-8"
writer = response.getPrintWriter(resultType)
writer.println(result)
writer.close()