Statistics
| Revision:

gvsig-projects-pool / org.gvsig.topology / trunk / org.gvsig.topology / org.gvsig.topology.lib / org.gvsig.topology.lib.impl / src / main / java / org / gvsig / topology / rule / GeometryMustNotBeNullRule.java @ 4565

History | View | Annotate | Download (2.74 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2021 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.topology.rule;
25

    
26
import org.gvsig.fmap.dal.feature.Feature;
27
import org.gvsig.fmap.dal.feature.FeatureSet;
28
import org.gvsig.tools.ToolsLocator;
29
import org.gvsig.tools.i18n.I18nManager;
30
import org.gvsig.tools.task.SimpleTaskStatus;
31
import org.gvsig.topology.lib.api.TopologyReport;
32
import org.gvsig.topology.lib.api.TopologyRuleFactory;
33
import org.gvsig.topology.lib.spi.AbstractTopologyRule;
34

    
35
/**
36
 *
37
 * @author jjdelcerro
38
 */
39
@SuppressWarnings("UseSpecificCatch")
40
public class GeometryMustNotBeNullRule extends AbstractTopologyRule {
41

    
42
    public GeometryMustNotBeNullRule() {
43
        // for persistence only
44
    }
45
    
46

    
47
    public GeometryMustNotBeNullRule(
48
            TopologyRuleFactory factory,
49
            double tolerance,
50
            String dataSet1,
51
            String dataSet2
52
    ) {
53
        super(factory, tolerance, dataSet1, dataSet2);
54
    }
55

    
56
    @Override
57
    protected void check(SimpleTaskStatus taskStatus, TopologyReport report, Feature feature1) throws Exception {
58
        FeatureSet set = null;
59
        try {
60
            if ( feature1.getDefaultGeometry()==null ) {
61
                I18nManager i18n = ToolsLocator.getI18nManager();
62
                report.addLine(this,
63
                        this.getDataSet1(),
64
                        this.getDataSet2(),
65
                        feature1.getDefaultGeometry(),
66
                        null,
67
                        feature1.getReference(),
68
                        null,
69
                        false,
70
                        i18n.getTranslation("_The_geometry_is_null")
71
                );
72
            }
73
        } catch(Exception ex) {
74
            LOGGER.warn("Can't check feature.", ex);
75
            addCodeException(report, feature1, ex);
76
        } finally {
77
            if( set!=null ) {
78
                set.dispose();
79
            }
80
        }
81
    }
82

    
83
}