Package org.locationtech.geogig.api

Examples of org.locationtech.geogig.api.NodeRef


        Map<String, RevTreeBuilder> repositoryChangedTrees = Maps.newHashMap();
        Map<String, NodeRef> indexChangedTrees = Maps.newHashMap();
        Map<String, ObjectId> changedTreesMetadataId = Maps.newHashMap();
        Set<String> deletedTrees = Sets.newHashSet();
        final boolean moveObjects = this.moveObjects;
        NodeRef ref;
        int i = 0;
        RevTree stageHead = index().getTree();
        while (diffs.hasNext()) {
            if (numChanges != 0) {
                progress.setProgress((float) (++i * 100) / numChanges);
            }
            if (progress.isCanceled()) {
                return null;
            }

            DiffEntry diff = diffs.next();
            // ignore the root entry
            if (NodeRef.ROOT.equals(diff.newName()) || NodeRef.ROOT.equals(diff.oldName())) {
                continue;
            }
            ref = diff.getNewObject();

            if (ref == null) {
                ref = diff.getOldObject();
            }

            final String parentPath = ref.getParentPath();
            final boolean isDelete = ChangeType.REMOVED.equals(diff.changeType());
            final TYPE type = ref.getType();
            if (isDelete && deletedTrees.contains(parentPath)) {
                // this is to avoid re-creating the parentTree for a feature delete after its parent
                // tree delete entry was processed
                continue;
            }
            RevTreeBuilder parentTree = resolveTargetTree(oldRootTree, parentPath,
                    repositoryChangedTrees, changedTreesMetadataId, ObjectId.NULL,
                    repositoryDatabase);
            if (type == TYPE.TREE && !isDelete) {
                // cache the tree
                resolveTargetTree(oldRootTree, ref.name(), repositoryChangedTrees,
                        changedTreesMetadataId, ref.getMetadataId(), repositoryDatabase);
            }

            resolveSourceTreeRef(parentPath, indexChangedTrees, changedTreesMetadataId, stageHead);

            Preconditions.checkState(parentTree != null);

            if (isDelete) {
                String oldName = diff.getOldObject().getNode().getName();
                parentTree.remove(oldName);
                if (TYPE.TREE.equals(type)) {
                    deletedTrees.add(ref.path());
                }
            } else {
                if (moveObjects && ref.getType().equals(TYPE.TREE)) {
                    RevTree tree = stagingDatabase().getTree(ref.objectId());
                    if (!ref.getMetadataId().isNull()) {
                        repositoryDatabase.put(stagingDatabase()
                                .getFeatureType(ref.getMetadataId()));
                    }
                    if (tree.isEmpty()) {
                        repositoryDatabase.put(tree);
                    } else {
                        continue;
                    }
                } else if (moveObjects) {
                    deepMove(ref.getNode());
                }
                parentTree.put(ref.getNode());
            }
        }

        if (progress.isCanceled()) {
            return null;
View Full Code Here


            Map<String, ObjectId> metadataCache, RevTree stageHead) {

        if (NodeRef.ROOT.equals(parentPath)) {
            return;
        }
        NodeRef indexTreeRef = indexChangedTrees.get(parentPath);

        if (indexTreeRef == null) {
            Optional<NodeRef> treeRef = Optional.absent();
            if (!stageHead.isEmpty()) {// slight optimization, may save a lot of processing on
                                       // large first commits
                treeRef = command(FindTreeChild.class).setIndex(true).setParent(stageHead)
                        .setChildPath(parentPath).call();
            }
            if (treeRef.isPresent()) {// may not be in case of a delete
                indexTreeRef = treeRef.get();
                indexChangedTrees.put(parentPath, indexTreeRef);
                metadataCache.put(parentPath, indexTreeRef.getMetadataId());
            }
        } else {
            metadataCache.put(parentPath, indexTreeRef.getMetadataId());
        }
    }
View Full Code Here

        @Override
        public void feature(Node left, Node right) {
            if (!finished && reportFeatures) {
                String treePath = tracker.getCurrentPath();

                NodeRef oldRef = left == null ? null : new NodeRef(left, treePath, tracker
                        .currentLeftMetadataId().or(ObjectId.NULL));
                NodeRef newRef = right == null ? null : new NodeRef(right, treePath, tracker
                        .currentRightMetadataId().or(ObjectId.NULL));

                try {
                    entries.put(new DiffEntry(oldRef, newRef));
                } catch (InterruptedException e) {
View Full Code Here

            final String parentPath = tracker.getCurrentPath();
            tracker.tree(left, right);
            // System.err.printf("%s.tree(%s, %s)\n", getClass().getSimpleName(), left, right);
            if (!finished && reportTrees) {
                if (parentPath != null) {// do not report the root tree
                    NodeRef oldRef = left == null ? null : new NodeRef(left, parentPath, tracker
                            .currentLeftMetadataId().or(ObjectId.NULL));

                    NodeRef newRef = right == null ? null : new NodeRef(right, parentPath, tracker
                            .currentRightMetadataId().or(ObjectId.NULL));
                    try {
                        entries.put(new DiffEntry(oldRef, newRef));
                    } catch (InterruptedException e) {
                        // throw Throwables.propagate(e);
View Full Code Here

        return RevTreeImpl.createLeafTree(id, size, features, trees);
    }

    public static DiffEntry readDiff(DataInput in) throws IOException {
        boolean oldNode = in.readBoolean();
        NodeRef oldNodeRef = null;
        if (oldNode) {
            oldNodeRef = readNodeRef(in);
        }
        boolean newNode = in.readBoolean();
        NodeRef newNodeRef = null;
        if (newNode) {
            newNodeRef = readNodeRef(in);
        }

        return new DiffEntry(oldNodeRef, newNodeRef);
View Full Code Here

    public static NodeRef readNodeRef(DataInput in) throws IOException {
        Node node = readNode(in);
        final ObjectId metadataId = readObjectId(in);
        String parentPath = in.readUTF();
        return new NodeRef(node, parentPath, metadataId);
    }
View Full Code Here

        checkArgument(revObject.isPresent(), "Invalid reference: %s", ref);

        final TYPE type = revObject.get().getType();
        switch (type) {
        case FEATURE:
            NodeRef nodeRef = treeRef.isPresent() ? treeRef.get() : null;
            List<NodeRef> nodeRefs = Lists.newArrayList();
            nodeRefs.add(nodeRef);
            // If show trees options is passed in show all trees that contain this feature
            if (this.strategy == Strategy.TREES_ONLY) {
                if (nodeRef != null) {
                    while (!nodeRef.getParentPath().isEmpty()) {
                        treeRef = command(FindTreeChild.class).setParent(workingTree().getTree())
                                .setChildPath(nodeRef.getParentPath()).setIndex(true).call();
                        nodeRef = treeRef.get();
                        nodeRefs.add(nodeRef);
                    }
                }
            }
View Full Code Here

        Optional<NodeRef> node = command(FindTreeChild.class).setParent(parent.get())
                .setChildPath(path).setIndex(true).call();
        if (!node.isPresent()) {
            return Optional.absent();
        }
        NodeRef found = node.get();
        ObjectId metadataID = found.getMetadataId();
        Optional<RevFeatureType> ft = command(RevObjectParse.class).setObjectId(metadataID).call(
                RevFeatureType.class);
        return ft;
    }
View Full Code Here

    }

    private void handlePureMetadataChanges(TreeDifference treeDifference, Set<String> ignoreList) {
        Map<NodeRef, NodeRef> pureMetadataChanges = treeDifference.findPureMetadataChanges();
        for (Map.Entry<NodeRef, NodeRef> e : pureMetadataChanges.entrySet()) {
            NodeRef newValue = e.getValue();
            String treePath = newValue.path();
            if (ignoreList.contains(treePath)) {
                continue;
            }
            ignoreList.add(treePath);
            if (!filterMatchesOrIsParent(treePath)) {
                continue;// filter doesn't apply to the changed tree
            }
            deepMove(newValue.getMetadataId());
            MutableTree leftTree = treeDifference.getLeftTree();
            leftTree.setChild(newValue.getParentPath(), newValue.getNode());
        }
    }
View Full Code Here

     */
    private void handleRenames(TreeDifference treeDifference, Set<String> ignoreList) {
        final SortedMap<NodeRef, NodeRef> renames = treeDifference.findRenames();

        for (Map.Entry<NodeRef, NodeRef> e : renames.entrySet()) {
            NodeRef oldValue = e.getKey();
            NodeRef newValue = e.getValue();
            String newPath = newValue.path();
            if (ignoreList.contains(newPath)) {
                continue;
            }
            ignoreList.add(newPath);
            if (!filterMatchesOrIsParent(newPath)) {
                continue;// filter doesn't apply to the renamed tree as a whole
            }
            LOGGER.trace("Handling rename of {} as {}", oldValue.path(), newPath);
            MutableTree leftTree = treeDifference.getLeftTree();
            leftTree.removeChild(oldValue.path());
            leftTree.setChild(newValue.getParentPath(), newValue.getNode());
        }
    }
View Full Code Here

TOP

Related Classes of org.locationtech.geogig.api.NodeRef

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.