/** * Create a new document and write entity. */ public ODocument create(final ODatabaseDocumentTx db, final RawBinaryMetadata entity) { checkNotNull(db); checkNotNull(entity); ODocument doc = db.newInstance(DB_CLASS); return write(doc, entity); }
/** * Add new entity. */ public ODocument addEntity(final ODatabaseDocumentTx db, final T entity) { checkNotNull(db); checkNotNull(entity); // new entity must either have no metadata or it should be a new record EntityMetadata metadata = entity.getEntityMetadata(); checkState(metadata == null || recordIdentity(metadata.getId()).isNew()); ODocument doc = db.newInstance(typeName); return writeEntity(doc, entity); }
@Override public Record create(final RecordType type) { checkOpen(); checkType(type); try { ODocument document = db.newInstance(type.getName()); return new OrientRecord(this, type, document); } catch (OSchemaException e) { throw new IllegalArgumentException(e); } }
@Override public void filter(String type, String value) { try (ODatabaseDocumentTx db = docDb()) { ODocument newFilter = db.newInstance("Filter"); newFilter.field("type", type); newFilter.field("value", value); newFilter.save(); } }
@Override protected void defineType(final ODatabaseDocumentTx db, final OClass type) { defineType(type); // primary index that guarantees path uniqueness for nodes in a given repository type.createIndex(I_REPOSITORY_NAME_PARENT_PATH_NAME, INDEX_TYPE.UNIQUE, P_REPOSITORY_NAME, P_PARENT_PATH, P_NAME); // save space and ignore nulls because we'll never query on a null component/asset id ODocument ignoreNullValues = db.newInstance().field("ignoreNullValues", true); type.createIndex(I_COMPONENT_ID, INDEX_TYPE.NOTUNIQUE.name(), null, ignoreNullValues, new String[] { P_COMPONENT_ID }); type.createIndex(I_ASSET_ID, INDEX_TYPE.UNIQUE.name(), null, ignoreNullValues, new String[] { P_ASSET_ID }); }
.setNotNull(true); ODocument metadata = db.newInstance() .field("ignoreNullValues", false) .field("mergeKeys", false);
@Override protected void defineType(final ODatabaseDocumentTx db, final OClass type) { super.defineType(type); type.createProperty(P_COMPONENT, OType.LINK, componentEntityAdapter.getSchemaType()); type.createProperty(P_NAME, OType.STRING) .setMandatory(true) .setNotNull(true); type.createProperty(P_SIZE, OType.LONG); type.createProperty(P_CONTENT_TYPE, OType.STRING); type.createProperty(P_BLOB_REF, OType.STRING); type.createProperty(P_LAST_DOWNLOADED, OType.DATETIME); type.createProperty(P_BLOB_CREATED, OType.DATETIME); type.createProperty(P_BLOB_UPDATED, OType.DATETIME); type.createProperty(P_CREATED_BY, OType.STRING); type.createProperty(P_CREATED_BY_IP, OType.STRING); ODocument metadata = db.newInstance() .field("ignoreNullValues", false) .field("mergeKeys", false); type.createIndex(I_BUCKET_COMPONENT_NAME, INDEX_TYPE.UNIQUE.name(), null, metadata, new String[]{P_BUCKET, P_COMPONENT, P_NAME} ); type.createIndex(I_BUCKET_NAME, INDEX_TYPE.NOTUNIQUE, P_BUCKET, P_NAME); type.createIndex(I_COMPONENT, INDEX_TYPE.NOTUNIQUE, P_COMPONENT); new OIndexBuilder(type, I_NAME_CASEINSENSITIVE, INDEX_TYPE.NOTUNIQUE) .property(P_NAME, OType.STRING) .caseInsensitive() .build(db); }