Revision 42775

View differences:

trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.fmap.control/pom.xml
61 61
            <scope>compile</scope>
62 62
    </dependency>
63 63
    <dependency>
64
      <groupId>org.gvsig</groupId>
65
      <artifactId>org.gvsig.fmap.dal.swing.api</artifactId>
66
      <scope>compile</scope>
67
    </dependency>
68
    <dependency>
64 69
        <groupId>org.gvsig</groupId>
65 70
        <artifactId>org.gvsig.fmap.geometry.api</artifactId>
66 71
        <scope>compile</scope>
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/fmap/mapcontrol/swing/dynobject/impl/DefaultLayersDynObjectSetComponent.java
313 313
    public void formAfterSearch(JDynFormSet jdfs) {
314 314
    }
315 315

  
316
    @Override
317
    public void formBeforeCancelNew(JDynFormSet dynformSet) throws AbortActionException {
318
    }
319

  
320
    @Override
321
    public void formAfterCancelNew(JDynFormSet dynformSet) throws AbortActionException {
322
    }
323

  
316 324
    public class CenterGeometryInMapContext extends AbstractAction implements Action {
317 325

  
318 326
        private MapContext mapContext;
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/FeatureTableModel.java
35 35
import javax.swing.event.TableModelEvent;
36 36
import javax.swing.table.AbstractTableModel;
37 37

  
38
import org.gvsig.editing.EditingNotification;
39
import org.gvsig.editing.EditingNotificationManager;
40 38
import org.gvsig.fmap.dal.DALLocator;
39
import org.gvsig.fmap.dal.EditingNotification;
40
import org.gvsig.fmap.dal.EditingNotificationManager;
41 41
import org.gvsig.fmap.dal.exception.DataException;
42 42
import org.gvsig.fmap.dal.feature.EditableFeature;
43 43
import org.gvsig.fmap.dal.feature.Feature;
......
48 48
import org.gvsig.fmap.dal.feature.FeatureType;
49 49
import org.gvsig.fmap.dal.feature.exception.ConcurrentDataModificationException;
50 50
import org.gvsig.fmap.dal.feature.paging.FeaturePagingHelper;
51
import org.gvsig.fmap.mapcontrol.MapControlLocator;
51
import org.gvsig.fmap.dal.swing.DALSwingLocator;
52 52
import org.gvsig.tools.exception.BaseException;
53 53
import org.gvsig.tools.observer.ComplexNotification;
54 54
import org.gvsig.tools.observer.ComplexObserver;
......
219 219
                    // change notification
220 220
                    editableFeature =
221 221
                        setFeatureValue(feature, columnIndex, value);
222
                    EditingNotificationManager editingNotificationManager = MapControlLocator.getEditingNotificationManager();
222
                    EditingNotificationManager editingNotificationManager = DALSwingLocator.getEditingNotificationManager();
223 223
                    EditingNotification notification = editingNotificationManager.notifyObservers(
224 224
                            this,
225 225
                            EditingNotification.BEFORE_UPDATE_FEATURE,
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/ConfigurableFeatureTableModel.java
490 490
            this.patterns.put(columnName,defaultIntegerPattern);
491 491
            break;
492 492
        case DataTypes.DOUBLE:
493
            String defaultDoublePattern = "#,##0.0000000000";
494
            this.patterns.put(columnName,defaultDoublePattern);
495
            break;
493 496
        case DataTypes.FLOAT:
494
            String defaultDecimalPattern = "#,##0.000";
495
            this.patterns.put(columnName,defaultDecimalPattern);
497
            String defaultFloatPattern = "#,##0.0000";
498
            this.patterns.put(columnName,defaultFloatPattern);
496 499
            break;
497 500
        case DataTypes.DATE:
498 501
            String defaultDatePattern = new SimpleDateFormat().toPattern();
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/fmap/mapcontrol/impl/DefaultMapControlLibrary.java
50 50
 
51 51
package org.gvsig.fmap.mapcontrol.impl;
52 52

  
53
import org.gvsig.editing.impl.DefaultEditingNotificationManager;
54 53
import org.gvsig.fmap.mapcontrol.MapControlLibrary;
55 54
import org.gvsig.fmap.mapcontrol.MapControlLocator;
56 55
import org.gvsig.fmap.mapcontrol.MapControlManager;
......
78 77
	@Override
79 78
	protected void doInitialize() throws LibraryException {
80 79
		MapControlLocator.registerMapControlManager(DefaultMapControlManager.class);
81
                MapControlLocator.registerEditingNotificationManager(DefaultEditingNotificationManager.class);
82 80
                MapControlLocator.registerPropertiesPageManager(DefaultPropertiesPageManager.class);
83 81
	}
84 82

  
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/fmap/mapcontrol/MapControlLocator.java
24 24
 
25 25
package org.gvsig.fmap.mapcontrol;
26 26

  
27
import org.gvsig.editing.EditingNotificationManager;
28 27
import org.gvsig.propertypage.PropertiesPageManager;
29 28
import org.gvsig.propertypage.impl.DefaultPropertiesPageManager;
30 29
import org.gvsig.tools.locator.AbstractLocator;
......
94 93
				MAPCONTROL_MANAGER_DESCRIPTION,
95 94
				clazz);
96 95
	}
97

  
98
        public static EditingNotificationManager getEditingNotificationManager() throws LocatorException {
99
            return (EditingNotificationManager) getInstance().get(EDITING_NOTIFICATION_MANAGER_NAME);
100
        }
101

  
102
	public static void registerEditingNotificationManager(Class clazz) {
103
		getInstance().register(EDITING_NOTIFICATION_MANAGER_NAME, 
104
				EDITING_NOTIFICATION_MANAGER_DESCRIPTION,
105
				clazz);
106
	}
107 96
        
108 97
        public static PropertiesPageManager getPropertiesPageManager() {
109 98
            return (PropertiesPageManager) getInstance().get(PROPERTIES_PAGE_MANAGER_NAME);
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.symbology/org.gvsig.symbology.lib/org.gvsig.symbology.lib.impl/src/main/java/org/gvsig/symbology/fmap/mapcontext/rendering/legend/styling/AttrInTableLabelingStrategy.java
30 30
import java.awt.image.BufferedImage;
31 31
import java.util.ArrayList;
32 32
import java.util.List;
33
import java.util.logging.Level;
33 34

  
34 35
import org.apache.batik.ext.awt.geom.PathLength;
35 36
import org.cresques.cts.ICoordTrans;
......
234 235
                String geomName = featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName();
235 236
                fields.add(geomName);
236 237

  
238
                FeatureQuery featureQuery = layer.createFeatureQuery();
239

  
237 240
                if (viewPort.getAdjustedEnvelope().contains(
238 241
                        layer.getFullEnvelope())) {
239 242
                    /*
240 243
                     * viewport contains layer completely
241 244
                     */
242
                    set = featureStore.getFeatureSet();
245
                    set = featureStore.getFeatureSet(featureQuery);
243 246
                } else {
244 247
                    /*
245 248
                     * view port does not contain layer completely
......
263 266
                            data_proj,
264 267
                            featureStore.getDefaultFeatureType(),
265 268
                            geomName);
266
                    FeatureQuery featureQuery = featureStore.createFeatureQuery();
267 269
                    featureQuery.setAttributeNames((String[]) fields.toArray(new String[fields.size()]));
268 270
                    featureQuery.setFilter(iee);
269 271
                    set = featureStore.getFeatureSet(featureQuery);
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc/JDBCServerExplorer.java
3 3
 *
4 4
 * Copyright (C) 2007-2013 gvSIG Association.
5 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 3
9
 * of the License, or (at your option) any later version.
6
 * This program is free software; you can redistribute it and/or modify it under
7
 * the terms of the GNU General Public License as published by the Free Software
8
 * Foundation; either version 3 of the License, or (at your option) any later
9
 * version.
10 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.
11
 * This program is distributed in the hope that it will be useful, but WITHOUT
12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14
 * details.
15 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.
16
 * You should have received a copy of the GNU General Public License along with
17
 * this program; if not, write to the Free Software Foundation, Inc., 51
18
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 19
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
20
 * For any additional information, do not hesitate to contact us at info AT
21
 * gvsig.com, or visit our website www.gvsig.com.
23 22
 */
24 23
package org.gvsig.fmap.dal.store.jdbc;
25 24

  
......
60 59
import org.gvsig.fmap.dal.store.jdbc.exception.JDBCSQLException;
61 60
import org.gvsig.tools.exception.BaseException;
62 61

  
63

  
64 62
/**
65 63
 * @author jmvivo
66 64
 *
67 65
 */
68 66
public class JDBCServerExplorer extends AbstractDBServerExplorer
69
		implements JDBCHelperUser {
67
        implements JDBCHelperUser {
70 68

  
71
	private static final Logger LOG = LoggerFactory
72
			.getLogger(JDBCServerExplorer.class);
73
	
74
	private static final String METADATA_COLUMN_TABLE_CATALOG = "TABLE_CAT";
75
	private static final String METADATA_COLUMN_TABLE_SCHEMA = "TABLE_SCHEM";
76
	private static final String METADATA_COLUMN_TABLE_NAME = "TABLE_NAME";
69
    private static final Logger LOG = LoggerFactory
70
            .getLogger(JDBCServerExplorer.class);
77 71

  
78
	public static final String NAME = "JDBCServerExplorer";
79
	protected JDBCHelper helper;
72
    private static final String METADATA_COLUMN_TABLE_CATALOG = "TABLE_CAT";
73
    private static final String METADATA_COLUMN_TABLE_SCHEMA = "TABLE_SCHEM";
74
    private static final String METADATA_COLUMN_TABLE_NAME = "TABLE_NAME";
80 75

  
81
	private Boolean canAdd;
76
    public static final String NAME = "JDBCServerExplorer";
77
    protected JDBCHelper helper;
82 78

  
83
	public JDBCServerExplorer(JDBCServerExplorerParameters parameters,
84
			DataServerExplorerProviderServices services)
85
			throws InitializeException {
86
		super(parameters, services);
87
		this.helper = createHelper();
88
	}
79
    private Boolean canAdd;
89 80

  
90
	protected JDBCServerExplorerParameters getJDBCParameters() {
91
		return (JDBCServerExplorerParameters) getParameters();
92
	}
81
    public JDBCServerExplorer(JDBCServerExplorerParameters parameters,
82
            DataServerExplorerProviderServices services)
83
            throws InitializeException {
84
        super(parameters, services);
85
        this.helper = createHelper();
86
    }
93 87

  
94
	protected JDBCHelper createHelper() throws InitializeException {
95
		return new JDBCHelper(this, getJDBCParameters());
96
	}
88
    protected JDBCServerExplorerParameters getJDBCParameters() {
89
        return (JDBCServerExplorerParameters) getParameters();
90
    }
97 91

  
98
	protected JDBCHelper getHelper() {
99
		return helper;
100
	}
92
    protected JDBCHelper createHelper() throws InitializeException {
93
        return new JDBCHelper(this, getJDBCParameters());
94
    }
101 95

  
96
    protected JDBCHelper getHelper() {
97
        return helper;
98
    }
102 99

  
103
	public List list() throws DataException {
104
		return this.list(MODE_ALL);
105
	}
100
    public List list() throws DataException {
101
        return this.list(MODE_ALL);
102
    }
106 103

  
107
	public List list(boolean showInformationDBTables) throws DataException {
108
		return this.list(MODE_ALL, showInformationDBTables);
109
	}
104
    public List list(boolean showInformationDBTables) throws DataException {
105
        return this.list(MODE_ALL, showInformationDBTables);
106
    }
110 107

  
111
	public List list(int mode) throws DataException {
112
		JDBCServerExplorerParameters parameters = getJDBCParameters();
113
		if (parameters.getShowInformationDBTables() != null) {
114
			return this.list(mode, parameters.getShowInformationDBTables()
115
					.booleanValue());
116
		}
117
		Boolean show = (Boolean) parameters
118
				.getDynClass()
119
				.getDynField(
120
						JDBCServerExplorerParameters.SHOWINFORMATIONDBTABLES_PARAMTER_NAME)
121
				.getDefaultValue();
122
		if (show == null){
123
			show = Boolean.FALSE;
124
		}
108
    public List list(int mode) throws DataException {
109
        JDBCServerExplorerParameters parameters = getJDBCParameters();
110
        if (parameters.getShowInformationDBTables() != null) {
111
            return this.list(mode, parameters.getShowInformationDBTables()
112
                    .booleanValue());
113
        }
114
        Boolean show = (Boolean) parameters
115
                .getDynClass()
116
                .getDynField(
117
                        JDBCServerExplorerParameters.SHOWINFORMATIONDBTABLES_PARAMTER_NAME)
118
                .getDefaultValue();
119
        if (show == null) {
120
            show = Boolean.FALSE;
121
        }
125 122

  
126
		return this.list(mode, show.booleanValue());
127
	}
123
        return this.list(mode, show.booleanValue());
124
    }
128 125

  
126
    protected DataManagerProviderServices getManager() {
127
        return (DataManagerProviderServices) DALLocator.getDataManager();
128
    }
129 129

  
130
	protected DataManagerProviderServices getManager() {
131
		return (DataManagerProviderServices) DALLocator.getDataManager();
132
	}
130
    public boolean hasGeometrySupport() {
131
        return false;
132
    }
133 133

  
134
	public boolean hasGeometrySupport() {
135
		return false;
136
	}
134
    public boolean closeResourceRequested(ResourceProvider resource) {
135
        try {
136
            this.helper.close();
137
        } catch (CloseException e) {
138
            LOG.error("Exception in close Request", e);
139
        }
140
        return !this.helper.isOpen();
141
    }
137 142

  
138
	public boolean closeResourceRequested(ResourceProvider resource) {
139
		try {
140
			this.helper.close();
141
		} catch (CloseException e) {
142
			LOG.error("Exception in close Request", e);
143
		}
144
		return !this.helper.isOpen();
145
	}
143
    public void resourceChanged(ResourceProvider resource) {
144
        // Nothing to do
145
    }
146 146

  
147
	public void resourceChanged(ResourceProvider resource) {
148
		// Nothing to do
149
	}
147
    public void remove(DataStoreParameters dsp) throws RemoveException {
148
        final JDBCStoreParameters dsParams = (JDBCStoreParameters) dsp;
150 149

  
151
	public void remove(DataStoreParameters dsp) throws RemoveException {
152
		final JDBCStoreParameters dsParams =(JDBCStoreParameters) dsp;
150
        TransactionalAction action = new TransactionalAction() {
151
            public boolean continueTransactionAllowed() {
152
                return false;
153
            }
153 154

  
154
		TransactionalAction action = new TransactionalAction() {
155
			public boolean continueTransactionAllowed() {
156
				return false;
157
			}
158
			public Object action(Connection conn) throws DataException {
159
				Statement st;
160
				try{
161
					st = conn.createStatement();
162
				} catch (SQLException e) {
163
					throw new JDBCSQLException(e);
164
				}
155
            public Object action(Connection conn) throws DataException {
156
                Statement st;
157
                try {
158
                    st = conn.createStatement();
159
                } catch (SQLException e) {
160
                    throw new JDBCSQLException(e);
161
                }
165 162

  
166
				String sqlDrop = "Drop table "
167
					+ dsParams.tableID();
163
                String sqlDrop = "Drop table "
164
                        + dsParams.tableID();
168 165

  
169
				try{
170
					try{
171
                                                JDBCHelper.execute(st, sqlDrop);
172
					} catch (SQLException e) {
173
						throw new JDBCExecuteSQLException(sqlDrop, e);
174
					}
166
                try {
167
                    try {
168
                        JDBCHelper.execute(st, sqlDrop);
169
                    } catch (SQLException e) {
170
                        throw new JDBCExecuteSQLException(sqlDrop, e);
171
                    }
175 172

  
176
				} finally{
177
					try{ st.close(); } catch (SQLException e) {};
178
				}
179
				return null;
180
			}
181
		};
182
		try {
183
			this.helper.doConnectionAction(action);
184
		} catch (Exception e) {
185
			throw new RemoveException(this.getProviderName(), e);
186
		}
187
	}
188

  
189
	public DataStoreParameters getOpenParameters() throws DataException {
190
		JDBCServerExplorerParameters parameters = getJDBCParameters();
191
		JDBCStoreParameters params = new JDBCStoreParameters();
192
		params.setHost(parameters.getHost());
193
		params.setPort(parameters.getPort());
194
		params.setDBName(parameters.getDBName());
195
		params.setUser(parameters.getUser());
196
		params.setPassword(parameters.getPassword());
197
		params.setCatalog(parameters.getCatalog());
198
		params.setSchema(parameters.getSchema());
199
		params.setJDBCDriverClassName(parameters.getJDBCDriverClassName());
200
		params.setUrl(parameters.getUrl());
201
		return params;
173
                } finally {
174
                    try {
175
                        st.close();
176
                    } catch (SQLException e) {
177
                    };
178
                }
179
                return null;
180
            }
181
        };
182
        try {
183
            this.helper.doConnectionAction(action);
184
        } catch (Exception e) {
185
            throw new RemoveException(this.getProviderName(), e);
202 186
        }
187
    }
203 188

  
204
        public NewDataStoreParameters getAddParameters() throws DataException {
205
		JDBCServerExplorerParameters parameters = getJDBCParameters();
206
		JDBCNewStoreParameters params = new JDBCNewStoreParameters();
207
		params.setHost(parameters.getHost());
208
		params.setPort(parameters.getPort());
209
		params.setDBName(parameters.getDBName());
210
		params.setUser(parameters.getUser());
211
		params.setPassword(parameters.getPassword());
212
		params.setCatalog(parameters.getCatalog());
213
		params.setSchema(parameters.getSchema());
214
		params.setJDBCDriverClassName(parameters.getJDBCDriverClassName());
215
		params.setUrl(parameters.getUrl());
189
    public DataStoreParameters getOpenParameters() throws DataException {
190
        JDBCServerExplorerParameters parameters = getJDBCParameters();
191
        JDBCStoreParameters params = new JDBCStoreParameters();
192
        params.setHost(parameters.getHost());
193
        params.setPort(parameters.getPort());
194
        params.setDBName(parameters.getDBName());
195
        params.setUser(parameters.getUser());
196
        params.setPassword(parameters.getPassword());
197
        params.setCatalog(parameters.getCatalog());
198
        params.setSchema(parameters.getSchema());
199
        params.setJDBCDriverClassName(parameters.getJDBCDriverClassName());
200
        params.setUrl(parameters.getUrl());
201
        return params;
202
    }
216 203

  
217
		params.setDefaultFeatureType(this.getServerExplorerProviderServices()
218
				.createNewFeatureType());
204
    public NewDataStoreParameters getAddParameters() throws DataException {
205
        JDBCServerExplorerParameters parameters = getJDBCParameters();
206
        JDBCNewStoreParameters params = new JDBCNewStoreParameters();
207
        params.setHost(parameters.getHost());
208
        params.setPort(parameters.getPort());
209
        params.setDBName(parameters.getDBName());
210
        params.setUser(parameters.getUser());
211
        params.setPassword(parameters.getPassword());
212
        params.setCatalog(parameters.getCatalog());
213
        params.setSchema(parameters.getSchema());
214
        params.setJDBCDriverClassName(parameters.getJDBCDriverClassName());
215
        params.setUrl(parameters.getUrl());
219 216

  
220
		return params;
221
	}
217
        params.setDefaultFeatureType(this.getServerExplorerProviderServices()
218
                .createNewFeatureType());
222 219

  
223
	public void closeDone() throws DataException {
224
		// Nothing to do
225
	}
220
        return params;
221
    }
226 222

  
227
	public void opendDone() throws DataException {
228
		// Nothin to do
223
    public void closeDone() throws DataException {
224
        // Nothing to do
225
    }
229 226

  
230
	}
227
    public void opendDone() throws DataException {
228
        // Nothin to do
231 229

  
232
	public DataStore open(DataStoreParameters dsp) throws DataException {
233
		checkIsMine(dsp);
234
		DataManager dataMan = DALLocator.getDataManager();
235
		DataStore store;
236
		try {
237
			store = dataMan.openStore(dsp.getDataStoreName(), dsp);
238
		} catch (ValidateDataParametersException e) {
239
			throw new InitializeException(e);
240
		}
230
    }
241 231

  
242
		return store;
243
	}
232
    public DataStore open(DataStoreParameters dsp) throws DataException {
233
        checkIsMine(dsp);
234
        DataManager dataMan = DALLocator.getDataManager();
235
        DataStore store;
236
        try {
237
            store = dataMan.openStore(dsp.getDataStoreName(), dsp);
238
        } catch (ValidateDataParametersException e) {
239
            throw new InitializeException(e);
240
        }
244 241

  
245
	protected void checkIsMine(DataStoreParameters dsp) {
246
		if (!(dsp instanceof JDBCConnectionParameters)) {
247
			// FIXME Exception ???
248
			throw new IllegalArgumentException(
249
					"not instance of FilesystemStoreParameters");
250
		}
242
        return store;
243
    }
251 244

  
245
    protected void checkIsMine(DataStoreParameters dsp) {
246
        if (!(dsp instanceof JDBCConnectionParameters)) {
247
            // FIXME Exception ???
248
            throw new IllegalArgumentException(
249
                    "not instance of FilesystemStoreParameters");
250
        }
251

  
252 252
		// try {
253
		// dsp.validate();
254
		// } catch (ValidateDataParametersException e) {
255
		// throw new IllegalArgumentException("check parameters", e);
256
		// }
253
        // dsp.validate();
254
        // } catch (ValidateDataParametersException e) {
255
        // throw new IllegalArgumentException("check parameters", e);
256
        // }
257
        JDBCServerExplorerParameters parameters = getJDBCParameters();
257 258

  
258
		JDBCServerExplorerParameters parameters = getJDBCParameters();
259
        JDBCConnectionParameters pgp = (JDBCConnectionParameters) dsp;
260
        if (!compare(pgp.getHost(), parameters.getHost())) {
261
            throw new IllegalArgumentException("wrong explorer: Host (mine: "
262
                    + parameters.getHost() + " other:" + pgp.getHost() + ")");
263
        }
264
        if (!compare(pgp.getPort(), parameters.getPort())) {
265
            throw new IllegalArgumentException("wrong explorer: Port (mine: "
266
                    + parameters.getPort() + " other:" + pgp.getPort() + ")");
267
        }
268
        if (!compare(pgp.getDBName(), parameters.getDBName())) {
269
            throw new IllegalArgumentException("wrong explorer: DBName (mine: "
270
                    + parameters.getDBName() + " other:" + pgp.getDBName()
271
                    + ")");
272
        }
273
        if (parameters.getCatalog() != null && !parameters.getCatalog().trim().equals("")) {
274
            // implicit catalog
275
            if (!compare(pgp.getCatalog(), parameters.getCatalog())) {
276
                throw new IllegalArgumentException(
277
                        "wrong explorer: Catalog (mine: "
278
                        + parameters.getCatalog() + " other:"
279
                        + pgp.getCatalog() + ")");
280
            }
281
        }
282
        if (parameters.getSchema() != null && !parameters.getSchema().trim().equals("")) {
283
            // implicit schema
284
            if (!compare(pgp.getSchema(), parameters.getSchema())) {
285
                throw new IllegalArgumentException(
286
                        "wrong explorer: Schema (mine: "
287
                        + parameters.getSchema() + " other:"
288
                        + pgp.getSchema() + ")");
289
            }
290
        }
291
    }
259 292

  
260
		JDBCConnectionParameters pgp = (JDBCConnectionParameters) dsp;
261
		if (!compare(pgp.getHost(), parameters.getHost())) {
262
			throw new IllegalArgumentException("wrong explorer: Host (mine: "
263
					+ parameters.getHost() + " other:" + pgp.getHost() + ")");
264
		}
265
		if (!compare(pgp.getPort(), parameters.getPort())) {
266
			throw new IllegalArgumentException("wrong explorer: Port (mine: "
267
					+ parameters.getPort() + " other:" + pgp.getPort() + ")");
268
		}
269
		if (!compare(pgp.getDBName(), parameters.getDBName())) {
270
			throw new IllegalArgumentException("wrong explorer: DBName (mine: "
271
					+ parameters.getDBName() + " other:" + pgp.getDBName()
272
					+ ")");
273
		}
274
		if (parameters.getCatalog() != null && !parameters.getCatalog().trim().equals("")) {
275
			// implicit catalog
276
			if (!compare(pgp.getCatalog(), parameters.getCatalog())) {
277
				throw new IllegalArgumentException(
278
						"wrong explorer: Catalog (mine: "
279
								+ parameters.getCatalog() + " other:"
280
								+ pgp.getCatalog() + ")");
281
			}
282
		}
283
		if (parameters.getSchema() != null && !parameters.getSchema().trim().equals("")) {
284
			// implicit schema
285
			if (!compare(pgp.getSchema(), parameters.getSchema())) {
286
				throw new IllegalArgumentException(
287
						"wrong explorer: Schema (mine: "
288
								+ parameters.getSchema() + " other:"
289
								+ pgp.getSchema() + ")");
290
			}
291
		}
292
	}
293
    protected boolean compare(Object str1, Object str2) {
294
        if (str1 == str2) {
295
            return true;
296
        }
297
        if (str1 == null) {
298
            return false;
299
        }
300
        return str1.equals(str2);
301
    }
293 302

  
294
	protected boolean compare(Object str1, Object str2) {
295
		if (str1 == str2){
296
			return true;
297
		}
298
		if (str1 == null){
299
			return false;
300
		}
301
		return  str1.equals(str2);
302
	}
303

  
304
	protected JDBCStoreParameters createStoreParams()
305
			throws InitializeException, ProviderNotRegisteredException {
306
		DataManagerProviderServices manager = this.getManager();
307
		JDBCServerExplorerParameters parameters = getJDBCParameters();
308
		JDBCStoreParameters orgParams = (JDBCStoreParameters) manager
309
				.createStoreParameters(getStoreName());
310
		orgParams.setHost(parameters.getHost());
311
		orgParams.setPort(parameters.getPort());
312
		orgParams.setDBName(parameters.getDBName());
313
		orgParams.setUser(parameters.getUser());
314
		orgParams.setPassword(parameters.getPassword());
303
    protected JDBCStoreParameters createStoreParams()
304
            throws InitializeException, ProviderNotRegisteredException {
305
        DataManagerProviderServices manager = this.getManager();
306
        JDBCServerExplorerParameters parameters = getJDBCParameters();
307
        JDBCStoreParameters orgParams = (JDBCStoreParameters) manager
308
                .createStoreParameters(getStoreName());
309
        orgParams.setHost(parameters.getHost());
310
        orgParams.setPort(parameters.getPort());
311
        orgParams.setDBName(parameters.getDBName());
312
        orgParams.setUser(parameters.getUser());
313
        orgParams.setPassword(parameters.getPassword());
315 314
        orgParams.setCatalog(parameters.getCatalog());
316 315
        orgParams.setJDBCDriverClassName(parameters.getJDBCDriverClassName());
317 316
        orgParams.setSchema(parameters.getSchema());
318 317
        orgParams.setUrl(parameters.getUrl());
319
		return orgParams;
320
	}
318
        return orgParams;
319
    }
321 320

  
322
	public List list(final int mode, final boolean showInformationDBTables)
323
			throws DataException {
321
    public List list(final int mode, final boolean showInformationDBTables)
322
            throws DataException {
324 323

  
325
		final JDBCStoreParameters orgParams = createStoreParams();
324
        final JDBCStoreParameters orgParams = createStoreParams();
326 325

  
327
		ConnectionAction action = new ConnectionAction() {
326
        ConnectionAction action = new ConnectionAction() {
328 327

  
329
			public Object action(Connection conn) throws DataException {
328
            public Object action(Connection conn) throws DataException {
330 329

  
331
				String[] tableTypes = null;
332
				if (!showInformationDBTables) {
333
					tableTypes = new String[] { "TABLE", "VIEW" };
334
				}
330
                String[] tableTypes = null;
331
                if (!showInformationDBTables) {
332
                    tableTypes = new String[]{"TABLE", "VIEW"};
333
                }
335 334

  
336
				ResultSet result = null;
337
				try {
338
					DatabaseMetaData metadata = conn.getMetaData();
339
					result = metadata.getTables(null, null, null,
340
							tableTypes);
341
					List<JDBCStoreParameters> paramList = new ArrayList<JDBCStoreParameters>();
342
					while (result.next()) {
343
						JDBCStoreParameters params = (JDBCStoreParameters) orgParams
344
								.getCopy();
345
						params.setCatalog(result
346
								.getString(METADATA_COLUMN_TABLE_CATALOG));
347
						params.setSchema(result
348
								.getString(METADATA_COLUMN_TABLE_SCHEMA));
349
						params.setTable(result
350
								.getString(METADATA_COLUMN_TABLE_NAME));
351
						paramList.add(params);
352
					}
335
                ResultSet result = null;
336
                try {
337
                    DatabaseMetaData metadata = conn.getMetaData();
338
                    result = metadata.getTables(null, null, null,
339
                            tableTypes);
340
                    List<JDBCStoreParameters> paramList = new ArrayList<JDBCStoreParameters>();
341
                    while (result.next()) {
342
                        JDBCStoreParameters params = (JDBCStoreParameters) orgParams
343
                                .getCopy();
344
                        params.setCatalog(result
345
                                .getString(METADATA_COLUMN_TABLE_CATALOG));
346
                        params.setSchema(result
347
                                .getString(METADATA_COLUMN_TABLE_SCHEMA));
348
                        params.setTable(result
349
                                .getString(METADATA_COLUMN_TABLE_NAME));
350
                        paramList.add(params);
351
                    }
353 352

  
354
					return paramList;
355
				} catch (SQLException e) {
356
					throw new JDBCSQLException(e);
357
				} finally {
358
					if (result != null) {
359
						try {
360
							result.close();
361
						} catch (Exception e) {
362
							LOG.error("Error closing DatabaseMetadata "
363
									+ "getTables() Resultset", e);
364
						}
365
					}
366
				}
367
			}
353
                    return paramList;
354
                } catch (SQLException e) {
355
                    throw new JDBCSQLException(e);
356
                } finally {
357
                    if (result != null) {
358
                        try {
359
                            result.close();
360
                        } catch (Exception e) {
361
                            LOG.error("Error closing DatabaseMetadata "
362
                                    + "getTables() Resultset", e);
363
                        }
364
                    }
365
                }
366
            }
368 367

  
369
		};
368
        };
370 369

  
371
		try {
372
			return (List) helper.doConnectionAction(action);
373
		} catch (Exception e) {
374
			throw new ReadException(this.getProviderName(), e);
375
		}
376
	}
370
        try {
371
            return (List) helper.doConnectionAction(action);
372
        } catch (Exception e) {
373
            throw new ReadException(this.getProviderName(), e);
374
        }
375
    }
377 376

  
377
    public void open() throws OpenException {
378
        helper.open();
379
    }
378 380

  
379
	public void open() throws OpenException {
380
		helper.open();
381
	}
381
    public void close() throws CloseException {
382
        helper.close();
383
    }
382 384

  
383
	public void close() throws CloseException {
384
		helper.close();
385
	}
385
    @Override
386
    protected void doDispose() throws BaseException {
387
        helper.dispose();
388
        helper = null;
389
    }
386 390

  
387
	@Override
388
	protected void doDispose() throws BaseException {
389
		helper.dispose();
390
		helper = null;
391
	}
391
    public String getProviderName() {
392
        return NAME;
393
    }
392 394

  
393
	public String getProviderName() {
394
		return NAME;
395
	}
395
    public String getStoreName() {
396
        return JDBCStoreProvider.NAME;
397
    }
396 398

  
397
	public String getStoreName() {
398
		return JDBCStoreProvider.NAME;
399
	}
399
    public boolean canAdd() {
400
        if (this.canAdd == null) {
401
            ConnectionAction action = new ConnectionAction() {
400 402

  
401
	public boolean canAdd() {
402
		if (this.canAdd == null){
403
			ConnectionAction action = new ConnectionAction(){
403
                public Object action(Connection conn) throws DataException {
404
                    try {
405
                        DatabaseMetaData metadata = conn.getMetaData();
406
                        if (metadata.isReadOnly()) {
407
                            return Boolean.FALSE;
408
                        }
409
                        return Boolean.TRUE;
410
                    } catch (SQLException e) {
411
                        throw new JDBCSQLException(e);
412
                    }
413
                }
404 414

  
405
				public Object action(Connection conn) throws DataException {
406
					try {
407
					DatabaseMetaData metadata = conn.getMetaData();
408
						if (metadata.isReadOnly()) {
409
							return Boolean.FALSE;
410
						}
411
						return Boolean.TRUE;
412
					} catch (SQLException e) {
413
						throw new JDBCSQLException(e);
414
					}
415
				}
415
            };
416 416

  
417
			};
417
            try {
418
                this.canAdd = (Boolean) helper.doConnectionAction(action);
419
            } catch (Exception e) {
420
                // FIXME Exception
421
                throw new RuntimeException(e);
422
            }
423
        }
424
        return this.canAdd.booleanValue();
425
    }
418 426

  
419
			try {
420
				this.canAdd = (Boolean) helper.doConnectionAction(action);
421
			} catch (Exception e) {
422
				// FIXME Exception
423
				throw new RuntimeException(e);
424
			}
425
		}
426
		return this.canAdd.booleanValue();
427
	}
427
    public FeatureType getFeatureType(DataStoreParameters dsp)
428
            throws DataException {
429
        checkIsMine(dsp);
428 430

  
429
	public FeatureType getFeatureType(DataStoreParameters dsp)
430
			throws DataException {
431
		checkIsMine(dsp);
431
        // TODO: checks geometry columns and driver geometry supports
432
        EditableFeatureType edType = this.getServerExplorerProviderServices()
433
                .createNewFeatureType();
434
        helper.loadFeatureType(edType, (JDBCStoreParameters) dsp);
432 435

  
433
		// TODO: checks geometry columns and driver geometry supports
434
		EditableFeatureType edType = this.getServerExplorerProviderServices()
435
				.createNewFeatureType();
436
		helper.loadFeatureType(edType, (JDBCStoreParameters) dsp);
436
        return edType;
437 437

  
438
		return edType;
438
    }
439 439

  
440
	}
441
        
442
	public boolean add(String providerName, NewDataStoreParameters ndsp, boolean overwrite)
443
			throws DataException {
440
    public boolean add(String providerName, NewDataStoreParameters ndsp, boolean overwrite)
441
            throws DataException {
444 442

  
445
		/**
446
		 * CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE table_name (
447
		 * { column_name data_type [ DEFAULT default_expr ] [ column_constraint
448
		 * [ ... ] ] | table_constraint | LIKE parent_table [ { INCLUDING |
449
		 * EXCLUDING } DEFAULTS ] } [, ... ] ) [ INHERITS ( parent_table [, ...
450
		 * ] ) ] [ WITH OIDS | WITHOUT OIDS ] [ ON COMMIT { PRESERVE ROWS |
451
		 * DELETE ROWS | DROP } ]
452
		 *
453
		 * where column_constraint is:
454
		 *
455
		 * [ CONSTRAINT constraint_name ] { NOT NULL | NULL | UNIQUE | PRIMARY
456
		 * KEY | CHECK (expression) | REFERENCES reftable [ ( refcolumn ) ] [
457
		 * MATCH FULL | MATCH PARTIAL | MATCH SIMPLE ] [ ON DELETE action ] [ ON
458
		 * UPDATE action ] } [ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY
459
		 * DEFERRED | INITIALLY IMMEDIATE ]
460
		 *
461
		 * and table_constraint is:
462
		 *
463
		 * [ CONSTRAINT constraint_name ] { UNIQUE ( column_name [, ... ] ) |
464
		 * PRIMARY KEY ( column_name [, ... ] ) | CHECK ( expression ) | FOREIGN
465
		 * KEY ( column_name [, ... ] ) REFERENCES reftable [ ( refcolumn [, ...
466
		 * ] ) ] [ MATCH FULL | MATCH PARTIAL | MATCH SIMPLE ] [ ON DELETE
467
		 * action ] [ ON UPDATE action ] } [ DEFERRABLE | NOT DEFERRABLE ] [
468
		 * INITIALLY DEFERRED | INITIALLY IMMEDIATE ]
469
		 */
443
        /**
444
         * CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE table_name (
445
         * { column_name data_type [ DEFAULT default_expr ] [ column_constraint
446
         * [ ... ] ] | table_constraint | LIKE parent_table [ { INCLUDING |
447
         * EXCLUDING } DEFAULTS ] } [, ... ] ) [ INHERITS ( parent_table [, ...
448
         * ] ) ] [ WITH OIDS | WITHOUT OIDS ] [ ON COMMIT { PRESERVE ROWS |
449
         * DELETE ROWS | DROP } ]
450
         *
451
         * where column_constraint is:
452
         *
453
         * [ CONSTRAINT constraint_name ] { NOT NULL | NULL | UNIQUE | PRIMARY
454
         * KEY | CHECK (expression) | REFERENCES reftable [ ( refcolumn ) ] [
455
         * MATCH FULL | MATCH PARTIAL | MATCH SIMPLE ] [ ON DELETE action ] [ ON
456
         * UPDATE action ] } [ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY
457
         * DEFERRED | INITIALLY IMMEDIATE ]
458
         *
459
         * and table_constraint is:
460
         *
461
         * [ CONSTRAINT constraint_name ] { UNIQUE ( column_name [, ... ] ) |
462
         * PRIMARY KEY ( column_name [, ... ] ) | CHECK ( expression ) | FOREIGN
463
         * KEY ( column_name [, ... ] ) REFERENCES reftable [ ( refcolumn [, ...
464
         * ] ) ] [ MATCH FULL | MATCH PARTIAL | MATCH SIMPLE ] [ ON DELETE
465
         * action ] [ ON UPDATE action ] } [ DEFERRABLE | NOT DEFERRABLE ] [
466
         * INITIALLY DEFERRED | INITIALLY IMMEDIATE ]
467
         */
468
        if (!(ndsp instanceof JDBCNewStoreParameters)) {
469
            // FIXME exception
470
            throw new IllegalArgumentException();
471
        }
472
        checkIsMine(ndsp);
470 473

  
471
		if (!(ndsp instanceof JDBCNewStoreParameters)) {
472
			// FIXME exception
473
			throw new IllegalArgumentException();
474
		}
475
		checkIsMine(ndsp);
474
        JDBCNewStoreParameters jdbcnsp = (JDBCNewStoreParameters) ndsp;
476 475

  
477
		JDBCNewStoreParameters jdbcnsp = (JDBCNewStoreParameters) ndsp;
476
        StringBuilder sql = new StringBuilder();
478 477

  
479
		StringBuilder sql = new StringBuilder();
478
        if (!jdbcnsp.isValid()) {
479
            // TODO Exception
480
            throw new InitializeException(this.getProviderName(), new Exception(
481
                    "Parameters not valid"));
482
        }
483
        try {
484
            jdbcnsp.validate();
485
        } catch (ValidateDataParametersException e1) {
486
            throw new InitializeException(this.getProviderName(), e1);
487
        }
480 488

  
481
		if (!jdbcnsp.isValid()) {
482
			// TODO Exception
483
			throw new InitializeException(this.getProviderName(), new Exception(
484
					"Parameters not valid"));
485
		}
486
		try {
487
			jdbcnsp.validate();
488
		} catch (ValidateDataParametersException e1) {
489
			throw new InitializeException(this.getProviderName(), e1);
490
		}
489
        FeatureType fType = jdbcnsp.getDefaultFeatureType();
491 490

  
492
		FeatureType fType = jdbcnsp.getDefaultFeatureType();
491
        sql.append("Create table " + jdbcnsp.tableID()
492
                + "(");
493
        Iterator attrs = fType.iterator();
494
        String sqlAttr;
495
        List sqlAttrs = new ArrayList();
493 496

  
494
		sql.append("Create table " + jdbcnsp.tableID()
495
				+ "(");
496
		Iterator attrs = fType.iterator();
497
		String sqlAttr;
498
		List sqlAttrs = new ArrayList();
497
        while (attrs.hasNext()) {
498
            sqlAttr = helper
499
                    .getSqlFieldDescription((FeatureAttributeDescriptor) attrs
500
                            .next());
501
            if (sqlAttr != null) {
502
                sqlAttrs.add(sqlAttr);
503
            }
504
        }
499 505

  
500
		while (attrs.hasNext()) {
501
			sqlAttr = helper
502
					.getSqlFieldDescription((FeatureAttributeDescriptor) attrs
503
							.next());
504
			if (sqlAttr != null) {
505
				sqlAttrs.add(sqlAttr);
506
			}
507
		}
506
        helper.stringJoin(sqlAttrs, ", ", sql);
508 507

  
509
		helper.stringJoin(sqlAttrs, ", ", sql);
508
        sql.append(")");
510 509

  
511
		sql.append(")");
510
        final String sqlCreate = sql.toString();
511
        final List sqlAdditional = helper.getAdditionalSqlToCreate(ndsp, fType);
512 512

  
513
		final String sqlCreate = sql.toString();
514
		final List sqlAdditional = helper.getAdditionalSqlToCreate(ndsp, fType);
513
        List permissions = this.getHelper().createGrantStatements((JDBCNewStoreParameters) ndsp);
514
        if (permissions != null) {
515
            sqlAdditional.addAll(permissions);
516
        }
515 517

  
516
                List permissions = this.getHelper().createGrantStatements((JDBCNewStoreParameters) ndsp);
517
                if( permissions != null ) {
518
                    sqlAdditional.addAll(permissions);
518
        if (((JDBCNewStoreParameters) ndsp).getPostCreatingStatement() != null) {
519
            sqlAdditional.add(((JDBCNewStoreParameters) ndsp).getPostCreatingStatement());
520
        }
521

  
522
        TransactionalAction action = new TransactionalAction() {
523

  
524
            public boolean continueTransactionAllowed() {
525
                // TODO Auto-generated method stub
526
                return false;
527
            }
528

  
529
            public Object action(Connection conn) throws DataException {
530
                Statement st = null;
531

  
532
                try {
533
                    st = conn.createStatement();
534
                } catch (SQLException e1) {
535
                    throw new JDBCSQLException(e1);
519 536
                }
520
                
521
                if( ((JDBCNewStoreParameters) ndsp).getPostCreatingStatement()!=null ) {
522
                    sqlAdditional.add(((JDBCNewStoreParameters) ndsp).getPostCreatingStatement());
523
                }
524
                
525
		TransactionalAction action = new TransactionalAction() {
537
                String sql = null;
526 538

  
527
			public boolean continueTransactionAllowed() {
528
				// TODO Auto-generated method stub
529
				return false;
530
			}
539
                try {
540
                    sql = sqlCreate;
541
                    JDBCHelper.execute(st, sql);
542
                    if (sqlAdditional != null) {
543
                        Iterator iter = sqlAdditional.iterator();
544
                        while (iter.hasNext()) {
545
                            sql = (String) iter.next();
546
                            JDBCHelper.execute(st, sql);
547
                        }
548
                    }
531 549

  
532
			public Object action(Connection conn) throws DataException {
533
				Statement st = null;
550
                } catch (SQLException e) {
551
                    throw new JDBCExecuteSQLException(sql, e);
552
                } finally {
553
                    try {
554
                        st.close();
555
                    } catch (SQLException e) {
556
                        LOG.error("Exception clossing statement", e);
557
                    }
558
                    ;
559
                }
534 560

  
535
				try {
536
					st = conn.createStatement();
537
				} catch (SQLException e1) {
538
					throw new JDBCSQLException(e1);
539
				}
540
				String sql = null;
561
                return Boolean.TRUE;
562
            }
541 563

  
542
				try {
543
					sql = sqlCreate;
544
                                        JDBCHelper.execute(st, sql);
545
					if (sqlAdditional != null) {
546
						Iterator iter = sqlAdditional.iterator();
547
						while (iter.hasNext()) {
548
							sql = (String) iter.next();
549
                                                        JDBCHelper.execute(st, sql);
550
						}
551
					}
564
        };
552 565

  
553
				} catch (SQLException e) {
554
					throw new JDBCExecuteSQLException(sql, e);
555
				} finally {
556
					try {
557
						st.close();
558
					} catch (SQLException e) {
559
						LOG.error("Exception clossing statement", e);
560
					}
561
					;
562
				}
566
        Boolean result = Boolean.FALSE;
563 567

  
564
				return Boolean.TRUE;
565
			}
568
        try {
569
            result = (Boolean) helper.doConnectionAction(action);
570
        } catch (DataException e) {
571
            throw e;
572
        } catch (Exception e) {
573
            // FIXME Exception
574
            throw new RuntimeException(e);
575
        }
566 576

  
567
		};
577
        return result.booleanValue();
578
    }
568 579

  
569
		Boolean result = Boolean.FALSE;
580
    public List getDataStoreProviderNames() {
581
        List x = new ArrayList(1);
582
        x.add(JDBCStoreProvider.NAME);
583
        return x;
584
    }
570 585

  
571
		try {
572
			result = (Boolean) helper.doConnectionAction(action);
573
		} catch (DataException e) {
574
                    throw  e;
575
		} catch (Exception e) {
576
                    // FIXME Exception
577
                    throw new RuntimeException(e);
578
		}
586
    public void updateTableStatistics(String tableName) throws JDBCExecuteSQLException {
579 587

  
580
		return result.booleanValue();
581
	}
588
    }
582 589

  
583
	public List getDataStoreProviderNames() {
584
		List x = new ArrayList(1);
585
		x.add(JDBCStoreProvider.NAME);
586
		return x;
587
	}
588
        
589
        public void updateTableStatistics(String tableName) throws JDBCExecuteSQLException {
590
            
591
        }
592

  
590
    @Override
591
    public DataStoreParameters get(String name) throws DataException {
592
        JDBCStoreParameters params = this.createStoreParams();
593
        params.setTable(name);
594
        return params;
595
    }
593 596
}
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.lib/src/main/java/org/gvsig/fmap/dal/serverexplorer/db/spi/AbstractDBServerExplorer.java
27 27
import org.gvsig.fmap.dal.NewDataStoreParameters;
28 28
import org.gvsig.fmap.dal.exception.DataException;
29 29
import org.gvsig.fmap.dal.serverexplorer.db.DBServerExplorer;
30
import org.gvsig.fmap.dal.spi.AbstractDataServerExplorer;
30 31
import org.gvsig.fmap.dal.spi.DataServerExplorerProvider;
31 32
import org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices;
32 33
import org.gvsig.fmap.dal.spi.DataStoreProvider;
......
38 39
 * @author jmvivo
39 40
 *
40 41
 */
41
public abstract class AbstractDBServerExplorer extends AbstractDisposable
42
public abstract class AbstractDBServerExplorer extends AbstractDataServerExplorer
42 43
		implements DBServerExplorer, DataServerExplorerProvider {
43 44

  
44
	private DataServerExplorerProviderServices dataServerExplorerProviderServices;
45
	private DataServerExplorerParameters dataServerParameters;
45
//	private DataServerExplorerProviderServices dataServerExplorerProviderServices;
46
//	private DataServerExplorerParameters dataServerParameters;
46 47

  
47 48
	protected AbstractDBServerExplorer(DataServerExplorerParameters parameters,
48 49
			DataServerExplorerProviderServices services) {
49
		this.dataServerParameters = parameters;
50
		this.dataServerExplorerProviderServices = services;
50
            super(parameters, services);
51 51
	}
52 52

  
53 53
	/**
......
78 78
		return getAddParameters();
79 79
	}
80 80

  
81
	/**
82
	 * Return instance of {@link DataServerExplorerProviderServices}
83
	 *
84
	 */
85
	public DataServerExplorerProviderServices getServerExplorerProviderServices() {
86
		return dataServerExplorerProviderServices;
87
	}
88

  
89
	/*
90
	 * (non-Javadoc)
91
	 * 
92
	 * @see
93
	 * org.gvsig.fmap.dal.serverexplorer.db.DBServerExplorer#getParameters()
94
	 */
95
	public DataServerExplorerParameters getParameters() {
96
		return dataServerParameters;
97
	}
98

  
99 81
}
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.api/src/main/java/org/gvsig/featureform/swing/FeatureFormDefinitionsProvider.java
1

  
2
package org.gvsig.featureform.swing;
3

  
4
import java.io.IOException;
5
import java.util.Iterator;
6
import org.gvsig.featureform.swing.FeatureFormDefinitionsProvider.Entry;
7
import org.gvsig.fmap.dal.exception.DataException;
8
import org.gvsig.fmap.dal.feature.FeatureStore;
9
import org.gvsig.tools.dynobject.DynClass;
10

  
11

  
12
public interface FeatureFormDefinitionsProvider extends Iterable<Entry> {
13
    
14
    public interface Entry extends Comparable<Entry>{
15
        public DynClass getDynClass();
16
        public String getKey();
17
        public String getXml();
18
        public boolean setXml(String xml);
19
    }
20
    
21
    public Entry get(FeatureStore store) throws DataException;
22

  
23
    public void put(Entry entry) throws DataException, IOException;
24

  
25
    @Override
26
    public Iterator<Entry> iterator();
27

  
28
    public void put(FeatureStore store) throws DataException, IOException;
29
    
30
    public DynClass getDynClass(FeatureStore store) throws DataException;
31

  
32
}
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.api/src/main/java/org/gvsig/featureform/swing/JFeatureForm.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2014 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
 */
1

  
23 2
package org.gvsig.featureform.swing;
24 3

  
25
import java.awt.Dimension;
26
import javax.swing.Action;
27

  
28
import javax.swing.JComponent;
4
import org.gvsig.fmap.dal.feature.EditableFeature;
29 5
import org.gvsig.fmap.dal.feature.Feature;
30

  
31
import org.gvsig.fmap.dal.feature.FeatureQuery;
32 6
import org.gvsig.fmap.dal.feature.FeatureStore;
33
import org.gvsig.tools.dynform.JDynFormSet;
34
import org.gvsig.tools.swing.api.windowmanager.WindowManager.MODE;
7
import org.gvsig.tools.dynform.JDynForm;
8
import org.gvsig.tools.swing.api.Component;
35 9

  
36
/**
37
 * @author fdiaz
38
 *
39
 */
40
public interface JFeatureForm {
41 10

  
42
    public void setPreferredSize(Dimension dimension);
43

  
44
    public void bind(FeatureStore store);
45

  
46
    public void setQuery(FeatureQuery query);
47

  
48
    public long getDataSetSize();
49

  
50
    public void showForm(MODE mode);
51

  
52
    public JComponent asJComponent();
53

  
54
    public void saveChanges();
55

  
56
    public JDynFormSet getFormset();
11
public interface JFeatureForm extends Component {
57 12
    
58
    public FeatureStore getFeatureStore();
13
    public void setStore(FeatureStore store);
59 14
    
60
    public void addAction(Action action);
15
    public void setFeature(Feature feature);
61 16
    
62
    public long getCurrentIndex();
17
    public JDynForm getDynForm();
63 18
    
64
    public Feature get(long index);
19
    public void fetch(EditableFeature feature);
65 20
}
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.api/src/main/java/org/gvsig/featureform/swing/JFeaturesForm.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2014 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.featureform.swing;
24

  
25
import java.awt.Dimension;
26
import javax.swing.Action;
27

  
28
import org.gvsig.fmap.dal.feature.Feature;
29

  
30
import org.gvsig.fmap.dal.feature.FeatureQuery;
31
import org.gvsig.fmap.dal.feature.FeatureStore;
32
import org.gvsig.tools.dynform.JDynFormSet;
33
import org.gvsig.tools.swing.api.Component;
34
import org.gvsig.tools.swing.api.windowmanager.WindowManager.MODE;
35

  
36
/**
37
 * @author fdiaz
38
 *
39
 */
40
public interface JFeaturesForm extends Component {
41

  
42
    public void setPreferredSize(Dimension dimension);
43

  
44
    public void bind(FeatureStore store);
45

  
46
    public void setQuery(FeatureQuery query);
47

  
48
    public long getDataSetSize();
49

  
50
    public void showForm(MODE mode);
51
    
52
    public void saveChanges();
53

  
54
    public JDynFormSet getFormset();
55
    
56
    public FeatureStore getFeatureStore();
57
    
58
    public void addAction(Action action);
59
    
60
    public long getCurrentIndex();
61
    
62
    public Feature get(long index);
63
}
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.api/src/main/java/org/gvsig/fmap/dal/EditingNotificationManager.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.dal;
25

  
26
import org.gvsig.fmap.dal.feature.EditableFeatureType;
27
import org.gvsig.fmap.dal.feature.Feature;
28
import org.gvsig.tools.observer.Observable;
29

  
30
/**
31
 * 
32
 * Acts as a hub to centralize editing notification events in a single manager.
33
 * 
34
 * All objects that modify a store notify this manager to reported the actions 
35
 * to  the objects interested in knowing when start or end editing, regardless 
36
 * of where the editing work is done.
37
 * 
38
 */
39
public interface EditingNotificationManager extends Observable {
40
 
41
    public EditingNotification notifyObservers(Object source, String type, Object document, Object auxdata, DataStore store, Feature feature);
42

  
43
    public EditingNotification notifyObservers(Object source, String type, Object document, DataStore store, Feature feature);
44

  
45
    public EditingNotification notifyObservers(Object source, String type, Object document, Object auxdata, DataStore store);
46

  
47
    public EditingNotification notifyObservers(Object source, String type, Object document, DataStore store);
48

  
49
    public EditingNotification notifyObservers(Object source, String type, Object document, DataStore store, EditableFeatureType featuretType);
50

  
51
    public EditingNotification notifyObservers(Object source, String type, Object document, Object auxdata);
52

  
53
    public EditingNotification notifyObservers(EditingNotification notification);
54
    
55
    public boolean validateFeature(Feature feature);
56
}
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.api/src/main/java/org/gvsig/fmap/dal/swing/DALSwingLocator.java
22 22
 */
23 23
package org.gvsig.fmap.dal.swing;
24 24

  
25
import org.gvsig.fmap.dal.EditingNotificationManager;
25 26
import org.gvsig.tools.locator.BaseLocator;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff