Examples of FeatureDiff


Examples of org.geotools.data.FeatureDiff

    public FeatureDiff next() throws IOException, NoSuchElementException {
        if (!hasNext()) {
            throw new NoSuchElementException("No more feature diffs in this reader");
        }

        FeatureDiff result = nextDifference;
        nextDifference = null;

        return result;
    }
View Full Code Here

Examples of org.geotools.data.FeatureDiff

        // updates -> the set of changes has to be rebuilt
        SimpleFeature from = null;
        SimpleFeature to = null;
        boolean removed = false;
        for (int i = 0; i < history.length; i++) {
            FeatureDiff diff = history[i];
            if (diff != null) {
                if (diff.getState() == FeatureDiff.INSERTED) {
                    // is this the rollback of a removal?
                    if(removed == true) {
                        from = null;
                        to = null;
                    } else {
                        from = null;
                        to = diff.getFeature();
                    }
                    removed = false;
                } else if (diff.getState() == FeatureDiff.DELETED) {
                    if (from == null) {
                        from = diff.getOldFeature();
                    }
                    to = null;
                    removed = true;
                } else {
                    // might we have a removed flag before this update? Maybe... if Central
                    // for some reason reinserted the feature (remember we're skipping
                    // changes coming from Central. But in that case we start over fresh
                    if (removed) {
                        removed = false;
                        from = diff.getOldFeature();
                    }

                    // is this the first diff or we have a history?
                    if (from == null) {
                        from = diff.getOldFeature();
                    }
                    to = diff.getFeature();
                }
            }
        }
       
        if(from == null && to == null) {
View Full Code Here

Examples of org.geotools.data.FeatureDiff

        for (int i = 0; i < delegates.length; i++) {
            if (delegates[i] != null && !featureRead[i]) {
                // read the next diff that is not linked to a conflicting feature
                while (delegates[i].hasNext()) {
                    // grab a new feature diff
                    FeatureDiff fd = delegates[i].next();
                    String fid = fd.getID();
                   
                    // is it about a feature id we already know about?
                    FeatureDiff[] history;
                    if (sortedFids.contains(fid)) {
                        history = diffHistory.get(fid);
View Full Code Here

Examples of org.geotools.data.FeatureDiff

                    String newLocalRevisionId = String.valueOf(newLocalRevision);
                    String lastLocalRevisionId = lastLocalRevision != -1 ? String.valueOf(lastLocalRevision) : "FIRST";
                    FeatureDiffReader localChanges = fs.getDifferences(lastLocalRevisionId,
                            newLocalRevisionId, ff.id(changedFids), null);
                    while (localChanges.hasNext()) {
                        FeatureDiff fd = localChanges.next();
                        FeatureId diffFeatureId = ff.featureId(fd.getID());
                        if (fd.getState() == FeatureDiff.INSERTED) {
                            throw new GSSException(
                                    "A new locally inserted feature has the same "
                                            + "id as a modified feature coming from Central, this is impossible, "
                                            + "there is either a bug in ID generation or someone manually tampered with it!");
                        } else if (fd.getState() == FeatureDiff.DELETED) {
                            if (deletedFids.contains(diffFeatureId)) {
                                saveCleanMergeMarker(fs, conflicts, lastLocalRevisionId,
                                        newLocalRevision, fd.getID());
                            } else {
                                handleDeletionConflict(fs, conflicts, lastLocalRevisionId,
                                        newLocalRevision, fd.getID());
                            }
                        } else {
                            if (updatedFids.contains(diffFeatureId)) {
                                if (isSameUpdate(fd, findUpdate(fd.getID(), updates))) {
                                    saveCleanMergeMarker(fs, conflicts, lastLocalRevisionId,
                                            newLocalRevision, fd.getID());
                                } else {
                                    handleUpdateConflict(fs, conflicts, lastLocalRevisionId,
                                            newLocalRevision, fd.getID());
                                }
                            } else {
                                handleUpdateConflict(fs, conflicts, lastLocalRevisionId,
                                        newLocalRevision, fd.getID());
                            }
                        }
                    }
                    localChanges.close();
                }
View Full Code Here

Examples of org.locationtech.geogig.api.plumbing.diff.FeatureDiff

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

Examples of org.locationtech.geogig.api.plumbing.diff.FeatureDiff

                        RevFeature feature = revObjectParse.setRefSpec(refSpec)
                                .call(RevFeature.class).get();
                        report.setFirstVersion(feature, commit);
                        break;
                    }
                    FeatureDiff featureDiff = diffFeature
                            .setNewVersion(Suppliers.ofInstance(diff.getNewObject()))
                            .setOldVersion(Suppliers.ofInstance(diff.getOldObject())).call();
                    Map<PropertyDescriptor, AttributeDiff> attribDiffs = featureDiff.getDiffs();
                    Iterator<PropertyDescriptor> iter = attribDiffs.keySet().iterator();
                    while (iter.hasNext()) {
                        PropertyDescriptor key = iter.next();
                        Optional<?> value = attribDiffs.get(key).getNewValue();
                        String attribute = key.getName().toString();
View Full Code Here

Examples of org.locationtech.geogig.api.plumbing.diff.FeatureDiff

        String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID());
        Map<PropertyDescriptor, AttributeDiff> map = Maps.newHashMap();
        Optional<?> oldValue = Optional.fromNullable(points1.getProperty("sp").getValue());
        GenericAttributeDiffImpl diff = new GenericAttributeDiffImpl(oldValue, Optional.of("new"));
        map.put(pointsType.getDescriptor("sp"), diff);
        FeatureDiff feaureDiff = new FeatureDiff(path, map, RevFeatureTypeImpl.build(pointsType),
                RevFeatureTypeImpl.build(pointsType));
        patch.addModifiedFeature(feaureDiff);
        File file = new File(platform.pwd(), "test.patch");
        BufferedWriter writer = Files.newWriter(file, Charsets.UTF_8);
        PatchSerializer.write(writer, patch);
View Full Code Here

Examples of org.locationtech.geogig.api.plumbing.diff.FeatureDiff

            if (describe) {
                sb.append(diffEntry.changeType().toString().charAt(0)).append(' ').append(path)
                        .append(LINE_BREAK);

                if (diffEntry.changeType() == ChangeType.MODIFIED) {
                    FeatureDiff featureDiff = geogig.command(DiffFeature.class)
                            .setNewVersion(Suppliers.ofInstance(diffEntry.getNewObject()))
                            .setOldVersion(Suppliers.ofInstance(diffEntry.getOldObject())).call();
                    Map<PropertyDescriptor, AttributeDiff> diffs = featureDiff.getDiffs();
                    HashSet<PropertyDescriptor> diffDescriptors = Sets.newHashSet(diffs.keySet());
                    NodeRef noderef = diffEntry.changeType() != ChangeType.REMOVED ? diffEntry
                            .getNewObject() : diffEntry.getOldObject();
                    RevFeatureType featureType = geogig.command(RevObjectParse.class)
                            .setObjectId(noderef.getMetadataId()).call(RevFeatureType.class).get();
View Full Code Here

Examples of org.locationtech.geogig.api.plumbing.diff.FeatureDiff

        if (!noHeader) {
            summaryPrinter.print(geogig, console, diffEntry);
        }

        if (diffEntry.changeType() == ChangeType.MODIFIED) {
            FeatureDiff diff = geogig.command(DiffFeature.class)
                    .setNewVersion(Suppliers.ofInstance(diffEntry.getNewObject()))
                    .setOldVersion(Suppliers.ofInstance(diffEntry.getOldObject())).call();

            Map<PropertyDescriptor, AttributeDiff> diffs = diff.getDiffs();

            Ansi ansi = AnsiDecorator.newAnsi(console.getTerminal().isAnsiSupported());
            Set<Entry<PropertyDescriptor, AttributeDiff>> entries = diffs.entrySet();
            Iterator<Entry<PropertyDescriptor, AttributeDiff>> iter = entries.iterator();
            while (iter.hasNext()) {
View Full Code Here

Examples of org.locationtech.geogig.api.plumbing.diff.FeatureDiff

    }

    private FeatureDiff compare(RevFeature oldRevFeature, RevFeature newRevFeature,
            RevFeatureType oldRevFeatureType, RevFeatureType newRevFeatureType) {

        return new FeatureDiff(oldNodeRef.path(), newRevFeature, oldRevFeature, newRevFeatureType,
                oldRevFeatureType, false);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.