Statistics
| Revision:

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 @ 44644

History | View | Annotate | Download (5.87 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 44419 jjdelcerro
    public interface AddDatabaseWorkspaceListener {
19
20
        public String getName();
21
22
        public void onAddDatabaseWorkspace(DatabaseWorkspaceManager databaseWorkspace);
23
    }
24
25
26
27 44297 jjdelcerro
    public static final String CONFIG_CAN_ANONYMOUS_USER_WRITE_IN_THE_TABLES = "CanAnonymousUserWriteInTheTables";
28 44304 jjdelcerro
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 44297 jjdelcerro
33 44304 jjdelcerro
    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 44297 jjdelcerro
42 44304 jjdelcerro
    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 44346 jjdelcerro
    /**
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 44633 jjdelcerro
    public DataServerExplorer getServerExplorer();
80
81 44346 jjdelcerro
    /**
82
     * Returns the label of this workspace.
83
     *
84
     * @return the label value.
85
     */
86 44633 jjdelcerro
    @Override
87 44346 jjdelcerro
    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 44297 jjdelcerro
    public String get(String name);
97
98 44346 jjdelcerro
    /**
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 44326 jjdelcerro
    public boolean set(String name, String value);
106 44297 jjdelcerro
107 44346 jjdelcerro
    /**
108
     * Gets the repository of data stores associated with this workspace.
109
     *
110
     * @return the data stores repository.
111
     */
112 44297 jjdelcerro
    public StoresRepository getStoresRepository();
113 44304 jjdelcerro
114 44346 jjdelcerro
    /**
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 44297 jjdelcerro
123
    public boolean canAnonymousUserWriteInTheTables();
124
125 44346 jjdelcerro
    /**
126
     * Check if the indicated configuration table exists in the workspace.
127
     *
128
     * @param tableid
129
     * @return true if the table exists.
130
     */
131 44304 jjdelcerro
    public boolean existsTable(int tableid);
132
133 44346 jjdelcerro
    /**
134
     * Create the configuration table indicated in the workspace.
135
     *
136
     * @param tableid identifier of the configuration table to create.
137
     */
138 44304 jjdelcerro
    public void createTable(int tableid);
139 44297 jjdelcerro
140 44346 jjdelcerro
    /**
141
     * Remove the indicated configuration table from the workspace.
142
     *
143
     * @param tableid identifier of the configuration table to remove.
144
     */
145 44304 jjdelcerro
    public void dropTable(int tableid);
146 44297 jjdelcerro
147 44346 jjdelcerro
    /**
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 44380 jjdelcerro
     * 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 44346 jjdelcerro
     * At least the repositories table must exist and the variable
168
     * "StoresRepository.id" must be defined.
169
     *
170
     * @return
171
     */
172 44304 jjdelcerro
    public boolean isValidStoresRepository();
173 44346 jjdelcerro
174
    /**
175
     * If the workspace has an alternate resource storage defined, return it.
176
     * If don't have it, return null.
177
     *
178 44380 jjdelcerro
     * @param tableName
179 44346 jjdelcerro
     * @return the alternate resource storage.
180
     */
181 44380 jjdelcerro
    public ResourcesStorage getAlternativeResourcesStorage(String tableName);
182 44346 jjdelcerro
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 44304 jjdelcerro
191 44362 jjdelcerro
    public void drop();
192 44397 jjdelcerro
193
    public File getBaseFolder();
194
195
    public void setBaseFolder(File baseFolder);
196 44419 jjdelcerro
197
    public ResourcesStorage getResourcesStorage();
198 44397 jjdelcerro
199 44297 jjdelcerro
}