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; }
/** * 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; }
/** * Returns a list of properties of a simple feature type, including all properties from a given * list, and all mandatory (minoccurs > 0) added. * * @param type feature type * @param propNames given list of properties * @return list of properties including all mandatory properties * @throws IOException */ public static List<PropertyName> addMandatoryProperties( SimpleFeatureType type, List<PropertyName> oldProps) { Iterator<PropertyDescriptor> ii = type.getDescriptors().iterator(); List<PropertyName> properties = new ArrayList<PropertyName>(); while (ii.hasNext()) { PropertyDescriptor descr = ii.next(); PropertyName propName = ff.property(descr.getName()); if (oldProps != null && oldProps.contains(propName)) { properties.add(propName); } else if (((descr.getMinOccurs() > 0) && (descr.getMaxOccurs() != 0))) { // mandatory, add it properties.add(propName); } } return properties; }
protected void cleanEmptyElements(Feature target) throws DataSourceException { try { ArrayList values = new ArrayList<Property>(); for (Iterator i = target.getValue().iterator(); i.hasNext(); ) { Property p = (Property) i.next(); if (hasChild(p) || p.getDescriptor().getMinOccurs() > 0 || getEncodeIfEmpty(p)) { values.add(p); } } target.setValue(values); } catch (DataSourceException e) { throw new DataSourceException("Unable to clean empty element", e); } }
int minOccurs = propertyDescriptor.getMinOccurs(); int numberOfProperties = properties.size();
values.add(o); result = true; } else if (((Property) o).getDescriptor().getMinOccurs() > 0) { if (((Property) o).getDescriptor().isNillable()) {
public void init(PropertyDescriptor descriptor) { init(); namespace = descriptor.getName().getNamespaceURI(); name = descriptor.getName().getLocalPart(); minOccurs = descriptor.getMinOccurs(); maxOccurs = descriptor.getMaxOccurs(); if (descriptor instanceof AttributeDescriptor) { AttributeDescriptor attribute = (AttributeDescriptor) descriptor; isNillable = attribute.isNillable(); propertyType = attribute.getType(); } if (descriptor instanceof AssociationDescriptor) { AssociationDescriptor association = (AssociationDescriptor) descriptor; propertyType = association.getType(); } }
Object descr = targetProp.evaluate(targetDescriptor.getType()); if (descr instanceof PropertyDescriptor) { if (((PropertyDescriptor) descr).getMinOccurs() >= 1) { selectedMapping.add(attMapping); selectedProperties.put(attMapping, new ArrayList<PropertyName>());
Object descr = targetProp.evaluate(targetDescriptor.getType()); if (descr instanceof PropertyDescriptor) { if (((PropertyDescriptor) descr).getMinOccurs() >= 1) { addThis = true;
XSDFactory.eINSTANCE.createXSDParticle(); substitutedChildParticle.setMaxOccurs(descriptor.getMaxOccurs()); substitutedChildParticle.setMinOccurs(descriptor.getMinOccurs()); XSDElementDeclaration wrapper = XSDFactory.eINSTANCE.createXSDElementDeclaration(); XSDFactory.eINSTANCE.createXSDParticle(); substitutedChildParticle.setMaxOccurs(descriptor.getMaxOccurs()); substitutedChildParticle.setMinOccurs(descriptor.getMinOccurs()); XSDElementDeclaration wrapper = XSDFactory.eINSTANCE.createXSDElementDeclaration(); XSDFactory.eINSTANCE.createXSDParticle(); substitutedChildParticle.setMaxOccurs(descriptor.getMaxOccurs()); substitutedChildParticle.setMinOccurs(descriptor.getMinOccurs()); XSDElementDeclaration wrapper = XSDFactory.eINSTANCE.createXSDElementDeclaration();
protected void cleanEmptyElements(Feature target) throws DataSourceException { try { ArrayList values = new ArrayList<Property>(); for (Iterator i = target.getValue().iterator(); i.hasNext();) { Property p = (Property) i.next(); if (hasChild(p) || p.getDescriptor().getMinOccurs() > 0 || getEncodeIfEmpty(p)) { values.add(p); } } target.setValue(values); } catch (DataSourceException e) { throw new DataSourceException("Unable to clean empty element", e); } }
private void writeProperty(PropertyDescriptor attr, DataOutput data) throws IOException { writeName(attr.getName(), data); data.writeBoolean(attr.isNillable()); data.writeInt(attr.getMinOccurs()); data.writeInt(attr.getMaxOccurs()); writePropertyType(attr.getType(), data); } }
private void writeProperty(PropertyDescriptor attr, DataOutput data) throws IOException { writeName(attr.getName(), data); data.writeBoolean(attr.isNillable()); data.writeInt(attr.getMinOccurs()); data.writeInt(attr.getMaxOccurs()); writePropertyType(attr.getType(), data); } }
private void writeProperty(PropertyDescriptor attr, DataOutput data) throws IOException { writeName(attr.getName(), data); data.writeBoolean(attr.isNillable()); data.writeInt(attr.getMinOccurs()); data.writeInt(attr.getMaxOccurs()); writePropertyType(attr.getType(), data); } }
private static void writeProperty(PropertyDescriptor attr, DataOutput data) throws IOException { writeName(attr.getName(), data); data.writeBoolean(attr.isNillable()); data.writeInt(attr.getMinOccurs()); data.writeInt(attr.getMaxOccurs()); writePropertyType(attr.getType(), data); }
private static void writeProperty(PropertyDescriptor attr, DataOutput data) throws IOException { writeName(attr.getName(), data); data.writeBoolean(attr.isNillable()); data.writeInt(attr.getMinOccurs()); data.writeInt(attr.getMaxOccurs()); writePropertyType(attr.getType(), data); }
public void init(PropertyDescriptor descriptor) { init(); namespace = descriptor.getName().getNamespaceURI(); name = descriptor.getName().getLocalPart(); minOccurs = descriptor.getMinOccurs(); maxOccurs = descriptor.getMaxOccurs(); if (descriptor instanceof AttributeDescriptor) { AttributeDescriptor attribute = (AttributeDescriptor) descriptor; isNillable = attribute.isNillable(); propertyType = attribute.getType(); } if (descriptor instanceof AssociationDescriptor) { AssociationDescriptor association = (AssociationDescriptor) descriptor; propertyType = association.getType(); } }
private void printAttributeDescriptor(Writer w, PropertyDescriptor attrib) throws IOException { print(w, attrib.getName().toString()); print(w, "\t"); print(w, FieldType.forBinding(attrib.getType().getBinding()).name()); print(w, "\t"); print(w, Integer.toString(attrib.getMinOccurs())); print(w, "\t"); print(w, Integer.toString(attrib.getMaxOccurs())); print(w, "\t"); print(w, Boolean.toString(attrib.isNillable())); PropertyType attrType = attrib.getType(); if (attrType instanceof GeometryType) { GeometryType gt = (GeometryType) attrType; CoordinateReferenceSystem crs = gt.getCoordinateReferenceSystem(); String crsText = CrsTextSerializer.serialize(crs); print(w, "\t"); println(w, crsText); } else { println(w, ""); } }
private void printAttributeDescriptor(Writer w, PropertyDescriptor attrib) throws IOException { print(w, attrib.getName().toString()); print(w, "\t"); print(w, FieldType.forBinding(attrib.getType().getBinding()).name()); print(w, "\t"); print(w, Integer.toString(attrib.getMinOccurs())); print(w, "\t"); print(w, Integer.toString(attrib.getMaxOccurs())); print(w, "\t"); print(w, Boolean.toString(attrib.isNillable())); PropertyType attrType = attrib.getType(); if (attrType instanceof GeometryType) { GeometryType gt = (GeometryType) attrType; CoordinateReferenceSystem crs = gt.getCoordinateReferenceSystem(); String crsText = CrsTextSerializer.serialize(crs); print(w, "\t"); println(w, crsText); } else { println(w, ""); } }
@Override public void funnel(PropertyDescriptor descriptor, PrimitiveSink into) { NameFunnel.funnel(descriptor.getName(), into); PropertyType attrType = descriptor.getType(); NameFunnel.funnel(attrType.getName(), into); FieldType type = FieldType.forBinding(attrType.getBinding()); into.putInt(type.getTag()); into.putBoolean(descriptor.isNillable()); into.putInt(descriptor.getMaxOccurs()); into.putInt(descriptor.getMinOccurs()); if (descriptor instanceof GeometryDescriptor) { CoordinateReferenceSystem crs; crs = ((GeometryDescriptor) descriptor).getCoordinateReferenceSystem(); String srsName; if (crs == null) { srsName = RevObjects.NULL_CRS_IDENTIFIER; } else { srsName = CRS.toSRS(crs); } NullableStringFunnel.funnel(srsName, into); } } };