Revision 4495
org.gvsig.topology/trunk/org.gvsig.topology/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/java/org/gvsig/topology/rule/CustomizableRuleFactory.java | ||
---|---|---|
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.topology.lib.api.TopologyDataSet; |
|
27 |
import org.gvsig.topology.lib.api.TopologyLocator; |
|
28 |
import org.gvsig.topology.lib.api.TopologyManager; |
|
29 |
import org.gvsig.topology.lib.api.TopologyPlan; |
|
30 |
import org.gvsig.topology.lib.api.TopologyRule; |
|
31 |
import org.gvsig.topology.lib.spi.AbstractTopologyRuleFactory; |
|
32 |
|
|
33 |
/** |
|
34 |
* |
|
35 |
* @author gvSIG Team |
|
36 |
*/ |
|
37 |
@SuppressWarnings("UseSpecificCatch") |
|
38 |
public class CustomizableRuleFactory extends AbstractTopologyRuleFactory { |
|
39 |
|
|
40 |
public static final String NAME = "Customizable"; |
|
41 |
|
|
42 |
public CustomizableRuleFactory() { |
|
43 |
super( |
|
44 |
NAME, |
|
45 |
"Customizable", |
|
46 |
"", |
|
47 |
null |
|
48 |
); |
|
49 |
} |
|
50 |
|
|
51 |
@Override |
|
52 |
public boolean canApplyToDataSet(TopologyDataSet dataSet) { |
|
53 |
return true; |
|
54 |
} |
|
55 |
|
|
56 |
@Override |
|
57 |
public boolean canApplyToSecondaryDataSet(TopologyDataSet dataSet) { |
|
58 |
return true; |
|
59 |
} |
|
60 |
|
|
61 |
@Override |
|
62 |
public TopologyRule createRule(TopologyPlan plan, String dataSet1, String dataSet2, double tolerance) { |
|
63 |
TopologyRule rule = new CustomizableRule(plan, this, tolerance, dataSet1, dataSet2); |
|
64 |
return rule; |
|
65 |
} |
|
66 |
|
|
67 |
public static void selfRegister() { |
|
68 |
try { |
|
69 |
TopologyManager manager = TopologyLocator.getTopologyManager(); |
|
70 |
manager.addRuleFactories(new CustomizableRuleFactory()); |
|
71 |
} catch(Exception ex) { |
|
72 |
LOGGER.warn("Can't register topology rule from "+CustomizableRuleFactory.class.getSimpleName(), ex); |
|
73 |
} |
|
74 |
} |
|
75 |
} |
org.gvsig.topology/trunk/org.gvsig.topology/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/java/org/gvsig/topology/rule/CustomizableRule.java | ||
---|---|---|
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.expressionevaluator.Expression; |
|
27 |
import org.gvsig.expressionevaluator.ExpressionUtils; |
|
28 |
import org.gvsig.expressionevaluator.MutableSymbolTable; |
|
29 |
import org.gvsig.fmap.dal.feature.Feature; |
|
30 |
import org.gvsig.tools.dynobject.DynObject; |
|
31 |
import org.gvsig.tools.task.SimpleTaskStatus; |
|
32 |
import org.gvsig.topology.lib.api.ExecuteTopologyRuleActionException; |
|
33 |
import org.gvsig.topology.lib.api.TopologyPlan; |
|
34 |
import org.gvsig.topology.lib.api.TopologyReport; |
|
35 |
import org.gvsig.topology.lib.api.TopologyReportLine; |
|
36 |
import org.gvsig.topology.lib.api.TopologyRule; |
|
37 |
import org.gvsig.topology.lib.api.TopologyRuleFactory; |
|
38 |
import org.gvsig.topology.lib.spi.AbstractTopologyRule; |
|
39 |
import org.gvsig.topology.lib.spi.AbstractTopologyRuleAction; |
|
40 |
import org.gvsig.topology.lib.api.TopologyCustomizableRule; |
|
41 |
|
|
42 |
/** |
|
43 |
* |
|
44 |
* @author gvSIG Team |
|
45 |
*/ |
|
46 |
@SuppressWarnings("UseSpecificCatch") |
|
47 |
public class CustomizableRule |
|
48 |
extends AbstractTopologyRule |
|
49 |
implements TopologyCustomizableRule |
|
50 |
{ |
|
51 |
|
|
52 |
private static class CustomizableActionImpl |
|
53 |
extends AbstractTopologyRuleAction |
|
54 |
implements TopologyCustomizableRuleAction |
|
55 |
{ |
|
56 |
|
|
57 |
protected Expression action; |
|
58 |
protected MutableSymbolTable symbolTable; |
|
59 |
|
|
60 |
public CustomizableActionImpl() { |
|
61 |
super(CustomizableRuleFactory.NAME); |
|
62 |
} |
|
63 |
|
|
64 |
@Override |
|
65 |
public Expression getAction() { |
|
66 |
return this.action; |
|
67 |
} |
|
68 |
|
|
69 |
@Override |
|
70 |
public void setAction(Expression action) { |
|
71 |
this.action = action; |
|
72 |
} |
|
73 |
|
|
74 |
@Override |
|
75 |
public void setId(String id) { |
|
76 |
this.idAction = id; |
|
77 |
} |
|
78 |
|
|
79 |
@Override |
|
80 |
public void setName(String name) { |
|
81 |
this.name = name; |
|
82 |
} |
|
83 |
|
|
84 |
@Override |
|
85 |
public void setShortDescription(String description) { |
|
86 |
this.shortDescription = description; |
|
87 |
} |
|
88 |
|
|
89 |
@Override |
|
90 |
public MutableSymbolTable getSymbolTable() { |
|
91 |
if (this.symbolTable == null) { |
|
92 |
this.symbolTable = ExpressionUtils.createSymbolTable(); |
|
93 |
} |
|
94 |
return this.symbolTable; |
|
95 |
} |
|
96 |
|
|
97 |
@Override |
|
98 |
public int execute(TopologyRule rule, TopologyReportLine line, DynObject parameters) throws ExecuteTopologyRuleActionException { |
|
99 |
MutableSymbolTable st = this.getSymbolTable(); |
|
100 |
st.setVar("rute", rule); |
|
101 |
st.setVar("line", line); |
|
102 |
st.setVar("parameters", parameters); |
|
103 |
this.action.execute(symbolTable); |
|
104 |
return EXECUTE_OK; |
|
105 |
} |
|
106 |
|
|
107 |
|
|
108 |
} |
|
109 |
|
|
110 |
protected Expression check; |
|
111 |
protected MutableSymbolTable symbolTable; |
|
112 |
|
|
113 |
public CustomizableRule( |
|
114 |
TopologyPlan plan, |
|
115 |
TopologyRuleFactory factory, |
|
116 |
double tolerance, |
|
117 |
String dataSet1, |
|
118 |
String dataSet2 |
|
119 |
) { |
|
120 |
super(plan, factory, tolerance, dataSet1, dataSet2); |
|
121 |
} |
|
122 |
|
|
123 |
@Override |
|
124 |
public void setCheck(Expression check) { |
|
125 |
this.check = check; |
|
126 |
} |
|
127 |
|
|
128 |
@Override |
|
129 |
public Expression getCheck() { |
|
130 |
return this.check; |
|
131 |
} |
|
132 |
|
|
133 |
@Override |
|
134 |
public TopologyCustomizableRuleAction createAction() { |
|
135 |
CustomizableActionImpl action = new CustomizableActionImpl(); |
|
136 |
return action; |
|
137 |
} |
|
138 |
|
|
139 |
@Override |
|
140 |
public MutableSymbolTable getSymbolTable() { |
|
141 |
if (this.symbolTable == null) { |
|
142 |
this.symbolTable = ExpressionUtils.createSymbolTable(); |
|
143 |
} |
|
144 |
return this.symbolTable; |
|
145 |
} |
|
146 |
|
|
147 |
@Override |
|
148 |
protected void check(SimpleTaskStatus taskStatus, TopologyReport report, Feature feature1) throws Exception { |
|
149 |
MutableSymbolTable st = this.getSymbolTable(); |
|
150 |
st.setVar("taskStatus", taskStatus); |
|
151 |
st.setVar("report", report); |
|
152 |
st.setVar("feature1", feature1); |
|
153 |
this.check.execute(st); |
|
154 |
} |
|
155 |
|
|
156 |
} |
org.gvsig.topology/trunk/org.gvsig.topology/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/api/TopologyCustomizableRule.java | ||
---|---|---|
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.topology.lib.api; |
|
7 |
|
|
8 |
import org.gvsig.expressionevaluator.Expression; |
|
9 |
import org.gvsig.expressionevaluator.MutableSymbolTable; |
|
10 |
|
|
11 |
/** |
|
12 |
* |
|
13 |
* @author gvSIG Team |
|
14 |
*/ |
|
15 |
public interface TopologyCustomizableRule extends TopologyRule { |
|
16 |
|
|
17 |
public interface TopologyCustomizableRuleAction extends TopologyRuleAction { |
|
18 |
|
|
19 |
public Expression getAction(); |
|
20 |
|
|
21 |
public MutableSymbolTable getSymbolTable(); |
|
22 |
|
|
23 |
public void setAction(Expression action); |
|
24 |
|
|
25 |
public void setId(String id); |
|
26 |
|
|
27 |
public void setName(String name); |
|
28 |
|
|
29 |
public void setShortDescription(String description); |
|
30 |
|
|
31 |
} |
|
32 |
|
|
33 |
public TopologyCustomizableRuleAction createAction(); |
|
34 |
|
|
35 |
public Expression getCheck(); |
|
36 |
|
|
37 |
public MutableSymbolTable getSymbolTable(); |
|
38 |
|
|
39 |
public void setCheck(Expression check); |
|
40 |
|
|
41 |
} |
org.gvsig.topology/trunk/org.gvsig.topology/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/spi/AbstractTopologyRuleAction.java | ||
---|---|---|
36 | 36 |
*/ |
37 | 37 |
public abstract class AbstractTopologyRuleAction implements TopologyRuleAction { |
38 | 38 |
|
39 |
private final String idAction;
|
|
40 |
private final String idRule;
|
|
41 |
private String name;
|
|
42 |
private String shortDescription;
|
|
39 |
protected final String idRule;
|
|
40 |
protected String idAction;
|
|
41 |
protected String name;
|
|
42 |
protected String shortDescription;
|
|
43 | 43 |
|
44 | 44 |
protected AbstractTopologyRuleAction( |
45 |
String idRule |
|
46 |
) { |
|
47 |
this.idRule = idRule; |
|
48 |
this.idAction = null; |
|
49 |
this.name = null; |
|
50 |
this.shortDescription = null; |
|
51 |
} |
|
52 |
|
|
53 |
protected AbstractTopologyRuleAction( |
|
45 | 54 |
String idRule, |
46 | 55 |
String idAction, |
47 | 56 |
String name, |
Also available in: Unified diff