Search in sources :

Example 1 with ContentEntry

use of org.geotools.data.store.ContentEntry in project GeoGig by boundlessgeo.

the class GeoGigDataStore method getDiffFeatureSource.

/**
     * Builds a FeatureSource (read-only) that fetches features out of the differences between two
     * root trees: a provided tree-ish as the left side of the comparison, and the datastore's
     * configured HEAD as the right side of the comparison.
     * <p>
     * E.g., to get all features of a given feature type that were removed between a given commit
     * and its parent:
     * 
     * <pre>
     * <code>
     * String commitId = ...
     * GeoGigDataStore store = new GeoGigDataStore(geogig);
     * store.setHead(commitId);
     * FeatureSource removed = store.getDiffFeatureSource("roads", commitId + "~1", ChangeType.REMOVED);
     * </code>
     * </pre>
     * 
     * @param typeName the feature type name to look up a type tree for in the datastore's current
     *        {@link #getOrFigureOutHead() HEAD}
     * @param oldRoot a tree-ish string that resolves to the ROOT tree to be used as the left side
     *        of the diff
     * @param changeType the type of change between {@code oldRoot} and
     *        {@link #getOrFigureOutHead() head} to pick as the features to return.
     * @return a feature source whose features are computed out of the diff between the feature type
     *         diffs between the given {@code oldRoot} and the datastore's
     *         {@link #getOrFigureOutHead() HEAD}.
     */
public SimpleFeatureSource getDiffFeatureSource(final String typeName, final String oldRoot, final ChangeType changeType) throws IOException {
    Preconditions.checkNotNull(typeName, "typeName");
    Preconditions.checkNotNull(oldRoot, "oldRoot");
    Preconditions.checkNotNull(changeType, "changeType");
    final Name name = name(typeName);
    final ContentEntry entry = ensureEntry(name);
    GeogigFeatureSource featureSource = new GeogigFeatureSource(entry);
    featureSource.setTransaction(Transaction.AUTO_COMMIT);
    featureSource.setChangeType(changeType);
    if (ObjectId.NULL.toString().equals(oldRoot) || RevTree.EMPTY_TREE_ID.toString().equals(oldRoot)) {
        featureSource.setOldRoot(null);
    } else {
        featureSource.setOldRoot(oldRoot);
    }
    return featureSource;
}
Also used : ContentEntry(org.geotools.data.store.ContentEntry) Name(org.opengis.feature.type.Name)

Aggregations

ContentEntry (org.geotools.data.store.ContentEntry)1 Name (org.opengis.feature.type.Name)1