本文整理了Java中org.xwiki.query.Query.setWiki
方法的一些代码示例,展示了Query.setWiki
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.setWiki
方法的具体详情如下:
包路径:org.xwiki.query.Query
类名称:Query
方法名:setWiki
暂无
代码示例来源:origin: org.xwiki.platform/xwiki-platform-query-manager
@Override
public Query setWiki(String wiki)
{
this.query.setWiki(wiki);
return this;
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-query-manager
@Override
public Query setWiki(String wiki)
{
return getWrappedQuery().setWiki(wiki);
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-search-solr-api
@Override
public long size()
{
long size = 0;
try {
getQuery();
for (String wikiName : getWikis()) {
size += (long) countQuery.setWiki(wikiName).execute().get(0);
}
} catch (QueryException e) {
logger.error("Failed to count the documents.", e);
}
return size;
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-wikistream-instance-oldcore
@Override
public List<String> getSpaces(String wiki) throws WikiStreamException
{
try {
return this.queryManager.getNamedQuery("getSpaces").setWiki(wiki).execute();
} catch (QueryException e) {
throw new WikiStreamException(String.format("Failed to get the list of spaces in wiki [%s]", wiki), e);
}
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-search-solr-api
/**
* Fetches the next 'page' of results from the database.
*/
private void fetchNextResults()
{
try {
// We use basic pagination (absolute offset) because we don't expect the database to change too much while
// the synchronization takes place. Also, the database is used as the reference store, meaning that we
// update the Solr index to match the database, not the other way around.
results = getQuery().setWiki(wiki).setOffset(offset).execute();
offset += LIMIT;
} catch (QueryException e) {
results = Collections.emptyList();
logger.error("Failed to query the database.", e);
}
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-wiki-template-default
@Override
public Collection<WikiDescriptor> getTemplates() throws WikiTemplateManagerException
{
List<WikiDescriptor> result = new ArrayList<WikiDescriptor>();
try {
Query query = this.queryManager.createQuery(
"from doc.object(WikiManager.WikiTemplateClass) as descriptor where doc.name like 'XWikiServer%' "
+ "and descriptor.iswikitemplate = 1", Query.XWQL);
query.setWiki(xcontextProvider.get().getMainXWiki());
List<String> documentNames = query.execute();
if (documentNames != null && !documentNames.isEmpty()) {
for (String documentName : documentNames) {
String id = documentName.substring("XWiki.XWikiServer".length()).toLowerCase();
result.add(wikiDescriptorManager.getById(id));
}
}
} catch (Exception e) {
throw new WikiTemplateManagerException("Failed to locate XWiki.XWikiServerClass documents", e);
}
return result;
}
代码示例来源:origin: org.phenotips/pingback-client-api
@Override
public Map<String, Object> provideData()
{
Map<String, Object> jsonMap = new HashMap<>();
try {
Query q = this.qm.createQuery("from doc.object(XWiki.XWikiUsers) as user", Query.XWQL);
q.addFilter(this.countFilter);
long count = 0;
for (String instanceId : this.wikiManager.getAllIds()) {
q.setWiki(instanceId);
List<Object> results = q.execute();
long instanceCount = (long) results.get(0);
count += instanceCount;
}
jsonMap.put(PROPERTY_USER_COUNT, count);
} catch (QueryException | WikiManagerException e) {
logWarning("Error getting users count", e);
}
return jsonMap;
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-wiki-default
@Override
public DocumentReference findXWikiServerClassDocumentReference(String wikiAlias) throws WikiManagerException
{
if (wikiAlias == null) {
throw new IllegalArgumentException("Wiki alias cannot be null");
}
WikiDescriptorManager wikiDescriptorManager = wikiDescriptorManagerProvider.get();
DocumentReference result = null;
try {
Query query = this.queryManager.createQuery(
"where doc.object(XWiki.XWikiServerClass).server = :wikiAlias and doc.name like 'XWikiServer%'",
Query.XWQL);
query.bindValue("wikiAlias", wikiAlias);
query.setWiki(wikiDescriptorManager.getMainWikiId());
List<String> documentNames = query.execute();
// Resolve the document name into a references
if (documentNames != null && !documentNames.isEmpty()) {
result = documentReferenceResolver.resolve(documentNames.get(0));
}
} catch (QueryException e) {
throw new WikiManagerException(String.format(
"Failed to locate XWiki.XWikiServerClass document for wiki alias [%s]", wikiAlias), e);
}
return result;
}
代码示例来源:origin: org.phenotips/pingback-client-api
@Override
public Map<String, Object> provideData()
{
Map<String, Object> jsonMap = new HashMap<>();
try {
Query q = this.qm.createQuery(
"from doc.object(PhenoTips.PatientClass) as patient "
+ "where doc.fullName<>'PhenoTips.PatientTemplate'",
Query.XWQL);
q.addFilter(this.countFilter);
long count = 0;
for (String instanceId : this.wikiManager.getAllIds()) {
q.setWiki(instanceId);
List<Object> results = q.execute();
long instanceCount = (long) results.get(0);
count += instanceCount;
}
jsonMap.put(PROPERTY_PATIENT_COUNT, count);
} catch (QueryException | WikiManagerException e) {
logWarning("Error getting patient count", e);
}
return jsonMap;
}
代码示例来源:origin: org.phenotips/pingback-client-api
@Override
public Map<String, Object> provideData()
{
Map<String, Object> jsonMap = new HashMap<>();
try {
Query q = this.qm.createQuery(
"from doc.object(PhenoTips.FamilyClass) as family "
+ "where doc.fullName<>'PhenoTips.FamilyTemplate'",
Query.XWQL);
q.addFilter(this.countFilter);
long count = 0;
for (String instanceId : this.wikiManager.getAllIds()) {
q.setWiki(instanceId);
List<Object> results = q.execute();
long instanceCount = (long) results.get(0);
count += instanceCount;
}
jsonMap.put(PROPERTY_FAMILIES_COUNT, count);
} catch (QueryException | WikiManagerException e) {
logWarning("Error getting families count", e);
}
return jsonMap;
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-wikistream-instance-oldcore
@Override
public List<String> getDocuments(String wiki, String space) throws WikiStreamException
{
try {
Query query =
this.queryManager
.createQuery(
"select distinct doc.name from Document doc where doc.space = :space order by doc.name asc",
Query.XWQL);
query.bindValue("space", space);
query.setWiki(wiki);
return query.execute();
} catch (QueryException e) {
throw new WikiStreamException(String.format(
"Failed to get the list of documents in wiki [%s] and space [%s]", wiki, space), e);
}
}
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-refactoring-default
@Override
public List<DocumentReference> getDocumentReferences(SpaceReference spaceReference)
{
try {
// At the moment we don't have a way to retrieve only the direct children so we select all the descendants.
// This means we select all the documents from the specified space and from all the nested spaces.
String statement = "select distinct(doc.fullName) from XWikiDocument as doc "
+ "where doc.space = :space or doc.space like :spacePrefix escape '/'";
Query query = this.queryManager.createQuery(statement, Query.HQL);
query.setWiki(spaceReference.getWikiReference().getName());
String localSpaceReference = this.localEntityReferenceSerializer.serialize(spaceReference);
query.bindValue("space", localSpaceReference);
String spacePrefix = LIKE_SPECIAL_CHARS.matcher(localSpaceReference).replaceAll("/$1");
query.bindValue("spacePrefix", spacePrefix + ".%");
List<DocumentReference> descendants = new ArrayList<>();
for (Object fullName : query.execute()) {
descendants.add(this.explicitDocumentReferenceResolver.resolve((String) fullName, spaceReference));
}
return descendants;
} catch (Exception e) {
this.logger.error("Failed to retrieve the documents from [{}].", spaceReference, e);
return Collections.emptyList();
}
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-search-solr-api
@Override
public List<EntityReference> getReferences(EntityReference wikiReference) throws SolrIndexerException
{
List<EntityReference> result = new ArrayList<EntityReference>();
// Ignore the wiki reference because it is not indexable.
List<String> localSpaceRefs = null;
// Make sure the list of spaces is from the requested wiki.
try {
localSpaceRefs = this.queryManager.getNamedQuery("getSpaces").setWiki(wikiReference.getName()).execute();
} catch (QueryException e) {
throw new SolrIndexerException("Failed to query wiki [" + wikiReference.getName() + "] spaces", e);
}
// Visit each space
for (String localSpaceRef : localSpaceRefs) {
EntityReference spaceReference =
this.explicitEntityReferenceResolver.resolve(localSpaceRef, EntityType.SPACE, wikiReference);
try {
Iterables.addAll(result, this.spaceResolverProvider.get().getReferences(spaceReference));
} catch (Exception e) {
this.logger.error("Failed to resolve references for space [" + spaceReference + "]", e);
}
}
return result;
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-watchlist-api
jobDocumentsQuery.setWiki(context.getWikiId());
List<String> jobDocumentNames = jobDocumentsQuery.execute();
代码示例来源:origin: org.xwiki.platform/xwiki-platform-localization-source-wiki
private void loadTranslations(String wiki)
{
XWikiContext xcontext = this.xcontextProvider.get();
WikiReference wikiReference = new WikiReference(wiki);
try {
Query query =
this.queryManager.createQuery(String.format(
"select distinct doc.fullName from Document doc, doc.object(%s) as translation",
TranslationDocumentModel.TRANSLATIONCLASS_REFERENCE_STRING), Query.XWQL);
query.setWiki(wiki);
List<String> documents = query.execute();
for (String documentName : documents) {
DocumentReference reference = currentResolver.resolve(documentName, wikiReference);
XWikiDocument document = xcontext.getWiki().getDocument(reference, xcontext);
try {
registerTranslationBundle(document);
} catch (Exception e) {
this.logger.error("Failed to register translation bundle from document [{}]",
document.getDocumentReference(), e);
}
}
} catch (Exception e) {
this.logger.error("Failed to load existing translations", e);
}
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-wiki-default
@Override
public List<String> getAllXWikiServerClassDocumentNames() throws WikiManagerException
{
WikiDescriptorManager wikiDescriptorManager = wikiDescriptorManagerProvider.get();
try {
Query query = this.queryManager.createQuery(
"from doc.object(XWiki.XWikiServerClass) as descriptor where doc.name like 'XWikiServer%' "
+ "and doc.fullName <> 'XWiki.XWikiServerClassTemplate'",
Query.XWQL);
query.setWiki(wikiDescriptorManager.getMainWikiId());
query.addFilter(componentManager.<QueryFilter>getInstance(QueryFilter.class, "unique"));
return query.execute();
} catch (Exception e) {
throw new WikiManagerException("Failed to locate XWiki.XWikiServerClass documents", e);
}
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-search-solr-api
@Override
public List<EntityReference> getReferences(EntityReference spaceReference) throws SolrIndexerException
{
List<EntityReference> result = new ArrayList<EntityReference>();
EntityReference wikiReference = spaceReference.extractReference(EntityType.WIKI);
String localSpaceReference = this.localEntityReferenceSerializer.serialize(spaceReference);
// Ignore the space reference because it is not indexable.
// Make sure the list of spaces is from the requested wiki
List<String> documentNames;
try {
documentNames =
this.queryManager.getNamedQuery("getSpaceDocsName").setWiki(wikiReference.getName())
.bindValue("space", localSpaceReference).execute();
} catch (QueryException e) {
throw new SolrIndexerException("Failed to query space [" + spaceReference + "] documents", e);
}
for (String documentName : documentNames) {
EntityReference documentReference = new EntityReference(documentName, EntityType.DOCUMENT, spaceReference);
try {
Iterables.addAll(result, this.documentResolverProvider.get().getReferences(documentReference));
} catch (Exception e) {
this.logger.error("Failed to resolve references for document [" + documentReference + "]", e);
}
}
return result;
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-query-manager
countQuery.setWiki(getWiki());
for (Map.Entry<Integer, Object> entry : getPositionalParameters().entrySet()) {
countQuery.bindValue(entry.getKey(), entry.getValue());
代码示例来源:origin: org.xwiki.platform/xwiki-platform-notifications-filters-default
query.bindValue("owner", serializedUser);
if (activityStreamConfiguration.useMainStore()) {
query.setWiki(context.getMainXWiki());
代码示例来源:origin: org.xwiki.platform/xwiki-platform-refactoring-default
.setLimit(queryLimit)
.bindValue("className", className)
.setWiki(classReference.getWikiReference().getName())
.<String>execute();
内容来源于网络,如有侵权,请联系作者删除!