gvsig-projects-pool / org.gvsig.topology / trunk / org.gvsig.topology / org.gvsig.topology.lib / org.gvsig.topology.lib.impl / src / main / java / org / gvsig / topology / lib / impl / DefaultTopologyManager.java @ 2067
History | View | Annotate | Download (3.31 KB)
1 | 688 | jjdelcerro | /**
|
---|---|---|---|
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.impl; |
||
25 | |||
26 | import java.util.ArrayList; |
||
27 | import java.util.Collections; |
||
28 | 886 | jjdelcerro | import java.util.HashMap; |
29 | 688 | jjdelcerro | import java.util.List; |
30 | 886 | jjdelcerro | import java.util.Map; |
31 | 727 | jjdelcerro | import org.gvsig.fmap.dal.DataStore; |
32 | 688 | jjdelcerro | import org.gvsig.topology.lib.api.TopologyDataSet; |
33 | import org.gvsig.topology.lib.api.TopologyManager; |
||
34 | import org.gvsig.topology.lib.api.TopologyPlan; |
||
35 | import org.gvsig.topology.lib.api.TopologyRuleFactory; |
||
36 | import org.gvsig.topology.lib.api.TopologyServices; |
||
37 | |||
38 | /**
|
||
39 | *
|
||
40 | * @author jjdelcerro
|
||
41 | */
|
||
42 | public class DefaultTopologyManager implements TopologyManager { |
||
43 | |||
44 | 886 | jjdelcerro | private final Map<String,TopologyRuleFactory> factories; |
45 | 688 | jjdelcerro | private TopologyServices services;
|
46 | |||
47 | public DefaultTopologyManager() {
|
||
48 | 886 | jjdelcerro | this.factories = new HashMap<>(); |
49 | 688 | jjdelcerro | } |
50 | |||
51 | @Override
|
||
52 | public TopologyPlan createTopologyPlan() {
|
||
53 | TopologyPlan plan = new DefaultTopologyPlan(this, this.services); |
||
54 | return plan;
|
||
55 | } |
||
56 | |||
57 | @Override
|
||
58 | public List<TopologyRuleFactory> getRuleFactories() { |
||
59 | 886 | jjdelcerro | List<TopologyRuleFactory> l = new ArrayList<>(this.factories.values()); |
60 | return Collections.unmodifiableList(l); |
||
61 | 688 | jjdelcerro | } |
62 | |||
63 | @Override
|
||
64 | public List<TopologyRuleFactory> getRuleFactories(TopologyDataSet dataSet) { |
||
65 | List<TopologyRuleFactory> f = new ArrayList<>(); |
||
66 | 886 | jjdelcerro | for (TopologyRuleFactory factory : this.factories.values()) { |
67 | 688 | jjdelcerro | if( factory.canApplyToDataSet(dataSet) ) {
|
68 | f.add(factory); |
||
69 | } |
||
70 | } |
||
71 | return f;
|
||
72 | } |
||
73 | |||
74 | @Override
|
||
75 | public TopologyRuleFactory getRulefactory(String id) { |
||
76 | 886 | jjdelcerro | if( id==null ) { |
77 | return null; |
||
78 | 688 | jjdelcerro | } |
79 | 886 | jjdelcerro | TopologyRuleFactory factory = this.factories.get(id.toLowerCase());
|
80 | return factory;
|
||
81 | 688 | jjdelcerro | } |
82 | |||
83 | @Override
|
||
84 | public void addRuleFactories(TopologyRuleFactory factory) { |
||
85 | 886 | jjdelcerro | if( factory==null ) { |
86 | throw new IllegalArgumentException("Invalid null value."); |
||
87 | } |
||
88 | this.factories.put(factory.getId().toLowerCase(), factory);
|
||
89 | 688 | jjdelcerro | } |
90 | |||
91 | @Override
|
||
92 | 727 | jjdelcerro | public TopologyDataSet createDataSet(String name, DataStore store) { |
93 | 688 | jjdelcerro | TopologyDataSet dataSet = new DefaultTopologyDataSet(this.services, name, store); |
94 | return dataSet;
|
||
95 | } |
||
96 | |||
97 | @Override
|
||
98 | public void setDefaultServices(TopologyServices services) { |
||
99 | this.services = services;
|
||
100 | } |
||
101 | |||
102 | @Override
|
||
103 | public TopologyServices getDefaultServices() {
|
||
104 | return this.services; |
||
105 | } |
||
106 | |||
107 | } |