@Override public DocumentModelList getOrderedRouteElement(String routeElementId, CoreSession session) { String query = String.format(ORDERED_CHILDREN_QUERY, routeElementId); DocumentModelList orderedChildren = session.query(query); return orderedChildren; }
protected DocumentModelList getChildrenFor(String containerId) throws NuxeoException { try { // don't use the query model: is deprecated & has a result size limitation too small return documentManager.query(String.format(QUERY_DOC_ORDERED_CHILDREN_QM, containerId), CST_MAX_RESULT_SET_SIZE); } catch (Exception e) { throw new NuxeoException(e); } }
@Override public void run() { docs = session.query(query); for (DocumentModel documentModel : docs) { documentModel.detach(true); } }
@Override public String getDocumentationStats(CoreSession session) { String query = "SELECT * FROM " + DocumentationItem.TYPE_NAME + " WHERE " + QueryHelper.NOT_DELETED; DocumentModelList docList = session.query(query); return docList.size() + " documents"; }
/** * Helper to load a list of documents. Documents without read access or that does not exists are not returned. */ public DocumentModelList loadDocuments(CoreSession session, List<String> documentIds) { if (documentIds == null || documentIds.isEmpty()) { return new DocumentModelListImpl(0); } return session.query(String.format(SELECT_DOCUMENTS_IN, String.join("', '", documentIds))); } }
private List<DocumentModel> fetchFromVcsChunk(final List<String> ids, CoreSession session) { StringBuilder sb = new StringBuilder(); sb.append("SELECT * FROM Document, Relation WHERE ecm:uuid IN ("); for (int i = 0; i < ids.size(); i++) { sb.append(NXQL.escapeString(ids.get(i))); if (i < ids.size() - 1) { sb.append(", "); } } sb.append(")"); return session.query(sb.toString()); }
@Override public void run() throws NuxeoException { this.docs = this.session.query(this.query, this.limit); for (DocumentModel documentModel : this.docs) { documentModel.detach(true); } }
@Override public List<DocumentRoute> getAvailableDocumentRouteModel(CoreSession session) { DocumentModelList list = session.query(AVAILABLE_ROUTES_MODEL_QUERY); List<DocumentRoute> routes = new ArrayList<>(); for (DocumentModel model : list) { routes.add(model.getAdapter(DocumentRoute.class)); } return routes; }
@Override public List<DocumentLocation> findExistingDocumentWithFile(CoreSession documentManager, String path, String digest, NuxeoPrincipal principal) { String nxql = String.format(QUERY, digest); DocumentModelList documentModelList = documentManager.query(nxql, MAX); List<DocumentLocation> docLocationList = new ArrayList<>(documentModelList.size()); for (DocumentModel documentModel : documentModelList) { docLocationList.add(new DocumentLocationImpl(documentModel)); } return docLocationList; }
public Catalogue(CoreSession session, DocumentModel document, String type) throws ClientException { DocumentModelList items = session.query("SELECT * FROM " + type + " WHERE " + "ecm:path STARTSWITH '" + document.getPathAsString() + "' " + "AND ecm:mixinType != 'HiddenInNavigation' " + "AND ecm:isCheckedInVersion = 0 " + "AND ecm:currentLifeCycleState != 'deleted'"); for (DocumentModel item : items) { this.catalogue.put(item.getRef().toString(), item); } }
@Override public DocumentModelList getDocuments(DocumentModel parent) { CoreSession session = parent.getCoreSession(); return session.query(String.format(TRASHED_QUERY, parent.getId())); }
@Override public List<String> getServiceIds() { Set<String> ids = new HashSet<>(); String query = QueryHelper.select(ComponentInfo.TYPE_NAME, doc); DocumentModelList components = getCoreSession().query(query); for (DocumentModel componentDoc : components) { ComponentInfo ci = componentDoc.getAdapter(ComponentInfo.class); if (ci != null) { ids.addAll(ci.getServiceNames()); } } return new ArrayList<>(ids); }
@Override public List<String> getBundleIds() { List<String> bundles = new ArrayList<>(); String query = QueryHelper.select(BundleInfo.TYPE_NAME, doc); DocumentModelList docs = getCoreSession().query(query); for (DocumentModel child : docs) { BundleInfo bi = child.getAdapter(BundleInfo.class); if (bi != null && !bi.getId().equals(getId())) { bundles.add(bi.getId()); } } return bundles; }
@Override public OperationInfo getOperation(String id) { if (id.startsWith(OperationInfo.ARTIFACT_PREFIX)) { id = id.substring(OperationInfo.ARTIFACT_PREFIX.length()); } String query = QueryHelper.select(OperationInfo.TYPE_NAME, getDoc()) + " AND " + OperationInfo.PROP_NAME + " = " + NXQL.escapeString(id) + " OR " + OperationInfo.PROP_ALIASES + " = " + NXQL.escapeString(id); DocumentModelList docs = getCoreSession().query(query); return docs.isEmpty() ? null : docs.get(0).getAdapter(OperationInfo.class); }
@Override public void run() { String query = "SELECT * FROM Document WHERE ecm:currentLifeCycleState != 'validated' AND" + " ecm:mixinType = '" + getConfiguration(configurationName).getRequestDocType() + "' AND docinfo:documentId = '%s' AND" + getConfiguration(configurationName).getUserInfoUsernameField() + " = '%s' AND ecm:isVersion = 0"; query = String.format(query, docId, username); registrationDocs.addAll(session.query(query)); } }.runUnrestricted();
protected void reinitDocumentsLifeCyle(CoreSession documentManager, DocumentModelList docs) { for (DocumentModel docMod : docs) { documentManager.reinitLifeCycleState(docMod.getRef()); if (docMod.isFolder()) { DocumentModelList children = documentManager.query(String.format( "SELECT * FROM Document WHERE ecm:isTrashed = 0 AND ecm:parentId = '%s'", docMod.getRef())); reinitDocumentsLifeCyle(documentManager, children); } } }
@Override public void run() throws NuxeoException { String docTitle = this.document.getTitle(); DocumentModel docParent = this.session.getParentDocument(this.document.getRef()); DocumentModelList rs = this.session.query("SELECT * FROM " + this.document.getType() + " WHERE ecm:parentId = '" + docParent.getId() + "' " + "AND ecm:mixinType != 'HiddenInNavigation' " + "AND ecm:isCheckedInVersion = 0 " + "AND dc:title LIKE '" + docTitle.replace("'", "\\'") + "%'", this.filter); this.count = rs.size(); } }
@Override public void run() throws ClientException { String docTitle = this.document.getTitle(); DocumentModel docParent = this.session.getParentDocument(this.document.getRef()); DocumentModelList rs = this.session.query("SELECT * FROM " + this.document.getType() + " WHERE ecm:parentId = '" + docParent.getId() + "' " + "AND ecm:mixinType != 'HiddenInNavigation' " + "AND ecm:isCheckedInVersion = 0 " + "AND dc:title LIKE '" + docTitle.replace("'", "\\'") + "%'", this.filter); this.count = rs.size(); } }
@Override public SeamComponentInfo getSeamComponent(String id) { String name = id.replace("seam:", ""); String query = QueryHelper.select(SeamComponentInfo.TYPE_NAME, getDoc()) + " AND " + SeamComponentInfo.PROP_COMPONENT_NAME + " = " + NXQL.escapeString(name); DocumentModelList docs = getCoreSession().query(query); return docs.isEmpty() ? null : docs.get(0).getAdapter(SeamComponentInfo.class); }
protected void initMinimalContext() { setupCurrentUser(); // we try to select the server to go to the next screen if (navigationContext.getCurrentServerLocation() == null) { // update location RepositoryLocation repLoc = new RepositoryLocation(repositoryManager.getRepositoryNames().get(0)); navigationContext.setCurrentServerLocation(repLoc); } CoreSession documentManager = navigationContext.getOrCreateDocumentManager(); DocumentModelList domains = documentManager.query("select * from Domain"); navigationContext.setCurrentDocument(domains.get(0)); }