root / branches / v2_0_0_prep / libraries / libFMap_dal / src / org / gvsig / fmap / dal / feature / AbstractFeatureStoreTransform.java @ 38608
History | View | Annotate | Download (4.54 KB)
1 | 24613 | 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 | 31186 | jpiera | import org.gvsig.tools.ToolsLocator; |
8 | 37496 | jjdelcerro | import org.gvsig.tools.dynobject.DynObject; |
9 | 32880 | jjdelcerro | import org.gvsig.tools.dynobject.DynStruct; |
10 | 37496 | jjdelcerro | import org.gvsig.tools.dynobject.exception.DynFieldNotFoundException; |
11 | 36450 | jpiera | import org.gvsig.tools.persistence.PersistenceManager; |
12 | 31186 | jpiera | import org.gvsig.tools.persistence.PersistentState; |
13 | 32880 | jjdelcerro | import org.gvsig.tools.persistence.exception.PersistenceException; |
14 | 24613 | jjdelcerro | |
15 | 25818 | jiyarza | /**
|
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 | 36632 | jpiera | * 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 | 25818 | jiyarza | */
|
27 | 24613 | jjdelcerro | public abstract class AbstractFeatureStoreTransform implements |
28 | 31186 | jpiera | FeatureStoreTransform { |
29 | 37496 | jjdelcerro | public static final String METADATA_DEFINITION_NAME = "FeatureStoreTransform"; |
30 | 31186 | jpiera | public static final String ABSTRACT_FEATURESTORE_DYNCLASS_NAME = "AbstractFeatureStoreTransform"; |
31 | 25798 | jmvivo | |
32 | 25407 | jiyarza | private FeatureStore store;
|
33 | 24613 | jjdelcerro | |
34 | 25568 | jjdelcerro | private FeatureType defaultFeatureType = null; |
35 | private List featureTypes = new ArrayList(); |
||
36 | 24613 | jjdelcerro | |
37 | 35739 | nfrancisco | protected String name; |
38 | |||
39 | protected String descripcion; |
||
40 | |||
41 | 37496 | jjdelcerro | private DynObject originalMetadata = null; |
42 | |||
43 | 35739 | nfrancisco | |
44 | public AbstractFeatureStoreTransform() {
|
||
45 | 37496 | jjdelcerro | this(null, ""); |
46 | 35739 | nfrancisco | } |
47 | |||
48 | public AbstractFeatureStoreTransform(String name, String description) { |
||
49 | if( name == null || "".equals(name) ) { |
||
50 | this.name = this.getClass().getSimpleName(); |
||
51 | } else {
|
||
52 | this.name = name;
|
||
53 | } |
||
54 | this.descripcion = description;
|
||
55 | 37496 | jjdelcerro | |
56 | 35739 | nfrancisco | } |
57 | |||
58 | public String getDescription() { |
||
59 | return this.descripcion; |
||
60 | } |
||
61 | |||
62 | public String getName() { |
||
63 | return this.name; |
||
64 | } |
||
65 | |||
66 | 24613 | jjdelcerro | public FeatureType getDefaultFeatureType() throws DataException { |
67 | return defaultFeatureType;
|
||
68 | } |
||
69 | |||
70 | public List getFeatureTypes() throws DataException { |
||
71 | return featureTypes;
|
||
72 | } |
||
73 | |||
74 | 25407 | jiyarza | public void setFeatureStore(FeatureStore store) { |
75 | this.store = store;
|
||
76 | } |
||
77 | 25798 | jmvivo | |
78 | 25407 | jiyarza | public FeatureStore getFeatureStore() {
|
79 | return store;
|
||
80 | } |
||
81 | 25798 | jmvivo | |
82 | protected void setFeatureTypes(List types, FeatureType defaultType) { |
||
83 | this.featureTypes.clear();
|
||
84 | this.featureTypes.addAll(types);
|
||
85 | this.defaultFeatureType = defaultType;
|
||
86 | 25568 | jjdelcerro | } |
87 | 25798 | jmvivo | |
88 | 31186 | jpiera | public static void registerPersistent() { |
89 | 36450 | jpiera | PersistenceManager persistenceManager = ToolsLocator.getPersistenceManager(); |
90 | DynStruct definition = persistenceManager.getDefinition(ABSTRACT_FEATURESTORE_DYNCLASS_NAME); |
||
91 | 31186 | jpiera | |
92 | 36450 | jpiera | 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 | 31186 | jpiera | } |
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 | 36632 | jpiera | state.set("store", store);
|
113 | 31186 | jpiera | } |
114 | 37496 | jjdelcerro | |
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 | 24613 | jjdelcerro | } |