use of org.opengis.feature.type.Name 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;
}
use of org.opengis.feature.type.Name in project GeoGig by boundlessgeo.
the class GeogigFeatureSource method getTypeRef.
/**
* @return
*/
NodeRef getTypeRef() {
GeoGigDataStore dataStore = getDataStore();
Name name = getName();
Transaction transaction = getTransaction();
return dataStore.findTypeRef(name, transaction);
}
use of org.opengis.feature.type.Name in project GeoGig by boundlessgeo.
the class GeogigFeatureSource method buildFeatureType.
@Override
protected SimpleFeatureType buildFeatureType() throws IOException {
SimpleFeatureType featureType = getNativeType();
final Name name = featureType.getName();
final Name assignedName = getEntry().getName();
if (assignedName.getNamespaceURI() != null && !assignedName.equals(name)) {
SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
builder.init(featureType);
builder.setName(assignedName);
featureType = builder.buildFeatureType();
}
return featureType;
}
use of org.opengis.feature.type.Name in project GeoGig by boundlessgeo.
the class ListOp method _call.
/**
* Executes the list operation on the provided data store.
*
* @return a list of all tables, or Optional.absent() if none were found
*/
@Override
protected Optional<List<String>> _call() {
if (dataStore == null) {
throw new GeoToolsOpException(StatusCode.DATASTORE_NOT_DEFINED);
}
List<String> features = new ArrayList<String>();
boolean foundTable = false;
List<Name> typeNames;
try {
typeNames = dataStore.getNames();
} catch (Exception e) {
throw new GeoToolsOpException(StatusCode.UNABLE_TO_GET_NAMES);
}
for (Name typeName : typeNames) {
foundTable = true;
features.add(typeName.toString());
}
if (!foundTable) {
return Optional.absent();
}
return Optional.of(features);
}
use of org.opengis.feature.type.Name in project GeoGig by boundlessgeo.
the class RemoteRepositoryTestCase method delete.
protected boolean delete(GeoGIG geogig, Feature f) throws Exception {
final WorkingTree workTree = geogig.getRepository().workingTree();
Name name = f.getType().getName();
String localPart = name.getLocalPart();
String id = f.getIdentifier().getID();
boolean existed = workTree.delete(localPart, id);
return existed;
}
Aggregations