Revision 24580

View differences:

tags/tmp_build/extensions/extMetadata/config/text_en.properties
1
# extMetadata
2
Metadata=Metadata
3

  
4
# PreferencesPanel
5
Base_Datos=Data Base
6
Personal_DB_Button=Personal Data Base
7
Corporative_DB_Button=Corporative Data Base
8

  
9
# MDBasicGUIPanel
10
edit_checkbox=Allow Edition
11
LayerMetadata=Layer Metadata
tags/tmp_build/extensions/extMetadata/config/config.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2

  
3
<plugin-config>
4
   <depends plugin-name="com.iver.cit.gvsig" />
5
   <resourceBundle name="text"/>
6
   <libraries library-dir="."/>
7
   <extensions>
8
         <extension class-name="org.gvsig.metadata.extension.MetadataExtension"
9
                 description="Metadata Extension (GUI + Metadata Publish Assistant)"
10
                 active="true"
11
                 priority="1">
12
         </extension>            
13
   </extensions>
14
</plugin-config>
tags/tmp_build/extensions/extMetadata/config/text.properties
1
# extMetadata
2
Metadata=Metadatos
3

  
4
# PreferencesPanel
5
Base_Datos=Base de Datos
6
Personal_DB_Button=Base de Datos Personal
7
Corporative_DB_Button=Base de Datos Corporativa
8

  
9
# MDBasicGUIPanel
10
edit_checkbox=Activar Edici?n
11
LayerMetadata=Metadatos de la Capa
tags/tmp_build/extensions/extMetadata/src/org/gvsig/metadata/extended/ExtendedMetadata.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

  
32

  
33

  
34
package org.gvsig.metadata.extended;
35

  
36
import java.util.Date;
37
import java.util.Iterator;
38

  
39
import org.gvsig.metadata.Metadata;
40
import org.gvsig.metadata.exceptions.NamedMetadataNotFoundException;
41
import org.gvsig.metadata.extended.registry.objects.MDDefinition;
42

  
43

  
44
public interface ExtendedMetadata extends Metadata {
45
	
46
	/**
47
	 * Retrieves a MDElement from the ExtendedMetadata object
48
	 * @param	name	the name which identifies the object to return
49
	 * @return			the object referenced by 'name' in the ExtendedMetadata object
50
	 * @throws ClassCastException	thrown to indicate that the code has attempted to cast an object to a subclass of which it is not an instance
51
	 * @throws NamedMetadataNotFoundException	if not Metadata with the 'name' is found
52
	 */
53
	public MDElement getElement(String name) throws ClassCastException, NamedMetadataNotFoundException;
54
	
55
	/**
56
	 * Puts a MDElement in the ExtendedMetadata object
57
	 * @param	elem	the MDElement object to put in the ExtendedMetadata object 
58
	 */
59
	public void setElement(MDElement elem);
60
	
61
	/**
62
	 * Retrieves the identifier of the ExtendedMetadata object
63
	 * @return			the String which identifies the ExtendedMetadata object
64
	 */
65
	public String getId();
66
	
67
	/**
68
	 * Retrieves the description of the ExtendedMetadata object
69
	 * @return			a String containing the description of the ExtendedMetadata object
70
	 */
71
	public String getDescription();
72
	
73
	/**
74
	 * Set the description of the ExtendedMetadata object
75
	 */
76
	public void setDescription(String desc);
77
	
78
	/**
79
	 * Retrieves the date of creation of the object
80
	 * @return			a Date object containing the system date when the ExtendedMetadata object was created
81
	 */
82
	public Date getCreateDate();
83
	
84
	/**
85
	 * Retrieves the date of the last change in the object
86
	 * @return			a Date object containing the system date when the ExtendedMetadata object was modified for the last time
87
	 */
88
	public Date getChangeDate();
89
	
90
	/**
91
	 * Retrieves the ExtendedMetadata object type
92
	 * @return			a MDDefinition object containing the name and the description of the ExtendedMetadata object
93
	 */
94
	public MDDefinition getType();
95
	
96
	/**
97
	 * Retrieves the name of the creator of the ExtendedMetadata object
98
	 * @return			a String containing the name of the creator of the object
99
	 */
100
	public String getAuthor();
101
	
102
	/**
103
	 * Checks if the ExtendedMetadata object has a specific value
104
	 * @param 	name	the name which identifies the value to check
105
	 * @return			a boolean value which indicates if there is a value in the object referenced by 'name'
106
	 */
107
	public boolean hasValue(String name);
108
	
109
	/**
110
	 * Checks if the ExtendedMetadata object is empty
111
	 * @return			a boolean value which indicates if the object has any value
112
	 */
113
	public boolean isEmpty();
114
	
115
	/**
116
	 * Retrieves the father of the Metadata object, or null if it doesn't have.
117
	 * @return			a ExtendedMetadata object or null
118
	 */
119
	public ExtendedMetadata getFather();
120
	
121
	/**
122
	 * Changes father of the object
123
	 * @param 	father	the new father value of the ExtendedMetadata object
124
	 */
125
	public void setFather(ExtendedMetadata father); 
126
	
127
	/**
128
	 * Checks if the ExtendedMetadata has father
129
	 * @return			a boolean value which indicates if the object has father
130
	 */
131
	public boolean hasFather();
132
	
133
	/**
134
	 * Retrieves the deep level in the Metadata tree, 0 for the root.
135
	 * @return			an integer value which indicates the level.
136
	 */
137
	public int getLevel();
138
	
139
	/**
140
	 * Retrieves a Iterator to the Metadata elements.
141
	 * @return			an Iterator object.
142
	 */
143
	public Iterator iterator();
144
	
145
	/**
146
	 * Retrieves a String representing the Metadata object and its elements.
147
	 * @return			a String.
148
	 */
149
	public String toString();
150
}
tags/tmp_build/extensions/extMetadata/src/org/gvsig/metadata/extended/exchanger/XSLTExchanger.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.extended.exchanger;
32

  
33
import org.gvsig.metadata.extended.ExtendedMetadata;
34

  
35

  
36
public class XSLTExchanger implements MDExchanger {
37
	
38
	public XSLTExchanger() {}
39

  
40
	public String exportMD(ExtendedMetadata md, String format) {
41
		return "";
42
	}
43

  
44
	public ExtendedMetadata importMD(String file) {
45
		return null;
46
	}
47
	
48
}
tags/tmp_build/extensions/extMetadata/src/org/gvsig/metadata/extended/exchanger/MDExchangerConstants.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
*/
tags/tmp_build/extensions/extMetadata/src/org/gvsig/metadata/extended/exchanger/MDExchanger.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.extended.exchanger;
32

  
33
import org.gvsig.metadata.extended.ExtendedMetadata;
34

  
35

  
36
public interface MDExchanger {
37
	
38
	/**
39
	 * Creates a Metadata object from the data of a file
40
	 * @param 	filePath	the path of the file where the metadata is located
41
	 * @return				an object which implements the Metadata interface 
42
	 */
43
	public ExtendedMetadata importMD(String file);
44
	
45
	/**
46
	 * Transforms the metadata passed as a parameter from its current format to another one, also passed as a parameter
47
	 * @param 	md		the metadata is obtained from this Metadata object
48
	 * @param 	format	the format to which the metadata transformation is done  
49
	 * @return			a String containing the metadata of 'md' in the format chosen  
50
	 */
51
	public String exportMD(ExtendedMetadata md, String format);
52
}
tags/tmp_build/extensions/extMetadata/src/org/gvsig/metadata/extended/persistence/MDPersistence.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

  
32
package org.gvsig.metadata.extended.persistence;
33

  
34
import org.gvsig.metadata.extended.ExtendedMetadata;
35

  
36

  
37
public interface MDPersistence {
38
	public boolean storeMD(ExtendedMetadata md);
39
	public boolean queryMD(String s);
40
	public boolean recoverMD(ExtendedMetadata md);
41
}
tags/tmp_build/extensions/extMetadata/src/org/gvsig/metadata/extended/persistence/H2Persistence.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

  
32
package org.gvsig.metadata.extended.persistence;
33

  
34

  
35
import java.sql.Connection;
36
import java.sql.PreparedStatement;
37
import java.sql.ResultSet;
38
import java.sql.SQLException;
39

  
40
import org.gvsig.metadata.extended.ExtendedMetadata;
41
import org.gvsig.personaldb.PersonalDBLocator;
42

  
43

  
44
public class H2Persistence implements MDPersistence{
45
	
46
	Connection conn = null;
47
	
48
	public H2Persistence() {
49
		conn = PersonalDBLocator.getInstance().getPersonalDBManager().getConnection();
50
	}
51

  
52
	public boolean recoverMD(ExtendedMetadata md) {
53
		return false;
54
	}
55
	
56
	public boolean queryMD(String s) {
57
		
58
		String sql = "SELECT * FROM TEST";
59
		PreparedStatement prep;
60
		try {
61
			prep = conn.prepareStatement(sql);
62
			ResultSet rs = prep.executeQuery();
63
			while (rs.next()) {
64
				String id = rs.getString(1);
65
				String name = rs.getString(2);
66
				System.out.println("ID: " + id);
67
				System.out.println("NAME: " + name);
68
			}
69
		} catch (SQLException e) {
70
			// TODO Auto-generated catch block
71
			e.printStackTrace();
72
		}
73
		
74
		return false;
75
	}
76

  
77
	public boolean storeMD(ExtendedMetadata md) {
78
		return false;
79
	}
80

  
81
}
tags/tmp_build/extensions/extMetadata/src/org/gvsig/metadata/extended/ExtendedMDLibrary.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.extended;
32

  
33
import org.gvsig.metadata.MDLocator;
34
import org.gvsig.metadata.MDManager;
35
import org.gvsig.metadata.extended.manager.ExtendedMDManagerImpl;
36
import org.gvsig.tools.locator.BaseLibrary;
37
import org.gvsig.tools.locator.ReferenceNotRegisteredException;
38

  
39
public class ExtendedMDLibrary extends BaseLibrary {
40

  
41
	public void initialize() {
42
        super.initialize();
43
        MDLocator.registerMDManager(ExtendedMDManagerImpl.class);
44
    }
45
	
46
	public void postInitialize() {
47
        super.postInitialize();
48
        // COMPROBAR que se ha instalado la implementacion extended.
49
		MDManager manager = MDLocator.getMDManager();
50
        if ( !(manager instanceof ExtendedMDManagerImpl) ) {
51
        	System.out.println("Extended Metadata Implementation installation FAILED.");
52
        	throw new ReferenceNotRegisteredException(MDLocator.METADATA_MANAGER_NAME, MDLocator.getInstance());
53
        }
54
        
55
        // INICIALIZAR Base de Datos
56
	}
57
	
58
}
tags/tmp_build/extensions/extMetadata/src/org/gvsig/metadata/extended/registry/MDRegistry.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

  
32

  
33
package org.gvsig.metadata.extended.registry;
34

  
35
import org.gvsig.metadata.extended.registry.objects.MDElementDefinition;
36
import org.gvsig.metadata.extended.registry.objects.MDType;
37

  
38

  
39

  
40
public interface MDRegistry {
41
	
42
	public MDElementDefinition getMDDefinition(String name);
43
	public MDElementDefinition getMDElementDefinition(String name);
44
	public MDType getMDType(String name);
45
	public boolean setMDDefinition(MDElementDefinition padre, String name, String description);
46
	public boolean setMDElementDefinition(MDElementDefinition padre, String description, MDType type /* ...*/);
47
	public boolean setMDType(/* ...*/);
48
	
49
}
tags/tmp_build/extensions/extMetadata/src/org/gvsig/metadata/extended/registry/objects/MDElementDefinition.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

  
32

  
33
package org.gvsig.metadata.extended.registry.objects;
34

  
35
import java.util.HashMap;
36
import java.util.Map;
37

  
38

  
39
public class MDElementDefinition {
40
	
41
	private String name;
42
	private MDType type;
43
	private Boolean required;
44
	private Object defaultValue;
45
	private String description;
46
	private Map<String, Object> synonyms = new HashMap<String, Object>();
47
	
48
	public MDElementDefinition() {}
49
	
50
	public MDElementDefinition(String name, MDType type, Boolean required, Object defaultValue, String description) {
51
		this.name = name;
52
		this.type = type;
53
		this.required = required;
54
		this.defaultValue = defaultValue;
55
		this.description = description;
56
	}
57
	
58
	public String getName() {
59
		return this.name;
60
	}
61
	
62
	public MDType getType() {
63
		return this.type;
64
	}
65
	
66
	public Boolean isRequired() {
67
		return this.required;
68
	}
69
	
70
	public Object getDefaultValue() {
71
		return this.defaultValue;
72
	}
73
	
74
	public String getDescription() {
75
		return this.description;
76
	}
77
	
78
	public Object getSynonym(String name) {
79
		return synonyms.get(name);
80
	}
81
	
82
	public void setName(String name) {
83
		this.name = name;
84
	}
85
	
86
	public void setType(MDType type) {
87
		this.type = type;
88
	}
89
	
90
	public void setRequired(Boolean required) {
91
		this.required = required;
92
	}
93
	
94
	public void setDefaultValue(Object defaultValue) {
95
		this.defaultValue = defaultValue;
96
	}
97
	
98
	public void setDescription(String description) {
99
		this.description = description;
100
	}
101
	
102
	public void setSynonym(String name, Object synonym) {
103
		synonyms.put(name, synonym);
104
	}
105
}
tags/tmp_build/extensions/extMetadata/src/org/gvsig/metadata/extended/registry/objects/MDDefinition.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

  
32
package org.gvsig.metadata.extended.registry.objects;
33

  
34

  
35
public class MDDefinition {
36
	private String name;
37
	private String description;
38
	
39
	public MDDefinition() {}
40
	
41
	public MDDefinition(String name, String description) {
42
		this.name = name;
43
		this.description = description;
44
	}
45
	
46
	public String getName() {
47
		return this.name;
48
	}
49

  
50
	public String getDescription() {
51
		return this.description;
52
	}
53

  
54
	public void setName(String name) {
55
		this.name = name;
56
	}
57
	
58
	public void setDescription(String description) {
59
		this.description = description;
60
	}
61

  
62
}
tags/tmp_build/extensions/extMetadata/src/org/gvsig/metadata/extended/registry/objects/MDType.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

  
32

  
33
package org.gvsig.metadata.extended.registry.objects;
34

  
35
import java.sql.Types;
36

  
37
public class MDType {
38
	private String id;
39
	private String name;
40
	private Types type;
41
	
42
	public MDType() {}
43
	
44
	public MDType(String name, Types type) {
45
		this.name = name;
46
		this.type = type;
47
	}
48

  
49
	public String getName() {
50
		return name;
51
	}
52

  
53
	public void setName(String name) {
54
		this.name = name;
55
	}
56

  
57
	public Types getType() {
58
		return type;
59
	}
60

  
61
	public void setType(Types type) {
62
		this.type = type;
63
	}
64
	
65
	
66
}
tags/tmp_build/extensions/extMetadata/src/org/gvsig/metadata/extended/registry/MDRegistryImpl.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

  
32
package org.gvsig.metadata.extended.registry;
33

  
34

  
35
import org.gvsig.metadata.extended.registry.objects.MDElementDefinition;
36
import org.gvsig.metadata.extended.registry.objects.MDType;
37

  
38

  
39
public class MDRegistryImpl implements MDRegistry {
40

  
41
	public MDElementDefinition getMDDefinition(String name) {
42
		return null;
43
	}
44

  
45
	public MDElementDefinition getMDElementDefinition(String name) {
46
		return null;
47
	}
48

  
49
	public MDType getMDType(String name) {
50
		return null;
51
	}
52

  
53
	public boolean setMDDefinition(MDElementDefinition padre, String name, String description) {
54
		return false;
55
	}
56

  
57
	public boolean setMDElementDefinition(MDElementDefinition padre, String description, MDType type) {
58
		return false;
59
	}
60

  
61
	public boolean setMDType() {
62
		return false;
63
	}
64

  
65
	
66
	
67
}
tags/tmp_build/extensions/extMetadata/src/org/gvsig/metadata/extended/MDElement.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.extended;
32

  
33
import java.util.Locale;
34

  
35
import org.gvsig.metadata.extended.registry.objects.MDElementDefinition;
36

  
37
public interface MDElement {
38
	
39
	/**
40
	 * Retrieves the identifier of the MDElement object
41
	 * @return	a String which identifies the object 
42
	 */
43
	public String getId();
44
	
45
	/**
46
	 * Retrieves the value of the MDElement object
47
	 * @return	an Object containing the value of the object
48
	 */
49
	public Object getValue();
50
	
51
	/**
52
	 * Retrieves the type of the MDElement object
53
	 * @return	a MDElementDefinition object containing data about the object
54
	 */
55
	public MDElementDefinition getType();
56
	
57
	/**
58
	 * Retrieves the Locale value of the MDElement object
59
	 * @return	a Locale object which represents a specific geographical, political or cultural region
60
	 */
61
	public Locale getLocale();
62
	
63
	/**
64
	 * Retrieves the MDElement name using its MDElementDefinition
65
	 * @return	the name of the MDElement object
66
	 */
67
	public String getName();
68
	
69
	/**
70
	 * Retrieves the father of the Metadata object, or null if it doesn't have.
71
	 * @return			a ExtendedMetadata object or null
72
	 */
73
	public Object getFather();
74
	
75
	/**
76
	 * Changes the identifier of the object
77
	 * @param 	id	the new identifier of the MDElement object
78
	 */
79
	public void setId(String id);
80
	
81
	/**
82
	 * Changes the value of the object
83
	 * @param 	value	the new value of the MDElement object
84
	 */
85
	public void setValue(Object value);
86
	
87
	/**
88
	 * Changes the type of the object
89
	 * @param 	type	the new type of the MDElement object
90
	 */
91
	public void setType(MDElementDefinition type);
92
	
93
	/**
94
	 * Changes the Locale value of the object
95
	 * @param 	locale	the new Locale value of the MDElement object
96
	 */
97
	public void setLocale(Locale locale); 
98
	
99
	/**
100
	 * Changes father of the object
101
	 * @param 	father	the new father value of the MDElement object
102
	 */
103
	public void setFather(Object father); 
104
	
105
	/**
106
	 * Checks if the ExtendedMetadata has father
107
	 * @return			a boolean value which indicates if the object has father
108
	 */
109
	public boolean hasFather();
110
	
111
	/**
112
	 * Retrieves the deep level in the Metadata tree, 0 for the root.
113
	 * @return			an integer value which indicates the level.
114
	 */
115
	public int getLevel();
116
	
117
	/**
118
	 * Retrieves a String representing the Element object and its value.
119
	 * @return			a String.
120
	 */
121
	public String toString();
122
	
123
}
tags/tmp_build/extensions/extMetadata/src/org/gvsig/metadata/extended/manager/ExtendedMetadataImpl.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

  
32

  
33
package org.gvsig.metadata.extended.manager;
34

  
35
import java.util.Date;
36
import java.util.Iterator;
37
import java.util.LinkedHashMap;
38
import java.util.Map;
39

  
40
import org.gvsig.metadata.exceptions.NamedMetadataNotFoundException;
41
import org.gvsig.metadata.extended.ExtendedMetadata;
42
import org.gvsig.metadata.extended.MDElement;
43
import org.gvsig.metadata.extended.registry.objects.MDDefinition;
44

  
45

  
46
public class ExtendedMetadataImpl implements ExtendedMetadata {
47
	
48
	private String id;
49
	private Date createDate;
50
	private Date changeDate;
51
	private MDDefinition type;
52
	private String author;
53
	private Map<String, MDElement> elements = new LinkedHashMap<String, MDElement>();	
54
	private ExtendedMetadata father;
55
	
56
	
57
	
58
	
59
	public ExtendedMetadataImpl(String name) {
60
		this.type = new MDDefinition();
61
		this.type.setName(name);
62
		this.createDate = new Date();
63
		this.changeDate = null;
64
		this.father = null;
65
	}
66
	
67
	public ExtendedMetadataImpl(MDDefinition type, String author) {
68
		this.createDate = new Date();
69
		this.changeDate = null;
70
		this.type = type;
71
		this.author = author;
72
		this.father = null;
73
	}
74
	
75
	public Object get(String name) throws NamedMetadataNotFoundException {
76
		if(!hasValue(name))
77
			throw new NamedMetadataNotFoundException(this.getClass());
78
		return ((MDElement) elements.get(name)).getValue();
79
	}
80

  
81
	public boolean getBoolean(String name) throws ClassCastException, NamedMetadataNotFoundException {
82
		if(!hasValue(name))
83
			throw new NamedMetadataNotFoundException(this.getClass());
84
		return ((Boolean) ((MDElement) elements.get(name)).getValue()).booleanValue();
85
	}
86

  
87
	public double getDouble(String name) throws ClassCastException, NamedMetadataNotFoundException {
88
		if(!hasValue(name))
89
			throw new NamedMetadataNotFoundException(this.getClass());
90
		return ((Double)((MDElement) elements.get(name)).getValue()).doubleValue();
91
	}
92

  
93
	public int getInt(String name) throws ClassCastException, NamedMetadataNotFoundException {
94
		if(!hasValue(name))
95
			throw new NamedMetadataNotFoundException(this.getClass());
96
		return ((Integer)((MDElement) elements.get(name)).getValue()).intValue();
97
	}
98
	
99
	public String getString(String name) throws ClassCastException, NamedMetadataNotFoundException {
100
		if(!hasValue(name))
101
			throw new NamedMetadataNotFoundException(this.getClass());
102
		return (String)((MDElement) elements.get(name)).getValue().toString();
103
	}
104

  
105
	public Date getDate(String name) throws ClassCastException, NamedMetadataNotFoundException {
106
		if(!hasValue(name))
107
			throw new NamedMetadataNotFoundException(this.getClass());
108
		return (Date)((MDElement) elements.get(name)).getValue();
109
	}
110
	
111
	public MDElement getElement(String idElem) throws ClassCastException, NamedMetadataNotFoundException {
112
		if(!hasValue(idElem))
113
			throw new NamedMetadataNotFoundException(this.getClass());
114
		return (MDElement) elements.get(idElem);
115
	}
116
	
117
	public String getId() {
118
		return this.id;
119
	}
120
	
121
	public String getName() {
122
		return this.type.getName();
123
	}
124
	
125
	public String getDescription() {
126
		return this.type.getDescription();
127
	}
128
	
129
	public Date getCreateDate() {
130
		return this.createDate;
131
	}
132
	
133
	public Date getChangeDate() {
134
		return this.changeDate;
135
	}
136
	
137
	public MDDefinition getType() {
138
		return this.type;
139
	}
140
	
141
	public String getAuthor() {
142
		return this.author;
143
	}
144
	
145
	public void set(String name, Object value) {
146
		if(value instanceof Boolean)
147
			setBoolean(name, (Boolean)value);
148
		else if(value instanceof Date)
149
			setDate(name, (Date)value);
150
		else if(value instanceof Double)
151
			setDouble(name, (Double)value);
152
		else if(value instanceof Integer)
153
			setInt(name, (Integer)value);
154
		else if(value instanceof String)
155
			setString(name, (String)value);
156
		else {
157
			MDElement mde = new MDElementImpl(value, name, null);
158
			elements.put(name, mde);
159
		}
160
	}
161
	
162
	public void setBoolean(String name, boolean value) {
163
		MDElement mde = new MDElementImpl(Boolean.valueOf(value), name, null);
164
		elements.put(name, mde);
165
		mde.setFather(this);
166
	}
167

  
168
	public void setDate(String name, Date value) {
169
		MDElement mde = new MDElementImpl(value, name, null);
170
		elements.put(name, mde);
171
		mde.setFather(this);
172
	}
173

  
174
	public void setDouble(String name, double value) {
175
		MDElement mde = new MDElementImpl(Double.valueOf(value), name, null);
176
		elements.put(name, mde);
177
		mde.setFather(this);
178
	}
179

  
180
	public void setInt(String name, int value) {
181
		MDElement mde = new MDElementImpl(Integer.valueOf(value), name, null);
182
		elements.put(name, mde);
183
		mde.setFather(this);
184
	}
185

  
186
	public void setString(String name, String value) {
187
		MDElement mde = new MDElementImpl(value, name, null);
188
		elements.put(name, mde);
189
		mde.setFather(this);
190
	}
191
	
192
	public void setElement(MDElement elem) {
193
		String idElem = elem.getName();
194
		elements.put(idElem, elem);
195
		elem.setFather(this);
196
	}
197
	
198
	public void setId(String id) {
199
		this.id = id;
200
		setChangeDate();
201
	}
202
	
203
	public void setName(String name) {
204
		this.type.setName(name);
205
	}
206
	
207
	public void setDescription(String desc) {
208
		this.type.setDescription(desc);
209
	}
210
	
211
	public void setChangeDate() {
212
		this.changeDate = new Date();
213
	}
214
	
215
	public void setType(MDDefinition type) {
216
		this.type = type;
217
		setChangeDate();
218
	}
219

  
220
	public boolean hasValue(String id) {
221
		return elements.containsKey(id);
222
	}
223
	
224
	public boolean isEmpty() {
225
		return elements.isEmpty();
226
	}
227

  
228
	/**
229
	 * @return the father
230
	 */
231
	public ExtendedMetadata getFather() {
232
		return father;
233
	}
234

  
235
	/**
236
	 * @param father the father to set
237
	 */
238
	public void setFather(ExtendedMetadata father) {
239
		this.father = father;
240
	}
241
	
242
	public boolean hasFather() {
243
		return (father != null);
244
	}
245
	
246
	public int getLevel() {
247
		if(!this.hasFather())
248
			return 0;
249
		else
250
			return 1 + this.getFather().getLevel();
251
	}
252
	
253
	public Iterator iterator() {
254
		return elements.entrySet().iterator();
255
	}
256
	
257
	public String toString() {
258
		String aux = "<MD_Metadata>";
259
		Iterator it = iterator();
260
		while (it.hasNext()) {
261
			Map.Entry e = (Map.Entry)it.next();
262
			aux += e.getValue().toString();
263
		}
264
		aux += "</MD_Metadata>";
265
		return aux;
266
	}
267
	
268
}
tags/tmp_build/extensions/extMetadata/src/org/gvsig/metadata/extended/manager/MDElementImpl.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

  
32

  
33
package org.gvsig.metadata.extended.manager;
34

  
35
import java.util.Locale;
36

  
37
import org.gvsig.metadata.extended.ExtendedMetadata;
38
import org.gvsig.metadata.extended.MDElement;
39
import org.gvsig.metadata.extended.registry.objects.MDElementDefinition;
40

  
41

  
42
public class MDElementImpl implements MDElement{
43
	
44
	private String id;
45
	private String name = "";
46
	private Object value;
47
	private MDElementDefinition type = null;
48
	private Locale locale;
49
	
50
	private Object father;
51

  
52

  
53
	public MDElementImpl() {}
54
	
55
	public MDElementImpl(Object value, MDElementDefinition type, Locale locale) {
56
		//this.id = id; Que poner como ID???
57
		this.value = value;
58
		this.type = type;
59
		this.locale = locale;
60
	}
61
	
62
	public MDElementImpl(Object value, String name, Locale locale) {
63
		//this.id = id; Que poner como ID???
64
		this.value = value;
65
		this.name = name;
66
		this.locale = locale;
67
	}
68
	
69
	public String getId() {
70
		return this.id;
71
	}
72
	
73
	public Object getValue() {
74
		return this.value;
75
	}
76
	
77
	public MDElementDefinition getType() {
78
		return this.type;
79
	}
80
	
81
	public Locale getLocale() {
82
		return this.locale;
83
	}
84
	
85
	public void setId(String id) {
86
		this.id = id;
87
	}
88
	
89
	public void setValue(Object value) {
90
		this.value = value;
91
	}
92
	
93
	public void setType(MDElementDefinition type) {
94
		this.type = type;
95
	}
96
	
97
	public void setLocale(Locale locale) {
98
		this.locale = locale;
99
	}
100
	
101
	public String getName() {
102
		if(this.type != null)
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff