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; }
/** * 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; }
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 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() ); } }
@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() ); }
/** * 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() );
private static LinkedList<Operator> findOperators( FeatureType ft, Envelope clickBox ) { LinkedList<Operator> list = new LinkedList<Operator>(); for ( PropertyType pt : ft.getPropertyDeclarations() ) { if ( pt instanceof GeometryPropertyType && ( ( (GeometryPropertyType) pt ).getCoordinateDimension() == DIM_2 || ( (GeometryPropertyType) pt ).getCoordinateDimension() == DIM_2_OR_3 ) ) { list.add( new Intersects( new ValueReference( pt.getName() ), clickBox ) ); } } return list; }
PropertyType prop = it.next(); if ( prop != null ) { QName name = prop.getName(); out.write( SP2 ); if ( !currentVars.contains( "np" ) ) {
this.declaration = declaration; if ( name == null ) { this.name = declaration.getName(); } else { this.name = name;
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 ); int count = ptToCount.get( pt ) == null ? 0 : ptToCount.get( pt ); 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 );
/** * @param pd * @param imports * @param imports * @return */ private Field getFromProperty( CustomPropertyType pd, Map<QName, FeatureClass> featClasses, Set<String> imports ) { String fieldName = createFieldName( createBetterMethodName( pd.getName().getLocalPart() ) ); String fieldType = "java.lang.Object"; if ( pd.isAbstract() ) { Set<Field> possibleSubstitutes = new HashSet<Field>(); PropertyType[] substitutions = pd.getSubstitutions(); if ( substitutions != null ) { for ( PropertyType p : substitutions ) { if ( !p.getName().equals( pd.getName() ) ) { Field f = createFieldFromProperty( p, featClasses, imports ); if ( f != null ) { possibleSubstitutes.add( f ); } else { LOG.warn( "Could not create a field type for the substitution property: " + p.getName() ); } } } } return new Field( fieldName, fieldType, pd.isAbstract(), possibleSubstitutes, pd.getName() ); } return new Field( fieldName, fieldType, pd.isAbstract(), pd.getName() ); }
propNames.add( pt.getName() );
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 ) ); } } }