Revision 44411 trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.lib/org.gvsig.exportto.lib.api/src/main/java/org/gvsig/export/spi/AbstractExportParameters.java
AbstractExportParameters.java | ||
---|---|---|
10 | 10 |
import org.gvsig.fmap.dal.feature.FeatureType; |
11 | 11 |
import org.gvsig.export.ExportParameters; |
12 | 12 |
import org.gvsig.expressionevaluator.Expression; |
13 |
import org.gvsig.tools.ToolsLocator; |
|
14 |
import org.gvsig.tools.dynobject.DynStruct; |
|
15 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
16 |
import org.gvsig.tools.persistence.PersistentState; |
|
17 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
13 | 18 |
import org.slf4j.Logger; |
14 | 19 |
import org.slf4j.LoggerFactory; |
15 | 20 |
|
... | ... | |
25 | 30 |
private Object context; |
26 | 31 |
protected ExportAttributes exportAttributes = null; |
27 | 32 |
private Date date = new Date(); |
28 |
private final ExportServiceFactory factory; |
|
33 |
public ExportServiceFactory factory; |
|
34 |
|
|
29 | 35 |
protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractExportParameters.class); |
30 | 36 |
|
31 | 37 |
public AbstractExportParameters(ExportServiceFactory factory) { |
... | ... | |
126 | 132 |
public Date getCreationDate() { |
127 | 133 |
return this.date; |
128 | 134 |
} |
129 |
|
|
135 |
|
|
130 | 136 |
public void setCreationDate(Date date) { |
131 | 137 |
this.date = date; |
132 | 138 |
} |
... | ... | |
171 | 177 |
public ExportServiceFactory getFactory() { |
172 | 178 |
return this.factory; |
173 | 179 |
} |
174 |
|
|
180 |
|
|
175 | 181 |
@Override |
176 | 182 |
public FeatureType getTargetFeatureType() { |
177 |
if (this.getExportAttributes()==null) {
|
|
183 |
if (this.getExportAttributes() == null) {
|
|
178 | 184 |
LOGGER.warn("Not been able to get target feature type from export attributes because it's null"); |
179 | 185 |
return null; |
180 | 186 |
} |
181 | 187 |
return this.getExportAttributes().getTargetFeatureType(); |
182 | 188 |
} |
183 | 189 |
|
190 |
public static void registerPersistence() { |
|
191 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
192 |
if (manager.getDefinition("AbstractExportParameters") == null) { |
|
193 |
DynStruct definition = manager.addDefinition(AbstractExportParameters.class, |
|
194 |
"AbstractExportParameters", "AbstractExportParameters persistence definition", null, null); |
|
195 |
definition.addDynFieldInt("featuresToUse").setMandatory(false); |
|
196 |
definition.addDynFieldObject("filterExpression").setClassOfValue(Expression.class).setMandatory(false); |
|
197 |
definition.addDynFieldObject("exportAttributes").setClassOfValue(ExportAttributes.class).setMandatory(false); |
|
198 |
definition.addDynFieldDate("dateCreation").setMandatory(false); |
|
199 |
definition.addDynFieldString("factory"); |
|
200 |
} |
|
201 |
} |
|
202 |
|
|
203 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
204 |
state.set("featuresToUse", this.featuresToUse); |
|
205 |
state.set("filterExpression", this.filterExpression); |
|
206 |
state.set("exportAttributes", this.exportAttributes); |
|
207 |
state.set("dateCreation", this.date); |
|
208 |
state.set("factory", this.factory.getName()); |
|
209 |
} |
|
210 |
|
|
211 |
public void loadFromState(PersistentState state) throws PersistenceException { |
|
212 |
this.featuresToUse = state.getInt("featuresToUse"); |
|
213 |
this.filterExpression = (Expression) state.get("filterExpression"); |
|
214 |
this.exportAttributes = (ExportAttributes) state.get("exportAttributes"); |
|
215 |
this.date = state.getDate("dateCreation"); |
|
216 |
String nameFactory = state.getString("factory"); |
|
217 |
ExportServiceFactory statefactory = ExportLocator.getServiceManager().getServiceFactory(nameFactory); |
|
218 |
this.factory = statefactory; |
|
219 |
} |
|
220 |
|
|
184 | 221 |
} |
Also available in: Unified diff