当前位置: 首页>>代码示例>>Java>>正文


Java MATCH类代码示例

本文整理汇总了Java中iot.jcypher.query.factories.clause.MATCH的典型用法代码示例。如果您正苦于以下问题:Java MATCH类的具体用法?Java MATCH怎么用?Java MATCH使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MATCH类属于iot.jcypher.query.factories.clause包,在下文中一共展示了MATCH类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isDatabaseEmpty

import iot.jcypher.query.factories.clause.MATCH; //导入依赖的package包/类
public static boolean isDatabaseEmpty(IDBAccess dbAccess) {
		JcNode n = new JcNode("n");
		JcRelation r = new JcRelation("r");
		JcQuery query = new JcQuery();
		query.setClauses(new IClause[] {
				MATCH.node(n),
				SEPARATE.nextClause(),
				MATCH.node().relation(r).node(),
				RETURN.ALL()
		});
//		Util.printQuery(query, "CHECK", Format.PRETTY_1);
		JcQueryResult result = dbAccess.execute(query);
		if (result.hasErrors()) {
			List<JcError> errors = Util.collectErrors(result);
			throw new JcResultException(errors);
		}
//		Util.printResult(result, "CHECK", Format.PRETTY_1);
		
		// perform check
		List<GrNode> nodes = result.resultOf(n);
		List<GrRelation> relations = result.resultOf(r);
		return nodes.size() == 0 && relations.size() == 0;
	}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:24,代码来源:DBUtil.java

示例2: getStoredQueryNames

import iot.jcypher.query.factories.clause.MATCH; //导入依赖的package包/类
List<String> getStoredQueryNames() {
	List<String> ret = new ArrayList<String>();
	IDBAccess dba = ((DBAccessWrapper)this.dbAccess).delegate;
	String qLabel = this.getDomainLabel()	.concat(QueryPersistor.Q_LABEL_POSTFIX);
	
	JcNode n = new JcNode("n");
	IClause[] clauses = new IClause[] {
			MATCH.node(n).label(qLabel),
			RETURN.value(n)
	};
	JcQuery q = new JcQuery();
	q.setClauses(clauses);
	JcQueryResult result = dba.execute(q);
	if (result.hasErrors()) {
		StringBuilder sb = new StringBuilder();
		Util.appendErrorList(Util.collectErrors(result), sb);
		throw new RuntimeException(sb.toString());
	}
	List<GrNode> lgn = result.resultOf(n);
	for (GrNode rn : lgn) {
		ret.add(rn.getProperty(QueryPersistor.PROP_NAME).getValue().toString());
	}
	return ret;
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:25,代码来源:DomainAccess.java

示例3: queryResult

import iot.jcypher.query.factories.clause.MATCH; //导入依赖的package包/类
/**
 * return a node, the node's relations, and the node's adjacent nodes.
 * @param personId
 * @param lockingStrategy
 * @return
 */
static QResult queryResult(long personId, Locking lockingStrategy, IDBAccess dba) {
	QResult res = new QResult();
	
	JcNode persN = new JcNode("a");
	JcRelation pocsR = new JcRelation("r");
	JcNode pocsN = new JcNode("b");
	IClause[] clauses = new IClause[] {
			MATCH.node(persN).relation(pocsR).node(pocsN),
			WHERE.valueOf(persN.id()).EQUALS(personId),
			RETURN.ALL()
	};
	JcQuery query = new JcQuery();
	query.setClauses(clauses);
	//String qStr = print(query, Format.PRETTY_1);
	JcQueryResult result = dba.execute(query);
	res.node = result.resultOf(persN).get(0);
	res.relations = result.resultOf(pocsR);
	res.relatedNodes = result.resultOf(pocsN);
	res.graph = result.getGraph().setLockingStrategy(lockingStrategy);
	
	return res;
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:29,代码来源:ConcurrencyGraphTest.java

示例4: queryResult2

import iot.jcypher.query.factories.clause.MATCH; //导入依赖的package包/类
/**
 * return a node, the node's pointOfContact relations, and the node's PointsOfContact.
 * @param personId
 * @param lockingStrategy
 * @return
 */
static QResult queryResult2(long personId, Locking lockingStrategy, IDBAccess dba) {
	QResult res = new QResult();
	
	JcNode persN = new JcNode("a");
	JcRelation pocsR = new JcRelation("r");
	JcNode pocsN = new JcNode("b");
	IClause[] clauses = new IClause[] {
			MATCH.node(persN).relation().type("pointsOfContact").out().node()
				.relation(pocsR).out().node(pocsN),
			WHERE.valueOf(persN.id()).EQUALS(personId),
			RETURN.ALL()
	};
	JcQuery query = new JcQuery();
	query.setClauses(clauses);
	//String qStr = print(query, Format.PRETTY_1);
	JcQueryResult result = dba.execute(query);
	res.node = result.resultOf(persN).get(0);
	res.relations = result.resultOf(pocsR);
	res.relatedNodes = result.resultOf(pocsN);
	res.graph = result.getGraph().setLockingStrategy(lockingStrategy);
	
	return res;
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:30,代码来源:ConcurrencyGraphTest.java

示例5: insertBooking

import iot.jcypher.query.factories.clause.MATCH; //导入依赖的package包/类
public void insertBooking(Booking booking) {

		JcNode b = new JcNode("b");
		JcNode e = new JcNode("e");

		JcQuery nodeQuery = new JcQuery();
		nodeQuery.setClauses(
				new IClause[] { MERGE.node(b).label(BOOKING_LABEL).property(ID_PARAMETER).value(booking.getId()),
						DO.SET(b.property("fraud")).to(booking.getFraud()),
						DO.SET(b.property("status")).to(booking.getStatus()),
						MERGE.node(e).label(EMAIL_LABEL).property(EMAIL_PROPERTY).value(booking.getEmail()) });

		JcQuery relationQuery = new JcQuery();
		relationQuery.setClauses(
				new IClause[] { MATCH.node(b).label(BOOKING_LABEL).property(ID_PARAMETER).value(booking.getId()),
						MATCH.node(e).label(EMAIL_LABEL).property("email").value(booking.getEmail()),
						MERGE.node(b).relation().type("WITH_EMAIL").node(e) });

		dbAccess.execute(Arrays.asList(nodeQuery, relationQuery));
	}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:21,代码来源:JCypherClient.java

示例6: checkDomainInfoNodeAgainst

import iot.jcypher.query.factories.clause.MATCH; //导入依赖的package包/类
private boolean checkDomainInfoNodeAgainst(String expected) {
	JcNode info = new JcNode("info");
	JcQuery query = new JcQuery();
	query.setClauses(new IClause[] {
			MATCH.node(info).label("DomainInfo"),
			WHERE.valueOf(info.property("name"))
				.EQUALS(domainName),
			RETURN.value(info)
	});
	JcQueryResult result = dbAccess.execute(query);
	List<JcError> errors = Util.collectErrors(result);
	if (!errors.isEmpty()) {
		throw new JcResultException(errors);
	}
	GrNode rInfo = result.resultOf(info).get(0);
	GrProperty prop = rInfo.getProperty("label2ClassMap");
	Object val = prop.getValue();
	String returned = val.toString();
	return expected.equals(returned);
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:21,代码来源:DomainMappingTest.java

示例7: SAVE

import iot.jcypher.query.factories.clause.MATCH; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private Block SAVE(final String sid, final String label, final long accessedAt,
    final long createdAt, final long savedAt, final long timeout) {
  return unit -> {
    {
      unit.mockStatic(MATCH.class);

      Node node = unit.mock(Node.class);

      Property<Node> prop = unit.mock(Property.class);
      expect(prop.value(sid)).andReturn(node);

      expect(node.label(label)).andReturn(node);
      expect(node.property("_id")).andReturn(prop);
      expect(MATCH.node(unit.get(JcNode.class))).andReturn(node);
    }

    DO_SET(unit, "_accessedAt", accessedAt);
    DO_SET(unit, "_createdAt", createdAt);
    DO_SET(unit, "_savedAt", savedAt);
    DO_SET(unit, "_expire", timeout);
    DO_SET(unit, "foo", "bar");
  };
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:25,代码来源:Neo4jSessionStoreTest.java

示例8: queryMovieGraph

import iot.jcypher.query.factories.clause.MATCH; //导入依赖的package包/类
/**
 * Query the entire graph
 */
static void queryMovieGraph() {
	
	String queryTitle = "MOVIE_GRAPH";
	JcNode movie = new JcNode("movie");
	JcNode actor = new JcNode("actor");
	
	/*******************************/
	JcQuery query = new JcQuery();
	query.setClauses(new IClause[] {
			MATCH.node(actor).label("Actor").relation().out().type("ACTS_IN").node(movie),
			RETURN.value(actor),
			RETURN.value(movie)
	});
	/** map to CYPHER statements and map to JSON, print the mapping results to System.out.
     This will show what normally is created in the background when accessing a Neo4j database*/
	print(query, queryTitle, Format.PRETTY_3);
	
	/** execute the query against a Neo4j database */
	JcQueryResult result = dbAccess.execute(query);
	if (result.hasErrors())
		printErrors(result);
	
	/** print the JSON representation of the query result */
	print(result, queryTitle);
	
	List<GrNode> actors = result.resultOf(actor);
	List<GrNode> movies = result.resultOf(movie);
	
	print(actors, true);
	print(movies, true);
	
	return;
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher_samples,代码行数:37,代码来源:MovieDatabase.java

示例9: loadMemento

import iot.jcypher.query.factories.clause.MATCH; //导入依赖的package包/类
/**
 * The memento contains a JSON representation of the query as well as a Java-DSL like string representation.
 * @return
 */
public QueryMemento loadMemento() {
	IDBAccess dbAccess = ((IIntDomainAccess)this.domainAccess).getInternalDomainAccess().getDBAccess();
	String qLabel = ((IIntDomainAccess)this.domainAccess).getInternalDomainAccess().getDomainLabel()
			.concat(QueryPersistor.Q_LABEL_POSTFIX);
	
	JcNode n = new JcNode("n");
	IClause[] clauses = new IClause[] {
			MATCH.node(n).label(qLabel).property(QueryPersistor.PROP_NAME).value(queryName),
			RETURN.value(n)
	};
	JcQuery q = new JcQuery();
	q.setClauses(clauses);
	JcQueryResult result = dbAccess.execute(q);
	if (result.hasErrors()) {
		StringBuilder sb = new StringBuilder();
		Util.appendErrorList(Util.collectErrors(result), sb);
		throw new RuntimeException(sb.toString());
	}
	List<GrNode> lgn = result.resultOf(n);
	if (lgn.size() > 0) {
		GrNode gn = lgn.get(0);
		String qJava = gn.getProperty(QueryPersistor.PROP_Q_JAVA).getValue().toString();
		String qJSON = gn.getProperty(QueryPersistor.PROP_Q_JSON).getValue().toString();
		QueryMemento qm = new QueryMemento(qJava, qJSON);
		return qm;
	}
	return null;
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:33,代码来源:QueryLoader.java

示例10: clearDatabase

import iot.jcypher.query.factories.clause.MATCH; //导入依赖的package包/类
public static List<JcError> clearDatabase(IDBAccess dbAccess) {
	JcNode n = new JcNode("n");
	JcRelation r = new JcRelation("r");
	IClause[] clauses = new IClause[] {
			MATCH.node(n),
			OPTIONAL_MATCH.node(n).relation(r).node(),
			DO.DELETE(n),
			DO.DELETE(r)
	};
	JcQuery query = new JcQuery();
	query.setClauses(clauses);
	JcQueryResult result = dbAccess.execute(query);
	List<JcError> errors = Util.collectErrors(result);
	return errors;
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:16,代码来源:DBUtil.java

示例11: loadAllDomainInfoNodes

import iot.jcypher.query.factories.clause.MATCH; //导入依赖的package包/类
private static List<GrNode> loadAllDomainInfoNodes (IDBAccess dbAccess) {
	JcNode n = new JcNode("n");
	JcQuery query = new JcQuery();
	query.setClauses(new IClause[] {
			MATCH.node(n).label(DomainInfoNodeLabel),
			RETURN.value(n)
	});
	JcQueryResult result = dbAccess.execute(query);
	List<JcError> errors = Util.collectErrors(result);
	if (errors.size() > 0) {
		throw new JcResultException(errors);
	}
	return result.resultOf(n);
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:15,代码来源:DomainInformation.java

示例12: test_12

import iot.jcypher.query.factories.clause.MATCH; //导入依赖的package包/类
@Test
public void test_12() {

	JcNode user = new JcNode("u");
	JcNode team = new JcNode("t");
	JcRelation r = new JcRelation("r");
	JcNode score = new JcNode("Score");
	JcNode partupId = new JcNode("partupId");
	JcNumber num_0 = new JcNumber(0);
	IClause[] clauses = new IClause[] {
			MATCH.node(user).label("User").relation(r).type("RECOMMEND").node(team).label("Team"),
			WHERE.valueOf(user.property("_id")).EQUALS("..."),
			WITH.value(JC.coalesce(r.property("nearbyTeams"), num_0).asNumber().plus(
					JC.coalesce(r.property("nearbyTeamsinNetworks"), num_0).asNumber().plus(
							JC.coalesce(r.property("daysActive"), num_0).asNumber().plus(
									JC.coalesce(r.property("parnersLimit"), num_0).asNumber().plus(
											JC.coalesce(r.property("sameCity"), num_0).asNumber().plus(
													JC.coalesce(r.property("sameCountry"), num_0).asNumber().plus(
															JC.coalesce(r.property("sameLanguage"), num_0).asNumber().plus(
																	JC.coalesce(r.property("sameTags"), num_0).asNumber())))))))).AS(score),
			WITH.value(team.property("_id")).AS(partupId),
			RETURN.value(score),
			RETURN.value(partupId)
	};
	String result = print(clauses, Format.PRETTY_1);
	
	return;
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:29,代码来源:TempTest.java

示例13: getBookingsRelated

import iot.jcypher.query.factories.clause.MATCH; //导入依赖的package包/类
public List<GrRelation> getBookingsRelated(Long bookingId, int maxHops) {
	JcQuery nodeQuery = new JcQuery();
	JcNode b = new JcNode("b");
	JcNode b2 = new JcNode("b2");
	JcRelation r = new JcRelation("r");
	nodeQuery.setClauses(new IClause[] { MATCH.node(b).label(BOOKING_LABEL).property(ID_PARAMETER).value(bookingId)
			.relation(r).maxHops(maxHops).node(b2), RETURN.DISTINCT().value(r) });
	return dbAccess.execute(nodeQuery).resultOf(r);
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:10,代码来源:JCypherClient.java

示例14: queryDB_01

import iot.jcypher.query.factories.clause.MATCH; //导入依赖的package包/类
private void queryDB_01() {
	setDoPrint(true);
	setDoAssert(true);

	JcQueryResult result;
	
	JcNode movie = new JcNode("movie");
	JcNode actor = new JcNode("actor");
	
	/*******************************/
	JcQuery query = new JcQuery();
	query.setClauses(new IClause[] {
			MATCH.node(actor).label("Actor").relation().out().type("ACTS_IN").node(movie),
			RETURN.value(actor),
			RETURN.value(movie)
	});
	result = dbAccess.execute(query);
	if (result.hasErrors())
		printErrors(result);
	assertFalse(result.hasErrors());
	
	List<GrNode> actors = result.resultOf(actor);
	List<GrNode> movies = result.resultOf(movie);
	
	assertTrue(containsProperty("name", "Keanu Reeves", actors));
	assertTrue(containsProperty("name", "Laurence Fishburne", actors));
	assertTrue(containsProperty("name", "Carrie-Anne Moss", actors));
	
	assertTrue(containsProperty("title", "The Matrix", movies));
	assertTrue(containsProperty("title", "The Matrix Reloaded", movies));
	assertTrue(containsProperty("title", "The Matrix Revolutions", movies));
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:33,代码来源:GraphModelTest.java

示例15: get

import iot.jcypher.query.factories.clause.MATCH; //导入依赖的package包/类
@Override
public Session get(final Session.Builder builder) {
  String sid = builder.sessionId();
  JcNode node = new JcNode("n");
  JcQuery query = new JcQuery();
  query.setClauses(new IClause[]{
      MATCH.node(node).label(label).property("_id").value(sid),
      // touch session
      DO.SET(node.property("_expire")).to(expire.getAsLong()),
      RETURN.value(node)
  });

  List<GrNode> result = db.execute(query).resultOf(node);
  log.debug("touch {} session {} ", sid, result);
  if (result.size() == 1) {
    GrNode found = result.get(0);
    builder
        .accessedAt(((Number) found.getProperty("_accessedAt").getValue()).longValue())
        .createdAt(((Number) found.getProperty("_createdAt").getValue()).longValue())
        .savedAt(((Number) found.getProperty("_savedAt").getValue()).longValue());

    found.getProperties()
        .stream()
        .filter(it -> !SPECIAL.contains(it.getName()))
        .forEach(p -> builder.set(p.getName(), p.getValue().toString()));

    return builder.build();
  }

  return null;
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:32,代码来源:Neo4jSessionStore.java


注:本文中的iot.jcypher.query.factories.clause.MATCH类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。