svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.api / src / main / java / org / gvsig / fmap / dal / feature / AbstractFeatureStoreTransform.java @ 40559
History | View | Annotate | Download (5.57 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.fmap.dal.feature; |
25 |
|
26 |
import java.util.ArrayList; |
27 |
import java.util.List; |
28 |
|
29 |
import org.gvsig.fmap.dal.exception.DataException; |
30 |
import org.gvsig.tools.ToolsLocator; |
31 |
import org.gvsig.tools.dynobject.DynObject; |
32 |
import org.gvsig.tools.dynobject.DynStruct; |
33 |
import org.gvsig.tools.dynobject.exception.DynFieldNotFoundException; |
34 |
import org.gvsig.tools.persistence.PersistenceManager; |
35 |
import org.gvsig.tools.persistence.PersistentState; |
36 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
37 |
|
38 |
/**
|
39 |
* Abstract feature store transform intended for giving a partial default implementation
|
40 |
* of the {@link FeatureStoreTransform} interface to other transform implementations. It is recommended
|
41 |
* to extend this class when implementing new {@link FeatureStoreTransform}s.
|
42 |
*
|
43 |
* The {@link FeatureType} of this class is not persistent: it has to be generated
|
44 |
* by the child implementations of this abstract class when they are created
|
45 |
* using the persistence mechanism.
|
46 |
*
|
47 |
* @author gvSIG team
|
48 |
* @version $Id$
|
49 |
*/
|
50 |
public abstract class AbstractFeatureStoreTransform implements |
51 |
FeatureStoreTransform { |
52 |
public static final String METADATA_DEFINITION_NAME = "FeatureStoreTransform"; |
53 |
public static final String ABSTRACT_FEATURESTORE_DYNCLASS_NAME = "AbstractFeatureStoreTransform"; |
54 |
|
55 |
private FeatureStore store;
|
56 |
|
57 |
private FeatureType defaultFeatureType = null; |
58 |
private List featureTypes = new ArrayList(); |
59 |
|
60 |
protected String name; |
61 |
|
62 |
protected String descripcion; |
63 |
|
64 |
private DynObject originalMetadata = null; |
65 |
|
66 |
|
67 |
public AbstractFeatureStoreTransform() {
|
68 |
this(null, ""); |
69 |
} |
70 |
|
71 |
public AbstractFeatureStoreTransform(String name, String description) { |
72 |
if( name == null || "".equals(name) ) { |
73 |
this.name = this.getClass().getName(); |
74 |
} else {
|
75 |
this.name = name;
|
76 |
} |
77 |
this.descripcion = description;
|
78 |
|
79 |
} |
80 |
|
81 |
public String getDescription() { |
82 |
return this.descripcion; |
83 |
} |
84 |
|
85 |
public String getName() { |
86 |
return this.name; |
87 |
} |
88 |
|
89 |
public FeatureType getDefaultFeatureType() throws DataException { |
90 |
return defaultFeatureType;
|
91 |
} |
92 |
|
93 |
public List getFeatureTypes() throws DataException { |
94 |
return featureTypes;
|
95 |
} |
96 |
|
97 |
public void setFeatureStore(FeatureStore store) { |
98 |
this.store = store;
|
99 |
} |
100 |
|
101 |
public FeatureStore getFeatureStore() {
|
102 |
return store;
|
103 |
} |
104 |
|
105 |
protected void setFeatureTypes(List types, FeatureType defaultType) { |
106 |
this.featureTypes.clear();
|
107 |
this.featureTypes.addAll(types);
|
108 |
this.defaultFeatureType = defaultType;
|
109 |
} |
110 |
|
111 |
public static void registerPersistent() { |
112 |
PersistenceManager persistenceManager = ToolsLocator.getPersistenceManager(); |
113 |
DynStruct definition = persistenceManager.getDefinition(ABSTRACT_FEATURESTORE_DYNCLASS_NAME); |
114 |
|
115 |
if (definition == null){ |
116 |
definition = persistenceManager.addDefinition( |
117 |
AbstractFeatureStoreTransform.class, |
118 |
ABSTRACT_FEATURESTORE_DYNCLASS_NAME, |
119 |
"AbstractFeatureStoreTransform Persistent definition",
|
120 |
null,
|
121 |
null
|
122 |
); |
123 |
|
124 |
definition.addDynFieldObject("store")
|
125 |
.setClassOfValue(FeatureStore.class) |
126 |
.setMandatory(true);
|
127 |
} |
128 |
} |
129 |
|
130 |
public void loadFromState(PersistentState state) throws PersistenceException { |
131 |
this.store = (FeatureStore) state.get("store"); |
132 |
} |
133 |
|
134 |
public void saveToState(PersistentState state) throws PersistenceException { |
135 |
state.set("store", store);
|
136 |
} |
137 |
|
138 |
|
139 |
public final void setSourceMetadata(DynObject metadata) { |
140 |
this.originalMetadata = metadata;
|
141 |
} |
142 |
|
143 |
protected DynObject getSourceMetadata() {
|
144 |
return this.originalMetadata; |
145 |
} |
146 |
|
147 |
/**
|
148 |
* Get the metadata value for the name <code>name</code>.
|
149 |
*
|
150 |
* Overwrite this method to support that this transform overwrite the values
|
151 |
* of the statore's metadata.
|
152 |
*
|
153 |
* @see {#Metadata.getDynValue}
|
154 |
*/
|
155 |
public Object getDynValue(String name) throws DynFieldNotFoundException { |
156 |
throw new DynFieldNotFoundException(name, "transform"); |
157 |
} |
158 |
|
159 |
/**
|
160 |
* Return true is the value <code>name</name> has a value in the metadata
|
161 |
*
|
162 |
* Overwrite this method to support that this transform overwrite the values
|
163 |
* of the statore's metadata.
|
164 |
*
|
165 |
* @see {#Metadata.hasDynValue}
|
166 |
*/
|
167 |
public boolean hasDynValue(String name) { |
168 |
return false; |
169 |
} |
170 |
|
171 |
/**
|
172 |
* Set the value of a metadata.
|
173 |
*
|
174 |
* Overwrite this method to support that this transform overwrite the values
|
175 |
* of the statore's metadata.
|
176 |
*
|
177 |
* @see {#Metadata.getDynValue}
|
178 |
*/
|
179 |
public void setDynValue(String name, Object value) |
180 |
throws DynFieldNotFoundException {
|
181 |
throw new DynFieldNotFoundException(name, "transform"); |
182 |
} |
183 |
|
184 |
|
185 |
public Object clone() throws CloneNotSupportedException { |
186 |
return super.clone(); |
187 |
|
188 |
} |
189 |
|
190 |
} |