Revision 39345

View differences:

tags/v2_0_0_Build_2060/extensions/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 javax.swing.JOptionPane;
35

  
36
import org.slf4j.Logger;
37
import org.slf4j.LoggerFactory;
38

  
39
import org.gvsig.andami.PluginServices;
40
import org.gvsig.andami.ui.mdiManager.IWindow;
41
import org.gvsig.app.ApplicationLocator;
42
import org.gvsig.app.join.dal.feature.JoinTransform;
43
import org.gvsig.daltransform.swing.DataTransformGui;
44
import org.gvsig.daltransform.swing.DataTransformWizardPanel;
45
import org.gvsig.fmap.dal.exception.DataException;
46
import org.gvsig.fmap.dal.feature.FeatureStore;
47
import org.gvsig.fmap.dal.feature.FeatureStoreTransform;
48
import org.gvsig.fmap.mapcontrol.dal.feature.swing.FeatureTypesTablePanel;
49
import org.gvsig.fmap.mapcontrol.dal.feature.swing.table.ConfigurableFeatureTableModel;
50
import org.gvsig.i18n.Messages;
51

  
52

  
53
/**
54
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
55
 */
56
public class JoinTransformGui implements DataTransformGui {
57
    
58
    private static Logger logger = LoggerFactory.getLogger(JoinTransformGui.class);
59
    
60
	private SelectSecondDataStoreWizardPanel secondDataStoreWizard = null;
61
	private SelectParametersWizardPanel parametersWizard = null;
62
	private List<DataTransformWizardPanel> panels = null;	
63
	
64
	public JoinTransformGui() {
65
		super();			
66
	}
67
	
68
	/* (non-Javadoc)
69
	 * @see org.gvsig.app.daltransform.gui.FeatureTransformGui#createFeatureStoreTransform(org.gvsig.fmap.dal.feature.FeatureStore)
70
	 */
71
	public FeatureStoreTransform createFeatureStoreTransform(
72
			FeatureStore featureStore) throws DataException {
73
		JoinTransform transform = new JoinTransform();
74
		transform.initialize(featureStore,
75
				secondDataStoreWizard.getSelectedFeatureStore(),
76
				parametersWizard.getKeyAttr1(),
77
				parametersWizard.getkeyAtrr2(),
78
				parametersWizard.getPrefix1(),
79
				parametersWizard.getPrefix2(),
80
				parametersWizard.getAttributes()
81
		);
82
		return transform;
83
	}
84

  
85

  
86

  
87
    /* (non-Javadoc)
88
	 * @see org.gvsig.app.daltransform.gui.FeatureTransformGui#getDescription()
89
	 */
90
	public String getDescription() {
91
		return PluginServices.getText(this, "join_description");
92
	}
93

  
94
	/* (non-Javadoc)
95
	 * @see org.gvsig.app.daltransform.gui.FeatureTransformGui#createPanels(org.gvsig.app.daltransform.gui.FeatureTransformWizardModel)
96
	 */
97
	public List<DataTransformWizardPanel> createPanels() {
98
		if (panels == null){
99
			parametersWizard = new SelectParametersWizardPanel();
100
			secondDataStoreWizard = new SelectSecondDataStoreWizardPanel(parametersWizard);
101
			panels = new ArrayList<DataTransformWizardPanel>();
102
			panels.add(secondDataStoreWizard);
103
			panels.add(parametersWizard);				
104
		}	
105
		return panels;		
106
	}
107

  
108
	/* (non-Javadoc)
109
	 * @see org.gvsig.app.daltransform.gui.FeatureTransformGui#getName()
110
	 */
111
	public String getName() {
112
		return PluginServices.getText(this, "join_name");
113
	}
114

  
115
	/* (non-Javadoc)
116
	 * @see org.gvsig.app.daltransform.gui.DataTransformGui#getMinDimension()
117
	 */
118
	public Dimension getMinDimension() {
119
		// TODO Auto-generated method stub
120
		return null;
121
	}
122

  
123
    public boolean accept(FeatureStore featureStore) {        
124
        return true;
125
    }
126

  
127
   
128
    
129
    public String toString() {
130
        return getName();
131
    }
132
}
133

  
0 134

  
tags/v2_0_0_Build_2060/extensions/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/v2_0_0_Build_2060/extensions/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 java.awt.event.ActionEvent;
31
import java.awt.event.ActionListener;
32
import java.util.ArrayList;
33

  
34
import javax.swing.JOptionPane;
35

  
36
import org.slf4j.Logger;
37
import org.slf4j.LoggerFactory;
38

  
39
import org.gvsig.andami.PluginServices;
40
import org.gvsig.app.ApplicationLocator;
41
import org.gvsig.app.join.utils.TransformUtils;
42
import org.gvsig.daltransform.swing.DataTransformWizardPanel;
43
import org.gvsig.daltransform.swing.impl.AbstractDataTransformWizardPanel;
44
import org.gvsig.daltransform.swing.impl.components.FeatureTypeAttributesCombo;
45
import org.gvsig.daltransform.swing.impl.components.FeatureTypeAttributesList;
46
import org.gvsig.fmap.dal.exception.DataException;
47
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
48
import org.gvsig.fmap.dal.feature.FeatureStore;
49
import org.gvsig.fmap.dal.feature.FeatureType;
50
import org.gvsig.i18n.Messages;
51

  
52

  
53
/**
54
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
55
 */
56
public class SelectParametersWizardPanel extends AbstractDataTransformWizardPanel
57
implements DataTransformWizardPanel, ActionListener{
58
    
59
    private static Logger logger =
60
        LoggerFactory.getLogger(SelectParametersWizardPanel.class);
61
    
62
	private javax.swing.JLabel attributesLabel;
63
	private FeatureTypeAttributesList attributesList;
64
	private javax.swing.JScrollPane attributesScroll;
65
	private FeatureTypeAttributesCombo key1Combo;
66
	private javax.swing.JLabel key1Label;
67
	private FeatureTypeAttributesCombo key2_Combo;
68
	private javax.swing.JLabel key2Label;
69
	private javax.swing.JLabel prefix1Label;
70
	private javax.swing.JTextField prefix1Text;
71
	private javax.swing.JLabel prefix2Label;
72
	private javax.swing.JTextField prefix2Text; 
73
	
74
	private FeatureStore secondFeatStore = null;
75

  
76
	/**
77
	 * @param featureTransformWizardModel
78
	 */
79
	public SelectParametersWizardPanel() {
80
		super();	
81
		initComponents();
82
		initLabels();
83
	}
84
	
85
	private void initLabels(){
86
		key1Label.setText(PluginServices.getText(this,"join_first_key"));
87
		key2Label.setText(PluginServices.getText(this,"join_second_key"));
88
		prefix1Label.setText(PluginServices.getText(this,"join_first_prefix"));
89
		prefix2Label.setText(PluginServices.getText(this,"join_second_prefix"));
90
		attributesLabel.setText(PluginServices.getText(this,"join_select_attributes"));
91
	}
92

  
93
	private void initComponents() {
94
		java.awt.GridBagConstraints gridBagConstraints;
95

  
96
		prefix2Text = new javax.swing.JTextField();
97
		key2_Combo = new FeatureTypeAttributesCombo();
98
		prefix1Text = new javax.swing.JTextField();
99
		key1Label = new javax.swing.JLabel();
100
		
101
		key1Combo = new FeatureTypeAttributesCombo();
102
		// listen to changes in first combo
103
		// we'll update second combo leaving
104
		// fields of same type
105
		key1Combo.addActionListener(this);
106
		
107
		key2Label = new javax.swing.JLabel();
108
		prefix1Label = new javax.swing.JLabel();
109
		prefix2Label = new javax.swing.JLabel();
110
		attributesLabel = new javax.swing.JLabel();
111
		attributesScroll = new javax.swing.JScrollPane();
112
		attributesList = new FeatureTypeAttributesList();
113

  
114
		setLayout(new java.awt.GridBagLayout());
115
		gridBagConstraints = new java.awt.GridBagConstraints();
116
		gridBagConstraints.gridx = 0;
117
		gridBagConstraints.gridy = 7;
118
		gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
119
		gridBagConstraints.weightx = 1.0;
120
		gridBagConstraints.insets = new java.awt.Insets(2, 2, 3, 2);
121
		add(prefix2Text, gridBagConstraints);
122

  
123
		gridBagConstraints = new java.awt.GridBagConstraints();
124
		gridBagConstraints.gridx = 0;
125
		gridBagConstraints.gridy = 3;
126
		gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
127
		gridBagConstraints.weightx = 1.0;
128
		gridBagConstraints.insets = new java.awt.Insets(2, 2, 3, 2);
129
		add(key2_Combo, gridBagConstraints);
130
		gridBagConstraints = new java.awt.GridBagConstraints();
131
		gridBagConstraints.gridx = 0;
132
		gridBagConstraints.gridy = 5;
133
		gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
134
		gridBagConstraints.weightx = 1.0;
135
		gridBagConstraints.insets = new java.awt.Insets(2, 2, 3, 2);
136
		add(prefix1Text, gridBagConstraints);
137

  
138
		key1Label.setText("jLabel1");
139
		gridBagConstraints = new java.awt.GridBagConstraints();
140
		gridBagConstraints.gridx = 0;
141
		gridBagConstraints.gridy = 0;
142
		gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
143
		gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
144
		add(key1Label, gridBagConstraints);
145

  
146
		gridBagConstraints = new java.awt.GridBagConstraints();
147
		gridBagConstraints.gridx = 0;
148
		gridBagConstraints.gridy = 1;
149
		gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
150
		gridBagConstraints.weightx = 1.0;
151
		gridBagConstraints.insets = new java.awt.Insets(2, 2, 3, 2);
152
		add(key1Combo, gridBagConstraints);
153

  
154
		key2Label.setText("jLabel2");
155
		gridBagConstraints = new java.awt.GridBagConstraints();
156
		gridBagConstraints.gridx = 0;
157
		gridBagConstraints.gridy = 2;
158
		gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
159
		gridBagConstraints.insets = new java.awt.Insets(3, 2, 2, 2);
160
		add(key2Label, gridBagConstraints);
161

  
162
		prefix1Label.setText("jLabel1");
163
		gridBagConstraints = new java.awt.GridBagConstraints();
164
		gridBagConstraints.gridx = 0;
165
		gridBagConstraints.gridy = 4;
166
		gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
167
		gridBagConstraints.insets = new java.awt.Insets(3, 2, 2, 2);
168
		add(prefix1Label, gridBagConstraints);
169

  
170
		prefix2Label.setText("jLabel2");
171
		gridBagConstraints = new java.awt.GridBagConstraints();
172
		gridBagConstraints.gridx = 0;
173
		gridBagConstraints.gridy = 6;
174
		gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
175
		gridBagConstraints.insets = new java.awt.Insets(3, 2, 2, 2);
176
		add(prefix2Label, gridBagConstraints);
177

  
178
		attributesLabel.setText("attributesLabel");
179
		gridBagConstraints = new java.awt.GridBagConstraints();
180
		gridBagConstraints.gridx = 0;
181
		gridBagConstraints.gridy = 8;
182
		gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
183
		gridBagConstraints.insets = new java.awt.Insets(3, 2, 2, 2);
184
		add(attributesLabel, gridBagConstraints);
185

  
186
		attributesScroll.setViewportView(attributesList);
187

  
188
		gridBagConstraints = new java.awt.GridBagConstraints();
189
		gridBagConstraints.gridx = 0;
190
		gridBagConstraints.gridy = 9;
191
		gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
192
		gridBagConstraints.weightx = 1.0;
193
		gridBagConstraints.weighty = 1.0;
194
		gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
195
		add(attributesScroll, gridBagConstraints);
196
	}
197

  
198
	/**
199
	 * @return
200
	 */
201
	public String getKeyAttr1() {
202
		return key1Combo.getSelectedFeatureAttributeDescriptor().getName();
203
	}
204

  
205
	/**
206
	 * @return
207
	 */
208
	public String getkeyAtrr2() {
209
		return key2_Combo.getSelectedFeatureAttributeDescriptor().getName();
210
	}
211

  
212
	/**
213
	 * @return
214
	 */
215
	public String getPrefix1() {
216
		return prefix1Text.getText();
217
	}
218

  
219
	/**
220
	 * @return
221
	 */
222
	public String getPrefix2() {
223
		return prefix2Text.getText();
224
	}
225

  
226
	/**
227
	 * @return
228
	 */
229
	public String[] getAttributes() {
230
		return attributesList.getAttributesName();
231
	}
232
	
233
	/**
234
	 * @param selectedFeatureStore
235
	 * @throws DataException 
236
	 */
237
	public void updateFeatureStores(FeatureStore selectedFeatureStore) throws DataException {
238
	    secondFeatStore = selectedFeatureStore;
239
		key1Combo.addFeatureAttributes(getFeatureStore().getDefaultFeatureType());
240
		attributesList.addFeatureAttributes(selectedFeatureStore.getDefaultFeatureType());
241
		
242
		if (key1Combo.getItemCount() == 0) {
243
		    
244
            String _msg =
245
                Messages.getText("_First_table_has_no_fields");
246
            String _tit = Messages.getText("_Join");
247
            
248
            JOptionPane.showMessageDialog(
249
                this, _msg, _tit,
250
                JOptionPane.ERROR_MESSAGE);
251
            
252
		    getDataTransformWizard().setApplicable(false);
253
        } else {
254
            key1Combo.setSelectedIndex(0);
255
		}
256
	}
257

  
258

  
259
	/**
260
	 * Listen to changes in first combo box (key1)
261
	 */
262
    public void actionPerformed(ActionEvent e) {
263
        
264
        Object src = e.getSource();
265
        if (src == key1Combo
266
            && key1Combo != null
267
            && key2_Combo != null
268
            && secondFeatStore != null) {
269
            
270
            FeatureAttributeDescriptor att =
271
                key1Combo.getSelectedFeatureAttributeDescriptor();
272
            if (att != null) {
273
                
274
                int the_type = att.getType();
275
                key2_Combo.removeAllItems();
276
                FeatureType ft = null;
277
                
278
                try {
279
                    ft = secondFeatStore.getDefaultFeatureType();
280
                } catch (DataException de) {
281
                    logger.info("While getting feat type: " + de.getMessage());
282
                    getDataTransformWizard().setApplicable(false);
283
                    ApplicationLocator.getManager().message(
284
                        Messages.getText("_Error_getting_attributes"),
285
                        JOptionPane.ERROR_MESSAGE);
286
                    return;
287
                }
288
                
289
                ArrayList<Integer> comparable_types =
290
                    TransformUtils.getComparableDataTypes(ft, the_type);
291
                
292
                if (key2_Combo.addFeatureAttributes(ft, comparable_types) == 0) {
293
                    getDataTransformWizard().setApplicable(false);
294
                    
295
                    String _msg =
296
                        Messages.getText("_No_compatible_field_in_second_table");
297
                    String _tit = Messages.getText("_Join");
298
                    
299
                    JOptionPane.showMessageDialog(
300
                        this, _msg, _tit,
301
                        JOptionPane.ERROR_MESSAGE);
302
                } else {
303
                    getDataTransformWizard().setApplicable(true);
304
                    // JOptionPane.showMessageDialog(this, "(2) OK !!");
305
                }
306
            }
307
        }
308
        
309
    }
310
}
311

  
0 312

  
tags/v2_0_0_Build_2060/extensions/extDalTransformJoin/src/org/gvsig/app/join/RemoveTableUnion.java
1
package org.gvsig.app.join;
2

  
3
import org.gvsig.andami.IconThemeHelper;
4
import org.gvsig.andami.PluginServices;
5
import org.gvsig.andami.plugins.Extension;
6
import org.gvsig.andami.ui.mdiManager.IWindow;
7
import org.gvsig.app.join.dal.feature.JoinTransform;
8
import org.gvsig.app.project.documents.table.TableDocument;
9
import org.gvsig.app.project.documents.table.gui.FeatureTableDocumentPanel;
10
import org.gvsig.fmap.dal.feature.FeatureStore;
11
import org.gvsig.fmap.dal.feature.FeatureStoreTransform;
12
import org.gvsig.fmap.dal.feature.FeatureStoreTransforms;
13

  
14

  
15
/**
16
 * @author Fernando Gonz?lez Cort?s
17
 */
18
public class RemoveTableUnion extends Extension{
19

  
20
	/**
21
	 * @see org.gvsig.andami.plugins.IExtension#initialize()
22
	 */
23
	public void initialize() {
24
		IconThemeHelper.registerIcon("action", "table-remove-join", this);
25
	}
26

  
27
	/**
28
	 * @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
29
	 */
30
	public void execute(String actionCommand) {
31
		if( "table-remove-join".equalsIgnoreCase(actionCommand)) {
32
			FeatureTableDocumentPanel t = (FeatureTableDocumentPanel) PluginServices.getMDIManager().getActiveWindow();
33
			TableDocument pt = t.getModel();
34
			FeatureStore fs = pt.getStore();
35
			this.removeJoinTransfor(fs);
36
	
37
			//		TODO
38
			//		if (fs instanceof JoinFeatureStore) {
39
			//			DataManager dm = DALLocator.getDataManager();
40
			//			DataStoreParameters originalParams = ((JoinFeatureStoreParameters) fs
41
			//					.getParameters()).getStorePrimary();
42
			//			FeatureStore original = null;
43
			//			try {
44
			//				original = (FeatureStore) dm.createStore(originalParams);
45
			//			} catch (InitializeException e) {
46
			//				NotificationManager.addError(e.getMessage(), e);
47
			//				return;
48
			//			}
49
			//
50
			//			pt.setStore(original);
51
			//			try {
52
			//				fs.dispose();
53
			//			} catch (CloseException e) {
54
			//				NotificationManager.addError(e);
55
			//			}
56
			//			t.setModel(pt);
57
			//
58
			//		}
59
	
60
			//		t.clearSelectedFields();
61
			t.getModel().setModified(true);
62
		}
63
	}
64

  
65
	public void removeJoinTransfor(FeatureStore store) {
66
		FeatureStoreTransforms transforms = store.getTransforms();
67
		int size = transforms.size();
68
		if (size < 1) {
69
			return;
70
		}
71
		FeatureStoreTransform join = transforms.getTransform(size - 1);
72
		if (join instanceof JoinTransform) {
73
			transforms.remove(join);
74
		} else {
75
			return;
76
		}
77

  
78

  
79

  
80
	}
81

  
82
	public boolean hasJoinTransform(FeatureStore store) {
83

  
84
		FeatureStoreTransforms transforms = store.getTransforms();
85
		int size = transforms.size();
86
		if (size < 1) {
87
			return false;
88
		}
89
		return (transforms.getTransform(size - 1) instanceof JoinTransform);
90

  
91
	}
92

  
93
	/**
94
	 * @see org.gvsig.andami.plugins.IExtension#isEnabled()
95
	 */
96
	public boolean isEnabled() {
97
		IWindow v = PluginServices.getMDIManager().getActiveWindow();
98

  
99
		if (v == null) {
100
			return false;
101
		}
102

  
103
		if (v.getClass() == FeatureTableDocumentPanel.class) {
104
			FeatureTableDocumentPanel t = (FeatureTableDocumentPanel) v;
105
			// FIXME !!!! Asi se hacia antes
106
			//			if (t.getModel().getOriginal() != null){
107
			//				return true;
108
			//			}
109

  
110
			TableDocument pt = t.getModel();
111
			FeatureStore fs = pt.getStore();
112

  
113
			return this.hasJoinTransform(fs);
114
//			TODO
115
//			if (fs instanceof JoinFeatureStore) {
116
//				return true;
117
//			}
118

  
119
		}
120
		return false;
121
	}
122

  
123
	/**
124
	 * @see org.gvsig.andami.plugins.IExtension#isVisible()
125
	 */
126
	public boolean isVisible() {
127
		IWindow v = PluginServices.getMDIManager().getActiveWindow();
128

  
129
		if (v == null) {
130
			return false;
131
		}
132

  
133
		if (v instanceof FeatureTableDocumentPanel) {
134
			return true;
135
		} else {
136
			return false;
137
		}
138

  
139
	}
140

  
141
}
0 142

  
tags/v2_0_0_Build_2060/extensions/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 java.util.Locale;
31

  
32
import org.gvsig.app.join.dal.feature.JoinTransform;
33
import org.gvsig.app.join.daltransform.JoinTransformGui;
34
import org.gvsig.daltransform.DataTransformLibrary;
35
import org.gvsig.daltransform.DataTransformLocator;
36
import org.gvsig.daltransform.DataTransformManager;
37
import org.gvsig.fmap.dal.DALLibrary;
38
import org.gvsig.i18n.Messages;
39
import org.gvsig.tools.library.AbstractLibrary;
40
import org.gvsig.tools.library.LibraryException;
41
import org.gvsig.tools.locator.ReferenceNotRegisteredException;
42

  
43
/**
44
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
45
 */
46
public class JoinTransformLibrary extends AbstractLibrary {
47

  
48
    @Override
49
    public void doRegistration() {
50
        registerAsImplementationOf(JoinTransformLibrary.class);
51
        require(DALLibrary.class);
52
        require(DataTransformLibrary.class);
53

  
54
    }
55

  
56
	@Override
57
	protected void doInitialize() throws LibraryException {
58
		if (!Messages.hasLocales()) {
59
            Messages.addLocale(Locale.getDefault());
60
        }
61
        Messages.addResourceFamily("org.gvsig.app.join.i18n.text",
62
            JoinTransformLibrary.class.getClassLoader(),
63
            JoinTransformLibrary.class.getClass().getName());		
64
	}
65

  
66
	@Override
67
	protected void doPostInitialize() throws LibraryException {
68
		// Validate there is any implementation registered.
69
		DataTransformManager dataTransformManager = DataTransformLocator.getDataTransformManager();
70
		if (dataTransformManager == null) {
71
			throw new ReferenceNotRegisteredException(
72
					DataTransformLocator.DATA_TRANSFORM_MANAGER_NAME, DataTransformLocator.getInstance());
73
		}	
74
		dataTransformManager.registerDataTransform("join", JoinTransformGui.class);		
75
		
76
		JoinTransform.registerPersistent();
77
	}
78

  
79
}
80

  
0 81

  
tags/v2_0_0_Build_2060/extensions/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
        // keep index of geometry and att desc ==============
140
        int orig_geom_field_index =
141
            this.originalFeatureType.getDefaultGeometryAttributeIndex();
142
        FeatureAttributeDescriptor orig_geom_field_att = 
143
            this.originalFeatureType.getDefaultGeometryAttribute();
144
        
145
        // Create the feature type and copy the store 1 type        
146
        EditableFeatureType editableFeatureType = this.getFeatureStore().getDefaultFeatureType().getEditable();
147
        FeatureAttributeDescriptor[] featureAttributeDescriptors = editableFeatureType.getAttributeDescriptors();
148
        for (int i=0 ; i<featureAttributeDescriptors.length ; i++){ 
149
            editableFeatureType.remove(featureAttributeDescriptors[i].getName());           
150
        }    
151
        addFeatureType(editableFeatureType, featureAttributeDescriptors, prefix1, store1NamesMap);
152

  
153
        // =========== set the new geom field name and restore geometry values
154
        if (orig_geom_field_index >= 0) {
155
            EditableFeatureAttributeDescriptor ed_att = null;
156
            ed_att = (EditableFeatureAttributeDescriptor)
157
                editableFeatureType.getAttributeDescriptor(orig_geom_field_index);
158
            ed_att.setSRS(orig_geom_field_att.getSRS());
159
            ed_att.setObjectClass(orig_geom_field_att.getObjectClass());
160
            ed_att.setGeometryType(orig_geom_field_att.getGeomType());
161
            ed_att.setDefaultValue(orig_geom_field_att.getDefaultValue());
162

  
163
            String new_geom_field_name = ed_att.getName();
164
            editableFeatureType.setDefaultGeometryAttributeName(new_geom_field_name);
165
        }
166
        // =====================================================================
167

  
168
        // Add the store 2 fields    
169
        FeatureType featureType2 = store2.getDefaultFeatureType();
170

  
171
        // Add the fields       
172
        for (int i = 0; i < attrs.length; i++) {
173
            addFeatureType(editableFeatureType, featureType2.getAttributeDescriptor(attrs[i]), prefix2, store2NamesMap);        
174
        }
175

  
176
        if (this.store2NamesMap.containsKey(keyAttr2)) {
177
            this.attrsForQuery = this.attrs;
178
        } else {
179
            List<String> list = new ArrayList<String>(this.attrs.length + 1);
180
            list.addAll(Arrays.asList(this.attrs));
181
            list.add(keyAttr2);
182
            this.attrsForQuery = (String[]) list.toArray(new String[] {});
183
        }
184

  
185
        // assign calculated feature type as this transform's feature type
186
        FeatureType[] types = new FeatureType[] { editableFeatureType.getNotEditableCopy() };
187
        setFeatureTypes(Arrays.asList(types), types[0]);
188
    }
189

  
190
    private void addFeatureType(EditableFeatureType targetFeatureType, FeatureAttributeDescriptor[] featureAttributeDescriptors,
191
        String prefix, Map<String, String> storeMap) throws DataException{
192

  
193
        for (int i=0 ; i<featureAttributeDescriptors.length ; i++){         
194
            addFeatureType(targetFeatureType, featureAttributeDescriptors[i], prefix, storeMap);
195
        }
196
    }
197

  
198
    private void addFeatureType(EditableFeatureType targetFeatureType, FeatureAttributeDescriptor featureAttributeDescriptor,
199
        String prefix, Map<String, String> storeMap) throws DataException{
200

  
201
        String attName = featureAttributeDescriptor.getName();
202
        if ((prefix != null) && (!prefix.equals(""))){
203
            attName = prefix + "_" + attName;
204
        }
205

  
206
        // If an attribute already exists, calculate an alternate name and add it to our type
207
        int j = 0;
208
        while (targetFeatureType.getIndex(attName) >= 0) {
209
            attName = targetFeatureType.getAttributeDescriptor(attName).getName() + "_" + ++j;
210
        }
211

  
212
        EditableFeatureAttributeDescriptor editableFeatureAttributeDescriptor = 
213
            targetFeatureType.add(attName, featureAttributeDescriptor.getType(),
214
                featureAttributeDescriptor.getSize());
215
        editableFeatureAttributeDescriptor.setPrecision(featureAttributeDescriptor.getPrecision());
216

  
217
        // keep correspondence between original name and transformed name
218
        storeMap.put(featureAttributeDescriptor.getName(), attName);
219
    } 
220

  
221
    /**
222
     *
223
     *
224
     * @param source
225
     *
226
     * @param target
227
     *
228
     * @throws DataException
229
     */
230
    public void applyTransform(Feature source, EditableFeature target)
231
    throws DataException {
232

  
233
        // copy the data from store1 into the resulting feature
234
        this.copySourceToTarget(source, target);
235

  
236
        // ask store2 for the specified attributes, filtering by the key
237
        // attribute value
238
        // from the source feature
239
        JoinTransformEvaluator eval = this.getEvaluator();
240
        eval.updateValue(source.get(this.keyAttr1));
241

  
242
        FeatureQuery query = store2.createFeatureQuery();
243
        query.setAttributeNames(attrsForQuery);
244
        query.setFilter(eval);
245
        FeatureSet set = null;
246
        DisposableIterator itFeat = null;
247

  
248
        try {
249

  
250
            set = store2.getFeatureSet(query);
251
            // In this join implementation, we will take only the first matching
252
            // feature found in store2
253

  
254
            Feature feat;
255

  
256

  
257
            itFeat = set.iterator();
258
            if (itFeat.hasNext()) {
259
                feat = (Feature) itFeat.next();
260

  
261
                // copy all attributes from joined feature to target
262
                this.copyJoinToTarget(feat, target);
263
            }
264
        } finally {
265
            if (itFeat != null) {
266
                itFeat.dispose();
267
            }
268
            if (set != null) {
269
                set.dispose();
270
            }
271
        }
272
    }
273

  
274
    /**
275
     * @param feat
276
     * @param target
277
     */
278
    private void copyJoinToTarget(Feature join, EditableFeature target) {
279
        Iterator<Entry<String, String>> iter = store2NamesMap.entrySet()
280
        .iterator();
281
        Entry<String, String> entry;
282
        FeatureType trgType = target.getType();
283
        FeatureAttributeDescriptor attr;
284
        while (iter.hasNext()) {
285
            entry = iter.next();
286
            attr = trgType.getAttributeDescriptor((String) entry.getValue());
287
            if (attr != null) {
288
                target.set(attr.getIndex(), join.get((String) entry.getKey()));
289
            }
290
        }
291
    }
292

  
293
    /**
294
     * @param source
295
     * @param target
296
     */
297
    private void copySourceToTarget(Feature source, EditableFeature target) {
298
        FeatureAttributeDescriptor attr, attrTrg;
299
        FeatureType ftSrc = source.getType();
300
        FeatureType ftTrg = target.getType();
301

  
302

  
303
        for (int i = 0; i < source.getType().size(); i++) {
304
            attr = ftSrc.getAttributeDescriptor(i);
305
            attrTrg = ftTrg.getAttributeDescriptor(store1NamesMap.get(attr.getName()));
306
            if (attrTrg != null) {
307
                try {
308
                    target.set(attrTrg.getIndex(), source.get(i));
309
                } catch (IllegalArgumentException e) {
310
                    attrTrg = ftTrg.getAttributeDescriptor(attr.getName());
311
                    target.set(attrTrg.getIndex(), attrTrg.getDefaultValue());
312
                }
313

  
314
            }
315
        }
316

  
317
    }
318

  
319
    private JoinTransformEvaluator getEvaluator() {
320
        if (this.evaluator == null){
321
            this.evaluator = new JoinTransformEvaluator(keyAttr2);
322
        }
323
        return evaluator;
324

  
325
    }
326

  
327
    private class JoinTransformEvaluator implements Evaluator {
328

  
329
        private String attribute;
330
        private Object value;
331
        private String sql;
332
        private EvaluatorFieldsInfo info = null;
333

  
334
        //		private int attributeIndex;
335

  
336
        public JoinTransformEvaluator(String attribute) {
337
            this.attribute = attribute;
338
            this.value = null;
339
            this.info = new EvaluatorFieldsInfo();
340

  
341
            //			this.attributeIndex = attrIndex;
342
        }
343

  
344
        public void updateValue(Object value) {
345
            this.value = value;
346
            this.sql = this.attribute + "= '" + this.value + "'";
347
            this.info = new EvaluatorFieldsInfo();
348
            this.info.addMatchFieldValue(this.attribute, value);
349
        }
350

  
351
        public Object evaluate(EvaluatorData arg0) throws EvaluatorException {
352
            Object curValue = arg0.getDataValue(attribute);
353
            if (curValue == null) {
354
                return value == null;
355
            }
356
            return curValue.equals(value);
357
        }
358

  
359
        public String getSQL() {
360
            return this.sql;
361
        }
362

  
363
        public String getDescription() {
364
            return "Evaluates join transform match";
365
        }
366

  
367
        public String getName() {
368
            return "JoinTransformEvaluator";
369
        }
370

  
371
        public EvaluatorFieldsInfo getFieldsInfo() {
372
            return this.info;
373
        }
374

  
375
    }	
376

  
377
    @SuppressWarnings("unchecked")
378
    public FeatureType getSourceFeatureTypeFrom(FeatureType arg0) {
379
        return originalFeatureType;
380
    }
381

  
382
    public boolean isTransformsOriginalValues() {
383
        return false;
384
    }
385

  
386
    public static void registerPersistent() {
387
        PersistenceManager persistenceManager = ToolsLocator.getPersistenceManager();
388

  
389
        if( persistenceManager.getDefinition(AbstractFeatureStoreTransform.class) == null ) {
390
            AbstractFeatureStoreTransform.registerPersistent();
391
        }
392

  
393
        DynStruct definition = persistenceManager.getDefinition(PERSISTENCE_DEFINITION_NAME);
394

  
395
        if (definition == null){  
396
            definition = persistenceManager.addDefinition(
397
                JoinTransform.class,
398
                PERSISTENCE_DEFINITION_NAME,
399
                "JoinTransform Persistence definition",
400
                null, 
401
                null
402
            );
403
            definition.extend(PersistenceManager.PERSISTENCE_NAMESPACE,
404
                ABSTRACT_FEATURESTORE_DYNCLASS_NAME);
405

  
406
            definition.addDynFieldObject("store2").setClassOfValue(FeatureStore.class).setMandatory(true);
407
            definition.addDynFieldString("keyAttr1").setMandatory(true);
408
            definition.addDynFieldString("keyAttr2").setMandatory(true);
409
            definition.addDynFieldString("prefix1").setMandatory(false);
410
            definition.addDynFieldString("prefix2").setMandatory(false);
411
            definition.addDynFieldList("attrs").setClassOfItems(String.class).setMandatory(true);
412
        }
413
    }
414

  
415
    public void saveToState(PersistentState state) throws PersistenceException {
416
        super.saveToState(state);
417
        state.set("store2", this.store2);
418
        state.set("keyAttr1", this.keyAttr1);
419
        state.set("keyAttr2", this.keyAttr2);
420
        state.set("prefix1", this.prefix1);
421
        state.set("prefix2", this.prefix2);		
422
        state.set("attrs", this.attrs);
423
    }
424

  
425
    public void loadFromState(PersistentState state) throws PersistenceException {
426
        super.loadFromState(state);
427
        FeatureStore store2 = (FeatureStore) state.get("store2");
428
        String keyAttr1 = state.getString("keyAttr1");
429
        String keyAttr2 = state.getString("keyAttr2");
430
        String prefix1 =  state.getString("prefix1");
431
        String prefix2 =  state.getString("prefix2");
432
        String[] attrs = (String[]) state.getArray("attrs", String.class);
433
        try {
434
            initialize(getFeatureStore(), store2, keyAttr1, keyAttr2, prefix1, prefix2, attrs);
435
        } catch (DataException e) {
436
            throw new PersistenceException("Impossible to create the transform", e);
437
        }
438
    }
439

  
440
}
0 441

  
tags/v2_0_0_Build_2060/extensions/extDalTransformJoin/src/org/gvsig/app/join/utils/TransformUtils.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2012 gvSIG Association
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.app.join.utils;
24

  
25
import java.util.ArrayList;
26

  
27
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
28
import org.gvsig.fmap.dal.feature.FeatureType;
29
import org.gvsig.tools.dataTypes.DataTypes;
30

  
31

  
32
/**
33
 * {@link DataTypes}-related utility methods
34
 * 
35
 * @author jldominguez
36
 *
37
 */
38
public class TransformUtils {
39

  
40
    public static boolean isNumericType(int t) {
41
        return (t == DataTypes.DOUBLE
42
            || t == DataTypes.FLOAT
43
            || t == DataTypes.INT
44
            || t == DataTypes.LONG
45
            || t == DataTypes.BYTE);
46
    }
47
    
48
    public static boolean comparableTypes(int a, int b) {
49
        
50
        if (a == b) {
51
            return true;
52
        } else {
53
            return isNumericType(a) && isNumericType(b);
54
        }
55
        
56
    }
57
    /**
58
     * @param ft
59
     * @param the_type
60
     * @return
61
     */
62
    public static ArrayList<Integer> getComparableDataTypes(
63
        FeatureType ft,
64
        int the_type) {
65

  
66
        ArrayList<Integer> resp = new ArrayList<Integer>();
67
        
68
        FeatureAttributeDescriptor[] atts = ft.getAttributeDescriptors();
69
        int len = atts.length;
70
        for (int i=0; i<len; i++) {
71
            if (comparableTypes(the_type, atts[i].getType())) {
72
                resp.add(atts[i].getType());
73
            }
74
        }
75
        return resp;
76
    }
77

  
78
}
tags/v2_0_0_Build_2060/extensions/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.IconThemeHelper;
35
import org.gvsig.andami.PluginServices;
36
import org.gvsig.andami.ui.mdiManager.IWindow;
37
import org.gvsig.app.extension.TableOperations;
38
import org.gvsig.app.join.daltransform.JoinTransformGui;
39
import org.gvsig.daltransform.DataTransformLocator;
40
import org.gvsig.daltransform.swing.DataTransformWizard;
41

  
42

  
43
/**
44
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
45
 */
46
public class JoinToolExtension extends TableOperations {
47

  
48
	public void initialize() {
49
		IconThemeHelper.registerIcon("action", "table-create-join", this);
50
	}
51
	
52
	/**
53
	 * @see com.iver.mdiApp.plugins.IExtension#updateUI(java.lang.String)
54
	 */
55
	public void execute(String actionCommand) {
56
		if( "table-create-join".equalsIgnoreCase(actionCommand)) {
57
		    try {
58
		        DataTransformWizard dataTransformWizard = DataTransformLocator.getDataTransformManager().createWizard();
59
	            dataTransformWizard.setDataTransformGui(new JoinTransformGui());
60
		        PluginServices.getMDIManager().addWindow(dataTransformWizard.getWindow());
61
	        } catch (Exception e) {
62
	            
63
	            IWindow iw = PluginServices.getMDIManager().getActiveWindow();
64
	            JOptionPane.showInternalMessageDialog(
65
	                iw instanceof Component ? (Component) iw : null,
66
	                    PluginServices.getText(this, "transform_create_wizard_exception"),
67
	                    PluginServices.getText(this, "feature_transform"),
68
	                    JOptionPane.ERROR_MESSAGE);
69
	        }
70
		}
71
	}		
72
	
73
}
0 74

  
tags/v2_0_0_Build_2060/extensions/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.andami</artifactId>
22
            <scope>compile</scope>
23
		</dependency>
24
		<dependency>
25
			<groupId>org.gvsig</groupId>
26
			<artifactId>org.gvsig.app</artifactId>
27
			<version>2.0-SNAPSHOT</version>
28
            <scope>compile</scope>
29
		</dependency>		
30
		<dependency>
31
            <groupId>org.gvsig</groupId>
32
            <artifactId>org.gvsig.app.document.table.app.mainplugin</artifactId>
33
            <version>2.0.0-SNAPSHOT</version>
34
            <scope>compile</scope>
35
        </dependency>  
36
        <dependency>
37
            <groupId>org.gvsig</groupId>
38
            <artifactId>org.gvsig.daltransform.app.mainplugin</artifactId>
39
            <version>2.0-SNAPSHOT</version>
40
            <scope>compile</scope>
41
        </dependency>  
42
        <dependency>
43
            <groupId>org.gvsig</groupId>
44
            <artifactId>org.gvsig.fmap.control</artifactId>
45
            <scope>compile</scope>
46
        </dependency>
47
        <dependency>
48
            <groupId>org.gvsig</groupId>
49
            <artifactId>org.gvsig.fmap.geometry</artifactId>
50
            <scope>compile</scope>
51
        </dependency>  
52
		<dependency>
53
            <groupId>org.gvsig</groupId>
54
            <artifactId>org.gvsig.fmap.dal</artifactId>
55
            <scope>compile</scope>
56
        </dependency>	
57
        <dependency>
58
            <groupId>org.gvsig</groupId>
59
            <artifactId>org.gvsig.fmap.mapcontext</artifactId>
60
            <scope>compile</scope>
61
        </dependency>       
62
        <dependency>
63
            <groupId>org.gvsig</groupId>
64
            <artifactId>org.gvsig.i18n</artifactId>
65
            <scope>compile</scope>
66
        </dependency> 
67
        <dependency>
68
            <groupId>org.gvsig</groupId>
69
            <artifactId>org.gvsig.metadata.lib.basic.api</artifactId>
70
            <scope>compile</scope>
71
        </dependency>
72
        <dependency>
73
            <groupId>org.gvsig</groupId>
74
            <artifactId>org.gvsig.projection</artifactId>
75
            <scope>compile</scope>
76
        </dependency>      
77
        <dependency>
78
            <groupId>org.gvsig</groupId>
79
            <artifactId>org.gvsig.tools.lib</artifactId>
80
            <scope>compile</scope>
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff