Package org.geotools.data

Examples of org.geotools.data.FeatureDiffReader


                    TransactionType centralChanges;
                    LOGGER.log(Level.INFO, "About to compute PostDiff changes. Last central revision known to client " + clientCentralRevision + ", last GetDiff central revision " + getDiffCentralRevision);
                    if (getDiffCentralRevision == null || clientCentralRevision >= getDiffCentralRevision) {
                        // either first time or we don't need to make jumps
                        LOGGER.log(Level.INFO, "First PostDiff or clientRevion same as the last central one, computing diff from " + fromRevision +  " to LAST");
                        FeatureDiffReader fdr = fs.getDifferences(fromRevision, "LAST", null, null);
                        centralChanges = new VersioningTransactionConverter().convert(fdr,
                                TransactionType.class);
                    } else  {
                        // we need to jump over the last local changes
                        String before = String.valueOf(getDiffCentralRevision - 1);
                        String after = String.valueOf(getDiffCentralRevision);
                        LOGGER.log(Level.INFO, "Client revision lower than the server one, computing diff from " + fromRevision +  " to " + before + " and merging with diffs from " + after + " to LAST");
                        FeatureDiffReader fdr1 = fs.getDifferences(fromRevision, before, null, null);
                        FeatureDiffReader fdr2 = fs.getDifferences(after, "LAST", null, null);
                        FeatureDiffReader[] fdr = new FeatureDiffReader[] { fdr1, fdr2 };
                        centralChanges = new VersioningTransactionConverter().convert(fdr,
                                TransactionType.class);
                    }
View Full Code Here


        SimpleFeature f = SimpleFeatureBuilder.build(schema, new Object[] { 123,
                wkt.read("POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))") }, null);
        restricted.addFeatures(collection(f));

        // grab a diff reader
        FeatureDiffReader reader = restricted.getDifferences("FIRST", "LAST", null, null);
        FeatureDiffReader reader2 = restricted.getDifferences("FIRST", "LAST", null, null);

        // build a merging one, it should report the same resuls
        MergingFeatureDiffReader merge = new MergingFeatureDiffReader(reader2);

        int count = 0;
View Full Code Here

        t.close();
       
        restricted.setTransaction(Transaction.AUTO_COMMIT);

        // grab the two readers, separate
        FeatureDiffReader r1 = restricted.getDifferences("FIRST", v1, null, null);
        FeatureDiffReader r2 = restricted.getDifferences(v1, v2, null, null);

        // build a merging one, it should report the same resuls
        MergingFeatureDiffReader merge = new MergingFeatureDiffReader(r1, r2);
       
        assertFalse(merge.hasNext());
View Full Code Here

        // clean up
        t.close();
        restricted.setTransaction(Transaction.AUTO_COMMIT);

        // grab the two readers, separate
        FeatureDiffReader r1 = restricted.getDifferences("FIRST", v1, null, null);
        FeatureDiffReader r2 = restricted.getDifferences(v1, v2, null, null);

        // build a merging one, it should report the same resuls
        MergingFeatureDiffReader merge = new MergingFeatureDiffReader(r1, r2);
       
        assertTrue(merge.hasNext());
View Full Code Here

                    TransactionType centralChanges;
                    LOGGER.log(Level.INFO, "About to compute PostDiff changes. Last central revision known to client " + clientCentralRevision + ", last GetDiff central revision " + getDiffCentralRevision);
                    if (getDiffCentralRevision == null || clientCentralRevision >= getDiffCentralRevision) {
                        // either first time or we don't need to make jumps
                        LOGGER.log(Level.INFO, "First PostDiff or clientRevion same as the last central one, computing diff from " + fromRevision +  " to LAST");
                        FeatureDiffReader fdr = fs.getDifferences(fromRevision, "LAST", null, null);
                        centralChanges = new VersioningTransactionConverter().convert(fdr,
                                TransactionType.class);
                    } else  {
                        // we need to jump over the last local changes
                        String before = String.valueOf(getDiffCentralRevision - 1);
                        String after = String.valueOf(getDiffCentralRevision);
                        LOGGER.log(Level.INFO, "Client revision lower than the server one, computing diff from " + fromRevision +  " to " + before + " and merging with diffs from " + after + " to LAST");
                        FeatureDiffReader fdr1 = fs.getDifferences(fromRevision, before, null, null);
                        FeatureDiffReader fdr2 = fs.getDifferences(after, "LAST", null, null);
                        FeatureDiffReader[] fdr = new FeatureDiffReader[] { fdr1, fdr2 };
                        centralChanges = new VersioningTransactionConverter().convert(fdr,
                                TransactionType.class);
                    }
View Full Code Here

                if (changedFids.size() > 0) {
                    // limit the changeset to the window between the last and the current
                    // synchronization
                    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();
                }

                // now that conflicting local changes have been moved out of the way, apply the
                // central ones
                core.applyChanges(changes, fs);
View Full Code Here

                }
   
                // now we need to merge the readers into a global set of changes, skip
                // the changes on the conflicting features, and turn everything into a
                // transaction (easy no?)
                FeatureDiffReader differences = new MergingFeatureDiffReader(readers);
                transaction = new VersioningTransactionConverter().convert(differences,
                        TransactionType.class);
            } else {
                // no local changes to return, it happens only if we never had local changes
                // in the current history
View Full Code Here

TOP

Related Classes of org.geotools.data.FeatureDiffReader

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.