use of com.orientechnologies.orient.core.fetch.OFetchContext in project orientdb by orientechnologies.
the class DepthFetchPlanTest method testFetchPlanDepth.
@Test
public void testFetchPlanDepth() {
ODatabaseDocument database = new ODatabaseDocumentTx("memory:" + DepthFetchPlanTest.class.getSimpleName());
database.create();
try {
database.getMetadata().getSchema().createClass("Test");
ODocument doc = new ODocument("Test");
ODocument doc1 = new ODocument("Test");
ODocument doc2 = new ODocument("Test");
doc.field("name", "name");
database.save(doc);
doc1.field("name", "name1");
doc1.field("ref", doc);
database.save(doc1);
doc2.field("name", "name2");
doc2.field("ref", doc1);
database.save(doc2);
OFetchContext context = new ORemoteFetchContext();
CountFetchListener listener = new CountFetchListener();
OFetchHelper.fetch(doc2, doc2, OFetchHelper.buildFetchPlan("ref:1 *:-2"), listener, context, "");
assertEquals(1, listener.count);
} finally {
database.drop();
}
}
use of com.orientechnologies.orient.core.fetch.OFetchContext in project orientdb by orientechnologies.
the class OSyncCommandResultListener method linkdedBySimpleValue.
@Override
public void linkdedBySimpleValue(ODocument doc) {
ORemoteFetchListener listener = new ORemoteFetchListener() {
@Override
protected void sendRecord(ORecord iLinked) {
if (!alreadySent.contains(iLinked))
fetchedRecordsToSend.add(iLinked);
}
@Override
public void parseLinked(ODocument iRootRecord, OIdentifiable iLinked, Object iUserObject, String iFieldName, OFetchContext iContext) throws OFetchException {
if (!(iLinked instanceof ORecordId)) {
sendRecord(iLinked.getRecord());
}
}
@Override
public void parseLinkedCollectionValue(ODocument iRootRecord, OIdentifiable iLinked, Object iUserObject, String iFieldName, OFetchContext iContext) throws OFetchException {
if (!(iLinked instanceof ORecordId)) {
sendRecord(iLinked.getRecord());
}
}
};
final OFetchContext context = new ORemoteFetchContext();
OFetchHelper.fetch(doc, doc, OFetchHelper.buildFetchPlan(""), listener, context, "");
}
Aggregations