gvsig-vectorediting / org.gvsig.vectorediting / trunk / org.gvsig.vectorediting / org.gvsig.vectorediting.lib / org.gvsig.vectorediting.lib.impl / src / main / java / org / gvsig / vectorediting / lib / impl / DefaultEditingManager.java @ 2608
History | View | Annotate | Download (3.33 KB)
1 | 159 | llmarques | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | *
|
||
4 | * Copyright ? 2007-2014 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 2
|
||
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 | 4 | llmarques | */
|
24 | 159 | llmarques | |
25 | 4 | llmarques | package org.gvsig.vectorediting.lib.impl; |
26 | |||
27 | 45 | llmarques | import org.gvsig.fmap.dal.feature.FeatureStore; |
28 | 322 | llmarques | import org.gvsig.fmap.mapcontext.MapContext; |
29 | 4 | llmarques | import org.gvsig.tools.dynobject.DynObject; |
30 | import org.gvsig.tools.service.AbstractManager; |
||
31 | import org.gvsig.tools.service.Service; |
||
32 | import org.gvsig.tools.service.ServiceException; |
||
33 | import org.gvsig.vectorediting.lib.api.EditingManager; |
||
34 | 19 | llmarques | import org.gvsig.vectorediting.lib.api.EditingService; |
35 | 4 | llmarques | import org.gvsig.vectorediting.lib.api.EditingServiceInfo; |
36 | 89 | llmarques | import org.gvsig.vectorediting.lib.api.exceptions.ServiceInformationException; |
37 | 17 | llmarques | import org.gvsig.vectorediting.lib.spi.EditingProvider; |
38 | 22 | llmarques | import org.gvsig.vectorediting.lib.spi.EditingProviderFactory; |
39 | 17 | llmarques | import org.gvsig.vectorediting.lib.spi.EditingProviderLocator; |
40 | 2608 | fdiaz | import org.slf4j.Logger; |
41 | import org.slf4j.LoggerFactory; |
||
42 | 4 | llmarques | |
43 | public class DefaultEditingManager extends AbstractManager implements |
||
44 | 227 | llmarques | EditingManager { |
45 | 4 | llmarques | |
46 | 128 | llmarques | private static final Logger logger = LoggerFactory |
47 | 264 | llmarques | .getLogger(DefaultEditingManager.class); |
48 | 2444 | fdiaz | |
49 | 128 | llmarques | public DefaultEditingManager() {
|
50 | super(new DefaultEditingProviderManager()); |
||
51 | } |
||
52 | 4 | llmarques | |
53 | 128 | llmarques | public Service getService(DynObject arg0) throws ServiceException { |
54 | EditingProvider provider = |
||
55 | (EditingProvider) EditingProviderLocator.getProviderManager() |
||
56 | 227 | llmarques | .createProvider(arg0, new DefaultEditingProviderServices());
|
57 | 128 | llmarques | return new DefaultEditingService(provider); |
58 | } |
||
59 | 4 | llmarques | |
60 | 128 | llmarques | public EditingServiceInfo getServiceInfo(String serviceName) |
61 | throws ServiceInformationException {
|
||
62 | return EditingProviderLocator.getProviderManager().getServiceInfo(
|
||
63 | serviceName); |
||
64 | 22 | llmarques | } |
65 | 128 | llmarques | |
66 | 2444 | fdiaz | @Override
|
67 | 128 | llmarques | public EditingService getEditingService(String name, |
68 | 322 | llmarques | FeatureStore featureStore, MapContext mapContext) { |
69 | 128 | llmarques | try {
|
70 | DynObject params = this.createServiceParameters(name);
|
||
71 | params.setDynValue(EditingProviderFactory.FEATURE_STORE_FIELD, |
||
72 | featureStore); |
||
73 | 322 | llmarques | params.setDynValue(EditingProviderFactory.MAPCONTEXT_FIELD, mapContext); |
74 | 128 | llmarques | return (EditingService) this.getService(params); |
75 | } catch (ServiceException e) {
|
||
76 | String msg =
|
||
77 | String
|
||
78 | 227 | llmarques | .format( |
79 | "Some problem getting %1$s editing service. Seems to name is not correct or there is not factory registered with that name. ",
|
||
80 | name); |
||
81 | 166 | llmarques | logger.info(msg, e); |
82 | 128 | llmarques | } |
83 | |||
84 | return null; |
||
85 | 22 | llmarques | } |
86 | 2444 | fdiaz | |
87 | 4 | llmarques | } |