use of org.opengis.filter.ResourceId in project geotoolkit by Geomatys.
the class AddDelta method commit.
/**
* {@inheritDoc }
*/
@Override
public Map<String, String> commit(final FeatureStore store) throws DataStoreException {
final List<ResourceId> createdIds = store.addFeatures(type.toString(), features);
// iterator and list should have the same size
final Map<String, String> updates = new HashMap<String, String>();
final FeatureIterator ite = features.iterator();
int i = 0;
try {
if (createdIds != null && !createdIds.isEmpty()) {
while (ite.hasNext()) {
final Feature f = ite.next();
final String id = FeatureExt.getId(f).getIdentifier();
updates.put(id, createdIds.get(i).getIdentifier());
i++;
}
}
} finally {
ite.close();
}
features.clear();
return updates;
}
use of org.opengis.filter.ResourceId in project geotoolkit by Geomatys.
the class IdTest method testFeatureId.
@Test
public void testFeatureId() {
String strid = "testFeatureType.1";
ResourceId id1 = FF.resourceId(strid);
ResourceId id2 = FF.resourceId(strid);
assertEquals(strid, id1.getIdentifier());
assertEquals(id1, id2);
}
use of org.opengis.filter.ResourceId in project geotoolkit by Geomatys.
the class FIDFixVisitorTest method testReplacement1.
@Test
public void testReplacement1() {
Filter filter = FF.equal(FF.property(AttributeConvention.IDENTIFIER), FF.literal("river.1"));
filter = (Filter) FIDFixVisitor.INSTANCE.visit(filter);
assertNotNull(filter);
assertTrue(filter instanceof ResourceId);
ResourceId fid = (ResourceId) filter;
assertEquals("river.1", fid.getIdentifier());
}
use of org.opengis.filter.ResourceId in project geotoolkit by Geomatys.
the class FIDFixVisitorTest method testReplacement2.
@Test
public void testReplacement2() {
Filter filter = FF.equal(FF.literal("river.1"), FF.property(AttributeConvention.IDENTIFIER));
filter = (Filter) FIDFixVisitor.INSTANCE.visit(filter);
assertNotNull(filter);
assertTrue(filter instanceof ResourceId);
ResourceId fid = (ResourceId) filter;
assertEquals("river.1", fid.getIdentifier());
}
use of org.opengis.filter.ResourceId in project geotoolkit by Geomatys.
the class JDBCFeatureWriterUpdate method write.
@Override
public void write() throws FeatureStoreRuntimeException {
if (last == null) {
throw new FeatureStoreRuntimeException("Cursor is not on a record.");
}
try {
// figure out what the fid is
final PrimaryKey key = store.getDatabaseModel().getPrimaryKey(type.getName().toString());
final String fid = key.encodeFID(rs);
final FilterFactory ff = store.getFilterFactory();
final ResourceId filter = ff.resourceId(fid);
// figure out which attributes changed
final Map<String, Object> changes = new HashMap<>();
for (final PropertyType att : type.getProperties(true)) {
if (att instanceof FeatureAssociationRole || att instanceof Operation || AttributeConvention.contains(att.getName())) {
// not a writable property
continue;
}
changes.put(att.getName().tip().toString(), last.getPropertyValue(att.getName().toString()));
}
// do the write
store.updateSingle(type, changes, filter, st.getConnection());
} catch (Exception e) {
throw new FeatureStoreRuntimeException(e);
}
}
Aggregations