public GenericProperty( PropertyType declaration, QName name, TypedObjectNode value, Map<QName, PrimitiveValue> attrs, List<TypedObjectNode> children, XSElementDeclaration xsType ) { this.declaration = declaration; if ( name == null ) { this.name = declaration.getName(); } else { this.name = name; } this.attrs = attrs; this.children = children; this.xsType = xsType; }
private static void printFt( FeatureType ft, Set<String> ftNames, Set<String> propNames ) { System.out.println( "\n - feature type '" + ft.getName() + "'" + ( ft.isAbstract() ? " (abstract)" : "" ) ); ftNames.add( ft.getName().getLocalPart() ); for ( PropertyType pt : ft.getPropertyDeclarations() ) { propNames.add( pt.getName().getLocalPart() ); String ptName = pt.getName().getNamespaceURI().equals( ft.getName().getNamespaceURI() ) ? pt.getName().getLocalPart() : pt.getName().toString(); System.out.println( " - '" + ptName + "', minOccurs=" + pt.getMinOccurs() + ", maxOccurs=" + pt.getMaxOccurs() + ", type: " + pt.getClass().getSimpleName() ); } }
private static String createPropertyTypeInstance( Writer out, PropertyType prop, Set<String> currentVars, int level ) throws IOException { int min = prop.getMinOccurs(); int max = prop.getMaxOccurs(); List<PropertyType> subs = Arrays.asList( prop.getSubstitutions() ); StringBuilder propTypeInstance = new StringBuilder( "new " ); propTypeInstance.append( prop.getClass().getSimpleName() ).append( "( " ); String name = "np"; if ( level > 0 ) { QName pN = prop.getName(); name = "new " + QNAME + "( \"" + pN.getNamespaceURI() + "\", \"" + pN.getLocalPart() + "\" )"; propTypeInstance.append( prop.isAbstract() ).append( ", " ); LOG.warn( "Ignore import for property type: " + prop.getName() );
public final PropertyType findConcretePropertyType( final QName elemName, final PropertyType pt ) { // LOG.debug( "Checking if '" + elemName + "' is a valid substitution for '" + pt.getName() + "'" ); for ( final PropertyType substitutionPt : pt.getSubstitutions() ) { // TODO !substitutionPt.isAbstract() if ( elemName.equals( substitutionPt.getName() ) ) { // LOG.debug( "Yep. Substitutable for '" + substitutionPt.getName() + "'" ); return substitutionPt; } } // LOG.debug( "Nope." ); return null; }
private void export( XMLStreamWriter writer, PropertyType pt ) throws XMLStreamException { LOG.debug( "Exporting property type " + pt.getName() ); boolean byRef = !pt.getName().getNamespaceURI().equals( targetNs ); writer.writeAttribute( "ref", getPrefixedName( pt.getName() ) ); } else { writer.writeStartElement( "element" ); writer.writeAttribute( "name", pt.getName().getLocalPart() ); if ( pt.getMinOccurs() != 1 ) { writer.writeAttribute( "minOccurs", "" + pt.getMinOccurs() ); if ( pt.getMaxOccurs() != 1 ) { if ( pt.getMaxOccurs() == -1 ) { writer.writeAttribute( "maxOccurs", "unbounded" ); } else { writer.writeAttribute( "maxOccurs", "" + pt.getMaxOccurs() ); if ( pt.isNillable() ) { writer.writeAttribute( "nillable", "true" );
private List<Mapping> generatePropMapping( PropertyType pt, MappingContext mc ) { LOG.debug( "Mapping property '" + pt.getName() + "'" ); XSElementDeclaration elDecl = pt.getElementDecl(); if ( pt.getMaxOccurs() == 1 ) { propMc = mcManager.mapOneToOneElement( mc, eName ); } else { mappings.clear(); } else { mappings.add( new CompoundMapping( path, pt.getMinOccurs() == 0, particles, jc, elDecl ) ); LOG.warn( "Unable to create relational mapping for property type '" + pt.getName() + "': " + t.getMessage() ); mappings.add( generatePropMapping( (CodePropertyType) pt, mc ) ); } else { LOG.warn( "Unhandled property type '" + pt.getName() + "': " + pt.getClass().getName() ); LOG.warn( "Unable to create relational mapping for property type '" + pt.getName() + "': " + t.getMessage() ); LOG.debug( "Mapping complexity index of property type '" + pt.getName() + "': " + complexity ); if ( complexity > MAX_COMPLEXITY_INDEX ) { LOG.warn( "Mapping property type '" + pt.getName() + "' exceeds complexity limit: " + complexity ); mappings.clear();
private void addProperties( List<Property> props, PropertyType pt, Mapping propMapping, ResultSet rs, String idPrefix ) throws SQLException { List<TypedObjectNode> particles = buildParticles( propMapping, rs, qualifiedSqlExprToRsIdx, idPrefix ); if ( particles.isEmpty() && pt.getMinOccurs() > 0 ) { if ( pt.isNillable() ) { Map<QName, PrimitiveValue> attrs = Collections.singletonMap( new QName( CommonNamespaces.XSINS, "nil" ), new PrimitiveValue( Boolean.TRUE ) ); props.add( new GenericProperty( pt, propMapping.getPath().getAsQName(), null, attrs, Collections.<TypedObjectNode> emptyList() ) ); } else { LOG.warn( "Unable to map NULL value for mapping '" + propMapping.getPath().getAsText() + "' to output. This will result in schema violations." ); } } for ( final TypedObjectNode particle : particles ) { if ( particle instanceof GenericXMLElement ) { if ( pt instanceof ObjectPropertyType && TIME_OBJECT.equals( ( (ObjectPropertyType) pt ).getCategory() ) ) { props.add( recreatePropertyFromGml( pt, (GenericXMLElement) particle ) ); } else { GenericXMLElement xmlEl = (GenericXMLElement) particle; props.add( new GenericProperty( pt, xmlEl.getName(), null, xmlEl.getAttributes(), xmlEl.getChildren() ) ); } } else { props.add( new GenericProperty( pt, pt.getName(), particle ) ); } } }
if ( value == null ) { if ( current - 1 < pt.getMinOccurs() ) { String msg = "Cannot remove property '" + propName + "' from feature '" + getName() + ": property must be present at least " + pt.getMinOccurs() + " time(s)."; throw new IllegalArgumentException( msg );
if ( pt.getMinOccurs() == 0 ) { LOG.debug( "Optional property '" + propName + "', checking if it is requested." ); if ( !isPropertyRequested( propName ) ) {
/** * Creates a new {@link GenericGMLObjectType} instance. * * @param category * GML object category, must not be <code>null</code> * @param name * qualified element name, must not be <code>null</code> * @param propDecls * property declarations, may be empty or <code>null</code> * @param isAbstract * <code>true</code>, if this object type declaration is abstract, <code>false</code> otherwise */ public GenericGMLObjectType( GMLObjectCategory category, QName name, List<PropertyType> propDecls, boolean isAbstract ) { this.category = category; this.name = name; for ( PropertyType propDecl : propDecls ) { propNameToDecl.put( propDecl.getName(), propDecl ); } this.isAbstract = isAbstract; }
Geometry geom = (Geometry) prop.getValue(); if ( geom != null ) { Property current = feature.getProperties( prop.getType().getName() ).get( 0 ); Geometry currentGeom = current != null ? ( (Geometry) current.getValue() ) : null; String msg = "Cannot replace given geometry property '" + prop.getType().getName() + "' with given value (wrong dimension)."; throw new InvalidParameterValueException( msg ); if ( !( geom instanceof Surface ) && prop.getType().getName().equals( qname ) ) { String msg = "Cannot replace given geometry property '" + prop.getType().getName() + "' with given value (wrong type)."; throw new InvalidParameterValueException( msg ); if ( count < pt.getMinOccurs() ) { String msg = "Update would result in invalid feature: property '" + pt.getName() + "' must be present at least " + pt.getMinOccurs() + " time(s)."; throw new InvalidParameterValueException( msg ); } else if ( pt.getMaxOccurs() != -1 && count > pt.getMaxOccurs() ) { String msg = "Update would result in invalid feature: property '" + pt.getName() + "' must be present no more than " + pt.getMaxOccurs() + " time(s)."; throw new InvalidParameterValueException( msg );
@Override public List<PropertyType> getNewPropertyDecls( FeatureType ft ) { List<PropertyType> propDecls = ft.getPropertyDeclarations(); FeatureType parentFt = getParent( ft ); int firstNewIdx = 0; if ( parentFt != null ) { for ( PropertyType parentPropDecl : parentFt.getPropertyDeclarations() ) { if ( parentPropDecl.getName().equals( propDecls.get( firstNewIdx ).getName() ) ) { firstNewIdx++; } else { throw new RuntimeException( "Content model of feature type '" + ft.getName() + "' is not compatible with parent type '" + parentFt.getName() + "'." ); } } } // TODO integrate handling of gml:featureMember properly for ( int i = firstNewIdx; i < propDecls.size(); i++ ) { if ( "featureMember".equals( propDecls.get( firstNewIdx ).getName().getLocalPart() ) ) { firstNewIdx++; } else if ( "featureMembers".equals( propDecls.get( firstNewIdx ).getName().getLocalPart() ) ) { firstNewIdx++; } } return propDecls.subList( firstNewIdx, propDecls.size() ); }
if ( activeDecl.getMaxOccurs() != -1 && propOccurences > activeDecl.getMaxOccurs() ) { String msg = Messages.getMessage( "ERROR_PROPERTY_TOO_MANY_OCCURENCES", propName, activeDecl.getMaxOccurs(), ft.getName() ); throw new XMLParsingException( xmlStream, msg ); if ( propOccurences < activeDecl.getMinOccurs() ) { String msg = null; if ( activeDecl.getMinOccurs() == 1 ) { msg = Messages.getMessage( "ERROR_PROPERTY_MANDATORY", activeDecl.getName(), ft.getName() ); } else { msg = Messages.getMessage( "ERROR_PROPERTY_TOO_FEW_OCCURENCES", activeDecl.getName(), activeDecl.getMinOccurs(), ft.getName() ); if ( BOUNDED_BY_GML31.equals( activeDecl.getName() ) || BOUNDED_BY_GML32.equals( activeDecl.getName() ) ) { Envelope bbox = (Envelope) property.getValue(); if ( bbox.getCoordinateSystem() != null ) {
if ( activeDecl.getMaxOccurs() != -1 && propOccurences > activeDecl.getMaxOccurs() ) { String msg = Messages.getMessage( "ERROR_PROPERTY_TOO_MANY_OCCURENCES", propName, activeDecl.getMaxOccurs(), type.getName() ); throw new XMLParsingException( xmlStream, msg ); if ( !gmlStreamReader.getLaxMode() && propOccurences < activeDecl.getMinOccurs() ) { String msg = null; if ( activeDecl.getMinOccurs() == 1 ) { msg = Messages.getMessage( "ERROR_PROPERTY_MANDATORY", activeDecl.getName(), type.getName() ); } else { msg = Messages.getMessage( "ERROR_PROPERTY_TOO_FEW_OCCURENCES", activeDecl.getName(), activeDecl.getMinOccurs(), type.getName() ); if ( BOUNDED_BY_GML31.equals( activeDecl.getName() ) || BOUNDED_BY_GML32.equals( activeDecl.getName() ) ) { Envelope bbox = (Envelope) property.getValue(); if ( bbox != null && bbox.getCoordinateSystem() != null ) {
/** * Collects all property names of a given feature type, or all feature types if the given name is null. * * @param schema * @param featureType * @return a set of property qnames */ public static Set<QName> collectProperyNames( AppSchema schema, QName featureType ) { HashSet<QName> set = new HashSet<QName>(); for ( FeatureType ft : schema.getFeatureTypes() ) { if ( featureType == null || featureType.equals( ft.getName() ) ) { for ( PropertyType pt : ft.getPropertyDeclarations() ) { set.add( pt.getName() ); } } } return set; }
/** * @param root * @throws IOException */ private static void addNode( BufferedWriter out, FeatureType ft ) throws IOException { if ( ft != null ) { String dotName = dotName( ft ); List<String> attributes = createAttributes( ft ); List<PropertyType> pd = ft.getPropertyDeclarations(); StringBuilder sb = new StringBuilder( "tooltip=\"" ); if ( pd != null && !pd.isEmpty() ) { Iterator<PropertyType> it = pd.iterator(); while ( it.hasNext() ) { sb.append( dotName( it.next().getName() ) ); if ( it.hasNext() ) { sb.append( ",<br/>" ); } } } sb.append( "\"" ); attributes.add( sb.toString() ); GraphvizDot.writeVertex( dotName, attributes, out ); } }
for ( PropertyType pt : featureType.getPropertyDeclarations() ) { if ( pt instanceof GeometryPropertyType ) { byte[] bs = rs.getBytes( pt.getName().getLocalPart() ); if ( bs != null ) { try { Object obj = rs.getObject( pt.getName().getLocalPart() ); if ( obj != null ) { SimplePropertyType spt = (SimplePropertyType) pt;
break; String field = pt.getName().getLocalPart().toLowerCase(); fields.add( field ); create.append( field + " " + sqlType );
return getFromProperty( (StringOrRefPropertyType) pd ); } else { LOG.warn( "Ignore import for property type: " + pd.getName() );