Revision 37681
tags/v_2_0_0_Build_2043/extensions/extDalTransformJoin/extDalTransformJoin/src/org/gvsig/app/join/RemoveTableUnion.java | ||
---|---|---|
1 |
package org.gvsig.app.join; |
|
2 |
|
|
3 |
import org.gvsig.andami.PluginServices; |
|
4 |
import org.gvsig.andami.plugins.Extension; |
|
5 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
6 |
import org.gvsig.app.join.dal.feature.JoinTransform; |
|
7 |
import org.gvsig.app.project.documents.table.TableDocument; |
|
8 |
import org.gvsig.app.project.documents.table.gui.FeatureTableDocumentPanel; |
|
9 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
10 |
import org.gvsig.fmap.dal.feature.FeatureStoreTransform; |
|
11 |
import org.gvsig.fmap.dal.feature.FeatureStoreTransforms; |
|
12 |
|
|
13 |
|
|
14 |
/** |
|
15 |
* @author Fernando Gonz?lez Cort?s |
|
16 |
*/ |
|
17 |
public class RemoveTableUnion extends Extension{ |
|
18 |
|
|
19 |
/** |
|
20 |
* @see org.gvsig.andami.plugins.IExtension#initialize() |
|
21 |
*/ |
|
22 |
public void initialize() { |
|
23 |
// TODO Auto-generated method stub |
|
24 |
|
|
25 |
} |
|
26 |
|
|
27 |
/** |
|
28 |
* @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String) |
|
29 |
*/ |
|
30 |
public void execute(String actionCommand) { |
|
31 |
FeatureTableDocumentPanel t = (FeatureTableDocumentPanel) PluginServices.getMDIManager().getActiveWindow(); |
|
32 |
TableDocument pt = t.getModel(); |
|
33 |
FeatureStore fs = pt.getStore(); |
|
34 |
this.removeJoinTransfor(fs); |
|
35 |
|
|
36 |
// TODO |
|
37 |
// if (fs instanceof JoinFeatureStore) { |
|
38 |
// DataManager dm = DALLocator.getDataManager(); |
|
39 |
// DataStoreParameters originalParams = ((JoinFeatureStoreParameters) fs |
|
40 |
// .getParameters()).getStorePrimary(); |
|
41 |
// FeatureStore original = null; |
|
42 |
// try { |
|
43 |
// original = (FeatureStore) dm.createStore(originalParams); |
|
44 |
// } catch (InitializeException e) { |
|
45 |
// NotificationManager.addError(e.getMessage(), e); |
|
46 |
// return; |
|
47 |
// } |
|
48 |
// |
|
49 |
// pt.setStore(original); |
|
50 |
// try { |
|
51 |
// fs.dispose(); |
|
52 |
// } catch (CloseException e) { |
|
53 |
// NotificationManager.addError(e); |
|
54 |
// } |
|
55 |
// t.setModel(pt); |
|
56 |
// |
|
57 |
// } |
|
58 |
|
|
59 |
// t.clearSelectedFields(); |
|
60 |
t.getModel().setModified(true); |
|
61 |
} |
|
62 |
|
|
63 |
public void removeJoinTransfor(FeatureStore store) { |
|
64 |
FeatureStoreTransforms transforms = store.getTransforms(); |
|
65 |
int size = transforms.size(); |
|
66 |
if (size < 1) { |
|
67 |
return; |
|
68 |
} |
|
69 |
FeatureStoreTransform join = transforms.getTransform(size - 1); |
|
70 |
if (join instanceof JoinTransform) { |
|
71 |
transforms.remove(join); |
|
72 |
} else { |
|
73 |
return; |
|
74 |
} |
|
75 |
|
|
76 |
|
|
77 |
|
|
78 |
} |
|
79 |
|
|
80 |
public boolean hasJoinTransform(FeatureStore store) { |
|
81 |
|
|
82 |
FeatureStoreTransforms transforms = store.getTransforms(); |
|
83 |
int size = transforms.size(); |
|
84 |
if (size < 1) { |
|
85 |
return false; |
|
86 |
} |
|
87 |
return (transforms.getTransform(size - 1) instanceof JoinTransform); |
|
88 |
|
|
89 |
} |
|
90 |
|
|
91 |
/** |
|
92 |
* @see org.gvsig.andami.plugins.IExtension#isEnabled() |
|
93 |
*/ |
|
94 |
public boolean isEnabled() { |
|
95 |
IWindow v = PluginServices.getMDIManager().getActiveWindow(); |
|
96 |
|
|
97 |
if (v == null) { |
|
98 |
return false; |
|
99 |
} |
|
100 |
|
|
101 |
if (v.getClass() == FeatureTableDocumentPanel.class) { |
|
102 |
FeatureTableDocumentPanel t = (FeatureTableDocumentPanel) v; |
|
103 |
// FIXME !!!! Asi se hacia antes |
|
104 |
// if (t.getModel().getOriginal() != null){ |
|
105 |
// return true; |
|
106 |
// } |
|
107 |
|
|
108 |
TableDocument pt = t.getModel(); |
|
109 |
FeatureStore fs = pt.getStore(); |
|
110 |
|
|
111 |
return this.hasJoinTransform(fs); |
|
112 |
// TODO |
|
113 |
// if (fs instanceof JoinFeatureStore) { |
|
114 |
// return true; |
|
115 |
// } |
|
116 |
|
|
117 |
} |
|
118 |
return false; |
|
119 |
} |
|
120 |
|
|
121 |
/** |
|
122 |
* @see org.gvsig.andami.plugins.IExtension#isVisible() |
|
123 |
*/ |
|
124 |
public boolean isVisible() { |
|
125 |
IWindow v = PluginServices.getMDIManager().getActiveWindow(); |
|
126 |
|
|
127 |
if (v == null) { |
|
128 |
return false; |
|
129 |
} |
|
130 |
|
|
131 |
if (v instanceof FeatureTableDocumentPanel) { |
|
132 |
return true; |
|
133 |
} else { |
|
134 |
return false; |
|
135 |
} |
|
136 |
|
|
137 |
} |
|
138 |
|
|
139 |
} |
|
0 | 140 |
tags/v_2_0_0_Build_2043/extensions/extDalTransformJoin/extDalTransformJoin/src/org/gvsig/app/join/JoinTransformLibrary.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2009 {Iver T.I.} {Task} |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.app.join; |
|
29 |
|
|
30 |
import org.gvsig.app.join.dal.feature.JoinTransform; |
|
31 |
import org.gvsig.app.join.daltransform.JoinTransformGui; |
|
32 |
import org.gvsig.daltransform.DataTransformLocator; |
|
33 |
import org.gvsig.daltransform.DataTransformManager; |
|
34 |
import org.gvsig.fmap.dal.DALLibrary; |
|
35 |
import org.gvsig.tools.library.AbstractLibrary; |
|
36 |
import org.gvsig.tools.library.LibraryException; |
|
37 |
import org.gvsig.tools.locator.ReferenceNotRegisteredException; |
|
38 |
|
|
39 |
/** |
|
40 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
41 |
*/ |
|
42 |
public class JoinTransformLibrary extends AbstractLibrary { |
|
43 |
|
|
44 |
@Override |
|
45 |
public void doRegistration() { |
|
46 |
registerAsImplementationOf(JoinTransformLibrary.class); |
|
47 |
require(DALLibrary.class); |
|
48 |
} |
|
49 |
|
|
50 |
@Override |
|
51 |
protected void doInitialize() throws LibraryException { |
|
52 |
// TODO Auto-generated method stub |
|
53 |
|
|
54 |
} |
|
55 |
|
|
56 |
@Override |
|
57 |
protected void doPostInitialize() throws LibraryException { |
|
58 |
// Validate there is any implementation registered. |
|
59 |
DataTransformManager dataTransformManager = DataTransformLocator.getDataTransformManager(); |
|
60 |
if (dataTransformManager == null) { |
|
61 |
throw new ReferenceNotRegisteredException( |
|
62 |
DataTransformLocator.DATA_TRANSFORM_MANAGER_NAME, DataTransformLocator.getInstance()); |
|
63 |
} |
|
64 |
dataTransformManager.registerDataTransform("join", JoinTransformGui.class); |
|
65 |
|
|
66 |
JoinTransform.registerPersistent(); |
|
67 |
} |
|
68 |
|
|
69 |
} |
|
70 |
|
|
0 | 71 |
tags/v_2_0_0_Build_2043/extensions/extDalTransformJoin/extDalTransformJoin/src/org/gvsig/app/join/dal/feature/JoinTransform.java | ||
---|---|---|
1 |
package org.gvsig.app.join.dal.feature; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.Arrays; |
|
5 |
import java.util.HashMap; |
|
6 |
import java.util.Iterator; |
|
7 |
import java.util.List; |
|
8 |
import java.util.Map; |
|
9 |
import java.util.Map.Entry; |
|
10 |
|
|
11 |
import org.gvsig.fmap.dal.exception.DataException; |
|
12 |
import org.gvsig.fmap.dal.feature.AbstractFeatureStoreTransform; |
|
13 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
|
14 |
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor; |
|
15 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
|
16 |
import org.gvsig.fmap.dal.feature.Feature; |
|
17 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
18 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
|
19 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
|
20 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
21 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
22 |
import org.gvsig.tools.ToolsLocator; |
|
23 |
import org.gvsig.tools.dispose.DisposableIterator; |
|
24 |
import org.gvsig.tools.dynobject.DynStruct; |
|
25 |
import org.gvsig.tools.evaluator.Evaluator; |
|
26 |
import org.gvsig.tools.evaluator.EvaluatorData; |
|
27 |
import org.gvsig.tools.evaluator.EvaluatorException; |
|
28 |
import org.gvsig.tools.evaluator.EvaluatorFieldsInfo; |
|
29 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
30 |
import org.gvsig.tools.persistence.PersistentState; |
|
31 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
32 |
|
|
33 |
public class JoinTransform extends AbstractFeatureStoreTransform { |
|
34 |
|
|
35 |
public static final String PERSISTENCE_DEFINITION_NAME = "JoinTransform"; |
|
36 |
|
|
37 |
/** |
|
38 |
* Store from which the join transform will get the additional attributes |
|
39 |
*/ |
|
40 |
private FeatureStore store2; |
|
41 |
|
|
42 |
/** |
|
43 |
* name of the key attr in store1 that will be used to match features in |
|
44 |
* store2 |
|
45 |
*/ |
|
46 |
private String keyAttr1; |
|
47 |
|
|
48 |
/** |
|
49 |
* name of the key attr in store2 that will be used to match features in |
|
50 |
* store1 |
|
51 |
*/ |
|
52 |
private String keyAttr2; |
|
53 |
|
|
54 |
/** |
|
55 |
* names of the attributes to join from store2 to store1 |
|
56 |
*/ |
|
57 |
private String[] attrs; |
|
58 |
|
|
59 |
/** |
|
60 |
* Attribute names may change after transformation a prefix is applied. |
|
61 |
* This map keeps correspondence between store1 original names |
|
62 |
* and their transformed counterparts. |
|
63 |
*/ |
|
64 |
private Map<String,String> store1NamesMap; |
|
65 |
|
|
66 |
/** |
|
67 |
* Attribute names may change after transformation if they are repeated in |
|
68 |
* both stores or if a prefix is applied. This map keeps correspondence |
|
69 |
* between store2 original names and their transformed counterparts. |
|
70 |
*/ |
|
71 |
private Map<String,String> store2NamesMap; |
|
72 |
|
|
73 |
private JoinTransformEvaluator evaluator = null; |
|
74 |
|
|
75 |
private FeatureType originalFeatureType; |
|
76 |
|
|
77 |
private String[] attrsForQuery; |
|
78 |
|
|
79 |
private String prefix1; |
|
80 |
|
|
81 |
private String prefix2; |
|
82 |
|
|
83 |
/** |
|
84 |
* A default constructor |
|
85 |
*/ |
|
86 |
public JoinTransform() { |
|
87 |
store1NamesMap = new HashMap<String,String>(); |
|
88 |
store2NamesMap = new HashMap<String,String>(); |
|
89 |
} |
|
90 |
|
|
91 |
/** |
|
92 |
* Initializes all the necessary data for this transform |
|
93 |
* |
|
94 |
* @param store1 |
|
95 |
* store whose default feature type is the target of this |
|
96 |
* transform |
|
97 |
* |
|
98 |
* @param store2 |
|
99 |
* store whose default feature type will provide the new |
|
100 |
* attributes to join |
|
101 |
* |
|
102 |
* @param keyAttr1 |
|
103 |
* key attribute in store1 that matches keyAttr2 in store2 |
|
104 |
* (foreign key), used for joining both stores. |
|
105 |
* |
|
106 |
* @param keyAttr2 |
|
107 |
* key attribute in store2 that matches keyAttr1 in store2 |
|
108 |
* (foreign key), used for joining both stores. |
|
109 |
* |
|
110 |
* @param attrs |
|
111 |
* names of the attributes in store2 that will be joined to |
|
112 |
* store1. |
|
113 |
*/ |
|
114 |
public void initialize(FeatureStore store1, FeatureStore store2, |
|
115 |
String keyAttr1, String keyAttr2, String prefix1, String prefix2, |
|
116 |
String[] attrs) |
|
117 |
throws DataException { |
|
118 |
|
|
119 |
if (store1 == store2) { |
|
120 |
throw new IllegalArgumentException("store1 == store2"); |
|
121 |
} |
|
122 |
|
|
123 |
// Initialize needed data |
|
124 |
this.setFeatureStore(store1); |
|
125 |
this.store2 = store2; |
|
126 |
this.keyAttr1 = keyAttr1; |
|
127 |
this.keyAttr2 = keyAttr2; |
|
128 |
this.prefix1 = prefix1; // TODO |
|
129 |
this.prefix2 = prefix2; // TODO |
|
130 |
this.attrs = attrs; |
|
131 |
|
|
132 |
// calculate this transform resulting feature type |
|
133 |
// by adding all specified attrs from store2 to store1's default |
|
134 |
// feature type |
|
135 |
// FIXME for more than one FTypes ?? |
|
136 |
this.originalFeatureType = this.getFeatureStore() |
|
137 |
.getDefaultFeatureType(); |
|
138 |
|
|
139 |
// Create the feature type and copy the store 1 type |
|
140 |
EditableFeatureType editableFeatureType = this.getFeatureStore().getDefaultFeatureType().getEditable(); |
|
141 |
FeatureAttributeDescriptor[] featureAttributeDescriptors = editableFeatureType.getAttributeDescriptors(); |
|
142 |
for (int i=0 ; i<featureAttributeDescriptors.length ; i++){ |
|
143 |
editableFeatureType.remove(featureAttributeDescriptors[i].getName()); |
|
144 |
} |
|
145 |
addFeatureType(editableFeatureType, featureAttributeDescriptors, prefix1, store1NamesMap); |
|
146 |
|
|
147 |
// Add the store 2 fields |
|
148 |
FeatureType featureType2 = store2.getDefaultFeatureType(); |
|
149 |
|
|
150 |
// Add the fields |
|
151 |
for (int i = 0; i < attrs.length; i++) { |
|
152 |
addFeatureType(editableFeatureType, featureType2.getAttributeDescriptor(attrs[i]), prefix2, store2NamesMap); |
|
153 |
} |
|
154 |
|
|
155 |
if (this.store2NamesMap.containsKey(keyAttr2)) { |
|
156 |
this.attrsForQuery = this.attrs; |
|
157 |
} else { |
|
158 |
List<String> list = new ArrayList<String>(this.attrs.length + 1); |
|
159 |
list.addAll(Arrays.asList(this.attrs)); |
|
160 |
list.add(keyAttr2); |
|
161 |
this.attrsForQuery = (String[]) list.toArray(new String[] {}); |
|
162 |
} |
|
163 |
|
|
164 |
// assign calculated feature type as this transform's feature type |
|
165 |
FeatureType[] types = new FeatureType[] { editableFeatureType.getNotEditableCopy() }; |
|
166 |
setFeatureTypes(Arrays.asList(types), types[0]); |
|
167 |
} |
|
168 |
|
|
169 |
private void addFeatureType(EditableFeatureType targetFeatureType, FeatureAttributeDescriptor[] featureAttributeDescriptors, |
|
170 |
String prefix, Map<String, String> storeMap) throws DataException{ |
|
171 |
|
|
172 |
for (int i=0 ; i<featureAttributeDescriptors.length ; i++){ |
|
173 |
addFeatureType(targetFeatureType, featureAttributeDescriptors[i], prefix, storeMap); |
|
174 |
} |
|
175 |
} |
|
176 |
|
|
177 |
private void addFeatureType(EditableFeatureType targetFeatureType, FeatureAttributeDescriptor featureAttributeDescriptor, |
|
178 |
String prefix, Map<String, String> storeMap) throws DataException{ |
|
179 |
|
|
180 |
String attName = featureAttributeDescriptor.getName(); |
|
181 |
if ((prefix != null) && (!prefix.equals(""))){ |
|
182 |
attName = prefix + "_" + attName; |
|
183 |
} |
|
184 |
|
|
185 |
// If an attribute already exists, calculate an alternate name and add it to our type |
|
186 |
int j = 0; |
|
187 |
while (targetFeatureType.getIndex(attName) >= 0) { |
|
188 |
attName = targetFeatureType.getAttributeDescriptor(attName).getName() + "_" + ++j; |
|
189 |
} |
|
190 |
|
|
191 |
EditableFeatureAttributeDescriptor editableFeatureAttributeDescriptor = |
|
192 |
targetFeatureType.add(attName, featureAttributeDescriptor.getType(), |
|
193 |
featureAttributeDescriptor.getSize()); |
|
194 |
editableFeatureAttributeDescriptor.setPrecision(featureAttributeDescriptor.getPrecision()); |
|
195 |
|
|
196 |
// keep correspondence between original name and transformed name |
|
197 |
storeMap.put(featureAttributeDescriptor.getName(), attName); |
|
198 |
} |
|
199 |
|
|
200 |
/** |
|
201 |
* |
|
202 |
* |
|
203 |
* @param source |
|
204 |
* |
|
205 |
* @param target |
|
206 |
* |
|
207 |
* @throws DataException |
|
208 |
*/ |
|
209 |
public void applyTransform(Feature source, EditableFeature target) |
|
210 |
throws DataException { |
|
211 |
|
|
212 |
// copy the data from store1 into the resulting feature |
|
213 |
this.copySourceToTarget(source, target); |
|
214 |
|
|
215 |
// ask store2 for the specified attributes, filtering by the key |
|
216 |
// attribute value |
|
217 |
// from the source feature |
|
218 |
JoinTransformEvaluator eval = this.getEvaluator(); |
|
219 |
eval.updateValue(source.get(this.keyAttr1)); |
|
220 |
|
|
221 |
FeatureQuery query = store2.createFeatureQuery(); |
|
222 |
query.setAttributeNames(attrsForQuery); |
|
223 |
query.setFilter(eval); |
|
224 |
FeatureSet set = null; |
|
225 |
DisposableIterator itFeat = null; |
|
226 |
|
|
227 |
try { |
|
228 |
|
|
229 |
set = store2.getFeatureSet(query); |
|
230 |
// In this join implementation, we will take only the first matching |
|
231 |
// feature found in store2 |
|
232 |
|
|
233 |
Feature feat; |
|
234 |
|
|
235 |
|
|
236 |
itFeat = set.iterator(); |
|
237 |
if (itFeat.hasNext()) { |
|
238 |
feat = (Feature) itFeat.next(); |
|
239 |
|
|
240 |
// copy all attributes from joined feature to target |
|
241 |
this.copyJoinToTarget(feat, target); |
|
242 |
} |
|
243 |
} finally { |
|
244 |
if (itFeat != null) { |
|
245 |
itFeat.dispose(); |
|
246 |
} |
|
247 |
if (set != null) { |
|
248 |
set.dispose(); |
|
249 |
} |
|
250 |
} |
|
251 |
} |
|
252 |
|
|
253 |
/** |
|
254 |
* @param feat |
|
255 |
* @param target |
|
256 |
*/ |
|
257 |
private void copyJoinToTarget(Feature join, EditableFeature target) { |
|
258 |
Iterator<Entry<String, String>> iter = store2NamesMap.entrySet() |
|
259 |
.iterator(); |
|
260 |
Entry<String, String> entry; |
|
261 |
FeatureType trgType = target.getType(); |
|
262 |
FeatureAttributeDescriptor attr; |
|
263 |
while (iter.hasNext()) { |
|
264 |
entry = iter.next(); |
|
265 |
attr = trgType.getAttributeDescriptor((String) entry.getValue()); |
|
266 |
if (attr != null) { |
|
267 |
target.set(attr.getIndex(), join.get((String) entry.getKey())); |
|
268 |
} |
|
269 |
} |
|
270 |
} |
|
271 |
|
|
272 |
/** |
|
273 |
* @param source |
|
274 |
* @param target |
|
275 |
*/ |
|
276 |
private void copySourceToTarget(Feature source, EditableFeature target) { |
|
277 |
FeatureAttributeDescriptor attr, attrTrg; |
|
278 |
FeatureType ftSrc = source.getType(); |
|
279 |
FeatureType ftTrg = target.getType(); |
|
280 |
|
|
281 |
|
|
282 |
for (int i = 0; i < source.getType().size(); i++) { |
|
283 |
attr = ftSrc.getAttributeDescriptor(i); |
|
284 |
attrTrg = ftTrg.getAttributeDescriptor(store1NamesMap.get(attr.getName())); |
|
285 |
if (attrTrg != null) { |
|
286 |
try { |
|
287 |
target.set(attrTrg.getIndex(), source.get(i)); |
|
288 |
} catch (IllegalArgumentException e) { |
|
289 |
attrTrg = ftTrg.getAttributeDescriptor(attr.getName()); |
|
290 |
target.set(attrTrg.getIndex(), attrTrg.getDefaultValue()); |
|
291 |
} |
|
292 |
|
|
293 |
} |
|
294 |
} |
|
295 |
|
|
296 |
} |
|
297 |
|
|
298 |
private JoinTransformEvaluator getEvaluator() { |
|
299 |
if (this.evaluator == null){ |
|
300 |
this.evaluator = new JoinTransformEvaluator(keyAttr2); |
|
301 |
} |
|
302 |
return evaluator; |
|
303 |
|
|
304 |
} |
|
305 |
|
|
306 |
private class JoinTransformEvaluator implements Evaluator { |
|
307 |
|
|
308 |
private String attribute; |
|
309 |
private Object value; |
|
310 |
private String sql; |
|
311 |
private EvaluatorFieldsInfo info = null; |
|
312 |
|
|
313 |
// private int attributeIndex; |
|
314 |
|
|
315 |
public JoinTransformEvaluator(String attribute) { |
|
316 |
this.attribute = attribute; |
|
317 |
this.value = null; |
|
318 |
this.info = new EvaluatorFieldsInfo(); |
|
319 |
|
|
320 |
// this.attributeIndex = attrIndex; |
|
321 |
} |
|
322 |
|
|
323 |
public void updateValue(Object value) { |
|
324 |
this.value = value; |
|
325 |
this.sql = this.attribute + "= '" + this.value + "'"; |
|
326 |
this.info = new EvaluatorFieldsInfo(); |
|
327 |
this.info.addMatchFieldValue(this.attribute, value); |
|
328 |
} |
|
329 |
|
|
330 |
public Object evaluate(EvaluatorData arg0) throws EvaluatorException { |
|
331 |
Object curValue = arg0.getDataValue(attribute); |
|
332 |
if (curValue == null) { |
|
333 |
return value == null; |
|
334 |
} |
|
335 |
return curValue.equals(value); |
|
336 |
} |
|
337 |
|
|
338 |
public String getSQL() { |
|
339 |
return this.sql; |
|
340 |
} |
|
341 |
|
|
342 |
public String getDescription() { |
|
343 |
return "Evaluates join transform match"; |
|
344 |
} |
|
345 |
|
|
346 |
public String getName() { |
|
347 |
return "JoinTransformEvaluator"; |
|
348 |
} |
|
349 |
|
|
350 |
public EvaluatorFieldsInfo getFieldsInfo() { |
|
351 |
return this.info; |
|
352 |
} |
|
353 |
|
|
354 |
} |
|
355 |
|
|
356 |
@SuppressWarnings("unchecked") |
|
357 |
public FeatureType getSourceFeatureTypeFrom(FeatureType arg0) { |
|
358 |
return originalFeatureType; |
|
359 |
} |
|
360 |
|
|
361 |
public boolean isTransformsOriginalValues() { |
|
362 |
return false; |
|
363 |
} |
|
364 |
|
|
365 |
public static void registerPersistent() { |
|
366 |
PersistenceManager persistenceManager = ToolsLocator.getPersistenceManager(); |
|
367 |
|
|
368 |
if( persistenceManager.getDefinition(AbstractFeatureStoreTransform.class) == null ) { |
|
369 |
AbstractFeatureStoreTransform.registerPersistent(); |
|
370 |
} |
|
371 |
|
|
372 |
DynStruct definition = persistenceManager.getDefinition(PERSISTENCE_DEFINITION_NAME); |
|
373 |
|
|
374 |
if (definition == null){ |
|
375 |
definition = persistenceManager.addDefinition( |
|
376 |
JoinTransform.class, |
|
377 |
PERSISTENCE_DEFINITION_NAME, |
|
378 |
"JoinTransform Persistence definition", |
|
379 |
null, |
|
380 |
null |
|
381 |
); |
|
382 |
definition.extend(PersistenceManager.PERSISTENCE_NAMESPACE, |
|
383 |
ABSTRACT_FEATURESTORE_DYNCLASS_NAME); |
|
384 |
|
|
385 |
definition.addDynFieldObject("store2").setClassOfValue(FeatureStore.class).setMandatory(true); |
|
386 |
definition.addDynFieldString("keyAttr1").setMandatory(true); |
|
387 |
definition.addDynFieldString("keyAttr2").setMandatory(true); |
|
388 |
definition.addDynFieldString("prefix1").setMandatory(false); |
|
389 |
definition.addDynFieldString("prefix2").setMandatory(false); |
|
390 |
definition.addDynFieldList("attrs").setClassOfItems(String.class).setMandatory(true); |
|
391 |
} |
|
392 |
} |
|
393 |
|
|
394 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
395 |
super.saveToState(state); |
|
396 |
state.set("store2", this.store2); |
|
397 |
state.set("keyAttr1", this.keyAttr1); |
|
398 |
state.set("keyAttr2", this.keyAttr2); |
|
399 |
state.set("prefix1", this.prefix1); |
|
400 |
state.set("prefix2", this.prefix2); |
|
401 |
state.set("attrs", this.attrs); |
|
402 |
} |
|
403 |
|
|
404 |
public void loadFromState(PersistentState state) throws PersistenceException { |
|
405 |
super.loadFromState(state); |
|
406 |
FeatureStore store2 = (FeatureStore) state.get("store2"); |
|
407 |
String keyAttr1 = state.getString("keyAttr1"); |
|
408 |
String keyAttr2 = state.getString("keyAttr2"); |
|
409 |
String prefix2 = state.getString("prefix2"); |
|
410 |
String[] attrs = (String[]) state.getArray("attrs", String.class); |
|
411 |
try { |
|
412 |
initialize(getFeatureStore(), store2, keyAttr1, keyAttr2, prefix1, prefix2, attrs); |
|
413 |
} catch (DataException e) { |
|
414 |
throw new PersistenceException("Impossible to create the transform", e); |
|
415 |
} |
|
416 |
} |
|
417 |
|
|
418 |
} |
|
0 | 419 |
tags/v_2_0_0_Build_2043/extensions/extDalTransformJoin/extDalTransformJoin/src/org/gvsig/app/join/JoinToolExtension.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2009 {Iver T.I.} {Task} |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.app.join; |
|
29 |
|
|
30 |
import java.awt.Component; |
|
31 |
|
|
32 |
import javax.swing.JOptionPane; |
|
33 |
|
|
34 |
import org.gvsig.andami.PluginServices; |
|
35 |
import org.gvsig.app.extension.TableOperations; |
|
36 |
import org.gvsig.app.join.daltransform.JoinTransformGui; |
|
37 |
import org.gvsig.daltransform.DataTransformLocator; |
|
38 |
import org.gvsig.daltransform.swing.DataTransformWizard; |
|
39 |
|
|
40 |
|
|
41 |
/** |
|
42 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
43 |
*/ |
|
44 |
public class JoinToolExtension extends TableOperations { |
|
45 |
|
|
46 |
/** |
|
47 |
* @see com.iver.mdiApp.plugins.IExtension#updateUI(java.lang.String) |
|
48 |
*/ |
|
49 |
public void execute(String actionCommand) { |
|
50 |
try { |
|
51 |
DataTransformWizard dataTransformWizard = DataTransformLocator.getDataTransformManager().createWizard(); |
|
52 |
dataTransformWizard.setDataTransformGui(new JoinTransformGui()); |
|
53 |
PluginServices.getMDIManager().addWindow(dataTransformWizard.getWindow()); |
|
54 |
} catch (Exception e) { |
|
55 |
JOptionPane.showInternalMessageDialog((Component)PluginServices.getMDIManager(), |
|
56 |
PluginServices.getText(this, "transform_create_wizard_exception"), |
|
57 |
PluginServices.getText(this, "feature_transform"), |
|
58 |
JOptionPane.ERROR_MESSAGE); |
|
59 |
} |
|
60 |
} |
|
61 |
|
|
62 |
} |
|
0 | 63 |
tags/v_2_0_0_Build_2043/extensions/extDalTransformJoin/extDalTransformJoin/src/org/gvsig/app/join/daltransform/SelectParametersWizardPanel.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2009 {Iver T.I.} {Task} |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.app.join.daltransform; |
|
29 |
|
|
30 |
import org.gvsig.andami.PluginServices; |
|
31 |
import org.gvsig.daltransform.swing.DataTransformWizardPanel; |
|
32 |
import org.gvsig.daltransform.swing.impl.AbstractDataTransformWizardPanel; |
|
33 |
import org.gvsig.daltransform.swing.impl.components.FeatureTypeAttributesCombo; |
|
34 |
import org.gvsig.daltransform.swing.impl.components.FeatureTypeAttributesList; |
|
35 |
import org.gvsig.fmap.dal.exception.DataException; |
|
36 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
37 |
|
|
38 |
|
|
39 |
/** |
|
40 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
41 |
*/ |
|
42 |
public class SelectParametersWizardPanel extends AbstractDataTransformWizardPanel implements DataTransformWizardPanel{ |
|
43 |
private javax.swing.JLabel attributesLabel; |
|
44 |
private FeatureTypeAttributesList attributesList; |
|
45 |
private javax.swing.JScrollPane attributesScroll; |
|
46 |
private FeatureTypeAttributesCombo key1Combo; |
|
47 |
private javax.swing.JLabel key1Label; |
|
48 |
private FeatureTypeAttributesCombo key2Combo; |
|
49 |
private javax.swing.JLabel key2Label; |
|
50 |
private javax.swing.JLabel prefix1Label; |
|
51 |
private javax.swing.JTextField prefix1Text; |
|
52 |
private javax.swing.JLabel prefix2Label; |
|
53 |
private javax.swing.JTextField prefix2Text; |
|
54 |
|
|
55 |
/** |
|
56 |
* @param featureTransformWizardModel |
|
57 |
*/ |
|
58 |
public SelectParametersWizardPanel() { |
|
59 |
super(); |
|
60 |
initComponents(); |
|
61 |
initLabels(); |
|
62 |
} |
|
63 |
|
|
64 |
private void initLabels(){ |
|
65 |
key1Label.setText(PluginServices.getText(this,"join_first_key")); |
|
66 |
key2Label.setText(PluginServices.getText(this,"join_second_key")); |
|
67 |
prefix1Label.setText(PluginServices.getText(this,"join_first_prefix")); |
|
68 |
prefix2Label.setText(PluginServices.getText(this,"join_second_prefix")); |
|
69 |
attributesLabel.setText(PluginServices.getText(this,"join_select_attributes")); |
|
70 |
} |
|
71 |
|
|
72 |
private void initComponents() { |
|
73 |
java.awt.GridBagConstraints gridBagConstraints; |
|
74 |
|
|
75 |
prefix2Text = new javax.swing.JTextField(); |
|
76 |
key2Combo = new FeatureTypeAttributesCombo(); |
|
77 |
prefix1Text = new javax.swing.JTextField(); |
|
78 |
key1Label = new javax.swing.JLabel(); |
|
79 |
key1Combo = new FeatureTypeAttributesCombo(); |
|
80 |
key2Label = new javax.swing.JLabel(); |
|
81 |
prefix1Label = new javax.swing.JLabel(); |
|
82 |
prefix2Label = new javax.swing.JLabel(); |
|
83 |
attributesLabel = new javax.swing.JLabel(); |
|
84 |
attributesScroll = new javax.swing.JScrollPane(); |
|
85 |
attributesList = new FeatureTypeAttributesList(); |
|
86 |
|
|
87 |
setLayout(new java.awt.GridBagLayout()); |
|
88 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
89 |
gridBagConstraints.gridx = 0; |
|
90 |
gridBagConstraints.gridy = 7; |
|
91 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
92 |
gridBagConstraints.weightx = 1.0; |
|
93 |
gridBagConstraints.insets = new java.awt.Insets(2, 2, 3, 2); |
|
94 |
add(prefix2Text, gridBagConstraints); |
|
95 |
|
|
96 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
97 |
gridBagConstraints.gridx = 0; |
|
98 |
gridBagConstraints.gridy = 3; |
|
99 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
100 |
gridBagConstraints.weightx = 1.0; |
|
101 |
gridBagConstraints.insets = new java.awt.Insets(2, 2, 3, 2); |
|
102 |
add(key2Combo, gridBagConstraints); |
|
103 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
104 |
gridBagConstraints.gridx = 0; |
|
105 |
gridBagConstraints.gridy = 5; |
|
106 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
107 |
gridBagConstraints.weightx = 1.0; |
|
108 |
gridBagConstraints.insets = new java.awt.Insets(2, 2, 3, 2); |
|
109 |
add(prefix1Text, gridBagConstraints); |
|
110 |
|
|
111 |
key1Label.setText("jLabel1"); |
|
112 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
113 |
gridBagConstraints.gridx = 0; |
|
114 |
gridBagConstraints.gridy = 0; |
|
115 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
|
116 |
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2); |
|
117 |
add(key1Label, gridBagConstraints); |
|
118 |
|
|
119 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
120 |
gridBagConstraints.gridx = 0; |
|
121 |
gridBagConstraints.gridy = 1; |
|
122 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
123 |
gridBagConstraints.weightx = 1.0; |
|
124 |
gridBagConstraints.insets = new java.awt.Insets(2, 2, 3, 2); |
|
125 |
add(key1Combo, gridBagConstraints); |
|
126 |
|
|
127 |
key2Label.setText("jLabel2"); |
|
128 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
129 |
gridBagConstraints.gridx = 0; |
|
130 |
gridBagConstraints.gridy = 2; |
|
131 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
|
132 |
gridBagConstraints.insets = new java.awt.Insets(3, 2, 2, 2); |
|
133 |
add(key2Label, gridBagConstraints); |
|
134 |
|
|
135 |
prefix1Label.setText("jLabel1"); |
|
136 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
137 |
gridBagConstraints.gridx = 0; |
|
138 |
gridBagConstraints.gridy = 4; |
|
139 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
|
140 |
gridBagConstraints.insets = new java.awt.Insets(3, 2, 2, 2); |
|
141 |
add(prefix1Label, gridBagConstraints); |
|
142 |
|
|
143 |
prefix2Label.setText("jLabel2"); |
|
144 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
145 |
gridBagConstraints.gridx = 0; |
|
146 |
gridBagConstraints.gridy = 6; |
|
147 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
|
148 |
gridBagConstraints.insets = new java.awt.Insets(3, 2, 2, 2); |
|
149 |
add(prefix2Label, gridBagConstraints); |
|
150 |
|
|
151 |
attributesLabel.setText("attributesLabel"); |
|
152 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
153 |
gridBagConstraints.gridx = 0; |
|
154 |
gridBagConstraints.gridy = 8; |
|
155 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
|
156 |
gridBagConstraints.insets = new java.awt.Insets(3, 2, 2, 2); |
|
157 |
add(attributesLabel, gridBagConstraints); |
|
158 |
|
|
159 |
attributesScroll.setViewportView(attributesList); |
|
160 |
|
|
161 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
162 |
gridBagConstraints.gridx = 0; |
|
163 |
gridBagConstraints.gridy = 9; |
|
164 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
|
165 |
gridBagConstraints.weightx = 1.0; |
|
166 |
gridBagConstraints.weighty = 1.0; |
|
167 |
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2); |
|
168 |
add(attributesScroll, gridBagConstraints); |
|
169 |
} |
|
170 |
|
|
171 |
/** |
|
172 |
* @return |
|
173 |
*/ |
|
174 |
public String getKeyAttr1() { |
|
175 |
return key1Combo.getSelectedFeatureAttributeDescriptor().getName(); |
|
176 |
} |
|
177 |
|
|
178 |
/** |
|
179 |
* @return |
|
180 |
*/ |
|
181 |
public String getkeyAtrr2() { |
|
182 |
return key2Combo.getSelectedFeatureAttributeDescriptor().getName(); |
|
183 |
} |
|
184 |
|
|
185 |
/** |
|
186 |
* @return |
|
187 |
*/ |
|
188 |
public String getPrefix1() { |
|
189 |
return prefix1Text.getText(); |
|
190 |
} |
|
191 |
|
|
192 |
/** |
|
193 |
* @return |
|
194 |
*/ |
|
195 |
public String getPrefix2() { |
|
196 |
return prefix2Text.getText(); |
|
197 |
} |
|
198 |
|
|
199 |
/** |
|
200 |
* @return |
|
201 |
*/ |
|
202 |
public String[] getAttributes() { |
|
203 |
return attributesList.getAttributesName(); |
|
204 |
} |
|
205 |
|
|
206 |
/** |
|
207 |
* @param selectedFeatureStore |
|
208 |
* @throws DataException |
|
209 |
*/ |
|
210 |
public void updateFeatureStores(FeatureStore selectedFeatureStore) throws DataException { |
|
211 |
key1Combo.addFeatureAttributes(getFeatureStore().getDefaultFeatureType()); |
|
212 |
key2Combo.addFeatureAttributes(selectedFeatureStore.getDefaultFeatureType()); |
|
213 |
attributesList.addFeatureAttributes(selectedFeatureStore.getDefaultFeatureType()); |
|
214 |
} |
|
215 |
} |
|
216 |
|
|
0 | 217 |
tags/v_2_0_0_Build_2043/extensions/extDalTransformJoin/extDalTransformJoin/src/org/gvsig/app/join/daltransform/JoinTransformGui.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2009 {Iver T.I.} {Task} |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.app.join.daltransform; |
|
29 |
|
|
30 |
import java.awt.Dimension; |
|
31 |
import java.util.ArrayList; |
|
32 |
import java.util.List; |
|
33 |
|
|
34 |
import org.gvsig.andami.PluginServices; |
|
35 |
import org.gvsig.app.join.dal.feature.JoinTransform; |
|
36 |
import org.gvsig.daltransform.swing.DataTransformGui; |
|
37 |
import org.gvsig.daltransform.swing.DataTransformWizardPanel; |
|
38 |
import org.gvsig.fmap.dal.exception.DataException; |
|
39 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
40 |
import org.gvsig.fmap.dal.feature.FeatureStoreTransform; |
|
41 |
|
|
42 |
|
|
43 |
/** |
|
44 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
45 |
*/ |
|
46 |
public class JoinTransformGui implements DataTransformGui { |
|
47 |
private SelectSecondDataStoreWizardPanel secondDataStoreWizard = null; |
|
48 |
private SelectParametersWizardPanel parametersWizard = null; |
|
49 |
private List<DataTransformWizardPanel> panels = null; |
|
50 |
|
|
51 |
public JoinTransformGui() { |
|
52 |
super(); |
|
53 |
} |
|
54 |
|
|
55 |
/* (non-Javadoc) |
|
56 |
* @see org.gvsig.app.daltransform.gui.FeatureTransformGui#createFeatureStoreTransform(org.gvsig.fmap.dal.feature.FeatureStore) |
|
57 |
*/ |
|
58 |
public FeatureStoreTransform createFeatureStoreTransform( |
|
59 |
FeatureStore featureStore) throws DataException { |
|
60 |
JoinTransform transform = new JoinTransform(); |
|
61 |
transform.initialize(featureStore, |
|
62 |
secondDataStoreWizard.getSelectedFeatureStore(), |
|
63 |
parametersWizard.getKeyAttr1(), |
|
64 |
parametersWizard.getkeyAtrr2(), |
|
65 |
parametersWizard.getPrefix1(), |
|
66 |
parametersWizard.getPrefix2(), |
|
67 |
parametersWizard.getAttributes() |
|
68 |
); |
|
69 |
return transform; |
|
70 |
} |
|
71 |
|
|
72 |
/* (non-Javadoc) |
|
73 |
* @see org.gvsig.app.daltransform.gui.FeatureTransformGui#getDescription() |
|
74 |
*/ |
|
75 |
public String getDescription() { |
|
76 |
return PluginServices.getText(this, "join_description"); |
|
77 |
} |
|
78 |
|
|
79 |
/* (non-Javadoc) |
|
80 |
* @see org.gvsig.app.daltransform.gui.FeatureTransformGui#createPanels(org.gvsig.app.daltransform.gui.FeatureTransformWizardModel) |
|
81 |
*/ |
|
82 |
public List<DataTransformWizardPanel> createPanels() { |
|
83 |
if (panels == null){ |
|
84 |
parametersWizard = new SelectParametersWizardPanel(); |
|
85 |
secondDataStoreWizard = new SelectSecondDataStoreWizardPanel(parametersWizard); |
|
86 |
panels = new ArrayList<DataTransformWizardPanel>(); |
|
87 |
panels.add(secondDataStoreWizard); |
|
88 |
panels.add(parametersWizard); |
|
89 |
} |
|
90 |
return panels; |
|
91 |
} |
|
92 |
|
|
93 |
/* (non-Javadoc) |
|
94 |
* @see org.gvsig.app.daltransform.gui.FeatureTransformGui#getName() |
|
95 |
*/ |
|
96 |
public String getName() { |
|
97 |
return PluginServices.getText(this, "join_name"); |
|
98 |
} |
|
99 |
|
|
100 |
/* (non-Javadoc) |
|
101 |
* @see org.gvsig.app.daltransform.gui.DataTransformGui#getMinDimension() |
|
102 |
*/ |
|
103 |
public Dimension getMinDimension() { |
|
104 |
// TODO Auto-generated method stub |
|
105 |
return null; |
|
106 |
} |
|
107 |
|
|
108 |
public boolean accept(FeatureStore featureStore) { |
|
109 |
return true; |
|
110 |
} |
|
111 |
} |
|
112 |
|
|
0 | 113 |
tags/v_2_0_0_Build_2043/extensions/extDalTransformJoin/extDalTransformJoin/src/org/gvsig/app/join/daltransform/SelectSecondDataStoreWizardPanel.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2009 {Iver T.I.} {Task} |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.app.join.daltransform; |
|
29 |
|
|
30 |
import org.gvsig.andami.PluginServices; |
|
31 |
import org.gvsig.daltransform.swing.impl.SelectDataStoreWizardPanel; |
|
32 |
import org.gvsig.fmap.dal.exception.DataException; |
|
33 |
|
|
34 |
|
|
35 |
/** |
|
36 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
37 |
*/ |
|
38 |
public class SelectSecondDataStoreWizardPanel extends SelectDataStoreWizardPanel{ |
|
39 |
private SelectParametersWizardPanel selectParametersWizardPanel = null; |
|
40 |
|
|
41 |
/** |
|
42 |
* @param featureTransformWizardModel |
|
43 |
*/ |
|
44 |
public SelectSecondDataStoreWizardPanel(SelectParametersWizardPanel selectParametersWizardPanel) { |
|
45 |
super(); |
|
46 |
this.selectParametersWizardPanel = selectParametersWizardPanel; |
|
47 |
} |
|
48 |
|
|
49 |
/* (non-Javadoc) |
|
50 |
* @see org.gvsig.app.daltransform.gui.SelectDataStoreWizard#getPanelTitle() |
|
51 |
*/ |
|
52 |
public String getPanelTitle() { |
|
53 |
return PluginServices.getText(this, "transform_second_datastore_selection"); |
|
54 |
} |
|
55 |
|
|
56 |
/* (non-Javadoc) |
|
57 |
* @see jwizardcomponent.JWizardPanel#next() |
|
58 |
*/ |
|
59 |
public void nextPanel() { |
|
60 |
try { |
|
61 |
selectParametersWizardPanel.updateFeatureStores(getSelectedFeatureStore()); |
|
62 |
} catch (DataException e) { |
|
63 |
logger.error("Error updating the params panel", e); |
|
64 |
} |
|
65 |
|
|
66 |
} |
|
67 |
|
|
68 |
/* (non-Javadoc) |
|
69 |
* @see org.gvsig.app.daltransform.gui.SelectDataStoreWizard#update() |
|
70 |
*/ |
|
71 |
public void updatePanel() { |
|
72 |
removeFeatureStore(getDataTransformWizard().getFeatureStore()); |
|
73 |
super.updatePanel(); |
|
74 |
} |
|
75 |
|
|
76 |
|
|
77 |
} |
|
78 |
|
|
0 | 79 |
tags/v_2_0_0_Build_2043/extensions/extDalTransformJoin/extDalTransformJoin/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
|
|
3 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|
4 |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 |
|
5 |
http://maven.apache.org/maven-v4_0_0.xsd"> |
|
6 |
|
|
7 |
<modelVersion>4.0.0</modelVersion> |
|
8 |
<artifactId>org.gvsig.app.join</artifactId> |
|
9 |
<packaging>jar</packaging> |
|
10 |
<version>2.0-SNAPSHOT</version> |
|
11 |
<name>Transformation: Join</name> |
|
12 |
<description>Allow join 2 tables by a common field and removing join.</description> |
|
13 |
<parent> |
|
14 |
<groupId>org.gvsig</groupId> |
|
15 |
<artifactId>gvsig-base-extension-pom</artifactId> |
|
16 |
<version>2.0-SNAPSHOT</version> |
|
17 |
</parent> |
|
18 |
<dependencies> |
|
19 |
<dependency> |
|
20 |
<groupId>org.gvsig</groupId> |
|
21 |
<artifactId>org.gvsig.daltransform.app.mainplugin</artifactId> |
|
22 |
<version>2.0-SNAPSHOT</version> |
|
23 |
<scope>compile</scope> |
|
24 |
</dependency> |
|
25 |
<dependency> |
|
26 |
<groupId>org.gvsig</groupId> |
|
27 |
<artifactId>org.gvsig.andami</artifactId> |
|
28 |
<scope>compile</scope> |
|
29 |
</dependency> |
|
30 |
<dependency> |
|
31 |
<groupId>org.gvsig</groupId> |
|
32 |
<artifactId>org.gvsig.app</artifactId> |
|
33 |
<version>2.0-SNAPSHOT</version> |
|
34 |
<scope>compile</scope> |
|
35 |
</dependency> |
|
36 |
<dependency> |
|
37 |
<groupId>org.gvsig</groupId> |
|
38 |
<artifactId>org.gvsig.app.document.table.app.mainplugin</artifactId> |
|
39 |
<version>2.0.0-SNAPSHOT</version> |
|
40 |
<scope>compile</scope> |
|
41 |
</dependency> |
|
42 |
<dependency> |
|
43 |
<groupId>org.gvsig</groupId> |
|
44 |
<artifactId>org.gvsig.fmap.dal</artifactId> |
|
45 |
<scope>compile</scope> |
|
46 |
</dependency> |
|
47 |
<dependency> |
|
48 |
<groupId>org.gvsig</groupId> |
|
49 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
50 |
<scope>compile</scope> |
|
51 |
</dependency> |
|
52 |
<dependency> |
|
53 |
<groupId>org.gvsig</groupId> |
|
54 |
<artifactId>org.gvsig.fmap.mapcontext</artifactId> |
|
55 |
<scope>compile</scope> |
|
56 |
</dependency> |
|
57 |
<dependency> |
|
58 |
<groupId>org.gvsig</groupId> |
|
59 |
<artifactId>org.gvsig.projection</artifactId> |
|
60 |
<scope>compile</scope> |
|
61 |
</dependency> |
|
62 |
<dependency> |
|
63 |
<groupId>org.gvsig</groupId> |
|
64 |
<artifactId>org.gvsig.metadata.lib.basic.api</artifactId> |
|
65 |
<scope>compile</scope> |
|
66 |
</dependency> |
|
67 |
<dependency> |
|
68 |
<groupId>org.gvsig</groupId> |
|
69 |
<artifactId>org.gvsig.fmap.control</artifactId> |
|
70 |
<scope>compile</scope> |
|
71 |
</dependency> |
|
72 |
<dependency> |
|
73 |
<groupId>org.gvsig</groupId> |
|
74 |
<artifactId>org.gvsig.fmap.geometry</artifactId> |
|
75 |
<scope>compile</scope> |
|
76 |
</dependency> |
|
77 |
<dependency> |
|
78 |
<groupId>org.gvsig</groupId> |
|
79 |
<artifactId>org.gvsig.utils</artifactId> |
|
80 |
<scope>compile</scope> |
|
81 |
</dependency> |
|
82 |
<dependency> |
|
83 |
<groupId>jwizardcomponent</groupId> |
|
84 |
<artifactId>jwizardcomponent</artifactId> |
|
85 |
<scope>compile</scope> |
|
86 |
</dependency> |
|
87 |
<dependency> |
|
88 |
<groupId>org.slf4j</groupId> |
|
89 |
<artifactId>slf4j-api</artifactId> |
|
90 |
<scope>compile</scope> |
|
91 |
</dependency> |
|
92 |
<dependency> |
|
93 |
<groupId>org.gvsig</groupId> |
|
94 |
<artifactId>org.gvsig.timesupport.lib.impl</artifactId> |
|
95 |
<scope>runtime</scope> |
|
96 |
</dependency> |
|
97 |
<!--TEST--> |
|
98 |
<dependency> |
|
99 |
<groupId>org.gvsig</groupId> |
|
100 |
<artifactId>org.gvsig.daltransform.app.mainplugin</artifactId> |
|
101 |
<version>2.0-SNAPSHOT</version> |
|
102 |
<type>test-jar</type> |
|
103 |
<scope>test</scope> |
|
104 |
</dependency> |
|
105 |
<dependency> |
|
106 |
<groupId>org.gvsig</groupId> |
|
107 |
<artifactId>org.gvsig.fmap.dal</artifactId> |
|
108 |
<classifier>tests</classifier> |
|
109 |
<scope>test</scope> |
|
110 |
</dependency> |
|
111 |
<dependency> |
|
112 |
<groupId>org.gvsig</groupId> |
|
113 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
114 |
<type>test-jar</type> |
|
115 |
<scope>test</scope> |
|
116 |
</dependency> |
|
117 |
</dependencies> |
|
118 |
<build> |
|
119 |
<sourceDirectory>src</sourceDirectory> |
|
120 |
<testSourceDirectory>src-test</testSourceDirectory> |
|
121 |
<resources> |
|
122 |
<resource> |
|
123 |
<directory>${basedir}/resources</directory> |
|
124 |
</resource> |
|
125 |
</resources> |
|
126 |
<plugins> |
|
127 |
<!-- TODO: MAKE TESTS WORK AND REMOVE THIS OPTION --> |
|
128 |
<plugin> |
|
129 |
<groupId>org.apache.maven.plugins</groupId> |
|
130 |
<artifactId>maven-surefire-plugin</artifactId> |
|
131 |
<configuration> |
|
132 |
<skipTests>true</skipTests> |
|
133 |
</configuration> |
|
134 |
</plugin> |
|
135 |
</plugins> |
|
136 |
</build> |
|
137 |
|
|
138 |
<properties> |
|
139 |
<build-dir>${basedir}/../build</build-dir> |
|
140 |
<eclipse.project.name>extDalTransformJoin</eclipse.project.name> |
|
141 |
<package.info.dependencies>required: org.gvsig.daltransform.app.mainplugin -ge 2</package.info.dependencies> |
|
142 |
<package.info.state>alpha3</package.info.state> |
|
143 |
</properties> |
|
144 |
</project> |
|
0 | 145 |
tags/v_2_0_0_Build_2043/extensions/extDalTransformJoin/extDalTransformJoin/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.app.join.JoinTransformLibrary |
tags/v_2_0_0_Build_2043/extensions/extDalTransformJoin/extDalTransformJoin/distribution/distribution.xml | ||
---|---|---|
1 |
<assembly> |
|
2 |
<id>distribution</id> |
|
3 |
<formats> |
|
4 |
<format>dir</format> |
|
5 |
</formats> |
|
6 |
<fileSets> |
|
7 |
<fileSet> |
|
8 |
<directory>config</directory> |
|
9 |
<outputDirectory>${extension.install.dir.name}</outputDirectory> |
|
10 |
</fileSet> |
|
11 |
<fileSet> |
|
12 |
<directory>images</directory> |
|
13 |
<outputDirectory>/${extension.install.dir.name}/images</outputDirectory> |
|
14 |
</fileSet> |
|
15 |
</fileSets> |
|
16 |
<files> |
|
17 |
<file> |
|
18 |
<source>package.info</source> |
|
19 |
<outputDirectory>${extension.install.dir.name} |
|
20 |
</outputDirectory> |
|
21 |
</file> |
|
22 |
</files> |
|
23 |
<dependencySets> |
|
24 |
<dependencySet> |
|
25 |
<outputDirectory>${extension.install.dir.name}/${library-dir} |
|
26 |
</outputDirectory> |
|
27 |
<includes> |
|
28 |
<include>org.gvsig:org.gvsig.app.join</include> |
|
29 |
</includes> |
|
30 |
</dependencySet> |
|
31 |
</dependencySets> |
|
32 |
</assembly> |
|
33 |
|
|
0 | 34 |
tags/v_2_0_0_Build_2043/extensions/extDalTransformJoin/extDalTransformJoin/buildNumber.properties | ||
---|---|---|
1 |
#maven.buildNumber.plugin properties file |
|
2 |
#Thu Jan 12 18:42:31 CET 2012 |
|
3 |
buildNumber=2035 |
tags/v_2_0_0_Build_2043/extensions/extDalTransformJoin/extDalTransformJoin/src-test/org/gvsig/app/join/dal/feature/JoinTransformTest.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2009 {Iver T.I.} {Task} |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.app.join.dal.feature; |
|
29 |
|
|
30 |
import java.io.File; |
|
31 |
import java.net.URL; |
|
32 |
import java.util.ArrayList; |
|
33 |
import java.util.Iterator; |
|
34 |
|
|
35 |
import org.gvsig.daltransform.BaseFeatureStoreTransform; |
|
36 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
37 |
import org.gvsig.fmap.dal.exception.DataException; |
|
38 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
39 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
40 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
41 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
42 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
43 |
import org.gvsig.fmap.dal.feature.FeatureStoreTransform; |
|
44 |
import org.gvsig.fmap.dal.store.dbf.DBFStoreParameters; |
|
45 |
import org.gvsig.fmap.dal.store.dbf.DBFStoreProvider; |
|
46 |
|
|
47 |
/** |
|
48 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
49 |
*/ |
|
50 |
public class JoinTransformTest extends BaseFeatureStoreTransform { |
|
51 |
private final File dbf = new File("src-test/org/gvsig/app/join/dal/feature/data/join.dbf"); |
|
52 |
|
|
53 |
@Override |
|
54 |
public DataStoreParameters getDefaultDataStoreParameters() |
|
55 |
throws DataException { |
|
56 |
DataStoreParameters dbfParameters = null; |
|
57 |
dbfParameters = dataManager.createStoreParameters(DBFStoreProvider.NAME); |
|
58 |
|
|
59 |
dbfParameters.setDynValue("dbfFile", dbf); |
|
60 |
|
|
61 |
return dbfParameters; |
|
62 |
} |
|
63 |
|
|
64 |
@Override |
|
65 |
public FeatureStoreTransform getFeatureStoreTransform() |
|
66 |
throws DataException, ValidateDataParametersException { |
|
67 |
URL url = JoinTransformTest.class.getResource("data/events.dbf"); |
|
68 |
|
|
69 |
FeatureStore store = (FeatureStore) dataManager.createStore(this |
|
70 |
.getDefaultDataStoreParameters()); |
|
71 |
|
|
72 |
FeatureStore store2 = (FeatureStore) dataManager.createStore(this |
|
73 |
.getDefaultDataStoreParameters2()); |
|
74 |
|
|
75 |
JoinTransform transform = new JoinTransform(); |
|
76 |
|
|
77 |
ArrayList names = new ArrayList(); |
|
78 |
Iterator iter = store2.getDefaultFeatureType().iterator();// <FeatureAttributeDescriptor> |
|
79 |
while (iter.hasNext()) { |
|
80 |
names.add(((FeatureAttributeDescriptor) iter.next()).getName()); |
|
81 |
} |
|
82 |
|
|
83 |
transform.initialize(store, store2, |
|
84 |
"NOMBRE", "NOMBRE", |
|
85 |
null, null, |
|
86 |
(String[]) names.toArray(new String[0])); |
|
87 |
return transform; |
|
88 |
} |
|
89 |
|
|
90 |
private DataStoreParameters getDefaultDataStoreParameters2() throws InitializeException, ProviderNotRegisteredException{ |
|
91 |
DBFStoreParameters dbfParameters = null; |
|
92 |
dbfParameters = (DBFStoreParameters) dataManager |
|
93 |
.createStoreParameters(DBFStoreProvider.NAME); |
|
94 |
|
|
95 |
dbfParameters.setFile(dbf); |
|
96 |
|
|
97 |
return dbfParameters; |
|
98 |
} |
|
99 |
|
|
100 |
} |
|
101 |
|
Also available in: Unified diff