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

History | View | Annotate | Download (5.35 KB)

1
package org.gvsig.fmap.dal;
2

    
3
import org.apache.commons.lang3.StringUtils;
4
import org.gvsig.fmap.dal.feature.FeatureStore;
5
import org.gvsig.tools.resourcesstorage.ResourcesStorage;
6
import org.gvsig.tools.util.LabeledValue;
7

    
8
/**
9
 *
10
 * @author jjdelcerro
11
 */
12
public interface DatabaseWorkspaceManager extends LabeledValue<DatabaseWorkspaceManager>{
13
    
14
    public static final String CONFIG_CAN_ANONYMOUS_USER_WRITE_IN_THE_TABLES = "CanAnonymousUserWriteInTheTables";
15

    
16
    public static final String TABLE_REPOSITORY_NAME = "gvsigd_repository";
17
    public static final String TABLE_RESOURCES_NAME = "gvsigd_resources";
18
    public static final String TABLE_CONFIGURATION_NAME = "gvsigd_config";
19
    
20
    public static final String FIELD_RESOURCES_NAME = "name";
21
    public static final String FIELD_RESOURCES_RESOURCE = "resource";
22

    
23
    public static final String FIELD_REPOSITORY_NAME = "name";
24
    public static final String FIELD_REPOSITORY_PARAMETERS = "parameters";
25

    
26
    public static final String FIELD_CONFIGURATION_NAME = "name";
27
    public static final String FIELD_CONFIGURATION_VALUE = "value";
28
    
29
    public static final int TABLE_RESOURCES = 0;
30
    public static final int TABLE_REPOSITORY = 1;
31
    public static final int TABLE_CONFIGURATION = 2;
32
    
33
    public static final String CONFIG_NAME_STORESREPOSITORYID = "StoresRepository.id";
34
    public static final String CONFIG_NAME_STORESREPOSITORYLABEL = "StoresRepository.label";
35

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

    
59
    /**
60
     * Returns the identifier of this workspace.
61
     * 
62
     * @return the id.
63
     */
64
    public String getId();
65

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

    
107
    public boolean canAnonymousUserWriteInTheTables();
108

    
109
    /**
110
     * Check if the indicated configuration table exists in the workspace.
111
     * 
112
     * @param tableid
113
     * @return true if the table exists.
114
     */
115
    public boolean existsTable(int tableid);
116

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

    
131
    /**
132
     * Gets the data store associated with the indicated configuration table.
133
     * 
134
     * @param tableid identifier of the configuration table to get.
135
     * @return the FeatureStore of the configuration table.
136
     */
137
    public FeatureStore getTable(int tableid);
138

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

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

    
175
    public void drop();
176
}