Statistics
| Revision:

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 @ 322

History | View | Annotate | Download (3.31 KB)

1
/**
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
 */
24

    
25
package org.gvsig.vectorediting.lib.impl;
26

    
27
import org.slf4j.Logger;
28
import org.slf4j.LoggerFactory;
29

    
30
import org.gvsig.fmap.dal.feature.FeatureStore;
31
import org.gvsig.fmap.mapcontext.MapContext;
32
import org.gvsig.tools.dynobject.DynObject;
33
import org.gvsig.tools.service.AbstractManager;
34
import org.gvsig.tools.service.Service;
35
import org.gvsig.tools.service.ServiceException;
36
import org.gvsig.vectorediting.lib.api.EditingManager;
37
import org.gvsig.vectorediting.lib.api.EditingService;
38
import org.gvsig.vectorediting.lib.api.EditingServiceInfo;
39
import org.gvsig.vectorediting.lib.api.exceptions.ServiceInformationException;
40
import org.gvsig.vectorediting.lib.spi.EditingProvider;
41
import org.gvsig.vectorediting.lib.spi.EditingProviderFactory;
42
import org.gvsig.vectorediting.lib.spi.EditingProviderLocator;
43

    
44
public class DefaultEditingManager extends AbstractManager implements
45
EditingManager {
46

    
47
    private static final Logger logger = LoggerFactory
48
        .getLogger(DefaultEditingManager.class);
49

    
50
    public DefaultEditingManager() {
51
        super(new DefaultEditingProviderManager());
52
    }
53

    
54
    public Service getService(DynObject arg0) throws ServiceException {
55
        EditingProvider provider =
56
            (EditingProvider) EditingProviderLocator.getProviderManager()
57
            .createProvider(arg0, new DefaultEditingProviderServices());
58
        return new DefaultEditingService(provider);
59
    }
60

    
61
    public EditingServiceInfo getServiceInfo(String serviceName)
62
        throws ServiceInformationException {
63
        return EditingProviderLocator.getProviderManager().getServiceInfo(
64
            serviceName);
65
    }
66

    
67
    public EditingService getEditingService(String name,
68
        FeatureStore featureStore, MapContext mapContext) {
69
        try {
70
            DynObject params = this.createServiceParameters(name);
71
            params.setDynValue(EditingProviderFactory.FEATURE_STORE_FIELD,
72
                featureStore);
73
            params.setDynValue(EditingProviderFactory.MAPCONTEXT_FIELD, mapContext);
74
            return (EditingService) this.getService(params);
75
        } catch (ServiceException e) {
76
            String msg =
77
                String
78
                .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
            logger.info(msg, e);
82
        }
83

    
84
        return null;
85
    }
86

    
87
}