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

History | View | Annotate | Download (5.54 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 static final String CONFIG_CAN_ANONYMOUS_USER_WRITE_IN_THE_TABLES = "CanAnonymousUserWriteInTheTables";
19

    
20
    public static final String TABLE_REPOSITORY_NAME = "gvsigd_repository";
21
    public static final String TABLE_RESOURCES_NAME = "gvsigd_resources";
22
    public static final String TABLE_CONFIGURATION_NAME = "gvsigd_config";
23
    
24
    public static final String FIELD_RESOURCES_NAME = "name";
25
    public static final String FIELD_RESOURCES_RESOURCE = "resource";
26

    
27
    public static final String FIELD_REPOSITORY_NAME = "name";
28
    public static final String FIELD_REPOSITORY_PARAMETERS = "parameters";
29

    
30
    public static final String FIELD_CONFIGURATION_NAME = "name";
31
    public static final String FIELD_CONFIGURATION_VALUE = "value";
32
    
33
    public static final int TABLE_RESOURCES = 0;
34
    public static final int TABLE_REPOSITORY = 1;
35
    public static final int TABLE_CONFIGURATION = 2;
36
    
37
    public static final String CONFIG_NAME_STORESREPOSITORYID = "StoresRepository.id";
38
    public static final String CONFIG_NAME_STORESREPOSITORYLABEL = "StoresRepository.label";
39

    
40
    /**
41
     * Check if the indicated name corresponds to one of the configuration tables of the workspace.
42
     * 
43
     * @param name to check.
44
     * @return true if the name is that of a configuration table.
45
     */
46
    public static boolean isInternalTable(String name) {
47
        if( StringUtils.isBlank(name) ) {
48
            return false;
49
        }
50
        String[] internalNames = new String[] {
51
            TABLE_REPOSITORY_NAME,
52
            TABLE_RESOURCES_NAME,
53
            TABLE_CONFIGURATION_NAME
54
        };
55
        for (String internalName : internalNames) {
56
            if( name.equalsIgnoreCase(internalName) ) {
57
                return true;
58
            }
59
        }
60
        return false;
61
    }
62

    
63
    /**
64
     * Returns the identifier of this workspace.
65
     * 
66
     * @return the id.
67
     */
68
    public String getId();
69

    
70
    /**
71
     * Returns the label of this workspace.
72
     * 
73
     * @return the label value.
74
     */
75
    public String getLabel();
76
    
77
    /**
78
     * Gets the value of a configuration variable associated with 
79
     * this work space.
80
     * 
81
     * @param name of the variable to consult 
82
     * @return the value of the variable 
83
     */
84
    public String get(String name);
85
    
86
    /**
87
     * Assigns the indicated value to the configuration variable.
88
     * 
89
     * @param name of the variable.
90
     * @param value value to set.
91
     * @return true if can assign the value.
92
     */
93
    public boolean set(String name, String value);
94
    
95
    /**
96
     * Gets the repository of data stores associated with this workspace.
97
     * 
98
     * @return the data stores repository.
99
     */
100
    public StoresRepository getStoresRepository();
101
    
102
    /**
103
     * Add a new data store to the workspace.
104
     * 
105
     * @param name of the data store.
106
     * @param parameters to open the data store.
107
     * @return true if ok.
108
     */
109
    public boolean writeStoresRepositoryEntry(String name, DataStoreParameters parameters);
110

    
111
    public boolean canAnonymousUserWriteInTheTables();
112

    
113
    /**
114
     * Check if the indicated configuration table exists in the workspace.
115
     * 
116
     * @param tableid
117
     * @return true if the table exists.
118
     */
119
    public boolean existsTable(int tableid);
120

    
121
    /**
122
     * Create the configuration table indicated in the workspace.
123
     * 
124
     * @param tableid identifier of the configuration table to create.
125
     */
126
    public void createTable(int tableid);
127
    
128
    /**
129
     * Remove the indicated configuration table from the workspace.
130
     * 
131
     * @param tableid identifier of the configuration table to remove.
132
     */
133
    public void dropTable(int tableid);
134

    
135
    /**
136
     * Gets the data store associated with the indicated configuration table.
137
     * 
138
     * @param tableid identifier of the configuration table to get.
139
     * @return the FeatureStore of the configuration table.
140
     */
141
    public FeatureStore getTable(int tableid);
142

    
143
    /**
144
     * Returns true if the connection associated with this object refers 
145
     * to a valid workspace.
146
     * At least the variable "StoresRepository.id" must be defined.
147
     * 
148
     * @return 
149
     */
150
    public boolean isValid();
151

    
152
    /**
153
     * Returns true if the connection associated with this object refers 
154
     * to a valid workspace with a stores-repository.
155
     * At least the repositories table must exist and the variable 
156
     * "StoresRepository.id" must be defined.
157
     * 
158
     * @return 
159
     */
160
    public boolean isValidStoresRepository();
161
    
162
    /**
163
     * If the workspace has an alternate resource storage defined, return it. 
164
     * If don't have it, return null.
165
     * 
166
     * @param tableName
167
     * @return the alternate resource storage.
168
     */
169
    public ResourcesStorage getAlternativeResourcesStorage(String tableName);
170
    
171
    /**
172
     * Create and initialize the tables associated with a gvSIG workspace.
173
     * 
174
     * @param id of the workspace
175
     * @param description of the workspace 
176
     */
177
    public void create(String id, String description);
178

    
179
    public void drop();
180
    
181
    public File getBaseFolder();
182
    
183
    public void setBaseFolder(File baseFolder);
184
        
185
}