Package org.geotools.data.complex

Examples of org.geotools.data.complex.FeatureTypeMapping


        Set mappings = AppSchemaDataAccessConfigurator.buildMappings(config);

        assertNotNull(mappings);
        assertEquals(1, mappings.size());
        FeatureTypeMapping mapping = (FeatureTypeMapping) mappings.iterator().next();

        assertEquals(8, mapping.getAttributeMappings().size());
        assertNotNull(mapping.getTargetFeature());
        assertNotNull(mapping.getSource());

        // Map/*<String, Expression>*/idMappings = mapping.getIdMappings();
        // assertEquals(idMappings.get("RoadSegment"), ExpressionBuilder.parse("getId()"));
    }   
View Full Code Here


            Name featureTypeName, CoordinateReferenceSystem reprojection,
            List<PropertyName> selectedProperties, boolean includeMandatory, int resolveDepth, Integer resolveTimeOut) throws IOException {
        JoiningQuery query = new JoiningQuery();
        query.setCoordinateSystemReproject(reprojection);

        FeatureTypeMapping fMapping = AppSchemaDataAccessRegistry.getMappingByName(featureTypeName);

        AttributeMapping mapping = fMapping
                .getAttributeMapping(this.nestedTargetXPath);
        if (mapping == null) {
            throw new IllegalArgumentException("Mapping is missing for: '" + this.nestedTargetXPath
                    + "'!");
        }
        Expression nestedSourceExpression = mapping.getSourceExpression();

        List<JoiningQuery.QueryJoin> joins = new ArrayList<JoiningQuery.QueryJoin>();
        if (instance.baseTableQuery instanceof JoiningQuery) {
            if (((JoiningQuery) instance.baseTableQuery).getQueryJoins() != null) {
                joins.addAll(((JoiningQuery) instance.baseTableQuery).getQueryJoins());
            }
        }

        JoiningQuery.QueryJoin join = new JoiningQuery.QueryJoin();
        join.setForeignKeyName(sourceExpression);
        join.setJoiningKeyName(nestedSourceExpression);
        join.setJoiningTypeName(instance.baseTableQuery.getTypeName());
        join.setDenormalised(fMapping.isDenormalised());
        join.setSortBy(instance.baseTableQuery.getSortBy()); // incorporate order
        // pass on paging from the parent table to the same query within this join
        join.setMaxFeatures(instance.baseTableQuery.getMaxFeatures());
        join.setStartIndex(instance.baseTableQuery.getStartIndex());
        FilterAttributeExtractor extractor = new FilterAttributeExtractor();
View Full Code Here

    }
   
    private List<Object> getValues(Feature feature, NestedAttributeMapping nestedMapping,
            StepList steps) {
        List<Object> values = new ArrayList<Object>();
        FeatureTypeMapping nextFMapping;
        try {
            nextFMapping = nestedMapping.getFeatureTypeMapping(feature);
        } catch (IOException e) {
            nextFMapping = null;
        }
        if (nextFMapping == null) {
            // throw error unless this is polymorphism
            if (nestedMapping.isConditional()) {
                return values;
            }
            throw new UnsupportedOperationException("FeatureTypeMapping not found for " + attPath
                    + ". Please revise PropertyName in your filter!");
        }
        List<Feature> nestedFeatures = new ArrayList<Feature>();
        if (nestedMapping.isSameSource()) {
            // same root/database row, different mappings, used in
            // polymorphism
            nestedFeatures = new ArrayList<Feature>();
            nestedFeatures.add(feature);
        } else {
            // get nested features
            try {
                nestedFeatures = getNestedFeatures(feature, nestedMapping, nextFMapping);
            } catch (IOException e) {
                throw new RuntimeException("Failed evaluating filter expression: '" + attPath
                        + "'. Caused by: " + e.getMessage());
            } catch (IllegalArgumentException e) {
                // might be a polymorphic case where it's looking for an attribute
                // from another type
                // that doesn't match this, but might match another database row
                // so just continue
                return values;
            }
        }

        boolean isClientProperty = isClientProperty(steps);
        StepList newSteps = null;
        if (isClientProperty) {
            // check for client properties for this mapping
            newSteps = steps.subList(0, steps.size() - 1);
            if (newSteps.size() == 1) {
                // special case for client property for this NestedAttributeMapping
                for (Feature f : nestedFeatures) {
                    values.addAll(getClientProperties(nestedMapping, f));
                }
            }
        }       
        // skip element name that is mapped at the next FeatureTypeMapping
        // except when it's a simple content
        // if simple content, then there will be no type name in the xpath, e.g. when gml:name
        // is
        // feature chained the path stays as gml:name.. but if it's a complex type with complex
        // content, e.g. gsml:specification the path will be
        // gsml:specification/gsml:GeologicUnit/<some leaf attribute to filter by>       
        Name nextElementName = nextFMapping.getTargetFeature().getName();
        // starting index for the next search
        int startPos = -1;           
        if (Types.equals(nextElementName, steps.get(0).getName())) {
            // simple contents where nested element name is the same as the nesting element
            startPos = 0;
        } else {
            Step elementNameStep = steps.get(nestedMapping.getTargetXPath().size());
            // support polymorphism
            // check that element type matches the steps
            if (Types.equals(nextElementName, elementNameStep.getName())) {
                startPos = nestedMapping.getTargetXPath().size();
                if (steps.size() > startPos + 1 && !steps.get(startPos + 1).isXmlAttribute()) {
                    // skip next element name for next evaluation
                    // except if the next step is a client property for that element name
                    // since we'd need the AttributeMapping for the client property
                    startPos++;
                }
            }
        }
        if (startPos > -1) {
            newSteps = steps.subList(startPos, steps.size());
            if (!newSteps.isEmpty()) {
                List<NestedAttributeMapping> nestedMappings = nextFMapping.getNestedMappings();
                if (!nestedMappings.isEmpty()) {
                    for (NestedAttributeMapping mapping : nestedMappings) {
                        if (newSteps.startsWith(mapping.getTargetXPath())) {
                            for (Feature f : nestedFeatures) {
                                // loop to this method
                                values.addAll(getValues(f, mapping, newSteps));
                            }
                        }
                    }
                }
                if (isClientProperty) {
                    // check for client properties
                    newSteps = newSteps.subList(0, newSteps.size() - 1);
                }
                boolean isXlinkHref = isClientProperty && isXlinkHref(steps);

                List<AttributeMapping> attMappings = nextFMapping
                        .getAttributeMappingsIgnoreIndex(newSteps);
                for (AttributeMapping attMapping : attMappings) {
                    if (isClientProperty) {
                        if (!(isXlinkHref && attMapping instanceof NestedAttributeMapping)) {
                            // if it's an xlink href,
View Full Code Here

                        || featureSource instanceof JDBCFeatureStore;

                List attMappings = getAttributeMappings(target, dto.getAttributeMappings(), dto
                        .getItemXpath(), crs, isDatabaseBackend);

                FeatureTypeMapping mapping;

                mapping = FeatureTypeMappingFactory.getInstance(featureSource, target, attMappings,
                        namespaces, dto.getItemXpath(), dto.isXmlDataStore(), dto.isDenormalised());

                String mappingName = dto.getMappingName();
                if (mappingName != null) {
                    mapping.setName(Types.degloseName(mappingName, namespaces));
                }
                featureTypeMappings.add(mapping);
            } catch (Exception e) {
                LOGGER.warning("Error creating app-schema data store for '"
                        + (dto.getMappingName() != null ? dto.getMappingName() : dto
View Full Code Here

        attMappings.add(new AttributeMapping(null, strConcat, XPath.steps(targetFeature,
                "concatenated", namespaces)));

        FeatureSource<?,?> simpleSource = mapping.getSource();
        FeatureTypeMapping mapping = new FeatureTypeMapping(simpleSource, targetFeature,
                attMappings, namespaces);
        return mapping;
    }
View Full Code Here

        // For example, create a mapping from the test case simple source to
        // a complex type with an "areaOfInfluence" attribute, which is a buffer
        // over the simple "location" attribute
        // and another which is the concatenation of the attributes "anzlic_no"
        // and "project_no"
        FeatureTypeMapping mapping = createSampleDerivedAttributeMappings();
        targetDescriptor = mapping.getTargetFeature();

        visitor = new UnmappingFilterVisitor(mapping);
        attExp = ff.property("areaOfInfluence");
        List unrolledExpressions = (List) attExp.accept(visitor, null);
View Full Code Here

TOP

Related Classes of org.geotools.data.complex.FeatureTypeMapping

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.