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

History | View | Annotate | Download (6.48 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.LabeledValue;
9

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

    
31
    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
    
35
    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
    public static final String FIELD_REPOSITORY_FLAGS = "flags";
41

    
42
    public static final String FIELD_CONFIGURATION_NAME = "name";
43
    public static final String FIELD_CONFIGURATION_VALUE = "value";
44
    
45
    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
    /**
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
    public DataServerExplorer getServerExplorer();
83
    
84
    public DataServerExplorerParameters getServerExplorerParameters();
85
    
86
    /**
87
     * Returns the label of this workspace.
88
     * 
89
     * @return the label value.
90
     */
91
    @Override
92
    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
    public String get(String name);
102
    
103
    /**
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
    public boolean set(String name, String value);
111
    
112
    /**
113
     * Gets the repository of data stores associated with this workspace.
114
     * 
115
     * @return the data stores repository.
116
     */
117
    public StoresRepository getStoresRepository();
118
    
119
    /**
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

    
128
    public boolean canAnonymousUserWriteInTheTables();
129

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

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

    
152
    /**
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
     * 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
     * At least the repositories table must exist and the variable 
173
     * "StoresRepository.id" must be defined.
174
     * 
175
     * @return 
176
     */
177
    public boolean isValidStoresRepository();
178
    
179
    /**
180
     * If the workspace has an alternate resource storage defined, return it. 
181
     * If don't have it, return null.
182
     * 
183
     * @param tableName
184
     * @return the alternate resource storage.
185
     */
186
    public ResourcesStorage getAlternativeResourcesStorage(String tableName);
187
    
188
    public boolean hasAlternativeResourcesStorage();
189

    
190
    public void setAlternativeResourcesStorage(String resourcesPath);
191
    
192
    /**
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

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

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