forked from ome/omero-py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathomero_sys_ParametersI.py
362 lines (307 loc) · 10 KB
/
omero_sys_ParametersI.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
/*
* $Id$
*
* Copyright 2008 Glencoe Software, Inc. All rights reserved.
* Use is subject to license terms supplied in LICENSE.txt
*
*/
"""
import Ice
import omero
from omero.rtypes import rint, rbool, rtime, rlist, rstring, rlong
_omero = Ice.openModule("omero")
_omero_sys = Ice.openModule("omero.sys")
__name__ = "omero.sys"
class ParametersI(omero.sys.Parameters):
"""
Helper subclass of omero.sys.Parameters for simplifying method
parameter creation.
"""
def __init__(self, parammap=None):
"""
If no argument is provided, creates an instance to prevent later
NoneType exceptions. To save memory, it is possible to pass None
as the first argument.
In order to prevent a single dict being referenced by several
instances of ParametersI a new dict is created if an empty one is
passed in either implicitly or explicitly.
Uses (and does not copy) the given dict as the named parameter
store in this instance. Be careful if either null is passed in
or if this instance is being used in a multi-threaded environment.
No synchronization takes place.
"""
if parammap is None or len(parammap) == 0:
self.map = {}
else:
self.map = parammap
self.theFilter = None
self.theOptions = None
def _rt(self, arg, rt):
"""
if arg is None, return None, otherwise use the
rt callable to wrap the argument.
"""
if arg is None:
return None
else:
return rt(arg)
# Parameters.theFilter.limit & offset
# ====================================================================
def noPage(self):
"""
Nulls both the Filter.limit and Filter.offset values.
"""
if self.theFilter:
self.theFilter.limit = None
self.theFilter.offset = None
return self
def page(self, offset, limit):
"""
Sets both the Filter.limit and Filter.offset values by
wrapping the arguments in omero.RInts if necessary.
"""
if not self.theFilter:
self.theFilter = omero.sys.Filter()
self.theFilter.limit = self._rt(limit, rint)
self.theFilter.offset = self._rt(offset, rint)
return self
def isPagination(self):
"""
Returns True if the filter contains a limit OR an offset,
False otherwise.
"""
if self.theFilter:
return None != self.theFilter.limit or \
None != self.theFilter.offset
return False
def getOffset(self):
"""
Returns the value of the offset parameter.
"""
if self.theFilter:
return self.theFilter.offset
return None
def getLimit(self):
"""
Returns the value of the limit parameter.
"""
if self.theFilter:
return self.theFilter.limit
return None
def unique(self):
if not self.theFilter:
self.theFilter = omero.sys.Filter()
self.theFilter.unique = rbool(True)
return self
def noUnique(self):
if not self.theFilter:
self.theFilter = omero.sys.Filter()
self.theFilter.unique = rbool(False)
return self
def getUnique(self):
if self.theFilter:
return self.theFilter.unique
return None
# Parameters.theFilter.ownerId & groupId
# ====================================================================
def exp(self, i):
"""
Sets the value of the <code>experimenter</code> parameter.
"""
if not self.theFilter:
self.theFilter = omero.sys.Filter()
self.theFilter.ownerId = self._rt(i, rlong)
return self
def allExps(self):
"""
Removes the <code>experimenter</code> parameter from the map.
"""
if self.theFilter:
self.theFilter.ownerId = None
return self
def isExperimenter(self):
"""
Returns <code>true</code> if the filter contains and
<code>ownerId</code> parameter, <code>false</code> otherwise.
"""
if self.theFilter:
return None != self.theFilter.ownerId
return False
def getExperimenter(self):
"""
Returns the value of the <code>experimenter</code> parameter.
"""
if self.theFilter:
return self.theFilter.ownerId
return None
def grp(self, i):
"""
Sets the value of the <code>group</code> parameter.
"""
if not self.theFilter:
self.theFilter = omero.sys.Filter()
self.theFilter.groupId = self._rt(i, rlong)
return self
def allGrps(self):
"""
Removes the <code>group</code> parameter from the map.
"""
if self.theFilter:
self.theFilter.groupId = None
return self
def isGroup(self):
"""
Returns <code>true</code> if the filter contains an
<code>groupId</code>, <code>false</code> otherwise.
"""
if self.theFilter:
return None != self.theFilter.groupId
return False
def getGroup(self):
"""
Returns the value of the <code>group</code> parameter.
"""
if self.theFilter:
return self.theFilter.groupId
return None
# ~ Parameters.theFilter.startTime, endTime
# ====================================================================
def startTime(self, startTime):
"""
Sets the value of the <code>start time</code> parameter.
"""
if not self.theFilter:
self.theFilter = omero.sys.Filter()
self.theFilter.startTime = self._rt(startTime, rtime)
return self
def endTime(self, endTime):
"""
Sets the value of the <code>end time</code> parameter.
"""
if not self.theFilter:
self.theFilter = omero.sys.Filter()
self.theFilter.endTime = self._rt(endTime, rtime)
return self
def allTimes(self):
"""
Removes the time parameters from the map.
"""
if self.theFilter:
self.theFilter.startTime = None
self.theFilter.endTime = None
return self
def isStartTime(self):
"""
Returns <code>true</code> if the map contains the
<code>startTime</code> parameter, <code>false</code> otherwise.
"""
if self.theFilter:
return None != self.theFilter.startTime
return False
def getStartTime(self):
"""
Returns the value of the <code>start time</code> parameter.
"""
if self.theFilter:
return self.theFilter.startTime
return None
def isEndTime(self):
"""
Returns <code>true</code> if the map contains the <code>end time</code>
parameter, <code>false</code> otherwise.
"""
if self.theFilter:
return None != self.theFilter.endTime
return False
def getEndTime(self):
"""
Returns the value of the <code>end time</code> parameter.
"""
if self.theFilter:
return self.theFilter.endTime
return None
# ~ Parameters.theOption.leaves, orphan, acquisitionData, cacheable
# ====================================================================
def leaves(self):
if not self.theOptions:
self.theOptions = omero.sys.Options()
self.theOptions.leaves = rbool(True)
return self
def noLeaves(self):
if not self.theOptions:
self.theOptions = omero.sys.Options()
self.theOptions.leaves = rbool(False)
return self
def getLeaves(self):
if self.theOptions:
return self.theOptions.leaves
return None
def orphan(self):
if not self.theOptions:
self.theOptions = omero.sys.Options()
self.theOptions.orphan = rbool(True)
return self
def noOrphan(self):
if not self.theOptions:
self.theOptions = omero.sys.Options()
self.theOptions.orphan = rbool(False)
return self
def getOrphan(self):
if self.theOptions:
return self.theOptions.orphan
return None
def acquisitionData(self):
if not self.theOptions:
self.theOptions = omero.sys.Options()
self.theOptions.acquisitionData = rbool(True)
return self
def noAcquisitionData(self):
if not self.theOptions:
self.theOptions = omero.sys.Options()
self.theOptions.acquisitionData = rbool(False)
return self
def getAcquisitionData(self):
if self.theOptions:
return self.theOptions.acquisitionData
return None
def cache(self):
if not self.theOptions:
self.theOptions = omero.sys.Options()
self.theOptions.cache = rbool(True)
return self
def noCache(self):
if not self.theOptions:
self.theOptions = omero.sys.Options()
self.theOptions.cache = rbool(False)
return self
def getCache(self):
if self.theOptions:
return self.theOptions.cache
return None
# Parameters.map
# ====================================================================
def add(self, name, rtype):
self.map[name] = rtype
return self
def addId(self, id):
self.addLong("id", rlong(id))
return self
def addIds(self, longs):
self.addLongs("ids", longs)
return self
def addLong(self, name, longValue):
self.add(name, rlong(longValue))
return self
def addLongs(self, name, longs):
rlongs = rlist([])
for l in longs:
rlongs.val.append(rlong(l))
self.add(name, rlongs)
return self
def addString(self, name, stringValue):
self.add(name, rstring(stringValue))
return self
_omero_sys.ParametersI = ParametersI