public Object visit(Id filter, Object extraData) { Set ids = filter.getIDs(); if (ids.isEmpty()) { throw new IllegalArgumentException("Invalid fid filter provides, has no fids inside"); } Set<FeatureId> fids = new HashSet<FeatureId>(); for (Iterator it = ids.iterator(); it.hasNext(); ) { FeatureId id = new FeatureIdImpl((String) it.next()); FeatureId retyped = RetypingFeatureCollection.reTypeId( id, map.getFeatureType(), map.getOriginalFeatureType()); fids.add(retyped); } return ff.id(fids); } }
/** * Given a feature id following the <typename>.<internalId> convention, the original type and * the destination type, this converts the id from <original>.<internalid> to * <target>.<internalid> * * @param id * @param original * @param target */ public static FeatureId reTypeId( FeatureId sourceId, SimpleFeatureType original, SimpleFeatureType target) { final String originalTypeName = original.getName().getLocalPart(); final String destTypeName = target.getName().getLocalPart(); if (destTypeName.equals(originalTypeName)) return sourceId; final String prefix = originalTypeName + "."; if (sourceId.getID().startsWith(prefix)) { return new FeatureIdImpl( destTypeName + "." + sourceId.getID().substring(prefix.length())); } else return sourceId; }
public MongoFeature( DBObject mongoObject, Object[] values, SimpleFeatureType featureType, String id) { super(values, featureType, new FeatureIdImpl(id), false); this.values = values; this.mongoObject = mongoObject; }
public Object convert(Object source, Class target) { if (source != null) { return new FeatureIdImpl((String) source); } return null; } };
public FeatureId featureId(String id) { return new FeatureIdImpl(id); }
.andReturn(Collections.singletonList((FeatureId) (new FeatureIdImpl("trees.105")))); replay(fs);
.andReturn(Collections.singletonList((FeatureId) (new FeatureIdImpl("trees.105")))); replay(fs);
/** * Internal method for a temporary FeatureId that can be assigned a real value after a commit. * * @param suggestedId suggested id */ public static FeatureIdImpl createDefaultFeatureIdentifier(String suggestedId) { if (suggestedId != null) { return new FeatureIdImpl(suggestedId); } return new FeatureIdImpl(createDefaultFeatureId()); } }
/** * Adds a feature ID to the filter. * * @param fid A single feature ID. * @deprecated */ public final void addFid(String fid) { LOGGER.finest("got fid: " + fid); fids.add(new FeatureIdImpl(fid)); ids.add(fid); }
private static FeatureIdImpl createDefaultFID(String id) { if (id == null) { id = SimpleFeatureBuilder.createDefaultFeatureId(); } return new FeatureIdImpl(id); }
@Override public FeatureId getIdentifier() { String id = getID(); return id != null ? new FeatureIdImpl(id) : null; }
public boolean matches(Object object) { if (object instanceof org.opengis.feature.Feature) { return new FeatureIdImpl(gmlId).matches((org.opengis.feature.Feature) object); } // TODO: geometries return false; }
private MongoCollectionFeature( MongoFeature feature, String collectionPath, int collectionIndex) { super( feature.getValues(), feature.getFeatureType(), new FeatureIdImpl(UUID.randomUUID().toString()), false); this.mongoFeature = feature; this.collectionsIndexes.put(collectionPath, collectionIndex); this.collectionPath = collectionPath; }
@Override public void run() { try { feature = DataAccessRegistry.getInstance() .findFeature(new FeatureIdImpl(refId), hints); } catch (IOException e) { // ignore, no resolve } } };
@Test(expected = InvalidClassException.class) public void wrap_invalidFeatureCannotResolvePath_throwsInvalidClassException() throws Exception { // Arrange Collection<Property> properties = new ArrayList<Property>(); Feature mine = new FeatureImpl(properties, Mine.MINETYPE_TYPE, new FeatureIdImpl("Invalid mine.")); // Act try { FeatureWrapper.wrap(mine, MineType.class); } catch (InvalidClassException ice) { ExceptionChecker.assertExceptionMessage( ice, "Unable to wrap attribute in class 'class org.geotools.feature.wrapper.MineType'. Reference to mineName could not be found in the attribute."); } }
if (current.getUserData().containsKey(Hints.PROVIDED_FID)) { String fid = (String) current.getUserData().get(Hints.PROVIDED_FID); FeatureId id = new FeatureIdImpl(fid); current = new SimpleFeatureImpl(
@Test(expected = InvalidClassException.class) public void wrap_invalidFeatureMissingMineName_throwsInvalidClassException() throws Exception { // Arrange Collection<Property> MineNamePropertyProperties = new ArrayList<Property>(); // MineNamePropertyProperties.add(MineName); // Deliberately not adding // this. // ComplexAttributeImpl:MineNamePropertyType= ComplexAttribute MineNamePropertyType = new ComplexAttributeImpl( MineNamePropertyProperties, Mine.MINENAMEPROPERTYTYPE_TYPE, null); Collection<Property> MineProperties = new ArrayList<Property>(); MineProperties.add(MineNamePropertyType); // FeatureImpl:MineType<MineType id=Mine>= Feature mine = new FeatureImpl( MineProperties, Mine.MINETYPE_TYPE, new FeatureIdImpl("Invalid Mine")); // Act try { FeatureWrapper.wrap(mine, MineType2.class); } catch (InvalidClassException ice) { ExceptionChecker.assertExceptionMessage( ice, "Unable to wrap attribute in class 'org.geotools.feature.wrapper.MineNamePropertyType'. 'urn:org:example:MineNamePropertyType' doesn't have required property 'urn:org:example:MineName'."); } } }
MineProperties, Mine.MINETYPE_TYPE, new FeatureIdImpl("Invalid Mine"));
new FeatureImpl(MineProperties, Mine.MINETYPE_TYPE, new FeatureIdImpl("Mine"));
MineProperties, Mine.MINETYPE_TYPE, new FeatureIdImpl("Invalid Mine"));