use of com.orientechnologies.orient.core.hook.ORecordHook.DISTRIBUTED_EXECUTION_MODE in project wicket-orientdb by OrienteerBAP.
the class TestInAppOrientDBCompatibility method testDocumentTrackingComplex.
@Test
@Ignore
public void testDocumentTrackingComplex() {
final String className = "TestDocumentTrackingComplex";
ODatabaseDocument db = wicket.getTester().getDatabase();
OSchema schema = db.getMetadata().getSchema();
final OClass classA = schema.createClass(className);
classA.createProperty("a", OType.STRING);
classA.createProperty("b", OType.STRING);
db.registerHook(new ODocumentHookAbstract(db) {
{
setIncludeClasses(className);
}
@Override
public DISTRIBUTED_EXECUTION_MODE getDistributedExecutionMode() {
return DISTRIBUTED_EXECUTION_MODE.SOURCE_NODE;
}
@Override
public void onRecordAfterCreate(ODocument iDocument) {
System.out.println("onRecordAfterCreate");
iDocument.field("a", "onRecordAfterCreate");
}
@Override
public void onRecordAfterUpdate(ODocument iDocument) {
System.out.println("onRecordAfterUpdate");
iDocument.field("a", "onRecordAfterUpdate");
}
@Override
public RESULT onRecordBeforeUpdate(ODocument iDocument) {
System.out.println("onRecordAfterUpdate before undo: " + iDocument.field("a"));
iDocument.undo("a");
System.out.println("onRecordAfterUpdate after undo: " + iDocument.field("a"));
return RESULT.RECORD_CHANGED;
}
@Override
public void onRecordAfterRead(ODocument iDocument) {
assertEquals("original", iDocument.field("a"));
}
});
db.commit();
ODocument doc = new ODocument(classA);
doc.field("a", "original");
doc.save();
doc.field("b", "other change");
doc.save();
doc.reload();
doc.field("a", "updated");
doc.save();
doc.field("b", "other change");
doc.save();
doc.reload();
doc.delete();
}
Aggregations