Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / extension / batchupdate / BatchUpdateProcessParameters.java @ 46448

History | View | Annotate | Download (3.56 KB)

1
/*
2
 * To change this license header, choose License Headers in Project Properties.
3
 * To change this template file, choose Tools | Templates
4
 * and open the template in the editor.
5
 */
6
package org.gvsig.app.extension.batchupdate;
7

    
8
import java.util.ArrayList;
9
import java.util.Iterator;
10
import java.util.List;
11
import org.gvsig.app.extension.batchupdate.BatchUpdateProcessParameters.ProcessFieldParameters;
12
import org.gvsig.expressionevaluator.Expression;
13
import org.gvsig.fmap.dal.feature.FeatureStore;
14
import org.gvsig.tools.dispose.Disposable;
15
import org.gvsig.tools.dispose.DisposeUtils;
16
import org.gvsig.tools.dispose.impl.AbstractDisposable;
17
import org.gvsig.tools.exception.BaseException;
18
import org.gvsig.tools.task.SimpleTaskStatus;
19

    
20
/**
21
 *
22
 * @author jjdelcerro
23
 */
24
public class BatchUpdateProcessParameters extends AbstractDisposable implements Iterable<ProcessFieldParameters>{
25

    
26
    public static class ProcessFieldParameters {
27
    
28
        private final String name;
29
        private final boolean update;
30
        private final Expression expression;
31
        
32
        public ProcessFieldParameters(String name, boolean update, Expression expression) {
33
            this.name = name;
34
            this.update = update;
35
            this.expression = expression;
36
        }
37

    
38
        /**
39
         * @return the name
40
         */
41
        public String getName() {
42
            return name;
43
        }
44

    
45
        /**
46
         * @return the update
47
         */
48
        public boolean isUpdate() {
49
            return update;
50
        }
51

    
52
        /**
53
         * @return the expression
54
         */
55
        public Expression getExpression() {
56
            return expression;
57
        }
58
        
59
        
60
    }
61
    
62
    public static final int BATCHUPDATE_PROCESS_ALL = 0;
63
    public static final int BATCHUPDATE_PROCESS_ONLY_SELECTION = 1;
64
    public static final int BATCHUPDATE_PROCESS_ONLY_EDITEDS = 2;
65
    
66
    private int rowsToProcess;
67
    private Expression filter;
68
    private final List<ProcessFieldParameters> fields;
69
    private FeatureStore store;
70
    
71

    
72
    public BatchUpdateProcessParameters() {
73
        super();
74
        this.fields = new ArrayList<>();
75
        this.rowsToProcess = BATCHUPDATE_PROCESS_ALL;
76
        this.filter = null;
77
        this.store = null;
78
    }
79

    
80
    @Override
81
    protected void doDispose() throws BaseException {
82
        DisposeUtils.dispose(store);
83
        this.store = null;
84
        this.fields.clear();
85
        this.filter = null;
86
        this.rowsToProcess = BATCHUPDATE_PROCESS_ALL;
87
    }
88

    
89
    public ProcessFieldParameters add(String name, boolean update, Expression expression) {
90
        ProcessFieldParameters x = new ProcessFieldParameters(name, update, expression);
91
        this.fields.add(x);
92
        return x;
93
    }
94

    
95
    @Override
96
    public Iterator<ProcessFieldParameters> iterator() {
97
        return this.fields.iterator();
98
    }
99

    
100
    public void setStore(FeatureStore store) {
101
        DisposeUtils.dispose(this.store);
102
        this.store = store;
103
        DisposeUtils.bind(this.store);
104
    }
105

    
106
    public FeatureStore getStore() {
107
        return store;
108
    }
109
    
110
    /**
111
     * @return the rowsToProcess
112
     */
113
    public int getRowsToProcess() {
114
        return rowsToProcess;
115
    }
116

    
117
    /**
118
     * @param rowsToProcess the rowsToProcess to set
119
     */
120
    public void setRowsToProcess(int rowsToProcess) {
121
        this.rowsToProcess = rowsToProcess;
122
    }
123

    
124
    /**
125
     * @return the filter
126
     */
127
    public Expression getFilter() {
128
        return filter;
129
    }
130

    
131
    /**
132
     * @param filter the filter to set
133
     */
134
    public void setFilter(Expression filter) {
135
        this.filter = filter;
136
    }
137

    
138
}