@Override public void run() { result = session.queryAndFetch(query, language); }
@Override public void run() { IterableQueryResult results = session.queryAndFetch(queryForSuspendedNodesWithEscalation, "NXQL"); for (Map<String, Serializable> result : results) { nodesDocIds.add(result.get("ecm:uuid").toString()); log.trace("Inspecting node for escalation rules:" + result.get("ecm:uuid").toString()); } results.close(); } }.runUnrestricted();
public IterableQueryResult query(CoreSession session, NuxeoCmisService service, String query) throws ToutaticeException { IterableQueryResult result = null; try { result = session.queryAndFetch(query, CMISQLQueryMaker.TYPE, service); } catch (Exception e) { if (log.isErrorEnabled()) { log.error("Failed to execute the query '" + query + "', error: " + e.getMessage()); } throw new ToutaticeException(e); } return result; }
@Override public void run() { // TODO could use a COUNT(*) query try (IterableQueryResult it = session.queryAndFetch("SELECT " + NXQL.ECM_UUID + " FROM " + docType, NXQL.NXQL)) { size = it.size(); } } }
protected Set<String> getPictureIdsToMigrate(CoreSession session) { IterableQueryResult it = null; Set<String> pictureIds = new HashSet<>(); try { it = session.queryAndFetch(PICTURES_TO_MIGRATE_QUERY, NXQL); for (Map<String, Serializable> map : it) { String id = (String) map.get(ECM_UUID); if (id != null) { pictureIds.add(id); } } } finally { if (it != null) { it.close(); } } return pictureIds; }
@Override public void run() { String query = "SELECT " + NXQL.ECM_UUID + " FROM " + docType; query = whereAnyBuilder(query, resource); try (IterableQueryResult it = session.queryAndFetch(query, NXQL.NXQL)) { found = it.iterator().hasNext(); } }
@Override protected void compute(CoreSession session, List<String> ids, Map<String, Serializable> properties) { String query = String.format(QUERY_TEMPLATE, String.join("', '", ids)); Set<DocumentRef> proxies = new HashSet<>(); try (IterableQueryResult res = session.queryAndFetch(query, NXQL.NXQL)) { for (Map<String, Serializable> map : res) { proxies.add(new IdRef((String) map.get(NXQL.ECM_UUID))); } } session.removeDocuments(proxies.toArray(new DocumentRef[0])); session.save(); } }
protected void findDocsToUpdate() { if (useJobId) { // find which docs will receive the extracted text (there may be more than one if the original // doc was copied between the time it was saved and this listener being asynchronously executed) String query = String.format( "SELECT ecm:uuid FROM Document WHERE ecm:fulltextJobId = '%s' AND ecm:isProxy = 0", docId); docsToUpdate = new ArrayList<>(); try (IterableQueryResult it = session.queryAndFetch(query, NXQL.NXQL)) { for (Map<String, Serializable> map : it) { docsToUpdate.add(new IdRef((String) map.get(NXQL.ECM_UUID))); } } } else { docsToUpdate = Collections.singletonList(document.getRef()); } }
protected void removeProxies(CoreSession session, List<String> ids) { Set<DocumentRef> proxies = new HashSet<>(); String query = String.format(PROXY_QUERY_TEMPLATE, String.join("', '", ids)); try (IterableQueryResult res = session.queryAndFetch(query, NXQL.NXQL)) { for (Map<String, Serializable> map : res) { proxies.add(new IdRef((String) map.get(NXQL.ECM_UUID))); } } session.removeDocuments(proxies.toArray(new DocumentRef[0])); try { session.save(); } catch (PropertyException e) { // TODO send to error stream log.warn("Cannot save session", e); } }
query += String.format(" AND relation:target = '%s'", tagId); try (IterableQueryResult res = session.queryAndFetch(query, NXQL.NXQL)) { for (Map<String, Serializable> map : res) { creators.add((String) map.get("dc:creator"));
public void setSystemProperty(CoreSession session, List<String> ids, Boolean value) { List<DocumentRef> updatedRefs = new ArrayList<>(ids.size()); String query = String.format(SYSPROP_QUERY_TEMPLATE, value ? "0" : "1", String.join("', '", ids)); try (IterableQueryResult res = session.queryAndFetch(query, NXQL.NXQL)) { for (Map<String, Serializable> map : res) { DocumentRef ref = new IdRef((String) map.get(NXQL.ECM_UUID)); try { session.setDocumentSystemProp(ref, "isTrashed", value); updatedRefs.add(ref); } catch (NuxeoException e) { // TODO send to error stream log.warn("Cannot set system property: isTrashed on: " + ref.toString(), e); } } } try { session.save(); if (!updatedRefs.isEmpty()) { fireEvent(session, value ? DOCUMENT_TRASHED : DOCUMENT_UNTRASHED, updatedRefs); } } catch (PropertyException e) { // TODO send to error stream log.warn("Cannot save session", e); } }
protected void remove(Statement statement) { String query = "SELECT " + NXQL.ECM_UUID + " FROM " + docType; query = whereBuilder(query, statement); if (query == null) { return; } try (IterableQueryResult it = session.queryAndFetch(query, NXQL.NXQL)) { for (Map<String, Serializable> map : it) { String id = (String) map.get(NXQL.ECM_UUID); session.removeDocument(new IdRef(id)); } } } }
@Override public String getRouteModelDocIdWithId(CoreSession session, String id) { if (modelsChache != null) { String routeDocId = modelsChache.getIfPresent(id); if (routeDocId != null) { return routeDocId; } } String query = String.format(ROUTE_MODEL_DOC_ID_WITH_ID_QUERY, NXQL.escapeString(id)); List<String> routeIds = new ArrayList<>(); try (IterableQueryResult results = session.queryAndFetch(query, "NXQL")) { if (results.size() == 0) { throw new NuxeoException("No route found for id: " + id); } if (results.size() != 1) { throw new NuxeoException("More than one route model found with id: " + id); } for (Map<String, Serializable> map : results) { routeIds.add(map.get("ecm:uuid").toString()); } } String routeDocId = routeIds.get(0); if (modelsChache == null) { modelsChache = CacheBuilder.newBuilder().maximumSize(100).expireAfterWrite(10, TimeUnit.MINUTES).build(); } modelsChache.put(id, routeDocId); return routeDocId; }
/** * Returns {@code false} if the type of one of the children documents matches a template item type, {@code true} * otherwise. */ protected boolean shouldCreateContent(DocumentModel eventDoc) { for (TemplateItemDescriptor item : template) { // don't use getChildren, which can be costly // if the folder has a huge number of children String query = "SELECT ecm:uuid FROM Document WHERE ecm:parentId = '%s' AND ecm:primaryType = '%s'"; query = String.format(query, eventDoc.getId(), item.getTypeName()); IterableQueryResult it = session.queryAndFetch(query, NXQL.NXQL); try { if (it.iterator().hasNext()) { return false; } } finally { it.close(); } } return true; } }
query += String.format(" AND relation:target = '%s'", tagId); try (IterableQueryResult res = session.queryAndFetch(query, NXQL.NXQL)) { for (Map<String, Serializable> map : res) { taggingIds.add((String) map.get(NXQL.ECM_UUID));
String formattedDate = FORMATTER.format(now); IterableQueryResult result = session.queryAndFetch(String.format(QUERY, formattedDate, formattedDate), NXQL.NXQL); Map<String, List<ACE>> docIdsToACEs = new HashMap<>();
return; try (IterableQueryResult result = session.queryAndFetch(String.format(TRASHED_QUERY, parent.getId()), NXQL.NXQL)) { NuxeoPrincipal principal = session.getPrincipal();
try (IterableQueryResult it = session.queryAndFetch(query, NXQL.NXQL)) { for (Map<String, Serializable> map : it) { String pred = (String) map.get(REL_PREDICATE);
log.trace("remove everything except root"); try (IterableQueryResult results = session.queryAndFetch( "SELECT ecm:uuid FROM Document WHERE ecm:isProxy = 1", NXQL.NXQL)) { batchRemoveDocuments(results); "remove orphan versions as OrphanVersionRemoverListener is not triggered by CoreSession#removeChildren"); try (IterableQueryResult results = session.queryAndFetch("SELECT ecm:uuid FROM Document, Relation", NXQL.NXQL)) { batchRemoveDocuments(results);
String query = NXQLQueryBuilder.getQuery(searchDocument, def.getWhereClause(), null); IterableQueryResult result = session.queryAndFetch(query, NXQL.NXQL); List<String> docIds = new ArrayList<>(); try {