use of org.opengis.feature.type.Name in project GeoGig by boundlessgeo.
the class RemoteRepositoryTestCase method insert.
/**
* Inserts the feature to the index but does not stages it to be committed
*/
protected ObjectId insert(GeoGIG geogig, Feature f) throws Exception {
final WorkingTree workTree = geogig.getRepository().workingTree();
Name name = f.getType().getName();
String parentPath = name.getLocalPart();
Node ref = workTree.insert(parentPath, f);
ObjectId objectId = ref.getObjectId();
return objectId;
}
use of org.opengis.feature.type.Name in project GeoGig by boundlessgeo.
the class GeoGigDataStoreTest method testGetSchemaProvidedNamespace.
@Test
public void testGetSchemaProvidedNamespace() throws Exception {
String namespace = "http://www.geogig.org/test";
dataStore.setNamespaceURI(namespace);
insertAndAdd(lines1);
commit();
SimpleFeatureType lines = dataStore.getSchema(RepositoryTestCase.linesTypeName);
Name expectedName = new NameImpl(namespace, linesName);
assertEquals(expectedName, lines.getName());
assertEquals(super.linesType.getAttributeDescriptors(), lines.getAttributeDescriptors());
insertAndAdd(points1);
commit();
SimpleFeatureType points = dataStore.getSchema(RepositoryTestCase.pointsTypeName);
assertEquals(new NameImpl(namespace, pointsName), points.getName());
assertEquals(super.pointsType.getAttributeDescriptors(), points.getAttributeDescriptors());
}
use of org.opengis.feature.type.Name in project GeoGig by boundlessgeo.
the class RepositoryTestCase method insert.
/**
* Inserts the feature to the index but does not stages it to be committed
*/
public ObjectId insert(GeogigTransaction transaction, Feature f) throws Exception {
final WorkingTree workTree = (transaction != null ? transaction.workingTree() : repo.workingTree());
Name name = f.getType().getName();
String parentPath = name.getLocalPart();
Node ref = workTree.insert(parentPath, f);
ObjectId objectId = ref.getObjectId();
return objectId;
}
use of org.opengis.feature.type.Name in project GeoGig by boundlessgeo.
the class RepositoryTestCase method delete.
public boolean delete(GeogigTransaction transaction, Feature f) throws Exception {
final WorkingTree workTree = (transaction != null ? transaction.workingTree() : repo.workingTree());
Name name = f.getType().getName();
String localPart = name.getLocalPart();
String id = f.getIdentifier().getID();
boolean existed = workTree.delete(localPart, id);
return existed;
}
use of org.opengis.feature.type.Name in project GeoGig by boundlessgeo.
the class DescribeOp method _call.
/**
* Describes a table from the data store that has been assigned.
*
* @return a map that contains all properties and their types from the provided table
*/
@Override
protected Optional<Map<String, String>> _call() {
if (dataStore == null) {
throw new GeoToolsOpException(StatusCode.DATASTORE_NOT_DEFINED);
}
if (table == null || table.isEmpty()) {
throw new GeoToolsOpException(StatusCode.TABLE_NOT_DEFINED);
}
Map<String, String> propertyMap = new HashMap<String, 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) {
if (!table.equals(typeName.toString()))
continue;
foundTable = true;
SimpleFeatureSource featureSource;
try {
featureSource = dataStore.getFeatureSource(typeName);
} catch (Exception e) {
throw new GeoToolsOpException(StatusCode.UNABLE_TO_GET_FEATURES);
}
SimpleFeatureType featureType = featureSource.getSchema();
Collection<PropertyDescriptor> descriptors = featureType.getDescriptors();
for (PropertyDescriptor descriptor : descriptors) {
propertyMap.put(descriptor.getName().toString(), descriptor.getType().getBinding().getSimpleName());
}
}
if (!foundTable) {
return Optional.absent();
}
return Optional.of(propertyMap);
}
Aggregations