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 @ 727
History | View | Annotate | Download (3.19 KB)
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.impl; |
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.DataStore; |
31 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
32 |
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 |
private final List<TopologyRuleFactory> factories; |
45 |
private TopologyServices services;
|
46 |
|
47 |
public DefaultTopologyManager() {
|
48 |
this.factories = new ArrayList<>(); |
49 |
} |
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 |
return Collections.unmodifiableList(this.factories); |
60 |
} |
61 |
|
62 |
@Override
|
63 |
public List<TopologyRuleFactory> getRuleFactories(TopologyDataSet dataSet) { |
64 |
List<TopologyRuleFactory> f = new ArrayList<>(); |
65 |
for (TopologyRuleFactory factory : this.factories) { |
66 |
if( factory.canApplyToDataSet(dataSet) ) {
|
67 |
f.add(factory); |
68 |
} |
69 |
} |
70 |
return f;
|
71 |
} |
72 |
|
73 |
@Override
|
74 |
public TopologyRuleFactory getRulefactory(String id) { |
75 |
for (TopologyRuleFactory factory : this.factories) { |
76 |
if( StringUtils.equalsIgnoreCase(id, factory.getId()) ) {
|
77 |
return factory;
|
78 |
} |
79 |
} |
80 |
return null; |
81 |
} |
82 |
|
83 |
@Override
|
84 |
public void addRuleFactories(TopologyRuleFactory factory) { |
85 |
this.factories.add(factory);
|
86 |
} |
87 |
|
88 |
@Override
|
89 |
public TopologyDataSet createDataSet(String name, DataStore store) { |
90 |
TopologyDataSet dataSet = new DefaultTopologyDataSet(this.services, name, store); |
91 |
return dataSet;
|
92 |
} |
93 |
|
94 |
@Override
|
95 |
public void setDefaultServices(TopologyServices services) { |
96 |
this.services = services;
|
97 |
} |
98 |
|
99 |
@Override
|
100 |
public TopologyServices getDefaultServices() {
|
101 |
return this.services; |
102 |
} |
103 |
|
104 |
} |