Package org.locationtech.geogig.repository

Examples of org.locationtech.geogig.repository.DepthSearch


            workTree.insert(NodeRef.parentPath(feature.getPath()), feature.getFeature());
        }
        List<FeatureDiff> diffs = patch.getModifiedFeatures();
        for (FeatureDiff diff : diffs) {
            String path = diff.getPath();
            DepthSearch depthSearch = new DepthSearch(indexDb);
            Optional<NodeRef> noderef = depthSearch.find(workTree.getTree(), path);
            RevFeatureType oldRevFeatureType = command(RevObjectParse.class)
                    .setObjectId(noderef.get().getMetadataId()).call(RevFeatureType.class).get();
            String refSpec = Ref.WORK_HEAD + ":" + path;
            RevFeature feature = command(RevObjectParse.class).setRefSpec(refSpec)
                    .call(RevFeature.class).get();
View Full Code Here


            return Optional.absent();
        }

        RevTree subtree = loadTree(bucket.id());

        DepthSearch depthSearch = new DepthSearch(db);
        Optional<Node> node = depthSearch.getDirectChild(subtree, key, depth + 1);

        if (node.isPresent()) {
            return Optional.of(node.get());
        } else {
            return Optional.absent();
View Full Code Here

        }
        final String path = childPath;
        final String parentPath = this.parentPath == null ? "" : this.parentPath;
        final ObjectDatabase target = indexDb ? stagingDatabase() : objectDatabase();

        DepthSearch depthSearch = new DepthSearch(target);
        Optional<NodeRef> childRef = depthSearch.find(tree, parentPath, path);
        return childRef;

    }
View Full Code Here

                        // We add it and consider it unconflicted
                        report.addUnconflicted(diff);
                        break;
                    }
                    RevFeature feature = (RevFeature) obj.get();
                    DepthSearch depthSearch = new DepthSearch(repository.objectDatabase());
                    Optional<NodeRef> noderef = depthSearch
                            .find(this.workingTree().getTree(), path);
                    RevFeatureType featureType = command(RevObjectParse.class)
                            .setObjectId(noderef.get().getMetadataId()).call(RevFeatureType.class)
                            .get();
                    ImmutableList<PropertyDescriptor> descriptors = featureType.sortedDescriptors();
View Full Code Here

            if (!obj.isPresent()) {
                toReject.addModifiedFeature(diff);
                break;
            }
            RevFeature feature = (RevFeature) obj.get();
            DepthSearch depthSearch = new DepthSearch(stagingDatabase());
            Optional<NodeRef> noderef = depthSearch.find(workingTree().getTree(), path);
            RevFeatureType featureType = command(RevObjectParse.class)
                    .setObjectId(noderef.get().getMetadataId()).call(RevFeatureType.class).get();
            ImmutableList<PropertyDescriptor> descriptors = featureType.sortedDescriptors();
            Set<Entry<PropertyDescriptor, AttributeDiff>> attrDiffs = diff.getDiffs().entrySet();
            boolean ok = true;
            for (Iterator<Entry<PropertyDescriptor, AttributeDiff>> iterator = attrDiffs.iterator(); iterator
                    .hasNext();) {
                Entry<PropertyDescriptor, AttributeDiff> entry = iterator.next();
                AttributeDiff attrDiff = entry.getValue();
                PropertyDescriptor descriptor = entry.getKey();
                switch (attrDiff.getType()) {
                case ADDED:
                    if (descriptors.contains(descriptor)) {
                        ok = false;
                    }
                    break;
                case REMOVED:
                case MODIFIED:
                    if (!descriptors.contains(descriptor)) {
                        ok = false;
                        break;
                    }
                    for (int i = 0; i < descriptors.size(); i++) {
                        if (descriptors.get(i).equals(descriptor)) {
                            Optional<Object> value = feature.getValues().get(i);
                            if (!attrDiff.canBeAppliedOn(value)) {
                                ok = false;
                            }
                            break;
                        }
                    }
                }
            }
            if (!ok) {
                toReject.addModifiedFeature(diff);
            } else {
                toApply.addModifiedFeature(diff);
            }
        }
        List<FeatureInfo> added = patch.getAddedFeatures();
        for (FeatureInfo feature : added) {
            String refSpec = Ref.WORK_HEAD + ":" + feature.getPath();
            obj = command(RevObjectParse.class).setRefSpec(refSpec).call();
            if (obj.isPresent()) {
                toReject.addAddedFeature(feature.getPath(), feature.getFeature(),
                        feature.getFeatureType());
            } else {
                toApply.addAddedFeature(feature.getPath(), feature.getFeature(),
                        feature.getFeatureType());
            }

        }
        List<FeatureInfo> removed = patch.getRemovedFeatures();
        for (FeatureInfo feature : removed) {
            String refSpec = Ref.WORK_HEAD + ":" + feature.getPath();
            obj = command(RevObjectParse.class).setRefSpec(refSpec).call();
            if (!obj.isPresent()) {
                toReject.addRemovedFeature(feature.getPath(), feature.getFeature(),
                        feature.getFeatureType());
            } else {
                RevFeature revFeature = (RevFeature) obj.get();
                DepthSearch depthSearch = new DepthSearch(stagingDatabase());
                Optional<NodeRef> noderef = depthSearch.find(workingTree().getTree(),
                        feature.getPath());
                RevFeatureType revFeatureType = command(RevObjectParse.class)
                        .setObjectId(noderef.get().getMetadataId()).call(RevFeatureType.class)
                        .get();
                RevFeature patchRevFeature = RevFeatureBuilder.build(feature.getFeature());
                if (revFeature.equals(patchRevFeature)
                        && revFeatureType.equals(feature.getFeatureType())) {
                    toApply.addRemovedFeature(feature.getPath(), feature.getFeature(),
                            feature.getFeatureType());
                } else {
                    toReject.addRemovedFeature(feature.getPath(), feature.getFeature(),
                            feature.getFeatureType());
                }
            }
        }
        ImmutableList<FeatureTypeDiff> alteredTrees = patch.getAlteredTrees();
        for (FeatureTypeDiff diff : alteredTrees) {
            DepthSearch depthSearch = new DepthSearch(stagingDatabase());
            Optional<NodeRef> noderef = depthSearch.find(workingTree().getTree(), diff.getPath());
            ObjectId metadataId = noderef.isPresent() ? noderef.get().getMetadataId()
                    : ObjectId.NULL;
            if (Objects.equal(metadataId, diff.getOldFeatureType())) {
                toApply.addAlteredTree(diff);
            } else {
View Full Code Here

        RevTreeBuilder oldRoot = new RevTreeBuilder(odb);
        RevTree tree = new RevTreeBuilder(odb).put(blob("blob")).build();
        ObjectId newRootId = writeBack.setAncestor(oldRoot).setChildPath("subtree").setTree(tree)
                .call();

        Optional<NodeRef> ref = new DepthSearch(odb).find(newRootId, "subtree");
        assertTrue(ref.isPresent());
    }
View Full Code Here

        ObjectId newRootId = writeBack.setAncestor(oldRoot).setChildPath("level1").setTree(tree)
                .call();

        // created the intermediate tree node?
        Optional<NodeRef> ref;
        DepthSearch depthSearch = new DepthSearch(odb);
        ref = depthSearch.find(newRootId, "level1");
        assertTrue(ref.isPresent());

        ref = depthSearch.find(newRootId, "level1/blob");
        assertTrue(ref.isPresent());
    }
View Full Code Here

        ObjectId newRootId = writeBack.setAncestor(oldRoot).setChildPath("level1/level2")
                .setTree(tree).call();

        // created the intermediate tree node?
        Optional<NodeRef> ref;
        DepthSearch depthSearch = new DepthSearch(odb);
        ref = depthSearch.find(newRootId, "level1");
        assertTrue(ref.isPresent());

        ref = depthSearch.find(newRootId, "level1/level2");
        assertTrue(ref.isPresent());

        ref = depthSearch.find(newRootId, "level1/level2/blob");
        assertTrue(ref.isPresent());
    }
View Full Code Here

        ancestor = odb.getTree(newRootId1).builder(odb);
        ObjectId newRootId2 = writeBack.setAncestor(ancestor).setChildPath("subtree2")
                .setTree(tree2).call();

        // created the intermediate tree node?
        DepthSearch depthSearch = new DepthSearch(odb);
        assertTrue(depthSearch.find(newRootId2, "subtree1").isPresent());
        assertTrue(depthSearch.find(newRootId2, "subtree2").isPresent());
        assertTrue(depthSearch.find(newRootId2, "subtree1/blob").isPresent());
        assertTrue(depthSearch.find(newRootId2, "subtree2/blob").isPresent());
    }
View Full Code Here

        ObjectId newRootId2 = writeBack.setAncestor(odb.getTree(newRootId1).builder(odb))
                .setChildPath("subtree2/level2/level3").setTree(tree2).call();

        // created the intermediate tree node?
        DepthSearch depthSearch = new DepthSearch(odb);
        assertTrue(depthSearch.find(newRootId2, "subtree1").isPresent());
        assertTrue(depthSearch.find(newRootId2, "subtree1/level2").isPresent());
        assertTrue(depthSearch.find(newRootId2, "subtree1/level2/blob").isPresent());

        assertTrue(depthSearch.find(newRootId2, "subtree2").isPresent());
        assertTrue(depthSearch.find(newRootId2, "subtree2/level2").isPresent());
        assertTrue(depthSearch.find(newRootId2, "subtree2/level2/level3").isPresent());
        assertTrue(depthSearch.find(newRootId2, "subtree2/level2/level3/blob").isPresent());
    }
View Full Code Here

TOP

Related Classes of org.locationtech.geogig.repository.DepthSearch

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.