@Override public OProperty setReadonly(final boolean iReadonly) { delegate.setReadonly(iReadonly); return this; }
@Override public void afterRegistration(final ODatabaseObject db, final SchemeDescriptor descriptor, final Field field, final Readonly annotation) { final String name = field.getName(); final boolean readonly = annotation.value(); final OProperty property = db.getMetadata().getSchema() .getClass(descriptor.schemeClass).getProperty(name); if (property.isReadonly() != readonly) { property.setReadonly(readonly); logger.debug("Set {}.{} property readonly={}", descriptor.schemeClass, name, readonly); } } }
.setMandatory(true) .setNotNull(true) .setReadonly(true); object.createIndex(className, ID, indexAttribute); getDatabase().getMetadata().getSchema().save();
@Test public void testRemovingReadonlyField() { ODatabaseDocument db = wicket.getTester().getDatabase(); OSchema schema = db.getMetadata().getSchema(); OClass classA = schema.createClass("TestRemovingField"); classA.createProperty("name", OType.STRING); OProperty property = classA.createProperty("property", OType.STRING); property.setReadonly(true); ODocument doc = new ODocument(classA); doc.field("name", "My Name"); doc.field("property", "value1"); doc.save(); doc.field("name", "My Name 2"); doc.field("property", "value2"); doc.undo("property"); doc.save(); }
@Test public void testRemovingReadonlyField2() { ODatabaseDocument db = wicket.getTester().getDatabase(); OSchema schema = db.getMetadata().getSchema(); OClass classA = schema.createClass("TestRemovingField2"); classA.createProperty("name", OType.STRING); OProperty property = classA.createProperty("property", OType.STRING); property.setReadonly(true); ODocument doc = new ODocument(classA); doc.field("name", "My Name"); doc.field("property", "value1"); doc.save(); doc.field("name", "My Name 2"); doc.field("property", "value2"); doc.undo(); doc.field("name", "My Name 3"); doc.save(); }
OClass classA = schema.createClass(TEST_VALIDATION_AND_HOOKS_CLASS); classA.createProperty("property1", OType.STRING).setNotNull(true); classA.createProperty("property2", OType.STRING).setReadonly(true); classA.createProperty("property3", OType.STRING).setMandatory(true); db.registerHook(new ODocumentHookAbstract(db) {