/** * Loads an attribute descriptor from feature type and attribute type metadata. * * <p>This method returns null if the attribute descriptor could not be loaded. */ public AttributeDescriptor getAttributeDescriptor( FeatureTypeInfo ftInfo, AttributeTypeInfo atInfo) throws Exception { FeatureType featureType = getFeatureType(ftInfo); if (featureType != null) { for (PropertyDescriptor pd : featureType.getDescriptors()) { if (pd instanceof AttributeDescriptor) { AttributeDescriptor ad = (AttributeDescriptor) pd; if (atInfo.getName().equals(ad.getLocalName())) { return ad; } } } } return null; }
} else { if (limitedAttributeSize > 0 && fc.getSchema().getDescriptors().size() > limitedAttributeSize) { if (fc instanceof SimpleFeatureCollection) {
/** * Extracts the AttributeTypeInfo by copying them from the specified feature type. * * @param ft The schema to be harvested * @param info The optional feature type info from which all the attributes belong to */ public List<AttributeTypeInfo> getAttributes(FeatureType ft, FeatureTypeInfo info) { List<AttributeTypeInfo> attributes = new ArrayList<AttributeTypeInfo>(); for (PropertyDescriptor pd : ft.getDescriptors()) { AttributeTypeInfo att = catalog.getFactory().createAttribute(); att.setFeatureType(info); att.setName(pd.getName().getLocalPart()); att.setMinOccurs(pd.getMinOccurs()); att.setMaxOccurs(pd.getMaxOccurs()); att.setNillable(pd.isNillable()); att.setBinding(pd.getType().getBinding()); int length = FeatureTypes.getFieldLength(pd); if (length > 0) { att.setLength(length); } attributes.add(att); } return attributes; }
public List<AttributeTypeInfo> loadAttributes(FeatureTypeInfo info) throws IOException { List<AttributeTypeInfo> attributes = new ArrayList(); FeatureType ft = getFeatureType(info); for (PropertyDescriptor pd : ft.getDescriptors()) { AttributeTypeInfo att = catalog.getFactory().createAttribute(); att.setFeatureType(info); att.setName(pd.getName().getLocalPart()); att.setMinOccurs(pd.getMinOccurs()); att.setMaxOccurs(pd.getMaxOccurs()); att.setNillable(pd.isNillable()); att.setBinding(pd.getType().getBinding()); int length = FeatureTypes.getFieldLength(pd); if (length > 0) { att.setLength(length); } attributes.add(att); } return attributes; }
if (info.getAttributes() == null || info.getAttributes().isEmpty()) { for (PropertyDescriptor pd : ft.getDescriptors()) { if (!(pd instanceof AttributeDescriptor)) { continue;
public Object get(Object object, String xpath, Class target) { if (object instanceof Feature) return ((Feature) object).getDefaultGeometryProperty(); if (object instanceof FeatureType) { FeatureType ft = (FeatureType) object; GeometryDescriptor gd = ft.getGeometryDescriptor(); if (gd == null) { // look for any geometry descriptor for (PropertyDescriptor pd : ft.getDescriptors()) { if (Geometry.class.isAssignableFrom(pd.getType().getBinding())) { return pd; } } } return gd; } return null; }
throws DataSourceException { List<PropertyDescriptor> attributes; Collection<PropertyDescriptor> descriptors = realType.getDescriptors(); attributes = new ArrayList<PropertyDescriptor>(descriptors); List<String> simpleProperties = new ArrayList<String>();
for (PropertyDescriptor propertyDescriptor : super.featureType.getDescriptors()) { Name name = propertyDescriptor.getName();
Collection<PropertyDescriptor> types = featureType.getDescriptors(); StringBuffer buf = new StringBuffer();
Collection<Property> value = new ArrayList<Property>(); for (PropertyDescriptor pd : schema.getDescriptors()) { if (pd instanceof AttributeDescriptor) { if (pd instanceof GeometryDescriptor) {
if (schema instanceof SimpleFeatureType) { List<Name> allNames = new ArrayList<Name>(); for (PropertyDescriptor pd : schema.getDescriptors()) { allNames.add(pd.getName());
private FeatureType reprojectType(FeatureType type) { Collection<PropertyDescriptor> schema = new ArrayList<PropertyDescriptor>(); for (PropertyDescriptor descr : type.getDescriptors()) { if (descr instanceof GeometryDescriptor) { schema.add(reprojectGeometry((GeometryDescriptor) descr)); } else { schema.add(descr); } } FeatureType ft; if (type instanceof NonFeatureTypeProxy) { ft = new NonFeatureTypeProxy( ((NonFeatureTypeProxy) type).getSubject(), mapping, schema); } else { ft = ftf.createFeatureType( type.getName(), schema, reprojectGeometry(type.getGeometryDescriptor()), type.isAbstract(), type.getRestrictions(), type.getSuper(), type.getDescription()); } ft.getUserData().putAll(type.getUserData()); return ft; }
/** * Create the modified feature type. * * @param sourceFeatureType the source feature type * @return the modified feature type * @throws ProcessException errror */ private SimpleFeatureType createTargetFeatureType(FeatureType sourceFeatureType) throws ProcessException { try { SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder(); typeBuilder.setName(sourceFeatureType.getName().getLocalPart()); typeBuilder.setNamespaceURI(sourceFeatureType.getName().getNamespaceURI()); AttributeDescriptor geomAttbType = sourceFeatureType.getGeometryDescriptor(); for (PropertyDescriptor attbType : sourceFeatureType.getDescriptors()) { if (attbType.equals(geomAttbType)) { typeBuilder.add(geomAttbType.getLocalName(), Point.class); } else { typeBuilder.add((AttributeDescriptor) attbType); } } typeBuilder.setDefaultGeometry( sourceFeatureType.getGeometryDescriptor().getLocalName()); return typeBuilder.buildFeatureType(); } catch (Exception e) { LOGGER.warning("Error creating type: " + e); throw new ProcessException("Error creating type: " + e, e); } }
geom.getDefaultValue()); Collection<PropertyDescriptor> descriptors = new HashSet<>(type.getDescriptors()); descriptors.add(defGeom);
/** * Create the modified feature type. * * @param sourceFeatureType the source feature type * @return the modified feature type * @throws ProcessException errror */ private SimpleFeatureType createTargetFeatureType(FeatureType sourceFeatureType) throws ProcessException { try { SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder(); typeBuilder.setName(sourceFeatureType.getName().getLocalPart()); typeBuilder.setNamespaceURI(sourceFeatureType.getName().getNamespaceURI()); for (PropertyDescriptor attbType : sourceFeatureType.getDescriptors()) { typeBuilder.add((AttributeDescriptor) attbType); } typeBuilder.minOccurs(1).maxOccurs(1).nillable(false).add("lrs_measure", Double.class); typeBuilder.setDefaultGeometry( sourceFeatureType.getGeometryDescriptor().getLocalName()); return typeBuilder.buildFeatureType(); } catch (Exception e) { LOGGER.warning("Error creating type: " + e); throw new ProcessException("Error creating type: " + e, e); } }
typeBuilder.setNamespaceURI(sourceFeatureType.getName().getNamespaceURI()); AttributeDescriptor geomAttbType = sourceFeatureType.getGeometryDescriptor(); for (PropertyDescriptor attbType : sourceFeatureType.getDescriptors()) { if (attbType.equals(geomAttbType)) { typeBuilder.add(geomAttbType.getLocalName(), Point.class);
typeBuilder.setName(sourceFeatureType.getName().getLocalPart()); typeBuilder.setNamespaceURI(sourceFeatureType.getName().getNamespaceURI()); for (PropertyDescriptor attbType : sourceFeatureType.getDescriptors()) { typeBuilder.add((AttributeDescriptor) attbType);
query.setCoordinateSystemReproject(getMapContent().getCoordinateReferenceSystem()); FeatureSource featureSource = getLayer().getFeatureSource(); Collection<PropertyDescriptor> descriptors = featureSource.getSchema().getDescriptors();
for (PropertyDescriptor desc : reader.getFeatureType().getDescriptors()) { assertTrue(i < feature.getAttributeCount()); assertEquals(feature.getAttribute(desc.getName()), feature.getAttribute(i++));
typeName = Types.typeName(GML.NAMESPACE, GML.AbstractFeatureType.getLocalPart()); Assert.assertEquals(typeName, wq_plus_Type.getSuper().getName()); Assert.assertNotNull(wq_plus_Type.getDescriptors()); Assert.assertEquals( 8, ((ComplexFeatureTypeImpl) wq_plus_Type).getTypeDescriptors().size());