svn-gvsig-desktop / 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 @ 44395
History | View | Annotate | Download (4.46 KB)
1 |
package org.gvsig.export.spi; |
---|---|
2 |
|
3 |
import java.text.DateFormat; |
4 |
import java.text.SimpleDateFormat; |
5 |
import java.util.Date; |
6 |
import org.gvsig.export.ExportAttributes; |
7 |
import org.gvsig.export.ExportLocator; |
8 |
import org.gvsig.fmap.dal.exception.DataException; |
9 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
10 |
import org.gvsig.fmap.dal.feature.FeatureType; |
11 |
import org.gvsig.export.ExportParameters; |
12 |
import org.gvsig.expressionevaluator.Expression; |
13 |
|
14 |
/**
|
15 |
*
|
16 |
* @author jjdelcerro
|
17 |
*/
|
18 |
public abstract class AbstractExportParameters implements ExportParameters { |
19 |
|
20 |
private FeatureStore sourceFeatureStore;
|
21 |
private Expression filterExpression; |
22 |
private int featuresToUse; |
23 |
private Object context; |
24 |
protected ExportAttributes exportAttributes = null; |
25 |
private Date date = new Date(); |
26 |
private final ExportServiceFactory factory; |
27 |
|
28 |
public AbstractExportParameters(ExportServiceFactory factory) {
|
29 |
this.factory = factory;
|
30 |
this.exportAttributes = ExportLocator.getServiceManager().createExportAttributes();
|
31 |
} |
32 |
|
33 |
@Override
|
34 |
public boolean needsSelectTargetProjection() { |
35 |
return false; |
36 |
} |
37 |
|
38 |
@Override
|
39 |
public FeatureType getSourceFeatureType() {
|
40 |
if (!(this.exportAttributes == null)) { |
41 |
return this.exportAttributes.getSourceFeatureType(); |
42 |
} else {
|
43 |
return null; |
44 |
} |
45 |
} |
46 |
|
47 |
@Override
|
48 |
public void setSourceFeatureType(FeatureType sourceFeatureType) { |
49 |
this.exportAttributes.setSourceFeatureType(sourceFeatureType);
|
50 |
} |
51 |
|
52 |
@Override
|
53 |
public void setSourceFeatureStore(FeatureStore sourceFeatureStore) { |
54 |
this.sourceFeatureStore = sourceFeatureStore;
|
55 |
try {
|
56 |
FeatureType sourceFeatureType = sourceFeatureStore.getDefaultFeatureType(); |
57 |
this.exportAttributes.setSourceFeatureType(sourceFeatureType);
|
58 |
} catch (DataException ex) {
|
59 |
throw new RuntimeException("Can't set feature type", ex); |
60 |
} |
61 |
} |
62 |
|
63 |
@Override
|
64 |
public FeatureStore getSourceFeatureStore() {
|
65 |
return this.sourceFeatureStore; |
66 |
} |
67 |
|
68 |
@Override
|
69 |
public Expression getFilterExpresion() { |
70 |
return this.filterExpression; |
71 |
} |
72 |
|
73 |
@Override
|
74 |
public void setFilterExpresion(Expression expression) { |
75 |
this.filterExpression = expression;
|
76 |
} |
77 |
|
78 |
@Override
|
79 |
public int getFeaturesToUse() { |
80 |
return featuresToUse;
|
81 |
} |
82 |
|
83 |
@Override
|
84 |
public void setFeaturesToUse(int featuresToUse) { |
85 |
this.featuresToUse = featuresToUse;
|
86 |
} |
87 |
|
88 |
@Override
|
89 |
public Object getContext() { |
90 |
return context;
|
91 |
} |
92 |
|
93 |
@Override
|
94 |
public void setContext(Object context) { |
95 |
this.context = context;
|
96 |
} |
97 |
|
98 |
@Override
|
99 |
public ExportAttributes getExportAttributes() {
|
100 |
return this.exportAttributes; |
101 |
} |
102 |
|
103 |
@Override
|
104 |
public void setExportAttributes(ExportAttributes export) { |
105 |
this.exportAttributes = export; |
106 |
} |
107 |
|
108 |
@Override
|
109 |
public ExportParameters clone() throws CloneNotSupportedException { |
110 |
ExportParameters clone = (ExportParameters) super.clone();
|
111 |
|
112 |
if (this.filterExpression != null) { |
113 |
clone.setFilterExpresion(this.filterExpression.clone());
|
114 |
} |
115 |
if (this.exportAttributes != null) { |
116 |
clone.setExportAttributes(this.exportAttributes.clone());
|
117 |
} |
118 |
|
119 |
return clone;
|
120 |
} |
121 |
|
122 |
@Override
|
123 |
public Date getCreationDate() { |
124 |
return this.date; |
125 |
} |
126 |
|
127 |
public void setCreationDate(Date date) { |
128 |
this.date = date;
|
129 |
} |
130 |
|
131 |
@Override
|
132 |
public String getLabel() { |
133 |
StringBuilder builder = new StringBuilder(); |
134 |
DateFormat df = new SimpleDateFormat("dd/MM/yy HH:mm:ss"); |
135 |
String dateName;
|
136 |
dateName = df.format(this.getCreationDate());
|
137 |
builder.append(dateName); |
138 |
builder.append(": ");
|
139 |
|
140 |
String serviceName;
|
141 |
if (this.getServiceName() != null) { |
142 |
serviceName = this.getServiceName();
|
143 |
} else {
|
144 |
serviceName = "Null service";
|
145 |
} |
146 |
builder.append(serviceName); |
147 |
|
148 |
if (this.getSourceFeatureStore() != null) { |
149 |
String storeName = this.getSourceFeatureStore().getName(); |
150 |
builder.append(" - ");
|
151 |
builder.append(storeName); |
152 |
} |
153 |
|
154 |
return builder.toString();
|
155 |
} |
156 |
|
157 |
@Override
|
158 |
public Object getValue() { |
159 |
return this; |
160 |
} |
161 |
|
162 |
@Override
|
163 |
public String toString() { |
164 |
return this.getLabel(); |
165 |
} |
166 |
|
167 |
@Override
|
168 |
public ExportServiceFactory getFactory() {
|
169 |
return this.factory; |
170 |
} |
171 |
|
172 |
} |