svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.metadata.basic / org.gvsig.metadata.basic.lib / org.gvsig.metadata.lib.basic.api / src / main / java / org / gvsig / metadata / MetadataManager.java @ 40769
History | View | Annotate | Download (8.24 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.metadata; |
25 |
|
26 |
import java.io.File; |
27 |
import java.io.InputStream; |
28 |
import java.util.Iterator; |
29 |
|
30 |
import org.gvsig.metadata.exceptions.InvalidMetadataNamespaceException; |
31 |
import org.gvsig.metadata.exceptions.MetadataException; |
32 |
import org.gvsig.tools.dynobject.DynClass; |
33 |
import org.gvsig.tools.dynobject.DynStruct; |
34 |
|
35 |
/**
|
36 |
* Manages the load and storage of Metadata objects.
|
37 |
*
|
38 |
* @author gvSIG Team
|
39 |
* @author <a href="mailto:cordin@disid.com">C?sar Ordi?ana</a>
|
40 |
* @author <a href="mailto:reinhold@uji.es">cmartin</a>
|
41 |
*
|
42 |
* @version $Id$
|
43 |
*
|
44 |
*/
|
45 |
public interface MetadataManager { |
46 |
|
47 |
public final static String METADATA_NAMESPACE = "metadata"; |
48 |
|
49 |
/**
|
50 |
* Adds a new definition in the metadata manager.
|
51 |
*
|
52 |
* The new definition is defined in the namespace by default for DynClasses
|
53 |
* used for metadata.
|
54 |
*
|
55 |
* @param name
|
56 |
* the definition Name
|
57 |
* @param description
|
58 |
* the definition Description
|
59 |
* @return the created DynStruct definition
|
60 |
*
|
61 |
* @throws MetadataException
|
62 |
*/
|
63 |
public DynStruct addDefinition(String name, String description) |
64 |
throws MetadataException;
|
65 |
|
66 |
/**
|
67 |
* Adds a new definition in the metadata manager.
|
68 |
*
|
69 |
* The new definition is defined in the namespace by default for DynClasses
|
70 |
* used for metadata.
|
71 |
*
|
72 |
* @param dynClass
|
73 |
* the new definition
|
74 |
*
|
75 |
* @return the DynStruct definition
|
76 |
*
|
77 |
* @throws MetadataException
|
78 |
*/
|
79 |
public void addDefinition(DynClass definition) throws MetadataException; |
80 |
|
81 |
/**
|
82 |
* Adds a new definition in the metadata manager.
|
83 |
*
|
84 |
* The new definition is defined in the namespace by default for DynClasses
|
85 |
* used for metadata.
|
86 |
*
|
87 |
* @param name
|
88 |
* the definition Name
|
89 |
* @param stream
|
90 |
* the input stream to be parsed.
|
91 |
* @param loader
|
92 |
* the Class loader that can parse this input stream
|
93 |
* @return the created DynStruct definition
|
94 |
*
|
95 |
* @throws MetadataException
|
96 |
*/
|
97 |
public DynStruct addDefinition(String name, InputStream stream, |
98 |
ClassLoader loader) throws MetadataException; |
99 |
|
100 |
/**
|
101 |
* <p>
|
102 |
* If a Metadata definition ( {@link DynStruct} ) with the given definition
|
103 |
* name has been previously registered in this manager, then this method
|
104 |
* returns that definition. Otherwise, it returns null.
|
105 |
* </p>
|
106 |
*
|
107 |
* @param definitionName
|
108 |
* the name whose corresponding attribute definition is to be
|
109 |
* retrieved.
|
110 |
*
|
111 |
* @return The attribute definition corresponding to the provided metadata
|
112 |
* class, or null otherwise.
|
113 |
*/
|
114 |
public DynStruct getDefinition(String definitionName); |
115 |
|
116 |
/**
|
117 |
* <p>
|
118 |
* Retrieves all the current definitions in the form of an Iterator
|
119 |
* interface.
|
120 |
* </p>
|
121 |
*
|
122 |
* @return The Metadata iterator containing the current metadata definitions
|
123 |
*/
|
124 |
public Iterator getDefinitions(); |
125 |
|
126 |
/**
|
127 |
* <p>
|
128 |
* If a Metadata definition ( {@link DynStruct} ) with a given metadata that
|
129 |
* has been previously registered in this manager, then this method returns
|
130 |
* that definition. Otherwise, it returns null.
|
131 |
* </p>
|
132 |
*
|
133 |
* @param metadata
|
134 |
* the given metadata.
|
135 |
*
|
136 |
* @return The attribute definition corresponding to the provided metadata
|
137 |
* class, or null otherwise.
|
138 |
*/
|
139 |
public DynStruct getDefinition(Metadata metadata) throws MetadataException; |
140 |
|
141 |
/**
|
142 |
*
|
143 |
* If the current dynStruct has been previously registered, it is removed
|
144 |
* from both the dynObjectManager and the metadataManager lists. Otherwise,
|
145 |
* does nothing.
|
146 |
*
|
147 |
* @param dynStruct
|
148 |
* the dynStruct to be removed.
|
149 |
*/
|
150 |
public void removeDefinition(DynStruct dynStruct); |
151 |
|
152 |
/**
|
153 |
* Creates a default {@link Metadata} instance based on a given
|
154 |
* {@link DynStruct}, if it has not been previously registered, and adds
|
155 |
* this Metadata to the system.
|
156 |
*
|
157 |
* @param dynStruct
|
158 |
* the given dynStruct object.
|
159 |
* @return the resultant Metadata object.
|
160 |
* @throws InvalidMetadataNamespaceException
|
161 |
*/
|
162 |
public Metadata getMetadata(DynStruct dynStruct)
|
163 |
throws InvalidMetadataNamespaceException;
|
164 |
|
165 |
/**
|
166 |
* This function populates the given Metadata object with the current values
|
167 |
* that the system contains. If there is any invalid access to an undeclared
|
168 |
* field, for example, a MetadataException will be thrown.
|
169 |
*
|
170 |
* @param metadata
|
171 |
* the metadata that needs to be populated.
|
172 |
*
|
173 |
* @throws MetadataException
|
174 |
* Exception caused by any access violation.
|
175 |
*/
|
176 |
public void loadMetadata(Metadata metadata) throws MetadataException; |
177 |
|
178 |
/**
|
179 |
* This function stores the given Metadata object to an output resource, be
|
180 |
* it a database or a file containing its information.
|
181 |
*
|
182 |
* @param metadata
|
183 |
* the metadata that needs to be stored.
|
184 |
*
|
185 |
* @throws MetadataException
|
186 |
* Exception caused by any access violation.
|
187 |
*/
|
188 |
public void storeMetadata(Metadata metadata) throws MetadataException; |
189 |
|
190 |
/**
|
191 |
* This is a utility interface to implement classes that implement the
|
192 |
* interface Metadata.
|
193 |
*
|
194 |
* Use the createMetadataContainer in the MetadataManager to create a
|
195 |
* container for delegate the implementation of Metadata methods in it.
|
196 |
*
|
197 |
* @param name
|
198 |
* the DynStruct name.
|
199 |
*
|
200 |
* @return the metadata container.
|
201 |
*/
|
202 |
public MetadataContainer createMetadataContainer(String name); |
203 |
|
204 |
/**
|
205 |
* Returns the main Metadata extension root repository.
|
206 |
*
|
207 |
* @return the File object containing the home repository folder
|
208 |
*
|
209 |
*/
|
210 |
public File getMetadataHomeRepository(); |
211 |
|
212 |
/**
|
213 |
* Sets the main Metadata root repository for this manager.
|
214 |
*
|
215 |
* @param metadataHomeRepository
|
216 |
* the main Repository folder.
|
217 |
*/
|
218 |
public void setMetadataHomeRepository(File metadataHomeRepository); |
219 |
|
220 |
/**
|
221 |
* Retrieves a metadata object based on its metadata ID. This metadata
|
222 |
* object is basically a dynObject if metadata namespace set to "metadata".
|
223 |
*
|
224 |
* @param metadataID
|
225 |
* the metadata ID of the metadata object.
|
226 |
* @return
|
227 |
* @throws InvalidMetadataNamespaceException
|
228 |
* if the metadataID was not previously registered as Metadata.
|
229 |
*/
|
230 |
public Metadata getMetadata(String metadataID) |
231 |
throws InvalidMetadataNamespaceException;
|
232 |
|
233 |
/**
|
234 |
* Added options properties setter for validating before the saving
|
235 |
* function. If it is set to false, the validation will not be performed.
|
236 |
* @param doValidation
|
237 |
* if the validation must be performed or not before saving metadata objects.
|
238 |
*/
|
239 |
public void setValidationBeforeSaving(boolean doValidation); |
240 |
|
241 |
/**
|
242 |
* Added options properties getter for validating before the saving
|
243 |
* function. If it is set to false, the validation will not be performed.
|
244 |
* @return
|
245 |
* if the validation must be performed or not before saving metadata objects.
|
246 |
*/
|
247 |
public boolean getValidationBeforeSaving(); |
248 |
|
249 |
/**
|
250 |
* Added options properties setter for validating before the exporting
|
251 |
* function. If it is set to false, the validation will not be performed.
|
252 |
* @param doValidation
|
253 |
* if the validation must be performed or not before saving metadata objects.
|
254 |
*/
|
255 |
public void setValidationBeforeExporting(boolean doValidation); |
256 |
|
257 |
/**
|
258 |
* Added options properties getter for validating before the exporting
|
259 |
* function. If it is set to false, the validation will not be performed.
|
260 |
* @return
|
261 |
* if the validation must be performed or not before saving metadata objects.
|
262 |
*/
|
263 |
public boolean getValidationBeforeExporting(); |
264 |
} |