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

History | View | Annotate | Download (6.02 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

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

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

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

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

    
125
    public boolean canAnonymousUserWriteInTheTables();
126

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

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

    
149
    /**
150
     * Gets the data store associated with the indicated configuration table.
151
     * 
152
     * @param tableid identifier of the configuration table to get.
153
     * @return the FeatureStore of the configuration table.
154
     */
155
    public FeatureStore getTable(int tableid);
156

    
157
    /**
158
     * Returns true if the connection associated with this object refers 
159
     * to a valid workspace.
160
     * At least the variable "StoresRepository.id" must be defined.
161
     * 
162
     * @return 
163
     */
164
    public boolean isValid();
165

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

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

    
201
    public void connect();
202
    
203
    public void disconnect();
204
}