public String prefixedName() { return delegate.prefixedName(); }
private Set<Integer> getPropertyNameTypeIndexes(Set<String> filterPrefixes) { Set<Integer> nameTypes = new HashSet<>(); for (String prefix : filterPrefixes) { int aliasIdx = aliases.indexOf(prefix); if (aliasIdx >= 0) { nameTypes.add(aliasIdx); } else { for (int i = 0; i < featureTypes.size(); i++) { FeatureTypeInfo ft = featureTypes.get(i); if (prefix.equals(ft.prefixedName()) || prefix.equals(ft.getName())) { nameTypes.add(i); break; } } } } return nameTypes; }
public JoinExtractingVisitor(List<FeatureTypeInfo> featureTypes, List<String> aliases) { this.primaryFeatureType = null; this.featureTypes = new ArrayList<>(featureTypes); if (aliases == null || aliases.isEmpty()) { hadAliases = false; // assign prefixes aliases = new ArrayList<String>(); for (int j = 0, i = 0; i < featureTypes.size(); i++) { String alias; boolean conflictFound; do { conflictFound = false; alias = String.valueOf((char) ('a' + (j++))); for (FeatureTypeInfo ft : featureTypes) { if (alias.equals(ft.getName()) || alias.equals(ft.prefixedName())) { conflictFound = true; break; } } } while (conflictFound); aliases.add(alias); } } else { hadAliases = true; } this.aliases = new ArrayList(aliases); }
/** * Builds a map going from alias, prefixed type name and simple type name to FeatureTypeInfo. In * case of conflicts aliases will override the type names */ private Map<String, FeatureTypeInfo> buildTypeMap() { Map<String, FeatureTypeInfo> typeMap = new HashMap<>(); typeMap.put(primaryFeatureType.prefixedName(), primaryFeatureType); typeMap.put(primaryFeatureType.getName(), primaryFeatureType); typeMap.put(primaryAlias, primaryFeatureType); for (int i = 0; i < aliases.size(); i++) { String alias = aliases.get(i); FeatureTypeInfo ft = featureTypes.get(i); typeMap.put(ft.getName(), ft); typeMap.put(ft.prefixedName(), ft); String localTypeName = getLocalTypeName(ft); if (localTypeName != null) { typeMap.put(localTypeName, ft); } typeMap.put(alias, ft); } return typeMap; }
/** Builds a map going from type name, qualified or unqualified, to alias */ private Map<String, String> buildNameToAlias() { Map<String, String> nameToAlias = new HashMap<>(); nameToAlias.put(primaryFeatureType.prefixedName(), primaryAlias); nameToAlias.put(primaryFeatureType.getName(), primaryAlias); String localTypeName = getLocalTypeName(primaryFeatureType); if (localTypeName != null) { nameToAlias.put(localTypeName, primaryAlias); } for (int i = 0; i < aliases.size(); i++) { String alias = aliases.get(i); FeatureTypeInfo ft = featureTypes.get(i); nameToAlias.put(ft.getName(), alias); nameToAlias.put(ft.prefixedName(), alias); localTypeName = getLocalTypeName(ft); if (localTypeName != null) { nameToAlias.put(localTypeName, alias); } } return nameToAlias; }
/** Returns the feature source for the given feature type */ FeatureSource getFeatureSource(FeatureTypeInfo typeInfo) { // grab the feature source FeatureSource source = null; try { source = typeInfo.getFeatureSource(null, GeoTools.getDefaultHints()); } catch (IOException e) { throw new ServiceException( "Could not get the feauture source to list time info for layer " + typeInfo.prefixedName(), e); } return source; }
@Override public Object findTemplateSource(String path) throws IOException { String templatePath = "empty.ftl"; if (path.toLowerCase().contains("content") && (this.resource != null) && this.resource .prefixedName() .equals(featureType2.prefixedName())) { templatePath = "test_content.ftl"; } try { return new File( this.getClass() .getResource(templateFolder + templatePath) .toURI()); } catch (URISyntaxException e) { return null; } } };
List<Filter> rewriteAndSortOtherFilters(List<Filter> filters) { String primaryName = primaryFeatureType.prefixedName(); Map<String, FeatureTypeInfo> typeMap = buildTypeMap(); Map<String, String> nameToAlias = buildNameToAlias();
public Object visit(PropertyName name, Object data) { // case of multiple geometries being returned if (name.evaluate(featureType) == null && !isGmlBoundedBy(name)) { throw new WFSException( request, "Illegal property name: " + name.getPropertyName() + " for feature type " + meta.prefixedName(), "InvalidParameterValue"); } return name; } };
void validateSortBy(List<SortBy> sortBys, FeatureTypeInfo meta, final GetFeatureRequest request) throws IOException { FeatureType featureType = meta.getFeatureType(); for (SortBy sortBy : sortBys) { PropertyName name = sortBy.getPropertyName(); if (name.evaluate(featureType) == null) { throw new WFSException( request, "Illegal property name: " + name.getPropertyName() + " for feature type " + meta.prefixedName(), "InvalidParameterValue"); } } }
@Before public void setup() { lakes = createNiceMock(FeatureTypeInfo.class); expect(lakes.prefixedName()).andReturn("gs:Lakes").anyTimes(); expect(lakes.getNativeName()).andReturn("Lakes").anyTimes(); expect(lakes.getName()).andReturn("Lakes").anyTimes(); forests = createNiceMock(FeatureTypeInfo.class); expect(forests.prefixedName()).andReturn("gs:Forests").anyTimes(); expect(forests.getNativeName()).andReturn("Forests").anyTimes(); expect(forests.getName()).andReturn("Forests").anyTimes(); buildings = createNiceMock(FeatureTypeInfo.class); expect(buildings.prefixedName()).andReturn("gs:Buildings").anyTimes(); expect(buildings.getNativeName()).andReturn("Buildings").anyTimes(); expect(buildings.getName()).andReturn("Buildings").anyTimes(); replay(lakes, forests, buildings); }
@Test public void testTypeNames() throws Exception { // filter on an existing namespace Document doc = getAsDOM("wfs?service=WFS&version=1.1.0&request=getCapabilities"); Element e = doc.getDocumentElement(); assertEquals("WFS_Capabilities", e.getLocalName()); final List<FeatureTypeInfo> enabledTypes = getCatalog().getFeatureTypes(); for (Iterator<FeatureTypeInfo> it = enabledTypes.iterator(); it.hasNext(); ) { FeatureTypeInfo ft = it.next(); if (ft.enabled()) { String prefixedName = ft.prefixedName(); String xpathExpr = "/wfs:WFS_Capabilities/wfs:FeatureTypeList/" + "wfs:FeatureType/wfs:Name[text()=\"" + prefixedName + "\"]"; XMLAssert.assertXpathExists(xpathExpr, doc); } } }
@Override public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) { FeatureTypeInfo ft = (FeatureTypeInfo) source; writer.startNode("name"); writer.setValue(ft.prefixedName()); writer.endNode(); StoreInfo store = ft.getStore(); WorkspaceInfo ws = store.getWorkspace(); encodeLink( "/workspaces/" + encode(ws.getName()) + "/datastores/" + encode(store.getName()) + "/featuretypes/" + encode(ft.getName()), writer, getFormatGet()); }
private FeatureCollection<?, ?> getDimensionCollection( FeatureTypeInfo typeInfo, DimensionInfo dimension) throws IOException { // grab the feature source FeatureSource<?, ?> source = null; try { source = typeInfo.getFeatureSource(null, GeoTools.getDefaultHints()); } catch (IOException e) { throw new ServiceException( "Could not get the feauture source to list time info for layer " + typeInfo.prefixedName(), e); } // build query to grab the dimension values final Query dimQuery = new Query(source.getSchema().getName().getLocalPart()); dimQuery.setPropertyNames(Arrays.asList(dimension.getAttribute())); return source.getFeatures(dimQuery); } }
if (time == null || !time.isEnabled()) { throw new ServiceException( "Layer " + typeInfo.prefixedName() + " does not have time support enabled");
kvp.put("LAYERS", featureType.prefixedName()); kvp.put("FORMAT", "application/openlayers"); this.mapPreviewURL =
protected Object visit(BinarySpatialOperator filter, Object data) { PropertyName name = null; if (filter.getExpression1() instanceof PropertyName) { name = (PropertyName) filter.getExpression1(); } else if (filter.getExpression2() instanceof PropertyName) { name = (PropertyName) filter.getExpression2(); } if (name != null) { // check against feataure type to make sure its // a geometric type AttributeDescriptor att = (AttributeDescriptor) name.evaluate(featureType); if (!(att instanceof GeometryDescriptor) && !isGmlBoundedBy(name)) { throw new WFSException( request, "Property " + name + " is not geometric in feature type " + meta.prefixedName(), "InvalidParameterValue"); } } return filter; } };
FeatureTypeInfo ft = it.next(); if (ft.enabled()) { String prefixedName = ft.prefixedName();
FeatureTypeInfo ft = it.next(); if (ft.enabled()) { String prefixedName = ft.prefixedName();
throw new ServiceException( "Layer " + typeInfo.prefixedName() + " does not have " + dimensionName