예제 #1
0
  public Node _importNode(GraphNode graphNode) {
    if (graphNode.isBroken() || graphNode.isDeleted()) return null;

    GraphKey key = graphNode.getKey();

    if (StringUtils.isEmpty(key.getIndex()))
      throw new IllegalArgumentException("Node Key Index can not be empty");
    if (StringUtils.isEmpty(key.getKey()))
      throw new IllegalArgumentException("Node Key Property can not be null");
    if (null == key.getValue())
      throw new IllegalArgumentException("Node Key Value can not be null");

    if (verbose) {
      System.out.println("Importing Node (" + key + ")");
    }

    Index<Node> idx = _getNodeIndex(key.getIndex());
    Node node = _findSingleNode(key.getIndex(), key.getKey(), key.getValue());
    if (null == node) {
      node = _createNode(graphNode.getLabels(), graphNode.getProperties());
      node.setProperty(key.getKey(), key.getValue());

      idx.add(node, key.getKey(), key.getValue());

      List<GraphRelationship> list = unknownRelationships.remove(getRelationshipKey(key));
      if (null != list)
        for (GraphRelationship relationship : list) _importRelationship(relationship, false);

      for (GraphKey index : graphNode.getIndexes()) {

        node.setProperty(index.getKey(), index.getValue());

        list = unknownRelationships.remove(getRelationshipKey(index));
        if (null != list)
          for (GraphRelationship relationship : list) _importRelationship(relationship, false);
      }
    } else {
      ++nodesUpdated;

      _updateNode(node, graphNode.getLabels(), graphNode.getProperties());
    }

    return node;
  }
예제 #2
0
  public Node _findNode(GraphKey key) {
    return _findNode(key.getIndex(), key.getKey(), key.getValue());

    /*	ResourceIterable<Node> nodes = graphDb.findNodesByLabelAndProperty(
    		DynamicLabel.label(connection.getType()),
    		AggrigationUtils.PROPERTY_KEY,
    		connection.getKey());

    try (ResourceIterator<Node> noded = nodes.iterator()) {
    	if (noded.hasNext())
    		return noded.next();
    	else
    		return null;
    }*/
  }
예제 #3
0
 private static String getRelationshipKey(GraphKey key) {
   return key.getIndex() + "." + key.getKey() + "." + key.getValue();
 }
예제 #4
0
 private List<Node> _findRelatedNodes(GraphKey key) {
   return _findRelatedNodes(DynamicLabel.label(key.getIndex()), key.getKey(), key.getValue());
 }
예제 #5
0
 public Node _findSingleNode(GraphKey key) {
   return _findSingleNode(key.getIndex(), key.getKey(), key.getValue());
 }
예제 #6
0
 public ResourceIterator<Node> _findNodes(GraphKey key) {
   return _findNodes(DynamicLabel.label(key.getIndex()), key.getKey(), key.getValue());
 }