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


Java Node类代码示例

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


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

示例1: insertBd

import org.neo4j.graphdb.Node; //导入依赖的package包/类
public void insertBd() {
    Result res;
    try (Transaction tx = db.beginTx()) {
        Node depart = db.createNode(Main.Tables.Depart);
        depart.setProperty("numero",numero);
        depart.setProperty("date",date);
        res = db.execute("MATCH (a:Avion), (d:Depart) WHERE a.numero="+avion+" AND d.numero="+numero+" CREATE (a)-[:Affecter]->(d)");
        res = db.execute("MATCH (v:Vol), (d:Depart) WHERE v.numero="+vol+" AND d.numero="+numero+" CREATE (v)-[:Constituer]->(d)");
        for (int i=0; i<passagers.size(); i++) {
            
            res = db.execute("MATCH (p:Passagers), (d:Depart) WHERE p.cin='"+passagers.get(i)+"' AND d.numero="+numero+" CREATE (p)-[:Enregistrer]->(d)");
        }
        for (int i=0; i<personnels.size(); i++) {
            res = db.execute("MATCH (p:Passagers), (d:Depart) WHERE p.cin='"+personnels.get(i)+"' AND d.numero="+numero+" CREATE (p)-[:Enregistrer]->(d)");
        }
        tx.success();
    }
     //res = db.execute("MATCH (d:Depart{date:'"+date+"'}), (p:Passager{cin:'"+passagers.get(0)+"'}) CREATE (p)-[r:Enregistrer]->(d)");
}
 
开发者ID:ATF19,项目名称:flight-management-system-java,代码行数:20,代码来源:Depart.java

示例2: diffFromCurrent

import org.neo4j.graphdb.Node; //导入依赖的package包/类
@Procedure(value = "graph.versioner.diff.from.current", mode = DEFAULT)
@Description("graph.versioner.diff.from.current(state) - Get a list of differences that must be applied to the given state in order to become the current entity state")
public Stream<DiffOutput> diffFromCurrent(
		@Name("state") Node state) {

	Optional<Node> currentState = Optional.ofNullable(state.getSingleRelationship(RelationshipType.withName(Utility.HAS_STATE_TYPE), Direction.INCOMING))
			.map(Relationship::getStartNode).map(entity -> entity.getSingleRelationship(RelationshipType.withName(Utility.CURRENT_TYPE), Direction.OUTGOING))
			.map(Relationship::getEndNode);

	Stream<DiffOutput> result = Stream.empty();

	if(currentState.isPresent() && !currentState.equals(Optional.of(state))){
		result = diffBetweenStates(Optional.of(state), currentState);
	}

	return result;
}
 
开发者ID:h-omer,项目名称:neo4j-versioner-core,代码行数:18,代码来源:Diff.java

示例3: diffBetweenStates

import org.neo4j.graphdb.Node; //导入依赖的package包/类
/**
 * It returns a {@link Stream<DiffOutput>} by the given nodes
 *
 * @param from
 * @param to
 * @return a {@link Stream<DiffOutput>}
 */
private Stream<DiffOutput> diffBetweenStates(Optional<Node> from, Optional<Node> to) {
	List<DiffOutput> diffs = new ArrayList<>();

	Map<String, Object> propertiesFrom = from.map(Node::getAllProperties).orElse(Collections.emptyMap());
	Map<String, Object> propertiesTo = to.map(Node::getAllProperties).orElse(Collections.emptyMap());

	//Getting updated and removed properties
	propertiesFrom.forEach((key, value) -> {
		Optional<Object> foundValue = Optional.ofNullable(propertiesTo.get(key));
		String operation = foundValue.map(val -> compareObj(val, value) ? "" : Utility.DIFF_OPERATION_UPDATE).orElse(Utility.DIFF_OPERATION_REMOVE);
		if(!operation.isEmpty()){
			diffs.add(new DiffOutput(operation, key, value, foundValue.orElse(null)));
		}
	});

	//Getting added properties
	propertiesTo.forEach((key, value) -> {
		if(!propertiesFrom.containsKey(key)) {
			diffs.add(new DiffOutput(Utility.DIFF_OPERATION_ADD, key, null, value));
		}
	});

	return diffs.stream().sorted((a, b) -> Integer.compare(Utility.DIFF_OPERATIONS_SORTING.indexOf(a.operation), Utility.DIFF_OPERATIONS_SORTING.indexOf(b.operation)));
}
 
开发者ID:h-omer,项目名称:neo4j-versioner-core,代码行数:32,代码来源:Diff.java

示例4: getIdAndCodeOfChildrenConnectedBy

import org.neo4j.graphdb.Node; //导入依赖的package包/类
public static List<Pair<Long, String>> getIdAndCodeOfChildrenConnectedBy(
		Node node, String edgeType)
{
	List<Pair<Long, String>> retval = new LinkedList<Pair<Long, String>>();
	List<Node> children = getChildrenConnectedBy(node, edgeType);

	for (Node childNode : children)
	{
		String childCode = childNode.getProperty(NodeKeys.CODE).toString();
		Pair<Long, String> pair = new Pair<Long, String>(childNode.getId(),
				childCode);
		retval.add(pair);
	}

	return retval;
}
 
开发者ID:RUB-SysSec,项目名称:EvilCoder,代码行数:17,代码来源:Traversals.java

示例5: getParentsConnectedBy

import org.neo4j.graphdb.Node; //导入依赖的package包/类
public static List<Node> getParentsConnectedBy(Node node, String edgeType)
{
	List<Node> retval = new LinkedList<Node>();

	long nodeId = node.getId();

	Iterable<Relationship> rels = node.getRelationships();
	for (Relationship rel : rels)
	{
		if (!rel.getType().name().equals(edgeType))
			continue;
		Node parentNode = rel.getStartNode();
		if (parentNode.getId() == nodeId)
			continue;

		retval.add(parentNode);
	}
	return retval;
}
 
开发者ID:RUB-SysSec,项目名称:EvilCoder,代码行数:20,代码来源:Traversals.java

示例6: all

import org.neo4j.graphdb.Node; //导入依赖的package包/类
static HashMap<String, Object> all( List<Node> lastOrdered, List<Node> predicted) {
    HashMap<String, Object> evaluations = new HashMap<>();
    ArrayList<Node> intersection = new ArrayList<>(lastOrdered);
    intersection.retainAll(predicted);

    Double precision = (double)intersection.size()/predicted.size();
    Double recall = (double) intersection.size()/lastOrdered.size();
    Double f1 = 2 * precision * recall / (precision + recall);

    evaluations.put("intersection", intersection);
    evaluations.put("precision", precision);
    evaluations.put("recall", recall);
    evaluations.put("f1", f1);

    return evaluations;
}
 
开发者ID:maxdemarzi,项目名称:instacart,代码行数:17,代码来源:Evaluations.java

示例7: getCallsToForFunction

import org.neo4j.graphdb.Node; //导入依赖的package包/类
public static List<Node> getCallsToForFunction(String source,
			long functionId)
	{
		List<Node> retval = new LinkedList<Node>();
// JANNIK
		String my = source;
		my = my.replace("*", "\\*");
		my = my.replace("(", "\\(");
		my = my.replace(")", "\\)");
		my = my.replace("-", "\\-");
		my = my.replace(" ", "\\ ");

		String query = String.format("%s:Callee AND %s:%s AND %s:%s", NodeKeys.TYPE, NodeKeys.FUNCTION_ID, functionId, NodeKeys.CODE, my);

		IndexHits<Node> hits = Neo4JDBInterface.queryIndex(query);
		for (Node n : hits)
		{
			List<Node> parents = getParentsConnectedBy(n, "IS_AST_PARENT");
			retval.add(parents.get(0));
		}
		return retval;
	}
 
开发者ID:RUB-SysSec,项目名称:EvilCoder,代码行数:23,代码来源:Traversals.java

示例8: getDDGForFunction

import org.neo4j.graphdb.Node; //导入依赖的package包/类
public static DDG getDDGForFunction(Node funcNode)
{
	DDG retval = new DDG();
	for (Node statement : Traversals.getStatementsForFunction(funcNode))
	{
		Iterable<Relationship> rels = statement
				.getRelationships(Direction.OUTGOING);
		long srcId = statement.getId();

		for (Relationship rel : rels)
		{
			if (!rel.getType().toString().equals(EdgeTypes.REACHES))
				continue;
			long dstId = rel.getEndNode().getId();
			String symbol = rel.getProperty("var").toString();
			retval.add(srcId, dstId, symbol);
		}

	}
	return retval;
}
 
开发者ID:RUB-SysSec,项目名称:EvilCoder,代码行数:22,代码来源:Traversals.java

示例9: remove_duplicated_edges_in_function

import org.neo4j.graphdb.Node; //导入依赖的package包/类
public static void remove_duplicated_edges_in_function(Joern_db joern_db, Long func_id)
    {
     System.out.print("remove_duplicated_edges_in_function: ");
     System.out.println(func_id);

    List<Node> Ns = Pipeline.v(func_id).functionToStatements().to_list();
//    Ns = Ns[0]

    Long counter = new Long(0);
    Long of = new Long(Ns.size());
      for(Node n : Ns)
       {
        counter += 1;
        System.out.println(counter.toString() + " of " + of.toString());
        remove_duplicated_edges_of_node(joern_db, n.getId());
       }
    }
 
开发者ID:RUB-SysSec,项目名称:EvilCoder,代码行数:18,代码来源:Remove_duplicated_edges.java

示例10: main

import org.neo4j.graphdb.Node; //导入依赖的package包/类
public static void main(String[] args) throws Exception
   {
     if(args.length != 1)
      {
       System.out.println("[/] Usage: <func_name>\n");
       System.exit(1);
      }
   String func_name = args[0];

   Joern_db joern_db = new Joern_db();
    joern_db.initialize();

   List<Node> hits = Joern_db.get_calls_to(func_name);
     for(Node h : hits)
      {
       remove_duplicated_edges_in_function(joern_db, (Long)h.getProperty("functionId"));
      }
//    remove_duplicated_edges();
    joern_db.g.commit();
   }
 
开发者ID:RUB-SysSec,项目名称:EvilCoder,代码行数:21,代码来源:Remove_duplicated_edges.java

示例11: find_inflow_nodes_with_path_length

import org.neo4j.graphdb.Node; //导入依赖的package包/类
public static HashSet<Long> find_inflow_nodes_with_path_length(Joern_db joern_db, Long node_id, Long path_length, HashSet<Long> nodes_in_step_before)
{
ArrayList<Long> start_nodes = new ArrayList(nodes_in_step_before);
  if(!nodes_in_step_before.contains(node_id))
   {
    start_nodes.add(node_id);
   }
List<Node> nodes = Pipeline.v(start_nodes).in("CFG_EDGE").to_list();

HashSet<Long> new_node_ids = new HashSet();
  for(Node n : nodes)
   {
   Long id = n.getId();
     if(!nodes_in_step_before.contains(id))
      {
       new_node_ids.add(id);
      }
   }
 return new_node_ids;
}
 
开发者ID:RUB-SysSec,项目名称:EvilCoder,代码行数:21,代码来源:Find_data_paths.java

示例12: print_path

import org.neo4j.graphdb.Node; //导入依赖的package包/类
public static void print_path(Joern_db joern_db, List<Long> path, List<String> var_names)
{
  for(int i=0, i_end=path.size(); i<i_end; ++i)
   {
   Long p = path.get(i);
   Node node = (Node)(Pipeline.v(p).to_list().get(0));
     if(node.hasProperty("code"))
      {
       System.out.println(p.toString() + "\t" + (String)(node.getProperty("code")));
      }
     else
      {
       System.out.println(p.toString());
      }
     if(var_names != null && i < path.size()-1)
      {
       System.out.println("\t" + var_names.get(i));
      }
   }
}
 
开发者ID:RUB-SysSec,项目名称:EvilCoder,代码行数:21,代码来源:Find_data_paths.java

示例13: fill_externally_defined_functions

import org.neo4j.graphdb.Node; //导入依赖的package包/类
public static void fill_externally_defined_functions(Joern_db joern_db)
   {
// completeType    extern void ( )
// baseType        extern void
// type            Decl
// identifier      extern_func
    if(externally_defined_functions != null) return;

    externally_defined_functions = new HashSet<>();
//    decls = joern_db.runGremlinQuery("queryNodeIndex('type:Decl').filter{it.completeType.startsWith('extern') && it.completeType.endsWith(')')}.identifier")
//    decls = joern_db.runGremlinQuery("g.V.filter{it.type == 'Decl' && it.completeType.startsWith('extern') && it.completeType.endsWith(')')}.identifier")

   List<Node> decl_nodes = Joern_db.queryNodeIndex("type:Decl");
     for(Node d : decl_nodes)
      {
      String completeType = (String)d.getProperty("completeType");
        if(completeType.startsWith("extern") && completeType.endsWith(")"))
         {
         String identifier = (String)d.getProperty("identifier");
          externally_defined_functions.add(identifier);
         }
      }
   }
 
开发者ID:RUB-SysSec,项目名称:EvilCoder,代码行数:24,代码来源:Find_all_function_pointers.java

示例14: find_all_func_names

import org.neo4j.graphdb.Node; //导入依赖的package包/类
public static HashSet<String> find_all_func_names(Joern_db joern_db) throws Exception
{
 fill_glibc_function_names();
 fill_externally_defined_functions(joern_db);

HashSet<String> all_funcs = new HashSet(glibc_function_names);
  for(String it : externally_defined_functions) all_funcs.add(it);

 // get all function-defs, extract their names
List<Node> func_defs = joern_db.queryNodeIndex("type:FunctionDef");
  for(Node n : func_defs)
   {
   String code = (String)n.getProperty("code");
   String[] splitters = code.split(" ", -1);
    all_funcs.add(splitters[0]);
   }

 return all_funcs;
}
 
开发者ID:RUB-SysSec,项目名称:EvilCoder,代码行数:20,代码来源:Find_all_function_pointers.java

示例15: matchUser

import org.neo4j.graphdb.Node; //导入依赖的package包/类
@Procedure(name = "com.maxdemarzi.match.user", mode = Mode.READ)
@Description("CALL com.maxdemarzi.match.user(username) - find matching rules")
public Stream<NodeResult> matchUser(@Name("username") String username) throws IOException {
    // We start by finding the user
    Node user = db.findNode(Labels.User, "username", username);
    if (user != null) {
        // Gather all of their attributes in to a Set
        Set<Node> userAttributes = new HashSet<>();
        Collection<String> attributes = new HashSet<>();

        for (Relationship r : user.getRelationships(Direction.OUTGOING, RelationshipTypes.HAS)) {
            userAttributes.add(r.getEndNode());
            attributes.add((String)r.getEndNode().getProperty("id"));
        }
        // Find the rules
        Set<Node> rules = findRules(attributes, userAttributes);
        return rules.stream().map(NodeResult::new);
    }

    return null;
}
 
开发者ID:maxdemarzi,项目名称:rule_matcher,代码行数:22,代码来源:Matcher.java


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