Revision 43215 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
AbstractFeatureStoreTransform.java | ||
---|---|---|
25 | 25 |
|
26 | 26 |
import java.util.ArrayList; |
27 | 27 |
import java.util.List; |
28 |
import org.apache.commons.lang3.StringUtils; |
|
28 | 29 |
|
29 | 30 |
import org.gvsig.fmap.dal.exception.DataException; |
30 | 31 |
import org.gvsig.tools.ToolsLocator; |
... | ... | |
36 | 37 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
37 | 38 |
|
38 | 39 |
/** |
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 |
* |
|
40 |
* Abstract feature store transform intended for giving a partial default |
|
41 |
* implementation of the {@link FeatureStoreTransform} interface to other |
|
42 |
* transform implementations. It is recommended to extend this class when |
|
43 |
* implementing new {@link FeatureStoreTransform}s. |
|
44 |
* |
|
45 |
* The {@link FeatureType} of this class is not persistent: it has to be |
|
46 |
* generated by the child implementations of this abstract class when they are |
|
47 |
* created using the persistence mechanism. |
|
48 |
* |
|
47 | 49 |
* @author gvSIG team |
48 | 50 |
* @version $Id$ |
49 | 51 |
*/ |
50 |
public abstract class AbstractFeatureStoreTransform implements |
|
51 |
FeatureStoreTransform { |
|
52 |
public abstract class AbstractFeatureStoreTransform |
|
53 |
implements |
|
54 |
FeatureStoreTransform { |
|
55 |
|
|
52 | 56 |
public static final String METADATA_DEFINITION_NAME = "FeatureStoreTransform"; |
53 |
public static final String ABSTRACT_FEATURESTORE_DYNCLASS_NAME = "AbstractFeatureStoreTransform";
|
|
57 |
public static final String ABSTRACT_FEATURESTORE_DYNCLASS_NAME = "AbstractFeatureStoreTransform";
|
|
54 | 58 |
|
55 |
private FeatureStore store;
|
|
59 |
private FeatureStore store;
|
|
56 | 60 |
|
57 |
private FeatureType defaultFeatureType = null;
|
|
58 |
private List featureTypes = new ArrayList();
|
|
61 |
private FeatureType defaultFeatureType = null;
|
|
62 |
private List featureTypes = new ArrayList();
|
|
59 | 63 |
|
60 | 64 |
protected String name; |
61 | 65 |
|
... | ... | |
63 | 67 |
|
64 | 68 |
private DynObject originalMetadata = null; |
65 | 69 |
|
66 |
|
|
67 | 70 |
public AbstractFeatureStoreTransform() { |
68 | 71 |
this(null, ""); |
69 | 72 |
} |
70 | 73 |
|
71 | 74 |
public AbstractFeatureStoreTransform(String name, String description) { |
72 |
if( name == null || "".equals(name) ) {
|
|
75 |
if( StringUtils.isEmpty(name) ) {
|
|
73 | 76 |
this.name = this.getClass().getName(); |
74 | 77 |
} else { |
75 | 78 |
this.name = name; |
76 | 79 |
} |
77 | 80 |
this.descripcion = description; |
81 |
} |
|
78 | 82 |
|
83 |
@Override |
|
84 |
public String getDescription() { |
|
85 |
return this.descripcion; |
|
79 | 86 |
} |
87 |
|
|
88 |
@Override |
|
89 |
public String getName() { |
|
90 |
return this.name; |
|
91 |
} |
|
92 |
|
|
93 |
@Override |
|
94 |
public FeatureType getDefaultFeatureType() throws DataException { |
|
95 |
return defaultFeatureType; |
|
96 |
} |
|
97 |
|
|
98 |
@Override |
|
99 |
public List getFeatureTypes() throws DataException { |
|
100 |
return featureTypes; |
|
101 |
} |
|
102 |
|
|
103 |
@Override |
|
104 |
public void setFeatureStore(FeatureStore store) { |
|
105 |
this.store = store; |
|
106 |
} |
|
107 |
|
|
108 |
@Override |
|
109 |
public FeatureStore getFeatureStore() { |
|
110 |
return store; |
|
111 |
} |
|
80 | 112 |
|
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 |
} |
|
113 |
@Override |
|
114 |
public boolean isTransformsOriginalValues() { |
|
115 |
return false; |
|
116 |
} |
|
92 | 117 |
|
93 |
public List getFeatureTypes() throws DataException { |
|
94 |
return featureTypes; |
|
95 |
} |
|
118 |
protected void setFeatureTypes(List types, FeatureType defaultType) { |
|
119 |
this.featureTypes.clear(); |
|
120 |
this.featureTypes.addAll(types); |
|
121 |
this.defaultFeatureType = defaultType; |
|
122 |
} |
|
96 | 123 |
|
97 |
public void setFeatureStore(FeatureStore store) {
|
|
98 |
this.store = store;
|
|
99 |
}
|
|
124 |
public static void registerPersistent() {
|
|
125 |
PersistenceManager persistenceManager = ToolsLocator.getPersistenceManager();
|
|
126 |
DynStruct definition = persistenceManager.getDefinition(ABSTRACT_FEATURESTORE_DYNCLASS_NAME);
|
|
100 | 127 |
|
101 |
public FeatureStore getFeatureStore() { |
|
102 |
return store; |
|
103 |
} |
|
128 |
if( definition == null ) { |
|
129 |
definition = persistenceManager.addDefinition( |
|
130 |
AbstractFeatureStoreTransform.class, |
|
131 |
ABSTRACT_FEATURESTORE_DYNCLASS_NAME, |
|
132 |
"AbstractFeatureStoreTransform Persistent definition", |
|
133 |
null, |
|
134 |
null |
|
135 |
); |
|
104 | 136 |
|
105 |
protected void setFeatureTypes(List types, FeatureType defaultType) { |
|
106 |
this.featureTypes.clear(); |
|
107 |
this.featureTypes.addAll(types); |
|
108 |
this.defaultFeatureType = defaultType; |
|
109 |
} |
|
137 |
definition.addDynFieldObject("store") |
|
138 |
.setClassOfValue(FeatureStore.class) |
|
139 |
.setMandatory(false); // Mantenemos el campo por compatibilidad |
|
140 |
// con versiones anteriores a la 2.4, pero |
|
141 |
// ya no se recupera ni se guarda. |
|
142 |
} |
|
143 |
} |
|
110 | 144 |
|
111 |
public static void registerPersistent() { |
|
112 |
PersistenceManager persistenceManager = ToolsLocator.getPersistenceManager(); |
|
113 |
DynStruct definition = persistenceManager.getDefinition(ABSTRACT_FEATURESTORE_DYNCLASS_NAME); |
|
145 |
@Override |
|
146 |
public void loadFromState(PersistentState state) throws PersistenceException { |
|
147 |
// this.store = (FeatureStore) state.get("store"); |
|
148 |
} |
|
114 | 149 |
|
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 |
); |
|
150 |
@Override |
|
151 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
152 |
// state.set("store", store); |
|
153 |
} |
|
123 | 154 |
|
124 |
definition.addDynFieldObject("store") |
|
125 |
.setClassOfValue(FeatureStore.class) |
|
126 |
.setMandatory(true); |
|
127 |
} |
|
128 |
} |
|
155 |
@Override |
|
156 |
public final void setSourceMetadata(DynObject metadata) { |
|
157 |
this.originalMetadata = metadata; |
|
158 |
} |
|
129 | 159 |
|
130 |
public void loadFromState(PersistentState state) throws PersistenceException {
|
|
131 |
this.store = (FeatureStore) state.get("store");
|
|
132 |
}
|
|
160 |
protected DynObject getSourceMetadata() {
|
|
161 |
return this.originalMetadata;
|
|
162 |
}
|
|
133 | 163 |
|
134 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
135 |
state.set("store", store); |
|
136 |
} |
|
164 |
@Override |
|
165 |
public Object getDynValue(String name) throws DynFieldNotFoundException { |
|
166 |
throw new DynFieldNotFoundException(name, "transform"); |
|
167 |
} |
|
137 | 168 |
|
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 |
} |
|
169 |
@Override |
|
170 |
public boolean hasDynValue(String name) { |
|
171 |
return false; |
|
172 |
} |
|
158 | 173 |
|
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 |
} |
|
174 |
@Override |
|
175 |
public void setDynValue(String name, Object value) |
|
176 |
throws DynFieldNotFoundException { |
|
177 |
throw new DynFieldNotFoundException(name, "transform"); |
|
178 |
} |
|
170 | 179 |
|
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 |
} |
|
180 |
@Override |
|
181 |
public Object clone() throws CloneNotSupportedException { |
|
182 |
return super.clone(); |
|
189 | 183 |
|
184 |
} |
|
185 |
|
|
190 | 186 |
} |
Also available in: Unified diff