svn-gvsig-desktop / 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 @ 44633
History | View | Annotate | Download (5.87 KB)
1 |
package org.gvsig.fmap.dal; |
---|---|
2 |
|
3 |
import java.io.File; |
4 |
import org.apache.commons.lang3.StringUtils; |
5 |
import org.gvsig.expressionevaluator.SymbolTable; |
6 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
7 |
import org.gvsig.tools.resourcesstorage.ResourcesStorage; |
8 |
import org.gvsig.tools.util.LabeledValue; |
9 |
|
10 |
/**
|
11 |
*
|
12 |
* @author jjdelcerro
|
13 |
*/
|
14 |
public interface DatabaseWorkspaceManager |
15 |
extends LabeledValue<DatabaseWorkspaceManager>, SymbolTable
|
16 |
{ |
17 |
|
18 |
public interface AddDatabaseWorkspaceListener { |
19 |
|
20 |
public String getName(); |
21 |
|
22 |
public void onAddDatabaseWorkspace(DatabaseWorkspaceManager databaseWorkspace); |
23 |
} |
24 |
|
25 |
|
26 |
|
27 |
public static final String CONFIG_CAN_ANONYMOUS_USER_WRITE_IN_THE_TABLES = "CanAnonymousUserWriteInTheTables"; |
28 |
|
29 |
public static final String TABLE_REPOSITORY_NAME = "gvsigd_repository"; |
30 |
public static final String TABLE_RESOURCES_NAME = "gvsigd_resources"; |
31 |
public static final String TABLE_CONFIGURATION_NAME = "gvsigd_config"; |
32 |
|
33 |
public static final String FIELD_RESOURCES_NAME = "name"; |
34 |
public static final String FIELD_RESOURCES_RESOURCE = "resource"; |
35 |
|
36 |
public static final String FIELD_REPOSITORY_NAME = "name"; |
37 |
public static final String FIELD_REPOSITORY_PARAMETERS = "parameters"; |
38 |
|
39 |
public static final String FIELD_CONFIGURATION_NAME = "name"; |
40 |
public static final String FIELD_CONFIGURATION_VALUE = "value"; |
41 |
|
42 |
public static final int TABLE_RESOURCES = 0; |
43 |
public static final int TABLE_REPOSITORY = 1; |
44 |
public static final int TABLE_CONFIGURATION = 2; |
45 |
|
46 |
public static final String CONFIG_NAME_STORESREPOSITORYID = "StoresRepository.id"; |
47 |
public static final String CONFIG_NAME_STORESREPOSITORYLABEL = "StoresRepository.label"; |
48 |
|
49 |
/**
|
50 |
* Check if the indicated name corresponds to one of the configuration tables of the workspace.
|
51 |
*
|
52 |
* @param name to check.
|
53 |
* @return true if the name is that of a configuration table.
|
54 |
*/
|
55 |
public static boolean isInternalTable(String name) { |
56 |
if( StringUtils.isBlank(name) ) {
|
57 |
return false; |
58 |
} |
59 |
String[] internalNames = new String[] { |
60 |
TABLE_REPOSITORY_NAME, |
61 |
TABLE_RESOURCES_NAME, |
62 |
TABLE_CONFIGURATION_NAME |
63 |
}; |
64 |
for (String internalName : internalNames) { |
65 |
if( name.equalsIgnoreCase(internalName) ) {
|
66 |
return true; |
67 |
} |
68 |
} |
69 |
return false; |
70 |
} |
71 |
|
72 |
/**
|
73 |
* Returns the identifier of this workspace.
|
74 |
*
|
75 |
* @return the id.
|
76 |
*/
|
77 |
public String getId(); |
78 |
|
79 |
public DataServerExplorer getServerExplorer();
|
80 |
|
81 |
/**
|
82 |
* Returns the label of this workspace.
|
83 |
*
|
84 |
* @return the label value.
|
85 |
*/
|
86 |
@Override
|
87 |
public String getLabel(); |
88 |
|
89 |
/**
|
90 |
* Gets the value of a configuration variable associated with
|
91 |
* this work space.
|
92 |
*
|
93 |
* @param name of the variable to consult
|
94 |
* @return the value of the variable
|
95 |
*/
|
96 |
public String get(String name); |
97 |
|
98 |
/**
|
99 |
* Assigns the indicated value to the configuration variable.
|
100 |
*
|
101 |
* @param name of the variable.
|
102 |
* @param value value to set.
|
103 |
* @return true if can assign the value.
|
104 |
*/
|
105 |
public boolean set(String name, String value); |
106 |
|
107 |
/**
|
108 |
* Gets the repository of data stores associated with this workspace.
|
109 |
*
|
110 |
* @return the data stores repository.
|
111 |
*/
|
112 |
public StoresRepository getStoresRepository();
|
113 |
|
114 |
/**
|
115 |
* Add a new data store to the workspace.
|
116 |
*
|
117 |
* @param name of the data store.
|
118 |
* @param parameters to open the data store.
|
119 |
* @return true if ok.
|
120 |
*/
|
121 |
public boolean writeStoresRepositoryEntry(String name, DataStoreParameters parameters); |
122 |
|
123 |
public boolean canAnonymousUserWriteInTheTables(); |
124 |
|
125 |
/**
|
126 |
* Check if the indicated configuration table exists in the workspace.
|
127 |
*
|
128 |
* @param tableid
|
129 |
* @return true if the table exists.
|
130 |
*/
|
131 |
public boolean existsTable(int tableid); |
132 |
|
133 |
/**
|
134 |
* Create the configuration table indicated in the workspace.
|
135 |
*
|
136 |
* @param tableid identifier of the configuration table to create.
|
137 |
*/
|
138 |
public void createTable(int tableid); |
139 |
|
140 |
/**
|
141 |
* Remove the indicated configuration table from the workspace.
|
142 |
*
|
143 |
* @param tableid identifier of the configuration table to remove.
|
144 |
*/
|
145 |
public void dropTable(int tableid); |
146 |
|
147 |
/**
|
148 |
* Gets the data store associated with the indicated configuration table.
|
149 |
*
|
150 |
* @param tableid identifier of the configuration table to get.
|
151 |
* @return the FeatureStore of the configuration table.
|
152 |
*/
|
153 |
public FeatureStore getTable(int tableid); |
154 |
|
155 |
/**
|
156 |
* Returns true if the connection associated with this object refers
|
157 |
* to a valid workspace.
|
158 |
* At least the variable "StoresRepository.id" must be defined.
|
159 |
*
|
160 |
* @return
|
161 |
*/
|
162 |
public boolean isValid(); |
163 |
|
164 |
/**
|
165 |
* Returns true if the connection associated with this object refers
|
166 |
* to a valid workspace with a stores-repository.
|
167 |
* At least the repositories table must exist and the variable
|
168 |
* "StoresRepository.id" must be defined.
|
169 |
*
|
170 |
* @return
|
171 |
*/
|
172 |
public boolean isValidStoresRepository(); |
173 |
|
174 |
/**
|
175 |
* If the workspace has an alternate resource storage defined, return it.
|
176 |
* If don't have it, return null.
|
177 |
*
|
178 |
* @param tableName
|
179 |
* @return the alternate resource storage.
|
180 |
*/
|
181 |
public ResourcesStorage getAlternativeResourcesStorage(String tableName); |
182 |
|
183 |
/**
|
184 |
* Create and initialize the tables associated with a gvSIG workspace.
|
185 |
*
|
186 |
* @param id of the workspace
|
187 |
* @param description of the workspace
|
188 |
*/
|
189 |
public void create(String id, String description); |
190 |
|
191 |
public void drop(); |
192 |
|
193 |
public File getBaseFolder(); |
194 |
|
195 |
public void setBaseFolder(File baseFolder); |
196 |
|
197 |
public ResourcesStorage getResourcesStorage();
|
198 |
|
199 |
} |