private void initSchemas() { schemas = new HashMap<>(); schemas.put("default", new Schema(1, new Date(), "admin", "default", "default schema for test and demo purpose", true, null)); schemas.put("TPoX", new Schema(1, new Date(), "admin", "TPoX", "TPoX: schema for TPoX-related tests", false, null)); schemas.put("XMark", new Schema(1, new Date(), "admin", "XMark", "XMark benchmark schema", false, null)); }
@Override public void write(ObjectDataOutput out, Schema xSchema) throws IOException { super.writeEntity(out, xSchema); out.writeUTF(xSchema.getName()); out.writeUTF(xSchema.getDescription()); out.writeBoolean(xSchema.isActive()); out.writeObject(xSchema.getProperties()); out.writeInt(xSchema.getCollections().size()); for (Collection collection: xSchema.getCollections()) { out.writeObject(collection); out.writeInt(xSchema.getFragments().size()); for (Fragment fragment: xSchema.getFragments()) { out.writeObject(fragment); out.writeInt(xSchema.getIndexes().size()); for (Index index: xSchema.getIndexes()) { out.writeObject(index); out.writeInt(xSchema.getResources().size()); for (Resource resource: xSchema.getResources()) { out.writeObject(resource); out.writeInt(xSchema.getTriggers().size()); for (TriggerDefinition trigger: xSchema.getTriggers()) { out.writeObject(trigger); out.writeInt(xSchema.getViews().size()); for (MaterializedView view: xSchema.getViews()) { out.writeObject(view);
public boolean addSchemaTrigger(TriggerDefinition trigger) { if (xdmSchema.addTrigger(trigger)) { return triggerMgr.createTrigger(trigger); } 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; }
@Override public Schema read(ObjectDataInput in) throws IOException { Object[] entity = super.readEntity(in); Schema xSchema = new Schema( (int) entity[0], (Date) entity[1], for (int i=0; i < size; i++) { Collection cln = in.readObject(); xSchema.addCollection(cln); xSchema.addFragment(fgt); xSchema.addIndex(idx); xSchema.addResource(res); xSchema.addTrigger(trg); xSchema.addView(view);
@Override protected java.util.Collection getSchemaFeatures(Schema schema) { return schema.getCollections(); }
@Override public Object process(Entry<String, Schema> entry) { logger.debug("process.enter; entry: {}", entry); if (entry.getValue() == null) { String schemaName = entry.getKey(); String pwd = properties.getProperty(pn_schema_password); if (pwd != null) { properties.setProperty(pn_schema_password, encrypt(pwd)); } Schema schema = new Schema(getVersion(), new Date(), getAdmin(), schemaName, description, true, properties); //if (initSchemaInCluster(schema) == 0) { schema.setActive(false); //} entry.setValue(schema); auditEntity(AuditType.create, schema); //if (schema.isActive()) { // logger.debug("process; schema activated, starting population"); // SchemaPopulator pop = new SchemaPopulator(schema.getName()); // execService.submitToAllMembers(pop); //} return schema; } 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; }
long txStart, int[] collections, Properties props) throws BagriException { props.setProperty(pn_document_data_format, repo.getSchema().getProperty(pn_schema_format_default)); ContentConverter<Object, ?> cc = getConverter(props, srcFormat, null); if (cc != null) { String dataFormat = repo.getSchema().getProperty(pn_schema_format_default); ParseResults pRes = parseContent(docKey, content, dataFormat, null); 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);
@ManagedOperation(description="Return Documents which belongs to Collection") @ManagedOperationParameters({ @ManagedOperationParameter(name = "clName", description = "Collection name"), @ManagedOperationParameter(name = "properties", description = "A list of properties in key=value form separated by semicolon")}) public java.util.Collection<String> getCollectionDocuments(String clName, String properties) { if (clName != null && !"All Documents".equals(clName)) { Collection cln = schemaManager.getEntity().getCollection(clName); if (cln == null) { logger.info("getCollectionDocuments; got unknown collection: {}", clName); return null; } } try { return getUris("collections.contains(" + clName + "), txFinish = 0", properties); } catch (Exception ex) { logger.error("getCollectionDocuments.error", ex); return null; } }
@Override protected Collection getSchemaFeatures(Schema schema) { return schema.getResources(); }
Index addIndex(String name, String docType, String path, String dataType, boolean caseSensitive, boolean range, boolean unique, String description) { // TODO: what it is for?! String typePath = path; //xdmRepo.getModelManagement().normalizePath(docType); Index index = new Index(1, new Date(), getCurrentUser(), name, docType, typePath, path, new QName(xs_ns, dataType, xs_prefix), caseSensitive, range, unique, description, true); Schema schema = getEntity(); if (schema.addIndex(index)) { // store schema! flushEntity(schema); return index; } return null; }
@ManagedAttribute(description="Returns short Schema description") public String getDescription() { return getEntity().getDescription(); }
Resource addResource(String name, String path, String module, String description) { Resource resource = new Resource(1, new Date(), getCurrentUser(), name, path, description, module, true); Schema schema = getEntity(); if (schema.addResource(resource)) { // store schema! flushEntity(schema); return resource; } return null; }
Fragment addFragment(String name, String docType, String path, String description) { //String typePath = schemaDictionary.normalizePath(docType); Fragment fragment = new Fragment(1, new Date(), getCurrentUser(), name, docType, //typePath, path, description, true); Schema schema = getEntity(); if (schema.addFragment(fragment)) { // store schema! flushEntity(schema); return fragment; } return null; }
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; }
for (Collection cln: repo.getSchema().getCollections()) { if (clnId == cln.getId()) { updateStats(cln.getName(), false, updated.getElements(), updated.getFragments().length); while (tc.hasMoreTokens()) { String clName = tc.nextToken(); Collection cln = repo.getSchema().getCollection(clName); if (cln != null) { newDoc.addCollection(cln.getId());
@ManagedOperation(description="Remove Document from Collection") @ManagedOperationParameters({ @ManagedOperationParameter(name = "uri", description = "Document identifier"), @ManagedOperationParameter(name = "clnName", description = "Collection name")}) public int removeDocumentFromCollection(String uri, String clnName) { Collection cln = schemaManager.getEntity().getCollection(clnName); if (cln != null) { return docManager.removeDocumentFromCollections(uri, new String[] {clnName}); } logger.info("removeDocumentFromCollection; no collection found for name: {}", clnName); return 0; }
private boolean buildSchemaConfig(ResourceConfig config, String schemaName) { Schema schema = rePro.getSchema(schemaName); // get schema -> resources int cnt = 0; for (com.bagri.core.system.Resource res: schema.getResources()) { // for each resource -> get module if (res.isEnabled()) { Module module = rePro.getModule(res.getModule()); try { buildDynamicResources(config, res.getPath(), module); cnt++; } catch (Exception ex) { logger.error("buildSchemaConfig; error processing module: " + res.getModule(), ex); // skip it.. } } } return cnt > 0; }
public boolean addSchemaIndex(Index index) { if (xdmSchema.addIndex(index)) { Path[] paths; try { paths = indexMgr.createIndex(index); } catch (BagriException ex) { logger.warn("addSchemaIndex.error; index: " + index, ex); return false; } DocumentManagementImpl docMgr = (DocumentManagementImpl) getDocumentManagement(); for (Path xPath: paths) { try { docMgr.indexElements(xPath.getPathId()); } catch (BagriException ex) { logger.warn("addSchemaIndex.error; index: " + index, ex); } } return paths.length > 0; } logger.info("addSchemaIndex; index {} already exists! do we need to index values?", index); return false; }