Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.swing / org.gvsig.fmap.dal.swing.api / src / main / java / org / gvsig / fmap / dal / swing / searchPostProcess / AbstractSearchPostProcess.java @ 46062

History | View | Annotate | Download (3.39 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.fmap.dal.swing.searchPostProcess;
7

    
8
import org.gvsig.fmap.dal.exception.DataException;
9
import org.gvsig.fmap.dal.feature.Feature;
10
import org.gvsig.fmap.dal.feature.FeatureQuery;
11
import org.gvsig.fmap.dal.feature.FeatureStore;
12
import org.gvsig.tools.dynobject.DynObject;
13
import org.gvsig.tools.exception.BaseException;
14
import org.gvsig.tools.task.SimpleTaskStatus;
15
import org.gvsig.tools.visitor.VisitCanceledException;
16
import org.gvsig.tools.visitor.Visitor;
17
import org.slf4j.Logger;
18
import org.slf4j.LoggerFactory;
19

    
20
/**
21
 *
22
 * @author jovivas
23
 */
24
public class AbstractSearchPostProcess implements SearchPostProcess{
25
    
26
    protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractSearchPostProcess.class);
27

    
28
    private final SearchPostProcessFactory factory;
29
    public final FeatureStore input;
30
    private final FeatureQuery query;
31
    private DynObject parameters;
32
    private SearchPostProcessResult output;
33
    
34
    public class DefaultSearchPostProcessResult implements SearchPostProcessResult {
35
        
36
        FeatureStore store;
37
        FeatureQuery query;
38

    
39
        public DefaultSearchPostProcessResult(FeatureStore store, FeatureQuery query) {
40
            this.store=store; 
41
            this.query=query;
42
        }
43

    
44
        public FeatureStore getStore(){
45
            return this.store;
46
        }
47

    
48
        public FeatureQuery getQuery(){
49
            return this.query;   
50
        }
51

    
52
    }
53
      
54
    protected AbstractSearchPostProcess (
55
        SearchPostProcessFactory factory,
56
        FeatureStore input,
57
        FeatureQuery query,
58
        DynObject parameters
59
            
60
    ){
61
        this.factory=factory;
62
        this.input=input;
63
        this.parameters=parameters;
64
        this.query=query;
65
        this.output=null;
66
    }
67

    
68
    @Override
69
    public SearchPostProcessResult execute(FeatureStore input, FeatureQuery query, DynObject parameters, SimpleTaskStatus status) {
70
        try {
71
            this.input.accept(new Visitor() {
72
                @Override
73
                public void visit(final Object obj) throws VisitCanceledException, BaseException {
74
                    try {
75
                        check((Feature) obj, query);
76
                    } catch (Exception ex) {
77
                        throw new RuntimeException(ex);
78
                    }
79
                }
80
            
81
            });
82
            this.input.dispose();
83
        } catch(VisitCanceledException ex) {
84
            LOGGER.warn("Error", ex);
85
        } catch (DataException ex) {
86
            LOGGER.warn("Error", ex);
87
        } catch (BaseException ex) {
88
            LOGGER.warn("Error", ex);
89
        }
90
        
91
        return output;
92
    }
93

    
94
    protected void check(Feature feature, FeatureQuery query) throws Exception {
95
        
96
    }
97

    
98
    @Override
99
    public String getLabel() {
100
        return this.getFactory().getLabel();
101
    }
102

    
103
    @Override
104
    public String getName() {
105
        return this.getFactory().getName();
106
    }
107

    
108
    @Override
109
    public SearchPostProcessFactory getFactory() {
110
        return this.factory;
111
    }
112

    
113
    @Override
114
    public DynObject getParameters() {
115
        return this.parameters;
116
    }
117

    
118
    @Override
119
    public void setParameters(DynObject parameters) {
120
        this.parameters=parameters;
121
    }
122
    
123
    
124
    
125
}