Revision 2801

View differences:

org.gvsig.topology/tags/org.gvsig.topology-1.0.46/org.gvsig.topology.lib/pom.xml
1
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2
  <modelVersion>4.0.0</modelVersion>
3
  <parent>
4
    <groupId>org.gvsig</groupId>
5
    <artifactId>org.gvsig.topology</artifactId>
6
    <version>1.0.46</version>
7
  </parent>
8
  <artifactId>org.gvsig.topology.lib</artifactId>
9
  <packaging>pom</packaging>
10
  <name>${project.artifactId}</name>
11
  <modules>
12
  	<module>org.gvsig.topology.lib.api</module>
13
  	<module>org.gvsig.topology.lib.impl</module>
14
  </modules>
15
</project>
org.gvsig.topology/tags/org.gvsig.topology-1.0.46/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.topology.lib.api.TopologyLibrary
org.gvsig.topology/tags/org.gvsig.topology-1.0.46/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/api/PerformOperationException.java
1
package org.gvsig.topology.lib.api;
2

  
3
import org.gvsig.fmap.dal.exception.DataException;
4

  
5
/**
6
 *
7
 * @author jjdelcerro
8
 */
9
public class PerformOperationException extends DataException {
10

  
11
    public PerformOperationException(String msg) {
12
        super("_CancelOperationException", msg, 0);
13
    }
14

  
15
}
org.gvsig.topology/tags/org.gvsig.topology-1.0.46/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/api/TopologyServices.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 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.lib.api;
25

  
26
import org.gvsig.fmap.dal.feature.FeatureStore;
27

  
28
/**
29
 *
30
 * @author jjdelcerro
31
 */
32
public interface TopologyServices {
33

  
34
    public FeatureStore getFeatureStore(TopologyDataSet dataSet);
35
    
36
}
org.gvsig.topology/tags/org.gvsig.topology-1.0.46/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/api/TopologyReportLine.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 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.lib.api;
25

  
26
import org.gvsig.fmap.dal.feature.FeatureReference;
27
import org.gvsig.fmap.geom.Geometry;
28

  
29
/**
30
 *
31
 * @author jjdelcerro
32
 */
33
public interface TopologyReportLine {
34
    
35
    public TopologyRule getRule();
36
    
37
    public TopologyDataSet getDataSet1();
38
    
39
    public TopologyDataSet getDataSet2();
40
    
41
    public Geometry getGeometry();
42
    
43
    public Geometry getError();
44
    
45
    public FeatureReference getFeature1();
46

  
47
    public FeatureReference getFeature2();
48
    
49
    public int getPrimitiveNumber1();
50
    
51
    public int getPrimitiveNumber2();
52
    
53
    public boolean isException();
54
    
55
    public String getDescription();
56

  
57
    public String getData();
58
}
org.gvsig.topology/tags/org.gvsig.topology-1.0.46/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/api/TopologyDataSet.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 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.lib.api;
25

  
26
import org.gvsig.expressionevaluator.Expression;
27
import org.gvsig.fmap.dal.DataStore;
28
import org.gvsig.fmap.dal.exception.DataException;
29
import org.gvsig.fmap.dal.feature.EditableFeature;
30
import org.gvsig.fmap.dal.feature.Feature;
31
import org.gvsig.fmap.dal.feature.FeatureReference;
32
import org.gvsig.fmap.dal.feature.FeatureStore;
33
import org.gvsig.fmap.geom.Geometry;
34
import org.gvsig.fmap.geom.SpatialIndex;
35
import org.gvsig.tools.util.PropertiesSupport;
36
import org.gvsig.tools.visitor.VisitCanceledException;
37
import org.gvsig.tools.visitor.Visitor;
38

  
39
/**
40
 *
41
 * @author jjdelcerro
42
 */
43
public interface TopologyDataSet extends PropertiesSupport, SerializableJSON {
44

  
45
    public static interface Operation {
46
        public void run() throws DataException;
47
    }
48
    
49
    public void setName(String name);
50

  
51
    public String getName();
52
    
53
    public DataStore getStore();
54

  
55
    public FeatureStore getFeatureStore();
56

  
57
    public boolean isThisStore(FeatureStore featureStore);
58

  
59
    public int getGeometryType() ;
60

  
61
    public void accept(Visitor visitor) throws VisitCanceledException;
62

  
63
    public void edit() throws DataException;
64

  
65
    public void finishEditing() throws DataException;
66
    
67
    public EditableFeature createNewFeature() throws DataException;
68

  
69
    public void delete(FeatureReference feature) throws DataException;
70

  
71
    public void delete(Feature feature) throws DataException;
72

  
73
    public void insert(EditableFeature feature) throws DataException;
74

  
75
    public void update(EditableFeature feature) throws DataException;
76

  
77
    public long getSize();
78
    
79
    public SpatialIndex getSpatialIndex();
80
    
81
    /**
82
     * @param geom
83
     * @return 
84
     * @deprecated  use queryFeatures or queryReferences
85
     */
86
    public Iterable<FeatureReference> query(Geometry geom);
87
    
88
    public Iterable<Feature> queryFeatures(Geometry geom);
89
    
90
    public Iterable<FeatureReference> queryReferences(Geometry geom);
91

  
92
    public Feature findFirst(Expression expression);
93

  
94
    public void restart();
95
}
org.gvsig.topology/tags/org.gvsig.topology-1.0.46/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/api/CancelOperationException.java
1
package org.gvsig.topology.lib.api;
2

  
3
import org.gvsig.fmap.dal.exception.DataException;
4

  
5
/**
6
 *
7
 * @author jjdelcerro
8
 */
9
public class CancelOperationException extends DataException {
10

  
11
    public CancelOperationException(String msg) {
12
        super("_CancelOperationException", msg, 0);
13
    }
14
}
org.gvsig.topology/tags/org.gvsig.topology-1.0.46/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/api/TopologyPlan.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 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.lib.api;
25

  
26
import java.util.Collection;
27
import org.gvsig.fmap.dal.DataStore;
28
import org.gvsig.fmap.dal.feature.FeatureStore;
29
import org.gvsig.tools.task.SimpleTaskStatus;
30

  
31
/**
32
 *
33
 * @author jjdelcerro
34
 */
35
public interface TopologyPlan extends SerializableJSON {
36

  
37
    
38
    public String getName();
39
    
40
    public void setName(String name);
41
    
42
    public double getTolerance();
43
    
44
    public void setTolerance(double tolerance);
45

  
46
    public void clear();
47

  
48
    public void setTopologyServices(TopologyServices services);
49

  
50
    public TopologyServices getTopologyServices();
51

  
52
    public SimpleTaskStatus getTaskStatus();
53
    
54
    public void execute();
55
    
56
    public TopologyDataSet addDataSet(String name, DataStore store);
57

  
58
    public TopologyDataSet addDataSet(TopologyDataSet dataSet);
59
    
60
    public void removeDataSet(TopologyDataSet dataSet);
61
    
62
    public boolean containsDataSet(String name);
63
 
64
    public TopologyDataSet getDataSet(String name);
65
    
66
    public Collection<TopologyDataSet> getDataSets();
67
    
68
    public Collection<TopologyDataSet> getSecondaryDataSets(TopologyRuleFactory ruleFactory);
69
    
70
    public TopologyRule addRule(String id, String dataSet1, String dataSet2, double tolerance);
71
    
72
    public TopologyRule addRule(TopologyRule rule);
73
    
74
    public void removeRule(TopologyRule rule);
75
 
76
    public Collection<TopologyRule> getRules();
77
    
78
    public TopologyReport getReport();
79

  
80
}
org.gvsig.topology/tags/org.gvsig.topology-1.0.46/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/api/TopologyReportLineSet.java
1
package org.gvsig.topology.lib.api;
2

  
3
import java.util.List;
4
import org.gvsig.tools.swing.api.ChangeListenerSupport;
5

  
6
/**
7
 *
8
 * @author jjdelcerro
9
 */
10
public interface TopologyReportLineSet extends ChangeListenerSupport {
11

  
12
    public List<TopologyReportLine> getLines();
13

  
14
    public boolean isComplete();
15

  
16
    public int size();
17

  
18
    public TopologyReportLine get(int index);
19
    
20
}
org.gvsig.topology/tags/org.gvsig.topology-1.0.46/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/api/TopologyRuleFactory.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 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.lib.api;
25

  
26
import java.util.List;
27
import org.gvsig.tools.dynobject.DynObject;
28

  
29
/**
30
 *
31
 * @author jjdelcerro
32
 */
33
public interface TopologyRuleFactory {
34
    
35
    public String getId();
36
    
37
    public String getName();
38
    
39
    public String getDescription();
40
    
41
    public List<Integer> getGeometryTypeDataSet1();
42
    
43
    public List<Integer> getGeometryTypeDataSet2();
44
    
45
    public DynObject createRuleParameters();
46

  
47
    public TopologyRule createRule(TopologyPlan plan, String dataSet1, String dataSet2, double tolerance);
48

  
49
    public boolean hasRuleParameters();
50

  
51
    public boolean hasSecondaryDataSet();
52

  
53
    public boolean canApplyToDataSet(TopologyDataSet dataSet);
54
    
55
    public boolean canApplyToSecondaryDataSet(TopologyDataSet dataSet);
56

  
57
    
58
}
org.gvsig.topology/tags/org.gvsig.topology-1.0.46/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/api/SerializableJSON.java
1
package org.gvsig.topology.lib.api;
2

  
3
import org.json.JSONObject;
4

  
5
/**
6
 *
7
 * @author jjdelcerro
8
 */
9
public interface SerializableJSON {
10
    public JSONObject toJSON();
11
    
12
    public void fromJSON(JSONObject json);
13
    
14
    public void fromJSON(String json);
15
    
16
}
org.gvsig.topology/tags/org.gvsig.topology-1.0.46/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/api/TopologyLocator.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 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.lib.api;
25

  
26
import org.gvsig.tools.locator.AbstractLocator;
27
import org.gvsig.tools.locator.Locator;
28
import org.gvsig.tools.locator.LocatorException;
29

  
30
@SuppressWarnings("rawtypes")
31
public class TopologyLocator extends AbstractLocator {
32

  
33
	private static final String LOCATOR_NAME = "TopologyLocator";
34
	
35
	public static final String TOPOLOGY_MANAGER_NAME =
36
			"org.gvsig.topology.manager";
37

  
38
	private static final String TOPOLOGY_MANAGER_DESCRIPTION =
39
			"Topology Manager of gvSIG";
40
	
41
	private static final TopologyLocator instance = new TopologyLocator();
42

  
43
	private TopologyLocator() {
44

  
45
	}
46

  
47
	/**
48
	 * Return the singleton instance.
49
	 * 
50
	 * @return the singleton instance
51
	 */
52
	public static TopologyLocator getInstance() {
53
		return instance;
54
	}
55

  
56
        @Override
57
	public String getLocatorName() {
58
		return LOCATOR_NAME;
59
	}
60

  
61
	/**
62
	 * Return a reference to TopologyManager.
63
	 * 
64
	 * @return a reference to TopologyManager
65
	 * @throws LocatorException
66
	 *             if there is no access to the class or the class cannot be
67
	 *             instantiated
68
	 * @see Locator#get(String)
69
	 */
70
	public static TopologyManager getTopologyManager()
71
			throws LocatorException {
72
		return (TopologyManager) getInstance().get(TOPOLOGY_MANAGER_NAME);
73
	}
74

  
75
	/**
76
	 * Registers the Class implementing the TopologyManager interface.
77
	 * 
78
	 * @param clazz
79
	 *            implementing the TopologyManager interface
80
	 */
81
	public static void registerTopologyManager(Class clazz) {
82
		getInstance().register(TOPOLOGY_MANAGER_NAME,
83
				TOPOLOGY_MANAGER_DESCRIPTION, clazz);
84
	}
85

  
86
	public static void registerDefaultTopologyManager(Class clazz) {
87
		getInstance().registerDefault(TOPOLOGY_MANAGER_NAME,
88
				TOPOLOGY_MANAGER_DESCRIPTION, clazz);
89
	}
90

  
91

  
92
}
org.gvsig.topology/tags/org.gvsig.topology-1.0.46/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/api/TopologyLibrary.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 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.lib.api;
25

  
26
import org.gvsig.fmap.dal.DALLibrary;
27
import org.gvsig.fmap.geom.GeometryLibrary;
28
import org.gvsig.tools.ToolsLibrary;
29
import org.gvsig.tools.library.AbstractLibrary;
30
import org.gvsig.tools.library.LibraryException;
31

  
32
/**
33
 *
34
 * @author jjdelcerro
35
 */
36
public class TopologyLibrary extends AbstractLibrary {
37

  
38
    @Override
39
    public void doRegistration() {
40
        super.doRegistration();
41
        registerAsAPI(TopologyLibrary.class);
42
        this.require(ToolsLibrary.class);
43
        this.require(DALLibrary.class);
44
        this.require(GeometryLibrary.class);
45
    }
46

  
47
    @Override
48
    protected void doInitialize() throws LibraryException {
49
    }
50

  
51
    @Override
52
    protected void doPostInitialize() throws LibraryException {
53
    }
54

  
55
}
org.gvsig.topology/tags/org.gvsig.topology-1.0.46/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/api/TopologyRuleAction.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 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.lib.api;
25

  
26
import org.gvsig.tools.dynobject.DynObject;
27

  
28
/**
29
 *
30
 * @author jjdelcerro
31
 */
32
public interface TopologyRuleAction {
33
    
34
    public String getId();
35
    
36
    public String getName();
37
    
38
    public String getShortDescription();
39
    
40
    public TopologyRuleFactory getRuleFactory();
41
    
42
    public boolean hasParameters();
43
    
44
    public DynObject createParameters();
45
    
46
    public void execute(
47
            TopologyRule rule,
48
            TopologyReportLine line, 
49
            DynObject parameters
50
        ) throws ExecuteTopologyRuleActionException;
51
    
52
}
org.gvsig.topology/tags/org.gvsig.topology-1.0.46/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/api/ExecuteTopologyRuleActionException.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 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.lib.api;
25

  
26

  
27
public class ExecuteTopologyRuleActionException extends RuntimeException {
28

  
29
    public ExecuteTopologyRuleActionException(Exception ex) {
30
        this.initCause(ex);
31
    }
32
    
33
}
org.gvsig.topology/tags/org.gvsig.topology-1.0.46/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/api/TopologyRule.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 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.lib.api;
25

  
26
import java.util.List;
27
import org.gvsig.tools.dynobject.DynObject;
28
import org.gvsig.tools.task.SimpleTaskStatus;
29

  
30
/**
31
 *
32
 * @author jjdelcerro
33
 */
34
public interface TopologyRule extends SerializableJSON {
35
    
36
    public void execute(SimpleTaskStatus taskStatus, TopologyReport report) throws ExecuteTopologyRuleException;
37
    
38
    public String getName();
39
    
40
    public String getId();
41
    
42
    public TopologyRuleFactory getFactory();
43
    
44
    public TopologyDataSet getDataSet1();
45
    
46
    public TopologyDataSet getDataSet2();
47
    
48
    public double getTolerance();
49
    
50
    public List<TopologyRuleAction> getActions();
51
    
52
    public TopologyRuleAction getAction(String name);
53
    
54
    public long getSteps();
55

  
56
    public void setParameters(DynObject parameters);
57

  
58
    public DynObject getParameters();
59
}
org.gvsig.topology/tags/org.gvsig.topology-1.0.46/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/api/ExecuteTopologyRuleException.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
/**
9
 *
10
 * @author jjdelcerro
11
 */
12
public class ExecuteTopologyRuleException extends RuntimeException {
13
    public ExecuteTopologyRuleException(Exception ex) {
14
        this.initCause(ex);
15
    }
16
        
17
}
org.gvsig.topology/tags/org.gvsig.topology-1.0.46/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/api/TopologyManager.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 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.lib.api;
25

  
26
import java.util.List;
27
import org.gvsig.fmap.dal.DataStore;
28

  
29
/**
30
 *
31
 * @author jjdelcerro
32
 */
33
public interface TopologyManager {
34
    
35
    public TopologyPlan createTopologyPlan();
36
    
37
    public List<TopologyRuleFactory> getRuleFactories();
38

  
39
    public TopologyRuleFactory getRulefactory(String id);
40
    
41
    public List<TopologyRuleFactory> getRuleFactories(TopologyDataSet dataSet);
42

  
43
    public void addRuleFactories(TopologyRuleFactory factory);
44

  
45
    public TopologyDataSet createDataSet(String name, DataStore store);
46
    
47
    public void setDefaultServices(TopologyServices services);
48

  
49
    public TopologyServices getDefaultServices();
50
}
org.gvsig.topology/tags/org.gvsig.topology-1.0.46/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/api/TopologyReport.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 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.lib.api;
25

  
26
import java.util.List;
27
import org.gvsig.fmap.dal.feature.FeatureReference;
28
import org.gvsig.fmap.geom.Geometry;
29

  
30
/**
31
 *
32
 * @author jjdelcerro
33
 */
34
public interface TopologyReport extends TopologyReportLineSet {
35

  
36
    public static String RULE_ID = "RULE_ID";
37
    public static String IS_ERROR = "IS_ERROR";
38
    public static String IS_EXCEPTION = "IS_EXCEPTION";
39
    public static String GEOMETRY = "GEOMETRY";
40

  
41
    
42
    public TopologyReportLine addLine(
43
            TopologyRule rule,
44
            TopologyDataSet dataSet1,
45
            TopologyDataSet dataSet2,
46
            Geometry geometry,
47
            Geometry error,
48
            FeatureReference feature1,
49
            FeatureReference feature2,
50
            boolean exception,
51
            String description
52
        );
53
    
54
    public TopologyReportLine addLine(
55
            TopologyRule rule,
56
            TopologyDataSet dataSet1,
57
            TopologyDataSet dataSet2,
58
            Geometry geometry,
59
            Geometry error,
60
            FeatureReference feature1,
61
            FeatureReference feature2,
62
            int primitive1,
63
            int primitive2,
64
            boolean exception,
65
            String description,
66
            String data
67
        );
68
    
69
    public void removeAllLines();
70
    
71
    @Override
72
    public List<TopologyReportLine> getLines();
73

  
74
    public List<TopologyReportLine> getLines(String filter);
75
    
76
    public TopologyReportLineSet getLineSet(String filter);
77

  
78
}
org.gvsig.topology/tags/org.gvsig.topology-1.0.46/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/spi/AbstractTopologyRuleAction.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 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.lib.spi;
25

  
26
import java.net.URL;
27
import org.gvsig.tools.dynobject.DynObject;
28
import org.gvsig.topology.lib.api.TopologyLocator;
29
import org.gvsig.topology.lib.api.TopologyRuleAction;
30
import org.gvsig.topology.lib.api.TopologyRuleFactory;
31
import org.json.JSONObject;
32

  
33
/**
34
 *
35
 * @author jjdelcerro
36
 */
37
public abstract class AbstractTopologyRuleAction implements TopologyRuleAction {
38

  
39
    private final String idAction;
40
    private final String idRule;
41
    private String name;
42
    private String shortDescription;
43

  
44
    protected AbstractTopologyRuleAction(
45
            String idRule,
46
            String idAction,
47
            String name,
48
            String shortDescription
49
        ) {
50
        this.idRule = idRule;
51
        this.idAction = idAction;
52
        this.name = name;
53
        this.shortDescription = shortDescription;
54
        this.load_from_resource();
55
    }
56
    
57
    @Override
58
    public String getId() {
59
        return this.idAction;
60
    }
61

  
62
    @Override
63
    public String getName() {
64
        return this.name;
65
    }
66

  
67
    @Override
68
    public String getShortDescription() {
69
        return this.shortDescription;
70
    }
71

  
72
    @Override
73
    public TopologyRuleFactory getRuleFactory() {
74
        TopologyRuleFactory f = TopologyLocator.getTopologyManager().getRulefactory(this.idRule);
75
        return f;
76
    }
77

  
78
    @Override
79
    public boolean hasParameters() {
80
        return false;
81
    }
82

  
83
    @Override
84
    public DynObject createParameters() {
85
        return null;
86
    }
87
    
88
    private void load_from_resource() {
89
        URL url = RuleResourceLoaderUtils.getRuleURL(this.idRule);
90
        JSONObject rule = RuleResourceLoaderUtils.getRule(url);
91
        load_from_resource(url, rule);
92
    }
93
    
94
    protected void load_from_resource(URL jsonUrl, JSONObject rule) {
95
        if( rule == null ) {
96
            return;
97
        }
98
        JSONObject action = RuleResourceLoaderUtils.getAction(rule, this.idAction);
99
        if( action.has("name") ) {
100
            this.name = action.getString("name");
101
        }
102
        if( action.has("description") ) {
103
            this.shortDescription = RuleResourceLoaderUtils.getDescription(jsonUrl, action);
104
        }
105
    }
106

  
107
}
org.gvsig.topology/tags/org.gvsig.topology-1.0.46/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/spi/RuleResourceLoaderUtils.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.spi;
7

  
8
import java.io.File;
9
import java.io.InputStream;
10
import java.net.MalformedURLException;
11
import java.net.URL;
12
import java.util.List;
13
import java.util.Locale;
14
import org.apache.commons.io.FilenameUtils;
15
import org.apache.commons.io.IOUtils;
16
import org.apache.commons.lang3.StringUtils;
17
import org.json.JSONArray;
18
import org.json.JSONObject;
19
import org.slf4j.Logger;
20
import org.slf4j.LoggerFactory;
21

  
22
/**
23
 *
24
 * @author jjdelcerro
25
 */
26
@SuppressWarnings("UseSpecificCatch")
27
public class RuleResourceLoaderUtils {
28
    
29
    private static Logger LOGGER = LoggerFactory.getLogger(RuleResourceLoaderUtils.class);
30
    
31
    public static URL getRuleURL(String idRule) {
32
        String lang = Locale.getDefault().getLanguage();
33
        URL url = RuleResourceLoaderUtils.class.getResource("/org/gvsig/topology/rules/"+lang+"/"+idRule+".json");
34
        if( url == null ) {
35
            url = RuleResourceLoaderUtils.class.getResource("/org/gvsig/topology/rules/en/"+idRule+".json");
36
            if( url == null ) {
37
                return null;
38
            }
39
        }
40
        return url;
41
    }
42
    
43
    public static JSONObject getRule(URL url) {
44
        if( url == null ) {
45
            return null;
46
        }
47
        InputStream is = null;
48
        JSONObject json;
49
        try {
50
            is = url.openStream();
51
            List<String> lines = IOUtils.readLines(is);
52
            json = new JSONObject(StringUtils.join(lines,  "\n"));
53
        } catch (Exception ex) {
54
            LOGGER.warn("Can't load resource from json file '"+url.toString()+"'.", ex);
55
            return null;
56
        } finally {
57
            IOUtils.closeQuietly(is);
58
        }
59
        return json;
60
    }
61

  
62
    public static JSONObject getRule(String idRuleOrPathname) {
63
        if( idRuleOrPathname==null ) {
64
            return null;
65
        }
66
        if( idRuleOrPathname.endsWith(".json") ) {
67
            // Asumimos que es una ruta al fichero json.
68
            return getRule(new File(idRuleOrPathname));
69
        }
70
        // Asumimos que es un ID de regla
71
        URL url = getRuleURL(idRuleOrPathname);
72
        if( url == null ) {
73
            return null;
74
        }
75
        return getRule(url);
76
    }
77
    
78
    public static JSONObject getRule(File jsonfile) {
79
        if( jsonfile == null || !jsonfile.exists() ) {
80
            return null;
81
        }
82
        try {
83
            return getRule(jsonfile.toURI().toURL());
84
        } catch (MalformedURLException ex) {
85
            LOGGER.warn("Can't load resource from json file '"+jsonfile.toString()+"'.", ex);
86
            return null;
87
        }
88
    }
89

  
90
    public static String getDescription(URL jsonUrl, JSONObject json) {
91
        String description = null;
92
        
93
        if( json.has("description") ) {
94
            Object x = json.get("description");
95
            if( x instanceof String ) {
96
                description = (String) x;
97
            } else if( x instanceof JSONArray ) {
98
                StringBuilder builder = new StringBuilder();
99
                for (int i = 0; i < ((JSONArray)x).length(); i++) {
100
                    if( i>0 ) {
101
                        builder.append(" ");
102
                    }
103
                    builder.append(((JSONArray)x).getString(i));
104
                }
105
                description = builder.toString();
106
            } else {
107
                description = x.toString();
108
            }
109
            if( description.contains("@@@") ) {
110
                description = StringUtils.replace(
111
                        description, 
112
                        "@@@", 
113
                        FilenameUtils.removeExtension(jsonUrl.toString())
114
                );
115
            }
116
        }
117
        return description;
118
    }
119
    
120
    public static JSONObject getAction(JSONObject rule, String idAction) {
121
        if( !rule.has("actions") ) {
122
            return null;
123
        }
124
        if( !rule.getJSONObject("actions").has(idAction) ) {
125
            return null;
126
        }
127
        JSONObject action = rule.getJSONObject("actions").getJSONObject(idAction);
128
        return action;
129
    }
130

  
131
}
org.gvsig.topology/tags/org.gvsig.topology-1.0.46/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/spi/AbstractTopologyRule.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 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.lib.spi;
25

  
26
import java.util.ArrayList;
27
import java.util.Collections;
28
import java.util.List;
29
import org.apache.commons.lang3.StringUtils;
30
import org.gvsig.fmap.dal.feature.Feature;
31
import org.gvsig.tools.dynobject.DynClass;
32
import org.gvsig.tools.dynobject.DynField;
33
import org.gvsig.tools.dynobject.DynObject;
34
import org.gvsig.tools.exception.BaseException;
35
import org.gvsig.tools.task.SimpleTaskStatus;
36
import org.gvsig.tools.visitor.VisitCanceledException;
37
import org.gvsig.tools.visitor.Visitor;
38
import org.gvsig.topology.lib.api.TopologyDataSet;
39
import org.gvsig.topology.lib.api.TopologyPlan;
40
import org.gvsig.topology.lib.api.TopologyReport;
41
import org.gvsig.topology.lib.api.TopologyRule;
42
import org.gvsig.topology.lib.api.TopologyRuleAction;
43
import org.gvsig.topology.lib.api.TopologyRuleFactory;
44
import org.json.JSONObject;
45
import org.slf4j.Logger;
46
import org.slf4j.LoggerFactory;
47

  
48
/**
49
 *
50
 * @author jjdelcerro
51
 */
52
public abstract class AbstractTopologyRule implements TopologyRule {
53

  
54
    protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractTopologyRule.class);
55
    
56
    private final TopologyPlan plan;
57
    private final TopologyRuleFactory factory;
58
    private double tolerance;
59
    private String dataSet1;
60
    private String dataSet2;
61

  
62
    protected List<TopologyRuleAction> actions;
63
    private DynObject parameters;
64

  
65
    protected AbstractTopologyRule(
66
            TopologyPlan plan,
67
            TopologyRuleFactory factory,
68
            double tolerance,
69
            String dataSet1,
70
            String dataSet2
71
    ) {
72
        this.plan = plan;
73
        this.factory = factory;
74
        this.tolerance = tolerance;
75
        this.dataSet1 = dataSet1;
76
        this.dataSet2 = dataSet2;
77
        this.actions = new ArrayList<>();
78
    }
79

  
80
    protected AbstractTopologyRule(
81
            TopologyPlan plan,
82
            TopologyRuleFactory factory,
83
            double tolerance,
84
            String dataSet1
85
    ) {
86
        this(plan, factory, tolerance, dataSet1, null);
87
    }
88

  
89
    protected TopologyPlan getPlan() {
90
        return this.plan;
91
    }
92

  
93
    @Override
94
    public TopologyRuleFactory getFactory() {
95
        return this.factory;
96
    }
97

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

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

  
108
    public final void addAction(TopologyRuleAction action) {
109
        this.actions.add(action);
110
    }
111
    
112
    @Override
113
    public boolean equals(Object obj) {
114
        if( !(obj instanceof TopologyRule) ) {
115
            return false;
116
        }
117
        AbstractTopologyRule other = (AbstractTopologyRule)obj;
118
        if( !StringUtils.equals(this.getName(), other.getName()) ) {
119
            return false;
120
        }
121
        if( !StringUtils.equals(this.dataSet1, other.dataSet1) ) {
122
            return false;
123
        }
124
        if( !StringUtils.equals(this.dataSet2, other.dataSet2) ) {
125
            return false;
126
        }
127
        // Ojo con la comparacion de doubles
128
//        if( this.tolerance != other.tolerance ) {
129
//            return false;
130
//        }
131
        return true;
132
    }
133
    
134
    @Override
135
    public String toString() {
136
        return this.getName();
137
    }
138

  
139
    @Override
140
    public TopologyDataSet getDataSet1() {
141
        return this.getPlan().getDataSet(dataSet1);
142
    }
143

  
144
    @Override
145
    public TopologyDataSet getDataSet2() {
146
        return this.getPlan().getDataSet(dataSet2);
147
    }
148

  
149
    @Override
150
    public double getTolerance() {
151
        return this.tolerance;
152
    }
153

  
154
    @Override
155
    public List<TopologyRuleAction> getActions() {
156
        return Collections.unmodifiableList(actions);
157
    }
158

  
159
    @Override
160
    public TopologyRuleAction getAction(String id) {
161
        for (TopologyRuleAction action : actions) {
162
            if (StringUtils.equalsIgnoreCase(id, action.getId())) {
163
                return action;
164
            }
165
        }
166
        return null;
167
    }
168

  
169
    @Override
170
    public long getSteps() {
171
        return this.getDataSet1().getSize();
172
    }
173

  
174
    @Override
175
    public void execute(final SimpleTaskStatus taskStatus, final TopologyReport report) {
176
        try {
177
            this.getDataSet1().accept(new Visitor() {
178
                @Override
179
                public void visit(final Object o1) throws VisitCanceledException, BaseException {
180
                    if( taskStatus.isCancellationRequested() ) {
181
                        throw new VisitCanceledException();
182
                    }
183
                    taskStatus.incrementCurrentValue();
184
                    try {
185
                        check(taskStatus, report, (Feature) o1);
186
                    } catch (Exception ex) {
187
                        throw new RuntimeException(ex);
188
                    }
189
                }
190
            });
191
        } catch(VisitCanceledException ex) {
192
            // return;
193
        }
194
    }
195

  
196
    protected void check(SimpleTaskStatus taskStatus, TopologyReport report, Feature feature) throws Exception {
197
        
198
    }
199

  
200
    @Override
201
    public JSONObject toJSON() {
202
        JSONObject me = new JSONObject();
203
        me.put("tolerance", this.tolerance);
204
        me.put("dataSet1", this.dataSet1);
205
        me.put("dataSet2", this.dataSet2);
206
        
207
        DynObject params = this.getParameters();
208
        if(params!= null) {
209
            JSONObject jsonParams = new JSONObject();
210
            DynClass parametersDefinition = params.getDynClass();
211
            for (DynField dynField : parametersDefinition.getDynFields()) {
212
                jsonParams.put(dynField.getName(), params.getDynValue(dynField.getName()));
213
            }
214
            me.put("params", jsonParams);
215
        }
216
        return me;
217
    }
218

  
219
    @Override
220
    public void fromJSON(String json) {
221
        this.fromJSON(new JSONObject(json));
222
    }
223
    
224
    @Override
225
    public void fromJSON(JSONObject json) {
226
//        this.report = null;
227

  
228
        if( json.has("tolerance") ) {
229
            this.tolerance = json.getDouble("tolerance");
230
        }
231
        if( json.has("dataSet1") ) {
232
            this.dataSet1 = json.getString("dataSet1");
233
        }
234
        if( json.has("dataSet2") ) {
235
            this.dataSet2 = json.getString("dataSet2");
236
        }
237
        if( json.has("params") ) {
238
            JSONObject jsonParams = json.getJSONObject("params");
239
            DynObject params = this.getFactory().createRuleParameters();
240
            DynClass parametersDefinition = params.getDynClass();
241
            for (DynField dynField : parametersDefinition.getDynFields()) {
242
                String paramName = dynField.getName();
243
                if (jsonParams.has(paramName)){
244
                    params.setDynValue(paramName, jsonParams.getString(paramName));
245
                }
246
            }
247
            this.setParameters(params);
248
        }
249
    }
250

  
251
    @Override
252
    public void setParameters(DynObject parameters) {
253
        this.parameters=parameters;
254
        
255
    }
256

  
257
    @Override
258
    public DynObject getParameters() {
259
        return this.parameters;
260
    }
261

  
262
}
org.gvsig.topology/tags/org.gvsig.topology-1.0.46/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/spi/AbstractTopologyRuleFactory.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 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.lib.spi;
25

  
26
import java.net.URL;
27
import java.util.List;
28
import org.gvsig.fmap.geom.GeometryLocator;
29
import org.gvsig.fmap.geom.GeometryManager;
30
import org.gvsig.tools.ToolsLocator;
31
import org.gvsig.tools.dynform.DynFormLocator;
32
import org.gvsig.tools.dynform.DynFormManager;
33
import org.gvsig.tools.dynobject.DynClass;
34
import org.gvsig.tools.dynobject.DynObject;
35
import org.gvsig.tools.dynobject.DynObjectManager;
36
import org.gvsig.topology.lib.api.TopologyDataSet;
37
import org.gvsig.topology.lib.api.TopologyRuleFactory;
38
import org.json.JSONObject;
39
import org.slf4j.Logger;
40
import org.slf4j.LoggerFactory;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff