Revision 690 org.gvsig.scripting/trunk/org.gvsig.scripting/org.gvsig.scripting.app/org.gvsig.scripting.app.mainplugin/src/main/resources-plugin/scripting/lib/gvsig/featurestore.py
featurestore.py | ||
---|---|---|
10 | 10 |
|
11 | 11 |
def __features(self, expresion = None, sortby="", asc=True): |
12 | 12 |
if expresion == None and sortby =="": |
13 |
return self.getFeatureSet()
|
|
14 |
|
|
13 |
return self.getFeatureSet() |
|
14 |
|
|
15 | 15 |
try: |
16 | 16 |
application = ApplicationLocator.getManager() |
17 | 17 |
datamanager = application.getDataManager() |
... | ... | |
36 | 36 |
def __append(self, *args, **kwargs): |
37 | 37 |
try: |
38 | 38 |
if not self.isEditing(): |
39 |
self.super_edit()
|
|
39 |
JFeatureStore.edit(self)
|
|
40 | 40 |
|
41 | 41 |
if len(args) ==1: |
42 | 42 |
if not isinstance(args[0], dict): |
... | ... | |
45 | 45 |
kwargs = args[0] |
46 | 46 |
else: |
47 | 47 |
kwargs.update(args[0]) |
48 |
|
|
48 |
|
|
49 | 49 |
f = self.createNewFeature() |
50 |
|
|
50 |
|
|
51 | 51 |
if f == None: |
52 | 52 |
raise RuntimeException("Failed to create a new Feature") |
53 |
|
|
53 |
|
|
54 | 54 |
for k,v in kwargs.iteritems(): |
55 | 55 |
f.set(k,v) |
56 | 56 |
self.insert(f) |
57 |
|
|
57 |
|
|
58 | 58 |
except Exception, ex: |
59 | 59 |
raise RuntimeException("Can't append values %s to layer %s (%s)" % ( |
60 |
repr(kwargs),
|
|
61 |
self.getName(),
|
|
60 |
repr(kwargs), |
|
61 |
self.getName(), |
|
62 | 62 |
str(ex) |
63 | 63 |
) |
64 | 64 |
) |
65 | 65 |
|
66 | 66 |
def __update(self, feature): |
67 | 67 |
if not self.isEditing(): |
68 |
self.super_edit()
|
|
69 |
self.super_update(feature)
|
|
68 |
JFeatureStore.edit(self, mode)
|
|
69 |
JFeatureStore.update(self, feature)
|
|
70 | 70 |
|
71 | 71 |
def __edit(self, mode=1): |
72 | 72 |
if not self.isEditing(): |
73 |
self.super_edit(mode)
|
|
74 |
|
|
73 |
JFeatureStore.edit(self, mode)
|
|
74 |
|
|
75 | 75 |
def __commit(self): |
76 | 76 |
try: |
77 |
self.finishEditing()
|
|
77 |
self.finishEditing() |
|
78 | 78 |
except Exception, ex: |
79 | 79 |
self.abort() |
80 | 80 |
raise RuntimeException("Can't finish layer edition, cancelling changes. %s" % repr(ex)) |
81 | 81 |
|
82 | 82 |
def __abort(self): |
83 |
self.cancelEditing()
|
|
83 |
self.cancelEditing() |
|
84 | 84 |
|
85 | 85 |
def __call(self): |
86 |
return self
|
|
86 |
return self |
|
87 | 87 |
|
88 | 88 |
|
89 | 89 |
# |
90 |
# Save methods edit and update that are rewriten in python |
|
91 |
# |
|
92 |
JFeatureStore.super_edit = JFeatureStore.edit |
|
93 |
JFeatureStore.super_update = JFeatureStore.update |
|
94 |
# |
|
95 | 90 |
# Inject new methods in the class JFeatureStore |
96 | 91 |
# |
97 | 92 |
JFeatureStore.getSchema = __getSchema |
Also available in: Unified diff