@Override protected java.util.Collection getSchemaFeatures(Schema schema) { return schema.getCollections(); }
private Collection getTypedCollection(Schema schema, String typePath) { for (Collection collect: schema.getCollections()) { String cPath = collect.getDocumentType(); if (cPath != null && typePath.equals(cPath)) { return collect; } } return null; }
@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; }
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 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; }
out.writeBoolean(xSchema.isActive()); out.writeObject(xSchema.getProperties()); out.writeInt(xSchema.getCollections().size()); for (Collection collection: xSchema.getCollections()) { out.writeObject(collection);
for (Collection cln: repo.getSchema().getCollections()) { if (clnId == cln.getId()) { updateStats(cln.getName(), false, updated.getElements(), updated.getFragments().length);
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); }
doc.setCollections(collections); for (int clnId: collections) { for (Collection cln: repo.getSchema().getCollections()) { if (clnId == cln.getId()) { updateStats(cln.getName(), true, doc.getElements(), doc.getFragments().length);