Revision 47784
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/JDBCUtils.java | ||
---|---|---|
85 | 85 |
} |
86 | 86 |
|
87 | 87 |
public static ResultSet executeQuery(Statement st, String sql) throws SQLException { |
88 |
if( LOGGER.isDebugEnabled() ) { |
|
89 |
LOGGER.debug("["+getConnId(st)+"] executeQuery(st) SQL= " + sql); |
|
90 |
} |
|
88 |
ResultSet rs; |
|
91 | 89 |
try { |
92 |
@SuppressWarnings("null") |
|
93 |
ResultSet rs = st.executeQuery(sql); |
|
90 |
if( LOGGER.isDebugEnabled() ) { |
|
91 |
long t1 = System.currentTimeMillis(); |
|
92 |
rs = st.executeQuery(sql); |
|
93 |
long t2 = System.currentTimeMillis(); |
|
94 |
LOGGER.debug("["+getConnId(st)+"] executeQuery(st) "+(t2-t1)+"ms SQL= " + sql); |
|
95 |
} else { |
|
96 |
rs = st.executeQuery(sql); |
|
97 |
} |
|
94 | 98 |
return rs; |
95 | 99 |
} catch(Exception ex) { |
96 | 100 |
LOGGER.debug("execute SQL: " + sql, ex); |
... | ... | |
98 | 102 |
} |
99 | 103 |
} |
100 | 104 |
|
101 |
@SuppressWarnings("null") |
|
102 | 105 |
public static void execute(Statement st, String sql) throws SQLException { |
103 |
if( LOGGER.isDebugEnabled() ) { |
|
104 |
LOGGER.debug("["+getConnId(st)+"] execute(st) SQL: " + sql); |
|
105 |
} |
|
106 | 106 |
try { |
107 |
st.execute(sql); |
|
107 |
if( LOGGER.isDebugEnabled() ) { |
|
108 |
long t1 = System.currentTimeMillis(); |
|
109 |
st.execute(sql); |
|
110 |
long t2 = System.currentTimeMillis(); |
|
111 |
LOGGER.debug("["+getConnId(st)+"] execute(st) "+(t2-t1)+"ms SQL: " + sql); |
|
112 |
} else { |
|
113 |
st.execute(sql); |
|
114 |
} |
|
108 | 115 |
} catch(Exception ex) { |
109 | 116 |
LOGGER.debug("execute SQL: " + sql, ex); |
110 | 117 |
throw ex; |
... | ... | |
112 | 119 |
} |
113 | 120 |
|
114 | 121 |
public static void execute(Connection connection, String sql) throws SQLException { |
115 |
if( LOGGER.isDebugEnabled() ) { |
|
116 |
LOGGER.debug("["+getConnId(connection)+"] execute(conn) SQL: " + sql); |
|
117 |
} |
|
118 | 122 |
try { |
119 |
@SuppressWarnings("null") |
|
120 | 123 |
Statement st = connection.createStatement(); |
121 |
st.execute(sql); |
|
124 |
if( LOGGER.isDebugEnabled() ) { |
|
125 |
long t1 = System.currentTimeMillis(); |
|
126 |
st.execute(sql); |
|
127 |
long t2 = System.currentTimeMillis(); |
|
128 |
LOGGER.debug("["+getConnId(connection)+"] execute(conn) "+(t2-t1)+"ms SQL: " + sql); |
|
129 |
} else { |
|
130 |
st.execute(sql); |
|
131 |
} |
|
122 | 132 |
} catch(Exception ex) { |
123 | 133 |
LOGGER.debug("execute SQL: " + sql, ex); |
124 | 134 |
throw ex; |
... | ... | |
134 | 144 |
while( it.hasNext() ) { |
135 | 145 |
sql = it.next(); |
136 | 146 |
if( LOGGER.isDebugEnabled() ) { |
137 |
LOGGER.debug("["+getConnId(connection)+"] execute(conn) SQLs: " + sql); |
|
147 |
long t1 = System.currentTimeMillis(); |
|
148 |
st.execute(sql); |
|
149 |
long t2 = System.currentTimeMillis(); |
|
150 |
LOGGER.debug("["+getConnId(connection)+"] execute(conn, sqls) "+(t2-t1)+"ms SQLs: " + sql); |
|
151 |
} else { |
|
152 |
st.execute(sql); |
|
138 | 153 |
} |
139 |
st.execute(sql); |
|
140 | 154 |
} |
141 | 155 |
} catch (SQLException ex) { |
142 | 156 |
LOGGER.debug("execute SQL: " + sql, ex); |
... | ... | |
147 | 161 |
} |
148 | 162 |
|
149 | 163 |
public static ResultSet executeQuery(PreparedStatement st, String sql) throws SQLException { |
150 |
if( LOGGER.isDebugEnabled() ) { |
|
151 |
LOGGER.debug("["+getConnId(st)+"] executeQuery(pst) SQL= "+ getSQLInfo(st,sql)); |
|
152 |
} |
|
164 |
ResultSet rs; |
|
153 | 165 |
try { |
154 |
@SuppressWarnings("null") |
|
155 |
ResultSet rs = st.executeQuery(); |
|
166 |
if( LOGGER.isDebugEnabled() ) { |
|
167 |
long t1 = System.currentTimeMillis(); |
|
168 |
rs = st.executeQuery(); |
|
169 |
long t2 = System.currentTimeMillis(); |
|
170 |
LOGGER.debug("["+getConnId(st)+"] executeQuery(pst) "+(t2-t1)+"ms SQL= "+ getSQLInfo(st,sql)); |
|
171 |
} else { |
|
172 |
rs = st.executeQuery(); |
|
173 |
} |
|
156 | 174 |
return rs; |
157 | 175 |
} catch(Exception ex) { |
158 | 176 |
LOGGER.debug("execute query SQL: " + getSQLInfo(st,sql), ex); |
... | ... | |
160 | 178 |
} |
161 | 179 |
} |
162 | 180 |
|
163 |
@SuppressWarnings("null") |
|
164 | 181 |
public static void execute(PreparedStatement st, String sql) throws SQLException { |
165 |
if( LOGGER.isDebugEnabled() ) { |
|
166 |
LOGGER.debug("["+getConnId(st)+"] execute(pst) SQL= "+ getSQLInfo(st,sql)); |
|
167 |
} |
|
168 | 182 |
try { |
169 |
st.execute(); |
|
183 |
if( LOGGER.isDebugEnabled() ) { |
|
184 |
long t1 = System.currentTimeMillis(); |
|
185 |
st.execute(); |
|
186 |
long t2 = System.currentTimeMillis(); |
|
187 |
LOGGER.debug("["+getConnId(st)+"] execute(pst) "+(t2-t1)+"ms SQL= "+ getSQLInfo(st,sql)); |
|
188 |
} else { |
|
189 |
st.execute(); |
|
190 |
} |
|
170 | 191 |
} catch(Exception ex) { |
171 | 192 |
LOGGER.debug("execute SQL: " + getSQLInfo(st,sql), ex); |
172 | 193 |
throw new SQLException(ex.getMessage() +getSQLInfo(st,sql), ex); |
... | ... | |
174 | 195 |
} |
175 | 196 |
|
176 | 197 |
public static int executeUpdate(PreparedStatement st, String sql) throws SQLException { |
177 |
if( LOGGER.isDebugEnabled() ) { |
|
178 |
LOGGER.debug("["+getConnId(st)+"] executeUpdate(pst) SQL= "+ getSQLInfo(st,sql)); |
|
179 |
} |
|
198 |
int r; |
|
180 | 199 |
try { |
181 |
return st.executeUpdate(); |
|
200 |
if( LOGGER.isDebugEnabled() ) { |
|
201 |
long t1 = System.currentTimeMillis(); |
|
202 |
r = st.executeUpdate(); |
|
203 |
long t2 = System.currentTimeMillis(); |
|
204 |
LOGGER.debug("["+getConnId(st)+"] executeUpdate(pst) "+(t2-t1)+"ms SQL= "+ getSQLInfo(st,sql)); |
|
205 |
} else { |
|
206 |
r = st.executeUpdate(); |
|
207 |
} |
|
208 |
return r; |
|
182 | 209 |
} catch(Exception ex) { |
183 | 210 |
LOGGER.debug("execute update SQL: " + getSQLInfo(st,sql), ex); |
184 | 211 |
throw new SQLException(ex.getMessage() +getSQLInfo(st,sql), ex); |
... | ... | |
186 | 213 |
} |
187 | 214 |
|
188 | 215 |
public static int executeUpdate(Statement st, String sql) throws SQLException { |
189 |
if( LOGGER.isDebugEnabled() ) { |
|
190 |
LOGGER.debug("["+getConnId(st)+"] executeUpdate(st) SQL= "+ sql); |
|
191 |
} |
|
216 |
int r; |
|
192 | 217 |
try { |
193 |
return st.executeUpdate(sql); |
|
218 |
if( LOGGER.isDebugEnabled() ) { |
|
219 |
long t1 = System.currentTimeMillis(); |
|
220 |
r = st.executeUpdate(sql); |
|
221 |
long t2 = System.currentTimeMillis(); |
|
222 |
LOGGER.debug("["+getConnId(st)+"] executeUpdate(st) "+(t2-t1)+"ms SQL= "+ sql); |
|
223 |
} else { |
|
224 |
r = st.executeUpdate(sql); |
|
225 |
} |
|
226 |
return r; |
|
194 | 227 |
} catch(Exception ex) { |
195 | 228 |
LOGGER.debug("execute update SQL: " + sql, ex); |
196 | 229 |
throw ex; |
... | ... | |
198 | 231 |
} |
199 | 232 |
|
200 | 233 |
public static int[] executeBatch(PreparedStatement st, String sql) throws SQLException { |
201 |
if( LOGGER.isDebugEnabled() ) { |
|
202 |
LOGGER.debug("["+getConnId(st)+"] executeBatch(pst) SQL= "+ getSQLInfo(st,sql)); |
|
203 |
} |
|
234 |
int[] r; |
|
204 | 235 |
try { |
205 |
return st.executeBatch(); |
|
236 |
if( LOGGER.isDebugEnabled() ) { |
|
237 |
long t1 = System.currentTimeMillis(); |
|
238 |
r = st.executeBatch(); |
|
239 |
long t2 = System.currentTimeMillis(); |
|
240 |
LOGGER.debug("["+getConnId(st)+"] executeBatch(pst) "+(t2-t1)+"ms SQL= "+ getSQLInfo(st,sql)); |
|
241 |
} else { |
|
242 |
r = st.executeBatch(); |
|
243 |
} |
|
244 |
return r; |
|
206 | 245 |
} catch(Exception ex) { |
207 | 246 |
LOGGER.debug("execute batch SQL: " + getSQLInfo(st,sql), ex); |
208 | 247 |
throw ex; |
... | ... | |
210 | 249 |
} |
211 | 250 |
|
212 | 251 |
public static void addBatch(PreparedStatement st, String sql) throws SQLException { |
213 |
if( LOGGER.isDebugEnabled() ) { |
|
214 |
LOGGER.debug("["+getConnId(st)+"] addBatch(pst) SQL= "+ getSQLInfo(st,sql)); |
|
215 |
} |
|
216 | 252 |
try { |
217 |
st.addBatch(); |
|
253 |
if( LOGGER.isDebugEnabled() ) { |
|
254 |
long t1 = System.currentTimeMillis(); |
|
255 |
st.addBatch(); |
|
256 |
long t2 = System.currentTimeMillis(); |
|
257 |
LOGGER.debug("["+getConnId(st)+"] addBatch(pst) "+(t2-t1)+"ms SQL= "+ getSQLInfo(st,sql)); |
|
258 |
} else { |
|
259 |
st.addBatch(); |
|
260 |
} |
|
218 | 261 |
} catch(Exception ex) { |
219 | 262 |
LOGGER.debug("add batch SQL: " + getSQLInfo(st,sql), ex); |
220 | 263 |
throw ex; |
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/JDBCStoreParametersBase.java | ||
---|---|---|
297 | 297 |
* |
298 | 298 |
* @return |
299 | 299 |
*/ |
300 |
@Override |
|
301 |
public String getSourceId() { |
|
302 |
if (getTable() != null) { |
|
303 |
return MessageFormat.format( |
|
304 |
"provider={0}:url=\"{1}\":table=\"{2}\":user={3}:driverclass={4}", |
|
305 |
this.getDataStoreName(), |
|
306 |
this.getUrl(), |
|
307 |
this.getTable(), |
|
308 |
this.getUser(), |
|
309 |
this.getJDBCDriverClassName() |
|
310 |
); |
|
311 |
} |
|
312 |
return MessageFormat.format( |
|
313 |
"provider={0}:url=\"{1}\":sql=\"{2}\":user={3}:driverclass={4}", |
|
314 |
this.getDataStoreName(), |
|
315 |
this.getUrl(), |
|
316 |
this.getSQL(), |
|
317 |
this.getUser(), |
|
318 |
this.getJDBCDriverClassName() |
|
319 |
); |
|
320 |
} |
|
300 |
// @Override
|
|
301 |
// public String getSourceId() {
|
|
302 |
// if (getTable() != null) {
|
|
303 |
// return MessageFormat.format(
|
|
304 |
// "provider={0}:url=\"{1}\":table=\"{2}\":user={3}:driverclass={4}",
|
|
305 |
// this.getDataStoreName(),
|
|
306 |
// this.getUrl(),
|
|
307 |
// this.getTable(),
|
|
308 |
// this.getUser(),
|
|
309 |
// this.getJDBCDriverClassName()
|
|
310 |
// );
|
|
311 |
// }
|
|
312 |
// return MessageFormat.format(
|
|
313 |
// "provider={0}:url=\"{1}\":sql=\"{2}\":user={3}:driverclass={4}",
|
|
314 |
// this.getDataStoreName(),
|
|
315 |
// this.getUrl(),
|
|
316 |
// this.getSQL(),
|
|
317 |
// this.getUser(),
|
|
318 |
// this.getJDBCDriverClassName()
|
|
319 |
// );
|
|
320 |
// }
|
|
321 | 321 |
|
322 | 322 |
@Override |
323 | 323 |
public String getUrl() { |
... | ... | |
361 | 361 |
return true; |
362 | 362 |
} |
363 | 363 |
|
364 |
@Override |
|
365 |
public String getSourceId() { |
|
366 |
StringBuilder builder = new StringBuilder(); |
|
367 |
builder.append(this.getTable()); |
|
368 |
builder.append("("); |
|
369 |
boolean needComma = false; |
|
370 |
if( StringUtils.isNotBlank(this.getHost()) ) { |
|
371 |
builder.append("host="); |
|
372 |
builder.append(this.getHost()); |
|
373 |
needComma = true; |
|
374 |
} |
|
375 |
if( this.getPort()>0 ) { |
|
376 |
if (needComma ) { |
|
377 |
builder.append(", "); |
|
378 |
} |
|
379 |
builder.append("port="); |
|
380 |
builder.append(this.getPort()); |
|
381 |
needComma = true; |
|
382 |
} |
|
383 |
if( StringUtils.isNotBlank(this.getDBName()) ) { |
|
384 |
if (needComma ) { |
|
385 |
builder.append(", "); |
|
386 |
} |
|
387 |
builder.append("db="); |
|
388 |
builder.append(this.getDBName()); |
|
389 |
needComma = true; |
|
390 |
} |
|
391 |
if( StringUtils.isNotBlank(this.getSchema()) ) { |
|
392 |
if (needComma ) { |
|
393 |
builder.append(", "); |
|
394 |
} |
|
395 |
builder.append("schema="); |
|
396 |
builder.append(this.getSchema()); |
|
397 |
needComma = true; |
|
398 |
} |
|
399 |
builder.append(")"); |
|
400 |
return builder.toString(); |
|
401 |
} |
|
402 |
|
|
364 | 403 |
} |
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/featuretype/FeatureAttributeTreeModel.java | ||
---|---|---|
4 | 4 |
import java.util.Collections; |
5 | 5 |
import java.util.HashSet; |
6 | 6 |
import java.util.List; |
7 |
import java.util.Locale; |
|
7 | 8 |
import java.util.Set; |
8 | 9 |
import java.util.function.Predicate; |
10 |
import java.util.function.Supplier; |
|
9 | 11 |
import javax.swing.event.TreeModelListener; |
10 | 12 |
import javax.swing.tree.TreeModel; |
11 | 13 |
import javax.swing.tree.TreePath; |
... | ... | |
30 | 32 |
import org.slf4j.Logger; |
31 | 33 |
import org.slf4j.LoggerFactory; |
32 | 34 |
import org.gvsig.expressionevaluator.Code.Callable; |
35 |
import org.gvsig.fmap.dal.StoresRepository; |
|
33 | 36 |
import org.gvsig.fmap.dal.feature.FeatureExtraColumns; |
34 | 37 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
38 |
import org.gvsig.fmap.dal.feature.OpenFeatureStoreParameters; |
|
35 | 39 |
import org.gvsig.fmap.dal.swing.DALSwingLocator; |
36 | 40 |
import org.gvsig.tools.dispose.Disposable; |
37 | 41 |
import org.gvsig.tools.dispose.DisposeUtils; |
... | ... | |
64 | 68 |
implements Node { |
65 | 69 |
|
66 | 70 |
private List<Node> childs; |
67 |
private FeatureStore store;
|
|
71 |
private Supplier<FeatureStore> store;
|
|
68 | 72 |
private final int type; |
69 | 73 |
|
70 |
public DefaultNode(FeatureStore store, List<OrderedAttribute> attributes) {
|
|
71 |
super(store == null ? "" : store.getName(), null);
|
|
74 |
public DefaultNode(String name, Supplier<FeatureStore> store, List<OrderedAttribute> attributes) {
|
|
75 |
super(name, null);
|
|
72 | 76 |
DisposeUtils.bind(store); |
73 | 77 |
this.store = store; |
74 | 78 |
this.type = OrderedAttribute.TYPE_REGURAL; |
... | ... | |
78 | 82 |
} |
79 | 83 |
} |
80 | 84 |
|
81 |
private DefaultNode(FeatureStore store, FeatureAttributeDescriptor attribute, int type) {
|
|
85 |
private DefaultNode(Supplier<FeatureStore> store, FeatureAttributeDescriptor attribute, int type) {
|
|
82 | 86 |
super(attribute.getLocalizedLabel(), attribute); |
83 | 87 |
DisposeUtils.bind(store); |
84 | 88 |
// LOGGER.info("BIND "+store.hashCode()+", "+this.getLabel()+", "+this.hashCode()); |
... | ... | |
120 | 124 |
|
121 | 125 |
@Override |
122 | 126 |
public FeatureStore getFeatureStore() { |
123 |
return this.store; |
|
127 |
return this.store.get();
|
|
124 | 128 |
} |
125 | 129 |
|
126 | 130 |
@Override |
... | ... | |
142 | 146 |
ContextForeingKey context = foreingKey.createContext(); |
143 | 147 |
// Ojo, no liberamos el contexto para que no se destruya el store. |
144 | 148 |
try { |
145 |
FeatureStore theStore = foreingKey.getFeatureStore(context); |
|
146 |
if (theStore == null) { |
|
149 |
// FeatureStore theStore = foreingKey.getFeatureStore(context); |
|
150 |
StoresRepository storesRepository = foreingKey.getStoresRepository(context); |
|
151 |
String tableName = foreingKey.getTableName(); |
|
152 |
Supplier<FeatureStore> theStore = () -> (FeatureStore) storesRepository.getStore(tableName); |
|
153 |
FeatureType featureType = storesRepository.getFeatureType(tableName); |
|
154 |
OpenFeatureStoreParameters theStoreParams = (OpenFeatureStoreParameters) storesRepository.get(tableName); |
|
155 |
if (featureType == null || theStoreParams==null ) { |
|
147 | 156 |
this.childs = Collections.EMPTY_LIST; |
148 | 157 |
} else { |
149 |
FeatureType featureType = foreingKey.getFeatureType(context); |
|
150 |
String fullName = theStore.getFullName(); |
|
158 |
String fullName = theStoreParams.getSourceId(); |
|
151 | 159 |
if (stores.contains(fullName)) { |
152 | 160 |
// Si ya hemos a?adido el store al arbol no lo volvemos a a?adir. |
153 | 161 |
this.childs = Collections.EMPTY_LIST; |
... | ... | |
185 | 193 |
Codes parameters = caller.parameters(); |
186 | 194 |
String tableName = (String) ((Code.Identifier)(parameters.get(1))).name(); |
187 | 195 |
DataManager dataManager = DALLocator.getDataManager(); |
188 |
FeatureStore theStore = (FeatureStore) dataManager.getStoresRepository().getStore(tableName); |
|
189 |
if (theStore == null) { |
|
196 |
// FeatureStore theStore = (FeatureStore) dataManager.getStoresRepository().getStore(tableName); |
|
197 |
StoresRepository storesRepository = dataManager.getStoresRepository(); |
|
198 |
Supplier<FeatureStore> theStore = () -> (FeatureStore) storesRepository.getStore(tableName); |
|
199 |
OpenFeatureStoreParameters theStoreParams = (OpenFeatureStoreParameters) storesRepository.get(tableName); |
|
200 |
FeatureType featureType = storesRepository.getFeatureType(tableName); |
|
201 |
if (featureType == null || theStoreParams==null ) { |
|
190 | 202 |
this.childs = Collections.EMPTY_LIST; |
191 | 203 |
} else { |
192 |
FeatureType featureType = theStore.getDefaultFeatureType(); |
|
193 |
String fullName = theStore.getFullName();
|
|
204 |
// FeatureType featureType = theStore.getDefaultFeatureType();
|
|
205 |
String fullName = theStoreParams.getSourceId();
|
|
194 | 206 |
if (stores.contains(fullName)) { |
195 | 207 |
// Si ya hemos a?adido el store al arbol no lo volvemos a a?adir. |
196 | 208 |
this.childs = Collections.EMPTY_LIST; |
... | ... | |
208 | 220 |
this.childs.add(new DefaultNode(theStore, attribute.getDescriptor(), attribute.getType())); |
209 | 221 |
} |
210 | 222 |
stores.add(fullName); |
211 |
DisposeUtils.disposeQuietly(theStore); |
|
223 |
// DisposeUtils.disposeQuietly(theStore);
|
|
212 | 224 |
} |
213 | 225 |
} |
214 | 226 |
} |
... | ... | |
236 | 248 |
@Override |
237 | 249 |
public void dispose() { |
238 | 250 |
// LOGGER.info("DISPOSE "+store.hashCode()+", "+this.getLabel()+", "+this.hashCode()); |
239 |
DisposeUtils.disposeQuietly(this.store); |
|
251 |
// DisposeUtils.disposeQuietly(this.store);
|
|
240 | 252 |
this.store = null; |
241 | 253 |
if (this.childs!=null) { |
242 | 254 |
for (Node child : this.childs) { |
... | ... | |
286 | 298 |
-1, |
287 | 299 |
extra |
288 | 300 |
); |
289 |
this.root = new DefaultNode(store, attributes); |
|
301 |
this.root = new DefaultNode( |
|
302 |
store.getName(), |
|
303 |
() -> store, |
|
304 |
attributes |
|
305 |
); |
|
290 | 306 |
this.stores = new HashSet<>(); |
291 | 307 |
this.showRelations = showRelations; |
292 | 308 |
} |
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/searchpanel/SearchConditionFieldController.java | ||
---|---|---|
305 | 305 |
|
306 | 306 |
@Override |
307 | 307 |
public String getLabel() { |
308 |
String theLabel = DALSwingLocator.getDataSwingManager().getAttributeDescriptorLabel(attrdesc, showStoreName ? store.getName() : null); |
|
308 |
DataSwingManager dataSwingManager = DALSwingLocator.getDataSwingManager(); |
|
309 |
String theLabel; |
|
310 |
FeatureAttributeDescriptor parentDescriptor = this.getParentDescriptor(); |
|
311 |
if( parentDescriptor==null ) { |
|
312 |
theLabel = dataSwingManager.getAttributeDescriptorLabel(attrdesc, showStoreName ? store.getName() : null); |
|
313 |
} else { |
|
314 |
switch (parentDescriptor.getRelationType()) { |
|
315 |
case DynField.RELATION_TYPE_COLLABORATION: |
|
316 |
case DynField.RELATION_TYPE_IDENTITY: |
|
317 |
theLabel = dataSwingManager.getAttributeDescriptorLabel(attrdesc)+" de "+store.getName(); |
|
318 |
break; // "_XFieldNameX_of_XTableNameX" |
|
319 |
|
|
320 |
case DynField.RELATION_TYPE_AGGREGATE: |
|
321 |
case DynField.RELATION_TYPE_COMPOSITION: |
|
322 |
theLabel = "\u2203 "+store.getName()+" que "+dataSwingManager.getAttributeDescriptorLabel(attrdesc); |
|
323 |
break; // "_With_some_XTableNameX_that_XFieldNameX". U+2203 -> Exsite alguno |
|
324 |
default: |
|
325 |
theLabel = dataSwingManager.getAttributeDescriptorLabel(attrdesc, showStoreName ? store.getName() : null); |
|
326 |
} |
|
327 |
} |
|
309 | 328 |
switch (this.presentationMode) { |
310 | 329 |
case Search.OrderedAttribute.TYPE_REGURAL: |
311 | 330 |
break; |
... | ... | |
1387 | 1406 |
FeatureType featureType = featureAttributeDescriptor.getFeatureType(); |
1388 | 1407 |
String storeName = featureType.getStore().getName(); |
1389 | 1408 |
pathArray.add(storeName); |
1390 |
} |
|
1409 |
}
|
|
1391 | 1410 |
arrayBuilder.add(pathArray); |
1392 | 1411 |
} |
1393 | 1412 |
String relational = this.getRelationalOperator(); |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/test/java/org/gvsig/fmap/dal/feature/DummyFetureStore.java | ||
---|---|---|
7 | 7 |
import java.util.List; |
8 | 8 |
import java.util.Map; |
9 | 9 |
import java.util.Set; |
10 |
import java.util.function.Predicate; |
|
10 | 11 |
import javax.json.JsonObject; |
11 | 12 |
|
12 | 13 |
import org.cresques.cts.IProjection; |
... | ... | |
1005 | 1006 |
return this.getName(); |
1006 | 1007 |
} |
1007 | 1008 |
|
1009 |
@Override |
|
1010 |
public Predicate<FeatureStoreNotification> setNotificationsFilter(Predicate<FeatureStoreNotification> filter) { |
|
1011 |
return null; |
|
1012 |
} |
|
1013 |
|
|
1008 | 1014 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.lib/src/main/java/org/gvsig/fmap/dal/feature/spi/simpleprovider/SimpleSequentialReaderStoreParameters.java | ||
---|---|---|
294 | 294 |
return b; |
295 | 295 |
} |
296 | 296 |
|
297 |
@Override |
|
298 |
public String getSourceId() { |
|
299 |
return this.toString(); // FIXME: Check if is correnct |
|
300 |
} |
|
301 |
|
|
297 | 302 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.lib/src/main/java/org/gvsig/fmap/dal/store/simplereader/SimpleReaderStoreParameters.java | ||
---|---|---|
362 | 362 |
} |
363 | 363 |
return this.featureType; |
364 | 364 |
} |
365 |
|
|
365 |
|
|
366 |
@Override |
|
367 |
public String getSourceId() { |
|
368 |
return this.toString(); // FIXME: Check if is correnct |
|
369 |
} |
|
366 | 370 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/DefaultFeature.java | ||
---|---|---|
41 | 41 |
import javax.json.JsonObject; |
42 | 42 |
import org.apache.commons.collections4.CollectionUtils; |
43 | 43 |
import org.apache.commons.lang3.ArrayUtils; |
44 |
import static org.apache.commons.lang3.ObjectUtils.mode; |
|
44 | 45 |
import org.apache.commons.lang3.StringUtils; |
45 | 46 |
import org.cresques.cts.IProjection; |
46 | 47 |
import org.gvsig.expressionevaluator.Expression; |
... | ... | |
2040 | 2041 |
Expression filter = ExpressionUtils.createExpression(builder.toString()); |
2041 | 2042 |
return filter; |
2042 | 2043 |
} |
2043 |
} |
|
2044 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/DefaultFeatureStore.java | ||
---|---|---|
35 | 35 |
import java.util.Objects; |
36 | 36 |
import java.util.Set; |
37 | 37 |
import java.util.UUID; |
38 |
import java.util.function.Predicate; |
|
38 | 39 |
import javax.json.JsonObject; |
39 | 40 |
import org.apache.commons.io.FilenameUtils; |
40 | 41 |
import org.apache.commons.io.IOUtils; |
... | ... | |
265 | 266 |
private final Observer transactionObserver; |
266 | 267 |
private String fullNameForTraces; |
267 | 268 |
|
269 |
private Predicate<FeatureStoreNotification> notificacionsFilter; |
|
270 |
|
|
268 | 271 |
private class StateInformation extends HashMap<Object, Object> { |
269 | 272 |
|
270 | 273 |
private static final long serialVersionUID = 4109026189635185666L; |
... | ... | |
1071 | 1074 |
@Override |
1072 | 1075 |
public FeatureStoreNotification notifyChange(FeatureStoreNotification storeNotification) { |
1073 | 1076 |
if (delegateObservable != null) { |
1074 |
try { |
|
1075 |
delegateObservable.notifyObservers(storeNotification); |
|
1076 |
} catch (Throwable ex) { |
|
1077 |
LOGGER.warn("Problems notifying changes in the store '" + this.getName() + " (" + storeNotification.getType() + ").", ex); |
|
1077 |
if( doesTheNotificationHaveToBeSent(storeNotification) ) { |
|
1078 |
try { |
|
1079 |
delegateObservable.notifyObservers(storeNotification); |
|
1080 |
} catch (Throwable ex) { |
|
1081 |
LOGGER.warn("Problems notifying changes in the store '" + this.getName() + " (" + storeNotification.getType() + ").", ex); |
|
1082 |
} |
|
1078 | 1083 |
} |
1079 | 1084 |
} |
1080 | 1085 |
return storeNotification; |
... | ... | |
4104 | 4109 |
} |
4105 | 4110 |
} |
4106 | 4111 |
|
4107 |
|
|
4112 |
public Predicate<FeatureStoreNotification> setNotificationsFilter(Predicate<FeatureStoreNotification> filter) { |
|
4113 |
Predicate<FeatureStoreNotification> x = this.notificacionsFilter; |
|
4114 |
this.notificacionsFilter = filter; |
|
4115 |
return x; |
|
4116 |
} |
|
4117 |
|
|
4118 |
private boolean doesTheNotificationHaveToBeSent(FeatureStoreNotification notfication) { |
|
4119 |
if( this.notificacionsFilter==null ) { |
|
4120 |
return false; |
|
4121 |
} |
|
4122 |
return !this.notificacionsFilter.test(notfication); |
|
4123 |
} |
|
4108 | 4124 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/store/memory/MemoryStoreParameters.java | ||
---|---|---|
24 | 24 |
|
25 | 25 |
package org.gvsig.fmap.dal.store.memory; |
26 | 26 |
|
27 |
import java.io.File; |
|
27 | 28 |
import org.gvsig.fmap.dal.feature.OpenFeatureStoreParameters; |
28 | 29 |
import org.gvsig.fmap.dal.spi.AbstractDataStoreParameters; |
29 | 30 |
import org.gvsig.tools.ToolsLocator; |
... | ... | |
114 | 115 |
public String getOrderByAttributeName() { |
115 | 116 |
return (String) parameters.getDynValue(ORDER_PARAMETER_NAME); |
116 | 117 |
} |
118 |
|
|
119 |
@Override |
|
120 |
public String getSourceId() { |
|
121 |
StringBuilder builder = new StringBuilder(); |
|
122 |
builder.append(this.getName()); |
|
123 |
builder.append("(Memory)"); |
|
124 |
return builder.toString(); |
|
125 |
|
|
126 |
} |
|
117 | 127 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/impl/DefaultDataManager.java | ||
---|---|---|
1553 | 1553 |
} catch (Exception ex) { |
1554 | 1554 |
LOGGER.warn("Can't remove local cache for of resources.", ex); |
1555 | 1555 |
} |
1556 |
// FIXME: deberia borrarse las caches de los featuretype del StoresRepository |
|
1556 | 1557 |
} |
1557 | 1558 |
|
1558 | 1559 |
@Override |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/impl/DefaultDatabaseWorkspaceManager.java | ||
---|---|---|
44 | 44 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
45 | 45 |
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters; |
46 | 46 |
import org.gvsig.fmap.dal.feature.spi.LocalTransaction; |
47 |
import static org.gvsig.fmap.dal.impl.DatabaseWorkspaceStoresRepository.BIT_CHANGE_DBNAME_CATALOG_SCHEMA; |
|
48 |
import static org.gvsig.fmap.dal.impl.DatabaseWorkspaceStoresRepository.BIT_CHANGE_PORT_HOST; |
|
49 |
import static org.gvsig.fmap.dal.impl.DatabaseWorkspaceStoresRepository.BIT_CHANGE_USER; |
|
47 | 50 |
import org.gvsig.tools.dispose.DisposeUtils; |
48 | 51 |
import org.gvsig.tools.dynobject.DynClass; |
49 | 52 |
import org.gvsig.tools.dynobject.DynField; |
50 | 53 |
import org.gvsig.tools.resourcesstorage.FilesResourcesStorage; |
51 | 54 |
import org.gvsig.tools.resourcesstorage.ResourcesStorage; |
55 |
import org.gvsig.tools.util.Bitmask; |
|
52 | 56 |
import org.gvsig.tools.util.CachedValue; |
53 | 57 |
import org.gvsig.tools.util.FileTools; |
54 | 58 |
import org.gvsig.tools.util.HasAFile; |
... | ... | |
710 | 714 |
|
711 | 715 |
@Override |
712 | 716 |
public boolean writeStoresRepositoryEntry(String name, DataStoreParameters parameters) { |
717 |
return writeStoresRepositoryEntry( |
|
718 |
name, |
|
719 |
parameters, |
|
720 |
Bitmask.createBitmask(0) |
|
721 |
.setBit(BIT_CHANGE_PORT_HOST) |
|
722 |
.setBit(BIT_CHANGE_USER) |
|
723 |
.setBit(BIT_CHANGE_DBNAME_CATALOG_SCHEMA) |
|
724 |
); |
|
725 |
} |
|
726 |
|
|
727 |
@Override |
|
728 |
public boolean writeStoresRepositoryEntry(String name, DataStoreParameters parameters, Bitmask flags) { |
|
713 | 729 |
FeatureStore store = null; |
714 | 730 |
LocalTransaction trans = new LocalTransaction(null, this.getTransaction()); |
715 | 731 |
try { |
... | ... | |
734 | 750 |
efeature = store.createNewFeature(); |
735 | 751 |
efeature.set(FIELD_REPOSITORY_NAME, name); |
736 | 752 |
efeature.set(FIELD_REPOSITORY_PARAMETERS, data); |
737 |
// algun set sobre los flags? |
|
738 |
efeature.set(FIELD_REPOSITORY_FLAGS, 0); |
|
753 |
efeature.set(FIELD_REPOSITORY_FLAGS, flags.get()); |
|
739 | 754 |
store.insert(efeature); |
740 | 755 |
} else { |
741 | 756 |
efeature = feature.getEditable(); |
742 | 757 |
efeature.set(FIELD_REPOSITORY_PARAMETERS, data); |
758 |
efeature.set(FIELD_REPOSITORY_FLAGS, flags.get()); |
|
743 | 759 |
store.update(efeature); |
744 | 760 |
} |
745 | 761 |
store.finishEditing(); |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/expressionevaluator/impl/function/dataaccess/SelectFunction.java | ||
---|---|---|
55 | 55 |
import static org.gvsig.fmap.dal.SQLBuilder.PROP_TABLE; |
56 | 56 |
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor; |
57 | 57 |
import org.gvsig.fmap.dal.feature.Feature; |
58 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
58 | 59 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
59 | 60 |
import org.gvsig.fmap.dal.feature.FeatureQueryOrder; |
60 | 61 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
... | ... | |
345 | 346 |
if (sqlBuilder == null) { |
346 | 347 |
return super.toValue(builder, args); |
347 | 348 |
} |
348 |
Function<String, FeatureType> featureTypeSupplier = (Function<String, FeatureType>) builder.getProperty(PROP_FEATURETYPESUPPLIER); |
|
349 |
if (featureTypeSupplier == null) { |
|
350 |
featureTypeSupplier = (String tableName) -> { |
|
351 |
DataManager dataManager = DALLocator.getDataManager(); |
|
352 |
FeatureType featureType = dataManager.getStoresRepository().getFeatureType(tableName); |
|
353 |
return featureType; |
|
354 |
}; |
|
355 |
} |
|
356 |
FeatureType featureType = null; |
|
349 |
// Function<String, FeatureType> featureTypeSupplier = (Function<String, FeatureType>) builder.getProperty(PROP_FEATURETYPESUPPLIER); |
|
350 |
// if (featureTypeSupplier == null) { |
|
351 |
// featureTypeSupplier = (String tableName) -> { |
|
352 |
// DataManager dataManager = DALLocator.getDataManager(); |
|
353 |
// FeatureType featureType = dataManager.getStoresRepository().getFeatureType(tableName); |
|
354 |
// return featureType; |
|
355 |
// }; |
|
356 |
// } |
|
357 | 357 |
SQLBuilder.SelectBuilder select = sqlBuilder.createSelectBuilder(); |
358 | 358 |
String builderTableName = (String) builder.getProperty(SQLBuilder.PROP_TABLENAME); |
359 | 359 |
|
... | ... | |
412 | 412 |
|
413 | 413 |
SQLBuilder.TableNameBuilder table = select.from().table(); |
414 | 414 |
String tableName = table.getName(); |
415 |
FeatureType featureType; |
|
416 |
if (StringUtils.equalsIgnoreCase(builderTableName, tableName)) { |
|
417 |
featureType = (FeatureType) builder.getProperty(SQLBuilder.PROP_FEATURE_TYPE); |
|
418 |
} else { |
|
419 |
DataManager dataManager = DALLocator.getDataManager(); |
|
420 |
featureType = dataManager.getStoresRepository().getFeatureType(tableName); |
|
421 |
} |
|
422 |
table.setFeatureType(featureType); |
|
423 |
|
|
415 | 424 |
if (columns == null || columns.parameters().isEmpty()){ |
416 | 425 |
if( intovar==null ) { |
417 | 426 |
select.column().all(); |
... | ... | |
424 | 433 |
select.column().value(builder.constant(null)); |
425 | 434 |
} else if (column instanceof Code.Identifier) { |
426 | 435 |
String columnName = ((Code.Identifier) column).name(); |
427 |
if(featureType == null) { |
|
428 |
if(StringUtils.equalsIgnoreCase(builderTableName, tableName)){ |
|
429 |
featureType = (FeatureType) builder.getProperty(SQLBuilder.PROP_FEATURE_TYPE); |
|
430 |
} else { |
|
431 |
featureType = featureTypeSupplier.apply(tableName); |
|
432 |
} |
|
433 |
} |
|
434 |
if(featureType == null){ |
|
435 |
select.column().name(select.from().table(),columnName);
|
|
436 |
} else if(featureType.get(columnName) != null) { |
|
437 |
select.column().name(select.from().table(),columnName);
|
|
438 |
} else { |
|
439 |
select.column().name(columnName).table(null); |
|
440 |
} |
|
436 |
// if(featureType == null) {
|
|
437 |
// if(StringUtils.equalsIgnoreCase(builderTableName, tableName)){
|
|
438 |
// featureType = (FeatureType) builder.getProperty(SQLBuilder.PROP_FEATURE_TYPE);
|
|
439 |
// } else {
|
|
440 |
// featureType = featureTypeSupplier.apply(tableName);
|
|
441 |
// }
|
|
442 |
// }
|
|
443 |
// if(featureType == null){
|
|
444 |
select.column().name(table,columnName);
|
|
445 |
// } else if(featureType.get(columnName) != null) {
|
|
446 |
// select.column().name(table,columnName);
|
|
447 |
// } else {
|
|
448 |
// select.column().name(columnName).table(null);
|
|
449 |
// }
|
|
441 | 450 |
} else { |
442 |
select.column().value(column.toValue(builder));
|
|
451 |
select.column().value(setTableName(table, column.toValue(builder)));
|
|
443 | 452 |
} |
444 | 453 |
} |
445 | 454 |
} |
446 | 455 |
|
447 | 456 |
if (where != null) { |
448 |
ExpressionBuilder.Value value = where.toValue(builder);
|
|
457 |
ExpressionBuilder.Value value = setTableName(table, where.toValue(builder));
|
|
449 | 458 |
select.where().value(value); |
450 | 459 |
sqlBuilder.setProperties(value, null, SQLBuilder.PROP_ADD_TABLE_NAME_TO_COLUMNS, true); |
451 | 460 |
} |
... | ... | |
461 | 470 |
for (int n = 0; n < order.parameters().size(); n++) { |
462 | 471 |
Code member = order.parameters().get(n); |
463 | 472 |
Code.Constant mode = (Code.Constant) order_mode.parameters().get(n); |
464 |
select.order_by().value(member.toValue(builder)).ascending((boolean) mode.value()); |
|
473 |
select.order_by() |
|
474 |
.value(setTableName(table,member.toValue(builder))) |
|
475 |
.ascending((boolean) mode.value()); |
|
465 | 476 |
} |
466 | 477 |
} |
467 |
if (featureType == null) { |
|
468 |
if (StringUtils.equalsIgnoreCase(builderTableName, tableName)) { |
|
469 |
featureType = (FeatureType) builder.getProperty(SQLBuilder.PROP_FEATURE_TYPE); |
|
470 |
} else { |
|
471 |
featureType = featureTypeSupplier.apply(tableName); |
|
472 |
} |
|
473 |
} |
|
478 |
// if (featureType == null) {
|
|
479 |
// if (StringUtils.equalsIgnoreCase(builderTableName, tableName)) {
|
|
480 |
// featureType = (FeatureType) builder.getProperty(SQLBuilder.PROP_FEATURE_TYPE);
|
|
481 |
// } else {
|
|
482 |
// featureType = featureTypeSupplier.apply(tableName);
|
|
483 |
// }
|
|
484 |
// }
|
|
474 | 485 |
|
475 | 486 |
sqlBuilder.setProperties( |
476 | 487 |
select, |
... | ... | |
502 | 513 |
|
503 | 514 |
return values.toString(); |
504 | 515 |
} |
505 |
|
|
516 |
|
|
517 |
private ExpressionBuilder.Value setTableName(SQLBuilder.TableNameBuilder table, ExpressionBuilder.Value value) { |
|
518 |
value.accept(new ExpressionBuilder.Visitor() { |
|
519 |
@Override |
|
520 |
public void visit(ExpressionBuilder.Visitable value) { |
|
521 |
if( value instanceof SQLBuilder.Column) { |
|
522 |
SQLBuilder.Column c = (SQLBuilder.Column) value; |
|
523 |
SQLBuilder.TableNameBuilder t = c.table(); |
|
524 |
if( t==null ) { |
|
525 |
c.table(table); |
|
526 |
return; |
|
527 |
} |
|
528 |
if( t.equals(table) ) { |
|
529 |
t.setFeatureType(table.featureType()); |
|
530 |
} |
|
531 |
} |
|
532 |
} |
|
533 |
}, null); |
|
534 |
return value; |
|
535 |
} |
|
506 | 536 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/updatetable/UpdateTableProcessImpl.java | ||
---|---|---|
6 | 6 |
package org.gvsig.app.extension.updatetable; |
7 | 7 |
|
8 | 8 |
import java.util.List; |
9 |
import java.util.function.Predicate; |
|
9 | 10 |
import org.gvsig.app.extension.updatetable.UpdateTableProcessParameters.ProcessFieldParameters; |
10 | 11 |
import org.gvsig.expressionevaluator.Expression; |
11 | 12 |
import org.gvsig.expressionevaluator.ExpressionUtils; |
... | ... | |
26 | 27 |
import org.slf4j.Logger; |
27 | 28 |
import org.slf4j.LoggerFactory; |
28 | 29 |
import org.gvsig.fmap.dal.DataTransaction; |
30 |
import org.gvsig.fmap.dal.feature.FeatureStoreNotification; |
|
31 |
import org.gvsig.tools.ToolsLocator; |
|
29 | 32 |
import org.gvsig.tools.dispose.DisposeUtils; |
33 |
import org.gvsig.tools.identitymanagement.IdentityUtils; |
|
30 | 34 |
|
31 | 35 |
/** |
32 | 36 |
* |
... | ... | |
75 | 79 |
try { |
76 | 80 |
DataManager dataManager = DALLocator.getDataManager(); |
77 | 81 |
|
82 |
FeatureStore store = this.parameters.getStore(); |
|
83 |
if( !IdentityUtils.isAuthorized( |
|
84 |
"tools-updatetable", store, store.getFullName()) ) { |
|
85 |
this.status.message("User not authotized to this action"); |
|
86 |
return; |
|
87 |
} |
|
88 |
|
|
78 | 89 |
this.transaction = dataManager.createTransaction(); |
79 | 90 |
this.transaction.begin(); |
80 | 91 |
|
81 |
FeatureStore store = this.parameters.getStore(); |
|
82 | 92 |
this.transaction.add(store, false); |
83 | 93 |
|
84 | 94 |
this.status.setTitle("Update table '" + store.getName() + "'"); |
... | ... | |
125 | 135 |
} |
126 | 136 |
|
127 | 137 |
public void update_editeds() throws DataException { |
138 |
Predicate<FeatureStoreNotification> saveNotificationsFilter = null; |
|
139 |
|
|
128 | 140 |
FeatureStore store = this.parameters.getStore(); |
129 |
Expression filter = this.parameters.getFilter(); |
|
130 |
List<FeatureReference> set = store.getEditedFeatures(); |
|
131 |
if( set.isEmpty() ) { |
|
132 |
return; |
|
133 |
} |
|
134 |
this.beginEditing(); |
|
135 |
long rows = set.size(); |
|
136 |
this.status.setRangeOfValues(0, rows); |
|
141 |
try { |
|
142 |
saveNotificationsFilter = store.setNotificationsFilter(new StoreNotificationsFilter()); |
|
137 | 143 |
|
138 |
for (FeatureReference featureReferfence : set) { |
|
139 |
this.status.incrementCurrentValue(); |
|
140 |
if (this.status.isCancellationRequested()) { |
|
141 |
this.status.cancel(); |
|
142 |
this.abortEditing(); |
|
144 |
Expression filter = this.parameters.getFilter(); |
|
145 |
List<FeatureReference> set = store.getEditedFeatures(); |
|
146 |
if( set.isEmpty() ) { |
|
143 | 147 |
return; |
144 | 148 |
} |
145 |
Feature feature = featureReferfence.getFeature(); |
|
146 |
this.featureSymbolTable.setFeature(feature); |
|
147 |
boolean sholdProcessFeature = DataTypeUtils.toBoolean(filter.execute(featureSymbolTable), false); |
|
148 |
if (!sholdProcessFeature) { |
|
149 |
continue; |
|
149 |
this.beginEditing(); |
|
150 |
long rows = set.size(); |
|
151 |
this.status.setRangeOfValues(0, rows); |
|
152 |
|
|
153 |
for (FeatureReference featureReferfence : set) { |
|
154 |
this.status.incrementCurrentValue(); |
|
155 |
if (this.status.isCancellationRequested()) { |
|
156 |
this.status.cancel(); |
|
157 |
this.abortEditing(); |
|
158 |
return; |
|
159 |
} |
|
160 |
Feature feature = featureReferfence.getFeature(); |
|
161 |
this.featureSymbolTable.setFeature(feature); |
|
162 |
boolean sholdProcessFeature = DataTypeUtils.toBoolean(filter.execute(featureSymbolTable), false); |
|
163 |
if (!sholdProcessFeature) { |
|
164 |
continue; |
|
165 |
} |
|
166 |
|
|
167 |
EditableFeature editable_feature = feature.getEditable(); |
|
168 |
process_feature(editable_feature); |
|
169 |
store.update(editable_feature); |
|
170 |
restart_editing(); |
|
150 | 171 |
} |
151 |
|
|
152 |
EditableFeature editable_feature = feature.getEditable(); |
|
153 |
process_feature(editable_feature); |
|
154 |
store.update(editable_feature); |
|
155 |
restart_editing(); |
|
172 |
this.endEditing(); |
|
173 |
} finally { |
|
174 |
store.setNotificationsFilter(saveNotificationsFilter); |
|
156 | 175 |
} |
157 |
this.endEditing(); |
|
158 | 176 |
} |
159 | 177 |
|
160 | 178 |
public void update_selection() throws DataException { |
179 |
Predicate<FeatureStoreNotification> saveNotificationsFilter = null; |
|
180 |
|
|
161 | 181 |
FeatureStore store = this.parameters.getStore(); |
162 |
Expression filter = this.parameters.getFilter(); |
|
163 |
FeatureSet set = store.getFeatureSelection(); |
|
164 |
this.beginEditing(); |
|
165 |
long rows = set.getSize(); |
|
166 |
this.status.setRangeOfValues(0, rows); |
|
182 |
try { |
|
183 |
saveNotificationsFilter = store.setNotificationsFilter(new StoreNotificationsFilter()); |
|
184 |
|
|
185 |
Expression filter = this.parameters.getFilter(); |
|
186 |
FeatureSet set = store.getFeatureSelection(); |
|
187 |
this.beginEditing(); |
|
188 |
long rows = set.getSize(); |
|
189 |
this.status.setRangeOfValues(0, rows); |
|
167 | 190 |
|
168 |
for (Feature feature : set) { |
|
169 |
this.status.incrementCurrentValue(); |
|
170 |
if (this.status.isCancellationRequested()) { |
|
171 |
this.status.cancel(); |
|
172 |
this.abortEditing(); |
|
173 |
return; |
|
174 |
} |
|
191 |
for (Feature feature : set) {
|
|
192 |
this.status.incrementCurrentValue();
|
|
193 |
if (this.status.isCancellationRequested()) {
|
|
194 |
this.status.cancel();
|
|
195 |
this.abortEditing();
|
|
196 |
return;
|
|
197 |
}
|
|
175 | 198 |
|
176 |
this.featureSymbolTable.setFeature(feature); |
|
177 |
if( filter!=null ) { |
|
178 |
boolean sholdProcessFeature = DataTypeUtils.toBoolean(filter.execute(featureSymbolTable), false); |
|
179 |
if (!sholdProcessFeature) { |
|
180 |
continue; |
|
199 |
this.featureSymbolTable.setFeature(feature); |
|
200 |
if( filter!=null ) { |
|
201 |
boolean sholdProcessFeature = DataTypeUtils.toBoolean(filter.execute(featureSymbolTable), false); |
|
202 |
if (!sholdProcessFeature) { |
|
203 |
continue; |
|
204 |
} |
|
181 | 205 |
} |
206 |
|
|
207 |
EditableFeature editable_feature = feature.getEditable(); |
|
208 |
process_feature(editable_feature); |
|
209 |
set.update(editable_feature); |
|
210 |
restart_editing(); |
|
182 | 211 |
} |
183 |
|
|
184 |
EditableFeature editable_feature = feature.getEditable(); |
|
185 |
process_feature(editable_feature); |
|
186 |
set.update(editable_feature); |
|
187 |
restart_editing(); |
|
212 |
this.endEditing(); |
|
213 |
} finally { |
|
214 |
store.setNotificationsFilter(saveNotificationsFilter); |
|
188 | 215 |
} |
189 |
this.endEditing(); |
|
190 | 216 |
} |
191 | 217 |
|
192 | 218 |
public void update_all() throws DataException { |
219 |
Predicate<FeatureStoreNotification> saveNotificationsFilter = null; |
|
220 |
|
|
193 | 221 |
FeatureStore store = this.parameters.getStore(); |
194 |
Expression filter = this.parameters.getFilter(); |
|
195 |
|
|
196 |
FeatureQuery query = store.createFeatureQuery(filter); |
|
197 |
FeatureSet set = store.getFeatureSet(query); |
|
198 |
this.transaction.add(set); |
|
199 |
|
|
200 |
this.beginEditing(); |
|
201 |
long rows = set.getSize(); |
|
202 |
this.status.setRangeOfValues(0, rows); |
|
222 |
try { |
|
223 |
saveNotificationsFilter = store.setNotificationsFilter(new StoreNotificationsFilter()); |
|
203 | 224 |
|
204 |
for (Feature feature : set) { |
|
205 |
this.status.incrementCurrentValue(); |
|
206 |
if (this.status.isCancellationRequested()) { |
|
207 |
this.status.cancel(); |
|
208 |
this.abortEditing(); |
|
209 |
return; |
|
225 |
Expression filter = this.parameters.getFilter(); |
|
226 |
|
|
227 |
FeatureQuery query = store.createFeatureQuery(filter); |
|
228 |
FeatureSet set = store.getFeatureSet(query); |
|
229 |
this.transaction.add(set); |
|
230 |
|
|
231 |
this.beginEditing(); |
|
232 |
long rows = set.getSize(); |
|
233 |
this.status.setRangeOfValues(0, rows); |
|
234 |
|
|
235 |
for (Feature feature : set) { |
|
236 |
this.status.incrementCurrentValue(); |
|
237 |
if (this.status.isCancellationRequested()) { |
|
238 |
this.status.cancel(); |
|
239 |
this.abortEditing(); |
|
240 |
return; |
|
241 |
} |
|
242 |
EditableFeature editable_feature = feature.getEditable(); |
|
243 |
process_feature(editable_feature); |
|
244 |
set.update(editable_feature); |
|
245 |
restart_editing(); |
|
210 | 246 |
} |
211 |
EditableFeature editable_feature = feature.getEditable(); |
|
212 |
process_feature(editable_feature); |
|
213 |
set.update(editable_feature); |
|
214 |
restart_editing(); |
|
247 |
this.endEditing(); |
|
248 |
} finally { |
|
249 |
store.setNotificationsFilter(saveNotificationsFilter); |
|
215 | 250 |
} |
216 |
this.endEditing(); |
|
251 |
|
|
217 | 252 |
} |
218 | 253 |
|
219 | 254 |
private void process_feature(EditableFeature feature) { |
... | ... | |
327 | 362 |
return this.out; |
328 | 363 |
} |
329 | 364 |
|
365 |
private class StoreNotificationsFilter implements Predicate<FeatureStoreNotification> { |
|
366 |
|
|
367 |
@Override |
|
368 |
public boolean test(FeatureStoreNotification t) { |
|
369 |
if( t!=null ) { |
|
370 |
switch(t.getType()) { |
|
371 |
case FeatureStoreNotification.AFTER_UPDATE: |
|
372 |
case FeatureStoreNotification.BEFORE_UPDATE: |
|
373 |
return true; |
|
374 |
} |
|
375 |
LOGGER.info(t.getType()); |
|
376 |
} |
|
377 |
return false; |
|
378 |
} |
|
379 |
|
|
380 |
} |
|
330 | 381 |
|
331 | 382 |
|
332 | 383 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/DefaultProject.java | ||
---|---|---|
562 | 562 |
if (type == null) { |
563 | 563 |
for (int i = 0; i < documents.size(); i++) { |
564 | 564 |
Document document = documents.get(i); |
565 |
if ( name.equalsIgnoreCase(document.getName())) { |
|
565 |
if( document == null ) { |
|
566 |
continue; |
|
567 |
} |
|
568 |
if( StringUtils.equalsIgnoreCase(name, document.getName()) ) { |
|
566 | 569 |
return document; |
567 | 570 |
} |
568 | 571 |
} |
569 | 572 |
} else { |
570 | 573 |
for (int i = 0; i < documents.size(); i++) { |
571 | 574 |
Document document = documents.get(i); |
572 |
if (type.equalsIgnoreCase(document.getTypeName()) |
|
573 |
&& name.equalsIgnoreCase(document.getName())) { |
|
575 |
if( document == null ) { |
|
576 |
continue; |
|
577 |
} |
|
578 |
if( StringUtils.equalsIgnoreCase(type, document.getTypeName()) |
|
579 |
&& StringUtils.equalsIgnoreCase(name, document.getName()) ) { |
|
574 | 580 |
return document; |
575 | 581 |
} |
576 | 582 |
} |
... | ... | |
580 | 586 |
|
581 | 587 |
public Document getDocument(Predicate<Document>condition) { |
582 | 588 |
for (Document document : documents) { |
589 |
if( document == null ) { |
|
590 |
continue; |
|
591 |
} |
|
583 | 592 |
if( condition.test(document) ) { |
584 | 593 |
return document; |
585 | 594 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.geodb.app/org.gvsig.geodb.app.mainplugin/src/main/java/org/gvsig/geodb/databaseworkspace/RepositoryAddTablePanel.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.util.ArrayList; |
4 | 4 |
import java.util.Collections; |
5 |
import java.util.Comparator; |
|
5 | 6 |
import java.util.List; |
6 | 7 |
import javax.swing.DefaultListModel; |
7 | 8 |
import javax.swing.JComponent; |
... | ... | |
11 | 12 |
import javax.swing.event.TreeSelectionEvent; |
12 | 13 |
import javax.swing.tree.TreeModel; |
13 | 14 |
import javax.swing.tree.TreePath; |
15 |
import org.apache.commons.lang3.StringUtils; |
|
14 | 16 |
import org.gvsig.app.ApplicationLocator; |
15 | 17 |
import org.gvsig.app.ApplicationManager; |
16 | 18 |
import org.gvsig.app.project.Project; |
... | ... | |
117 | 119 |
DataManager dataManager = DALLocator.getDataManager(); |
118 | 120 |
JDBCServerExplorerParameters explorerParams = this.connectionPicker.get(); |
119 | 121 |
JDBCServerExplorer explorer = (JDBCServerExplorer) dataManager.openServerExplorer(explorerParams.getProviderName(), explorerParams); |
120 |
DefaultListModel<LabeledValue<JDBCStoreParameters>> tablesModel = new DefaultListModel<>();
|
|
122 |
List<LabeledValue<JDBCStoreParameters>> tables = new ArrayList<>();
|
|
121 | 123 |
for (DataStoreParameters dataStoreParameters : explorer.list()) { |
122 | 124 |
JDBCStoreParameters p = (JDBCStoreParameters) dataStoreParameters; |
123 |
tablesModel.addElement(new LabeledValueImpl<>(p.getTable(), p));
|
|
125 |
tables.add(new LabeledValueImpl<>(p.getTable(), p));
|
|
124 | 126 |
} |
127 |
Collections.sort(tables, new Comparator<LabeledValue<JDBCStoreParameters>>() { |
|
128 |
@Override |
|
129 |
public int compare(LabeledValue<JDBCStoreParameters> o1, LabeledValue<JDBCStoreParameters> o2) { |
|
130 |
return StringUtils.compare(o1.getLabel(), o2.getLabel()); |
|
131 |
} |
|
132 |
}); |
|
133 |
DefaultListModel<LabeledValue<JDBCStoreParameters>> tablesModel = new DefaultListModel<>(); |
|
134 |
for (LabeledValue<JDBCStoreParameters> table : tables) { |
|
135 |
tablesModel.addElement(table); |
|
136 |
} |
|
125 | 137 |
this.lstDatabaseTables.setModel(tablesModel); |
126 | 138 |
} catch (Exception ex) { |
127 | 139 |
LOGGER.warn("Can't update list of database tables.", ex); |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.h2spatial/org.gvsig.h2spatial.h2gis132/org.gvsig.h2spatial.h2gis132.provider/src/main/java/org/gvsig/fmap/dal/store/h2/H2SpatialStoreParameters.java | ||
---|---|---|
28 | 28 |
import org.gvsig.fmap.dal.DataStoreParameters; |
29 | 29 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
30 | 30 |
import org.gvsig.fmap.dal.store.jdbc.JDBCConnectionParameters; |
31 |
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters; |
|
31 | 32 |
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParametersBase; |
32 | 33 |
|
33 | 34 |
public class H2SpatialStoreParameters extends JDBCStoreParametersBase implements H2SpatialConnectionParameters { |
... | ... | |
122 | 123 |
public boolean getMaintainGlobalConnection() { |
123 | 124 |
return this.helper.getMaintainGlobalConnection(); |
124 | 125 |
} |
126 |
|
|
127 |
@Override |
|
128 |
public String getSourceId() { |
|
129 |
StringBuilder builder = new StringBuilder(); |
|
130 |
builder.append(this.getTable()); |
|
131 |
builder.append("("); |
|
132 |
boolean needComma = false; |
|
133 |
if( StringUtils.isNotBlank(this.getHost()) ) { |
|
134 |
builder.append("host="); |
|
135 |
builder.append(this.getHost()); |
|
136 |
needComma = true; |
|
137 |
} |
|
138 |
if( this.getPort()>0 ) { |
|
139 |
if (needComma ) { |
|
140 |
builder.append(", "); |
|
141 |
} |
|
142 |
builder.append("port="); |
|
143 |
builder.append(this.getPort()); |
|
144 |
needComma = true; |
|
145 |
} |
|
146 |
if( StringUtils.isNotBlank(this.getDBName()) ) { |
|
147 |
if (needComma ) { |
|
148 |
builder.append(", "); |
|
149 |
} |
|
150 |
builder.append("db="); |
|
151 |
builder.append(this.getDBName()); |
|
152 |
needComma = true; |
|
153 |
} |
|
154 |
if( StringUtils.isNotBlank(this.getSchema()) ) { |
|
155 |
if (needComma ) { |
|
156 |
builder.append(", "); |
|
157 |
} |
|
158 |
builder.append("schema="); |
|
159 |
builder.append(this.getSchema()); |
|
160 |
needComma = true; |
|
161 |
} |
|
162 |
File f = this.getFile(); |
|
163 |
if( f != null) { |
|
164 |
if (needComma ) { |
|
165 |
builder.append(", "); |
|
166 |
} |
|
167 |
builder.append("file="); |
|
168 |
builder.append(this.getFile().getAbsolutePath()); |
|
169 |
} |
|
170 |
builder.append(")"); |
|
171 |
return builder.toString(); |
|
172 |
|
|
173 |
} |
|
125 | 174 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.sqlite/org.gvsig.sqlite.provider/src/main/java/org/gvsig/sqlite/dal/SQLiteStoreParameters.java | ||
---|---|---|
107 | 107 |
|
108 | 108 |
} |
109 | 109 |
|
110 |
|
|
111 |
@Override |
|
112 |
public String getSourceId() { |
|
113 |
StringBuilder builder = new StringBuilder(); |
|
114 |
builder.append(this.getTable()); |
|
115 |
builder.append("("); |
|
116 |
boolean needComma = false; |
|
117 |
File f = this.getFile(); |
|
118 |
if( f != null) { |
|
119 |
if (needComma ) { |
|
120 |
builder.append(", "); |
|
121 |
} |
|
122 |
builder.append("file="); |
|
123 |
builder.append(this.getFile().getAbsolutePath()); |
|
124 |
} |
|
125 |
builder.append(")"); |
|
126 |
return builder.toString(); |
|
110 | 127 |
|
128 |
} |
|
129 |
|
|
111 | 130 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.sqlite/org.gvsig.sqlite.provider/pom.xml | ||
---|---|---|
219 | 219 |
<!-- Skip test execution ? --> |
220 | 220 |
<skipTests>false</skipTests> |
221 | 221 |
<!-- Ignore test execution failure ? --> |
222 |
<testFailureIgnore>true</testFailureIgnore>
|
|
222 |
<testFailureIgnore>false</testFailureIgnore>
|
|
223 | 223 |
<!-- |
224 | 224 |
<excludes> |
225 | 225 |
<exclude>**/TestCheckoutAlternativo.java</exclude> |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/app/project/documents/table/TableManager.java | ||
---|---|---|
72 | 72 |
import org.gvsig.tools.dynobject.DynStruct; |
73 | 73 |
import org.gvsig.tools.evaluator.Evaluator; |
74 | 74 |
import org.gvsig.tools.i18n.I18nManager; |
75 |
import org.gvsig.tools.identitymanagement.IdentityUtils; |
|
75 | 76 |
import org.gvsig.tools.persistence.PersistenceManager; |
76 | 77 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
77 | 78 |
import org.gvsig.tools.swing.api.ToolsSwingUtils; |
... | ... | |
463 | 464 |
|
464 | 465 |
@Override |
465 | 466 |
public IWindow getMainWindow(Document doc, WindowLayout layout) { |
466 |
IDocumentWindow win = (IDocumentWindow) super.getMainWindow(doc, layout); |
|
467 |
|
|
468 |
FeatureStore store = ((TableDocument)doc).getFeatureStore(); |
|
469 |
if( !IdentityUtils.isAuthorized("document-table-showmainwindow", |
|
470 |
doc, store.getFullName()) ) { |
|
471 |
return null; |
|
472 |
} |
|
473 |
IDocumentWindow win = (IDocumentWindow) super.getMainWindow(doc, layout); |
|
467 | 474 |
if (win == null) { |
468 | 475 |
try { |
469 | 476 |
win = (IDocumentWindow) this.createDocumentWindow(doc); |
Also available in: Unified diff