Revision 45715
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.impl/src/main/java/org/gvsig/fmap/dal/swing/impl/searchPostProcess/distinctOn/DistinctOn.java | ||
---|---|---|
93 | 93 |
ft_inputStoreNoContainer.addAll(ft_inputStore); |
94 | 94 |
for (FeatureAttributeDescriptor attr : ft_inputStore) { |
95 | 95 |
DataType dataType = attr.getDataType(); |
96 |
EditableFeatureAttributeDescriptor eattr = ft_inputStoreNoContainer.getEditableAttributeDescriptor(attr.getName()); |
|
96 | 97 |
if (dataType.isContainer()){ |
97 | 98 |
ft_inputStoreNoContainer.remove(attr.getName()); |
98 | 99 |
} |
100 |
if (eattr.isComputed()){ |
|
101 |
eattr.setFeatureAttributeEmulator((FeatureAttributeEmulator) null); |
|
102 |
} |
|
103 |
if (eattr.isPrimaryKey()){ |
|
104 |
eattr.setIsPrimaryKey(false); |
|
105 |
} |
|
106 |
if (eattr.allowIndexDuplicateds()){ |
|
107 |
eattr.setAllowIndexDuplicateds(true); |
|
108 |
} |
|
99 | 109 |
} |
100 |
if (query.getExtraColumn().size()>0) { |
|
101 |
FeatureExtraColumns extraColumns = query.getExtraColumn(); |
|
102 |
for (int i = 0; i < extraColumns.size(); i++) { |
|
103 |
DataType dataType = extraColumns.get(i).getDataType(); |
|
110 |
Map<String, EditableFeatureAttributeDescriptor> allExtraColumns = new HashMap<>(); |
|
111 |
for (EditableFeatureAttributeDescriptor column : ft_inputStore.getExtraColumns().getColumns()) { |
|
112 |
allExtraColumns.put(column.getName(), column); |
|
113 |
} |
|
114 |
for (EditableFeatureAttributeDescriptor column : query.getExtraColumn().getColumns()) { |
|
115 |
allExtraColumns.put(column.getName(), column); |
|
116 |
} |
|
117 |
if (allExtraColumns.size()>0) { |
|
118 |
for (EditableFeatureAttributeDescriptor column : allExtraColumns.values()) { |
|
119 |
DataType dataType = column.getDataType(); |
|
104 | 120 |
if (!dataType.isContainer()){ |
105 |
ft_inputStoreNoContainer.add(extraColumns.get(i).getName(), extraColumns.get(i).getType(), extraColumns.get(i).getSize());
|
|
121 |
ft_inputStoreNoContainer.add(column.getName(), column.getType(), column.getSize());
|
|
106 | 122 |
} |
107 | 123 |
} |
108 | 124 |
} |
109 |
EditableFeatureType ft_outputStore = dataManager.createFeatureType(); |
|
110 |
ft_outputStore.addAll(ft_inputStoreNoContainer); |
|
111 |
for (FeatureAttributeDescriptor attr : ft_outputStore) { |
|
112 |
if(attr.isComputed()){ |
|
113 |
((DefaultFeatureAttributeDescriptor) attr).setFeatureAttributeEmulator((FeatureAttributeEmulator) null); |
|
114 |
} |
|
115 |
} |
|
116 |
parametersResults.setDefaultFeatureType(ft_outputStore); |
|
117 | 125 |
|
126 |
parametersResults.setDefaultFeatureType(ft_inputStoreNoContainer); |
|
127 |
|
|
118 | 128 |
serverExplorer.add("H2Spatial", parametersResults, true); |
119 | 129 |
|
120 | 130 |
|
... | ... | |
151 | 161 |
for (Feature feature : features) { |
152 | 162 |
if (lastFeature == null){ |
153 | 163 |
lastFeature=storeResults.createNewFeature(feature); |
154 |
for (AggregateOperation aggregate : aggregates.values()) { |
|
155 |
aggregate.reset(); |
|
156 |
} |
|
157 |
} |
|
158 |
if ( Objects.equals(feature.get(uniqueFieldName), lastFeature.get(uniqueFieldName))){ |
|
159 | 164 |
for (Map.Entry<String, AggregateOperation> entry : aggregates.entrySet()) { |
160 | 165 |
String name = entry.getKey(); |
161 | 166 |
AggregateOperation operation = entry.getValue(); |
167 |
operation.reset(); |
|
162 | 168 |
Object value = feature.get(name); |
163 | 169 |
if (operation.isApplicable(value)){ |
164 | 170 |
operation.perform(value); |
165 | 171 |
} |
166 | 172 |
lastFeature.set(name, operation.getValue()); |
167 | 173 |
} |
168 |
}else{ |
|
169 |
storeResults.insert(lastFeature); |
|
170 |
lastFeature = storeResults.createNewFeature(feature); |
|
174 |
} |
|
175 |
if ( Objects.equals(feature.get(uniqueFieldName), lastFeature.get(uniqueFieldName))){ |
|
171 | 176 |
for (Map.Entry<String, AggregateOperation> entry : aggregates.entrySet()) { |
172 | 177 |
String name = entry.getKey(); |
173 | 178 |
AggregateOperation operation = entry.getValue(); |
174 |
operation.reset(); |
|
175 | 179 |
Object value = feature.get(name); |
176 | 180 |
if (operation.isApplicable(value)){ |
177 | 181 |
operation.perform(value); |
178 | 182 |
} |
179 | 183 |
lastFeature.set(name, operation.getValue()); |
180 | 184 |
} |
185 |
}else{ |
|
186 |
storeResults.insert(lastFeature); |
|
187 |
lastFeature = null; |
|
181 | 188 |
} |
182 | 189 |
} |
183 | 190 |
|
Also available in: Unified diff