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 @ 46316
History | View | Annotate | Download (6.2 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 | 44346 | jjdelcerro | /**
|
85 | * Returns the label of this workspace.
|
||
86 | *
|
||
87 | * @return the label value.
|
||
88 | */
|
||
89 | 44633 | jjdelcerro | @Override
|
90 | 44346 | jjdelcerro | public String getLabel(); |
91 | |||
92 | /**
|
||
93 | * Gets the value of a configuration variable associated with
|
||
94 | * this work space.
|
||
95 | *
|
||
96 | * @param name of the variable to consult
|
||
97 | * @return the value of the variable
|
||
98 | */
|
||
99 | 44297 | jjdelcerro | public String get(String name); |
100 | |||
101 | 44346 | jjdelcerro | /**
|
102 | * Assigns the indicated value to the configuration variable.
|
||
103 | *
|
||
104 | * @param name of the variable.
|
||
105 | * @param value value to set.
|
||
106 | * @return true if can assign the value.
|
||
107 | */
|
||
108 | 44326 | jjdelcerro | public boolean set(String name, String value); |
109 | 44297 | jjdelcerro | |
110 | 44346 | jjdelcerro | /**
|
111 | * Gets the repository of data stores associated with this workspace.
|
||
112 | *
|
||
113 | * @return the data stores repository.
|
||
114 | */
|
||
115 | 44297 | jjdelcerro | public StoresRepository getStoresRepository();
|
116 | 44304 | jjdelcerro | |
117 | 44346 | jjdelcerro | /**
|
118 | * Add a new data store to the workspace.
|
||
119 | *
|
||
120 | * @param name of the data store.
|
||
121 | * @param parameters to open the data store.
|
||
122 | * @return true if ok.
|
||
123 | */
|
||
124 | public boolean writeStoresRepositoryEntry(String name, DataStoreParameters parameters); |
||
125 | 44297 | jjdelcerro | |
126 | public boolean canAnonymousUserWriteInTheTables(); |
||
127 | |||
128 | 44346 | jjdelcerro | /**
|
129 | * Check if the indicated configuration table exists in the workspace.
|
||
130 | *
|
||
131 | * @param tableid
|
||
132 | * @return true if the table exists.
|
||
133 | */
|
||
134 | 44304 | jjdelcerro | public boolean existsTable(int tableid); |
135 | |||
136 | 44346 | jjdelcerro | /**
|
137 | * Create the configuration table indicated in the workspace.
|
||
138 | *
|
||
139 | * @param tableid identifier of the configuration table to create.
|
||
140 | */
|
||
141 | 44304 | jjdelcerro | public void createTable(int tableid); |
142 | 44297 | jjdelcerro | |
143 | 44346 | jjdelcerro | /**
|
144 | * Remove the indicated configuration table from the workspace.
|
||
145 | *
|
||
146 | * @param tableid identifier of the configuration table to remove.
|
||
147 | */
|
||
148 | 44304 | jjdelcerro | public void dropTable(int tableid); |
149 | 44297 | jjdelcerro | |
150 | 44346 | jjdelcerro | /**
|
151 | * Gets the data store associated with the indicated configuration table.
|
||
152 | *
|
||
153 | * @param tableid identifier of the configuration table to get.
|
||
154 | * @return the FeatureStore of the configuration table.
|
||
155 | */
|
||
156 | public FeatureStore getTable(int tableid); |
||
157 | |||
158 | /**
|
||
159 | * Returns true if the connection associated with this object refers
|
||
160 | * to a valid workspace.
|
||
161 | 44380 | jjdelcerro | * At least the variable "StoresRepository.id" must be defined.
|
162 | *
|
||
163 | * @return
|
||
164 | */
|
||
165 | public boolean isValid(); |
||
166 | |||
167 | /**
|
||
168 | * Returns true if the connection associated with this object refers
|
||
169 | * to a valid workspace with a stores-repository.
|
||
170 | 44346 | jjdelcerro | * At least the repositories table must exist and the variable
|
171 | * "StoresRepository.id" must be defined.
|
||
172 | *
|
||
173 | * @return
|
||
174 | */
|
||
175 | 44304 | jjdelcerro | public boolean isValidStoresRepository(); |
176 | 44346 | jjdelcerro | |
177 | /**
|
||
178 | * If the workspace has an alternate resource storage defined, return it.
|
||
179 | * If don't have it, return null.
|
||
180 | *
|
||
181 | 44380 | jjdelcerro | * @param tableName
|
182 | 44346 | jjdelcerro | * @return the alternate resource storage.
|
183 | */
|
||
184 | 44380 | jjdelcerro | public ResourcesStorage getAlternativeResourcesStorage(String tableName); |
185 | 44346 | jjdelcerro | |
186 | /**
|
||
187 | * Create and initialize the tables associated with a gvSIG workspace.
|
||
188 | *
|
||
189 | * @param id of the workspace
|
||
190 | * @param description of the workspace
|
||
191 | */
|
||
192 | public void create(String id, String description); |
||
193 | 44304 | jjdelcerro | |
194 | 44362 | jjdelcerro | public void drop(); |
195 | 44397 | jjdelcerro | |
196 | public File getBaseFolder(); |
||
197 | |||
198 | public void setBaseFolder(File baseFolder); |
||
199 | 44419 | jjdelcerro | |
200 | public ResourcesStorage getResourcesStorage();
|
||
201 | 44728 | jjdelcerro | |
202 | public void connect(); |
||
203 | 44821 | jjdelcerro | |
204 | public void disconnect(); |
||
205 | 45580 | jjdelcerro | |
206 | public void createTableRepository(String tableName); |
||
207 | |||
208 | public void createTableResources(String tableName); |
||
209 | 44297 | jjdelcerro | } |