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 @ 40435
History | View | Annotate | Download (4.63 KB)
1 | 40435 | jjdelcerro | package org.gvsig.fmap.dal.feature; |
---|---|---|---|
2 | |||
3 | import java.util.ArrayList; |
||
4 | import java.util.List; |
||
5 | |||
6 | import org.gvsig.fmap.dal.exception.DataException; |
||
7 | import org.gvsig.tools.ToolsLocator; |
||
8 | import org.gvsig.tools.dynobject.DynObject; |
||
9 | import org.gvsig.tools.dynobject.DynStruct; |
||
10 | import org.gvsig.tools.dynobject.exception.DynFieldNotFoundException; |
||
11 | import org.gvsig.tools.persistence.PersistenceManager; |
||
12 | import org.gvsig.tools.persistence.PersistentState; |
||
13 | import org.gvsig.tools.persistence.exception.PersistenceException; |
||
14 | |||
15 | /**
|
||
16 | * Abstract feature store transform intended for giving a partial default implementation
|
||
17 | * of the {@link FeatureStoreTransform} interface to other transform implementations. It is recommended
|
||
18 | * to extend this class when implementing new {@link FeatureStoreTransform}s.
|
||
19 | *
|
||
20 | * The {@link FeatureType} of this class is not persistent: it has to be generated
|
||
21 | * by the child implementations of this abstract class when they are created
|
||
22 | * using the persistence mechanism.
|
||
23 | *
|
||
24 | * @author gvSIG team
|
||
25 | * @version $Id$
|
||
26 | */
|
||
27 | public abstract class AbstractFeatureStoreTransform implements |
||
28 | FeatureStoreTransform { |
||
29 | public static final String METADATA_DEFINITION_NAME = "FeatureStoreTransform"; |
||
30 | public static final String ABSTRACT_FEATURESTORE_DYNCLASS_NAME = "AbstractFeatureStoreTransform"; |
||
31 | |||
32 | private FeatureStore store;
|
||
33 | |||
34 | private FeatureType defaultFeatureType = null; |
||
35 | private List featureTypes = new ArrayList(); |
||
36 | |||
37 | protected String name; |
||
38 | |||
39 | protected String descripcion; |
||
40 | |||
41 | private DynObject originalMetadata = null; |
||
42 | |||
43 | |||
44 | public AbstractFeatureStoreTransform() {
|
||
45 | this(null, ""); |
||
46 | } |
||
47 | |||
48 | public AbstractFeatureStoreTransform(String name, String description) { |
||
49 | if( name == null || "".equals(name) ) { |
||
50 | this.name = this.getClass().getName(); |
||
51 | } else {
|
||
52 | this.name = name;
|
||
53 | } |
||
54 | this.descripcion = description;
|
||
55 | |||
56 | } |
||
57 | |||
58 | public String getDescription() { |
||
59 | return this.descripcion; |
||
60 | } |
||
61 | |||
62 | public String getName() { |
||
63 | return this.name; |
||
64 | } |
||
65 | |||
66 | public FeatureType getDefaultFeatureType() throws DataException { |
||
67 | return defaultFeatureType;
|
||
68 | } |
||
69 | |||
70 | public List getFeatureTypes() throws DataException { |
||
71 | return featureTypes;
|
||
72 | } |
||
73 | |||
74 | public void setFeatureStore(FeatureStore store) { |
||
75 | this.store = store;
|
||
76 | } |
||
77 | |||
78 | public FeatureStore getFeatureStore() {
|
||
79 | return store;
|
||
80 | } |
||
81 | |||
82 | protected void setFeatureTypes(List types, FeatureType defaultType) { |
||
83 | this.featureTypes.clear();
|
||
84 | this.featureTypes.addAll(types);
|
||
85 | this.defaultFeatureType = defaultType;
|
||
86 | } |
||
87 | |||
88 | public static void registerPersistent() { |
||
89 | PersistenceManager persistenceManager = ToolsLocator.getPersistenceManager(); |
||
90 | DynStruct definition = persistenceManager.getDefinition(ABSTRACT_FEATURESTORE_DYNCLASS_NAME); |
||
91 | |||
92 | if (definition == null){ |
||
93 | definition = persistenceManager.addDefinition( |
||
94 | AbstractFeatureStoreTransform.class, |
||
95 | ABSTRACT_FEATURESTORE_DYNCLASS_NAME, |
||
96 | "AbstractFeatureStoreTransform Persistent definition",
|
||
97 | null,
|
||
98 | null
|
||
99 | ); |
||
100 | |||
101 | definition.addDynFieldObject("store")
|
||
102 | .setClassOfValue(FeatureStore.class) |
||
103 | .setMandatory(true);
|
||
104 | } |
||
105 | } |
||
106 | |||
107 | public void loadFromState(PersistentState state) throws PersistenceException { |
||
108 | this.store = (FeatureStore) state.get("store"); |
||
109 | } |
||
110 | |||
111 | public void saveToState(PersistentState state) throws PersistenceException { |
||
112 | state.set("store", store);
|
||
113 | } |
||
114 | |||
115 | |||
116 | public final void setSourceMetadata(DynObject metadata) { |
||
117 | this.originalMetadata = metadata;
|
||
118 | } |
||
119 | |||
120 | protected DynObject getSourceMetadata() {
|
||
121 | return this.originalMetadata; |
||
122 | } |
||
123 | |||
124 | /**
|
||
125 | * Get the metadata value for the name <code>name</code>.
|
||
126 | *
|
||
127 | * Overwrite this method to support that this transform overwrite the values
|
||
128 | * of the statore's metadata.
|
||
129 | *
|
||
130 | * @see {#Metadata.getDynValue}
|
||
131 | */
|
||
132 | public Object getDynValue(String name) throws DynFieldNotFoundException { |
||
133 | throw new DynFieldNotFoundException(name, "transform"); |
||
134 | } |
||
135 | |||
136 | /**
|
||
137 | * Return true is the value <code>name</name> has a value in the metadata
|
||
138 | *
|
||
139 | * Overwrite this method to support that this transform overwrite the values
|
||
140 | * of the statore's metadata.
|
||
141 | *
|
||
142 | * @see {#Metadata.hasDynValue}
|
||
143 | */
|
||
144 | public boolean hasDynValue(String name) { |
||
145 | return false; |
||
146 | } |
||
147 | |||
148 | /**
|
||
149 | * Set the value of a metadata.
|
||
150 | *
|
||
151 | * Overwrite this method to support that this transform overwrite the values
|
||
152 | * of the statore's metadata.
|
||
153 | *
|
||
154 | * @see {#Metadata.getDynValue}
|
||
155 | */
|
||
156 | public void setDynValue(String name, Object value) |
||
157 | throws DynFieldNotFoundException {
|
||
158 | throw new DynFieldNotFoundException(name, "transform"); |
||
159 | } |
||
160 | |||
161 | |||
162 | public Object clone() throws CloneNotSupportedException { |
||
163 | return super.clone(); |
||
164 | |||
165 | } |
||
166 | |||
167 | } |