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 / DefaultEditingProviderServices.java @ 36

History | View | Annotate | Download (2.79 KB)

1
/*
2
 * Copyright 2014 DiSiD Technologies S.L.L. All rights reserved.
3
 * 
4
 * Project  : DiSiD org.gvsig.vectorediting.lib.impl 
5
 * SVN Id   : $Id$
6
 */
7
package org.gvsig.vectorediting.lib.impl;
8

    
9
import org.exolab.castor.xml.ValidationException;
10
import org.gvsig.andami.messages.NotificationManager;
11
import org.gvsig.editing.EditingNotification;
12
import org.gvsig.editing.EditingNotificationManager;
13
import org.gvsig.fmap.dal.feature.EditableFeature;
14
import org.gvsig.fmap.dal.feature.Feature;
15
import org.gvsig.fmap.dal.feature.FeatureStore;
16
import org.gvsig.fmap.geom.Geometry;
17
import org.gvsig.fmap.mapcontext.layers.CancelationException;
18
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
19
import org.gvsig.fmap.mapcontrol.MapControlLocator;
20
import org.gvsig.tools.service.spi.AbstractProviderServices;
21
import org.gvsig.vectorediting.lib.spi.EditingProviderServices;
22

    
23
public class DefaultEditingProviderServices extends AbstractProviderServices
24
    implements EditingProviderServices {
25

    
26
  public void insertFeatureIntoFeatureStore(Feature feature, FeatureStore featureStore) {
27
    // TODO Auto-generated method stub
28

    
29
  }
30

    
31
  public void insertGeometryIntoFeatureStore(Geometry geometry, FeatureStore featureStore) {
32
    try {
33
      EditableFeature eFeature = featureStore.createNewFeature(true);
34

    
35
      eFeature.setGeometry(featureStore.getDefaultFeatureType()
36
          .getDefaultGeometryAttributeName(), geometry);
37

    
38
      EditingNotificationManager editingNotificationManager = MapControlLocator
39
          .getEditingNotificationManager();
40

    
41
      EditingNotification notification = editingNotificationManager
42
          .notifyObservers(this, EditingNotification.BEFORE_INSERT_FEATURE,
43
              null, null, featureStore, eFeature);
44
      if (notification.isCanceled()) {
45
        throw new CancelationException("");
46
      }
47
      if (!notification.shouldValidateTheFeature()) {
48
        if (!editingNotificationManager.validateFeature(eFeature)) {
49
          throw new ValidationException("");
50
        }
51
      }
52

    
53
      featureStore.insert(eFeature);
54

    
55
      editingNotificationManager.notifyObservers(this,
56
          EditingNotification.AFTER_INSERT_FEATURE, null, null, featureStore,
57
          eFeature);
58

    
59
    }
60
    catch (Exception e) {
61
      NotificationManager.addError(e.getMessage(), e);
62
    }
63
  }
64

    
65
  public void deleteFeatureFromFeatureStore(Feature feature, FeatureStore featureStore) {
66
    // TODO Auto-generated method stub
67

    
68
  }
69

    
70
  public void deleteGeometryFromFeatureStore(Geometry geometry, FeatureStore featureStore) {
71
    // TODO Auto-generated method stub
72

    
73
  }
74

    
75
  public void updateFeatureInFeatureStore(Feature feature, FeatureStore featureStore) {
76
    // TODO Auto-generated method stub
77

    
78
  }
79

    
80
  public void updateGeometryInFeatureStore(Geometry geometry, FeatureStore featureStore) {
81
    // TODO Auto-generated method stub
82

    
83
  }
84

    
85

    
86
}