Beispiel #1
0
  /**
   * Runs the command and builds the appropriate response
   *
   * @param context - the context to use for this command
   * @throws CommandSpecException
   */
  @Override
  public void run(CommandContext context) {
    if (oldRefSpec == null || oldRefSpec.trim().isEmpty()) {
      throw new CommandSpecException("No old ref spec");
    }

    final Context geogig = this.getCommandLocator(context);

    final Iterator<DiffEntry> diff =
        geogig
            .command(DiffOp.class)
            .setOldVersion(oldRefSpec)
            .setNewVersion(newRefSpec)
            .setFilter(pathFilter)
            .call();

    context.setResponseContent(
        new CommandResponse() {
          @Override
          public void write(ResponseWriter out) throws Exception {
            out.start();
            if (showGeometryChanges) {
              out.writeGeometryChanges(geogig, diff, page, elementsPerPage);
            } else {
              out.writeDiffEntries("diff", page * elementsPerPage, elementsPerPage, diff);
            }
            out.finish();
          }
        });
  }
  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);
  }
  private RevTreeBuilder2 createBuilder(String treePath, FeatureType type) {

    final NodeRef treeRef = findOrCreateTree(treePath, type);
    final ObjectId treeId = treeRef.objectId();
    final RevTree origTree = indexDatabase.getTree(treeId);

    ObjectId defaultMetadataId = treeRef.getMetadataId();

    RevTreeBuilder2 builder;
    Platform platform = context.platform();
    builder =
        new RevTreeBuilder2(indexDatabase, origTree, defaultMetadataId, platform, executorService);
    return builder;
  }