|
34 | 34 | ----------------------------------------------------------------------------*/
|
35 | 35 | package org.deegree.feature.persistence.sql;
|
36 | 36 |
|
37 |
| -import java.util.ArrayList; |
38 |
| -import java.util.Collection; |
39 |
| -import java.util.List; |
40 |
| - |
41 |
| -import javax.xml.namespace.QName; |
42 |
| - |
43 | 37 | import org.deegree.commons.utils.QNameUtils;
|
44 | 38 | import org.deegree.feature.persistence.sql.xpath.MappableNameStep;
|
45 | 39 | import org.deegree.feature.persistence.sql.xpath.MappableStep;
|
|
50 | 44 | import org.deegree.sqldialect.filter.PropertyNameMapping;
|
51 | 45 | import org.deegree.sqldialect.filter.TableAliasManager;
|
52 | 46 | import org.deegree.sqldialect.filter.UnmappableException;
|
| 47 | +import org.slf4j.Logger; |
| 48 | +import org.slf4j.LoggerFactory; |
| 49 | + |
| 50 | +import javax.xml.namespace.QName; |
| 51 | +import java.util.ArrayList; |
| 52 | +import java.util.Collection; |
| 53 | +import java.util.List; |
53 | 54 |
|
54 | 55 | /**
|
55 | 56 | * {@link PropertyNameMapper} for the {@link SQLFeatureStore}.
|
|
58 | 59 | */
|
59 | 60 | public class SQLPropertyNameMapper implements PropertyNameMapper {
|
60 | 61 |
|
| 62 | + private static final Logger LOG = LoggerFactory.getLogger(SQLPropertyNameMapper.class); |
| 63 | + |
61 | 64 | private final SQLFeatureStore fs;
|
62 | 65 |
|
63 | 66 | private final FeatureTypeMapping ftMapping;
|
@@ -103,23 +106,36 @@ else if (ftMapping == null && (ftMappings != null && ftMappings.size() > 1)) {
|
103 | 106 | @Override
|
104 | 107 | public PropertyNameMapping getMapping(ValueReference propName, TableAliasManager aliasManager)
|
105 | 108 | throws FilterEvaluationException, UnmappableException {
|
106 |
| - if (ftMapping != null || propName == null || propName.getAsText().isEmpty()) |
107 |
| - return new MappedXPath(fs, ftMapping, propName, aliasManager, false, handleStrict).getPropertyNameMapping(); |
| 109 | + if (ftMapping != null || propName == null || propName.getAsText().isEmpty()) { |
| 110 | + List<PropertyNameMapping> propertyNameMappings = new MappedXPath(fs, ftMapping, propName, aliasManager, |
| 111 | + false, handleStrict) |
| 112 | + .getPropertyNameMappings(); |
| 113 | + if (propertyNameMappings.isEmpty()) |
| 114 | + return null; |
| 115 | + else if (propertyNameMappings.size() > 1) |
| 116 | + LOG.warn("Multiple non-spatial mappings are currently not supported!"); |
| 117 | + return propertyNameMappings.get(0); |
| 118 | + } |
108 | 119 | FeatureTypeMapping correspondingFtMapping = findCorrespondingMapping(propName);
|
109 |
| - return new MappedXPath(fs, correspondingFtMapping, propName, aliasManager, false, handleStrict) |
110 |
| - .getPropertyNameMapping(); |
| 120 | + List<PropertyNameMapping> propertyNameMappings = new MappedXPath(fs, correspondingFtMapping, propName, |
| 121 | + aliasManager, false, handleStrict) |
| 122 | + .getPropertyNameMappings(); |
| 123 | + if (propertyNameMappings.isEmpty()) |
| 124 | + return null; |
| 125 | + else if (propertyNameMappings.size() > 1) |
| 126 | + LOG.warn("Multiple non-spatial mappings are currently not supported!"); |
| 127 | + return propertyNameMappings.get(0); |
111 | 128 |
|
112 | 129 | }
|
113 | 130 |
|
114 | 131 | @Override
|
115 |
| - public PropertyNameMapping getSpatialMapping(ValueReference propName, TableAliasManager aliasManager) |
116 |
| - throws FilterEvaluationException, UnmappableException { |
117 |
| - |
| 132 | + public List<PropertyNameMapping> getSpatialMappings(ValueReference propName, TableAliasManager aliasManager) |
| 133 | + throws UnmappableException { |
118 | 134 | if (ftMapping != null || propName == null || propName.getAsText().isEmpty())
|
119 |
| - return new MappedXPath(fs, ftMapping, propName, aliasManager, true, handleStrict).getPropertyNameMapping(); |
120 |
| - FeatureTypeMapping correspondingFtMapping = findCorrespondingMapping(propName); |
| 135 | + return new MappedXPath(fs, ftMapping, propName, aliasManager, true, handleStrict).getPropertyNameMappings(); |
| 136 | + FeatureTypeMapping correspondingFtMapping = ftMapping != null ? ftMapping : findCorrespondingMapping(propName); |
121 | 137 | return new MappedXPath(fs, correspondingFtMapping, propName, aliasManager, true, handleStrict)
|
122 |
| - .getPropertyNameMapping(); |
| 138 | + .getPropertyNameMappings(); |
123 | 139 | }
|
124 | 140 |
|
125 | 141 | private FeatureTypeMapping findCorrespondingMapping(ValueReference propName) throws UnmappableException {
|
|
0 commit comments