Revision 44346
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/H2SpatialHelper.java | ||
---|---|---|
113 | 113 |
if( startServer && server == null ) { |
114 | 114 |
String port = "9123"; |
115 | 115 |
try { |
116 |
Server theServer = Server.createTcpServer("-tcpPort", port, /*"-tcpAllowOthers",*/ "-ifExists"); |
|
116 |
Server theServer; |
|
117 |
String s = System.getProperty("H2Port"); |
|
118 |
if( s!=null ) { |
|
119 |
try { |
|
120 |
int n = Integer.parseInt(s); |
|
121 |
port = String.valueOf(n); |
|
122 |
} catch(Throwable th) { |
|
123 |
// Ignore port number, use default. |
|
124 |
} |
|
125 |
} |
|
126 |
if( System.getProperty("H2AllowOthers")!=null ) { |
|
127 |
theServer = Server.createTcpServer("-tcpPort", port, "-tcpAllowOthers", "-ifExists"); |
|
128 |
} else { |
|
129 |
theServer = Server.createTcpServer("-tcpPort", port, "-ifExists"); |
|
130 |
} |
|
117 | 131 |
theServer.start(); |
118 | 132 |
server = theServer; |
119 | 133 |
LOGGER.info("H2 Server started" ); |
120 | 134 |
LOGGER.info(" port :"+ server.getPort()); |
135 |
LOGGER.info(" URL :"+ server.getURL()); |
|
121 | 136 |
LOGGER.info(" status:"+ server.getStatus()); |
122 | 137 |
} catch (SQLException ex) { |
123 | 138 |
LOGGER.warn("H2 Server not started",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/jdbc2/spi/JDBCResourcesStorage.java | ||
---|---|---|
108 | 108 |
ExpressionBuilder builder = ExpressionUtils.createExpressionBuilder(); |
109 | 109 |
String filter = builder.eq( |
110 | 110 |
builder.column(FIELD_RESOURCES_NAME), |
111 |
builder.constant(this.tableName+"/"+this.name)
|
|
111 |
builder.constant(this.tableName+"."+this.name)
|
|
112 | 112 |
).toString(); |
113 | 113 |
Feature feature = store.findFirst(filter); |
114 | 114 |
return feature!=null; |
... | ... | |
135 | 135 |
ExpressionBuilder builder = ExpressionUtils.createExpressionBuilder(); |
136 | 136 |
String filter = builder.eq( |
137 | 137 |
builder.column(FIELD_RESOURCES_NAME), |
138 |
builder.constant(this.tableName+"/"+this.name)
|
|
138 |
builder.constant(this.tableName+"."+this.name)
|
|
139 | 139 |
).toString(); |
140 | 140 |
Feature feature = store.findFirst(filter); |
141 | 141 |
if (feature == null) { |
... | ... | |
179 | 179 |
ExpressionBuilder builder = ExpressionUtils.createExpressionBuilder(); |
180 | 180 |
String filter = builder.eq( |
181 | 181 |
builder.column(FIELD_RESOURCES_NAME), |
182 |
builder.constant(this.tableName+"/"+this.name)
|
|
182 |
builder.constant(this.tableName+"."+this.name)
|
|
183 | 183 |
).toString(); |
184 | 184 |
Feature feature = store.findFirst(filter); |
185 | 185 |
EditableFeature efeature; |
186 | 186 |
if (feature == null) { |
187 | 187 |
efeature = store.createNewFeature(); |
188 |
efeature.set(FIELD_RESOURCES_NAME, this.tableName+"/"+this.name);
|
|
188 |
efeature.set(FIELD_RESOURCES_NAME, this.tableName+"."+this.name);
|
|
189 | 189 |
efeature.set(FIELD_RESOURCES_RESOURCE, this.out.toByteArray()); |
190 | 190 |
store.insert(efeature); |
191 | 191 |
} else { |
... | ... | |
204 | 204 |
} |
205 | 205 |
} |
206 | 206 |
|
207 |
private final ResourcesStorage alternativeStorge; |
|
207 | 208 |
private final JDBCStoreParameters resourcesStoreParameters; |
208 | 209 |
private final String tableName; |
209 | 210 |
|
210 |
public JDBCResourcesStorage(JDBCStoreParameters resourcesStoreParameters, String tableName) { |
|
211 |
public JDBCResourcesStorage(ResourcesStorage alternativeStorge, JDBCStoreParameters resourcesStoreParameters, String tableName) { |
|
212 |
this.alternativeStorge = alternativeStorge; |
|
211 | 213 |
if( StringUtils.equals(TABLE_RESOURCES_NAME, tableName) ) { |
212 | 214 |
// No podemos buscar recursos de la tabla de recursos, ya que si no |
213 | 215 |
// al abrise la tabla de recursos entraria en bucle. |
... | ... | |
225 | 227 |
|
226 | 228 |
@Override |
227 | 229 |
public Resource getResource(String name) { |
230 |
if( this.alternativeStorge!=null ) { |
|
231 |
Resource r = this.alternativeStorge.getResource(name); |
|
232 |
if( r.exists() ) { |
|
233 |
return r; |
|
234 |
} |
|
235 |
} |
|
228 | 236 |
if (this.resourcesStoreParameters == null) { |
229 | 237 |
return null; |
230 | 238 |
} |
... | ... | |
240 | 248 |
if (this.resourcesStoreParameters == null) { |
241 | 249 |
return null; |
242 | 250 |
} |
251 |
if( this.alternativeStorge!=null ) { |
|
252 |
List<Resource> r = this.alternativeStorge.getResources(name); |
|
253 |
if( r!=null && !r.isEmpty() ) { |
|
254 |
return r; |
|
255 |
} |
|
256 |
} |
|
243 | 257 |
FeatureStore store = null; |
244 | 258 |
try { |
245 | 259 |
DataManager dataManager = DALLocator.getDataManager(); |
... | ... | |
255 | 269 |
if (n == 0) { |
256 | 270 |
multiresourceName = name; |
257 | 271 |
} else { |
258 |
multiresourceName = name + "." + String.valueOf(n);
|
|
272 |
multiresourceName = String.valueOf(n) + "." + name ;
|
|
259 | 273 |
} |
260 | 274 |
String filter = builder.eq( |
261 | 275 |
builder.column(FIELD_RESOURCES_NAME), |
262 |
builder.constant(this.tableName+"/"+multiresourceName)
|
|
276 |
builder.constant(this.tableName+"."+multiresourceName)
|
|
263 | 277 |
).toString(); |
264 | 278 |
Feature feature = store.findFirst(filter); |
265 | 279 |
if( feature==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/JDBCServerExplorerBase.java | ||
---|---|---|
36 | 36 |
import org.gvsig.fmap.dal.DataManager; |
37 | 37 |
import org.gvsig.fmap.dal.DataStore; |
38 | 38 |
import org.gvsig.fmap.dal.DataStoreParameters; |
39 |
import org.gvsig.fmap.dal.DatabaseWorkspaceManager; |
|
39 | 40 |
import static org.gvsig.fmap.dal.DatabaseWorkspaceManager.TABLE_RESOURCES_NAME; |
40 | 41 |
import org.gvsig.fmap.dal.NewDataStoreParameters; |
41 | 42 |
import org.gvsig.fmap.dal.exception.CloseException; |
... | ... | |
69 | 70 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.UpdateTableStatisticsOperation; |
70 | 71 |
import org.gvsig.tools.exception.BaseException; |
71 | 72 |
import org.gvsig.tools.resourcesstorage.EmptyResourcesStorage; |
73 |
import org.gvsig.tools.resourcesstorage.FilesResourcesStorage; |
|
72 | 74 |
import org.gvsig.tools.resourcesstorage.ResourcesStorage; |
73 | 75 |
import org.slf4j.Logger; |
74 | 76 |
import org.slf4j.LoggerFactory; |
... | ... | |
406 | 408 |
} |
407 | 409 |
|
408 | 410 |
private ResourcesStorage getResourcesStorage(DataStoreParameters parameters, String storeName) { |
409 |
try { |
|
410 |
List<JDBCStoreParameters> tables = this.list(); |
|
411 |
for (JDBCStoreParameters params : tables) { |
|
412 |
String theTableName = params.getTable(); |
|
413 |
if (StringUtils.equals(theTableName, TABLE_RESOURCES_NAME)) { |
|
414 |
JDBCResourcesStorage theResourcesStorage = new JDBCResourcesStorage( |
|
415 |
params, |
|
416 |
storeName |
|
417 |
); |
|
418 |
return theResourcesStorage; |
|
411 |
|
|
412 |
if( !DatabaseWorkspaceManager.isInternalTable(storeName) ) { |
|
413 |
ResourcesStorage alternateResourcesStorage = null; |
|
414 |
try { |
|
415 |
DataManager dataManager = DALLocator.getDataManager(); |
|
416 |
DatabaseWorkspaceManager workspace = dataManager.getDatabaseWorkspace(parameters); |
|
417 |
if( workspace != null ) { |
|
418 |
alternateResourcesStorage = workspace.getAlternativeResourcesStorage(); |
|
419 | 419 |
} |
420 |
} catch(Throwable th) { |
|
421 |
alternateResourcesStorage = null; |
|
420 | 422 |
} |
421 |
} catch (Throwable ex) { |
|
422 |
LOG.warn("Can't retrieve reources storage from table '" + TABLE_RESOURCES_NAME + "' in '"+this.getParameters().getUrl()+"'.", ex); |
|
423 |
try { |
|
424 |
List<JDBCStoreParameters> tables = this.list(); |
|
425 |
for (JDBCStoreParameters params : tables) { |
|
426 |
String theTableName = params.getTable(); |
|
427 |
if (StringUtils.equals(theTableName, TABLE_RESOURCES_NAME)) { |
|
428 |
JDBCResourcesStorage theResourcesStorage = new JDBCResourcesStorage( |
|
429 |
alternateResourcesStorage, |
|
430 |
params, |
|
431 |
storeName |
|
432 |
); |
|
433 |
return theResourcesStorage; |
|
434 |
} |
|
435 |
} |
|
436 |
} catch (Throwable ex) { |
|
437 |
LOG.warn("Can't retrieve reources storage from table '" + TABLE_RESOURCES_NAME + "' in '"+this.getParameters().getUrl()+"'.", ex); |
|
438 |
} |
|
423 | 439 |
} |
424 | 440 |
EmptyResourcesStorage theResourcesStorage = new EmptyResourcesStorage(); |
425 | 441 |
return theResourcesStorage; |
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/featureform/swing/impl/DefaultJFeaturesForm.java | ||
---|---|---|
414 | 414 |
|
415 | 415 |
@Override |
416 | 416 |
public void update(Observable observable, Object notification) { |
417 |
if( store == null || formset==null ) { |
|
418 |
return; |
|
419 |
} |
|
417 | 420 |
if( notification instanceof FeatureStoreNotification ) { |
418 | 421 |
FeatureStoreNotification n = (FeatureStoreNotification) notification; |
419 | 422 |
switch( n.getType() ) { |
... | ... | |
465 | 468 |
|
466 | 469 |
@Override |
467 | 470 |
public void update(Observable observable, Object notification) { |
471 |
if( store == null || formset==null ) { |
|
472 |
return; |
|
473 |
} |
|
468 | 474 |
if( notification instanceof FeatureStoreNotification ) { |
469 | 475 |
FeatureStoreNotification n = (FeatureStoreNotification) notification; |
470 | 476 |
switch( n.getType() ) { |
... | ... | |
518 | 524 |
} |
519 | 525 |
|
520 | 526 |
private void saveChanges(JDynFormSet dynformSet) { |
527 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
521 | 528 |
if( dynformSet.isInNewState() ) { |
522 | 529 |
Feature feat = null; |
523 | 530 |
try { |
... | ... | |
541 | 548 |
} catch(Exception ex) { |
542 | 549 |
LOGGER.warn("Can't reload form data after insert.",ex); |
543 | 550 |
} |
551 |
this.formset.message(i18n.getTranslation("_Record_saved")); |
|
544 | 552 |
} else { |
545 | 553 |
int index = dynformSet.getCurrentIndex(); |
546 | 554 |
DynObject dynObject = dynformSet.get(index); |
547 | 555 |
|
548 | 556 |
if ( !(dynObject instanceof FacadeOfAFeature) ) { |
549 | 557 |
LOGGER.warn("Can't get the associated feature index " + index); |
550 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
551 |
dynformSet.message(i18nManager.getTranslation("error_saving_data_will_not_save")); |
|
558 |
dynformSet.message(i18n.getTranslation("error_saving_data_will_not_save")); |
|
552 | 559 |
throw new RuntimeException("Can't save values"); |
553 | 560 |
} |
554 | 561 |
dynformSet.getFormValues(dynObject); |
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/featuretable/table/DynFieldFacadeOfAFeatureAttributeDescriptor.java | ||
---|---|---|
3 | 3 |
|
4 | 4 |
import java.text.DateFormat; |
5 | 5 |
import java.util.List; |
6 |
import java.util.Objects; |
|
6 | 7 |
import org.cresques.cts.IProjection; |
7 | 8 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
8 | 9 |
import org.gvsig.fmap.dal.feature.FeatureAttributeEmulator; |
... | ... | |
592 | 593 |
return ((DynField_v2)field).getLocalizedLabel(); |
593 | 594 |
} |
594 | 595 |
|
596 |
@Override |
|
597 |
public String getLabelOfValue(Object value) { |
|
598 |
return Objects.toString(value, ""); |
|
599 |
} |
|
600 |
|
|
595 | 601 |
} |
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 | ||
---|---|---|
771 | 771 |
@Override |
772 | 772 |
public void copyTo(FeatureStore target) { |
773 | 773 |
} |
774 |
|
|
775 |
@Override |
|
776 |
public FeatureQuery createFeatureQuery(String filter, String sortBy, boolean asc) { |
|
777 |
return null; |
|
778 |
} |
|
779 |
|
|
780 |
@Override |
|
781 |
public FeatureQuery createFeatureQuery(Expression filter, String sortBy, boolean asc) { |
|
782 |
return null; |
|
783 |
} |
|
774 | 784 |
} |
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/DummyFeatureAttributeDescriptor.java | ||
---|---|---|
3 | 3 |
|
4 | 4 |
import java.text.DateFormat; |
5 | 5 |
import java.util.List; |
6 |
import java.util.Objects; |
|
6 | 7 |
import org.cresques.cts.IProjection; |
7 | 8 |
import org.gvsig.fmap.geom.type.GeometryType; |
8 | 9 |
import org.gvsig.timesupport.Interval; |
... | ... | |
563 | 564 |
return this.getLabel(); |
564 | 565 |
} |
565 | 566 |
|
567 |
@Override |
|
568 |
public String getLabelOfValue(Object value) { |
|
569 |
return Objects.toString(value, ""); |
|
570 |
} |
|
571 |
|
|
566 | 572 |
} |
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/StoresRepository.java | ||
---|---|---|
21 | 21 |
|
22 | 22 |
public void add(String name, DataStoreParameters parameters); |
23 | 23 |
|
24 |
public boolean contains(DataStoreParameters parameters); |
|
25 |
|
|
24 | 26 |
public void remove(String name); |
25 | 27 |
|
26 | 28 |
public DataStore getStore(String name); |
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/AbstractStoresRepository.java | ||
---|---|---|
51 | 51 |
public void remove(String name) { |
52 | 52 |
throw new UnsupportedOperationException(); |
53 | 53 |
} |
54 |
|
|
55 |
@Override |
|
56 |
public boolean contains(DataStoreParameters parameters) { |
|
57 |
for (DataStoreParameters currentParameters : this) { |
|
58 |
if( parameters.equals(currentParameters) ) { |
|
59 |
return true; |
|
60 |
} |
|
61 |
} |
|
62 |
return false; |
|
63 |
} |
|
54 | 64 |
|
55 | 65 |
@Override |
56 | 66 |
public String getID() { |
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/DataManager.java | ||
---|---|---|
512 | 512 |
|
513 | 513 |
public DatabaseWorkspaceManager createDatabaseWorkspaceManager(DataServerExplorerParameters connection); |
514 | 514 |
|
515 |
public void addDatabaseWorkspace(DatabaseWorkspaceManager DatabaseWorkspace); |
|
516 |
|
|
517 |
public DatabaseWorkspaceManager getDatabaseWorkspace(String name); |
|
518 |
|
|
519 |
public DatabaseWorkspaceManager getDatabaseWorkspace(DataStoreParameters params); |
|
520 |
|
|
515 | 521 |
public void writeDALResource(ResourcesStorage resources, DataStore store); |
516 | 522 |
|
517 | 523 |
public void writeDALResource(ResourcesStorage resources, FeatureType featureType); |
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/DatabaseWorkspaceManager.java | ||
---|---|---|
1 | 1 |
package org.gvsig.fmap.dal; |
2 | 2 |
|
3 |
import org.apache.commons.lang3.StringUtils; |
|
3 | 4 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
5 |
import org.gvsig.tools.resourcesstorage.ResourcesStorage; |
|
4 | 6 |
|
5 | 7 |
/** |
6 | 8 |
* |
... | ... | |
30 | 32 |
public static final String CONFIG_NAME_STORESREPOSITORYID = "StoresRepository.id"; |
31 | 33 |
public static final String CONFIG_NAME_STORESREPOSITORYLABEL = "StoresRepository.label"; |
32 | 34 |
|
35 |
/** |
|
36 |
* Check if the indicated name corresponds to one of the configuration tables of the workspace. |
|
37 |
* |
|
38 |
* @param name to check. |
|
39 |
* @return true if the name is that of a configuration table. |
|
40 |
*/ |
|
41 |
public static boolean isInternalTable(String name) { |
|
42 |
if( StringUtils.isBlank(name) ) { |
|
43 |
return false; |
|
44 |
} |
|
45 |
String[] internalNames = new String[] { |
|
46 |
TABLE_REPOSITORY_NAME, |
|
47 |
TABLE_RESOURCES_NAME, |
|
48 |
TABLE_CONFIGURATION_NAME |
|
49 |
}; |
|
50 |
for (String internalName : internalNames) { |
|
51 |
if( name.equalsIgnoreCase(internalName) ) { |
|
52 |
return true; |
|
53 |
} |
|
54 |
} |
|
55 |
return false; |
|
56 |
} |
|
57 |
|
|
58 |
/** |
|
59 |
* Returns the identifier of this workspace. |
|
60 |
* |
|
61 |
* @return the id. |
|
62 |
*/ |
|
63 |
public String getId(); |
|
64 |
|
|
65 |
/** |
|
66 |
* Returns the label of this workspace. |
|
67 |
* |
|
68 |
* @return the label value. |
|
69 |
*/ |
|
70 |
public String getLabel(); |
|
71 |
|
|
72 |
/** |
|
73 |
* Gets the value of a configuration variable associated with |
|
74 |
* this work space. |
|
75 |
* |
|
76 |
* @param name of the variable to consult |
|
77 |
* @return the value of the variable |
|
78 |
*/ |
|
33 | 79 |
public String get(String name); |
34 | 80 |
|
81 |
/** |
|
82 |
* Assigns the indicated value to the configuration variable. |
|
83 |
* |
|
84 |
* @param name of the variable. |
|
85 |
* @param value value to set. |
|
86 |
* @return true if can assign the value. |
|
87 |
*/ |
|
35 | 88 |
public boolean set(String name, String value); |
36 | 89 |
|
90 |
/** |
|
91 |
* Gets the repository of data stores associated with this workspace. |
|
92 |
* |
|
93 |
* @return the data stores repository. |
|
94 |
*/ |
|
37 | 95 |
public StoresRepository getStoresRepository(); |
38 | 96 |
|
39 |
public boolean storesRepositoryWriteEntry(String name, DataStoreParameters parameters); |
|
97 |
/** |
|
98 |
* Add a new data store to the workspace. |
|
99 |
* |
|
100 |
* @param name of the data store. |
|
101 |
* @param parameters to open the data store. |
|
102 |
* @return true if ok. |
|
103 |
*/ |
|
104 |
public boolean writeStoresRepositoryEntry(String name, DataStoreParameters parameters); |
|
40 | 105 |
|
41 | 106 |
public boolean canAnonymousUserWriteInTheTables(); |
42 | 107 |
|
108 |
/** |
|
109 |
* Check if the indicated configuration table exists in the workspace. |
|
110 |
* |
|
111 |
* @param tableid |
|
112 |
* @return true if the table exists. |
|
113 |
*/ |
|
43 | 114 |
public boolean existsTable(int tableid); |
44 | 115 |
|
45 |
public FeatureStore getTable(int tableid); |
|
46 |
|
|
116 |
/** |
|
117 |
* Create the configuration table indicated in the workspace. |
|
118 |
* |
|
119 |
* @param tableid identifier of the configuration table to create. |
|
120 |
*/ |
|
47 | 121 |
public void createTable(int tableid); |
48 | 122 |
|
123 |
/** |
|
124 |
* Remove the indicated configuration table from the workspace. |
|
125 |
* |
|
126 |
* @param tableid identifier of the configuration table to remove. |
|
127 |
*/ |
|
49 | 128 |
public void dropTable(int tableid); |
50 | 129 |
|
130 |
/** |
|
131 |
* Gets the data store associated with the indicated configuration table. |
|
132 |
* |
|
133 |
* @param tableid identifier of the configuration table to get. |
|
134 |
* @return the FeatureStore of the configuration table. |
|
135 |
*/ |
|
136 |
public FeatureStore getTable(int tableid); |
|
137 |
|
|
138 |
/** |
|
139 |
* Returns true if the connection associated with this object refers |
|
140 |
* to a valid workspace. |
|
141 |
* At least the repositories table must exist and the variable |
|
142 |
* "StoresRepository.id" must be defined. |
|
143 |
* |
|
144 |
* @return |
|
145 |
*/ |
|
51 | 146 |
public boolean isValidStoresRepository(); |
147 |
|
|
148 |
/** |
|
149 |
* If the workspace has an alternate resource storage defined, return it. |
|
150 |
* If don't have it, return null. |
|
151 |
* |
|
152 |
* @return the alternate resource storage. |
|
153 |
*/ |
|
154 |
public ResourcesStorage getAlternativeResourcesStorage(); |
|
155 |
|
|
156 |
/** |
|
157 |
* Create and initialize the tables associated with a gvSIG workspace. |
|
158 |
* |
|
159 |
* @param id of the workspace |
|
160 |
* @param description of the workspace |
|
161 |
*/ |
|
162 |
public void create(String id, String description); |
|
52 | 163 |
|
53 | 164 |
} |
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/feature/FeatureStore.java | ||
---|---|---|
47 | 47 |
import org.gvsig.tools.observer.Observer; |
48 | 48 |
import org.gvsig.tools.undo.UndoRedoStack; |
49 | 49 |
import org.gvsig.tools.resourcesstorage.ResourcesStorage; |
50 |
import org.gvsig.tools.util.UnmodifiableBasicList64; |
|
50 | 51 |
|
51 | 52 |
/** |
52 | 53 |
* <p> |
... | ... | |
187 | 188 |
* |
188 | 189 |
* Query related services |
189 | 190 |
*/ |
191 |
|
|
192 |
/** |
|
193 |
* Create a {@link FeatureQuery} with the restrictions indicateds. |
|
194 |
* |
|
195 |
* "filter" will be null or a valid filter expression for the store. |
|
196 |
* |
|
197 |
* "sortBy" can be null to use the store's default order. |
|
198 |
* |
|
199 |
* The parameter sortBy can be an attribute name or a comma separated list. |
|
200 |
* Each attribute name can be preceded or followed by "+" or "-" to indicate |
|
201 |
* the order to use to sort by that attribute. |
|
202 |
* |
|
203 |
* If no "+" or "-" is indicated, the "asc" parameter will be used to |
|
204 |
* determine if the order is ascending, "true" or decent, "false". |
|
205 |
* |
|
206 |
* @param filter an {@link String} expression used to filter the features in the store. |
|
207 |
* @param sortBy Attribute names separated by commas used to sort the list to return. |
|
208 |
* @param asc use order ascending, true, or descending, false. |
|
209 |
* @return a {@link FeatureQuery} with the restrictions. |
|
210 |
* @see {@link FeatureQuery} |
|
211 |
*/ |
|
212 |
public FeatureQuery createFeatureQuery(String filter, String sortBy, boolean asc); |
|
190 | 213 |
|
214 |
/** |
|
215 |
* Create a {@link FeatureQuery} with the restrictions indicateds. |
|
216 |
* |
|
217 |
* "filter" will be null or {@link Expression} valid for the store. |
|
218 |
* |
|
219 |
* "sortBy" can be null to use the store's default order. |
|
220 |
* |
|
221 |
* The parameter sortBy can be an attribute name or a comma separated list. |
|
222 |
* Each attribute name can be preceded or followed by "+" or "-" to indicate |
|
223 |
* the order to use to sort by that attribute. |
|
224 |
* |
|
225 |
* If no "+" or "-" is indicated, the "asc" parameter will be used to |
|
226 |
* determine if the order is ascending, "true" or decent, "false". |
|
227 |
* |
|
228 |
* @param filter an {@link String} expression used to filter the features in the store. |
|
229 |
* @param sortBy Attribute names separated by commas used to sort the list to return. |
|
230 |
* @param asc use order ascending, true, or descending, false. |
|
231 |
* @return a {@link FeatureQuery} with the restrictions. |
|
232 |
* @see {@link FeatureQuery} |
|
233 |
*/ |
|
234 |
public FeatureQuery createFeatureQuery(Expression filter, String sortBy, boolean asc); |
|
235 |
|
|
191 | 236 |
/** |
192 | 237 |
* Returns all available features in the store. |
193 |
* <p> |
|
194 |
* <em> |
|
195 |
* <strong>NOTE:</strong> if you use this method to get a |
|
196 |
* {@link FeatureSet}, you must get sure it is disposed |
|
197 |
* (@see {@link DisposableIterator#dispose()}) in any case, even if an |
|
198 |
* error occurs while getting the data. It is recommended to use the |
|
199 |
* <code>accept</code> methods instead, which handle everything for you. |
|
200 |
* Take into account the accept methods may use a fast iterator to |
|
201 |
* get the features. |
|
202 |
* </em> |
|
203 |
* </p> |
|
204 | 238 |
* |
205 |
* @see #accept(org.gvsig.tools.visitor.Visitor)
|
|
206 |
* |
|
207 |
* @return a collection of features
|
|
208 |
* @throws ReadException |
|
209 |
* if there is any error while reading the features
|
|
239 |
* It is a utility method that calls {@link #getFeatureSet(FeatureQuery)}
|
|
240 |
*
|
|
241 |
* @return the {@link FeatureSet}
|
|
242 |
* @throws ReadException if there is any error while reading the features
|
|
243 |
* @see {@link #accept(org.gvsig.tools.visitor.Visitor)}, {@link #getFeatureSet(FeatureQuery)}
|
|
210 | 244 |
*/ |
211 | 245 |
FeatureSet getFeatureSet() throws DataException; |
212 | 246 |
|
247 |
/** |
|
248 |
* Return a subset of features. |
|
249 |
* |
|
250 |
* It is a utility method that calls {@link #getFeatureSet(FeatureQuery)} |
|
251 |
* |
|
252 |
* @param filter an {@link String} expression used to filter the features in the store. |
|
253 |
* @return the {@link FeatureSet} |
|
254 |
* @throws ReadException if there is any error while reading the features |
|
255 |
* @see {@link #createFeatureQuery(Expression,String,boolean)}, {@link #getFeatureSet(FeatureQuery)} |
|
256 |
*/ |
|
213 | 257 |
FeatureSet getFeatureSet(String filter) throws DataException; |
214 | 258 |
|
259 |
/** |
|
260 |
* Return a subset of features. |
|
261 |
* |
|
262 |
* It is a utility method that calls {@link #getFeatureSet(FeatureQuery)} |
|
263 |
* |
|
264 |
* The sort order used is ascending. |
|
265 |
* |
|
266 |
* @param filter an {@link String} expression used to filter the features in the store. |
|
267 |
* @param sortBy Attribute names separated by commas used to sort the list to return. |
|
268 |
* @return the {@link FeatureSet} |
|
269 |
* @throws ReadException if there is any error while reading the features |
|
270 |
* @see {@link #createFeatureQuery(Expression,String,boolean)}, {@link #getFeatureSet(FeatureQuery)} |
|
271 |
*/ |
|
215 | 272 |
FeatureSet getFeatureSet(String filter, String sortBy) throws DataException; |
216 | 273 |
|
274 |
/** |
|
275 |
* Return a subset of features. |
|
276 |
* |
|
277 |
* It is a utility method that calls {@link #getFeatureSet(FeatureQuery)} |
|
278 |
* |
|
279 |
* @param filter an {@link String} expression used to filter the features in the store. |
|
280 |
* @param sortBy Attribute names separated by commas used to sort the list to return. |
|
281 |
* @param asc use order ascending, true, or descending, false. |
|
282 |
* @return the {@link FeatureSet} |
|
283 |
* @throws ReadException if there is any error while reading the features |
|
284 |
* @see {@link #createFeatureQuery(Expression,String,boolean)}, {@link #getFeatureSet(FeatureQuery)} |
|
285 |
*/ |
|
217 | 286 |
FeatureSet getFeatureSet(String filter, String sortBy, boolean asc) throws DataException; |
218 | 287 |
|
288 |
/** |
|
289 |
* Return a subset of features. |
|
290 |
* |
|
291 |
* It is a utility method that calls {@link #getFeatureSet(FeatureQuery)} |
|
292 |
* |
|
293 |
* @param filter an {@link Expression} used to filter the features in the store. |
|
294 |
* @return the {@link FeatureSet} |
|
295 |
* @throws DataException |
|
296 |
* @see {@link #createFeatureQuery(Expression,String,boolean)}, {@link #getFeatureSet(FeatureQuery)} |
|
297 |
*/ |
|
219 | 298 |
FeatureSet getFeatureSet(Expression filter) throws DataException; |
220 | 299 |
|
300 |
/** |
|
301 |
* Return a subset of features. |
|
302 |
* |
|
303 |
* It is a utility method that calls {@link #getFeatureSet(FeatureQuery)} |
|
304 |
* |
|
305 |
* The sort order used is ascending. |
|
306 |
* |
|
307 |
* @param filter an {@link Expression} used to filter the features in the store. |
|
308 |
* @param sortBy Attribute names separated by commas used to sort the list to return. |
|
309 |
* @return the {@link FeatureSet} |
|
310 |
* @throws ReadException if there is any error while reading the features |
|
311 |
* @see {@link #createFeatureQuery(Expression,String,boolean)}, {@link #getFeatureSet(FeatureQuery)} |
|
312 |
*/ |
|
221 | 313 |
FeatureSet getFeatureSet(Expression filter, String sortBy) throws DataException; |
222 | 314 |
|
315 |
/** |
|
316 |
* Return a subset of features. |
|
317 |
* |
|
318 |
* It is a utility method that calls {@link #getFeatureSet(FeatureQuery)} |
|
319 |
* |
|
320 |
* @param filter an {@link Expression} used to filter the features in the store. |
|
321 |
* @param sortBy Attribute names separated by commas used to sort the list to return. |
|
322 |
* @param asc use order ascending, true, or descending, false. |
|
323 |
* @return the {@link FeatureSet} |
|
324 |
* @throws DataException |
|
325 |
* @see {@link #createFeatureQuery(Expression,String,boolean)}, {@link #getFeatureSet(FeatureQuery)} |
|
326 |
*/ |
|
223 | 327 |
FeatureSet getFeatureSet(Expression filter, String sortBy, boolean asc) throws DataException; |
328 |
|
|
224 | 329 |
/** |
225 | 330 |
* Returns a subset of features taking into account the properties and |
226 |
* restrictions of the FeatureQuery. |
|
331 |
* restrictions of the {@link FeatureQuery}. |
|
332 |
* |
|
333 |
* If {@link FeatureQuery} is null, return al features in the store. |
|
334 |
* |
|
227 | 335 |
* <p> |
228 | 336 |
* <em> |
229 | 337 |
* <strong>NOTE:</strong> if you use this method to get a |
... | ... | |
236 | 344 |
* </em> |
237 | 345 |
* </p> |
238 | 346 |
* |
239 |
* @see #accept(org.gvsig.tools.visitor.Visitor, |
|
240 |
* org.gvsig.fmap.dal.DataQuery) |
|
241 |
* |
|
242 |
* @param featureQuery |
|
243 |
* defines the characteristics of the features to return |
|
244 |
* @return a collection of features |
|
245 |
* @throws ReadException |
|
246 |
* if there is any error while reading the features |
|
347 |
* @param featureQuery defines the characteristics of the features to return. |
|
348 |
* @return the {@link FeatureSet} |
|
349 |
* @throws ReadException if there is any error while reading the features. |
|
350 |
* @see #accept(org.gvsig.tools.visitor.Visitor, org.gvsig.fmap.dal.DataQuery) |
|
247 | 351 |
*/ |
248 | 352 |
FeatureSet getFeatureSet(FeatureQuery featureQuery) throws DataException; |
249 | 353 |
|
250 | 354 |
/** |
251 | 355 |
* Loads a subset of features taking into account the properties and |
252 |
* restrictions of the FeatureQuery. Feature loading is performed by calling |
|
253 |
* the Observer, once each loaded Feature. |
|
356 |
* restrictions of the FeatureQuery. |
|
357 |
* When feature loading is finished call the Observer passing the |
|
358 |
* {@link FeatureSet} loaded. |
|
254 | 359 |
* |
255 |
* @param featureQuery |
|
256 |
* defines the characteristics of the features to return |
|
257 |
* @param observer |
|
258 |
* to be notified of each loaded Feature |
|
259 |
* @throws DataException |
|
260 |
* if there is any error while loading the features |
|
360 |
* @param featureQuery defines the characteristics of the features to return. |
|
361 |
* @param observer to be notified when loading is finished. |
|
362 |
* @throws DataException if there is any error while loading the features |
|
261 | 363 |
*/ |
262 |
void getFeatureSet(FeatureQuery featureQuery, Observer observer) |
|
263 |
throws DataException; |
|
364 |
void getFeatureSet(FeatureQuery featureQuery, Observer observer) throws DataException; |
|
264 | 365 |
|
265 | 366 |
/** |
266 | 367 |
* Loads all available feature in the store. The loading of Features is |
267 | 368 |
* performed by calling the Observer, once each loaded Feature. |
268 | 369 |
* |
269 |
* @param observer |
|
270 |
* to be notified of each loaded Feature |
|
271 |
* @throws DataException |
|
272 |
* if there is any error while loading the features |
|
370 |
* @param observer to be notified of each loaded Feature |
|
371 |
* @throws DataException if there is any error while loading the features |
|
273 | 372 |
*/ |
274 | 373 |
void getFeatureSet(Observer observer) throws DataException; |
275 | 374 |
|
276 | 375 |
/** |
277 | 376 |
* Return a paginated list of Features filtered by the query. |
377 |
* |
|
378 |
* If the query is null, return all features in the store sorteds |
|
379 |
* by default order. |
|
380 |
* |
|
381 |
* The return value implements {@link List} and {@link UnmodifiableBasicList64} |
|
382 |
* to support large list of features. |
|
383 |
* |
|
384 |
* The returned list of Features is paginated, and the page size |
|
385 |
* used is "pageSize". |
|
386 |
* |
|
387 |
* If the page size is less than or equal to 0, the default page size of |
|
388 |
* 100 will be used. |
|
278 | 389 |
* |
279 |
* The returned List of Features is paginated, and the page size |
|
280 |
* used is "pageSize". |
|
281 |
* |
|
282 |
* @param query to filter the returned feature list |
|
390 |
* @param query to filter and sort the returned feature list |
|
283 | 391 |
* @param pageSize the page size of the list |
284 |
* @return the list of features
|
|
392 |
* @return the {@link List}/{@link UnmodifiableBasicList64} of features
|
|
285 | 393 |
*/ |
286 | 394 |
public List<Feature> getFeatures(FeatureQuery query, int pageSize); |
287 | 395 |
|
396 |
/** |
|
397 |
* Return a paginated list of Features. |
|
398 |
* |
|
399 |
* It is a utility method that calls {@link #getFeatures(FeatureQuery, int)} |
|
400 |
* using the default page size. |
|
401 |
* |
|
402 |
* @param query to filter and sort the returned feature list |
|
403 |
* @return the {@link List}/{@link UnmodifiableBasicList64} of features |
|
404 |
* @see {@link #getFeatures(FeatureQuery, int)} |
|
405 |
*/ |
|
288 | 406 |
public List<Feature> getFeatures(FeatureQuery query); |
289 | 407 |
|
408 |
/** |
|
409 |
* Return a paginated list with al Features in the store. |
|
410 |
* |
|
411 |
* It is a utility method that calls {@link #getFeatures(FeatureQuery, int)} |
|
412 |
* using the default page size. |
|
413 |
* |
|
414 |
* @return the {@link List}/{@link UnmodifiableBasicList64} of features |
|
415 |
* @see {@link #getFeatures(FeatureQuery, int)} |
|
416 |
*/ |
|
290 | 417 |
public List<Feature> getFeatures(); |
291 | 418 |
|
419 |
/** |
|
420 |
* Return a paginated list of Features |
|
421 |
* |
|
422 |
* It is a utility method that calls {@link #getFeatures(FeatureQuery, int)} |
|
423 |
* |
|
424 |
* @param filter used to filter the features in the store. |
|
425 |
* @return the List of Features |
|
426 |
* @see {@link #getFeatures(FeatureQuery, int)}, {@link #createFeatureQuery(String,String,boolean)} |
|
427 |
*/ |
|
292 | 428 |
public List<Feature> getFeatures(String filter); |
293 | 429 |
|
430 |
/** |
|
431 |
* Return a paginated list of Features. |
|
432 |
* |
|
433 |
* It is a utility method that calls {@link #getFeatures(FeatureQuery, int)} |
|
434 |
* using the default page size. |
|
435 |
* |
|
436 |
* @param filter used to filter the features in the store. |
|
437 |
* @param sortBy Attribute names separated by commas used to sort the list to return. |
|
438 |
* @return the {@link List}/{@link UnmodifiableBasicList64} of features |
|
439 |
* @see {@link #getFeatures(FeatureQuery, int)}, {@link #createFeatureQuery(String,String,boolean)} |
|
440 |
*/ |
|
294 | 441 |
public List<Feature> getFeatures(String filter, String sortBy); |
295 | 442 |
|
443 |
/** |
|
444 |
* Return a paginated list of Features. |
|
445 |
* |
|
446 |
* It is a utility method that calls {@link #getFeatures(FeatureQuery, int)} |
|
447 |
* using the default page size. |
|
448 |
* |
|
449 |
* @param filter an {@link String} expression used to filter the features in the store. |
|
450 |
* @param sortBy Attribute names separated by commas used to sort the list to return. |
|
451 |
* @param asc use order ascending, true, or descending, false. |
|
452 |
* @return the {@link List}/{@link UnmodifiableBasicList64} of features |
|
453 |
* @see {@link #getFeatures(FeatureQuery, int)}, {@link #createFeatureQuery(String,String,boolean)} |
|
454 |
*/ |
|
296 | 455 |
public List<Feature> getFeatures(String filter, String sortBy, boolean asc); |
297 | 456 |
|
457 |
/** |
|
458 |
* Return a paginated list of Features |
|
459 |
* |
|
460 |
* It is a utility method that calls {@link #getFeatures(FeatureQuery, int)} |
|
461 |
* using the default page size. |
|
462 |
* |
|
463 |
* @param filter an {@link Expression} used to filter the features in the store. |
|
464 |
* @return the List of Features |
|
465 |
* @see {@link #getFeatures(FeatureQuery, int)}, {@link #createFeatureQuery(Expression,String,boolean)} |
|
466 |
*/ |
|
298 | 467 |
public List<Feature> getFeatures(Expression filter); |
299 | 468 |
|
469 |
/** |
|
470 |
* Return a paginated list of Features |
|
471 |
* |
|
472 |
* It is a utility method that calls {@link #getFeatures(FeatureQuery, int)} |
|
473 |
* using the default page size. |
|
474 |
* |
|
475 |
* @param filter an {@link Expression} used to filter the features in the store. |
|
476 |
* @param sortBy Attribute names separated by commas used to sort the list to return. |
|
477 |
* @return the {@link List}/{@link UnmodifiableBasicList64} of features |
|
478 |
* @see {@link #getFeatures(FeatureQuery, int)}, {@link #createFeatureQuery(Expression,String,boolean)} |
|
479 |
*/ |
|
300 | 480 |
public List<Feature> getFeatures(Expression filter, String sortBy); |
301 | 481 |
|
482 |
/** |
|
483 |
* Return a paginated list of Features |
|
484 |
* |
|
485 |
* It is a utility method that calls {@link #getFeatures(FeatureQuery, int)} |
|
486 |
* using the default page size. |
|
487 |
* |
|
488 |
* @param filter an {@link Expression} used to filter the features in the store. |
|
489 |
* @param sortBy Attribute names separated by commas used to sort the list to return. |
|
490 |
* @param asc use order ascending, true, or descending, false. |
|
491 |
* @return the {@link List}/{@link UnmodifiableBasicList64} of features |
|
492 |
* @see {@link #getFeatures(FeatureQuery, int)}, {@link #createFeatureQuery(Expression,String,boolean)} |
|
493 |
*/ |
|
302 | 494 |
public List<Feature> getFeatures(Expression filter, String sortBy, boolean asc); |
303 | 495 |
|
496 |
/** |
|
497 |
* Return the first {@link Feature} of the store. |
|
498 |
* |
|
499 |
* @return the first {@link Feature} or null if the store is empty. |
|
500 |
* @throws DataException |
|
501 |
*/ |
|
304 | 502 |
public Feature first() throws DataException; |
305 | 503 |
|
504 |
/** |
|
505 |
* Returns the first {@link Feature} that meets the criteria indicated. |
|
506 |
* |
|
507 |
* It is a utility method that calls {@link #findFirst(FeatureQuery)}. |
|
508 |
* |
|
509 |
* @param filter {@link String} expression used to filter the features. |
|
510 |
* @return the first {@link Feature} or null if the filter don't return any feature. |
|
511 |
* @throws DataException |
|
512 |
* @see {@link #findFirst(FeatureQuery)}, {@link #createFeatureQuery(String,String,boolean)} |
|
513 |
*/ |
|
306 | 514 |
public Feature findFirst(String filter) throws DataException; |
307 | 515 |
|
516 |
/** |
|
517 |
* Returns the first {@link Feature} that meets the criteria indicated. |
|
518 |
* |
|
519 |
* It is a utility method that calls {@link #findFirst(FeatureQuery)}. |
|
520 |
* |
|
521 |
* @param filter {@link String} expression used to filter the features. |
|
522 |
* @param sortBy Attribute names separated by commas used to sort the list to return. |
|
523 |
* @return the first {@link Feature} or null if the filter don't return any feature. |
|
524 |
* @throws DataException |
|
525 |
* @see {@link #findFirst(FeatureQuery)}, {@link #createFeatureQuery(String,String,boolean)} |
|
526 |
*/ |
|
308 | 527 |
public Feature findFirst(String filter, String sortBy) throws DataException; |
309 | 528 |
|
529 |
/** |
|
530 |
* Returns the first {@link Feature} that meets the criteria indicated. |
|
531 |
* |
|
532 |
* It is a utility method that calls {@link #findFirst(FeatureQuery)}. |
|
533 |
* |
|
534 |
* @param filter {@link String} expression used to filter the features. |
|
535 |
* @param sortBy Attribute names separated by commas used to sort the list to return. |
|
536 |
* @param asc use order ascending, true, or descending, false. |
|
537 |
* @return the first {@link Feature} or null if the filter don't return any feature. |
|
538 |
* @throws DataException |
|
539 |
* @see {@link #findFirst(FeatureQuery)}, {@link #createFeatureQuery(String,String,boolean)} |
|
540 |
*/ |
|
310 | 541 |
public Feature findFirst(String filter, String sortBy, boolean asc) throws DataException; |
311 | 542 |
|
543 |
/** |
|
544 |
* Returns the first {@link Feature} that meets the criteria indicated. |
|
545 |
* |
|
546 |
* It is a utility method that calls {@link #findFirst(FeatureQuery)}. |
|
547 |
* |
|
548 |
* @param filter {@link String} expression used to filter the features. |
|
549 |
* @return the first {@link Feature} or null if the filter don't return any feature. |
|
550 |
* @throws DataException |
|
551 |
* @see {@link #findFirst(FeatureQuery)}, {@link #createFeatureQuery(Expession,String,boolean)} |
|
552 |
*/ |
|
312 | 553 |
public Feature findFirst(Expression filter) throws DataException; |
313 | 554 |
|
555 |
/** |
|
556 |
* Returns the first {@link Feature} that meets the criteria indicated. |
|
557 |
* |
|
558 |
* It is a utility method that calls {@link #findFirst(FeatureQuery)}. |
|
559 |
* |
|
560 |
* @param filter {@link String} expression used to filter the features. |
|
561 |
* @param sortBy Attribute names separated by commas used to sort the list to return. |
|
562 |
* @return the first {@link Feature} or null if the filter don't return any feature. |
|
563 |
* @throws DataException |
|
564 |
* @see {@link #findFirst(FeatureQuery)}, {@link #createFeatureQuery(Expession,String,boolean)} |
|
565 |
*/ |
|
314 | 566 |
public Feature findFirst(Expression filter, String sortBy) throws DataException; |
315 | 567 |
|
568 |
/** |
|
569 |
* Returns the first {@link Feature} that meets the criteria indicated. |
|
570 |
* |
|
571 |
* It is a utility method that calls {@link #findFirst(FeatureQuery)}. |
|
572 |
* |
|
573 |
* @param filter {@link String} expression used to filter the features. |
|
574 |
* @param sortBy Attribute names separated by commas used to sort the list to return. |
|
575 |
* @param asc use order ascending, true, or descending, false. |
|
576 |
* @return the first {@link Feature} or null if the filter don't return any feature. |
|
577 |
* @throws DataException |
|
578 |
* @see {@link #findFirst(FeatureQuery)}, {@link #createFeatureQuery(Expession,String,boolean)} |
|
579 |
*/ |
|
316 | 580 |
public Feature findFirst(Expression filter, String sortBy, boolean asc) throws DataException; |
317 | 581 |
|
582 |
/** |
|
583 |
* Returns the first {@link Feature} that meets the criteria indicated. |
|
584 |
* |
|
585 |
* It is a utility method that calls {@link #findFirst(FeatureQuery)}. |
|
586 |
* |
|
587 |
* @param query to filter and sort the returned feature list |
|
588 |
* @return the first {@link Feature} or null if the filter don't return any feature. |
|
589 |
* @throws DataException |
|
590 |
* @see {@link #findFirst(FeatureQuery)}, {@link #createFeatureQuery(Expession,String,boolean)} |
|
591 |
*/ |
|
318 | 592 |
public Feature findFirst(FeatureQuery query) throws DataException; |
593 |
|
|
319 | 594 |
/** |
320 | 595 |
* Returns the feature given its reference. |
321 | 596 |
* |
322 |
* @param reference |
|
323 |
* a unique FeatureReference |
|
324 |
* @return |
|
325 |
* The Feature |
|
326 |
* |
|
597 |
* @param reference a unique FeatureReference |
|
598 |
* @return |
|
599 |
* @returnThe Feature |
|
327 | 600 |
* @throws DataException |
328 | 601 |
* |
329 | 602 |
*/ |
330 |
public Feature getFeatureByReference(FeatureReference reference) |
|
331 |
throws DataException; |
|
603 |
public Feature getFeatureByReference(FeatureReference reference) throws DataException; |
|
332 | 604 |
|
333 | 605 |
/** |
334 | 606 |
* Returns the feature given its reference and feature type. |
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/feature/FeatureAttributeDescriptor.java | ||
---|---|---|
261 | 261 |
|
262 | 262 |
public void recentUsed(); |
263 | 263 |
|
264 |
@Override |
|
264 | 265 |
public String getLocalizedShortLabel(); |
265 | 266 |
|
267 |
@Override |
|
266 | 268 |
public String getLocalizedLabel(); |
269 |
|
|
270 |
public String getLabelOfValue(Object value); |
|
267 | 271 |
} |
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/feature/Feature.java | ||
---|---|---|
501 | 501 |
* @return the FeatureStore of the feature. |
502 | 502 |
*/ |
503 | 503 |
public FeatureStore getStore(); |
504 |
|
|
505 |
public String getLabelOfValue(String name); |
|
504 | 506 |
} |
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/spi/AbstractDataParameters.java | ||
---|---|---|
240 | 240 |
return null; |
241 | 241 |
} |
242 | 242 |
} |
243 |
|
|
243 |
|
|
244 |
@Override |
|
245 |
public boolean equals(Object obj) { |
|
246 |
if( !(obj instanceof DynObject) ) { |
|
247 |
return false; |
|
248 |
} |
|
249 |
DynObjectManager manager = ToolsLocator.getDynObjectManager(); |
|
250 |
return manager.equals(this, (DynObject) obj); |
|
251 |
} |
|
252 |
|
|
253 |
@Override |
|
254 |
public int hashCode() { |
|
255 |
DynObjectManager manager = ToolsLocator.getDynObjectManager(); |
|
256 |
return manager.hashCode(this); |
|
257 |
} |
|
258 |
|
|
244 | 259 |
/** |
245 | 260 |
* Returns an instance of the {@link DynObject} to delegate to. |
246 | 261 |
* |
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 | ||
---|---|---|
19 | 19 |
|
20 | 20 |
import org.gvsig.fmap.dal.DataFactory; |
21 | 21 |
import org.gvsig.fmap.dal.DataManager; |
22 |
import org.gvsig.fmap.dal.DataParameters; |
|
22 | 23 |
import org.gvsig.fmap.dal.DataServerExplorer; |
23 | 24 |
import org.gvsig.fmap.dal.DataServerExplorerFactory; |
24 | 25 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
... | ... | |
149 | 150 |
|
150 | 151 |
private List<DataProfile> dataProfiles; |
151 | 152 |
|
153 |
private final Map<String, DatabaseWorkspaceManager> databaseWorkspaces = new HashMap<>(); |
|
154 |
|
|
152 | 155 |
public DefaultDataManager() { |
153 | 156 |
this.registers = new Registers(); |
154 | 157 |
this.defaultDataIndexProviders = new HashMap<>(); |
... | ... | |
1030 | 1033 |
DatabaseWorkspaceManager workspace = new DefaultDatabaseWorkspaceManager(connection); |
1031 | 1034 |
return workspace; |
1032 | 1035 |
} |
1036 |
|
|
1037 |
@Override |
|
1038 |
public void addDatabaseWorkspace(DatabaseWorkspaceManager databaseWorkspace) { |
|
1039 |
this.databaseWorkspaces.put(databaseWorkspace.getId(),databaseWorkspace); |
|
1040 |
StoresRepository repo = databaseWorkspace.getStoresRepository(); |
|
1041 |
this.getStoresRepository().addRepository(repo); |
|
1042 |
} |
|
1043 |
|
|
1044 |
@Override |
|
1045 |
public DatabaseWorkspaceManager getDatabaseWorkspace(String name) { |
|
1046 |
return this.databaseWorkspaces.get(name); |
|
1047 |
} |
|
1033 | 1048 |
|
1034 | 1049 |
@Override |
1050 |
public DatabaseWorkspaceManager getDatabaseWorkspace(DataStoreParameters params) { |
|
1051 |
for (DatabaseWorkspaceManager databaseWorkspace : this.databaseWorkspaces.values()) { |
|
1052 |
if( databaseWorkspace.getStoresRepository().contains(params) ) { |
|
1053 |
return databaseWorkspace; |
|
1054 |
} |
|
1055 |
} |
|
1056 |
return null; |
|
1057 |
} |
|
1058 |
|
|
1059 |
@Override |
|
1035 | 1060 |
public void writeDALResource(ResourcesStorage resources, DataStore store) { |
1036 | 1061 |
ResourcesStorage.Resource resource = null; |
1037 | 1062 |
try { |
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 | ||
---|---|---|
1 | 1 |
package org.gvsig.fmap.dal.impl; |
2 | 2 |
|
3 |
import java.io.File; |
|
3 | 4 |
import org.gvsig.fmap.dal.DatabaseWorkspaceManager; |
4 | 5 |
import org.apache.commons.lang3.StringUtils; |
6 |
import org.apache.commons.lang3.mutable.Mutable; |
|
7 |
import org.apache.commons.lang3.mutable.MutableObject; |
|
5 | 8 |
import org.gvsig.expressionevaluator.ExpressionBuilder; |
6 | 9 |
import org.gvsig.expressionevaluator.ExpressionUtils; |
7 | 10 |
import org.gvsig.fmap.dal.DALLocator; |
... | ... | |
10 | 13 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
11 | 14 |
import org.gvsig.fmap.dal.DataStoreParameters; |
12 | 15 |
import org.gvsig.fmap.dal.DataTypes; |
16 |
import static org.gvsig.fmap.dal.DatabaseWorkspaceManager.CONFIG_NAME_STORESREPOSITORYID; |
|
17 |
import static org.gvsig.fmap.dal.DatabaseWorkspaceManager.CONFIG_NAME_STORESREPOSITORYLABEL; |
|
18 |
import static org.gvsig.fmap.dal.DatabaseWorkspaceManager.FIELD_CONFIGURATION_NAME; |
|
19 |
import static org.gvsig.fmap.dal.DatabaseWorkspaceManager.FIELD_CONFIGURATION_VALUE; |
|
13 | 20 |
import org.gvsig.fmap.dal.StoresRepository; |
14 | 21 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
15 | 22 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
16 | 23 |
import org.gvsig.fmap.dal.feature.Feature; |
17 | 24 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
18 |
//import org.gvsig.fmap.dal.store.jdbc.JDBCNewStoreParameters; |
|
19 |
//import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorer; |
|
20 |
//import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
|
21 |
//import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters; |
|
22 | 25 |
import static org.gvsig.fmap.dal.DatabaseWorkspaceManager.FIELD_REPOSITORY_NAME; |
26 |
import static org.gvsig.fmap.dal.DatabaseWorkspaceManager.FIELD_REPOSITORY_PARAMETERS; |
|
27 |
import static org.gvsig.fmap.dal.DatabaseWorkspaceManager.FIELD_RESOURCES_NAME; |
|
28 |
import static org.gvsig.fmap.dal.DatabaseWorkspaceManager.FIELD_RESOURCES_RESOURCE; |
|
29 |
import static org.gvsig.fmap.dal.DatabaseWorkspaceManager.TABLE_CONFIGURATION; |
|
30 |
import static org.gvsig.fmap.dal.DatabaseWorkspaceManager.TABLE_CONFIGURATION_NAME; |
|
31 |
import static org.gvsig.fmap.dal.DatabaseWorkspaceManager.TABLE_REPOSITORY; |
|
32 |
import static org.gvsig.fmap.dal.DatabaseWorkspaceManager.TABLE_REPOSITORY_NAME; |
|
33 |
import static org.gvsig.fmap.dal.DatabaseWorkspaceManager.TABLE_RESOURCES; |
|
34 |
import static org.gvsig.fmap.dal.DatabaseWorkspaceManager.TABLE_RESOURCES_NAME; |
|
23 | 35 |
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters; |
36 |
import org.gvsig.tools.resourcesstorage.FilesResourcesStorage; |
|
37 |
import org.gvsig.tools.resourcesstorage.ResourcesStorage; |
|
24 | 38 |
import org.slf4j.Logger; |
25 | 39 |
import org.slf4j.LoggerFactory; |
26 | 40 |
|
... | ... | |
29 | 43 |
* @author jjdelcerro |
30 | 44 |
*/ |
31 | 45 |
@SuppressWarnings("UseSpecificCatch") |
32 |
public class DefaultDatabaseWorkspaceManager implements DatabaseWorkspaceManager { |
|
46 |
public class DefaultDatabaseWorkspaceManager |
|
47 |
implements DatabaseWorkspaceManager |
|
48 |
{ |
|
33 | 49 |
|
34 | 50 |
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultDatabaseWorkspaceManager.class); |
35 |
|
|
36 |
private final DataServerExplorerParameters connection;
|
|
51 |
|
|
52 |
private final DataServerExplorerParameters serverParameters;
|
|
37 | 53 |
private Boolean existsConfiguration = null; |
38 | 54 |
private StoresRepository storesRepository; |
55 |
private Mutable<ResourcesStorage> alternativeResourcesStorage = null; |
|
39 | 56 |
|
40 |
public DefaultDatabaseWorkspaceManager(DataServerExplorerParameters connection) { |
|
41 |
this.connection = connection; |
|
57 |
|
|
58 |
public DefaultDatabaseWorkspaceManager(DataServerExplorerParameters serverParameters) { |
|
59 |
this.serverParameters = serverParameters; |
|
42 | 60 |
} |
43 | 61 |
|
44 | 62 |
@Override |
63 |
public String getId() { |
|
64 |
String id = this.get(CONFIG_NAME_STORESREPOSITORYID); |
|
65 |
return id; |
|
66 |
} |
|
67 |
|
|
68 |
@Override |
|
69 |
public String getLabel() { |
|
70 |
String label = this.get(CONFIG_NAME_STORESREPOSITORYLABEL); |
|
71 |
return label; |
|
72 |
} |
|
73 |
|
|
74 |
@Override |
|
45 | 75 |
public boolean existsTable(int tableid) { |
46 | 76 |
switch(tableid) { |
47 | 77 |
case TABLE_RESOURCES: |
... | ... | |
107 | 137 |
try { |
108 | 138 |
DataManager dataManager = DALLocator.getDataManager(); |
109 | 139 |
DataServerExplorer server = dataManager.openServerExplorer( |
110 |
this.connection.getProviderName(),
|
|
111 |
this.connection
|
|
140 |
this.serverParameters.getProviderName(),
|
|
141 |
this.serverParameters
|
|
112 | 142 |
); |
113 | 143 |
for (DataStoreParameters params : server.list()) { |
114 | 144 |
String theTableName = (String) params.getDynValue("Table"); |
... | ... | |
126 | 156 |
try { |
127 | 157 |
DataManager dataManager = DALLocator.getDataManager(); |
128 | 158 |
DataServerExplorer server = dataManager.openServerExplorer( |
129 |
this.connection.getProviderName(),
|
|
130 |
this.connection
|
|
159 |
this.serverParameters.getProviderName(),
|
|
160 |
this.serverParameters
|
|
131 | 161 |
); |
132 | 162 |
DataStoreParameters params = server.get(tableName); |
133 | 163 |
if( params!=null ) { |
... | ... | |
147 | 177 |
try { |
148 | 178 |
DataManager dataManager = DALLocator.getDataManager(); |
149 | 179 |
DataServerExplorer server = dataManager.openServerExplorer( |
150 |
this.connection.getProviderName(),
|
|
151 |
this.connection
|
|
180 |
this.serverParameters.getProviderName(),
|
|
181 |
this.serverParameters
|
|
152 | 182 |
); |
153 | 183 |
DataStoreParameters params = server.get(tableName); |
154 | 184 |
if( params!=null ) { |
... | ... | |
164 | 194 |
try { |
165 | 195 |
DataManager dataManager = DALLocator.getDataManager(); |
166 | 196 |
DataServerExplorer server = dataManager.openServerExplorer( |
167 |
this.connection.getProviderName(),
|
|
168 |
this.connection
|
|
197 |
this.serverParameters.getProviderName(),
|
|
198 |
this.serverParameters
|
|
169 | 199 |
); |
170 | 200 |
NewFeatureStoreParameters params = (NewFeatureStoreParameters) server.getAddParameters(tableName); |
171 | 201 |
EditableFeatureType ft = params.getDefaultFeatureType(); |
... | ... | |
185 | 215 |
try { |
186 | 216 |
DataManager dataManager = DALLocator.getDataManager(); |
187 | 217 |
DataServerExplorer server = dataManager.openServerExplorer( |
188 |
this.connection.getProviderName(),
|
|
189 |
this.connection
|
|
218 |
this.serverParameters.getProviderName(),
|
|
219 |
this.serverParameters
|
|
190 | 220 |
); |
191 | 221 |
NewFeatureStoreParameters params = (NewFeatureStoreParameters) server.getAddParameters(tableName); |
192 | 222 |
EditableFeatureType ft = params.getDefaultFeatureType(); |
... | ... | |
206 | 236 |
try { |
207 | 237 |
DataManager dataManager = DALLocator.getDataManager(); |
208 | 238 |
DataServerExplorer server = dataManager.openServerExplorer( |
209 |
this.connection.getProviderName(),
|
|
210 |
this.connection
|
|
239 |
this.serverParameters.getProviderName(),
|
|
240 |
this.serverParameters
|
|
211 | 241 |
); |
212 | 242 |
NewFeatureStoreParameters params = (NewFeatureStoreParameters) server.getAddParameters(tableName); |
213 | 243 |
EditableFeatureType ft = params.getDefaultFeatureType(); |
... | ... | |
301 | 331 |
this.storesRepository = new DatabaseWorkspaceStoresRepository( |
302 | 332 |
id, |
303 | 333 |
label, |
304 |
this.connection
|
|
334 |
this.serverParameters
|
|
305 | 335 |
); |
306 | 336 |
} |
307 | 337 |
return this.storesRepository; |
308 | 338 |
} |
339 |
|
|
340 |
public boolean contains(DataStoreParameters parameters) { |
|
341 |
boolean c = this.getStoresRepository().contains(parameters); |
|
342 |
return c; |
|
343 |
} |
|
309 | 344 |
|
310 | 345 |
@Override |
311 | 346 |
public boolean canAnonymousUserWriteInTheTables() { |
... | ... | |
313 | 348 |
} |
314 | 349 |
|
315 | 350 |
@Override |
316 |
public boolean storesRepositoryWriteEntry(String name, DataStoreParameters parameters) {
|
|
351 |
public boolean writeStoresRepositoryEntry(String name, DataStoreParameters parameters) {
|
|
317 | 352 |
try { |
318 | 353 |
byte[] data = parameters.toByteArray(); |
319 | 354 |
if( data == null ) { |
... | ... | |
359 | 394 |
return true; |
360 | 395 |
|
361 | 396 |
} |
397 |
|
|
398 |
@Override |
|
399 |
public ResourcesStorage getAlternativeResourcesStorage() { |
|
400 |
if( this.alternativeResourcesStorage==null ) { |
|
401 |
this.alternativeResourcesStorage = new MutableObject<>(null); |
|
402 |
String resourcesPath = this.get("ALTERNATIVE_RESOURCES_PATH"); |
|
403 |
if( !StringUtils.isBlank(resourcesPath) ) { |
|
404 |
try { |
|
405 |
resourcesPath = (String) ExpressionUtils.evaluate(resourcesPath); |
|
406 |
} catch(Throwable th) { |
|
407 |
// Do nothing |
|
408 |
} |
|
409 |
File f = new File(resourcesPath); |
|
410 |
if( f.exists() ) { |
|
411 |
ResourcesStorage resources = new FilesResourcesStorage(resourcesPath); |
|
412 |
this.alternativeResourcesStorage.setValue(resources); |
|
413 |
} |
|
414 |
} |
|
415 |
} |
|
416 |
return this.alternativeResourcesStorage.getValue(); |
|
417 |
} |
|
418 |
|
|
419 |
public void create(String id, String description) { |
|
420 |
if( !this.existsTable(TABLE_RESOURCES) ) { |
|
421 |
this.createTable(TABLE_RESOURCES); |
|
422 |
} |
|
423 |
if( !this.existsTable(TABLE_CONFIGURATION) ) { |
|
424 |
this.createTable(TABLE_CONFIGURATION); |
|
425 |
} |
|
426 |
if( !this.existsTable(TABLE_REPOSITORY) ) { |
|
427 |
this.createTable(TABLE_REPOSITORY); |
|
428 |
} |
|
429 |
this.set(CONFIG_NAME_STORESREPOSITORYID,id); |
|
430 |
this.set(CONFIG_NAME_STORESREPOSITORYLABEL,description); |
|
431 |
this.set(CONFIG_CAN_ANONYMOUS_USER_WRITE_IN_THE_TABLES,"true"); |
|
432 |
this.set("ALTERNATIVE_RESOURCES_PATH",""); |
|
433 |
} |
|
362 | 434 |
} |
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 | ||
---|---|---|
1059 | 1059 |
public boolean containsKey(String key) { |
1060 | 1060 |
return this.data.getType().get(key)!=null; |
1061 | 1061 |
} |
1062 |
|
|
1063 |
@Override |
|
1064 |
public String getLabelOfValue(String name) { |
|
1065 |
FeatureAttributeDescriptor attrdesc = this.data.getType().getAttributeDescriptor(name); |
|
1066 |
if( attrdesc==null ) { |
|
1067 |
throw new IllegalArgumentException("Attribute name '"+name+"' not found in the feature."); |
|
1068 |
} |
|
1069 |
Object value = this.get(attrdesc.getIndex()); |
|
1070 |
String label = attrdesc.getLabelOfValue(value); |
|
1071 |
return label; |
|
1072 |
} |
|
1073 |
|
|
1062 | 1074 |
} |
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 | ||
---|---|---|
47 | 47 |
import org.gvsig.expressionevaluator.Expression; |
48 | 48 |
import org.gvsig.expressionevaluator.ExpressionBuilder; |
49 | 49 |
import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator; |
50 |
import org.gvsig.expressionevaluator.ExpressionUtils; |
|
50 | 51 |
import org.gvsig.fmap.dal.BaseStoresRepository; |
51 | 52 |
|
52 | 53 |
import org.gvsig.fmap.dal.DALLocator; |
... | ... | |
1915 | 1916 |
@Override |
1916 | 1917 |
public List<Feature> getFeatures(String filter, String sortBy, boolean asc) { |
1917 | 1918 |
FeatureQuery query = this.createFeatureQuery(filter, sortBy, asc); |
1918 |
return this.getFeatures(query, 100);
|
|
1919 |
return this.getFeatures(query, 0); |
|
1919 | 1920 |
} |
1920 | 1921 |
|
1921 | 1922 |
@Override |
... | ... | |
1931 | 1932 |
@Override |
1932 | 1933 |
public List<Feature> getFeatures(Expression filter, String sortBy, boolean asc) { |
1933 | 1934 |
FeatureQuery query = this.createFeatureQuery(filter, sortBy, asc); |
1934 |
return this.getFeatures(query, 100);
|
|
1935 |
return this.getFeatures(query, 0); |
|
1935 | 1936 |
} |
1936 | 1937 |
|
1937 | 1938 |
@Override |
1938 | 1939 |
public List<Feature> getFeatures(FeatureQuery query) { |
1939 |
return this.getFeatures(query, 100);
|
|
1940 |
return this.getFeatures(query, 0); |
|
1940 | 1941 |
} |
1941 | 1942 |
|
1942 | 1943 |
@Override |
1943 | 1944 |
public List<Feature> getFeatures(FeatureQuery query, int pageSize) { |
1944 | 1945 |
try { |
1946 |
if( pageSize<=0 ) { |
|
1947 |
pageSize = 100; |
|
1948 |
} |
|
1945 | 1949 |
FeaturePagingHelper pager = this.dataManager.createFeaturePagingHelper(this, query, pageSize); |
1946 | 1950 |
return pager.asList(); |
1947 | 1951 |
} catch (BaseException ex) { |
... | ... | |
1951 | 1955 |
|
1952 | 1956 |
@Override |
1953 | 1957 |
public List<Feature> getFeatures() { |
1954 |
return this.getFeatures(null, 500);
|
|
1958 |
return this.getFeatures(null, 0); |
|
1955 | 1959 |
} |
1956 | 1960 |
|
1957 | 1961 |
@Override |
... | ... | |
2527 | 2531 |
return new DefaultFeatureQuery(); |
2528 | 2532 |
} |
2529 | 2533 |
|
2530 |
private FeatureQuery createFeatureQuery(Expression filter, String sortBy, boolean asc) {
|
|
2534 |
public FeatureQuery createFeatureQuery(Expression filter, String sortBy, boolean asc) {
|
|
2531 | 2535 |
FeatureQuery query = null; |
2532 | 2536 |
if( filter!=null ) { |
2533 | 2537 |
query = this.createFeatureQuery(); |
... | ... | |
2537 | 2541 |
if( query == null ) { |
2538 | 2542 |
query = this.createFeatureQuery(); |
2539 | 2543 |
} |
2540 |
query.getOrder().add(sortBy, asc); |
|
2544 |
String[] attrnames; |
|
2545 |
if( sortBy.contains(",") ) { |
|
2546 |
attrnames = StringUtils.split(sortBy, ","); |
|
2547 |
} else { |
|
2548 |
attrnames = new String[] { sortBy }; |
|
2549 |
} |
|
2550 |
for (String attrname : attrnames) { |
|
2551 |
attrname = attrname.trim(); |
|
2552 |
if( attrname.startsWith("-") ) { |
|
2553 |
query.getOrder().add(sortBy.substring(1).trim(), false); |
|
2554 |
} else if( attrname.endsWith("-") ) { |
|
2555 |
query.getOrder().add(sortBy.substring(0,sortBy.length()-1).trim(), false); |
|
2556 |
} else if( attrname.startsWith("+") ) { |
|
2557 |
query.getOrder().add(sortBy.substring(1).trim(), true); |
|
2558 |
} else if( attrname.endsWith("-") ) { |
|
2559 |
query.getOrder().add(sortBy.substring(0,sortBy.length()-1).trim(), true); |
|
2560 |
} else { |
|
2561 |
query.getOrder().add(sortBy, asc); |
|
2562 |
} |
|
2563 |
} |
|
2541 | 2564 |
} |
2542 | 2565 |
if( query != null ) { |
2543 | 2566 |
query.retrievesAllAttributes(); |
... | ... | |
2545 | 2568 |
return query; |
2546 | 2569 |
} |
2547 | 2570 |
|
2548 |
private FeatureQuery createFeatureQuery(String filter, String sortBy, boolean asc) { |
|
2549 |
FeatureQuery query = null; |
|
2550 |
if( !StringUtils.isEmpty(filter) ) { |
|
2551 |
query = this.createFeatureQuery(); |
|
2552 |
query.setFilter(filter); |
|
2571 |
public FeatureQuery createFeatureQuery(String filter, String sortBy, boolean asc) { |
|
2572 |
if( StringUtils.isBlank(filter) ) { |
|
2573 |
return this.createFeatureQuery( |
|
2574 |
(Expression)null, |
|
2575 |
sortBy, |
|
2576 |
asc |
|
2577 |
); |
|
2578 |
} else { |
|
2579 |
return this.createFeatureQuery( |
|
2580 |
ExpressionUtils.createExpression(filter), |
|
2581 |
sortBy, |
|
2582 |
asc |
|
2583 |
); |
|
2553 | 2584 |
} |
2554 |
if( !StringUtils.isEmpty(sortBy) ) { |
|
2555 |
if( query == null ) { |
|
2556 |
query = this.createFeatureQuery(); |
|
2557 |
} |
|
2558 |
query.getOrder().add(sortBy, asc); |
|
2559 |
} |
|
2560 |
if( query != null ) { |
|
2561 |
query.retrievesAllAttributes(); |
|
2562 |
} |
|
2563 |
return query; |
|
2564 | 2585 |
} |
2565 | 2586 |
|
2566 | 2587 |
@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/feature/impl/DefaultFeatureAttributeDescriptor.java | ||
---|---|---|
112 | 112 |
protected boolean allowIndexDuplicateds = true; |
113 | 113 |
|
114 | 114 |
protected DynObjectValueItem[] availableValues; |
115 |
private Map<Object,String> labelOfValueMap; // No persistente |
|
115 | 116 |
protected String description; |
116 | 117 |
protected Object minValue; |
117 | 118 |
protected Object maxValue; |
... | ... | |
785 | 786 |
} |
786 | 787 |
|
787 | 788 |
@Override |
789 |
public String getLabelOfValue(Object value) { |
|
790 |
if( this.labelOfValueMap != null ) { |
|
791 |
String theLabel = this.labelOfValueMap.get(value); |
|
792 |
if( theLabel == null ) { |
|
793 |
theLabel = Objects.toString(value, ""); |
|
794 |
} |
|
795 |
return theLabel; |
|
796 |
} |
|
797 |
DynObjectValueItem[] values = this.getAvailableValues(); |
|
798 |
if( values == null ) { |
|
799 |
return Objects.toString(value, ""); |
|
800 |
} |
|
801 |
Map<Object, String> map = new HashMap<>(); |
|
802 |
for (DynObjectValueItem theValue : values) { |
|
803 |
map.put(theValue.getValue(), theValue.getLabel()); |
|
804 |
} |
|
805 |
this.labelOfValueMap = map; |
|
806 |
String theLabel = this.labelOfValueMap.get(value); |
|
807 |
if( theLabel == null ) { |
|
808 |
theLabel = Objects.toString(value, ""); |
|
809 |
} |
|
810 |
return theLabel; |
|
811 |
} |
|
812 |
|
|
813 |
@Override |
Also available in: Unified diff