@Override public <T> List<T> execute() throws QueryException { return this.query.execute(); }
private List<String> getAllTags() throws QueryException { String query = "select distinct elements(prop.list) from BaseObject as obj, " + "DBStringListProperty as prop where obj.className='XWiki.TagClass' " + "and obj.id=prop.id.id and prop.id.name='tags'"; List<String> tags = queryManager.createQuery(query, Query.HQL).execute(); Collections.sort(tags, String.CASE_INSENSITIVE_ORDER); return tags; } }
@Override public <T> List<T> execute() throws QueryException { return getWrappedQuery().execute(); } }
/** * Execute the query. * * @return the query result. * @throws java.io.IOException on encoding error. * @throws QueryException on query error. */ protected <T> List<T> execute() throws IOException, QueryException { return getQuery().execute(); } }
private List<String> getDocumentsWithTag(String tag) throws QueryException { String query = "select doc.fullName from XWikiDocument as doc, BaseObject as obj, DBStringListProperty as prop " + "where obj.name=doc.fullName and obj.className='XWiki.TagClass' and obj.id=prop.id.id " + "and prop.id.name='tags' and :tag in elements(prop.list) order by doc.name asc"; List<String> documentsWithTag = queryManager.createQuery(query, Query.HQL).bindValue("tag", tag).execute(); return documentsWithTag; } }
private List<String> runQuery(String queryString, String input) { String formattedInput = String.format(PhenotipsFamilyExport.INPUT_FORMAT, input.toLowerCase()); // Query patients Query query = null; List<String> queryResults = null; try { query = this.qm.createQuery(queryString, Query.XWQL); query.bindValue(PhenotipsFamilyExport.INPUT_PARAMETER, formattedInput); queryResults = query.execute(); } catch (QueryException e) { this.logger.error("Error while performing patients/families query: [{}] ", e.getMessage()); return Collections.emptyList(); } return queryResults; }
@Override public List<String> getIconSetNames() throws IconException { try { String xwql = "SELECT obj.name FROM Document doc, doc.object(IconThemesCode.IconThemeClass) obj " + "ORDER BY obj.name"; Query query = queryManager.createQuery(xwql, Query.XWQL); return query.execute(); } catch (QueryException e) { throw new IconException("Failed to get the name of all icon sets.", e); } } }
@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; }
@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); } }
/** * Retrieves and collects patient entities that correspond to the provided external ID. * * @param patientsBuilder a patient entity set builder * @param eids external patient IDs, as a list * @throws QueryException if the query fails */ private void collectPatientsFromEids(@Nonnull final ImmutableSet.Builder<PrimaryEntity> patientsBuilder, @Nonnull final List<Object> eids) throws QueryException { final Query q = this.qm.createQuery("from doc.object(PhenoTips.PatientClass) p where p.external_id in (:eids)", Query.XWQL); q.bindValue("eids", eids); final List<Object> patientIds = q.execute(); addIds(patientsBuilder, patientIds); }
protected Patient getPatientByGUID(String guid) { try { Query q = this.queryManager.createQuery("from doc.object(PhenoTips.PatientClass) as o where o.guid = :guid", Query.XWQL).bindValue("guid", guid); List<String> results = q.<String>execute(); if (results.size() == 1) { DocumentReference reference = this.stringResolver.resolve(results.get(0), Patient.DEFAULT_DATA_SPACE); return new PhenoTipsPatient((XWikiDocument) this.bridge.getDocument(reference)); } } catch (Exception ex) { this.logger.warn("Failed to get patient with GUID [{}]: [{}] {}", guid, ex.getMessage(), ex); } return null; }
/** * Execute the query. * * @param subject the subject name * @return the query result. * @throws QueryException on query error. */ protected <T> List<T> execute(PrincipalIndentifier subject) throws QueryException { return getQuery().bindValue(SUBJECT, subject.getName()).execute(); }
/** * Execute the query. * * @param issuer the issuer name. * @param serial the serial number. * @return the query result. * @throws QueryException on query error. */ protected <T> List<T> execute(PrincipalIndentifier issuer, BigInteger serial) throws QueryException { return getQuery().bindValue(ISSUER, issuer.getName()).bindValue(SERIAL, serial.toString()).execute(); }
/** * Execute the query. * * @param keyId the subject key identifier. * @return the query result. * @throws IOException on encoding error. * @throws QueryException on query error. */ protected <T> List<T> execute(byte[] keyId) throws IOException, QueryException { return getQuery().bindValue(KEYID, getEncoder().encode(keyId)).execute(); }
/** * Search for all wiki macros in the current wiki. * * @param xcontext the current request context * @return a list of documents containing wiki macros, each item as a List of 3 strings: space name, document name, * last author of the document * @throws Exception if the database search fails */ private List<Object[]> getWikiMacroDocumentData(XWikiContext xcontext) throws Exception { final QueryManager qm = xcontext.getWiki().getStore().getQueryManager(); final Query q = qm.getNamedQuery("getWikiMacroDocuments"); return (List<Object[]>) (List) q.execute(); }
public void refreshLinks(XWikiContext context) throws XWikiException { try { // refreshes all Links of each doc of the wiki List<String> docs = getStore().getQueryManager().getNamedQuery("getAllDocuments").execute(); for (int i = 0; i < docs.size(); i++) { XWikiDocument myDoc = this.getDocument(docs.get(i), context); myDoc.getStore().saveLinks(myDoc, context, true); } } catch (QueryException ex) { throw new XWikiException(0, 0, ex.getMessage(), ex); } }
public List<String> getSpaces(XWikiContext context) throws XWikiException { try { return getStore().getQueryManager().getNamedQuery("getSpaces").execute(); } catch (QueryException ex) { throw new XWikiException(0, 0, ex.getMessage(), ex); } }
@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); } }
public void addAllWikiDocuments(XWikiContext context) throws XWikiException { XWiki wiki = context.getWiki(); try { List<String> documentNames = wiki.getStore().getQueryManager().getNamedQuery("getAllDocuments").execute(); for (String docName : documentNames) { add(docName, DocumentInfo.ACTION_OVERWRITE, context); } } catch (QueryException ex) { throw new PackageException(PackageException.ERROR_XWIKI_STORE_HIBERNATE_SEARCH, "Cannot retrieve the list of documents to export", ex); } }
public List<String> getSpaceDocsName(String spaceName, XWikiContext context) throws XWikiException { try { return getStore().getQueryManager().getNamedQuery("getSpaceDocsName").bindValue("space", spaceName) .execute(); } catch (QueryException ex) { throw new XWikiException(0, 0, ex.getMessage(), ex); } }