/** * * @param collectId the XDM collection id * @return true if the schema contains collection with id provided, false otherwise */ public boolean hasCollection(int collectId) { for (Collection collection: collections) { if (collectId == collection.getId()) { return true; } } return false; }
private int getCollectionId(String uri, String baseUri) { Schema schema = repo.getSchema(); if (baseUri != null && !baseUri.isEmpty() && uri.startsWith(baseUri)) { uri = uri.substring(baseUri.length()); } Collection cln = schema.getCollection(uri); if (cln != null) { return cln.getId(); } logger.info("getCollectionId; no collection found for uri: {}; baseUri: {}, collections: {}", uri, baseUri, schema.getCollections()); return ModelManagementBase.WRONG_PATH; }
private int[] getUriCollections(Schema schema, String uri) { List<Integer> found = new ArrayList<>(); for (Collection collect: schema.getCollections()) { Pattern p = collect.getCompiledPattern(); if (p != null) { found.add(collect.getId()); } } if (found.size() > 0) { int idx = 0; int[] clns = new int[found.size()]; for (Integer id: found) { clns[idx] = id; idx++; } return clns; } return null; }
Collection addCollection(String name, String docType, String uriPattern, String description) { Schema schema = getEntity(); int id = 0; for (Collection collect: schema.getCollections()) { if (collect.getId() > id) { id = collect.getId(); } } id++; Collection collection = new Collection(1, new Date(), getCurrentUser(), id, name, docType, uriPattern, description, true); if (schema.addCollection(collection)) { // store schema! flushEntity(schema); return collection; } return null; }
public String checkDefaultDocumentCollection(Document doc) { Collection cln = getTypedCollection(repo.getSchema(), doc.getTypeRoot()); logger.trace("checkDefaultDocumentCollection; got collection: {} for typePath: {}", cln, doc.getTypeRoot()); if (cln != null) { doc.addCollection(cln.getId()); return cln.getName(); } return null; }
collectId = default_collection; } else { collectId = schema.getCollection(trigger.getCollection()).getId();
return null; return new CollectionPredicate(cln.getId());
public int updateDocumentCollections(boolean add, Map.Entry<DocumentKey, Document> entry, String[] collections) { int updCount = 0; Document doc = entry.getValue(); if (doc != null) { int size = doc.getElements(); for (Collection cln: repo.getSchema().getCollections()) { for (String collection: collections) { if (collection.equals(cln.getName())) { if (add) { if (doc.addCollection(cln.getId())) { updCount++; updateStats(cln.getName(), true, size, doc.getFragments().length); } } else { if (doc.removeCollection(cln.getId())) { updCount++; updateStats(cln.getName(), false, size, doc.getFragments().length); } } break; } } } if (updCount > 0) { entry.setValue(doc); } } return updCount; }
@Override public boolean deleteTrigger(TriggerDefinition trigger) { logger.trace("deleteTrigger.enter; git trigger definition: {}", trigger); int cnt = 0; Schema schema = repo.getSchema(); for (TriggerAction action: trigger.getActions()) { String key = getTriggerScopeKey(action.getOrder(), action.getScope()); Map<Integer, List<TriggerContainer>> current = triggers.get(key); if (current == null) { continue; } int collectId = tx_collection; if (!isTransactionalAction(action)) { if (trigger.getCollection() == null) { collectId = default_collection; } else { collectId = schema.getCollection(trigger.getCollection()).getId(); } } List<TriggerContainer> impls = current.get(collectId); if (impls != null) { if (impls.remove(action.getIndex()) != null) { cnt++; } } } logger.trace("deleteTrigger.exit; {} triggers deleted, for collection: {}", cnt, trigger.getCollection()); return cnt > 0; }
if (clnId == cln.getId()) { updateStats(cln.getName(), false, updated.getElements(), updated.getFragments().length); break; Collection cln = repo.getSchema().getCollection(clName); if (cln != null) { newDoc.addCollection(cln.getId()); updateStats(clName, true, newDoc.getElements(), newDoc.getFragments().length);
@Override public void write(ObjectDataOutput out, Collection xCollection) throws IOException { super.writeEntity(out, xCollection); out.writeInt(xCollection.getId()); out.writeUTF(xCollection.getName()); out.writeUTF(xCollection.getDocumentType()); out.writeUTF(xCollection.getUriPattern()); out.writeUTF(xCollection.getDescription()); out.writeBoolean(xCollection.isEnabled()); }
public void cleanDocument(DocumentKey docKey, boolean complete) { logger.trace("cleanDocument.enter; docKey: {}, complete: {}", docKey, complete); Document doc = getDocument(docKey); boolean cleaned = false; if (doc != null) { // TODO: clean via EntryProcessor.. cntCache.delete(docKey); int size = deleteDocumentElements(doc.getFragments(), doc.getTypeRoot()); if (complete) { docCache.delete(docKey); } cleaned = true; // TODO: if xdm-key cache is used it must be cleaned too! // update statistics for (Collection cln: repo.getSchema().getCollections()) { if (doc.hasCollection(cln.getId())) { updateStats(cln.getName(), false, size, doc.getFragments().length); } } updateStats(null, false, size, doc.getFragments().length); } ((QueryManagementImpl) repo.getQueryManagement()).removeQueryResults(docKey.getKey()); logger.trace("cleanDocument.exit; cleaned: {}", cleaned); }
for (int clnId: collections) { for (Collection cln: repo.getSchema().getCollections()) { if (clnId == cln.getId()) { updateStats(cln.getName(), true, doc.getElements(), doc.getFragments().length); break;