Revision 43355
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/test/java/org/gvsig/fmap/dal/store/jdbc2/SQLBuilderTest.java | ||
---|---|---|
155 | 155 |
45, |
156 | 156 |
0, |
157 | 157 |
false, |
158 |
false, |
|
158 | 159 |
true, |
159 | 160 |
false, |
160 | 161 |
null |
... | ... | |
166 | 167 |
0, |
167 | 168 |
true, |
168 | 169 |
false, |
170 |
false, |
|
169 | 171 |
true, |
170 | 172 |
0 |
171 | 173 |
); |
... | ... | |
175 | 177 |
0, |
176 | 178 |
0, |
177 | 179 |
false, |
180 |
false, |
|
178 | 181 |
true, |
179 | 182 |
false, |
180 | 183 |
null |
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/jdbc2/spi/operations/ResultSetForSetProviderOperation.java | ||
---|---|---|
4 | 4 |
import java.util.ArrayList; |
5 | 5 |
import java.util.List; |
6 | 6 |
import org.apache.commons.lang3.StringUtils; |
7 |
import org.gvsig.fmap.dal.ExpressionBuilder.Config; |
|
7 | 8 |
import org.gvsig.fmap.dal.exception.DataException; |
8 | 9 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
9 | 10 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
... | ... | |
84 | 85 |
int fetchSize |
85 | 86 |
) throws DataException { |
86 | 87 |
|
88 |
double tolerance = -1 ; //query.getScale(); |
|
87 | 89 |
JDBCSQLBuilderBase sqlbuilder = createSQLBuilder(); |
88 | 90 |
|
89 | 91 |
List<String> primaryKeys = new ArrayList<>(); |
... | ... | |
101 | 103 |
primaryKeys.remove(attr.getName()); |
102 | 104 |
} |
103 | 105 |
if( attr.getType() == DataTypes.GEOMETRY ) { |
104 |
sqlbuilder.select().column().name(attr.getName()).as_geometry(); |
|
106 |
if( tolerance<=0 || !sqlbuilder.getConfig().has_functionality(Config.ST_Simplify)) { |
|
107 |
sqlbuilder.select().column().name(attr.getName()).as_geometry(); |
|
108 |
} else { |
|
109 |
sqlbuilder.select().column().value( |
|
110 |
sqlbuilder.ST_Simplify( |
|
111 |
sqlbuilder.column(attr.getName()), |
|
112 |
sqlbuilder.constant(tolerance) |
|
113 |
) |
|
114 |
).as_geometry(); |
|
115 |
} |
|
105 | 116 |
} else { |
106 | 117 |
sqlbuilder.select().column().name(attr.getName()); |
107 | 118 |
} |
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/jdbc2/spi/operations/PerformChangesOperation.java | ||
---|---|---|
22 | 22 |
|
23 | 23 |
public class PerformChangesOperation extends AbstractConnectionOperation { |
24 | 24 |
|
25 |
private final String dbName;
|
|
26 |
private final String schemaName;
|
|
27 |
private final String tableName;
|
|
28 |
private final FeatureType featureType;
|
|
29 |
private final Iterator<FeatureReferenceProviderServices> deleteds;
|
|
30 |
private final Iterator<FeatureStoreProvider.FeatureTypeChanged> featureTypesChanged;
|
|
31 |
private final Iterator<FeatureProvider> updateds;
|
|
32 |
private final Iterator<FeatureProvider> inserteds;
|
|
25 |
protected String dbName;
|
|
26 |
protected String schemaName;
|
|
27 |
protected String tableName;
|
|
28 |
protected FeatureType featureType;
|
|
29 |
protected Iterator<FeatureReferenceProviderServices> deleteds;
|
|
30 |
protected Iterator<FeatureStoreProvider.FeatureTypeChanged> featureTypesChanged;
|
|
31 |
protected Iterator<FeatureProvider> updateds;
|
|
32 |
protected Iterator<FeatureProvider> inserteds;
|
|
33 | 33 |
|
34 |
private boolean typeChanged = false;
|
|
34 |
protected boolean typeChanged = false;
|
|
35 | 35 |
|
36 | 36 |
public PerformChangesOperation(JDBCHelper helper) { |
37 | 37 |
this(helper, null, null, null, null, null, null, null, null); |
... | ... | |
251 | 251 |
attrTarget.getPrecision(), |
252 | 252 |
attrTarget.getSize(), |
253 | 253 |
attrTarget.isPrimaryKey(), |
254 |
attrTarget.isIndexed(), |
|
254 | 255 |
attrTarget.allowNull(), |
255 | 256 |
attrTarget.isAutomatic(), |
256 | 257 |
attrTarget.getDefaultValue() |
... | ... | |
265 | 266 |
attrTarget.getPrecision(), |
266 | 267 |
attrTarget.getSize(), |
267 | 268 |
attrTarget.isPrimaryKey(), |
269 |
attrTarget.isIndexed(), |
|
268 | 270 |
attrTarget.allowNull(), |
269 | 271 |
attrTarget.isAutomatic(), |
270 | 272 |
attrTarget.getDefaultValue() |
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/jdbc2/spi/operations/FetchFeatureTypeOperation.java | ||
---|---|---|
151 | 151 |
} |
152 | 152 |
|
153 | 153 |
protected boolean isInPrimaryKeys(List<String> pks, EditableFeatureAttributeDescriptor attr) { |
154 |
return pks != null && pks.contains(attr.getName()); |
|
154 |
// En algunos gestores de BBDD, los nombres obtenidos de las pks de los |
|
155 |
// metadados no coinciden con los nombres de los campos ya que unos estan |
|
156 |
// en mayusculas y otros en minusculas, asi que en lugar de usar un "contains" |
|
157 |
// nos los recorremos y comparamos con IgnoreCase. |
|
158 |
for (String pk : pks) { |
|
159 |
if( StringUtils.equalsIgnoreCase(pk, attr.getName()) ) { |
|
160 |
return true; |
|
161 |
} |
|
162 |
} |
|
163 |
return false; |
|
155 | 164 |
} |
156 | 165 |
|
157 | 166 |
protected List<String> getPrimaryKeysFromMetadata( |
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/jdbc2/spi/operations/CreateTableOperation.java | ||
---|---|---|
72 | 72 |
attr.getGeomType().getType(), |
73 | 73 |
attr.getGeomType().getSubType(), |
74 | 74 |
attr.getSRS(), |
75 |
attr.isIndexed(), |
|
75 | 76 |
attr.allowNull() |
76 | 77 |
); |
77 | 78 |
} else { |
... | ... | |
81 | 82 |
attr.getSize(), |
82 | 83 |
attr.getPrecision(), |
83 | 84 |
attr.isPrimaryKey(), |
85 |
attr.isIndexed(), |
|
84 | 86 |
attr.allowNull(), |
85 | 87 |
attr.isAutomatic(), |
86 | 88 |
attr.getDefaultValue() |
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/jdbc2/spi/JDBCSRSsDumb.java | ||
---|---|---|
1 |
|
|
2 |
package org.gvsig.fmap.dal.store.jdbc2.spi; |
|
3 |
|
|
4 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
|
5 |
|
|
6 |
public class JDBCSRSsDumb extends JDBCSRSsBase implements JDBCSRSs { |
|
7 |
|
|
8 |
public JDBCSRSsDumb(JDBCHelper helper) { |
|
9 |
super(helper); |
|
10 |
} |
|
11 |
|
|
12 |
@Override |
|
13 |
protected String searchDatabaseCode(String applicationAbbrev) { |
|
14 |
try { |
|
15 |
String[] s = applicationAbbrev.split(applicationAbbrev); |
|
16 |
return s[1].trim(); |
|
17 |
} catch (Throwable ex) { |
|
18 |
throw new RuntimeException("Problems searching database code from '"+applicationAbbrev+"'.",ex); |
|
19 |
} |
|
20 |
} |
|
21 |
|
|
22 |
@Override |
|
23 |
protected String searchApplicationAbbrev(String databaseCode) { |
|
24 |
try { |
|
25 |
return "EPSG:" + databaseCode.trim(); |
|
26 |
} catch (Throwable ex) { |
|
27 |
throw new RuntimeException("Problems searching application abbrev from '"+databaseCode+"'.",ex); |
|
28 |
} |
|
29 |
} |
|
30 |
} |
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/jdbc2/spi/JDBCSRSsBase.java | ||
---|---|---|
1 |
|
|
2 |
package org.gvsig.fmap.dal.store.jdbc2.spi; |
|
3 |
|
|
4 |
import java.sql.ResultSet; |
|
5 |
import java.sql.Statement; |
|
6 |
import java.util.HashMap; |
|
7 |
import java.util.Map; |
|
8 |
import org.apache.commons.lang3.StringUtils; |
|
9 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
|
10 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCUtils; |
|
11 |
|
|
12 |
public class JDBCSRSsBase implements JDBCSRSs { |
|
13 |
|
|
14 |
protected Map<String,String> database2applicationAbbrev; |
|
15 |
protected Map<String,String> applicationAbbrev2database; |
|
16 |
protected JDBCHelper helper; |
|
17 |
|
|
18 |
public JDBCSRSsBase(JDBCHelper helper) { |
|
19 |
this.helper = helper; |
|
20 |
this.applicationAbbrev2database = new HashMap<>(); |
|
21 |
this.database2applicationAbbrev = new HashMap<>(); |
|
22 |
} |
|
23 |
|
|
24 |
public void add(String databaseCode, String applicationAbbrev) { |
|
25 |
this.applicationAbbrev2database.put(applicationAbbrev, databaseCode); |
|
26 |
this.database2applicationAbbrev.put(databaseCode, applicationAbbrev); |
|
27 |
} |
|
28 |
|
|
29 |
public String getDatabaseCode(String applicationAbbrev) { |
|
30 |
if( this.hasApplicationAbbrev(applicationAbbrev) ) { |
|
31 |
return this.applicationAbbrev2database.get(applicationAbbrev); |
|
32 |
} |
|
33 |
String databaseCode = this.searchDatabaseCode(applicationAbbrev); |
|
34 |
if( StringUtils.isEmpty(databaseCode) ) { |
|
35 |
return null; |
|
36 |
} |
|
37 |
this.add(databaseCode, applicationAbbrev); |
|
38 |
return databaseCode; |
|
39 |
} |
|
40 |
|
|
41 |
public String getApplicationAbbrev(String databaseCode) { |
|
42 |
if( this.hasDatabaseCode(databaseCode) ) { |
|
43 |
return this.database2applicationAbbrev.get(databaseCode); |
|
44 |
} |
|
45 |
String applicationAbbrev = this.searchApplicationAbbrev(databaseCode); |
|
46 |
if( StringUtils.isEmpty(applicationAbbrev) ) { |
|
47 |
return null; |
|
48 |
} |
|
49 |
this.add(databaseCode, applicationAbbrev); |
|
50 |
return applicationAbbrev; |
|
51 |
} |
|
52 |
|
|
53 |
public boolean hasDatabaseCode(String databaseCode) { |
|
54 |
return this.database2applicationAbbrev.containsKey(databaseCode); |
|
55 |
} |
|
56 |
|
|
57 |
public boolean hasApplicationAbbrev(String applicationAbbrev) { |
|
58 |
return this.applicationAbbrev2database.containsKey(applicationAbbrev); |
|
59 |
} |
|
60 |
|
|
61 |
protected String searchDatabaseCode(String applicationAbbrev) { |
|
62 |
// Initialize sql only for debugging purposes |
|
63 |
String sql = "select srid, auth_name, auth_srid from spatial_ref_sys where auth_name/auth_srid is '"+applicationAbbrev+"'."; |
|
64 |
try { |
|
65 |
String[] s = applicationAbbrev.split(applicationAbbrev); |
|
66 |
sql = "select srid, auth_name, auth_srid from spatial_ref_sys where auth_name = '" + s[0] +"' and auth_srid = '"+s[1]+"' "; |
|
67 |
Statement st = this.helper.getConnection().createStatement(); |
|
68 |
ResultSet rs = JDBCUtils.executeQuery(st, sql); |
|
69 |
if ( rs.next() ) { |
|
70 |
int srid = rs.getInt("srid"); |
|
71 |
return String.valueOf(srid); |
|
72 |
} |
|
73 |
return null; |
|
74 |
} catch (Throwable ex) { |
|
75 |
throw new RuntimeException("Problems with SQL '"+sql+"'.",ex); |
|
76 |
} |
|
77 |
} |
|
78 |
|
|
79 |
protected String searchApplicationAbbrev(String databaseCode) { |
|
80 |
String sql = "select srid, auth_name, auth_srid from spatial_ref_sys where srid = " + databaseCode; |
|
81 |
try { |
|
82 |
Statement st = this.helper.getConnection().createStatement(); |
|
83 |
ResultSet rs = JDBCUtils.executeQuery(st, sql); |
|
84 |
if ( rs.next() ) { |
|
85 |
int auth_code = rs.getInt("auth_srid"); |
|
86 |
String auth_name = rs.getString("auth_name"); |
|
87 |
return auth_name + ":" + auth_code; |
|
88 |
} |
|
89 |
return null; |
|
90 |
} catch (Throwable ex) { |
|
91 |
throw new RuntimeException("Problems with SQL '"+sql+"'.",ex); |
|
92 |
} |
|
93 |
} |
|
94 |
|
|
95 |
} |
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/jdbc2/spi/JDBCHelperBase.java | ||
---|---|---|
70 | 70 |
|
71 | 71 |
protected OperationsFactory operationsFactory = null; |
72 | 72 |
|
73 |
protected JDBCSRSs srss; |
|
74 |
|
|
73 | 75 |
public JDBCHelperBase(JDBCConnectionParameters connectionParameters) { |
74 | 76 |
this.connectionParameters = connectionParameters; |
77 |
|
|
78 |
// If a particular treatment is required to convert SRS to the |
|
79 |
// BBDD format, overwrite JDBCSRSsBase and use it instead of JDBCSRSsDumb. |
|
80 |
this.srss = new JDBCSRSsDumb(this); |
|
75 | 81 |
} |
76 | 82 |
|
77 | 83 |
protected void initialize( |
... | ... | |
323 | 329 |
|
324 | 330 |
@Override |
325 | 331 |
public int getSRSCode(IProjection crs) { |
326 |
// Dumb implementation |
|
327 |
String abrev = crs.getAbrev(); |
|
328 |
if( StringUtils.isEmpty(abrev) ) { |
|
329 |
return -1; |
|
330 |
} |
|
331 |
String[] ss = abrev.split(":"); |
|
332 |
if( ss.length < 2 ) { |
|
333 |
return -1; |
|
334 |
} |
|
335 |
int id = Integer.parseInt(ss[1]); |
|
336 |
return id; |
|
332 |
String databaseCode = this.srss.getDatabaseCode(crs.getAbrev()); |
|
333 |
return Integer.parseInt(databaseCode); |
|
337 | 334 |
} |
338 | 335 |
|
339 | 336 |
@Override |
340 | 337 |
public IProjection getProjectionFromSRSId(int srsid) { |
341 |
// Dumb implementation |
|
342 |
if( srsid < 2000 ) { |
|
338 |
return getProjectionFromDatabaseCode(String.valueOf(srsid)); |
|
339 |
} |
|
340 |
|
|
341 |
@Override |
|
342 |
public String getDatabaseCodeFromProyection(IProjection proj) { |
|
343 |
String[] s = proj.getAbrev().split(":"); |
|
344 |
return this.srss.getDatabaseCode(proj.getAbrev()); |
|
345 |
} |
|
346 |
|
|
347 |
@Override |
|
348 |
public IProjection getProjectionFromDatabaseCode(String databaseCode) { |
|
349 |
String abbrev = this.srss.getApplicationAbbrev(databaseCode); |
|
350 |
if( StringUtils.isEmpty(abbrev) ) { |
|
343 | 351 |
return null; |
344 | 352 |
} |
345 |
IProjection proj = CRSFactory.getCRS("EPSG:"+srsid);
|
|
353 |
IProjection proj = CRSFactory.getCRS(abbrev);
|
|
346 | 354 |
return proj; |
347 | 355 |
} |
348 | 356 |
|
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/jdbc2/spi/JDBCSRSs.java | ||
---|---|---|
1 |
|
|
2 |
package org.gvsig.fmap.dal.store.jdbc2.spi; |
|
3 |
|
|
4 |
public interface JDBCSRSs { |
|
5 |
|
|
6 |
void add(String databaseCode, String applicationAbbrev); |
|
7 |
|
|
8 |
String getApplicationAbbrev(String databaseCode); |
|
9 |
|
|
10 |
String getDatabaseCode(String applicationAbbrev); |
|
11 |
|
|
12 |
boolean hasApplicationAbbrev(String applicationAbbrev); |
|
13 |
|
|
14 |
boolean hasDatabaseCode(String databaseCode); |
|
15 |
} |
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/jdbc2/JDBCHelper.java | ||
---|---|---|
158 | 158 |
DataServerExplorerProviderServices providerServices |
159 | 159 |
) throws InitializeException; |
160 | 160 |
|
161 |
public String getDatabaseCodeFromProyection(IProjection proj); |
|
162 |
|
|
163 |
public IProjection getProjectionFromDatabaseCode(String databaseCode); |
|
164 |
|
|
165 |
/** |
|
166 |
* @param crs |
|
167 |
* @return |
|
168 |
* @deprecated use getDatabaseCodeFromProyection |
|
169 |
*/ |
|
161 | 170 |
public int getSRSCode(IProjection crs); |
162 | 171 |
|
172 |
/** |
|
173 |
* @param srsid |
|
174 |
* @return |
|
175 |
* @deprecated use getProjectionFromDatabaseCode |
|
176 |
*/ |
|
163 | 177 |
public IProjection getProjectionFromSRSId(int srsid); |
164 | 178 |
|
165 | 179 |
public JDBCNewStoreParameters createNewStoreParameters(); |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.impl/src/main/java/org/gvsig/fmap/dal/swing/impl/jdbc/DefaultJDBCConnectionPanel.java | ||
---|---|---|
12 | 12 |
import java.awt.event.ItemListener; |
13 | 13 |
import java.io.File; |
14 | 14 |
import java.util.Iterator; |
15 |
import java.util.List; |
|
16 | 15 |
import javax.swing.ComboBoxModel; |
17 | 16 |
import javax.swing.JComponent; |
18 | 17 |
import javax.swing.JLabel; |
... | ... | |
28 | 27 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
29 | 28 |
import org.gvsig.fmap.dal.DataServerExplorerPool; |
30 | 29 |
import org.gvsig.fmap.dal.DataServerExplorerPoolEntry; |
31 |
import org.gvsig.fmap.dal.exception.DataException; |
|
32 | 30 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters; |
33 | 31 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
34 | 32 |
import org.gvsig.fmap.dal.swing.jdbc.JDBCConnectionPanel; |
... | ... | |
44 | 42 |
// org.gvsig.fmap.mapcontrol.dal.jdbc.JDBCConnectionPanel |
45 | 43 |
public class DefaultJDBCConnectionPanel extends DefaultJDBCConnectionPanelView implements JDBCConnectionPanel{ |
46 | 44 |
|
47 |
private static final Logger |
|
48 |
logger = LoggerFactory.getLogger(DefaultJDBCConnectionPanel.class);
|
|
45 |
private static final Logger logger = LoggerFactory.getLogger(DefaultJDBCConnectionPanel.class);
|
|
46 |
private static final long serialVersionUID = -6119489353793596382L;
|
|
49 | 47 |
private JDBCServerExplorerParameters forcedParameters; |
48 |
private ItemListener onChangeConnectorItemListener; |
|
50 | 49 |
|
51 | 50 |
@Override |
52 | 51 |
public JComponent asJComponent() { |
... | ... | |
91 | 90 |
this.cboConnections.addItemListener(new ItemListener() { |
92 | 91 |
@Override |
93 | 92 |
public void itemStateChanged(ItemEvent e) { |
94 |
// Lo hago asi para evitar cuelgues durante la depuracion |
|
93 |
if(e.getStateChange() != ItemEvent.SELECTED) { |
|
94 |
return; |
|
95 |
} // Lo hago asi para evitar cuelgues durante la depuracion |
|
95 | 96 |
// al poner puntos de ruptura en un evento de un combo. |
96 | 97 |
SwingUtilities.invokeLater(new Runnable() { |
97 | 98 |
|
... | ... | |
102 | 103 |
}); |
103 | 104 |
} |
104 | 105 |
}); |
105 |
this.cboConnectors.addItemListener(new ItemListener() {
|
|
106 |
this.onChangeConnectorItemListener = new ItemListener() {
|
|
106 | 107 |
@Override |
107 | 108 |
public void itemStateChanged(ItemEvent e) { |
109 |
if(e.getStateChange() != ItemEvent.SELECTED) { |
|
110 |
return; |
|
111 |
} |
|
108 | 112 |
// Lo hago asi para evitar cuelgues durante la depuracion |
109 | 113 |
// al poner puntos de ruptura en un evento de un combo. |
110 | 114 |
SwingUtilities.invokeLater(new Runnable() { |
... | ... | |
115 | 119 |
} |
116 | 120 |
}); |
117 | 121 |
} |
118 |
}); |
|
122 |
}; |
|
123 |
this.cboConnectors.addItemListener(onChangeConnectorItemListener); |
|
119 | 124 |
try { |
120 | 125 |
fillConnections(); |
121 | 126 |
fillConnectors(); |
... | ... | |
167 | 172 |
|
168 | 173 |
int indexConnector = this.getIndexOfConnector(parameters); |
169 | 174 |
if ( indexConnector >= 0 && this.cboConnectors.getSelectedIndex()!=indexConnector ) { |
175 |
this.cboConnectors.removeItemListener(this.onChangeConnectorItemListener); |
|
170 | 176 |
this.cboConnectors.setSelectedIndex(indexConnector); |
177 |
this.cboConnectors.addItemListener(onChangeConnectorItemListener); |
|
171 | 178 |
} |
172 | 179 |
|
173 | 180 |
this.txtServer.setText(parameters.getHost()); |
... | ... | |
200 | 207 |
public JDBCServerExplorerParameters getServerExplorerParameters() { |
201 | 208 |
JDBCServerExplorerParameters params; |
202 | 209 |
JDBCServerExplorerParameters connector = this.getConnector(); |
210 |
if( connector==null ) { |
|
211 |
return null; |
|
212 |
} |
|
203 | 213 |
if( this.forcedParameters==null ) { |
204 | 214 |
params = (JDBCServerExplorerParameters) connector.getCopy(); |
205 | 215 |
} else { |
... | ... | |
319 | 329 |
ComboBoxModel model = this.cboConnectors.getModel(); |
320 | 330 |
for ( int i = 0; i < model.getSize(); i++ ) { |
321 | 331 |
ServerExplorerParametersComboItem x = (ServerExplorerParametersComboItem) model.getElementAt(i); |
322 |
if ( x.getLabel().equalsIgnoreCase(explorerParameters.getExplorerName()) ) {
|
|
332 |
if ( x.getParams()!=null && x.getParams().getExplorerName().equalsIgnoreCase(explorerParameters.getExplorerName()) ) {
|
|
323 | 333 |
return i; |
324 | 334 |
} |
325 | 335 |
} |
... | ... | |
333 | 343 |
DataManager dataManager = DALLocator.getDataManager(); |
334 | 344 |
|
335 | 345 |
ServerExplorerParametersComboItem last = null; |
346 |
this.cboConnectors.addItem(new ServerExplorerParametersComboItem("",null)); |
|
336 | 347 |
|
337 | 348 |
for (DataFactory factory : dataManager.getServerExplorerRegister() ) { |
338 | 349 |
DataServerExplorerParameters params = (DataServerExplorerParameters) factory.createParameters(); |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/ExpressionBuilder.java | ||
---|---|---|
33 | 33 |
|
34 | 34 |
public interface Config { |
35 | 35 |
public final static String has_spatial_functions = "has_spatial_functions"; |
36 |
public final static String support_schemas = "support_schemas"; |
|
36 | 37 |
public final static String quote_for_identifiers = "quote_for_identifiers"; |
37 | 38 |
public final static String quote_for_strings = "quote_for_strings"; |
38 | 39 |
public final static String geometry_type_support = "geometry_type_support"; |
... | ... | |
59 | 60 |
public final static String ST_GeomFromText = "ST_GeomFromText"; |
60 | 61 |
public final static String ST_GeomFromWKB = "ST_GeomFromWKB"; |
61 | 62 |
public final static String ST_GeomFromEWKB = "ST_GeomFromEWKB"; |
63 |
public final static String ST_Simplify = "ST_Simplify"; |
|
62 | 64 |
public final static String lcase = "lcase"; |
63 | 65 |
public final static String ucase = "ucase"; |
64 | 66 |
public final static String isNull = "isNull"; |
... | ... | |
227 | 229 |
|
228 | 230 |
public Function ST_GeomFromEWKB(Value geom, Value crs); |
229 | 231 |
|
232 |
public Function ST_Simplify(Value geom, Value tolerance); |
|
233 |
|
|
230 | 234 |
public Function ST_Equals(Value geom1, Value geom2); |
231 | 235 |
|
232 | 236 |
public Function ST_Intersects(Value geom1, Value geom2); |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/SQLBuilder.java | ||
---|---|---|
63 | 63 |
public final static String UPDATE_table_SET_columnsAndValues_WHERE_expresion = "UPDATE_table_SET_columnsAndValues_WHERE_expresion"; |
64 | 64 |
public final static String UPDATE_table_SET_columnsAndValues = "UPDATE_table_SET_columnsAndValues"; |
65 | 65 |
public final static String GRANT_privileges_ON_table_TO_role = "GRANT_privileges_ON_table_TO_role"; |
66 |
|
|
66 |
public final static String CREATE_INDEX_name_ON_table_column = "CREATE_INDEX_name_ON_table_column"; |
|
67 |
public final static String CREATE_INDEX_name_ON_table_USING_GIST_column = "CREATE_INDEX_name_ON_table_USING_GIST_column"; |
|
68 |
|
|
67 | 69 |
} |
68 | 70 |
|
69 | 71 |
public interface TableNameBuilder extends Visitable { |
... | ... | |
83 | 85 |
public int getSize(); |
84 | 86 |
public int getPrecision(); |
85 | 87 |
public boolean isPrimaryKey(); |
88 |
public boolean isIndexed(); |
|
86 | 89 |
public boolean isAutomatic(); |
87 | 90 |
boolean allowNulls(); |
88 | 91 |
public Object getDefaultValue(); |
... | ... | |
213 | 216 |
public interface AlterTableBuilder extends Statement { |
214 | 217 |
public TableNameBuilder table(); |
215 | 218 |
public AlterTableBuilder drop_column(String columnName); |
216 |
public AlterTableBuilder add_column(String columnName, int type, int type_p, int type_s, boolean isPk, boolean allowNulls, boolean isAutomatic, Object defaultValue); |
|
217 |
public AlterTableBuilder alter_column(String columnName, int type, int type_p, int type_s, boolean isPk, boolean allowNulls, boolean isAutomatic, Object defaultValue); |
|
219 |
public AlterTableBuilder add_column(String columnName, int type, int type_p, int type_s, boolean isPk, boolean isIndexed, boolean allowNulls, boolean isAutomatic, Object defaultValue);
|
|
220 |
public AlterTableBuilder alter_column(String columnName, int type, int type_p, int type_s, boolean isPk, boolean isIndexed, boolean allowNulls, boolean isAutomatic, Object defaultValue);
|
|
218 | 221 |
public AlterTableBuilder rename_column(String source, String target); |
219 | 222 |
public List<String> toStrings(); |
220 | 223 |
} |
221 | 224 |
|
222 | 225 |
public interface CreateTableBuilder extends Statement { |
223 | 226 |
public TableNameBuilder table(); |
224 |
public CreateTableBuilder add_column(String columnName, int type, int type_p, int type_s, boolean isPk, boolean allowNulls, boolean isAutomatic, Object defaultValue); |
|
225 |
public CreateTableBuilder add_geometry_column(String columnName, int geom_type, int geom_subtype, IProjection proj, boolean allowNulls); |
|
227 |
public CreateTableBuilder add_column(String columnName, int type, int type_p, int type_s, boolean isPk, boolean isIndexed, boolean allowNulls, boolean isAutomatic, Object defaultValue);
|
|
228 |
public CreateTableBuilder add_geometry_column(String columnName, int geom_type, int geom_subtype, IProjection proj, boolean isIndexed, boolean allowNulls);
|
|
226 | 229 |
public ColumnDescriptorBuilder getColumnDescriptor(String columnName); |
227 | 230 |
public List<String> toStrings(); |
228 | 231 |
} |
... | ... | |
256 | 259 |
} |
257 | 260 |
|
258 | 261 |
public String default_schema(); |
262 |
|
|
263 |
public boolean supportSchemas(); |
|
259 | 264 |
|
260 | 265 |
public String sqltype(int dataType, int p, int s); |
261 | 266 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.spi/src/main/java/org/gvsig/fmap/dal/feature/spi/ExpressionBuilderBase.java | ||
---|---|---|
42 | 42 |
public ConfigBase() { |
43 | 43 |
this.values = new HashMap<>(); |
44 | 44 |
|
45 |
this.values.put(has_spatial_functions, false); |
|
46 |
this.values.put(constant_true, "(1=1)"); |
|
47 |
this.values.put(constant_false, "(1=2)"); |
|
48 |
this.values.put(quote_for_identifiers, "\""); |
|
49 |
this.values.put(quote_for_strings, "'"); |
|
50 |
this.values.put(geometry_type_support, GeometrySupportType.WKT); |
|
51 |
this.values.put(group, "( {0} )"); |
|
45 |
this.set(Config.has_spatial_functions, false); |
|
46 |
this.set(Config.support_schemas, true); |
|
47 |
this.set(Config.constant_true, "(1=1)"); |
|
48 |
this.set(Config.constant_false, "(1=2)"); |
|
49 |
this.set(Config.quote_for_identifiers, "\""); |
|
50 |
this.set(Config.quote_for_strings, "'"); |
|
51 |
this.set(Config.geometry_type_support, GeometrySupportType.WKT); |
|
52 |
this.set(Config.group, "( {0} )"); |
|
52 | 53 |
|
53 |
this.values.put(Find_SRID, "Find_SRID(({0}), ({1}), ({2}))"); |
|
54 |
this.values.put(ST_SRID, "ST_SRID({0})"); |
|
55 |
this.values.put(ST_AsText, "ST_AsText({0})"); |
|
56 |
this.values.put(ST_AsBinary, "ST_AsBinary({0})"); |
|
57 |
this.values.put(ST_AsEWKB, "ST_AsWKB({0})"); |
|
58 |
this.values.put(ST_Contains, "ST_Contains(({0}), ({1}))"); |
|
59 |
this.values.put(ST_Crosses, "ST_Crosses(({0}), ({1}))"); |
|
60 |
this.values.put(ST_Disjoint, "ST_Disjoint(({0}), ({1}))"); |
|
61 |
this.values.put(ST_Equals, "ST_Equals(({0}), ({1}))"); |
|
62 |
this.values.put(ST_IsClosed, "ST_IsClosed({0})"); |
|
63 |
this.values.put(ST_Overlaps, "ST_Overlaps(({0}), ({1}))"); |
|
64 |
this.values.put(ST_Touches, "ST_Touches(({0}), ({1}))"); |
|
65 |
this.values.put(ST_Within, "ST_Within(({0}), ({1}))"); |
|
66 |
this.values.put(ST_Envelope, "ST_Envelope({0})"); |
|
67 |
this.values.put(ST_Intersects, "ST_Intersects(({0}), ({1}))"); |
|
68 |
this.values.put(ST_GeomFromText, "ST_GeomFromText({0}, ({1}))"); |
|
69 |
this.values.put(ST_GeomFromWKB, "ST_GeomFromWKB(({0}), ({1}))"); |
|
70 |
this.values.put(ST_GeomFromEWKB, "ST_GeomFromEWKB(({0}), ({1}))"); |
|
71 |
this.values.put(lcase, "LCASE({0})"); |
|
72 |
this.values.put(ucase, "UCASE({0})"); |
|
73 |
this.values.put(isNull, "( ({0}) IS NULL )"); |
|
74 |
this.values.put(notIsNull, "( ({0}) NOT IS NULL )"); |
|
75 |
this.values.put(operator_not, "( NOT ({0}) )"); |
|
54 |
this.set(Config.Find_SRID, "Find_SRID(({0}), ({1}), ({2}))"); |
|
55 |
this.set(Config.ST_SRID, "ST_SRID({0})"); |
|
56 |
this.set(Config.ST_AsText, "ST_AsText({0})"); |
|
57 |
this.set(Config.ST_AsBinary, "ST_AsBinary({0})"); |
|
58 |
this.set(Config.ST_AsEWKB, "ST_AsEWKB({0})"); |
|
59 |
this.set(Config.ST_Contains, "ST_Contains(({0}), ({1}))"); |
|
60 |
this.set(Config.ST_Crosses, "ST_Crosses(({0}), ({1}))"); |
|
61 |
this.set(Config.ST_Disjoint, "ST_Disjoint(({0}), ({1}))"); |
|
62 |
this.set(Config.ST_Equals, "ST_Equals(({0}), ({1}))"); |
|
63 |
this.set(Config.ST_IsClosed, "ST_IsClosed({0})"); |
|
64 |
this.set(Config.ST_Overlaps, "ST_Overlaps(({0}), ({1}))"); |
|
65 |
this.set(Config.ST_Touches, "ST_Touches(({0}), ({1}))"); |
|
66 |
this.set(Config.ST_Within, "ST_Within(({0}), ({1}))"); |
|
67 |
this.set(Config.ST_Envelope, "ST_Envelope({0})"); |
|
68 |
this.set(Config.ST_Intersects, "ST_Intersects(({0}), ({1}))"); |
|
69 |
this.set(Config.ST_GeomFromText, "ST_GeomFromText({0}, ({1}))"); |
|
70 |
this.set(Config.ST_GeomFromWKB, "ST_GeomFromWKB(({0}), ({1}))"); |
|
71 |
this.set(Config.ST_GeomFromEWKB, "ST_GeomFromEWKB(({0}), ({1}))"); |
|
72 |
|
|
73 |
// Por defecto no esta disponible la funcion ST_Simplify |
|
74 |
// El proveedor que la soporte que la defina. |
|
75 |
// this.set(Config.ST_Simplify, "ST_Simplify(({0}), ({1}))"); |
|
76 |
this.remove_functionality(Config.ST_Simplify); |
|
77 |
|
|
78 |
this.set(Config.lcase, "LCASE({0})"); |
|
79 |
this.set(Config.ucase, "UCASE({0})"); |
|
80 |
this.set(Config.isNull, "( ({0}) IS NULL )"); |
|
81 |
this.set(Config.notIsNull, "( ({0}) NOT IS NULL )"); |
|
82 |
this.set(Config.operator_not, "( NOT ({0}) )"); |
|
76 | 83 |
|
77 |
this.values.put(operator_AND, "{0} AND {1}");
|
|
78 |
this.values.put(operator_OR, "{0} OR {1}");
|
|
79 |
this.values.put(operator_EQ, "( ({0}) = ({1}) )");
|
|
80 |
this.values.put(operator_NE, "( ({0}) <> ({1}) )");
|
|
81 |
this.values.put(operator_GT, "( ({0}) > ({1}) )");
|
|
82 |
this.values.put(operator_GE, "( ({0}) >= ({1}) )");
|
|
83 |
this.values.put(operator_LT, "( ({0}) < ({1}) )");
|
|
84 |
this.values.put(operator_LE, "( ({0}) <= ({1}) )");
|
|
85 |
this.values.put(operator_LIKE, "( ({0}) LIKE ({1}) )");
|
|
86 |
this.values.put(operator_ILIKE, "( ({0}) ILIKE ({1}) )");
|
|
84 |
this.set(Config.operator_AND, "{0} AND {1}");
|
|
85 |
this.set(Config.operator_OR, "{0} OR {1}");
|
|
86 |
this.set(Config.operator_EQ, "( ({0}) = ({1}) )");
|
|
87 |
this.set(Config.operator_NE, "( ({0}) <> ({1}) )");
|
|
88 |
this.set(Config.operator_GT, "( ({0}) > ({1}) )");
|
|
89 |
this.set(Config.operator_GE, "( ({0}) >= ({1}) )");
|
|
90 |
this.set(Config.operator_LT, "( ({0}) < ({1}) )");
|
|
91 |
this.set(Config.operator_LE, "( ({0}) <= ({1}) )");
|
|
92 |
this.set(Config.operator_LIKE, "( ({0}) LIKE ({1}) )");
|
|
93 |
this.set(Config.operator_ILIKE, "( ({0}) ILIKE ({1}) )");
|
|
87 | 94 |
|
88 |
this.values.put(operator_add, "{0} + {1}");
|
|
89 |
this.values.put(operator_subst, "{0} - {1}");
|
|
90 |
this.values.put(operator_mult, "{0} * {1}");
|
|
91 |
this.values.put(operator_div, "{0} / {1}");
|
|
92 |
this.values.put(operator_concat, "{0} || {1}");
|
|
95 |
this.set(Config.operator_add, "{0} + {1}");
|
|
96 |
this.set(Config.operator_subst, "{0} - {1}");
|
|
97 |
this.set(Config.operator_mult, "{0} * {1}");
|
|
98 |
this.set(Config.operator_div, "{0} / {1}");
|
|
99 |
this.set(Config.operator_concat, "{0} || {1}");
|
|
93 | 100 |
|
94 | 101 |
} |
95 | 102 |
|
... | ... | |
735 | 742 |
return bytearray_0x(data); |
736 | 743 |
} |
737 | 744 |
|
738 |
protected String bytearray_0x(byte[] data) {
|
|
745 |
protected String bytearray_hex(byte[] data) {
|
|
739 | 746 |
StringBuilder builder = new StringBuilder(); |
740 |
builder.append("0x"); |
|
741 | 747 |
for (byte abyte : data) { |
742 | 748 |
int v = abyte & 0xff; |
743 | 749 |
builder.append(String.format("%02x", v)); |
... | ... | |
745 | 751 |
return builder.toString(); |
746 | 752 |
} |
747 | 753 |
|
754 |
protected String bytearray_0x(byte[] data) { |
|
755 |
return "0x" + bytearray_hex(data); |
|
756 |
} |
|
757 |
|
|
748 | 758 |
protected String bytearray_x(byte[] data) { |
749 |
StringBuilder builder = new StringBuilder(); |
|
750 |
builder.append("x'"); |
|
751 |
for (byte abyte : data) { |
|
752 |
int v = abyte & 0xff; |
|
753 |
builder.append(String.format("%02x", v)); |
|
754 |
} |
|
755 |
builder.append("'"); |
|
756 |
return builder.toString(); |
|
759 |
return "x'" + bytearray_hex(data) + "'"; |
|
757 | 760 |
} |
758 | 761 |
|
759 | 762 |
@Override |
... | ... | |
1005 | 1008 |
} |
1006 | 1009 |
|
1007 | 1010 |
@Override |
1011 |
public Function ST_Simplify(Value geom, Value tolerance) { |
|
1012 |
return function("ST_Simplify", config.getString(Config.ST_Simplify), tolerance); |
|
1013 |
} |
|
1014 |
|
|
1015 |
@Override |
|
1008 | 1016 |
public Function ST_Disjoint(Value geom1, Value geom2) { |
1009 | 1017 |
return function("ST_Disjoint", config.getString(Config.ST_Disjoint), geom1, geom2); |
1010 | 1018 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.spi/src/main/java/org/gvsig/fmap/dal/feature/spi/SQLBuilderBase.java | ||
---|---|---|
63 | 63 |
private int geom_type; |
64 | 64 |
private int geom_subtype; |
65 | 65 |
private int geom_srsid; |
66 |
private boolean _isIndexed; |
|
66 | 67 |
|
67 | 68 |
public ColumnDescriptorBuilderBase(String name, int type, Object defaultValue) { |
68 | 69 |
this.name = name; |
... | ... | |
76 | 77 |
this.geom_type = Geometry.TYPES.GEOMETRY; |
77 | 78 |
this.geom_subtype = Geometry.SUBTYPES.GEOM2D; |
78 | 79 |
this.geom_srsid = -1; |
80 |
this._isIndexed = false; |
|
79 | 81 |
} |
80 | 82 |
|
81 |
public ColumnDescriptorBuilderBase(String name, int type, int type_p, int type_s, boolean isPk, boolean allowNulls, boolean isAutomatic, Object defaultValue) { |
|
83 |
public ColumnDescriptorBuilderBase(String name, int type, int type_p, int type_s, boolean isPk, boolean isIndexed, boolean allowNulls, boolean isAutomatic, Object defaultValue) {
|
|
82 | 84 |
this.name = name; |
83 | 85 |
this.type = type; |
84 | 86 |
this.type_p = type_p; |
... | ... | |
90 | 92 |
this.geom_type = Geometry.TYPES.GEOMETRY; |
91 | 93 |
this.geom_subtype = Geometry.SUBTYPES.GEOM2D; |
92 | 94 |
this.geom_srsid = -1; |
95 |
this._isIndexed = isIndexed; |
|
93 | 96 |
} |
94 | 97 |
|
95 |
public ColumnDescriptorBuilderBase(String name, int geom_type, int geom_subtype, IProjection proj, boolean allowNulls) { |
|
98 |
public ColumnDescriptorBuilderBase(String name, int geom_type, int geom_subtype, IProjection proj, boolean isIndexed, boolean allowNulls) {
|
|
96 | 99 |
this.name = name; |
100 |
this.type = DataTypes.GEOMETRY; |
|
97 | 101 |
this.type_p = 0; |
98 | 102 |
this.type_s = 0; |
99 | 103 |
this.isPk = false; |
... | ... | |
103 | 107 |
this.geom_type = geom_type; |
104 | 108 |
this.geom_subtype = geom_subtype; |
105 | 109 |
this.geom_srsid = getSRSId(proj); |
110 |
this._isIndexed = isIndexed; |
|
106 | 111 |
} |
107 | 112 |
|
108 | 113 |
@Override |
... | ... | |
171 | 176 |
} |
172 | 177 |
|
173 | 178 |
@Override |
179 |
public boolean isIndexed() { |
|
180 |
return _isIndexed; |
|
181 |
} |
|
182 |
|
|
183 |
@Override |
|
174 | 184 |
public void setIsAutomatic(boolean isAutomatic) { |
175 | 185 |
this._isAutomatic = isAutomatic; |
176 | 186 |
} |
... | ... | |
247 | 257 |
|
248 | 258 |
@Override |
249 | 259 |
public TableNameBuilder schema(String name) { |
250 |
this.schemaName = name; |
|
260 |
if( supportSchemas() ) { |
|
261 |
this.schemaName = name; |
|
262 |
} |
|
251 | 263 |
return this; |
252 | 264 |
} |
253 | 265 |
|
... | ... | |
274 | 286 |
|
275 | 287 |
@Override |
276 | 288 |
public boolean has_schema() { |
289 |
if( !supportSchemas() ) { |
|
290 |
return false; |
|
291 |
} |
|
277 | 292 |
return !StringUtils.isEmpty(this.schemaName); |
278 | 293 |
} |
279 | 294 |
|
... | ... | |
1216 | 1231 |
} |
1217 | 1232 |
|
1218 | 1233 |
@Override |
1219 |
public AlterTableBuilder add_column(String columnName, int type, int type_p, int type_s, boolean isPk, boolean allowNulls, boolean isAutomatic, Object defaultValue) { |
|
1234 |
public AlterTableBuilder add_column(String columnName, int type, int type_p, int type_s, boolean isPk, boolean isIndexed, boolean allowNulls, boolean isAutomatic, Object defaultValue) {
|
|
1220 | 1235 |
if (isPk || isAutomatic) { |
1221 | 1236 |
allowNulls = false; |
1222 | 1237 |
} |
1223 |
this.adds.add(new ColumnDescriptorBuilderBase(columnName, type, type_p, type_s, isPk, allowNulls, isAutomatic, defaultValue)); |
|
1238 |
this.adds.add(new ColumnDescriptorBuilderBase(columnName, type, type_p, type_s, isPk, isIndexed, allowNulls, isAutomatic, defaultValue));
|
|
1224 | 1239 |
return this; |
1225 | 1240 |
} |
1226 | 1241 |
|
1227 | 1242 |
@Override |
1228 |
public AlterTableBuilder alter_column(String columnName, int type, int type_p, int type_s, boolean isPk, boolean allowNulls, boolean isAutomatic, Object defaultValue) { |
|
1243 |
public AlterTableBuilder alter_column(String columnName, int type, int type_p, int type_s, boolean isPk, boolean isIndexed, boolean allowNulls, boolean isAutomatic, Object defaultValue) {
|
|
1229 | 1244 |
if (isPk || isAutomatic) { |
1230 | 1245 |
allowNulls = false; |
1231 | 1246 |
} |
1232 |
this.alters.add(new ColumnDescriptorBuilderBase(columnName, type, type_p, type_s, isPk, allowNulls, isAutomatic, defaultValue)); |
|
1247 |
this.alters.add(new ColumnDescriptorBuilderBase(columnName, type, type_p, type_s, isPk, isIndexed, allowNulls, isAutomatic, defaultValue));
|
|
1233 | 1248 |
return this; |
1234 | 1249 |
} |
1235 | 1250 |
|
... | ... | |
1443 | 1458 |
} |
1444 | 1459 |
|
1445 | 1460 |
@Override |
1446 |
public CreateTableBuilderBase add_column(String columnName, int type, int type_p, int type_s, boolean isPk, boolean allowNulls, boolean isAutomatic, Object defaultValue) { |
|
1461 |
public CreateTableBuilderBase add_column(String columnName, int type, int type_p, int type_s, boolean isPk, boolean isIndexed, boolean allowNulls, boolean isAutomatic, Object defaultValue) {
|
|
1447 | 1462 |
if( StringUtils.isEmpty(columnName) ) { |
1448 | 1463 |
throw new IllegalArgumentException("Argument 'columnName' can't be empty."); |
1449 | 1464 |
} |
1450 | 1465 |
if (isPk || isAutomatic) { |
1451 | 1466 |
allowNulls = false; |
1452 | 1467 |
} |
1453 |
this.columns.add(new ColumnDescriptorBuilderBase(columnName, type, type_p, type_s, isPk, allowNulls, isAutomatic, defaultValue)); |
|
1468 |
this.columns.add(new ColumnDescriptorBuilderBase(columnName, type, type_p, type_s, isPk, isIndexed, allowNulls, isAutomatic, defaultValue));
|
|
1454 | 1469 |
return this; |
1455 | 1470 |
} |
1456 | 1471 |
|
1457 | 1472 |
@Override |
1458 |
public CreateTableBuilder add_geometry_column(String columnName, int type, int subtype, IProjection proj, boolean allowNulls) { |
|
1473 |
public CreateTableBuilder add_geometry_column(String columnName, int type, int subtype, IProjection proj, boolean isIndexed, boolean allowNulls) {
|
|
1459 | 1474 |
if( StringUtils.isEmpty(columnName) ) { |
1460 | 1475 |
throw new IllegalArgumentException("Argument 'columnName' can't be empty."); |
1461 | 1476 |
} |
1462 |
this.columns.add(new ColumnDescriptorBuilderBase(columnName, type, subtype, proj, allowNulls)); |
|
1477 |
this.columns.add(new ColumnDescriptorBuilderBase(columnName, type, subtype, proj, isIndexed, allowNulls));
|
|
1463 | 1478 |
return this; |
1464 | 1479 |
} |
1465 | 1480 |
|
... | ... | |
1563 | 1578 |
} |
1564 | 1579 |
builder.append(" )"); |
1565 | 1580 |
sqls.add(builder.toString()); |
1566 |
|
|
1581 |
for (ColumnDescriptorBuilderBase column : columns) { |
|
1582 |
if( column.isIndexed() ) { |
|
1583 |
String sql; |
|
1584 |
String name = "idx_" + this.table().getName() + column.getName(); |
|
1585 |
if( column.isGeometry() ) { |
|
1586 |
sql = MessageFormat.format( |
|
1587 |
config.getString(SQLConfig.CREATE_INDEX_name_ON_table_USING_GIST_column), |
|
1588 |
name, |
|
1589 |
this.table().toString(), |
|
1590 |
column.getName() |
|
1591 |
); |
|
1592 |
} else { |
|
1593 |
sql = MessageFormat.format( |
|
1594 |
config.getString(SQLConfig.CREATE_INDEX_name_ON_table_column), |
|
1595 |
name, |
|
1596 |
this.table().toString(), |
|
1597 |
column.getName() |
|
1598 |
); |
|
1599 |
} |
|
1600 |
sqls.add(sql); |
|
1601 |
} |
|
1602 |
} |
|
1567 | 1603 |
return sqls; |
1568 | 1604 |
} |
1569 | 1605 |
} |
... | ... | |
1789 | 1825 |
config.set(SQLConfig.UPDATE_TABLE_STATISTICS_table, "VACUUM ANALYZE {0}"); |
1790 | 1826 |
config.set(SQLConfig.DROP_TABLE_table, "DROP TABLE {0}"); |
1791 | 1827 |
config.set(SQLConfig.DELETE_GEOMETRY_COLUMN_FROM_TABLE_schema_table, "DELETE FROM GEOMETRY_COLUMNS WHERE f_table_schema = {0} AND f_table_name = {1}"); |
1792 |
config.set(SQLConfig.DELETE_GEOMETRY_COLUMN_FROM_TABLE_table, "DELETE FROM GEOMETRY_COLUMNS WHERE f_table_name, {0}");
|
|
1828 |
config.set(SQLConfig.DELETE_GEOMETRY_COLUMN_FROM_TABLE_table, "DELETE FROM GEOMETRY_COLUMNS WHERE f_table_name = {0}");
|
|
1793 | 1829 |
config.set(SQLConfig.UPDATE_table_SET_columnsAndValues_WHERE_expresion, "UPDATE {0} SET {1} WHERE {2}"); |
1794 | 1830 |
config.set(SQLConfig.UPDATE_table_SET_columnsAndValues, "UPDATE {0} SET {1}"); |
1795 |
config.set(SQLConfig.GRANT_privileges_ON_table_TO_role, "GRANT {0} ON {1} TO {2}"); |
|
1831 |
config.set(SQLConfig.GRANT_privileges_ON_table_TO_role, "GRANT {0} ON {1} TO {2}"); |
|
1832 |
config.set(SQLConfig.CREATE_INDEX_name_ON_table_column, "CREATE INDEX {0} ON {1} ({2})"); |
|
1833 |
config.set(SQLConfig.CREATE_INDEX_name_ON_table_USING_GIST_column, "CREATE INDEX {0} ON {1} USING GIST ({2})"); |
|
1796 | 1834 |
} |
1797 | 1835 |
|
1798 | 1836 |
@Override |
1799 | 1837 |
public String default_schema() { |
1800 | 1838 |
return config.getString(SQLConfig.default_schema); |
1801 | 1839 |
} |
1840 |
|
|
1841 |
@Override |
|
1842 |
public boolean supportSchemas() { |
|
1843 |
return config.getBoolean(Config.support_schemas); |
|
1844 |
} |
|
1802 | 1845 |
|
1803 | 1846 |
@Override |
1804 | 1847 |
public String sqltype(int type, int p, int s) { |
... | ... | |
1904 | 1947 |
sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTILINE,Geometry.SUBTYPES.GEOM2DM), "MULTILINESTRINGM"); |
1905 | 1948 |
sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTILINE,Geometry.SUBTYPES.GEOM3DM), "MULTILINESTRINGZM"); |
1906 | 1949 |
|
1950 |
sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTICURVE,Geometry.SUBTYPES.GEOM2D), "MULTILINESTRING"); |
|
1951 |
sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTICURVE,Geometry.SUBTYPES.GEOM3D), "MULTILINESTRINGZ"); |
|
1952 |
sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTICURVE,Geometry.SUBTYPES.GEOM2DM), "MULTILINESTRINGM"); |
|
1953 |
sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTICURVE,Geometry.SUBTYPES.GEOM3DM), "MULTILINESTRINGZM"); |
|
1954 |
|
|
1907 | 1955 |
sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTIPOLYGON,Geometry.SUBTYPES.GEOM2D), "MULTIPOLYGON"); |
1908 | 1956 |
sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTIPOLYGON,Geometry.SUBTYPES.GEOM3D), "MULTIPOLYGONZ"); |
1909 | 1957 |
sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTIPOLYGON,Geometry.SUBTYPES.GEOM2DM), "MULTIPOLYGONM"); |
1910 | 1958 |
sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTIPOLYGON,Geometry.SUBTYPES.GEOM3DM), "MULTIPOLYGONZM"); |
1911 | 1959 |
|
1960 |
sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTISURFACE,Geometry.SUBTYPES.GEOM2D), "MULTIPOLYGON"); |
|
1961 |
sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTISURFACE,Geometry.SUBTYPES.GEOM3D), "MULTIPOLYGONZ"); |
|
1962 |
sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTISURFACE,Geometry.SUBTYPES.GEOM2DM), "MULTIPOLYGONM"); |
|
1963 |
sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTISURFACE,Geometry.SUBTYPES.GEOM3DM), "MULTIPOLYGONZM"); |
|
1964 |
|
|
1912 | 1965 |
sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.GEOMETRY,Geometry.SUBTYPES.GEOM2D), "GEOMETRY"); |
1913 | 1966 |
sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.GEOMETRY,Geometry.SUBTYPES.GEOM3D), "GEOMETRYZ"); |
1914 | 1967 |
sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.GEOMETRY,Geometry.SUBTYPES.GEOM2DM), "GEOMETRYM"); |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/test/java/org/gvsig/fmap/dal/store/SQLBuilderTest.java | ||
---|---|---|
154 | 154 |
45, |
155 | 155 |
0, |
156 | 156 |
false, |
157 |
false, |
|
157 | 158 |
true, |
158 | 159 |
false, |
159 | 160 |
null |
... | ... | |
165 | 166 |
0, |
166 | 167 |
true, |
167 | 168 |
false, |
169 |
false, |
|
168 | 170 |
true, |
169 | 171 |
0 |
170 | 172 |
); |
... | ... | |
174 | 176 |
0, |
175 | 177 |
0, |
176 | 178 |
false, |
179 |
false, |
|
177 | 180 |
true, |
178 | 181 |
false, |
179 | 182 |
null |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/IntersectsEnvelopeEvaluator.java | ||
---|---|---|
109 | 109 |
|
110 | 110 |
@Override |
111 | 111 |
public String getSQL() { |
112 |
// Los gestores de BBDD no usan indices si se envuelve la columna |
|
113 |
// geometria con la funcion ST_envelope. |
|
114 |
|
|
112 | 115 |
return builder.set( |
113 | 116 |
builder.ST_Intersects( |
114 | 117 |
builder.geometry(envelope.getGeometry(), this.projection), |
115 |
builder.ST_Envelope(builder.column(geomName)) |
|
118 |
// builder.ST_Envelope(builder.column(geomName)) |
|
119 |
builder.column(geomName) |
|
116 | 120 |
) |
117 | 121 |
).toString(); |
118 | 122 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.swing/org.gvsig.exportto.swing.prov/org.gvsig.exportto.swing.prov.jdbc/src/main/java/org/gvsig/exportto/swing/prov/jdbc/panel/JDBCConnectionPanel.java | ||
---|---|---|
80 | 80 |
@Override |
81 | 81 |
public boolean isValidPanel() throws ExporttoPanelValidationException { |
82 | 82 |
DBServerExplorerParameters connection = this.connectionPanel.getServerExplorerParameters(); |
83 |
if( connection==null ) { |
|
84 |
return false; |
|
85 |
} |
|
83 | 86 |
try { |
84 | 87 |
connection.validate(); |
85 | 88 |
return true; |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.swing/org.gvsig.exportto.swing.prov/org.gvsig.exportto.swing.prov.jdbc/src/main/java/org/gvsig/exportto/swing/prov/jdbc/panel/SelectTableNamePanel.java | ||
---|---|---|
26 | 26 |
import java.awt.event.ActionListener; |
27 | 27 |
import java.util.Iterator; |
28 | 28 |
import java.util.List; |
29 |
import java.util.logging.Level; |
|
29 | 30 |
|
30 | 31 |
import javax.swing.DefaultListModel; |
31 | 32 |
import javax.swing.JComponent; |
... | ... | |
44 | 45 |
import org.gvsig.exportto.swing.spi.ExporttoSwingProviderPanel; |
45 | 46 |
import org.gvsig.fmap.dal.DALLocator; |
46 | 47 |
import org.gvsig.fmap.dal.DataManager; |
48 |
import org.gvsig.fmap.dal.SQLBuilder; |
|
49 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
50 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
51 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
47 | 52 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorer; |
48 | 53 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
49 | 54 |
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters; |
... | ... | |
67 | 72 |
private final ExporttoJDBCOptions provider; |
68 | 73 |
|
69 | 74 |
private FillTablesListTask task = null; |
75 |
private SQLBuilder sqlbuilder; |
|
70 | 76 |
|
71 | 77 |
private static class TableItem { |
72 | 78 |
|
... | ... | |
79 | 85 |
} |
80 | 86 |
|
81 | 87 |
public TableItem(JDBCStoreParameters params) { |
82 |
this(params.getSchema() + "." + params.getTable(), params); |
|
88 |
this( StringUtils.isEmpty(params.getSchema())? |
|
89 |
params.getTable() : params.getSchema() + "." + params.getTable(), |
|
90 |
params); |
|
83 | 91 |
} |
84 | 92 |
|
85 | 93 |
@Override |
... | ... | |
206 | 214 |
); |
207 | 215 |
} |
208 | 216 |
String schema = this.getSchema(); |
209 |
if (schema == null) { |
|
210 |
throw new ExporttoPanelValidationException( |
|
211 |
i18nManager.getTranslation( |
|
212 |
"_The_name_of_schema_cannot_be_empty" |
|
213 |
) |
|
214 |
); |
|
217 |
if( sqlbuilder.supportSchemas() ) { |
|
218 |
if (schema == null) { |
|
219 |
throw new ExporttoPanelValidationException( |
|
220 |
i18nManager.getTranslation( |
|
221 |
"_The_name_of_schema_cannot_be_empty" |
|
222 |
) |
|
223 |
); |
|
224 |
} |
|
215 | 225 |
} |
216 | 226 |
if (this.rdoCreateTable.isSelected()) { |
217 | 227 |
String tablename_tr = tablename; |
... | ... | |
244 | 254 |
ListModel model = this.lstTables.getModel(); |
245 | 255 |
for (int i = 0; i < model.getSize(); i++) { |
246 | 256 |
TableItem item = (TableItem) model.getElementAt(i); |
247 |
if (schema.equals(item.getParams().getSchema())
|
|
248 |
&& tablename.equals(item.getParams().getTable())) {
|
|
257 |
if ( StringUtils.equals(schema,item.getParams().getSchema())
|
|
258 |
&& StringUtils.equals(tablename,item.getParams().getTable())) {
|
|
249 | 259 |
String msg = i18nManager.getTranslation( |
250 | 260 |
"_La_tabla_{0}_{1}_ya_existe_en_la_base_de_datos_Seleccione_la_opcion_de_insertar_registros_en_una_tabla_existente_para_a?adir_los_datos_a_esta_o_indique_otro_nombre", |
251 | 261 |
new String[]{schema, tablename} |
... | ... | |
259 | 269 |
|
260 | 270 |
@Override |
261 | 271 |
public void enterPanel() { |
272 |
JDBCServerExplorerParameters explorerParameters = provider.getExplorerParameters(); |
|
273 |
if (explorerParameters != null) { |
|
274 |
try { |
|
275 |
DataManager dataManager = DALLocator.getDataManager(); |
|
276 |
JDBCServerExplorer explorer = (JDBCServerExplorer) dataManager.openServerExplorer( |
|
277 |
explorerParameters.getExplorerName(), |
|
278 |
explorerParameters |
|
279 |
); |
|
280 |
this.sqlbuilder = explorer.createSQLBuilder(); |
|
281 |
} catch (Exception ex) { |
|
282 |
throw new RuntimeException("Can't retrieve the sqlbuilder", ex); |
|
283 |
} |
|
284 |
} |
|
262 | 285 |
this.fillTablesList(); |
263 | 286 |
} |
264 | 287 |
|
... | ... | |
325 | 348 |
|
326 | 349 |
@Override |
327 | 350 |
public void run() { |
328 |
txtSchema.setText(explorer.createSQLBuilder().default_schema()); |
|
351 |
if( sqlbuilder.supportSchemas() ) { |
|
352 |
txtSchema.setText(sqlbuilder.default_schema()); |
|
353 |
} else { |
|
354 |
txtSchema.setText(""); |
|
355 |
txtSchema.setEnabled(false); |
|
356 |
} |
|
329 | 357 |
} |
330 | 358 |
}); |
331 | 359 |
|
332 | 360 |
Also available in: Unified diff