svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.exportto / org.gvsig.exportto.lib / org.gvsig.exportto.lib.impl / src / main / java / org / gvsig / export / impl / service / DefaultExportServiceManager.java @ 44390
History | View | Annotate | Download (3.99 KB)
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.export.impl.service; |
7 |
|
8 |
import java.util.ArrayList; |
9 |
import java.util.Collections; |
10 |
import java.util.HashMap; |
11 |
import java.util.List; |
12 |
import java.util.Map; |
13 |
import org.cresques.cts.ICoordTrans; |
14 |
import org.gvsig.export.ExportAttributes; |
15 |
import org.gvsig.export.ExportParameters; |
16 |
import org.gvsig.export.ExportParametersGeometry; |
17 |
import org.gvsig.export.Filter; |
18 |
import org.gvsig.export.impl.ExportGeometryUtils; |
19 |
import org.gvsig.export.spi.AttributeNamesTranslator; |
20 |
import org.gvsig.export.spi.ExportGeometryHelper; |
21 |
import org.gvsig.export.spi.ExportService; |
22 |
import org.gvsig.export.spi.ExportServiceFactory; |
23 |
import org.gvsig.export.spi.ExportServiceManager; |
24 |
import org.gvsig.fmap.dal.feature.FeatureType; |
25 |
import org.gvsig.fmap.geom.Geometry; |
26 |
import org.gvsig.tools.bookmarksandhistory.Bookmark; |
27 |
import org.gvsig.tools.bookmarksandhistory.Bookmarks; |
28 |
import org.gvsig.tools.bookmarksandhistory.History; |
29 |
import org.gvsig.tools.bookmarksandhistory.impl.BaseBookmarks; |
30 |
import org.gvsig.tools.bookmarksandhistory.impl.BaseHistory; |
31 |
import org.slf4j.Logger; |
32 |
import org.slf4j.LoggerFactory; |
33 |
|
34 |
/**
|
35 |
*
|
36 |
* @author jjdelcerro
|
37 |
*/
|
38 |
public class DefaultExportServiceManager implements ExportServiceManager { |
39 |
|
40 |
private static final Logger LOG = LoggerFactory.getLogger(DefaultExportServiceManager.class); |
41 |
|
42 |
private final Map<String, ExportServiceFactory> factories; |
43 |
|
44 |
public DefaultExportServiceManager() {
|
45 |
super();
|
46 |
this.factories = new HashMap<>(); |
47 |
} |
48 |
|
49 |
@Override
|
50 |
public ExportServiceFactory getServiceFactory(String name) { |
51 |
ExportServiceFactory factory = this.factories.get(name);
|
52 |
if (factory == null) { |
53 |
throw new IllegalArgumentException("Don't exists export factory '" + name + "'."); |
54 |
} |
55 |
return factory;
|
56 |
} |
57 |
|
58 |
@Override
|
59 |
public ExportService createService(ExportParameters parameters) {
|
60 |
return this.getServiceFactory(parameters.getServiceName()).createService(parameters); |
61 |
} |
62 |
|
63 |
@Override
|
64 |
public ExportParameters createServiceParameters(String name) { |
65 |
return this.getServiceFactory(name).createParameters(); |
66 |
} |
67 |
|
68 |
@Override
|
69 |
public void register(ExportServiceFactory factory) { |
70 |
this.factories.put(factory.getName(), factory);
|
71 |
} |
72 |
|
73 |
@Override
|
74 |
public List<ExportServiceFactory> getAllServiceFactories() { |
75 |
List<ExportServiceFactory> result = new ArrayList<>(); |
76 |
result.addAll(this.factories.values());
|
77 |
return Collections.unmodifiableList(result); |
78 |
} |
79 |
|
80 |
@Override
|
81 |
public List<ExportServiceFactory> getServiceFactories(Filter<ExportServiceFactory> filter) { |
82 |
List<ExportServiceFactory> result = new ArrayList<>(); |
83 |
if (filter == null) { |
84 |
result.addAll(this.factories.values());
|
85 |
} else {
|
86 |
for (ExportServiceFactory factory : this.factories.values()) { |
87 |
if (factory.isEnabled() && filter.apply(factory)) {
|
88 |
result.add(factory); |
89 |
} |
90 |
} |
91 |
} |
92 |
return Collections.unmodifiableList(result); |
93 |
} |
94 |
|
95 |
@Override
|
96 |
public FixGeometryStatus fixGeometry(
|
97 |
ExportParametersGeometry parmeters, |
98 |
ICoordTrans coord_trans, |
99 |
Geometry geometry |
100 |
) { |
101 |
return ExportGeometryUtils.fixGeometry(parmeters, coord_trans, geometry);
|
102 |
} |
103 |
|
104 |
@Override
|
105 |
public ExportGeometryHelper createGeometryHelper(ExportParametersGeometry parameters, FeatureType theTargetFeatureType, FeatureType theSourceFeatureType) {
|
106 |
DefaultExportGeometryHelper helper = new DefaultExportGeometryHelper(
|
107 |
parameters, |
108 |
theTargetFeatureType, |
109 |
theSourceFeatureType |
110 |
); |
111 |
return helper;
|
112 |
|
113 |
} |
114 |
|
115 |
@Override
|
116 |
public ExportAttributes createExportAttributes() {
|
117 |
DefaultExportAttributes exp = new DefaultExportAttributes();
|
118 |
return exp;
|
119 |
} |
120 |
} |