/** * * @param name the name of the collection to search for * @return the XDM collection instance if it is found, null otherwise */ public Collection getCollection(String name) { for (Collection collection: collections) { if (name.equals(collection.getName())) { return collection; } } return null; }
/** * * @param name the name of the collection to remove from schema * @return true if collection has been removed, false otherwise */ public Collection removeCollection(String name) { for (Collection collection: collections) { if (name.equals(collection.getName())) { if (collections.remove(collection)) { return collection; } break; } } return null; }
/** * * @param name the name of schema collection to enable * @param enable the new enable value * @return true if the collection enable flag has been changed, false otherwise */ public boolean enableCollection(String name, boolean enable) { for (Collection collection: collections) { if (name.equals(collection.getName())) { return collection.setEnabled(enable); } } return false; }
@Override public java.util.Collection<String> getCollections() throws BagriException { List<String> clNames = new ArrayList<>(repo.getSchema().getCollections().size()); for (Collection cln: repo.getSchema().getCollections()) { clNames.add(cln.getName()); } return clNames; }
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; }
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; }
for (Collection cln: repo.getSchema().getCollections()) { if (clnId == cln.getId()) { updateStats(cln.getName(), false, updated.getElements(), updated.getFragments().length); break;
@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 (Collection cln: repo.getSchema().getCollections()) { if (clnId == cln.getId()) { updateStats(cln.getName(), true, doc.getElements(), doc.getFragments().length); break;