Package org.locationtech.geogig.api

Examples of org.locationtech.geogig.api.RevObject


     * @param id the id to look for
     * @return true if the object was found, false otherwise
     */
    public boolean commitExists(final ObjectId id) {
        try {
            RevObject revObject = objectDatabase().get(id);
            return revObject instanceof RevCommit;
        } catch (IllegalArgumentException e) {
            return false;
        }
    }
View Full Code Here


        while (diffs.hasNext()) {
            DiffEntry diffEntry = diffs.next();
            final NodeRef newObject = diffEntry.getNewObject();
            final NodeRef oldObject = diffEntry.getOldObject();
            if (diffEntry.changeType() == ChangeType.MODIFIED) {
                RevObject revObject = command(RevObjectParse.class)
                        .setObjectId(diffEntry.newObjectId()).call().get();
                if (revObject instanceof RevFeature) {
                    FeatureDiff diff = command(DiffFeature.class)
                            .setNewVersion(Suppliers.ofInstance(diffEntry.getNewObject()))
                            .setOldVersion(Suppliers.ofInstance(diffEntry.getOldObject())).call();
                    patch.addModifiedFeature(diff);
                } else if (revObject instanceof RevTree) {
                    RevFeatureType oldFeatureType = command(RevObjectParse.class)
                            .setObjectId(diffEntry.getOldObject().getMetadataId())
                            .call(RevFeatureType.class).get();
                    RevFeatureType newFeatureType = command(RevObjectParse.class)
                            .setObjectId(diffEntry.getNewObject().getMetadataId())
                            .call(RevFeatureType.class).get();
                    patch.addFeatureType(oldFeatureType);
                    patch.addFeatureType(newFeatureType);
                    patch.addAlteredTree(diffEntry);
                }

            } else if (diffEntry.changeType() == ChangeType.ADDED) {
                RevObject revObject = command(RevObjectParse.class)
                        .setObjectId(diffEntry.newObjectId()).call().get();
                if (revObject instanceof RevFeature) {
                    RevFeatureType featureType;
                    if (featureTypes.containsKey(newObject.getMetadataId())) {
                        featureType = featureTypes.get(newObject.getMetadataId());
                    } else {
                        featureType = command(RevObjectParse.class)
                                .setObjectId(newObject.getMetadataId()).call(RevFeatureType.class)
                                .get();
                        featureTypes.put(newObject.getMetadataId(), featureType);
                    }

                    FeatureBuilder featureBuilder = new FeatureBuilder(featureType);
                    Feature feature = featureBuilder.build(diffEntry.newObjectId().toString(),
                            (RevFeature) revObject);
                    String name = diffEntry.newPath();
                    patch.addAddedFeature(name, feature, featureType);
                } else if (revObject instanceof RevTree) {
                    ObjectId metadataId = diffEntry.getNewObject().getMetadataId();
                    if (!metadataId.isNull()) {
                        RevFeatureType featureType = command(RevObjectParse.class)
                                .setObjectId(metadataId).call(RevFeatureType.class).get();
                        patch.addAlteredTree(diffEntry);
                        patch.addFeatureType(featureType);
                    }
                }
            } else if (diffEntry.changeType() == ChangeType.REMOVED) {
                RevObject revObject = command(RevObjectParse.class)
                        .setObjectId(diffEntry.oldObjectId()).call().get();
                if (revObject instanceof RevFeature) {
                    RevFeatureType featureType;
                    if (featureTypes.containsKey(oldObject.getMetadataId())) {
                        featureType = featureTypes.get(oldObject.getMetadataId());
View Full Code Here

            from = tmp;
        }
        final ObjectDatabase fromDb = from.objectDatabase();
        final ObjectDatabase toDb = to.objectDatabase();

        final RevObject object = fromDb.get(newHeadId);

        RevCommit commit = null;
        RevTag tag = null;

        if (object.getType().equals(TYPE.COMMIT)) {
            commit = (RevCommit) object;
        } else if (object.getType().equals(TYPE.TAG)) {
            tag = (RevTag) object;
            commit = fromDb.getCommit(tag.getCommitId());
        }
        if (commit != null) {
            final RevTree newTree = fromDb.getTree(commit.getTreeId());
View Full Code Here

                ObjectId metadataId = newObject.getMetadataId();
                if (writtenMetadataIds.contains(metadataId)) {
                    out.write(CHUNK_TYPE.OBJECT_AND_DIFF_ENTRY.value());
                } else {
                    out.write(CHUNK_TYPE.METADATA_OBJECT_AND_DIFF_ENTRY.value());
                    RevObject metadata = objectDatabase.get(metadataId);
                    writeObjectId(metadataId, out, oidbuffer);
                    serializer.createObjectWriter(metadata.getType()).write(metadata, out);
                    writtenMetadataIds.add(metadataId);
                    objectCount++;
                }

                ObjectId objectId = newObject.objectId();
                writeObjectId(objectId, out, oidbuffer);
                RevObject object = objectDatabase.get(objectId);
                serializer.createObjectWriter(object.getType()).write(object, out);
                objectCount++;
            }
            DataOutput dataOut = new DataOutputStream(out);
            FormatCommonV1.writeDiff(diff, dataOut);
        }
View Full Code Here

            @Override
            protected RevObject computeNext() {
                if (current != null) {
                    Preconditions.checkState(current.metadataObject != null);
                    RevObject ret = current.metadataObject;
                    current = null;
                    return ret;
                }
                while (readingIterator.hasNext()) {
                    DiffPacket diffPacket = readingIterator.next();
                    callback.callback(diffPacket.entry);
                    RevObject obj = diffPacket.newObject;
                    RevObject md = diffPacket.metadataObject;
                    Preconditions.checkState(obj != null || (obj == null && md == null));
                    if (obj != null) {
                        if (md != null) {
                            current = diffPacket;
                        }
View Full Code Here

        }

        private DiffPacket readNext() throws IOException {
            final CHUNK_TYPE chunkType = CHUNK_TYPE.valueOf((int) (data.readByte() & 0xFF));

            RevObject revObj = null;
            RevObject metadata = null;

            switch (chunkType) {
            case DIFF_ENTRY:
                break;
            case OBJECT_AND_DIFF_ENTRY: {
View Full Code Here

     */
    @Override
    protected SimpleFeatureStore _call() {
        final StagingDatabase database = stagingDatabase();
        if (filterFeatureTypeId != null) {
            RevObject filterType = database.getIfPresent(filterFeatureTypeId);
            checkArgument(filterType instanceof RevFeatureType,
                    "Provided filter feature type is does not exist");
        }

        final SimpleFeatureStore targetStore = getTargetStore();
View Full Code Here

            NodeRef newObject;
            if (oldObject != null) {
                newObject = input.getNewObject();
                if (newObject != null) {
                    // we are tracking this object, but we still need to process the new object
                    RevObject object = sourceRepo.command(RevObjectParse.class)
                            .setObjectId(newObject.getNode().getObjectId()).call().get();

                    RevObject metadata = null;
                    if (newObject.getMetadataId() != ObjectId.NULL) {
                        metadata = sourceRepo.command(RevObjectParse.class)
                                .setObjectId(newObject.getMetadataId()).call().get();
                    }
                    processObject(object);
View Full Code Here

    private NodeRef filter(NodeRef node) {
        if (node == null) {
            return null;
        }

        RevObject object = sourceRepo.objectDatabase().get(node.objectId());

        RevObject metadata = null;
        if (!node.getMetadataId().isNull()) {
            metadata = sourceRepo.objectDatabase().get(node.getMetadataId());
        }
        if (node.getType() == TYPE.FEATURE) {
            if (trackingObject(object.getId())) {
View Full Code Here

            } else {
                if (enqueue) {
                    // We're building up a list of objects to visit, so add all the reachable
                    // objects from here to the front of the toVisit stack
                    final ObjectId id = currentList.get(0);
                    final RevObject object = database.get(id);
                    final List<ObjectId> next = new ArrayList<ObjectId>();
                    successors.findSuccessors(object, next);
                    toVisit.add(0, next);
                } else {
                    // We just visited a node, so switch back to enqueuing mode in order to make
View Full Code Here

TOP

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

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.