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

History | View | Annotate | Download (6.64 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.Bitmask;
9
import org.gvsig.tools.util.LabeledValue;
10

    
11
/**
12
 *
13
 * @author jjdelcerro
14
 */
15
public interface DatabaseWorkspaceManager 
16
        extends LabeledValue<DatabaseWorkspaceManager>, SymbolTable, SupportTransactions
17
    {
18
    
19
    public interface DatabaseWorkspaceListener {
20
        
21
        public String getName();
22
        
23
        public void onAddDatabaseWorkspace(DatabaseWorkspaceManager databaseWorkspace);
24
        
25
        public void onRemoveDatabaseWorkspace(DatabaseWorkspaceManager databaseWorkspace);
26
    }
27
    
28
    
29
    
30
    public static final String CONFIG_CAN_ANONYMOUS_USER_WRITE_IN_THE_TABLES = "CanAnonymousUserWriteInTheTables";
31

    
32
    public static final String TABLE_REPOSITORY_NAME = "GVSIGD_REPOSITORY";
33
    public static final String TABLE_RESOURCES_NAME = "GVSIGD_RESOURCES";
34
    public static final String TABLE_CONFIGURATION_NAME = "GVSIGD_CONFIG";
35
    
36
    public static final String FIELD_RESOURCES_NAME = "name";
37
    public static final String FIELD_RESOURCES_RESOURCE = "resource";
38

    
39
    public static final String FIELD_REPOSITORY_NAME = "name";
40
    public static final String FIELD_REPOSITORY_PARAMETERS = "parameters";
41
    public static final String FIELD_REPOSITORY_FLAGS = "flags";
42

    
43
    public static final String FIELD_CONFIGURATION_NAME = "name";
44
    public static final String FIELD_CONFIGURATION_VALUE = "value";
45
    
46
    public static final int TABLE_RESOURCES = 0;
47
    public static final int TABLE_REPOSITORY = 1;
48
    public static final int TABLE_CONFIGURATION = 2;
49
    
50
    public static final String CONFIG_NAME_STORESREPOSITORYID = "StoresRepository.id";
51
    public static final String CONFIG_NAME_STORESREPOSITORYLABEL = "StoresRepository.label";
52

    
53
    /**
54
     * Check if the indicated name corresponds to one of the configuration tables of the workspace.
55
     * 
56
     * @param name to check.
57
     * @return true if the name is that of a configuration table.
58
     */
59
    public static boolean isInternalTable(String name) {
60
        if( StringUtils.isBlank(name) ) {
61
            return false;
62
        }
63
        String[] internalNames = new String[] {
64
            TABLE_REPOSITORY_NAME,
65
            TABLE_RESOURCES_NAME,
66
            TABLE_CONFIGURATION_NAME
67
        };
68
        for (String internalName : internalNames) {
69
            if( name.equalsIgnoreCase(internalName) ) {
70
                return true;
71
            }
72
        }
73
        return false;
74
    }
75

    
76
    /**
77
     * Returns the identifier of this workspace.
78
     * 
79
     * @return the id.
80
     */
81
    public String getId();
82

    
83
    public DataServerExplorer getServerExplorer();
84
    
85
    public DataServerExplorerParameters getServerExplorerParameters();
86
    
87
    /**
88
     * Returns the label of this workspace.
89
     * 
90
     * @return the label value.
91
     */
92
    @Override
93
    public String getLabel();
94
    
95
    /**
96
     * Gets the value of a configuration variable associated with 
97
     * this work space.
98
     * 
99
     * @param name of the variable to consult 
100
     * @return the value of the variable 
101
     */
102
    public String get(String name);
103
    
104
    /**
105
     * Assigns the indicated value to the configuration variable.
106
     * 
107
     * @param name of the variable.
108
     * @param value value to set.
109
     * @return true if can assign the value.
110
     */
111
    public boolean set(String name, String value);
112
    
113
    /**
114
     * Gets the repository of data stores associated with this workspace.
115
     * 
116
     * @return the data stores repository.
117
     */
118
    public StoresRepository getStoresRepository();
119
    
120
    /**
121
     * Add a new data store to the workspace.
122
     * 
123
     * @param name of the data store.
124
     * @param parameters to open the data store.
125
     * @return true if ok.
126
     */
127
    public boolean writeStoresRepositoryEntry(String name, DataStoreParameters parameters);
128
    public boolean writeStoresRepositoryEntry(String name, DataStoreParameters parameters, Bitmask mask);
129

    
130
    public boolean canAnonymousUserWriteInTheTables();
131

    
132
    /**
133
     * Check if the indicated configuration table exists in the workspace.
134
     * 
135
     * @param tableid
136
     * @return true if the table exists.
137
     */
138
    public boolean existsTable(int tableid);
139

    
140
    /**
141
     * Create the configuration table indicated in the workspace.
142
     * 
143
     * @param tableid identifier of the configuration table to create.
144
     */
145
    public void createTable(int tableid);
146
    
147
    /**
148
     * Remove the indicated configuration table from the workspace.
149
     * 
150
     * @param tableid identifier of the configuration table to remove.
151
     */
152
    public void dropTable(int tableid);
153

    
154
    /**
155
     * Gets the data store associated with the indicated configuration table.
156
     * 
157
     * @param tableid identifier of the configuration table to get.
158
     * @return the FeatureStore of the configuration table.
159
     */
160
    public FeatureStore getTable(int tableid);
161

    
162
    /**
163
     * Returns true if the connection associated with this object refers 
164
     * to a valid workspace.
165
     * At least the variable "StoresRepository.id" must be defined.
166
     * 
167
     * @return 
168
     */
169
    public boolean isValid();
170

    
171
    /**
172
     * Returns true if the connection associated with this object refers 
173
     * to a valid workspace with a stores-repository.
174
     * At least the repositories table must exist and the variable 
175
     * "StoresRepository.id" must be defined.
176
     * 
177
     * @return 
178
     */
179
    public boolean isValidStoresRepository();
180
    
181
    /**
182
     * If the workspace has an alternate resource storage defined, return it. 
183
     * If don't have it, return null.
184
     * 
185
     * @param tableName
186
     * @return the alternate resource storage.
187
     */
188
    public ResourcesStorage getAlternativeResourcesStorage(String tableName);
189
    
190
    public boolean hasAlternativeResourcesStorage();
191

    
192
    public void setAlternativeResourcesStorage(String resourcesPath);
193
    
194
    /**
195
     * Create and initialize the tables associated with a gvSIG workspace.
196
     * 
197
     * @param id of the workspace
198
     * @param description of the workspace 
199
     */
200
    public void create(String id, String description);
201

    
202
    public void drop();
203
    
204
    public File getBaseFolder();
205
    
206
    public void setBaseFolder(File baseFolder);
207
    
208
    public ResourcesStorage getResourcesStorage();
209

    
210
    public void connect();
211
    
212
    public void disconnect();
213
    
214
    public void createTableRepository(String tableName);
215
    
216
    public void createTableResources(String tableName);
217
    
218
    public boolean isConnected();
219
    
220
    public String getLabelOrId();
221
}