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


Java IClause类代码示例

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


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

示例1: storeAs

import iot.jcypher.query.api.IClause; //导入依赖的package包/类
/**
 * Store the query with the domain model under the given name.
 * @param queryName
 */
public void storeAs(String queryName) {
	QueryRecorder.queryCompleted(this.query);
	QueryMemento qm = this.createMemento();
	IDBAccess dbAccess = ((IIntDomainAccess)this.domainAccess).getInternalDomainAccess().getDBAccess();
	String qLabel = ((IIntDomainAccess)this.domainAccess).getInternalDomainAccess().getDomainLabel()
			.concat(Q_LABEL_POSTFIX);
	
	JcNode n = new JcNode("n");
	IClause[] clauses = new IClause[] {
			MERGE.node(n).label(qLabel).property(PROP_NAME).value(queryName),
			DO.SET(n.property(PROP_Q_JAVA)).to(qm.getQueryJava()),
			DO.SET(n.property(PROP_Q_JSON)).to(qm.getQueryJSON())
	};
	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());
	}
	return;
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:28,代码来源:QueryPersistor.java

示例2: indexOfOrderClause

import iot.jcypher.query.api.IClause; //导入依赖的package包/类
private int indexOfOrderClause(ClausesPerType cpt, List<IClause> clauses) {
	int strt = clauses.size() - 1;
	while(strt >= 0 && clauses.get(strt) instanceof SEPARATE)
		strt--;
	int idx = -1;
	for (int i = strt; i >= 0; i--) {
		IClause clause = clauses.get(i);
		if (clause instanceof RSortable) { // only RSortables can be ordered
			// can only be a ReturnExpression
			ReturnExpression rexp = (ReturnExpression)APIObjectAccess.getAstNode((APIObject) clause);
			if (rexp.getAlias() != null && ValueAccess.isSame(rexp.getAlias(), cpt.node)) {
				idx = i;
				break;
			} else if (rexp.getReturnValue() instanceof ReturnElement) {
				JcValue elem = ((ReturnElement)rexp.getReturnValue()).getElement();
				if (ValueAccess.isSame(elem, cpt.node)) {
					idx = i;
					break;
				}
			}
		} else
			break;
	}
	return idx;
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:26,代码来源:QueryExecutor.java

示例3: addCountWithClause

import iot.jcypher.query.api.IClause; //导入依赖的package包/类
private void addCountWithClause(JcNode n, List<IClause> countWithClauses,
		List<IClause> selfWithClauses, List<IClause> selectClauses, ClausesPerType cpt,
		boolean addSelf) {
	String nnm = ValueAccess.getName(n);
	String alias = nnm.concat(countXprPostPrefix);
	JcNumber num = new JcNumber(alias);
	selectClauses.add(WITH.count().DISTINCT().value(n).AS(num));
	if (addSelf)
		selectClauses.add(WITH.value(n));
	selectClauses.addAll(countWithClauses);
	if (addSelf)
		selectClauses.addAll(selfWithClauses);
	if (cpt.withClausesAddIdxs == null)
		cpt.withClausesAddIdxs = new ArrayList<Integer>();
	cpt.withClausesAddIdxs.add(0, selectClauses.size());
	countWithClauses.add(0, WITH.value(num));
	if (addSelf)
		selfWithClauses.add(WITH.value(n));
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:20,代码来源:QueryExecutor.java

示例4: addDependencyClauses

import iot.jcypher.query.api.IClause; //导入依赖的package包/类
private void addDependencyClauses(List<IClause> clauses, List<ClausesPerType> added,
					OrderClausesHolder withClausesHolder, ClauseBuilderContext cbContext,
					boolean isCountQuery) {
				if (this.expressionsPerDOM.flattenedDependencies != null) {
					for (ExpressionsPerDOM xpd : this.expressionsPerDOM.flattenedDependencies) {
						// for a traversal expression for this select expression we do not need to
						// add the original traversal expression, because the select expression
						// will work on the clones.
						List<DomainObjectMatch<?>> collOwner = APIAccess.getCollectExpressionOwner(xpd.domainObjectMatch);
						boolean addExpressions = collOwner == null || !collOwner.contains(this.domainObjectMatch);
						for (ClausesPerType cpt : xpd.clausesPerTypes) {
							if (cbContext.isNodeValid(cpt.node)) {
								if (!added.contains(cpt)) {
									if (addExpressions) {
										if (!isCountQuery)
											withClausesHolder.checkForOrdeClause(cpt);
										cpt.addClausesTo(clauses, added);
										added.add(cpt);
									}
//									added.add(cpt);
								}
							}
						}
					}
				}
			}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:27,代码来源:QueryExecutor.java

示例5: addCreateNodeClause

import iot.jcypher.query.api.IClause; //导入依赖的package包/类
private void addCreateNodeClause(GrNode node,
		List<IClause> clauses, Map<GrNode, JcNode> localNodeMap,
		List<GrNode2JcNode> nodesToCreate) {
	String nm = "ln_".concat(String.valueOf(clauses.size()));
	JcNode n = new JcNode(nm);
	nodesToCreate.add(new GrNode2JcNode(node, n));
	Node create = CREATE.node(n);
	for (GrLabel label : node.getLabels()) {
		create = create.label(label.getName());
	}
	for (GrProperty prop : node.getProperties()) {
		create = create.property(prop.getName()).value(prop.getValue());
	}
	if (writeVersion || lockingStrategy == Locking.OPTIMISTIC)
		create = create.property(ResultHandler.lockVersionProperty).value(0);
	clauses.add(create);
	localNodeMap.put(node, n);
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:19,代码来源:ResultHandler.java

示例6: addCreateRelationClause

import iot.jcypher.query.api.IClause; //导入依赖的package包/类
private void addCreateRelationClause(GrRelation relation,
		List<IClause> createRelationClauses,
		Map<GrNode, JcNode> localNodeMap, Map<GrNode, JcNode> dbNodeMap,
		List<IClause> startNodeClauses, List<GrRelation2JcRelation> relationsToCreate) {
	String nm = "lr_".concat(String.valueOf(createRelationClauses.size()));
	JcRelation r = new JcRelation(nm);
	relationsToCreate.add(new GrRelation2JcRelation(relation, r));
	GrNode sNode = relation.getStartNode();
	GrNode eNode = relation.getEndNode();
	JcNode sn = getNode(sNode, localNodeMap, dbNodeMap, startNodeClauses);
	JcNode en = getNode(eNode, localNodeMap, dbNodeMap, startNodeClauses);
	Relation create = CREATE.node(sn).relation(r).out();
	if (relation.getType() != null)
		create = create.type(relation.getType());
	for (GrProperty prop : relation.getProperties()) {
		create = create.property(prop.getName()).value(prop.getValue());
	}
	if (writeVersion || lockingStrategy == Locking.OPTIMISTIC)
		create = create.property(ResultHandler.lockVersionProperty).value(0);
	createRelationClauses.add(create.node(en));
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:22,代码来源:ResultHandler.java

示例7: buildChangedLabelsClauses

import iot.jcypher.query.api.IClause; //导入依赖的package包/类
private Collection<? extends IClause> buildChangedLabelsClauses(
		GrPropertyContainer element) {
	List<IClause> ret = new ArrayList<IClause>();
	if (element instanceof GrNode) {
		GrNode node = (GrNode)element;
		List<GrLabel> modified = GrAccess.getModifiedLabels(node);
		Iterator<GrLabel> lit = modified.iterator();
		while (lit.hasNext()) {
			GrLabel lab = lit.next();
			SyncState state = GrAccess.getState(lab);
			JcNode elem = new JcNode("elem");
			IClause c = null;
			// a label can only be created and added or it can be removed
			// but a label can never be changed
			if (state == SyncState.NEW) {
				c = DO.SET(elem.label(lab.getName()));
			} else if (state == SyncState.REMOVED) {
				c = DO.REMOVE(elem.label(lab.getName()));
			}
			ret.add(c);
		}
	}
	return ret;
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:25,代码来源:ResultHandler.java

示例8: isDatabaseEmpty

import iot.jcypher.query.api.IClause; //导入依赖的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

示例9: getStoredQueryNames

import iot.jcypher.query.api.IClause; //导入依赖的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

示例10: queryResult

import iot.jcypher.query.api.IClause; //导入依赖的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

示例11: queryResult2

import iot.jcypher.query.api.IClause; //导入依赖的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

示例12: testDeletedRelation

import iot.jcypher.query.api.IClause; //导入依赖的package包/类
static boolean testDeletedRelation(long relId, IDBAccess dba) {
	JcRelation a = new JcRelation("a");
	IClause[] clauses = new IClause[] {
			START.relation(a).byId(relId),
			RETURN.ALL()
	};
	JcQuery query = new JcQuery();
	query.setClauses(clauses);
	//String qStr = print(query, Format.PRETTY_1);
	JcQueryResult result = dba.execute(query);
	try {
		 List<GrRelation> ares = result.resultOf(a);
		return ares.size() == 0 || (ares.size() == 1 && ares.get(0) == null);
	} catch (IndexOutOfBoundsException e) {
		return true;
	}
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:18,代码来源:ConcurrencyGraphTest.java

示例13: testExperimental

import iot.jcypher.query.api.IClause; //导入依赖的package包/类
public void testExperimental() {
	JcRelation r_0 = new JcRelation("r_0");
	JcRelation r_1 = new JcRelation("r_1");
	JcNumber sum = new JcNumber("sum");
	IClause[] clauses = new IClause[] {
			OPTIONAL_MATCH.node().relation(r_0).node(),
			WHERE.valueOf(r_0.id()).EQUALS(100),
			OPTIONAL_MATCH.node().relation(r_1).node(),
			WHERE.valueOf(r_1.id()).EQUALS(101),
			WITH.value(r_0),
			WITH.value(r_1),
			WITH.value(r_0.numberProperty("_c_version_").plus(r_1.numberProperty("_c_version_"))).AS(sum),
			RETURN.value(r_0),
			RETURN.value(r_1),
			RETURN.value(sum)
	};
	String result = print(clauses, Format.PRETTY_1);
	return;
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:20,代码来源:ClauseTest.java

示例14: testOptionalMatch_01

import iot.jcypher.query.api.IClause; //导入依赖的package包/类
@Test
public void testOptionalMatch_01() {
	String result;
	String testId;
	setDoPrint(true);
	setDoAssert(true);
	
	TestDataReader tdr = new TestDataReader("/test/Test_OPTIONAL_MATCH_01.txt");
	
	JcNode a = new JcNode("a");
	JcRelation r = new JcRelation("r");
	
	/*******************************/
	IClause match = OPTIONAL_MATCH.node(a).relation(r).out().type("ACTS_IN").node();
	
	result = print(match, Format.PRETTY_1);
	testId = "OPTIONAL_MATCH_01";
	assertQuery(testId, result, tdr.getTestData(testId));
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:20,代码来源:ClauseTest.java

示例15: testIndex_01

import iot.jcypher.query.api.IClause; //导入依赖的package包/类
@Test
public void testIndex_01() {
	String result;
	String testId;
	setDoPrint(true);
	setDoAssert(true);

	TestDataReader tdr = new TestDataReader("/test/Test_INDEX_01.txt");
	
	/*******************************/
	IClause index = CREATE_INDEX.onLabel("Person").forProperty("name");

	result = print(index, Format.PRETTY_1);
	testId = "INDEX_01";
	assertQuery(testId, result, tdr.getTestData(testId));
	
	/*******************************/
	index = DROP_INDEX.onLabel("Person").forProperty("name");

	result = print(index, Format.PRETTY_1);
	testId = "INDEX_02";
	assertQuery(testId, result, tdr.getTestData(testId));
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:24,代码来源:ClauseTest.java


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