Revision 740
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 | ||
---|---|---|
4 | 4 |
from org.gvsig.fmap.dal.feature import FeatureQueryOrder |
5 | 5 |
from java.lang import RuntimeException |
6 | 6 |
from org.gvsig.app import ApplicationLocator |
7 |
from org.gvsig.tools.evaluator import Evaluator |
|
7 | 8 |
|
8 |
|
|
9 | 9 |
# |
10 | 10 |
# Save methods edit and update that are rewriten in python |
11 | 11 |
# |
... | ... | |
17 | 17 |
|
18 | 18 |
def __features(self, expresion = None, sortby="", asc=True): |
19 | 19 |
if expresion == None and sortby =="": |
20 |
return self.getFeatureSet()
|
|
21 |
|
|
20 |
return self.getFeatureSet() |
|
21 |
|
|
22 | 22 |
try: |
23 | 23 |
application = ApplicationLocator.getManager() |
24 | 24 |
datamanager = application.getDataManager() |
... | ... | |
28 | 28 |
order.add(sortby, asc) |
29 | 29 |
query.setOrder(order) |
30 | 30 |
if expresion != None: |
31 |
query.setFilter(datamanager.createExpresion(expresion)) |
|
31 |
if isinstance(expresion,Evaluator): |
|
32 |
query.setFilter(expresion) |
|
33 |
else: |
|
34 |
query.setFilter(datamanager.createExpresion(expresion)) |
|
32 | 35 |
fset = self.getFeatureSet(query) |
33 | 36 |
return fset |
34 | 37 |
except Exception, e: |
... | ... | |
43 | 46 |
def __append(self, *args, **kwargs): |
44 | 47 |
try: |
45 | 48 |
if not self.isEditing(): |
46 |
self.edit()
|
|
49 |
self.edit() |
|
47 | 50 |
|
48 | 51 |
if len(args) ==1: |
49 | 52 |
if not isinstance(args[0], dict): |
... | ... | |
52 | 55 |
kwargs = args[0] |
53 | 56 |
else: |
54 | 57 |
kwargs.update(args[0]) |
55 |
|
|
58 |
|
|
56 | 59 |
f = self.createNewFeature() |
57 |
|
|
60 |
|
|
58 | 61 |
if f == None: |
59 | 62 |
raise RuntimeException("Failed to create a new Feature") |
60 |
|
|
63 |
|
|
61 | 64 |
for k,v in kwargs.iteritems(): |
62 | 65 |
f.set(k,v) |
63 | 66 |
self.insert(f) |
64 |
|
|
67 |
|
|
65 | 68 |
except Exception, ex: |
66 | 69 |
raise RuntimeException("Can't append values %s to layer %s (%s)" % ( |
67 |
repr(kwargs),
|
|
68 |
self.getName(),
|
|
70 |
repr(kwargs), |
|
71 |
self.getName(), |
|
69 | 72 |
str(ex) |
70 | 73 |
) |
71 | 74 |
) |
72 | 75 |
|
73 | 76 |
def __update(self, feature): |
74 | 77 |
if not self.isEditing(): |
75 |
self.edit()
|
|
76 |
super_update(self, feature)
|
|
78 |
self.edit() |
|
79 |
super_update(self, feature) |
|
77 | 80 |
|
78 | 81 |
def __edit(self, mode=JFeatureStore.MODE_FULLEDIT): |
79 | 82 |
if not self.isEditing(): |
80 | 83 |
super_edit(self, mode) |
81 |
|
|
84 |
|
|
82 | 85 |
def __commit(self): |
83 | 86 |
try: |
84 |
self.finishEditing()
|
|
87 |
self.finishEditing() |
|
85 | 88 |
except Exception, ex: |
86 | 89 |
self.abort() |
87 | 90 |
raise RuntimeException("Can't finish layer edition, cancelling changes. %s" % repr(ex)) |
88 | 91 |
|
89 | 92 |
def __abort(self): |
90 |
self.cancelEditing()
|
|
93 |
self.cancelEditing() |
|
91 | 94 |
|
92 | 95 |
def __call(self): |
93 |
return self
|
|
96 |
return self |
|
94 | 97 |
|
95 | 98 |
|
96 | 99 |
# |
Also available in: Unified diff