Ejemplo n.º 1
0
    @Override
    public Void call() {
      RevTree tree = builder.build();

      Node treeNode;
      {
        ObjectId treeMetadataId = builder.getDefaultMetadataId();
        String name = NodeRef.nodeFromPath(treePath);
        ObjectId oid = tree.getId();
        Envelope bounds = SpatialOps.boundsOf(tree);
        treeNode = Node.create(name, oid, treeMetadataId, RevObject.TYPE.TREE, bounds);
      }

      final String parentPath = NodeRef.parentPath(treePath);
      final ObjectId parentMetadataId;
      if (NodeRef.ROOT.equals(parentPath)) {
        parentMetadataId = ObjectId.NULL;
      } else {
        Optional<NodeRef> parentRef =
            context
                .command(FindTreeChild.class)
                .setChildPath(parentPath)
                .setIndex(true)
                .setParent(workHead)
                .setParentPath(NodeRef.ROOT)
                .call();

        parentMetadataId = parentRef.isPresent() ? parentRef.get().getMetadataId() : ObjectId.NULL;
      }
      NodeRef newTreeRef = new NodeRef(treeNode, parentPath, parentMetadataId);
      target.put(newTreeRef, tree);
      return null;
    }
Ejemplo n.º 2
0
  private NodeRef findOrCreateTree(final String treePath, final FeatureType type) {

    RevTree tree =
        context
            .command(FindOrCreateSubtree.class)
            .setChildPath(treePath)
            .setIndex(true)
            .setParent(workHead)
            .setParentPath(NodeRef.ROOT)
            .call();

    ObjectId metadataId = ObjectId.NULL;
    if (type != null) {
      RevFeatureType revFeatureType = RevFeatureTypeImpl.build(type);
      if (tree.isEmpty()) {
        indexDatabase.put(revFeatureType);
      }
      metadataId = revFeatureType.getId();
    }
    Envelope bounds = SpatialOps.boundsOf(tree);
    Node node =
        Node.create(NodeRef.nodeFromPath(treePath), tree.getId(), metadataId, TYPE.TREE, bounds);

    String parentPath = NodeRef.parentPath(treePath);
    return new NodeRef(node, parentPath, ObjectId.NULL);
  }