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