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

History | View | Annotate | Download (3.17 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, FLyrVect layer) {
27
    // TODO Auto-generated method stub
28

    
29
  }
30

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

    
36
      // //Reproject the geometry
37
      // Geometry insertedGeometry = geometry;
38
      // if ( getVLE().getLayer().getCoordTrans() != null ) {
39
      // insertedGeometry = insertedGeometry.cloneGeometry();
40
      // insertedGeometry.reProject(getVLE().getLayer().getCoordTrans().getInverted());
41
      // }
42

    
43
      eFeature.setGeometry(featureStore.getDefaultFeatureType()
44
          .getDefaultGeometryAttributeName(), geometry);
45

    
46
      EditingNotificationManager editingNotificationManager = MapControlLocator
47
          .getEditingNotificationManager();
48

    
49
      EditingNotification notification = editingNotificationManager
50
          .notifyObservers(this, EditingNotification.BEFORE_INSERT_FEATURE,
51
              null, layer, featureStore, eFeature);
52
      if (notification.isCanceled()) {
53
        throw new CancelationException("");
54
      }
55
      if (!notification.shouldValidateTheFeature()) {
56
        if (!editingNotificationManager.validateFeature(eFeature)) {
57
          throw new ValidationException("");
58
        }
59
      }
60

    
61
      featureStore.insert(eFeature);
62
      // insertSpatialCache(insertedGeometry);
63
      // draw(insertedGeometry, eFeature);
64

    
65
      editingNotificationManager.notifyObservers(this,
66
          EditingNotification.AFTER_INSERT_FEATURE, null, layer, featureStore,
67
          eFeature);
68

    
69
    }
70
    catch (Exception e) {
71
      NotificationManager.addError(e.getMessage(), e);
72
    }
73
  }
74

    
75
  public void deleteFeatureFromFeatureStore(Feature feature, FLyrVect layer) {
76
    // TODO Auto-generated method stub
77

    
78
  }
79

    
80
  public void deleteGeometryFromFeatureStore(Geometry geometry, FLyrVect layer) {
81
    // TODO Auto-generated method stub
82

    
83
  }
84

    
85
  public void updateFeatureInFeatureStore(Feature feature, FLyrVect layer) {
86
    // TODO Auto-generated method stub
87

    
88
  }
89

    
90
  public void updateGeometryInFeatureStore(Geometry geometry, FLyrVect layer) {
91
    // TODO Auto-generated method stub
92

    
93
  }
94

    
95

    
96
}