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

History | View | Annotate | Download (6.2 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
    /**
85
     * Returns the label of this workspace.
86
     * 
87
     * @return the label value.
88
     */
89
    @Override
90
    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
    public String get(String name);
100
    
101
    /**
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
    public boolean set(String name, String value);
109
    
110
    /**
111
     * Gets the repository of data stores associated with this workspace.
112
     * 
113
     * @return the data stores repository.
114
     */
115
    public StoresRepository getStoresRepository();
116
    
117
    /**
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

    
126
    public boolean canAnonymousUserWriteInTheTables();
127

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

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

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

    
194
    public void drop();
195
    
196
    public File getBaseFolder();
197
    
198
    public void setBaseFolder(File baseFolder);
199
    
200
    public ResourcesStorage getResourcesStorage();
201

    
202
    public void connect();
203
    
204
    public void disconnect();
205
    
206
    public void createTableRepository(String tableName);
207
    
208
    public void createTableResources(String tableName);
209
}