Revision 41947

View differences:

tags/org.gvsig.desktop-2.0.76/org.gvsig.desktop.compat.cdc/org.gvsig.metadata.basic/org.gvsig.metadata.basic.lib/org.gvsig.metadata.lib.basic.impl/src/test/resources/README.txt
1
#set( $symbol_pound = '#' )
2
#set( $symbol_dollar = '$' )
3
#set( $symbol_escape = '\' )
4
Put into this folder the resources needed by your test classes.
5

  
6
This folder is added to the Tests classpath, so you can load any resources 
7
through the ClassLoader.
8

  
9
By default, in this folder you can find an example of log4j configuration,
10
prepared to log messages through the console, so logging works when you
11
run your tests classes.
0 12

  
tags/org.gvsig.desktop-2.0.76/org.gvsig.desktop.compat.cdc/org.gvsig.metadata.basic/org.gvsig.metadata.basic.lib/org.gvsig.metadata.lib.basic.impl/src/test/resources/log4j.xml
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
3

  
4
<!-- 
5
Log4J configuration file for unit tests execution.
6
 -->
7
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
8

  
9
	<!-- Appender configuration to show logging messages through the console -->
10
	<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
11
		<layout class="org.apache.log4j.PatternLayout">
12
			<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n  %m%n" />
13
		</layout>
14
	</appender>
15

  
16
	<!-- 
17
	Activate logging messages of DEBUG level of higher only for the
18
	DefaultExampleManager class.
19
	You can put full classes names or packages instead, to configure
20
	logging for all the classes and subpackages of the package.
21
	-->
22
	<category name="org.gvsig.metadata.basic.impl.DefaultExampleManager">
23
		<priority value="DEBUG" />
24
	</category>
25

  
26
	<!-- 
27
	By default, show only logging messages of INFO level or higher, 
28
	through the previously configured CONSOLE appender. 
29
	-->
30
	<root>
31
		<priority value="INFO" />
32
		<appender-ref ref="CONSOLE" />
33
	</root>
34
</log4j:configuration>
0 35

  
tags/org.gvsig.desktop-2.0.76/org.gvsig.desktop.compat.cdc/org.gvsig.metadata.basic/org.gvsig.metadata.basic.lib/org.gvsig.metadata.lib.basic.impl/src/test/java/README.txt
1
#set( $symbol_pound = '#' )
2
#set( $symbol_dollar = '$' )
3
#set( $symbol_escape = '\' )
4
For each class you are going to test, create one Test class with the same
5
name as the class to test, ending with Test.
6

  
7
For example, the unit tests of the "ExampleLibrary" class are performed
8
by the "ExampleLibraryTest" class.
0 9

  
tags/org.gvsig.desktop-2.0.76/org.gvsig.desktop.compat.cdc/org.gvsig.metadata.basic/org.gvsig.metadata.basic.lib/org.gvsig.metadata.lib.basic.impl/src/main/resources/org/gvsig/metadata/lib/basic/impl/i18n/text.properties
1
# Resource bundle texts for the Spanish language locale (es)
2
Example.returns_value=devuelve el valor
0 3

  
tags/org.gvsig.desktop-2.0.76/org.gvsig.desktop.compat.cdc/org.gvsig.metadata.basic/org.gvsig.metadata.basic.lib/org.gvsig.metadata.lib.basic.impl/src/main/resources/org/gvsig/metadata/lib/basic/impl/i18n/text_en.properties
1
# Resource bundle texts for the English language locale (en)
2
Example.returns_value=returns value
0 3

  
tags/org.gvsig.desktop-2.0.76/org.gvsig.desktop.compat.cdc/org.gvsig.metadata.basic/org.gvsig.metadata.basic.lib/org.gvsig.metadata.lib.basic.impl/src/main/resources/README.txt
1
Put into this folder the resources needed by your library classes.
2

  
3
This folder is added to the runtime classpath, so you can load any resources 
4
through the ClassLoader.
5

  
6
By default, into this folder you can find some examples of resource bundle 
7
property files that may be used by your library classes.
0 8

  
tags/org.gvsig.desktop-2.0.76/org.gvsig.desktop.compat.cdc/org.gvsig.metadata.basic/org.gvsig.metadata.basic.lib/org.gvsig.metadata.lib.basic.impl/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.metadata.lib.basic.impl.BasicMetadataLibrary
tags/org.gvsig.desktop-2.0.76/org.gvsig.desktop.compat.cdc/org.gvsig.metadata.basic/org.gvsig.metadata.basic.lib/org.gvsig.metadata.lib.basic.impl/src/main/java/org/gvsig/metadata/lib/basic/impl/AbstractMetadata.java
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.lib.basic.impl;
25

  
26
import java.util.HashSet;
27
import java.util.Set;
28

  
29
import org.gvsig.metadata.Metadata;
30
import org.gvsig.metadata.exceptions.MetadataException;
31
import org.gvsig.tools.dynobject.DynStruct;
32
import org.gvsig.tools.dynobject.impl.DefaultDynObject;
33

  
34
/**
35
 * Abstract metadata used in both metadata basic and full modules.
36
 */
37
public abstract class AbstractMetadata extends DefaultDynObject implements
38
		Metadata, Comparable {
39

  
40
	public AbstractMetadata(DynStruct dynClass) {
41
		super(dynClass);
42
	}
43

  
44
	public Set getMetadataChildren() throws MetadataException {
45
		Set children = new HashSet();
46
		DynStruct[] items = this.getDynClass().getSuperDynStructs();
47
		if (items == null)
48
			return children;
49

  
50
		Object item;
51
		for (int i = 0; i < items.length; i++) {
52
			item = items[i];
53
			if (item instanceof Metadata) {
54
				children.add(item);
55
			}
56
		}
57
		return children;
58
	}
59

  
60
	public Object getMetadataID() throws MetadataException {
61
		return this.getDynClass().getFullName();
62
	}
63

  
64
	public String getMetadataName() throws MetadataException {
65
		return this.getDynClass().getName();
66
	}
67

  
68

  
69
	public int compareTo(Object object) {
70
		if (object == null) {
71
			return 0;
72
		}
73
		if (object instanceof Metadata) {
74
			return this
75
					.getDynClass()
76
					.getFullName()
77
					.toLowerCase()
78
					.compareTo(
79
							((Metadata) object).getDynClass().getFullName()
80
									.toLowerCase());
81
		}
82
		if (object instanceof DynStruct) {
83
			return this
84
					.getDynClass()
85
					.getFullName()
86
					.toLowerCase()
87
					.compareTo(((DynStruct) object).getFullName().toLowerCase());
88
		}
89
		return 0;
90
	}
91

  
92
	public String toString() {
93
		String name = this.getDynClass().getName();
94
		return name.substring(0, 1).toUpperCase() + name.substring(1);
95
	}
96

  
97
	public String toDynObjectString() {
98
		return super.toString();
99
	}
100
}
0 101

  
tags/org.gvsig.desktop-2.0.76/org.gvsig.desktop.compat.cdc/org.gvsig.metadata.basic/org.gvsig.metadata.basic.lib/org.gvsig.metadata.lib.basic.impl/src/main/java/org/gvsig/metadata/lib/basic/impl/BasicMetadataContainer.java
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.lib.basic.impl;
25

  
26
import org.gvsig.metadata.MetadataContainer;
27
import org.gvsig.tools.dynobject.DynStruct;
28
import org.gvsig.tools.dynobject.impl.DefaultDynObject;
29

  
30
public class BasicMetadataContainer extends DefaultDynObject implements MetadataContainer {
31

  
32
	public BasicMetadataContainer(DynStruct dynClass) {
33
		super(dynClass);
34
	}
35

  
36
}
0 37

  
tags/org.gvsig.desktop-2.0.76/org.gvsig.desktop.compat.cdc/org.gvsig.metadata.basic/org.gvsig.metadata.basic.lib/org.gvsig.metadata.lib.basic.impl/src/main/java/org/gvsig/metadata/lib/basic/impl/DefaultMetadata.java
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.lib.basic.impl;
25

  
26
import org.gvsig.metadata.Metadata;
27
import org.gvsig.tools.dynobject.DynStruct;
28

  
29
/**
30
 * Default metadata implementation of the basic implementation module.
31
 */
32
public class DefaultMetadata extends AbstractMetadata implements Metadata {
33

  
34
	public DefaultMetadata(DynStruct dynClass) {
35
		super(dynClass);
36
	}
37

  
38
}
0 39

  
tags/org.gvsig.desktop-2.0.76/org.gvsig.desktop.compat.cdc/org.gvsig.metadata.basic/org.gvsig.metadata.basic.lib/org.gvsig.metadata.lib.basic.impl/src/main/java/org/gvsig/metadata/lib/basic/impl/BasicMetadataLibrary.java
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.lib.basic.impl;
25

  
26
import java.util.Locale;
27

  
28
import org.gvsig.metadata.MetadataLibrary;
29
import org.gvsig.metadata.MetadataLocator;
30
import org.gvsig.metadata.MetadataManager;
31
import org.gvsig.tools.ToolsLibrary;
32
import org.gvsig.tools.ToolsLocator;
33
import org.gvsig.tools.i18n.I18nManager;
34
import org.gvsig.tools.library.AbstractLibrary;
35
import org.gvsig.tools.library.LibraryException;
36

  
37
public class BasicMetadataLibrary extends AbstractLibrary {
38

  
39
	public void doRegistration() {
40
		super.doRegistration();
41
		require(ToolsLibrary.class);
42
		registerAsImplementationOf(MetadataLibrary.class);
43
	}
44

  
45
	protected void doInitialize() throws LibraryException {
46
        MetadataLocator.registerMetadataManager(BasicMetadataManager.class);
47
        I18nManager i18nManager = ToolsLocator.getI18nManager();
48

  
49
        i18nManager.addResourceFamily("org.gvsig.metadata.basic.impl.i18n.text",
50
				BasicMetadataLibrary.class.getClassLoader(),
51
				BasicMetadataLibrary.class.getClass().getName());
52
	}
53

  
54
	protected void doPostInitialize() throws LibraryException {
55
		MetadataManager metadataManager = MetadataLocator.getMetadataManager();
56
		if (!(metadataManager instanceof MetadataManager)) {
57
			throw new LibraryException(BasicMetadataManager.class, null);
58
		}
59
	}
60
	
61
}
0 62

  
tags/org.gvsig.desktop-2.0.76/org.gvsig.desktop.compat.cdc/org.gvsig.metadata.basic/org.gvsig.metadata.basic.lib/org.gvsig.metadata.lib.basic.impl/src/main/java/org/gvsig/metadata/lib/basic/impl/BasicMetadataManager.java
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.lib.basic.impl;
25

  
26
import org.gvsig.metadata.Metadata;
27
import org.gvsig.metadata.MetadataContainer;
28
import org.gvsig.metadata.MetadataManager;
29
import org.gvsig.tools.dynobject.DynClass;
30
import org.gvsig.tools.dynobject.DynStruct;
31

  
32
public class BasicMetadataManager extends AbstractMetadataManager implements
33
		MetadataManager {
34

  
35

  
36
	protected Metadata createMetadata(DynStruct definition) {
37
		return new DefaultMetadata(definition);
38
	}
39

  
40
	protected MetadataContainer createMetadataContainer(DynClass dynClass) {
41
		return new BasicMetadataContainer(dynClass);
42
	}
43
}
0 44

  
tags/org.gvsig.desktop-2.0.76/org.gvsig.desktop.compat.cdc/org.gvsig.metadata.basic/org.gvsig.metadata.basic.lib/org.gvsig.metadata.lib.basic.impl/src/main/java/org/gvsig/metadata/lib/basic/impl/AbstractMetadataManager.java
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.lib.basic.impl;
25

  
26
import java.io.File;
27
import java.io.IOException;
28
import java.io.InputStream;
29
import java.util.ArrayList;
30
import java.util.HashMap;
31
import java.util.Iterator;
32
import java.util.Map;
33

  
34
import org.slf4j.Logger;
35
import org.slf4j.LoggerFactory;
36
import org.xmlpull.v1.XmlPullParserException;
37

  
38
import org.gvsig.metadata.Metadata;
39
import org.gvsig.metadata.MetadataContainer;
40
import org.gvsig.metadata.MetadataManager;
41
import org.gvsig.metadata.exceptions.AddMetadataDefinitionException;
42
import org.gvsig.metadata.exceptions.DuplicateMetadataDefinitionException;
43
import org.gvsig.metadata.exceptions.InvalidMetadataNamespaceException;
44
import org.gvsig.metadata.exceptions.MetadataException;
45
import org.gvsig.tools.ToolsLocator;
46
import org.gvsig.tools.dynobject.DynClass;
47
import org.gvsig.tools.dynobject.DynObjectManager;
48
import org.gvsig.tools.dynobject.DynStruct;
49
import org.gvsig.tools.dynobject.impl.DefaultDynClassName;
50
import org.gvsig.tools.persistence.impl.exception.CantFindDefinitionInStreamException;
51

  
52

  
53
/**
54
 * Abstract metadata manager used in both metadata basic and full modules.
55
 */
56
public abstract class AbstractMetadataManager implements MetadataManager {
57

  
58
	private final Logger LOG = LoggerFactory
59
			.getLogger(AbstractMetadataManager.class);
60

  
61
	private Map metadataItems;
62

  
63
	protected DynObjectManager dynManager;
64

  
65
	protected File metadataHomeFile = null;
66

  
67
	private boolean doSavingValidation;
68

  
69
	private boolean doExportingValidation;
70

  
71
	public AbstractMetadataManager() {
72
		dynManager = ToolsLocator.getDynObjectManager();
73
	}
74

  
75
	protected void initDefinitions() {
76
		this.metadataItems = new HashMap();
77
		Iterator definitionsIter = ToolsLocator.getDynObjectManager().iterator(
78
				MetadataManager.METADATA_NAMESPACE);
79
		DynStruct definition;
80
		while (definitionsIter.hasNext()) {
81
			definition = (DynStruct) definitionsIter.next();
82
			if (!this.getMetadataItems().containsKey(definition)) {
83
				Metadata metadata = createMetadata(definition);
84
				this.getMetadataItems().put(definition, metadata);
85
			}
86
		}
87
	}
88

  
89
	public DynStruct addDefinition(String name, String description)
90
			throws MetadataException {
91

  
92
		DynClass definition = dynManager.createDynClass(METADATA_NAMESPACE,
93
				name, description);
94

  
95
		addDefinition(definition);
96
		return definition;
97
	}
98

  
99
	public DynStruct addDefinition(String metadataDefinitionName,
100
			InputStream stream, ClassLoader loader) throws MetadataException {
101
		Map x;
102
		try {
103
			x = dynManager.importDynClassDefinitions(stream, loader,
104
					METADATA_NAMESPACE);
105
		} catch (XmlPullParserException e) {
106
			throw new AddMetadataDefinitionException(e, metadataDefinitionName);
107
		} catch (IOException e) {
108
			throw new AddMetadataDefinitionException(e, metadataDefinitionName);
109
		}
110
		DynClass definition = (DynClass) x.get(metadataDefinitionName);
111
		if (definition == null) {
112
			throw new CantFindDefinitionInStreamException(
113
					metadataDefinitionName, getKeys(x));
114
		}
115
		addDefinition(definition);
116
		return definition;
117
	}
118

  
119
	private String getKeys(Map theMap) {
120
		return new ArrayList(theMap.keySet()).toString();
121
	}
122

  
123
	public DynStruct getDefinition(Metadata metadata) throws MetadataException {
124
		return dynManager.get(METADATA_NAMESPACE, metadata.getMetadataName());
125
	}
126

  
127
	public DynStruct getDefinition(String metadataName) {
128
		if (metadataName == null)
129
			return null;
130
		if (metadataName.contains(":")) {
131
			int index = metadataName.lastIndexOf(":");
132
			return dynManager.get(metadataName.substring(0, index),
133
					metadataName.substring(index + 1, metadataName.length()));
134
		}
135
		return dynManager.get(METADATA_NAMESPACE, metadataName);
136
	}
137

  
138
	public void addDefinition(DynClass definition) throws MetadataException {
139
		if (definition == null) {
140
			return;
141
		}
142
		if ((definition.getNamespace() == null)
143
				|| (definition.getNamespace().equals(""))) {
144
			definition.setNamespace(METADATA_NAMESPACE);
145
		}
146

  
147
		if (!METADATA_NAMESPACE.equalsIgnoreCase(definition.getNamespace())) {
148
			throw new InvalidMetadataNamespaceException(definition.getName(),
149
					definition.getNamespace());
150
		}
151
		if (dynManager.get(definition.getNamespace(), definition.getName()) != null) {
152
			throw new DuplicateMetadataDefinitionException(definition.getName());
153
		}
154
		dynManager.add(definition);
155

  
156
		LOG.trace("Registered metadata definition {}.",
157
				definition.getFullName());
158

  
159
	}
160

  
161
	public void removeDefinition(DynStruct dynStruct) {
162
		if (dynStruct == null)
163
			return;
164
		this.metadataItems.remove(dynStruct);
165
		dynManager.remove(dynStruct);
166
	}
167

  
168
	public MetadataContainer createMetadataContainer(String name) {
169
		DynClass dynClass = dynManager.get(METADATA_NAMESPACE, name);
170
		if (dynClass == null) {
171
			throw new IllegalArgumentException(
172
					"Can't locate class '"
173
							+ new DefaultDynClassName(METADATA_NAMESPACE, name)
174
									.getFullName() + "'.");
175
		}
176

  
177
		return createMetadataContainer(dynClass);
178
		// return new BasicMetadataContainer(dynClass);
179
	}
180

  
181
	protected abstract MetadataContainer createMetadataContainer(
182
			DynClass dynClass);
183

  
184
	public void storeMetadata(Metadata metadata) throws MetadataException {
185
		// In SimpleMetadataManager do nothing
186
	}
187

  
188
	public void loadMetadata(Metadata metadata) throws MetadataException {
189
		// In SimpleMetadataManager do nothing
190
	}
191

  
192
	private Map getMetadataItems() {
193
		if (this.metadataItems == null) {
194
			initDefinitions();
195
		}
196
		return this.metadataItems;
197
	}
198

  
199
	public Metadata getMetadata(DynStruct definition)
200
			throws InvalidMetadataNamespaceException {
201
		if (this.getMetadataItems().containsKey(definition)) {
202
			return (Metadata) this.getMetadataItems().get(definition);
203
		}
204

  
205
		if (definition == null) {
206
			return null;
207
		}
208

  
209
		if ((definition.getNamespace() == null)
210
				|| (!definition.getNamespace().equals(METADATA_NAMESPACE))) {
211
			throw new InvalidMetadataNamespaceException(definition);
212
		}
213

  
214
		Metadata metadata = createMetadata(definition);
215

  
216
		this.getMetadataItems().put(definition, metadata);
217

  
218
		LOG.trace("Registered metadata definition {}.",
219
				definition.getFullName());
220

  
221
		return metadata;
222
	}
223

  
224
	protected abstract Metadata createMetadata(DynStruct definition);
225

  
226
	public File getMetadataHomeRepository() {
227
		if (this.metadataHomeFile == null) {
228
			String path = System.getProperty("user.home");
229
			path += File.separator + ".org.gvsig.metadata";
230
			this.metadataHomeFile = new File(path);
231
		}
232
		if (!this.metadataHomeFile.exists()) {
233
			this.metadataHomeFile.mkdirs();
234
		}
235
		return this.metadataHomeFile;
236
	}
237

  
238
	public File getRepositoryFile(String relativePath) {
239
		if ((relativePath == null) || (relativePath.equals("")))
240
			return this.metadataHomeFile;
241
		return new File(getMetadataHomeRepository().toString() + File.separator
242
				+ relativePath);
243
	}
244

  
245
	public void storeDefinitions() {
246
		Iterator it = ToolsLocator.getDynObjectManager().iterator(
247
				METADATA_NAMESPACE);
248
	}
249

  
250
	public Iterator getDefinitions() {
251
		// initDefinitions();
252
		return getMetadataItems().values().iterator();
253
	}
254

  
255
	public void setMetadataHomeRepository(File metadataHomeFile) {
256
		if (metadataHomeFile == null) {
257
			return;
258
		}
259

  
260
		this.metadataHomeFile = metadataHomeFile;
261
		if (!this.metadataHomeFile.exists())
262
			this.metadataHomeFile.mkdirs();
263
	}
264

  
265
	public Metadata getMetadata(String metadataID)
266
			throws InvalidMetadataNamespaceException {
267
		return this.getMetadata(getDefinition(metadataID));
268
	}
269

  
270
	public void setValidationBeforeSaving(boolean doValidation) {
271
		this.doSavingValidation = doValidation;
272
	}
273

  
274
	public boolean getValidationBeforeSaving() {
275
		return this.doSavingValidation;
276
	}
277

  
278
	public void setValidationBeforeExporting(boolean doValidation) {
279
		this.doExportingValidation = doValidation;
280
	}
281

  
282
	public boolean getValidationBeforeExporting() {
283
		return this.doExportingValidation;
284
	}
285
}
0 286

  
tags/org.gvsig.desktop-2.0.76/org.gvsig.desktop.compat.cdc/org.gvsig.metadata.basic/org.gvsig.metadata.basic.lib/org.gvsig.metadata.lib.basic.impl/src/main/java/org/gvsig/metadata/lib/basic/impl/CantFindDefinitionInStreamException.java
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.lib.basic.impl;
25

  
26
import org.gvsig.metadata.exceptions.AddMetadataDefinitionException;
27

  
28
public class CantFindDefinitionInStreamException extends AddMetadataDefinitionException {
29

  
30
	/**
31
	 * 
32
	 */
33
	private static final long serialVersionUID = 450922621905049558L;
34

  
35
	public CantFindDefinitionInStreamException(String name) {
36
		super(
37
			"Can't find metadata definition %(name) in stream.", 
38
			"_cant_find_metadata_definition_XnameX_in_stream", 
39
			serialVersionUID
40
		);
41
		setValue("name",name);
42
	}
43

  
44
	public CantFindDefinitionInStreamException(String name, String found) {
45
		super(
46
				"Can't find metadata definition %(name) in stream, found %(found).", 
47
				"_cant_find_metadata_definition_XnameX_in_stream_found_XfoundX", 
48
				serialVersionUID
49
			);
50
		setValue("name",name);
51
		setValue("found",found);
52
	}
53
}
0 54

  
tags/org.gvsig.desktop-2.0.76/org.gvsig.desktop.compat.cdc/org.gvsig.metadata.basic/org.gvsig.metadata.basic.lib/org.gvsig.metadata.lib.basic.impl/src/main/javadoc/overview.html
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
<html xmlns="http://www.w3.org/1999/xhtml">
4
<head>
5
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6
<title>org.gvsig.metadata.basic package documentation</title>
7
</head>
8
<body>
9

  
10
	<p>TODO: Example library overview.</p>
11
	
12
	<p>See the <a href="http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/javadoc.html#overviewcomment">Javadoc Tool documentation about the overview file</a></p>
13

  
14
</body>
15
</html>
0 16

  
tags/org.gvsig.desktop-2.0.76/org.gvsig.desktop.compat.cdc/org.gvsig.metadata.basic/org.gvsig.metadata.basic.lib/org.gvsig.metadata.lib.basic.impl/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3
	<modelVersion>4.0.0</modelVersion>
4
	<artifactId>org.gvsig.metadata.lib.basic.impl</artifactId>
5
	<packaging>jar</packaging>
6

  
7
	<name>org.gvsig.metadata.lib.basic.impl</name>
8
	<description>Metadata library basic implementation</description>
9
	<parent>
10
		<groupId>org.gvsig</groupId>
11
		<artifactId>org.gvsig.metadata.basic.lib</artifactId>
12
		<version>2.0.76</version>
13
	</parent>
14

  
15

  
16
	<dependencies>
17
		<dependency>
18
			<groupId>org.gvsig</groupId>
19
			<artifactId>org.gvsig.metadata.lib.basic.api</artifactId>
20
		</dependency>
21
	    <dependency>
22
	        <groupId>org.gvsig</groupId>
23
	        <artifactId>org.gvsig.tools.lib</artifactId>
24
	    </dependency>
25
	</dependencies>
26
</project>
0 27

  
tags/org.gvsig.desktop-2.0.76/org.gvsig.desktop.compat.cdc/org.gvsig.metadata.basic/org.gvsig.metadata.basic.lib/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2

  
3
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4

  
5
  <modelVersion>4.0.0</modelVersion>
6
  <artifactId>org.gvsig.metadata.basic.lib</artifactId>
7
  <name>${project.artifactId}</name>
8
  <packaging>pom</packaging>    
9
  <description>This project contains the basic metadata features.</description>
10
  <parent>
11
      <groupId>org.gvsig</groupId>
12
      <artifactId>org.gvsig.metadata.basic</artifactId>
13
      <version>2.0.76</version>
14
  </parent>  
15

  
16
  <modules>
17
    <module>org.gvsig.metadata.lib.basic.api</module>
18
    <module>org.gvsig.metadata.lib.basic.impl</module>
19
  </modules>
20

  
21
</project>
0 22

  
tags/org.gvsig.desktop-2.0.76/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/MetadataContainer.java
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 org.gvsig.tools.dynobject.DelegatedDynObject;
27

  
28
/**
29
 * This is a utility interface to implement classes that implement the interface
30
 * Metadata.
31
 * 
32
 * Use the createMetadataContainer in the MetadataManager to create a container
33
 * for delegate the implementation of Metadata methods in it.
34
 * 
35
 * @author gvSIG Team
36
 * @author jjdelcerro
37
 * 
38
 * @version $Id$
39
 * 
40
 */
41
public interface MetadataContainer extends DelegatedDynObject {
42

  
43
}
0 44

  
tags/org.gvsig.desktop-2.0.76/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/MetadataLocator.java
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 org.gvsig.tools.locator.BaseLocator;
27
import org.gvsig.tools.locator.LocatorException;
28

  
29
/**
30
 * 
31
 * Locator that provides the Metadata manager instance.
32
 * 
33
 * @author gvSIG Team
34
 * @author <a href="mailto:reinhold@uji.es">cmartin</a>
35
 * @version $Id$
36
 * 
37
 */
38
public class MetadataLocator extends BaseLocator {
39

  
40
	public static final String METADATA_MANAGER_NAME = "org.gvsig.metadata.manager";
41

  
42
	private static final String METADATA_MANAGER_DESCRIPTION = "Implementation for MetadataManager";
43

  
44
	/**
45
	 * Unique instance.
46
	 */
47
	private static final MetadataLocator instance = new MetadataLocator();
48

  
49
	/**
50
	 * Return the singleton instance.
51
	 * 
52
	 * @return the singleton instance
53
	 */
54
	public static MetadataLocator getInstance() {
55
		return instance;
56
	}
57

  
58
	/**
59
	 * Return a reference to MetadataManager.
60
	 * 
61
	 * @return a reference to MetadataManager
62
	 * @throws org.gvsig.tools.locator.LocatorException
63
	 *             if there is no access to the class or the class cannot be
64
	 *             instantiated
65
	 * @see org.gvsig.tools.locator.Locator#get(String)
66
	 */
67
	public static MetadataManager getMetadataManager() throws LocatorException {
68
		return (MetadataManager) getInstance().get(METADATA_MANAGER_NAME);
69
	}
70

  
71
	/**
72
	 * Registers the Class implementing the MetadataManager interface.
73
	 * 
74
	 * @param clazz
75
	 *            implementing the MetadataManager interface
76
	 */
77
	public static void registerMetadataManager(Class clazz) {
78
		getInstance().register(METADATA_MANAGER_NAME,
79
				METADATA_MANAGER_DESCRIPTION, clazz);
80
	}
81

  
82
}
0 83

  
tags/org.gvsig.desktop-2.0.76/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/MetadataLibrary.java
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 org.gvsig.tools.ToolsLibrary;
27
import org.gvsig.tools.library.AbstractLibrary;
28
import org.gvsig.tools.library.LibraryException;
29
import org.gvsig.tools.locator.ReferenceNotRegisteredException;
30

  
31
/**
32
 * Library that initalizes the Metadata module.
33
 * 
34
 * @author gvSIG Team
35
 * @author <a href="mailto:reinhold@uji.es">cmartin</a>
36
 * @version $Id$
37
 * 
38
 */
39
public class MetadataLibrary extends AbstractLibrary {
40

  
41
	public void doRegistration() {
42
		super.doRegistration();
43
		registerAsAPI(MetadataLibrary.class);
44
		require(ToolsLibrary.class);
45
	}
46

  
47
	protected void doInitialize() throws LibraryException {
48
	}
49

  
50
	protected void doPostInitialize() throws LibraryException {
51
		// Validate if there is any implementation registered.
52
		MetadataManager manager = MetadataLocator.getMetadataManager();
53

  
54
		if (manager == null) {
55
			throw new ReferenceNotRegisteredException(
56
					MetadataLocator.METADATA_MANAGER_NAME,
57
					MetadataLocator.getInstance());
58
		}
59
	}
60

  
61
}
0 62

  
tags/org.gvsig.desktop-2.0.76/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/DefinitionsMap.java
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.util.Iterator;
27
import java.util.List;
28
import java.util.Map;
29

  
30
import org.gvsig.tools.dispose.DisposableIterator;
31
import org.gvsig.tools.dynobject.DynField;
32
import org.gvsig.tools.dynobject.DynStruct;
33

  
34
/**
35
 * 
36
 * This is the intermediary of the ImportExport module, which enables to have a
37
 * disposable iterator of a list of DynStructs. It also permits to obtain
38
 * another disposable iterator of the related DynFields based on a given
39
 * DynStruct. It extends from a Map<String, DynStruct>.
40
 * 
41
 * 
42
 * @author gvSIG Team
43
 * @author <a href="mailto:reinhold@uji.es">cmartin</a>
44
 * @version $Id$
45
 * 
46
 */
47
public interface DefinitionsMap extends Map {
48

  
49

  
50
	/**
51
	 * Removes a definition from the list
52
	 * 
53
	 * @param definition
54
	 *            the definition to be removed.
55
	 */
56
	public void remove(DynStruct definition);
57

  
58
	/**
59
	 * Adds a definition to the list
60
	 * 
61
	 * @param definition
62
	 *            the definition to be added.
63
	 */
64
	public void add(DynStruct newDefinition);
65

  
66
	public void addAll(Map map);
67

  
68
	/**
69
	 * Determines if this definition is already included.
70
	 * 
71
	 * @param definition
72
	 *            the current definition to be checked.
73
	 * @return true if the definition is contained, false otherwise.
74
	 */
75
	public boolean hasDefinition(DynStruct definition);
76

  
77
	/**
78
	 * Saves the current Metadata elements of the list.
79
	 * 
80
	 */
81
	public void save();
82

  
83
	/**
84
	 * Retrieves the size of the list of elements.
85
	 */
86
	public int size();
87

  
88
	/**
89
	 * Sets the current user definitions linked to the current hierarchy
90
	 * definitions.
91
	 * 
92
	 * @param userDefs
93
	 *            the user Definitions
94
	 * @param hierarchyDefs
95
	 *            the hierarchy Definitions
96
	 */
97
	public void setHierarchyDefinitions(Map userDefs, Map hierarchyDefs);
98

  
99
	/**
100
	 * Returns a list containing definitions ( {@link DynStruct} ), which are
101
	 * disposable.
102
	 * 
103
	 * @return the disposable DynStructs iterator.
104
	 */
105
	public Iterator iterator();
106

  
107
	/**
108
	 * Returns a disposable list iteration containing {@link DynField}s based on
109
	 * a given definition ( {@link DynStruct} ).
110
	 * 
111
	 * @param definition
112
	 *            the DynStruct definition from which to obtain the associated
113
	 *            DynFields.
114
	 * @return the disposable DynFields iterator.
115
	 */
116
	public DisposableIterator dynFieldsIterator(DynStruct definition);
117

  
118
	/**
119
	 * Returns a list containing children definitions ({@link DynStruct}s) based
120
	 * on a given definition.
121
	 * 
122
	 * @param definition
123
	 *            the DynStruct definition from which to obtain the associated
124
	 *            children.
125
	 * @return the disposable DynFields iterator.
126
	 */
127
	public List getChildren(DynStruct definition);
128

  
129
	/**
130
	 * Returns a disposable list iteration containing the current elements of
131
	 * the list.
132
	 * 
133
	 * @return the disposable DynFields iterator.
134
	 */
135
	public DisposableIterator disposableIterator();
136

  
137
	/**
138
	 * Returns a list iteration containing the current parent element
139
	 * definitions of a given childDefinition.
140
	 * 
141
	 * @param childDefinition
142
	 * @return the parent definitions' iterator.
143
	 */
144
	public Iterator parentsIterator(DynStruct childDefinition);
145

  
146
	/**
147
	 * Returns a list iteration containing the current children element
148
	 * definitions of a given parentDefinition.
149
	 * 
150
	 * @return the parent definitions' iterator.
151
	 */
152
	public Iterator childrenIterator(DynStruct parentDefinition);
153

  
154
}
0 155

  
tags/org.gvsig.desktop-2.0.76/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
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
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff