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

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

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

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

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

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

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

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

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

    
106
    public boolean canAnonymousUserWriteInTheTables();
107

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

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

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

    
138
    /**
139
     * Returns true if the connection associated with this object refers 
140
     * to a valid workspace.
141
     * At least the repositories table must exist and the variable 
142
     * "StoresRepository.id" must be defined.
143
     * 
144
     * @return 
145
     */
146
    public boolean isValidStoresRepository();
147
    
148
    /**
149
     * If the workspace has an alternate resource storage defined, return it. 
150
     * If don't have it, return null.
151
     * 
152
     * @return the alternate resource storage.
153
     */
154
    public ResourcesStorage getAlternativeResourcesStorage();
155
    
156
    /**
157
     * Create and initialize the tables associated with a gvSIG workspace.
158
     * 
159
     * @param id of the workspace
160
     * @param description of the workspace 
161
     */
162
    public void create(String id, String description);
163

    
164
}