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


Java CREATE类代码示例

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


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

示例1: addCreateNodeClause

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

示例2: addCreateRelationClause

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

示例3: create

import iot.jcypher.query.factories.clause.CREATE; //导入依赖的package包/类
@Test
public void create() throws Exception {
  new MockUnit(IDBAccess.class, Session.class)
      .expect(sid("sidfoo", ImmutableMap.of("foo", "bar"), 1L, 2L, 3L))
      .expect(newNode("n"))
      .expect(millis())
      .expect(SAVE("sidfoo", "session", 1L, 2L, 3L, TimeUnit.MINUTES.toMillis(30)))
      .expect(newQuery())
      .expect(execute())
      .expect(emptyResultOf())
      .expect(newQuery())
      .expect(CREATE("sidfoo", "session", 1L, 2L, 3L, TimeUnit.MINUTES.toMillis(30)))
      .expect(execute())
      .expect(emptyResultOf())
      .run(unit -> {
        new Neo4jSessionStore(unit.get(IDBAccess.class), "session", "30m")
            .create(unit.get(Session.class));
      });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:20,代码来源:Neo4jSessionStoreTest.java

示例4: createAdditionalNodes

import iot.jcypher.query.factories.clause.CREATE; //导入依赖的package包/类
/**
 * Create additional nodes in the movie database
 */
static void createAdditionalNodes() {
	JcNode escape_plan = new JcNode("escape_plan");
	JcNode arnie = new JcNode("arnie");
	JcNode sylvester = new JcNode("sylvester");
	
	/**
	 * -----------------------------------------------------------------
	 * Create the movie database
	 */
	String queryTitle = "CREATE ADDITIONAL NODES";
	JcQuery query = new JcQuery();
	query.setClauses(new IClause[] {
			CREATE.node(escape_plan).label("Movie")
					.property("title").value("Escape Plan")
					.property("year").value("2013-03-31"),
			CREATE.node(arnie).label("Actor")
					.property("name").value("Arnold Schwarzenegger")
					.property("like").value(9.0),
			CREATE.node(sylvester).label("Actor")
					.property("name").value("Sylvester Stalone")
					.property("like").value(9.0),
			CREATE.node(arnie).relation().out().type("ACTS_IN").property("role").value("Prisoner").node(escape_plan),
			CREATE.node(sylvester).relation().out().type("ACTS_IN").property("role").value("Prisoner").node(escape_plan)
	});
	/** 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);
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher_samples,代码行数:40,代码来源:MovieDatabase.java

示例5: CREATE

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

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

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

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

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

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

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

      Property<Node> _foo = unit.mock(Property.class);
      expect(_foo.value("bar")).andReturn(node);

      expect(node.label(label)).andReturn(node);
      expect(node.property("_id")).andReturn(id);
      expect(node.property("_accessedAt")).andReturn(_accessedAt);
      expect(node.property("_savedAt")).andReturn(_savedAt);
      expect(node.property("_createdAt")).andReturn(_createdAt);
      expect(node.property("_expire")).andReturn(_expire);
      expect(node.property("foo")).andReturn(_foo);
      expect(CREATE.node(unit.get(JcNode.class))).andReturn(node);
    }
  };
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:39,代码来源:Neo4jSessionStoreTest.java

示例6: createMovieDatabaseByQuery

import iot.jcypher.query.factories.clause.CREATE; //导入依赖的package包/类
/**
 * Create the movie database
 */
static void createMovieDatabaseByQuery() {
	JcNode matrix1 = new JcNode("matrix1");
	JcNode matrix2 = new JcNode("matrix2");
	JcNode matrix3 = new JcNode("matrix3");
	JcNode keanu = new JcNode("keanu");
	JcNode laurence = new JcNode("laurence");
	JcNode carrieanne = new JcNode("carrieanne");
	
	/**
	 * -----------------------------------------------------------------
	 * Create the movie database
	 */
	String queryTitle = "CREATE MOVIE DATABASE";
	JcQuery query = new JcQuery();
	query.setClauses(new IClause[] {
			CREATE.node(matrix1).label("Movie")
					.property("title").value("The Matrix")
					.property("year").value("1999-03-31"),
			CREATE.node(matrix2).label("Movie")
					.property("title").value("The Matrix Reloaded")
					.property("year").value("2003-05-07"),
			CREATE.node(matrix3).label("Movie")
					.property("title").value("The Matrix Revolutions")
					.property("year").value("2003-10-27"),
			CREATE.node(keanu).label("Actor")
					.property("name").value("Keanu Reeves")
					.property("like").value(8.5)
					.property("numbers").values(1, 2, 3),
			CREATE.node(laurence).label("Actor")
					.property("name").value("Laurence Fishburne")
					.property("like").value(7),
			CREATE.node(carrieanne).label("Actor")
					.property("name").value("Carrie-Anne Moss")
					.property("like").value(8.3),
			CREATE.node(keanu).relation().out().type("ACTS_IN").property("role").value("Neo").node(matrix1),
			CREATE.node(keanu).relation().out().type("ACTS_IN").property("role").value("Neo").node(matrix2),
			CREATE.node(keanu).relation().out().type("ACTS_IN").property("role").value("Neo").node(matrix3),
			CREATE.node(laurence).relation().out().type("ACTS_IN").property("role").value("Morpheus").node(matrix1),
			CREATE.node(laurence).relation().out().type("ACTS_IN").property("role").value("Morpheus").node(matrix2),
			CREATE.node(laurence).relation().out().type("ACTS_IN").property("role").value("Morpheus").node(matrix3),
			CREATE.node(carrieanne).relation().out().type("ACTS_IN").property("role").value("Trinity").node(matrix1),
			CREATE.node(carrieanne).relation().out().type("ACTS_IN").property("role").value("Trinity").node(matrix2),
			CREATE.node(carrieanne).relation().out().type("ACTS_IN").property("role").value("Trinity").node(matrix3)
	});
	/** 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);
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher_samples,代码行数:60,代码来源:MovieDatabase.java

示例7: testForEach_Do_01

import iot.jcypher.query.factories.clause.CREATE; //导入依赖的package包/类
@Test
	public void testForEach_Do_01() {
		String result;
		String testId;
		setDoPrint(true);
		setDoAssert(true);
		
		TestDataReader tdr = new TestDataReader("/test/Test_CASE_01.txt");
		
		JcNode n = new JcNode("n");
		JcValue x = new JcValue("x");
		
		/*******************************/
//		IClause foreach = FOR_EACH.element(x).IN_list("Stan", "Will", "Henry").DO().
//				CREATE(X.node().property("name").value(x).relation().in().node(n))
//				.AND_DO()
//				.SET(n.property("name")).to("John");
//		
//		result = print(foreach, Format.PRETTY_1);
		
//		foreach = FOR_EACH.element(x).IN_list("Stan", "Will", "Henry").DO(new IClause[]{
//				CREATE.node().property("name").value(x).relation().in().node(n),
//				DO.SET(n.property("name")).to("John")
//		});
//		
//		result = print(foreach, Format.PRETTY_1);
		
		/*******************************/
		IClause[] clauses = new IClause[] {
				MATCH.node(n).label("Person"),
				WHERE.valueOf(n.property("lastName")).EQUALS("Smith"),
				FOR_EACH.element(x).IN(C.CREATE(new IClause[]{
						CASE.result(),
						WHEN.valueOf(n.property("firstName")).EQUALS("John"),
							NATIVE.cypher("[1]"),
						ELSE.perform(),
							NATIVE.cypher("[]"),
						END.caseXpr()
				})).DO(new IClause[]{
						CREATE.node().property("name").value("Johnnys_Relative").relation().in().node(n),
						DO.SET(n.property("name")).to("John")
				})
		};
		
		result = print(clauses, Format.PRETTY_1);
		testId = "CASE_05";
		assertQuery(testId, result, tdr.getTestData(testId));
		
		return;
	}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:51,代码来源:ClauseTest.java

示例8: testForEach_Case_01

import iot.jcypher.query.factories.clause.CREATE; //导入依赖的package包/类
@Test
public void testForEach_Case_01() {
	String result;
	String testId;
	setDoPrint(true);
	setDoAssert(true);
	
	TestDataReader tdr = new TestDataReader("/test/Test_CASE_01.txt");
	
	JcNode n = new JcNode("n");
	JcValue x = new JcValue("x");
	
	/*******************************/
	IClause[] clauses = new IClause[] {
			MATCH.node(n).label("Person"),
			WHERE.valueOf(n.property("lastName")).EQUALS("Smith"),
			FOR_EACH.element(x).IN(C.CREATE(new IClause[]{
					CASE.result(),
					WHEN.valueOf(n.property("firstName")).EQUALS("John"),
						NATIVE.cypher("[1]"),
					ELSE.perform(),
						NATIVE.cypher("[]"),
					END.caseXpr()
			})).DO().SET(n.property("role")).to("Father"),
			FOR_EACH.element(x).IN(C.CREATE(new IClause[]{
					CASE.result(),
					WHEN.valueOf(n.property("firstName")).EQUALS("Caroline"),
						NATIVE.cypher("[1]"),
					ELSE.perform(),
						NATIVE.cypher("[]"),
					END.caseXpr()
			})).DO().SET(n.property("role")).to("Mother"),
			RETURN.value(n)
	};
	
	result = print(clauses, Format.PRETTY_1);
	testId = "CASE_04";
	assertQuery(testId, result, tdr.getTestData(testId));
	
	return;
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:42,代码来源:ClauseTest.java

示例9: createDB_01

import iot.jcypher.query.factories.clause.CREATE; //导入依赖的package包/类
private void createDB_01() {
	
	JcNode matrix1 = new JcNode("matrix1");
	JcNode matrix2 = new JcNode("matrix2");
	JcNode matrix3 = new JcNode("matrix3");
	JcNode keanu = new JcNode("keanu");
	JcNode laurence = new JcNode("laurence");
	JcNode carrieanne = new JcNode("carrieanne");
	
	/*******************************/
	JcQuery query = new JcQuery();
	query.setClauses(new IClause[] {
			CREATE.node(matrix1).label("Movie")
					.property("title").value("The Matrix")
					.property("year").value("1999-03-31"),
			CREATE.node(matrix2).label("Movie")
					.property("title").value("The Matrix Reloaded")
					.property("year").value("2003-05-07"),
			CREATE.node(matrix3).label("Movie")
					.property("title").value("The Matrix Revolutions")
					.property("year").value("2003-10-27"),
			CREATE.node(keanu).label("Actor")
					.property("name").value("Keanu Reeves")
					.property("rating").value(5),
			CREATE.node(laurence).label("Actor")
					.property("name").value("Laurence Fishburne")
					.property("rating").value(6),
			CREATE.node(carrieanne).label("Actor")
					.property("name").value("Carrie-Anne Moss")
					.property("rating").value(7),
			CREATE.node(keanu).relation().out().type("ACTS_IN").property("role").value("Neo").node(matrix1),
			CREATE.node(keanu).relation().out().type("ACTS_IN").property("role").value("Neo").node(matrix2),
			CREATE.node(keanu).relation().out().type("ACTS_IN").property("role").value("Neo").node(matrix3),
			CREATE.node(laurence).relation().out().type("ACTS_IN").property("role").value("Morpheus").node(matrix1),
			CREATE.node(laurence).relation().out().type("ACTS_IN").property("role").value("Morpheus").node(matrix2),
			CREATE.node(laurence).relation().out().type("ACTS_IN").property("role").value("Morpheus").node(matrix3),
			CREATE.node(carrieanne).relation().out().type("ACTS_IN").property("role").value("Trinity").node(matrix1),
			CREATE.node(carrieanne).relation().out().type("ACTS_IN").property("role").value("Trinity").node(matrix2),
			CREATE.node(carrieanne).relation().out().type("ACTS_IN").property("role").value("Trinity").node(matrix3)
	});
	
	JcQueryResult result = dbAccess.execute(query);
	if (result.hasErrors())
		printErrors(result);
	assertFalse(result.hasErrors());
	
	return;
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:49,代码来源:DBAccessTest.java


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