use of com.orientechnologies.orient.core.id.ORID in project jphp by jphp-compiler.
the class ODocument method getId.
@Getter
public String getId() {
ORID identity = getWrappedObject().getIdentity();
if (identity.isNew()) {
return null;
}
StringBuilder buffer = new StringBuilder();
return identity.toString(buffer).toString();
}
use of com.orientechnologies.orient.core.id.ORID in project wicket-orientdb by OrienteerBAP.
the class TestInAppOrientDBCompatibility method testTransactions.
@Test
public void testTransactions() throws Exception {
ODatabaseDocument db = wicket.getTester().getDatabase();
try {
assertFalse(db.getTransaction().isActive());
OSchema schema = db.getMetadata().getSchema();
OClass classA = schema.createClass("TransA");
classA.createProperty("name", OType.STRING);
ODocument doc = new ODocument(classA);
doc.field("name", "test1");
doc.save();
ORID orid = doc.getIdentity();
db.begin();
assertTrue(db.getTransaction().isActive());
doc = orid.getRecord();
assertEquals("test1", doc.field("name"));
doc.field("name", "test2");
doc = orid.getRecord();
assertEquals("test2", doc.field("name"));
// There is NO SAVE!
db.commit();
db.getLocalCache().clear();
/* COMMENT START */
// db.close();
// db = wicket.getTester().getDatabase();
/* COMMENT STOP */
doc = orid.getRecord();
assertEquals("test1", doc.field("name"));
} finally {
db.commit();
}
}
use of com.orientechnologies.orient.core.id.ORID in project wicket-orientdb by OrienteerBAP.
the class TestInAppOrientDBCompatibility method testOFunctions.
@Test
public void testOFunctions() throws Exception {
ODatabaseDocument db = wicket.getTester().getDatabase();
ODocument doc = new ODocument(OFunction.CLASS_NAME);
doc.field("name", "testResurection");
doc.field("language", "JavaScript");
doc.field("idempotent", true);
doc.save();
ORID orid = doc.getIdentity();
for (int i = 0; i < 10; i++) {
db = wicket.getTester().getDatabase();
String signature = "signature" + RANDOM.nextLong();
boolean isGoodCall = (i + 1) % 3 != 0;
db.begin();
doc = orid.getRecord();
String code = isGoodCall ? "return \"" + signature + "\";" : "return nosuchvar;";
doc.field("code", code);
doc.save();
db.commit();
db.close();
if (isGoodCall) {
String result;
for (int j = 0; j < 3; j++) {
result = wicket.getTester().executeUrl("orientdb/function/db/testResurection", "GET", null);
assertContains(signature, result);
}
} else {
try {
wicket.getTester().executeUrl("orientdb/function/db/testResurection", "GET", null);
assertFalse("We should be there, because function should have 400 response", true);
} catch (Exception e) {
// NOP
}
}
}
}
use of com.orientechnologies.orient.core.id.ORID in project wicket-orientdb by OrienteerBAP.
the class TestInAppOrientDBCompatibility method testLinkToOUser.
// TODO: Uncomment when OrientDB issue will be fixed: https://github.com/orientechnologies/orientdb/issues/8067
@Ignore
@Test
public void testLinkToOUser() {
ODatabaseDocument db = wicket.getTester().getDatabase();
OSchema schema = db.getMetadata().getSchema();
final OClass classA = schema.createClass("TestLinkToOUser");
classA.createProperty("name", OType.STRING);
classA.createProperty("user", OType.LINK).setLinkedClass(schema.getClass("OUser"));
ORID userRid = new ORecordId("#5:0");
ODocument doc = new ODocument(classA);
wicket.getTester().signIn("writer", "writer");
db = wicket.getTester().getDatabase();
db.begin();
ODocument userDoc = userRid.getRecord();
userDoc.field("roles");
doc.field("Admin");
doc.field("user", userDoc);
doc.save();
db.commit();
}
use of com.orientechnologies.orient.core.id.ORID in project wicket-orientdb by OrienteerBAP.
the class TestRestApi method testGetDocument.
@Test
public void testGetDocument() throws Exception {
ODocument doc = (ODocument) wicket.getTester().getDatabase().browseClass(TEST_REST_CLASS).current();
ORID id = doc.getIdentity();
String ret = wicket.getTester().executeUrl("orientdb/document/db/" + id.getClusterId() + ":" + id.getClusterPosition(), "GET", null);
assertEquals(doc.toJSON(), ret);
}
Aggregations