Revision 1832

View differences:

org.gvsig.topology/tags/org.gvsig.topology-1.0.28/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.28/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.28/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.28/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.28/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.awt.Image;
27
import java.util.List;
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 TopologyRule createRule(TopologyPlan plan, String dataSet1, String dataSet2, double tolerance);
46

  
47
    public boolean hasSecondaryDataSet();
48

  
49
    public boolean canApplyToDataSet(TopologyDataSet dataSet);
50
    
51
    public boolean canApplyToSecondaryDataSet(TopologyDataSet dataSet);
52

  
53
    
54
}
org.gvsig.topology/tags/org.gvsig.topology-1.0.28/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.28/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.28/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.28/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.28/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.28/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.task.SimpleTaskStatus;
28

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

  
55
}
org.gvsig.topology/tags/org.gvsig.topology-1.0.28/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.28/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.28/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.28/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.28/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.28/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.28/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.28/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.28/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.28/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.exception.BaseException;
32
import org.gvsig.tools.task.SimpleTaskStatus;
33
import org.gvsig.tools.visitor.VisitCanceledException;
34
import org.gvsig.tools.visitor.Visitor;
35
import org.gvsig.topology.lib.api.TopologyDataSet;
36
import org.gvsig.topology.lib.api.TopologyPlan;
37
import org.gvsig.topology.lib.api.TopologyReport;
38
import org.gvsig.topology.lib.api.TopologyRule;
39
import org.gvsig.topology.lib.api.TopologyRuleAction;
40
import org.gvsig.topology.lib.api.TopologyRuleFactory;
41
import org.json.JSONObject;
42
import org.slf4j.Logger;
43
import org.slf4j.LoggerFactory;
44

  
45
/**
46
 *
47
 * @author jjdelcerro
48
 */
49
public abstract class AbstractTopologyRule implements TopologyRule {
50

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

  
59
    protected List<TopologyRuleAction> actions;
60

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

  
76
    protected AbstractTopologyRule(
77
            TopologyPlan plan,
78
            TopologyRuleFactory factory,
79
            double tolerance,
80
            String dataSet1
81
    ) {
82
        this(plan, factory, tolerance, dataSet1, null);
83
    }
84

  
85
    protected TopologyPlan getPlan() {
86
        return this.plan;
87
    }
88

  
89
    @Override
90
    public TopologyRuleFactory getFactory() {
91
        return this.factory;
92
    }
93

  
94
    @Override
95
    public String getName() {
96
        return this.getFactory().getName();
97
    }
98

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

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

  
135
    @Override
136
    public TopologyDataSet getDataSet1() {
137
        return this.getPlan().getDataSet(dataSet1);
138
    }
139

  
140
    @Override
141
    public TopologyDataSet getDataSet2() {
142
        return this.getPlan().getDataSet(dataSet2);
143
    }
144

  
145
    @Override
146
    public double getTolerance() {
147
        return this.tolerance;
148
    }
149

  
150
    @Override
151
    public List<TopologyRuleAction> getActions() {
152
        return Collections.unmodifiableList(actions);
153
    }
154

  
155
    @Override
156
    public TopologyRuleAction getAction(String id) {
157
        for (TopologyRuleAction action : actions) {
158
            if (StringUtils.equalsIgnoreCase(id, action.getId())) {
159
                return action;
160
            }
161
        }
162
        return null;
163
    }
164

  
165
    @Override
166
    public long getSteps() {
167
        return this.getDataSet1().getSize();
168
    }
169

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

  
192
    protected void check(SimpleTaskStatus taskStatus, TopologyReport report, Feature feature) throws Exception {
193
        
194
    }
195

  
196
    @Override
197
    public JSONObject toJSON() {
198
        JSONObject me = new JSONObject();
199
        me.put("tolerance", this.tolerance);
200
        me.put("dataSet1", this.dataSet1);
201
        me.put("dataSet2", this.dataSet2);
202
        
203
        return me;
204
    }
205

  
206
    @Override
207
    public void fromJSON(String json) {
208
        this.fromJSON(new JSONObject(json));
209
    }
210
    
211
    @Override
212
    public void fromJSON(JSONObject json) {
213
//        this.report = null;
214

  
215
        if( json.has("tolerance") ) {
216
            this.tolerance = json.getDouble("tolerance");
217
        }
218
        if( json.has("dataSet1") ) {
219
            this.dataSet1 = json.getString("dataSet1");
220
        }
221
        if( json.has("dataSet2") ) {
222
            this.dataSet2 = json.getString("dataSet2");
223
        }
224
    }
225

  
226
}
org.gvsig.topology/tags/org.gvsig.topology-1.0.28/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.topology.lib.api.TopologyDataSet;
31
import org.gvsig.topology.lib.api.TopologyRuleFactory;
32
import org.json.JSONObject;
33
import org.slf4j.Logger;
34
import org.slf4j.LoggerFactory;
35

  
36
/**
37
 *
38
 * @author jjdelcerro
39
 */
40
public abstract class AbstractTopologyRuleFactory implements TopologyRuleFactory {
41
    
42
    protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractTopologyRuleFactory.class);
43
    
44
    private final String id;
45
    protected String name;
46
    protected String description;
47
    private final List<Integer> geometryTypeDataSet1;
48
    private final List<Integer> geometryTypeDataSet2;
49

  
50
    protected AbstractTopologyRuleFactory(
51
            String id,
52
            String name,
53
            String description,
54
            List<Integer> geometryTypeDataSet1,
55
            List<Integer> geometryTypeDataSet2
56
        ) {
57
        this.id = id;
58
        this.name = name;
59
        this.description = description;
60
        this.geometryTypeDataSet1 = geometryTypeDataSet1;
61
        this.geometryTypeDataSet2 = geometryTypeDataSet2;
62
        this.load_from_resource();
63
    }
64

  
65
    protected AbstractTopologyRuleFactory(
66
            String id,
67
            String name,
68
            String description,
69
            List<Integer> geometryTypeDataSet1
70
        ) {
71
        this(id, name, description, geometryTypeDataSet1, null);
72
    }
73

  
74
    @Override
75
    public String toString() {
76
        return this.name;
77
    }
78
    
79
    @Override
80
    public String getId() {
81
        return this.id;
82
    }
83

  
84
    @Override
85
    public String getName() {
86
        return this.name;
87
    }
88

  
89
    @Override
90
    public String getDescription() {
91
        return this.description;
92
    }
93

  
94
    @Override
95
    public List<Integer> getGeometryTypeDataSet1() {
96
        return this.geometryTypeDataSet1;
97
    }
98

  
99
    @Override
100
    public List<Integer> getGeometryTypeDataSet2() {
101
        return this.geometryTypeDataSet2;
102
    }
103

  
104
    @Override
105
    public boolean hasSecondaryDataSet() {
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff