Package org.locationtech.geogig.api.RevObject

Examples of org.locationtech.geogig.api.RevObject.TYPE


        String fullPath = (commit != null ? commit.toString() : Ref.HEAD) + ":" + path;
        Optional<ObjectId> id = command(RevParse.class).setRefSpec(fullPath).call();
        if (!id.isPresent()) {
            throw new BlameException(StatusCode.FEATURE_NOT_FOUND);
        }
        TYPE type = command(ResolveObjectType.class).setObjectId(id.get()).call();
        if (!type.equals(TYPE.FEATURE)) {
            throw new BlameException(StatusCode.PATH_NOT_FEATURE);
        }
        Optional<RevFeatureType> featureType = command(ResolveFeatureType.class).setRefSpec(path)
                .call();
View Full Code Here


        Optional<ObjectId> objectId = command(RevParse.class).setRefSpec(branchOrigin).call();
        checkArgument(objectId.isPresent(), branchOrigin
                + " does not resolve to a repository object");

        ObjectId commitId = objectId.get();
        TYPE objectType = command(ResolveObjectType.class).setObjectId(commitId).call();
        checkArgument(TYPE.COMMIT.equals(objectType), branchOrigin
                + " does not resolve to a commit: " + objectType);

        return commitId;
    }
View Full Code Here

        ObjectId objectId = resolved.get();
        if (objectId.isNull()) {// might be an empty commit ref
            return Optional.of(RevTree.EMPTY_TREE_ID);
        }

        final TYPE objectType = command(ResolveObjectType.class).setObjectId(objectId).call();

        switch (objectType) {
        case TREE:
            // ok
            break;
View Full Code Here

                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;
            }
View Full Code Here

            Optional<RevObject> obj = command(RevObjectParse.class).setRefSpec(
                    Ref.HEAD + ":" + path).call();
            switch (diff.changeType()) {
            case ADDED:
                if (obj.isPresent()) {
                    TYPE type = command(ResolveObjectType.class).setObjectId(
                            diff.getNewObject().objectId()).call();
                    if (TYPE.TREE.equals(type)) {
                        NodeRef headVersion = command(FindTreeChild.class).setChildPath(path)
                                .setParent(repository.getOrCreateHeadTree()).call().get();
                        if (!headVersion.getMetadataId()
                                .equals(diff.getNewObject().getMetadataId())) {
                            report.addConflict(new Conflict(path, ObjectId.NULL, diff
                                    .getNewObject().getMetadataId(), headVersion.getMetadataId()));
                        }
                    } else {
                        if (!obj.get().getId().equals(diff.newObjectId())) {
                            report.addConflict(new Conflict(path, ObjectId.NULL,
                                    diff.newObjectId(), obj.get().getId()));
                        }
                    }
                } else {
                    report.addUnconflicted(diff);
                }
                break;
            case REMOVED:
                if (obj.isPresent()) {
                    if (obj.get().getId().equals(diff.oldObjectId())) {
                        report.addUnconflicted(diff);
                    } else {
                        report.addConflict(new Conflict(path, diff.oldObjectId(), ObjectId.NULL,
                                obj.get().getId()));
                    }
                }
                break;
            case MODIFIED:
                TYPE type = command(ResolveObjectType.class).setObjectId(
                        diff.getNewObject().objectId()).call();
                if (TYPE.TREE.equals(type)) {
                    // TODO:see how to do this. For now, we will pass any change as a conflicted
                    // one
                    if (!diff.isChange()) {
View Full Code Here

                switch (toMergeDiff.changeType()) {
                case ADDED:
                    if (toMergeDiff.getNewObject().equals(mergeIntoDiff.getNewObject())) {
                        // already added in current branch, no need to do anything
                    } else {
                        TYPE type = command(ResolveObjectType.class).setObjectId(
                                toMergeDiff.getNewObject().objectId()).call();
                        if (TYPE.TREE.equals(type)) {
                            boolean conflict = !toMergeDiff.getNewObject().getMetadataId()
                                    .equals(mergeIntoDiff.getNewObject().getMetadataId());
                            if (conflict) {
                                // In this case, we store the metadata id, not the element id
                                ancestorVersionId = ancestorVersion.isPresent() ? ancestorVersion
                                        .get().getMetadataId() : ObjectId.NULL;
                                ours = mergeIntoDiff.getNewObject().getMetadataId();
                                theirs = toMergeDiff.getNewObject().getMetadataId();
                                report.addConflict(new Conflict(path, ancestorVersionId, ours,
                                        theirs));
                            }
                            // if the metadata ids match, it means both branches have added the same
                            // tree, maybe with different content, but there is no need to do
                            // anything. The correct tree is already there and the merge can be run
                            // safely, so we do not add it neither as a conflicted change nor as an
                            // unconflicted one
                        } else {
                            report.addConflict(new Conflict(path, ancestorVersionId, ours, theirs));
                        }
                    }
                    break;
                case REMOVED:
                    // removed by both histories => no conflict and no need to do anything
                    break;
                case MODIFIED:
                    TYPE type = command(ResolveObjectType.class).setObjectId(
                            toMergeDiff.getNewObject().objectId()).call();
                    if (TYPE.TREE.equals(type)) {
                        boolean conflict = !toMergeDiff.getNewObject().getMetadataId()
                                .equals(mergeIntoDiff.getNewObject().getMetadataId());
                        if (conflict) {
                            // In this case, we store the metadata id, not the element id
                            ancestorVersionId = ancestorVersion.isPresent() ? ancestorVersion.get()
                                    .getMetadataId() : ObjectId.NULL;
                            ours = mergeIntoDiff.getNewObject().getMetadataId();
                            theirs = toMergeDiff.getNewObject().getMetadataId();
                            report.addConflict(new Conflict(path, ancestorVersionId, ours, theirs));
                        }
                    } else {
                        FeatureDiff toMergeFeatureDiff = command(DiffFeature.class)
                                .setOldVersion(Suppliers.ofInstance(toMergeDiff.getOldObject()))
                                .setNewVersion(Suppliers.ofInstance(toMergeDiff.getNewObject()))
                                .call();
                        FeatureDiff mergeIntoFeatureDiff = command(DiffFeature.class)
                                .setOldVersion(Suppliers.ofInstance(mergeIntoDiff.getOldObject()))
                                .setNewVersion(Suppliers.ofInstance(mergeIntoDiff.getNewObject()))
                                .call();
                        if (toMergeFeatureDiff.conflicts(mergeIntoFeatureDiff)) {
                            report.addConflict(new Conflict(path, ancestorVersionId, ours, theirs));
                        } else {
                            // if the feature types are different we report a conflict and do not
                            // try to perform automerge
                            if (!toMergeDiff.getNewObject().getMetadataId()
                                    .equals(mergeIntoDiff.getNewObject().getMetadataId())) {
                                report.addConflict(new Conflict(path, ancestorVersionId, ours,
                                        theirs));
                            } else if (!toMergeFeatureDiff.equals(mergeIntoFeatureDiff)) {
                                Feature mergedFeature = command(MergeFeaturesOp.class)
                                        .setFirstFeature(mergeIntoDiff.getNewObject())
                                        .setSecondFeature(toMergeDiff.getNewObject())
                                        .setAncestorFeature(mergeIntoDiff.getOldObject()).call();
                                RevFeature revFeature = RevFeatureBuilder.build(mergedFeature);
                                if (revFeature.getId().equals(toMergeDiff.newObjectId())) {
                                    // the resulting merged feature equals the feature to merge from
                                    // the branch, which means that it exists in the repo and there
                                    // is no need to add it
                                    report.addUnconflicted(toMergeDiff);
                                } else {
                                    RevFeatureType featureType = command(RevObjectParse.class)
                                            .setObjectId(
                                                    mergeIntoDiff.getNewObject().getMetadataId())
                                            .call(RevFeatureType.class).get();
                                    FeatureInfo merged = new FeatureInfo(mergedFeature,
                                            featureType, path);
                                    report.addMerged(merged);
                                }
                            }
                        }
                    }
                    break;
                }
            } else {
                // If the element is a tree, not a feature, it might be a conflict even if the other
                // branch has not modified it.
                // If we are removing the tree, we have to make sure that there are no features
                // modified in the other branch under it.
                if (ChangeType.REMOVED.equals(toMergeDiff.changeType())) {
                    TYPE type = command(ResolveObjectType.class).setObjectId(
                            toMergeDiff.oldObjectId()).call();
                    if (TYPE.TREE.equals(type)) {
                        String parentPath = toMergeDiff.oldPath();
                        Set<Entry<String, DiffEntry>> entries = mergeIntoDiffs.entrySet();
                        boolean conflict = false;
View Full Code Here

        @Override
        public T read(ObjectId id, InputStream rawData) throws IllegalArgumentException {
            try {
                BufferedReader reader;
                reader = new BufferedReader(new InputStreamReader(rawData, "UTF-8"));
                TYPE type = RevObject.TYPE.valueOf(requireLine(reader).trim());
                T parsed = read(id, reader, type);
                Preconditions.checkState(parsed != null, "parsed to null");
                if (id != null) {
                    Preconditions
                            .checkState(id.equals(parsed.getId()),
View Full Code Here

        protected Node parseNodeLine(String line) {
            List<String> tokens = Lists.newArrayList(Splitter.on('\t').split(line));
            Preconditions.checkArgument(tokens.size() == 6, "Wrong tree element definition: %s",
                    line);
            TYPE type = TYPE.valueOf(tokens.get(1));
            String name = tokens.get(2);
            ObjectId id = ObjectId.valueOf(tokens.get(3));
            ObjectId metadataId = ObjectId.valueOf(tokens.get(4));
            Envelope bbox = parseBBox(tokens.get(5));
View Full Code Here

            revObject = command(RevObjectParse.class).setObjectId(treeId).call(RevObject.class);
        }

        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);
View Full Code Here

        if (!diff.changeType().equals(diff2.changeType())) {
            return true;
        }
        switch (diff.changeType()) {
        case ADDED:
            TYPE type = command(ResolveObjectType.class)
                    .setObjectId(diff.getNewObject().objectId()).call();
            if (TYPE.TREE.equals(type)) {
                return !diff.getNewObject().getMetadataId()
                        .equals(diff2.getNewObject().getMetadataId());
            }
View Full Code Here

TOP

Related Classes of org.locationtech.geogig.api.RevObject.TYPE

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.