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 @ 40608
History | View | Annotate | Download (8.39 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
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 2
|
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 |
*/
|
22 |
|
23 |
/*
|
24 |
* AUTHORS (In addition to CIT):
|
25 |
* 2008 Geographic Information research group: http://www.geoinfo.uji.es
|
26 |
* Departamento de Lenguajes y Sistemas Inform?ticos (LSI)
|
27 |
* Universitat Jaume I
|
28 |
*/
|
29 |
|
30 |
package org.gvsig.metadata; |
31 |
|
32 |
import java.io.File; |
33 |
import java.io.InputStream; |
34 |
import java.util.Iterator; |
35 |
|
36 |
import org.gvsig.metadata.exceptions.InvalidMetadataNamespaceException; |
37 |
import org.gvsig.metadata.exceptions.MetadataException; |
38 |
import org.gvsig.tools.dynobject.DynClass; |
39 |
import org.gvsig.tools.dynobject.DynStruct; |
40 |
|
41 |
/**
|
42 |
* Manages the load and storage of Metadata objects.
|
43 |
*
|
44 |
* @author gvSIG Team
|
45 |
* @author <a href="mailto:cordin@disid.com">C?sar Ordi?ana</a>
|
46 |
* @author <a href="mailto:reinhold@uji.es">cmartin</a>
|
47 |
*
|
48 |
* @version $Id$
|
49 |
*
|
50 |
*/
|
51 |
public interface MetadataManager { |
52 |
|
53 |
public final static String METADATA_NAMESPACE = "metadata"; |
54 |
|
55 |
/**
|
56 |
* Adds a new definition in the metadata manager.
|
57 |
*
|
58 |
* The new definition is defined in the namespace by default for DynClasses
|
59 |
* used for metadata.
|
60 |
*
|
61 |
* @param name
|
62 |
* the definition Name
|
63 |
* @param description
|
64 |
* the definition Description
|
65 |
* @return the created DynStruct definition
|
66 |
*
|
67 |
* @throws MetadataException
|
68 |
*/
|
69 |
public DynStruct addDefinition(String name, String description) |
70 |
throws MetadataException;
|
71 |
|
72 |
/**
|
73 |
* Adds a new definition in the metadata manager.
|
74 |
*
|
75 |
* The new definition is defined in the namespace by default for DynClasses
|
76 |
* used for metadata.
|
77 |
*
|
78 |
* @param dynClass
|
79 |
* the new definition
|
80 |
*
|
81 |
* @return the DynStruct definition
|
82 |
*
|
83 |
* @throws MetadataException
|
84 |
*/
|
85 |
public void addDefinition(DynClass definition) throws MetadataException; |
86 |
|
87 |
/**
|
88 |
* Adds a new definition in the metadata manager.
|
89 |
*
|
90 |
* The new definition is defined in the namespace by default for DynClasses
|
91 |
* used for metadata.
|
92 |
*
|
93 |
* @param name
|
94 |
* the definition Name
|
95 |
* @param stream
|
96 |
* the input stream to be parsed.
|
97 |
* @param loader
|
98 |
* the Class loader that can parse this input stream
|
99 |
* @return the created DynStruct definition
|
100 |
*
|
101 |
* @throws MetadataException
|
102 |
*/
|
103 |
public DynStruct addDefinition(String name, InputStream stream, |
104 |
ClassLoader loader) throws MetadataException; |
105 |
|
106 |
/**
|
107 |
* <p>
|
108 |
* If a Metadata definition ( {@link DynStruct} ) with the given definition
|
109 |
* name has been previously registered in this manager, then this method
|
110 |
* returns that definition. Otherwise, it returns null.
|
111 |
* </p>
|
112 |
*
|
113 |
* @param definitionName
|
114 |
* the name whose corresponding attribute definition is to be
|
115 |
* retrieved.
|
116 |
*
|
117 |
* @return The attribute definition corresponding to the provided metadata
|
118 |
* class, or null otherwise.
|
119 |
*/
|
120 |
public DynStruct getDefinition(String definitionName); |
121 |
|
122 |
/**
|
123 |
* <p>
|
124 |
* Retrieves all the current definitions in the form of an Iterator
|
125 |
* interface.
|
126 |
* </p>
|
127 |
*
|
128 |
* @return The Metadata iterator containing the current metadata definitions
|
129 |
*/
|
130 |
public Iterator getDefinitions(); |
131 |
|
132 |
/**
|
133 |
* <p>
|
134 |
* If a Metadata definition ( {@link DynStruct} ) with a given metadata that
|
135 |
* has been previously registered in this manager, then this method returns
|
136 |
* that definition. Otherwise, it returns null.
|
137 |
* </p>
|
138 |
*
|
139 |
* @param metadata
|
140 |
* the given metadata.
|
141 |
*
|
142 |
* @return The attribute definition corresponding to the provided metadata
|
143 |
* class, or null otherwise.
|
144 |
*/
|
145 |
public DynStruct getDefinition(Metadata metadata) throws MetadataException; |
146 |
|
147 |
/**
|
148 |
*
|
149 |
* If the current dynStruct has been previously registered, it is removed
|
150 |
* from both the dynObjectManager and the metadataManager lists. Otherwise,
|
151 |
* does nothing.
|
152 |
*
|
153 |
* @param dynStruct
|
154 |
* the dynStruct to be removed.
|
155 |
*/
|
156 |
public void removeDefinition(DynStruct dynStruct); |
157 |
|
158 |
/**
|
159 |
* Creates a default {@link Metadata} instance based on a given
|
160 |
* {@link DynStruct}, if it has not been previously registered, and adds
|
161 |
* this Metadata to the system.
|
162 |
*
|
163 |
* @param dynStruct
|
164 |
* the given dynStruct object.
|
165 |
* @return the resultant Metadata object.
|
166 |
* @throws InvalidMetadataNamespaceException
|
167 |
*/
|
168 |
public Metadata getMetadata(DynStruct dynStruct)
|
169 |
throws InvalidMetadataNamespaceException;
|
170 |
|
171 |
/**
|
172 |
* This function populates the given Metadata object with the current values
|
173 |
* that the system contains. If there is any invalid access to an undeclared
|
174 |
* field, for example, a MetadataException will be thrown.
|
175 |
*
|
176 |
* @param metadata
|
177 |
* the metadata that needs to be populated.
|
178 |
*
|
179 |
* @throws MetadataException
|
180 |
* Exception caused by any access violation.
|
181 |
*/
|
182 |
public void loadMetadata(Metadata metadata) throws MetadataException; |
183 |
|
184 |
/**
|
185 |
* This function stores the given Metadata object to an output resource, be
|
186 |
* it a database or a file containing its information.
|
187 |
*
|
188 |
* @param metadata
|
189 |
* the metadata that needs to be stored.
|
190 |
*
|
191 |
* @throws MetadataException
|
192 |
* Exception caused by any access violation.
|
193 |
*/
|
194 |
public void storeMetadata(Metadata metadata) throws MetadataException; |
195 |
|
196 |
/**
|
197 |
* This is a utility interface to implement classes that implement the
|
198 |
* interface Metadata.
|
199 |
*
|
200 |
* Use the createMetadataContainer in the MetadataManager to create a
|
201 |
* container for delegate the implementation of Metadata methods in it.
|
202 |
*
|
203 |
* @param name
|
204 |
* the DynStruct name.
|
205 |
*
|
206 |
* @return the metadata container.
|
207 |
*/
|
208 |
public MetadataContainer createMetadataContainer(String name); |
209 |
|
210 |
/**
|
211 |
* Returns the main Metadata extension root repository.
|
212 |
*
|
213 |
* @return the File object containing the home repository folder
|
214 |
*
|
215 |
*/
|
216 |
public File getMetadataHomeRepository(); |
217 |
|
218 |
/**
|
219 |
* Sets the main Metadata root repository for this manager.
|
220 |
*
|
221 |
* @param metadataHomeRepository
|
222 |
* the main Repository folder.
|
223 |
*/
|
224 |
public void setMetadataHomeRepository(File metadataHomeRepository); |
225 |
|
226 |
/**
|
227 |
* Retrieves a metadata object based on its metadata ID. This metadata
|
228 |
* object is basically a dynObject if metadata namespace set to "metadata".
|
229 |
*
|
230 |
* @param metadataID
|
231 |
* the metadata ID of the metadata object.
|
232 |
* @return
|
233 |
* @throws InvalidMetadataNamespaceException
|
234 |
* if the metadataID was not previously registered as Metadata.
|
235 |
*/
|
236 |
public Metadata getMetadata(String metadataID) |
237 |
throws InvalidMetadataNamespaceException;
|
238 |
|
239 |
/**
|
240 |
* Added options properties setter for validating before the saving
|
241 |
* function. If it is set to false, the validation will not be performed.
|
242 |
* @param doValidation
|
243 |
* if the validation must be performed or not before saving metadata objects.
|
244 |
*/
|
245 |
public void setValidationBeforeSaving(boolean doValidation); |
246 |
|
247 |
/**
|
248 |
* Added options properties getter for validating before the saving
|
249 |
* function. If it is set to false, the validation will not be performed.
|
250 |
* @return
|
251 |
* if the validation must be performed or not before saving metadata objects.
|
252 |
*/
|
253 |
public boolean getValidationBeforeSaving(); |
254 |
|
255 |
/**
|
256 |
* Added options properties setter for validating before the exporting
|
257 |
* function. If it is set to false, the validation will not be performed.
|
258 |
* @param doValidation
|
259 |
* if the validation must be performed or not before saving metadata objects.
|
260 |
*/
|
261 |
public void setValidationBeforeExporting(boolean doValidation); |
262 |
|
263 |
/**
|
264 |
* Added options properties getter for validating before the exporting
|
265 |
* function. If it is set to false, the validation will not be performed.
|
266 |
* @return
|
267 |
* if the validation must be performed or not before saving metadata objects.
|
268 |
*/
|
269 |
public boolean getValidationBeforeExporting(); |
270 |
} |