Revision 44387 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

View differences:

AbstractExportParameters.java
1 1
package org.gvsig.export.spi;
2 2

  
3
import java.text.DateFormat;
4
import java.text.SimpleDateFormat;
5
import java.util.Date;
6
import org.apache.commons.lang3.StringUtils;
3 7
import org.gvsig.export.ExportAttributes;
4 8
import org.gvsig.export.ExportLocator;
5 9
import org.gvsig.fmap.dal.exception.DataException;
......
18 22
    private Expression filterExpression;
19 23
    private int featuresToUse;
20 24
    private Object context;
21
    private ExportAttributes exportAttributes = null;
25
    protected ExportAttributes exportAttributes = null;
26
    private Date date = new Date();
27
    private final ExportServiceFactory factory;
22 28

  
29
    public AbstractExportParameters(ExportServiceFactory factory) {
30
        this.factory = factory;
31
        this.exportAttributes = ExportLocator.getServiceManager().createExportAttributes();
32
    }
33

  
23 34
    @Override
24 35
    public boolean needsSelectTargetProjection() {
25 36
        return false;
......
44 55
        this.sourceFeatureStore = sourceFeatureStore;
45 56
        try {
46 57
            FeatureType sourceFeatureType = sourceFeatureStore.getDefaultFeatureType();
47
            if (this.exportAttributes == null) {
48
                this.exportAttributes = ExportLocator.getServiceManager().createExportAttributes(sourceFeatureType);
49
            } else {
50
                this.exportAttributes.setSourceFeatureType(sourceFeatureType);
51
            }
52

  
58
            this.exportAttributes.setSourceFeatureType(sourceFeatureType);
53 59
        } catch (DataException ex) {
54
            throw new RuntimeException("Can't create export attributes", ex);
60
            throw new RuntimeException("Can't set feature type", ex);
55 61
        }
56 62
    }
57 63

  
......
100 106
        this.exportAttributes = export;
101 107
    }
102 108

  
109
    @Override
110
    public ExportParameters clone() throws CloneNotSupportedException {
111
        ExportParameters clone = (ExportParameters) super.clone();
112
        clone.setContext(new Date());
113

  
114
        if (this.filterExpression != null) {
115
            clone.setFilterExpresion(this.filterExpression.clone());
116
        }
117
        if (this.exportAttributes != null) {
118
            clone.setExportAttributes(this.exportAttributes.clone());
119
        }
120

  
121
        return clone;
122
    }
123

  
124
    @Override
125
    public Date getCreationDate() {
126
        return this.date;
127
    }
128
    
129
    public void setCreationDate(Date date) {
130
        this.date = date;
131
    }
132

  
133
    @Override
134
    public String getLabel() {
135
        StringBuilder builder = new StringBuilder();
136
        DateFormat df = new SimpleDateFormat("dd/MM/yy HH:mm:ss");
137
        String dateName;
138
        dateName = df.format(this.getCreationDate());
139
        builder.append(dateName);
140
        builder.append(": ");
141

  
142
        String serviceName;
143
        if (this.getServiceName() != null) {
144
            serviceName = this.getServiceName();
145
        } else {
146
            serviceName = "Null service";
147
        }
148
        builder.append(serviceName);
149

  
150
        if (this.getSourceFeatureStore() != null) {
151
            String storeName = this.getSourceFeatureStore().getName();
152
            builder.append(" - ");
153
            builder.append(storeName);
154
        }
155

  
156
        return builder.toString();
157
    }
158

  
159
    @Override
160
    public Object getValue() {
161
        return this;
162
    }
163

  
164
    @Override
165
    public String toString() {
166
        return this.getLabel();
167
    }
168

  
169
    @Override
170
    public ExportServiceFactory getFactory() {
171
        return this.factory;
172
    }
173

  
103 174
}

Also available in: Unified diff