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 44304 jjdelcerro
package org.gvsig.fmap.dal;
2 44297 jjdelcerro
3 44346 jjdelcerro
import org.apache.commons.lang3.StringUtils;
4 44297 jjdelcerro
import org.gvsig.fmap.dal.feature.FeatureStore;
5 44346 jjdelcerro
import org.gvsig.tools.resourcesstorage.ResourcesStorage;
6 44390 jjdelcerro
import org.gvsig.tools.util.LabeledValue;
7 44297 jjdelcerro
8
/**
9
 *
10
 * @author jjdelcerro
11
 */
12 44390 jjdelcerro
public interface DatabaseWorkspaceManager extends LabeledValue<DatabaseWorkspaceManager>{
13 44297 jjdelcerro
14
    public static final String CONFIG_CAN_ANONYMOUS_USER_WRITE_IN_THE_TABLES = "CanAnonymousUserWriteInTheTables";
15 44304 jjdelcerro
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 44297 jjdelcerro
20 44304 jjdelcerro
    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 44297 jjdelcerro
29 44304 jjdelcerro
    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 44346 jjdelcerro
    /**
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 44297 jjdelcerro
    public String get(String name);
81
82 44346 jjdelcerro
    /**
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 44326 jjdelcerro
    public boolean set(String name, String value);
90 44297 jjdelcerro
91 44346 jjdelcerro
    /**
92
     * Gets the repository of data stores associated with this workspace.
93
     *
94
     * @return the data stores repository.
95
     */
96 44297 jjdelcerro
    public StoresRepository getStoresRepository();
97 44304 jjdelcerro
98 44346 jjdelcerro
    /**
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 44297 jjdelcerro
107
    public boolean canAnonymousUserWriteInTheTables();
108
109 44346 jjdelcerro
    /**
110
     * Check if the indicated configuration table exists in the workspace.
111
     *
112
     * @param tableid
113
     * @return true if the table exists.
114
     */
115 44304 jjdelcerro
    public boolean existsTable(int tableid);
116
117 44346 jjdelcerro
    /**
118
     * Create the configuration table indicated in the workspace.
119
     *
120
     * @param tableid identifier of the configuration table to create.
121
     */
122 44304 jjdelcerro
    public void createTable(int tableid);
123 44297 jjdelcerro
124 44346 jjdelcerro
    /**
125
     * Remove the indicated configuration table from the workspace.
126
     *
127
     * @param tableid identifier of the configuration table to remove.
128
     */
129 44304 jjdelcerro
    public void dropTable(int tableid);
130 44297 jjdelcerro
131 44346 jjdelcerro
    /**
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 44380 jjdelcerro
     * 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 44346 jjdelcerro
     * At least the repositories table must exist and the variable
152
     * "StoresRepository.id" must be defined.
153
     *
154
     * @return
155
     */
156 44304 jjdelcerro
    public boolean isValidStoresRepository();
157 44346 jjdelcerro
158
    /**
159
     * If the workspace has an alternate resource storage defined, return it.
160
     * If don't have it, return null.
161
     *
162 44380 jjdelcerro
     * @param tableName
163 44346 jjdelcerro
     * @return the alternate resource storage.
164
     */
165 44380 jjdelcerro
    public ResourcesStorage getAlternativeResourcesStorage(String tableName);
166 44346 jjdelcerro
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 44304 jjdelcerro
175 44362 jjdelcerro
    public void drop();
176 44297 jjdelcerro
}