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