本文整理汇总了Java中com.buschmais.xo.api.Query.Result类的典型用法代码示例。如果您正苦于以下问题:Java Result类的具体用法?Java Result怎么用?Java Result使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Result类属于com.buschmais.xo.api.Query包,在下文中一共展示了Result类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reset
import com.buschmais.xo.api.Query.Result; //导入依赖的package包/类
@Override
public void reset() {
LOGGER.info("Resetting store.");
long nodes;
long relations;
long totalNodes = 0;
long totalRelations = 0;
Map<String, Object> params = new HashMap<>();
params.put("limit", BATCH_LIMIT);
do {
beginTransaction();
Result.CompositeRowObject result = executeQuery(
"MATCH (n) OPTIONAL MATCH (n)-[r]-() WITH n, count(r) as rels LIMIT {limit} DETACH DELETE n RETURN count(n) as nodes, sum(rels) as relations",
params).getSingleResult();
nodes = result.get("nodes", Long.class);
relations = result.get("relations", Long.class);
commitTransaction();
totalNodes += nodes;
totalRelations += relations;
} while (nodes == BATCH_LIMIT);
LOGGER.info("Reset finished (removed " + totalNodes + " nodes, " + totalRelations + " relations).");
}
示例2: getUsers
import com.buschmais.xo.api.Query.Result; //导入依赖的package包/类
@Override
public Set<User> getUsers() {
xoManager.currentTransaction().begin();
try {
Set<User> users = new LinkedHashSet<>();
Result<UserVertex> results = xoManager
.createQuery("g.V().hasLabel('" + UserVertex.NAME + "')", UserVertex.class).execute();
for (UserVertex userVertex : results) {
RoleVertex roleVertex = userVertex.getRole();
Role role = new Role(roleVertex.getId(), roleVertex.getName());
User user = new User(new EmailAddress(userVertex.getEmail()), userVertex.getName(), role);
users.add(user);
}
return users;
} finally {
xoManager.currentTransaction().rollback();
}
}
示例3: findSkywalkerFamily
import com.buschmais.xo.api.Query.Result; //导入依赖的package包/类
@Test
public void findSkywalkerFamily() {
XOManager xoManager = getXOManager();
xoManager.currentTransaction().begin();
Query<Person> query = xoManager
.createQuery("g.V().has('" + StarWarsGraph.LAST_NAME_PROPERTY + "', 'Skywalker')", Person.class);
assertNotNull(query);
Result<Person> results = query.execute();
assertNotNull(results);
int count = 0;
for (Person person : results) {
count++;
assertEquals("Skywalker", person.getLastName());
}
assertEquals(1, count);
xoManager.currentTransaction().commit();
}
示例4: gremlinStringQuery
import com.buschmais.xo.api.Query.Result; //导入依赖的package包/类
@Test
public void gremlinStringQuery() {
XOManager xoManager = getXOManager();
xoManager.currentTransaction().begin();
Result<CompositeRowObject> result = xoManager.createQuery("g.V().hasLabel('A').has('value', {value})")
.withParameter("value", "A1").execute();
A a = result.getSingleResult().get("unknown", A.class);
assertThat(a.getValue(), equalTo("A1"));
result = xoManager.createQuery("g.V().hasLabel('A').has('value', {value})").withParameter("value", "A2")
.execute();
try {
result.getSingleResult().get("a", A.class);
fail("Expecting a " + XOException.class.getName());
} catch (XOException e) {
}
xoManager.currentTransaction().commit();
}
示例5: compositeRowTypedQuery
import com.buschmais.xo.api.Query.Result; //导入依赖的package包/类
@Test
public void compositeRowTypedQuery() {
XOManager xoManager = getXOManager();
xoManager.currentTransaction().begin();
Result<InstanceByValue> result = xoManager.createQuery(InstanceByValue.class).withParameter("value", "A1")
.execute();
A a = result.getSingleResult().getA();
assertThat(a.getValue(), equalTo("A1"));
result = xoManager.createQuery(InstanceByValue.class).withParameter("value", "A2").execute();
try {
result.getSingleResult().getA();
fail("Expecting a " + XOException.class.getName());
} catch (XOException e) {
}
xoManager.currentTransaction().commit();
}
示例6: testRelations
import com.buschmais.xo.api.Query.Result; //导入依赖的package包/类
@Test
@Ignore("Queries are not implemented, yet.")
public void testRelations() {
XOManager xoManager = getXOManager();
xoManager.currentTransaction().begin();
Query<Person> query = xoManager.createQuery("g.V().has('lastName', 'Skywalker').has('firstName','Luke')",
Person.class);
Result<Person> result = query.execute();
Person lukeSkywalker = result.getSingleResult();
assertEquals("Luke", lukeSkywalker.getFirstName());
assertEquals("Skywalker", lukeSkywalker.getLastName());
Person anakinSkywalker = lukeSkywalker.getFather();
assertNotNull(anakinSkywalker);
assertEquals("Anakin", anakinSkywalker.getFirstName());
assertEquals("Skywalker", anakinSkywalker.getLastName());
Person leaSkywalker = lukeSkywalker.getMother();
assertNotNull(leaSkywalker);
assertEquals("Padme", leaSkywalker.getFirstName());
assertEquals("Skywalker", leaSkywalker.getLastName());
xoManager.currentTransaction().commit();
}
示例7: findSkywalkerFamily
import com.buschmais.xo.api.Query.Result; //导入依赖的package包/类
@Test
public void findSkywalkerFamily() {
XOManager xoManager = getXOManager();
xoManager.currentTransaction().begin();
Query<Person> query = xoManager.createQuery(
"_().has('lastName', 'Skywalker')", Person.class);
assertNotNull(query);
Result<Person> results = query.execute();
assertNotNull(results);
int count = 0;
for (Person person : results) {
count++;
assertEquals("Skywalker", person.getLastName());
}
assertEquals(4, count);
xoManager.currentTransaction().commit();
}
示例8: gremlinStringQuery
import com.buschmais.xo.api.Query.Result; //导入依赖的package包/类
@Test
public void gremlinStringQuery() {
XOManager xoManager = getXOManager();
xoManager.currentTransaction().begin();
Result<CompositeRowObject> result = xoManager
.createQuery(
"_().has('_xo_discriminator_A').has('value', {value})")
.withParameter("value", "A1").execute();
A a = result.getSingleResult().get("unknown", A.class);
assertThat(a.getValue(), equalTo("A1"));
result = xoManager
.createQuery(
"_().has('_xo_discriminator_A').has('value', {value})")
.withParameter("value", "A2").execute();
try {
result.getSingleResult().get("a", A.class);
fail("Expecting a " + XOException.class.getName());
} catch (XOException e) {
}
xoManager.currentTransaction().commit();
}
示例9: compositeRowTypedQuery
import com.buschmais.xo.api.Query.Result; //导入依赖的package包/类
@Test
public void compositeRowTypedQuery() {
XOManager xoManager = getXOManager();
xoManager.currentTransaction().begin();
Result<InstanceByValue> result = xoManager
.createQuery(InstanceByValue.class)
.withParameter("value", "A1").execute();
A a = result.getSingleResult().getA();
assertThat(a.getValue(), equalTo("A1"));
result = xoManager.createQuery(InstanceByValue.class)
.withParameter("value", "A2").execute();
try {
result.getSingleResult().getA();
fail("Expecting a " + XOException.class.getName());
} catch (XOException e) {
}
xoManager.currentTransaction().commit();
}
示例10: testRelations
import com.buschmais.xo.api.Query.Result; //导入依赖的package包/类
@Test
public void testRelations() {
XOManager xoManager = getXOManager();
xoManager.currentTransaction().begin();
Query<Person> query = xoManager.createQuery(
"_().has('lastName', 'Skywalker').has('firstName','Luke')",
Person.class);
Result<Person> result = query.execute();
Person lukeSkywalker = result.getSingleResult();
assertEquals("Luke", lukeSkywalker.getFirstName());
assertEquals("Skywalker", lukeSkywalker.getLastName());
Person anakinSkywalker = lukeSkywalker.getFather();
assertNotNull(anakinSkywalker);
assertEquals("Anakin", anakinSkywalker.getFirstName());
assertEquals("Skywalker", anakinSkywalker.getLastName());
Person leaSkywalker = lukeSkywalker.getMother();
assertNotNull(leaSkywalker);
assertEquals("Padme", leaSkywalker.getFirstName());
assertEquals("Skywalker", leaSkywalker.getLastName());
xoManager.currentTransaction().commit();
}
示例11: relation
import com.buschmais.xo.api.Query.Result; //导入依赖的package包/类
@Test
public void relation() {
XOManager xoManager = getXOManager();
xoManager.currentTransaction().begin();
A a = xoManager.create(A.class);
B b = xoManager.create(B.class);
xoManager.create(a, A2B.class, b);
Query<A2B> query = xoManager.createQuery("_().has('"
+ TitanStoreSession.XO_DISCRIMINATORS_PROPERTY + "A').outE",
A2B.class);
Result<A2B> result = query.execute();
A2B a2b = result.getSingleResult();
CompositeObject composite = (CompositeObject) a2b;
Edge edge = composite.getDelegate();
assertThat(edge.getLabel(), equalTo("RELATION"));
xoManager.currentTransaction().commit();
}
示例12: getRoles
import com.buschmais.xo.api.Query.Result; //导入依赖的package包/类
@Override
public Set<Role> getRoles() {
xoManager.currentTransaction().begin();
try {
Set<Role> roles = new LinkedHashSet<>();
Result<RoleVertex> results = xoManager
.createQuery("g.V().hasLabel('" + RoleVertex.NAME + "')", RoleVertex.class).execute();
for (RoleVertex roleVertex : results) {
roles.add(new Role(roleVertex.getId(), roleVertex.getName()));
}
return roles;
} finally {
xoManager.currentTransaction().rollback();
}
}
示例13: resultUsingExplicitQuery
import com.buschmais.xo.api.Query.Result; //导入依赖的package包/类
@Test
public void resultUsingExplicitQuery() {
XOManager xoManager = getXOManager();
xoManager.currentTransaction().begin();
Result<E2F.ByValue> byValue = e2f1.getResultByValueUsingExplicitQuery("E2F1");
assertThat(byValue.getSingleResult().getF(), equalTo(f1));
xoManager.currentTransaction().commit();
}
示例14: resultUsingReturnType
import com.buschmais.xo.api.Query.Result; //导入依赖的package包/类
@Test
public void resultUsingReturnType() {
XOManager xoManager = getXOManager();
xoManager.currentTransaction().begin();
Result<E2F.ByValue> byValue = e2f1.getResultByValueUsingReturnType("E2F1");
assertThat(byValue.getSingleResult().getF(), equalTo(f1));
xoManager.currentTransaction().commit();
}
示例15: resultUsingGremlin
import com.buschmais.xo.api.Query.Result; //导入依赖的package包/类
@Test
public void resultUsingGremlin() {
XOManager xoManager = getXOManager();
xoManager.currentTransaction().begin();
Result<F> result = e2f1.getResultUsingGremlin("E2F1");
assertThat(result, hasItems(equalTo(f1)));
result = e2f1.getResultUsingGremlin("unknownF");
assertThat(result.iterator().hasNext(), equalTo(false));
xoManager.currentTransaction().commit();
}