Revision 33906
tags/v2_0_0_Build_2020/libraries/libMetadata/src-test/org/gvsig/metadata/simple/SimpleMDLibraryTest.java | ||
---|---|---|
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 |
* {{Task}} |
|
29 |
*/ |
|
30 |
|
|
31 |
package org.gvsig.metadata.simple; |
|
32 |
|
|
33 |
import junit.framework.TestCase; |
|
34 |
|
|
35 |
import org.gvsig.metadata.MetadataLibrary; |
|
36 |
import org.gvsig.metadata.MetadataLocator; |
|
37 |
import org.gvsig.tools.library.Library; |
|
38 |
|
|
39 |
public class SimpleMDLibraryTest extends TestCase { |
|
40 |
|
|
41 |
/** |
|
42 |
* Test method for {@link org.gvsig.metadata.simple.SimpleMetadataLibrary#initialize()}. |
|
43 |
*/ |
|
44 |
public void testInitialize() { |
|
45 |
Library api = new MetadataLibrary(); |
|
46 |
Library impl = new SimpleMetadataLibrary(); |
|
47 |
|
|
48 |
// 1: Initialize the Libraries |
|
49 |
api.initialize(); |
|
50 |
impl.initialize(); |
|
51 |
|
|
52 |
// 2: postInitialize them |
|
53 |
// if the library is not correctly initialized, |
|
54 |
// an Exception will be thrown |
|
55 |
api.postInitialize(); |
|
56 |
impl.postInitialize(); |
|
57 |
|
|
58 |
// Check if the correct implementation is returned |
|
59 |
assertEquals(SimpleMetadataManager.class, MetadataLocator.getMetadataManager() |
|
60 |
.getClass()); |
|
61 |
} |
|
62 |
|
|
63 |
} |
tags/v2_0_0_Build_2020/libraries/libMetadata/resources-test/log4j.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8" ?> |
|
2 |
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> |
|
3 |
|
|
4 |
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> |
|
5 |
|
|
6 |
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> |
|
7 |
<layout class="org.apache.log4j.PatternLayout"> |
|
8 |
<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n %m%n" /> |
|
9 |
</layout> |
|
10 |
</appender> |
|
11 |
|
|
12 |
<category name="org.gvsig.tools"> |
|
13 |
<priority value="DEBUG" /> |
|
14 |
</category> |
|
15 |
<category name="org.gvsig.metadata"> |
|
16 |
<priority value="DEBUG" /> |
|
17 |
</category> |
|
18 |
|
|
19 |
<root> |
|
20 |
<priority value="INFO" /> |
|
21 |
<appender-ref ref="CONSOLE" /> |
|
22 |
</root> |
|
23 |
</log4j:configuration> |
tags/v2_0_0_Build_2020/libraries/libMetadata/src/org/gvsig/metadata/MetadataLibrary.java | ||
---|---|---|
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 |
* {{Task}} |
|
29 |
*/ |
|
30 |
|
|
31 |
package org.gvsig.metadata; |
|
32 |
|
|
33 |
import org.gvsig.tools.ToolsLibrary; |
|
34 |
import org.gvsig.tools.library.AbstractLibrary; |
|
35 |
import org.gvsig.tools.library.Library; |
|
36 |
import org.gvsig.tools.library.LibraryException; |
|
37 |
import org.gvsig.tools.locator.ReferenceNotRegisteredException; |
|
38 |
|
|
39 |
public class MetadataLibrary extends AbstractLibrary { |
|
40 |
|
|
41 |
public MetadataLibrary() { |
|
42 |
super(MetadataLibrary.class,Library.TYPE.API); |
|
43 |
require(ToolsLibrary.class); |
|
44 |
} |
|
45 |
|
|
46 |
protected void doInitialize() throws LibraryException { |
|
47 |
} |
|
48 |
|
|
49 |
protected void doPostInitialize() throws LibraryException { |
|
50 |
// Validate there is any implementation registered. |
|
51 |
MetadataManager manager = MetadataLocator.getMetadataManager(); |
|
52 |
|
|
53 |
if (manager == null) { |
|
54 |
throw new ReferenceNotRegisteredException( |
|
55 |
MetadataLocator.METADATA_MANAGER_NAME, MetadataLocator.getInstance()); |
|
56 |
} |
|
57 |
} |
|
58 |
|
|
59 |
} |
tags/v2_0_0_Build_2020/libraries/libMetadata/src/org/gvsig/metadata/simple/SimpleMetadataContainer.java | ||
---|---|---|
1 |
package org.gvsig.metadata.simple; |
|
2 |
|
|
3 |
import org.gvsig.metadata.MetadataContainer; |
|
4 |
import org.gvsig.tools.dynobject.DynStruct; |
|
5 |
import org.gvsig.tools.dynobject.impl.DefaultDynObject; |
|
6 |
|
|
7 |
public class SimpleMetadataContainer extends DefaultDynObject implements MetadataContainer { |
|
8 |
|
|
9 |
public SimpleMetadataContainer(DynStruct dynClass) { |
|
10 |
super(dynClass); |
|
11 |
} |
|
12 |
|
|
13 |
} |
|
0 | 14 |
tags/v2_0_0_Build_2020/libraries/libMetadata/src/org/gvsig/metadata/simple/SimpleMetadataLibrary.java | ||
---|---|---|
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 |
* {{Task}} |
|
29 |
*/ |
|
30 |
|
|
31 |
package org.gvsig.metadata.simple; |
|
32 |
|
|
33 |
import org.gvsig.metadata.MetadataLibrary; |
|
34 |
import org.gvsig.metadata.MetadataLocator; |
|
35 |
import org.gvsig.tools.ToolsLibrary; |
|
36 |
import org.gvsig.tools.library.AbstractLibrary; |
|
37 |
import org.gvsig.tools.library.Library; |
|
38 |
import org.gvsig.tools.library.LibraryException; |
|
39 |
|
|
40 |
public class SimpleMetadataLibrary extends AbstractLibrary { |
|
41 |
|
|
42 |
public SimpleMetadataLibrary() { |
|
43 |
super(MetadataLibrary.class,Library.TYPE.IMPL); |
|
44 |
require(ToolsLibrary.class); |
|
45 |
} |
|
46 |
|
|
47 |
protected void doInitialize() throws LibraryException { |
|
48 |
MetadataLocator.registerMetadataManager(SimpleMetadataManager.class); |
|
49 |
} |
|
50 |
|
|
51 |
protected void doPostInitialize() throws LibraryException { |
|
52 |
} |
|
53 |
|
|
54 |
} |
tags/v2_0_0_Build_2020/libraries/libMetadata/src/org/gvsig/metadata/simple/CantFindDefinitionInStreamException.java | ||
---|---|---|
1 |
package org.gvsig.metadata.simple; |
|
2 |
|
|
3 |
import org.gvsig.metadata.exceptions.AddMetadataDefinitionException; |
|
4 |
|
|
5 |
public class CantFindDefinitionInStreamException extends AddMetadataDefinitionException { |
|
6 |
|
|
7 |
/** |
|
8 |
* |
|
9 |
*/ |
|
10 |
private static final long serialVersionUID = 450922621905049558L; |
|
11 |
|
|
12 |
public CantFindDefinitionInStreamException(String name) { |
|
13 |
super( |
|
14 |
"Can't find metadata definition %(name) in stream.", |
|
15 |
"_cant_find_metadata_definition_XnameX_in_stream", |
|
16 |
serialVersionUID |
|
17 |
); |
|
18 |
setValue("name",name); |
|
19 |
} |
|
20 |
|
|
21 |
public CantFindDefinitionInStreamException(String name, String found) { |
|
22 |
super( |
|
23 |
"Can't find metadata definition %(name) in stream, found %(found).", |
|
24 |
"_cant_find_metadata_definition_XnameX_in_stream_found_XfoundX", |
|
25 |
serialVersionUID |
|
26 |
); |
|
27 |
setValue("name",name); |
|
28 |
setValue("found",found); |
|
29 |
} |
|
30 |
} |
|
0 | 31 |
tags/v2_0_0_Build_2020/libraries/libMetadata/src/org/gvsig/metadata/simple/SimpleMetadataManager.java | ||
---|---|---|
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 |
* {{Task}} |
|
29 |
*/ |
|
30 |
|
|
31 |
package org.gvsig.metadata.simple; |
|
32 |
|
|
33 |
import java.io.IOException; |
|
34 |
import java.io.InputStream; |
|
35 |
import java.util.ArrayList; |
|
36 |
import java.util.List; |
|
37 |
import java.util.Map; |
|
38 |
|
|
39 |
import org.slf4j.Logger; |
|
40 |
import org.slf4j.LoggerFactory; |
|
41 |
import org.xmlpull.v1.XmlPullParserException; |
|
42 |
|
|
43 |
import org.gvsig.metadata.Metadata; |
|
44 |
import org.gvsig.metadata.MetadataContainer; |
|
45 |
import org.gvsig.metadata.MetadataManager; |
|
46 |
import org.gvsig.metadata.exceptions.AddMetadataDefinitionException; |
|
47 |
import org.gvsig.metadata.exceptions.DuplicateMetadataDefinitionException; |
|
48 |
import org.gvsig.metadata.exceptions.InvalidMetadataNamespaceException; |
|
49 |
import org.gvsig.metadata.exceptions.MetadataException; |
|
50 |
import org.gvsig.tools.ToolsLocator; |
|
51 |
import org.gvsig.tools.dynobject.DynClass; |
|
52 |
import org.gvsig.tools.dynobject.DynObjectManager; |
|
53 |
import org.gvsig.tools.dynobject.DynStruct; |
|
54 |
|
|
55 |
public class SimpleMetadataManager implements MetadataManager { |
|
56 |
|
|
57 |
private final Logger LOG = LoggerFactory.getLogger(SimpleMetadataManager.class); |
|
58 |
|
|
59 |
public DynStruct addDefinition(String name, String description) |
|
60 |
throws MetadataException { |
|
61 |
DynObjectManager dynman = ToolsLocator.getDynObjectManager(); |
|
62 |
|
|
63 |
DynClass definition = dynman.createDynClass(METADATA_NAMESPACE, name, description); |
|
64 |
if( dynman.get(definition.getNamespace(),definition.getName())!=null ) { |
|
65 |
throw new DuplicateMetadataDefinitionException(definition.getName()); |
|
66 |
} |
|
67 |
dynman.add(definition); |
|
68 |
LOG.trace("Registered metadata definition {}.", definition.getFullName()); |
|
69 |
return definition; |
|
70 |
} |
|
71 |
|
|
72 |
public DynStruct getDefinition(String name) { |
|
73 |
DynObjectManager dynman = ToolsLocator.getDynObjectManager(); |
|
74 |
|
|
75 |
return dynman.get(METADATA_NAMESPACE,name); |
|
76 |
} |
|
77 |
|
|
78 |
public DynStruct addDefinition(String metadataDefinitionName, |
|
79 |
InputStream stream, ClassLoader loader) throws MetadataException { |
|
80 |
DynObjectManager dynman = ToolsLocator.getDynObjectManager(); |
|
81 |
Map x; |
|
82 |
try { |
|
83 |
x = dynman.importDynClassDefinitions(stream, loader, METADATA_NAMESPACE); |
|
84 |
} catch (XmlPullParserException e) { |
|
85 |
throw new AddMetadataDefinitionException(e, metadataDefinitionName); |
|
86 |
} catch (IOException e) { |
|
87 |
throw new AddMetadataDefinitionException(e, metadataDefinitionName); |
|
88 |
} |
|
89 |
DynClass definition = (DynClass) x.get(metadataDefinitionName); |
|
90 |
if( definition== null ) { |
|
91 |
throw new CantFindDefinitionInStreamException(metadataDefinitionName, getKeys(x)); |
|
92 |
} |
|
93 |
return addDefinition(definition); |
|
94 |
} |
|
95 |
|
|
96 |
private String getKeys(Map theMap) { |
|
97 |
List l = new ArrayList(theMap.keySet()); |
|
98 |
return l.toString(); |
|
99 |
} |
|
100 |
|
|
101 |
|
|
102 |
protected DynStruct addDefinition(DynClass definition) throws MetadataException{ |
|
103 |
DynObjectManager dynman = ToolsLocator.getDynObjectManager(); |
|
104 |
|
|
105 |
if(! METADATA_NAMESPACE.equalsIgnoreCase(definition.getNamespace()) ) { |
|
106 |
throw new InvalidMetadataNamespaceException(definition.getName(), definition.getNamespace()); |
|
107 |
} |
|
108 |
if( dynman.get(definition.getNamespace(),definition.getName())!=null ) { |
|
109 |
throw new DuplicateMetadataDefinitionException(definition.getName()); |
|
110 |
} |
|
111 |
dynman.add(definition); |
|
112 |
LOG.trace("Registered metadata definition {}.", definition.getFullName()); |
|
113 |
return definition; |
|
114 |
} |
|
115 |
|
|
116 |
public MetadataContainer createMetadataContainer(String name) { |
|
117 |
DynObjectManager dynman = ToolsLocator.getDynObjectManager(); |
|
118 |
|
|
119 |
DynClass dynClass = dynman.get(METADATA_NAMESPACE, name); |
|
120 |
if (dynClass == null) { |
|
121 |
throw new IllegalArgumentException("Can't locate class '" |
|
122 |
+ dynman.createDynClassName(METADATA_NAMESPACE, name) |
|
123 |
.getFullName() + "'."); |
|
124 |
} |
|
125 |
return new SimpleMetadataContainer(dynClass); |
|
126 |
} |
|
127 |
|
|
128 |
public void loadMetadata(Metadata metadata) throws MetadataException { |
|
129 |
// do nothing |
|
130 |
|
|
131 |
} |
|
132 |
|
|
133 |
public void storeMetadata(Metadata metadata) throws MetadataException { |
|
134 |
// do nothing |
|
135 |
|
|
136 |
} |
|
137 |
|
|
138 |
} |
tags/v2_0_0_Build_2020/libraries/libMetadata/src/org/gvsig/metadata/MetadataManager.java | ||
---|---|---|
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 |
* {{Task}} |
|
29 |
*/ |
|
30 |
|
|
31 |
package org.gvsig.metadata; |
|
32 |
|
|
33 |
import java.io.InputStream; |
|
34 |
|
|
35 |
import org.gvsig.metadata.exceptions.MetadataException; |
|
36 |
import org.gvsig.tools.dynobject.DynStruct; |
|
37 |
|
|
38 |
/** |
|
39 |
* Manages the load and storage of Metadata objects. |
|
40 |
* |
|
41 |
* @author <a href="mailto:cordin@disid.com">C?sar Ordi?ana</a> |
|
42 |
*/ |
|
43 |
public interface MetadataManager { |
|
44 |
|
|
45 |
public final static String METADATA_NAMESPACE = "metadata"; |
|
46 |
|
|
47 |
/** |
|
48 |
* Add a new definition in the metadata manager. |
|
49 |
* |
|
50 |
* The new definition is defined in the namespace by default |
|
51 |
* for DynClasses used for metadata. |
|
52 |
|
|
53 |
* @param name |
|
54 |
* @param description |
|
55 |
* @return |
|
56 |
* @throws MetadataException; |
|
57 |
*/ |
|
58 |
public DynStruct addDefinition(String name, String description) throws MetadataException; |
|
59 |
|
|
60 |
public DynStruct addDefinition(String name, |
|
61 |
InputStream stream, ClassLoader loader) throws MetadataException; |
|
62 |
|
|
63 |
/** |
|
64 |
* <p>if has registered in this manager a metadata definition for |
|
65 |
* this name, then this method return that definition. |
|
66 |
* Otherwise, it returns null. |
|
67 |
* </p> |
|
68 |
* |
|
69 |
* @param definition name |
|
70 |
* the name whose corresponding attribute definition is to be |
|
71 |
* retrieved. |
|
72 |
* |
|
73 |
* @return The attribute definition corresponding to the provided metadata |
|
74 |
* class, or null otherwise. |
|
75 |
*/ |
|
76 |
public DynStruct getDefinition(String name); |
|
77 |
|
|
78 |
public MetadataContainer createMetadataContainer(String name); |
|
79 |
|
|
80 |
public void storeMetadata(Metadata metadata) throws MetadataException; |
|
81 |
|
|
82 |
public void loadMetadata(Metadata metadata)throws MetadataException; |
|
83 |
|
|
84 |
} |
tags/v2_0_0_Build_2020/libraries/libMetadata/src/org/gvsig/metadata/Metadata.java | ||
---|---|---|
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 |
* {{Task}} |
|
29 |
*/ |
|
30 |
|
|
31 |
package org.gvsig.metadata; |
|
32 |
|
|
33 |
import java.util.Set; |
|
34 |
|
|
35 |
import org.gvsig.metadata.exceptions.MetadataException; |
|
36 |
import org.gvsig.tools.dynobject.DynObject; |
|
37 |
|
|
38 |
/** |
|
39 |
* Metadata is information or data about data |
|
40 |
* {@link http://en.wikipedia.org/wiki/Metadata}. |
|
41 |
* <p> |
|
42 |
* This interface extends DynObject to add anything needed over the DynObject |
|
43 |
* model to be able to be used as a Metadata model. |
|
44 |
* </p> |
|
45 |
* |
|
46 |
* @author <a href="mailto:cordin@disid.com">C?sar Ordi?ana</a> |
|
47 |
*/ |
|
48 |
public interface Metadata extends DynObject { |
|
49 |
|
|
50 |
/** |
|
51 |
* Returns the unique identifier of the Metadata. |
|
52 |
* |
|
53 |
* @return the Metadata identifier |
|
54 |
*/ |
|
55 |
Object getMetadataID() throws MetadataException; |
|
56 |
|
|
57 |
/** |
|
58 |
* Returns the name of the Metadata, which allows to identify the type in |
|
59 |
* the Metadata registry. |
|
60 |
* |
|
61 |
* @return the Metadata name |
|
62 |
*/ |
|
63 |
String getMetadataName() throws MetadataException; |
|
64 |
|
|
65 |
/** |
|
66 |
* Returns a set of child Metadata objects. |
|
67 |
* |
|
68 |
* @return a set of child Metadata objects |
|
69 |
*/ |
|
70 |
Set getMetadataChildren() throws MetadataException; |
|
71 |
|
|
72 |
} |
tags/v2_0_0_Build_2020/libraries/libMetadata/src/org/gvsig/metadata/exceptions/MetadataException.java | ||
---|---|---|
1 |
package org.gvsig.metadata.exceptions; |
|
2 |
|
|
3 |
import org.gvsig.tools.exception.ListBaseException; |
|
4 |
|
|
5 |
public class MetadataException extends ListBaseException { |
|
6 |
/** |
|
7 |
* |
|
8 |
*/ |
|
9 |
private static final long serialVersionUID = -2654368520999289207L; |
|
10 |
private final static String MESSAGE_FORMAT = "Error getting or setting the state of the object."; |
|
11 |
private final static String MESSAGE_KEY = "_MetadataException"; |
|
12 |
|
|
13 |
/** |
|
14 |
* |
|
15 |
* @param messageFormat |
|
16 |
* @deprecated No debe usarse este constructor, si lo necesitas, seguramente tendrias que |
|
17 |
* crear una excepcion mas concreta que deribe de esta. |
|
18 |
*/ |
|
19 |
public MetadataException(String messageFormat) { |
|
20 |
super(messageFormat, MESSAGE_KEY, serialVersionUID); |
|
21 |
} |
|
22 |
|
|
23 |
public MetadataException(Throwable cause) { |
|
24 |
this(MESSAGE_FORMAT, cause); |
|
25 |
} |
|
26 |
|
|
27 |
protected MetadataException(String messageFormat, String messageKey, long code) { |
|
28 |
super(messageFormat, messageKey, code); |
|
29 |
} |
|
30 |
|
|
31 |
protected MetadataException(String messageFormat, Throwable cause, String messageKey, long code) { |
|
32 |
super(messageFormat, cause, messageKey, code); |
|
33 |
} |
|
34 |
|
|
35 |
public MetadataException(String messageFormat, Throwable cause) { |
|
36 |
super(messageFormat, cause, MESSAGE_KEY, serialVersionUID); |
|
37 |
} |
|
38 |
} |
|
0 | 39 |
tags/v2_0_0_Build_2020/libraries/libMetadata/src/org/gvsig/metadata/exceptions/AddMetadataDefinitionException.java | ||
---|---|---|
1 |
package org.gvsig.metadata.exceptions; |
|
2 |
|
|
3 |
|
|
4 |
public class AddMetadataDefinitionException extends MetadataException { |
|
5 |
|
|
6 |
/** |
|
7 |
* |
|
8 |
*/ |
|
9 |
private static final long serialVersionUID = 564722264607592985L; |
|
10 |
|
|
11 |
public AddMetadataDefinitionException(Throwable cause, String name) { |
|
12 |
super( |
|
13 |
"Can't add definition %(name) to metadata manager.", |
|
14 |
cause, |
|
15 |
"_Cant_add_definition_XnameX_to_metadata_manager", |
|
16 |
serialVersionUID |
|
17 |
); |
|
18 |
} |
|
19 |
|
|
20 |
protected AddMetadataDefinitionException(String message, String key, long code) { |
|
21 |
super(message, key, code); |
|
22 |
} |
|
23 |
|
|
24 |
} |
|
25 |
|
|
0 | 26 |
tags/v2_0_0_Build_2020/libraries/libMetadata/src/org/gvsig/metadata/exceptions/DuplicateMetadataDefinitionException.java | ||
---|---|---|
1 |
package org.gvsig.metadata.exceptions; |
|
2 |
|
|
3 |
|
|
4 |
public class DuplicateMetadataDefinitionException extends AddMetadataDefinitionException { |
|
5 |
|
|
6 |
/** |
|
7 |
* |
|
8 |
*/ |
|
9 |
private static final long serialVersionUID = 1774035106179247051L; |
|
10 |
private final static String MESSAGE_FORMAT = "Duplicated name (%(name)s) in definition of metadata."; |
|
11 |
private final static String MESSAGE_KEY = "_DuplicateMetadataDefinitionException"; |
|
12 |
|
|
13 |
public DuplicateMetadataDefinitionException(String name) { |
|
14 |
super(MESSAGE_FORMAT, MESSAGE_KEY, serialVersionUID); |
|
15 |
this.setValue("name",name); |
|
16 |
} |
|
17 |
|
|
18 |
} |
|
19 |
|
|
0 | 20 |
tags/v2_0_0_Build_2020/libraries/libMetadata/src/org/gvsig/metadata/exceptions/InvalidMetadataNamespaceException.java | ||
---|---|---|
1 |
package org.gvsig.metadata.exceptions; |
|
2 |
|
|
3 |
|
|
4 |
public class InvalidMetadataNamespaceException extends MetadataException { |
|
5 |
|
|
6 |
/** |
|
7 |
* |
|
8 |
*/ |
|
9 |
private static final long serialVersionUID = 7848869189284006672L; |
|
10 |
private final static String MESSAGE_FORMAT = "Invalid namespace '%(namespace)s' for class '%(names)s' in metadata context."; |
|
11 |
private final static String MESSAGE_KEY = "_InvalidMetadataNamespaceException"; |
|
12 |
|
|
13 |
public InvalidMetadataNamespaceException(String definitionName, String namespace) { |
|
14 |
super(MESSAGE_FORMAT, MESSAGE_KEY, serialVersionUID); |
|
15 |
this.setValue("name", definitionName); |
|
16 |
this.setValue("namespace", namespace); |
|
17 |
} |
|
18 |
|
|
19 |
} |
|
20 |
|
|
0 | 21 |
tags/v2_0_0_Build_2020/libraries/libMetadata/src/org/gvsig/metadata/exceptions/MetadataRuntimeException.java | ||
---|---|---|
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 |
* 2009 IVER T.I {{Task}} |
|
26 |
*/ |
|
27 |
|
|
28 |
/** |
|
29 |
* |
|
30 |
*/ |
|
31 |
package org.gvsig.metadata.exceptions; |
|
32 |
|
|
33 |
import org.gvsig.tools.exception.BaseException; |
|
34 |
import org.gvsig.tools.exception.BaseRuntimeException; |
|
35 |
|
|
36 |
/** |
|
37 |
* @author jjdelcerro |
|
38 |
* |
|
39 |
*/ |
|
40 |
public class MetadataRuntimeException extends BaseRuntimeException { |
|
41 |
|
|
42 |
/** |
|
43 |
* |
|
44 |
*/ |
|
45 |
private static final long serialVersionUID = -1059880619868712491L; |
|
46 |
|
|
47 |
public MetadataRuntimeException(BaseException exception) { |
|
48 |
super(exception); |
|
49 |
} |
|
50 |
|
|
51 |
protected MetadataRuntimeException(String message, String key, long code) { |
|
52 |
// Don't make public this method. |
|
53 |
super(message, key, code); |
|
54 |
} |
|
55 |
|
|
56 |
protected MetadataRuntimeException(String message, Throwable cause, String key, long code) { |
|
57 |
// Don't make public this method. |
|
58 |
super(message, cause, key, code); |
|
59 |
} |
|
60 |
|
|
61 |
} |
|
0 | 62 |
tags/v2_0_0_Build_2020/libraries/libMetadata/src/org/gvsig/metadata/MetadataContainer.java | ||
---|---|---|
1 |
package org.gvsig.metadata; |
|
2 |
|
|
3 |
import org.gvsig.tools.dynobject.DelegatedDynObject; |
|
4 |
|
|
5 |
/** |
|
6 |
* This is a utility interface to implement classes |
|
7 |
* that implement the interface Metadata. |
|
8 |
* |
|
9 |
* Use the createMetadataContainer in the MetadataManager |
|
10 |
* to create a container for delegate the implementation of |
|
11 |
* Metadata methods in it. |
|
12 |
* |
|
13 |
* @author jjdelcerro |
|
14 |
* |
|
15 |
*/ |
|
16 |
public interface MetadataContainer extends DelegatedDynObject { |
|
17 |
|
|
18 |
} |
|
0 | 19 |
tags/v2_0_0_Build_2020/libraries/libMetadata/src/org/gvsig/metadata/MetadataLocator.java | ||
---|---|---|
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 |
* {{Task}} |
|
29 |
*/ |
|
30 |
|
|
31 |
package org.gvsig.metadata; |
|
32 |
|
|
33 |
import org.gvsig.tools.locator.BaseLocator; |
|
34 |
import org.gvsig.tools.locator.LocatorException; |
|
35 |
|
|
36 |
|
|
37 |
public class MetadataLocator extends BaseLocator { |
|
38 |
|
|
39 |
public static final String METADATA_MANAGER_NAME = "org.gvsig.metadata.manager"; |
|
40 |
|
|
41 |
private static final String METADATA_MANAGER_DESCRIPTION = "Implementation for MetadataManager"; |
|
42 |
|
|
43 |
/** |
|
44 |
* Unique instance. |
|
45 |
*/ |
|
46 |
private static final MetadataLocator instance = new MetadataLocator(); |
|
47 |
|
|
48 |
/** |
|
49 |
* Return the singleton instance. |
|
50 |
* |
|
51 |
* @return the singleton instance |
|
52 |
*/ |
|
53 |
public static MetadataLocator getInstance() { |
|
54 |
return instance; |
|
55 |
} |
|
56 |
|
|
57 |
/** |
|
58 |
* Return a reference to MetadataManager. |
|
59 |
* |
|
60 |
* @return a reference to MetadataManager |
|
61 |
* @throws LocatorException |
|
62 |
* if there is no access to the class or the class cannot be |
|
63 |
* instantiated |
|
64 |
* @see Locator#get(String) |
|
65 |
*/ |
|
66 |
public static MetadataManager getMetadataManager() throws LocatorException { |
|
67 |
return (MetadataManager) getInstance().get(METADATA_MANAGER_NAME); |
|
68 |
} |
|
69 |
|
|
70 |
/** |
|
71 |
* Registers the Class implementing the MetadataManager interface. |
|
72 |
* |
|
73 |
* @param clazz |
|
74 |
* implementing the MetadataManager interface |
|
75 |
*/ |
|
76 |
public static void registerMetadataManager(Class clazz) { |
|
77 |
getInstance().register(METADATA_MANAGER_NAME, METADATA_MANAGER_DESCRIPTION, clazz); |
|
78 |
} |
|
79 |
|
|
80 |
} |
tags/v2_0_0_Build_2020/libraries/libMetadata/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" |
|
4 |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 |
|
5 |
http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
6 |
|
|
7 |
<modelVersion>4.0.0</modelVersion> |
|
8 |
<groupId>org.gvsig</groupId> |
|
9 |
<artifactId>org.gvsig.metadata</artifactId> |
|
10 |
<packaging>jar</packaging> |
|
11 |
<version>2.0-SNAPSHOT</version> |
|
12 |
<name>libMetadata</name> |
|
13 |
<url>http://gvsig.org</url> |
|
14 |
<parent> |
|
15 |
<groupId>org.gvsig</groupId> |
|
16 |
<artifactId>gvsig-base-library-pom</artifactId> |
|
17 |
<version>2.0-SNAPSHOT</version> |
|
18 |
</parent> |
|
19 |
<distributionManagement> |
|
20 |
<site> |
|
21 |
<id>gvsig-repository</id> |
|
22 |
<url>${site-repository}/</url> |
|
23 |
</site> |
|
24 |
</distributionManagement> |
|
25 |
|
|
26 |
<properties> |
|
27 |
<build-dir>${basedir}/../build</build-dir> |
|
28 |
</properties> |
|
29 |
<dependencies> |
|
30 |
<dependency> |
|
31 |
<groupId>org.gvsig</groupId> |
|
32 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
33 |
</dependency> |
|
34 |
</dependencies> |
|
35 |
<build> |
|
36 |
<sourceDirectory>src</sourceDirectory> |
|
37 |
<testSourceDirectory>src-test</testSourceDirectory> |
|
38 |
<plugins> |
|
39 |
<plugin> |
|
40 |
<groupId>org.apache.maven.plugins</groupId> |
|
41 |
<artifactId>maven-compiler-plugin</artifactId> |
|
42 |
<configuration> |
|
43 |
<source>1.4</source> |
|
44 |
<target>1.4</target> |
|
45 |
<!-- put your configurations here --> |
|
46 |
<encoding>ISO-8859-1</encoding> |
|
47 |
</configuration> |
|
48 |
</plugin> |
|
49 |
<plugin> |
|
50 |
<groupId>org.apache.maven.plugins</groupId> |
|
51 |
<artifactId>maven-jar-plugin</artifactId> |
|
52 |
<configuration> |
|
53 |
<excludes> |
|
54 |
<exclude>**/simple/**</exclude> |
|
55 |
</excludes> |
|
56 |
</configuration> |
|
57 |
<executions> |
|
58 |
<!-- |
|
59 |
Generates a jar file only with the libMetadata simple implementation. |
|
60 |
--> |
|
61 |
<execution> |
|
62 |
<id>simple</id> |
|
63 |
<!--phase>package</phase--> |
|
64 |
<goals> |
|
65 |
<goal>jar</goal> |
|
66 |
</goals> |
|
67 |
<configuration> |
|
68 |
<classifier>simple</classifier> |
|
69 |
<excludes> |
|
70 |
<exclude>NONE</exclude> |
|
71 |
</excludes> |
|
72 |
<includes> |
|
73 |
<include>**/simple/**</include> |
|
74 |
</includes> |
|
75 |
<!--finalName>${project.build.finalName}</finalName--> |
|
76 |
</configuration> |
|
77 |
</execution> |
|
78 |
</executions> |
|
79 |
</plugin> |
|
80 |
<plugin> |
|
81 |
<artifactId>maven-antrun-plugin</artifactId> |
|
82 |
<executions> |
|
83 |
<execution> |
|
84 |
<id>services</id> |
|
85 |
<phase>package</phase> |
|
86 |
<goals> |
|
87 |
<goal>run</goal> |
|
88 |
</goals> |
|
89 |
<configuration> |
|
90 |
<tasks> |
|
91 |
<jar destfile="${project.build.directory}/${project.build.finalName}.jar" |
|
92 |
update="true"> |
|
93 |
<fileset dir="${basedir}/resources/api" /> |
|
94 |
</jar> |
|
95 |
<jar destfile="${project.build.directory}/${project.build.finalName}-simple.jar" |
|
96 |
update="true"> |
|
97 |
<fileset dir="${basedir}/resources/simple" /> |
|
98 |
</jar> |
|
99 |
</tasks> |
|
100 |
</configuration> |
|
101 |
</execution> |
|
102 |
</executions> |
|
103 |
</plugin> |
|
104 |
<plugin> |
|
105 |
<groupId>org.apache.maven.plugins</groupId> |
|
106 |
<artifactId>maven-surefire-plugin</artifactId> |
|
107 |
<configuration> |
|
108 |
<additionalClasspathElements> |
|
109 |
<additionalClasspathElement>${basedir}/resources/api</additionalClasspathElement> |
|
110 |
<additionalClasspathElement>${basedir}/resources/simple</additionalClasspathElement> |
|
111 |
</additionalClasspathElements> |
|
112 |
</configuration> |
|
113 |
</plugin> |
|
114 |
</plugins> |
|
115 |
</build> |
|
116 |
<profiles> |
|
117 |
<profile> |
|
118 |
<id>eclipse-project</id> |
|
119 |
<build> |
|
120 |
<defaultGoal>antrun:run</defaultGoal> |
|
121 |
<plugins> |
|
122 |
<plugin> |
|
123 |
<artifactId>maven-antrun-plugin</artifactId> |
|
124 |
<configuration> |
|
125 |
<tasks> |
|
126 |
<ant antfile="${build-dir}/ant-tasks/eclipse-tasks.xml" |
|
127 |
target="eclipse.all"/> |
|
128 |
</tasks> |
|
129 |
</configuration> |
|
130 |
</plugin> |
|
131 |
</plugins> |
|
132 |
</build> |
|
133 |
</profile> |
|
134 |
</profiles> |
|
135 |
<reporting> |
|
136 |
<plugins> |
|
137 |
<plugin> |
|
138 |
<groupId>org.apache.maven.plugins</groupId> |
|
139 |
<artifactId>maven-javadoc-plugin</artifactId> |
|
140 |
<reportSets> |
|
141 |
<reportSet> |
|
142 |
<id>api</id> |
|
143 |
<configuration> |
|
144 |
<excludePackageNames>org.gvsig.metadata.simple</excludePackageNames> |
|
145 |
<name>Javadoc: API</name> |
|
146 |
<destDir>apidoc</destDir> |
|
147 |
<windowtitle>API Documentation</windowtitle> |
|
148 |
<links> |
|
149 |
<link>http://java.sun.com/j2se/1.5.0/docs/api/</link> |
|
150 |
<link>http://www.slf4j.org/api/</link> |
|
151 |
<link>${site-repository}/org.gvsig.tools/2.0.0/apidocs/</link> |
|
152 |
<link>${site-repository}/org.gvsig.i18n/2.0.0/apidocs/</link> |
|
153 |
</links> |
|
154 |
</configuration> |
|
155 |
<reports> |
|
156 |
<report>javadoc</report> |
|
157 |
</reports> |
|
158 |
</reportSet> |
|
159 |
<reportSet> |
|
160 |
<id>basic-impl</id> |
|
161 |
<configuration> |
|
162 |
<doctitle>${project.name} ${project.version} Basic Implementation |
|
163 |
</doctitle> |
|
164 |
<subpackages>org.gvsig.metadata.simple</subpackages> |
|
165 |
<name>Javadoc: basic impl</name> |
|
166 |
<destDir>basicimpldoc</destDir> |
|
167 |
<windowtitle>Basic implementation Documentation</windowtitle> |
|
168 |
<links> |
|
169 |
<link>http://java.sun.com/j2se/1.5.0/docs/api/</link> |
|
170 |
<link>http://www.slf4j.org/api/</link> |
|
171 |
<link>../apidoc/</link> |
|
172 |
<link>${site-repository}/org.gvsig.tools/2.0.0/apidocs/</link> |
|
173 |
<link>${site-repository}/org.gvsig.i18n/2.0.0/apidocs/</link> |
|
174 |
</links> |
|
175 |
</configuration> |
|
176 |
<reports> |
|
177 |
<report>javadoc</report> |
|
178 |
</reports> |
|
179 |
</reportSet> |
|
180 |
</reportSets> |
|
181 |
</plugin> |
|
182 |
</plugins> |
|
183 |
</reporting> |
|
184 |
</project> |
tags/v2_0_0_Build_2020/libraries/libMetadata/resources/api/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.metadata.MetadataLibrary |
tags/v2_0_0_Build_2020/libraries/libMetadata/resources/simple/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.metadata.simple.SimpleMetadataLibrary |
|
0 | 2 |
Also available in: Unified diff