def testFilter(self): p = ParametersI() p.noPage() self.assertEquals(None, p.theFilter) p.page(2, 3) self.assert_(p.isPagination()) self.assertEquals(rint(2), p.theFilter.offset) self.assertEquals(rint(3), p.theFilter.limit) p.noPage() self.assertFalse(p.isPagination()) self.assertEquals(None, p.theFilter.offset) self.assertEquals(None, p.theFilter.limit) self.assertEquals(None, p.getLimit()) self.assertEquals(None, p.getOffset())
def testFilter(self): p = ParametersI() p.noPage() assert None == p.theFilter p.page(2, 3) assert p.isPagination() assert rint(2) == p.theFilter.offset assert rint(3) == p.theFilter.limit p.noPage() assert not p.isPagination() assert None == p.theFilter.offset assert None == p.theFilter.limit assert None == p.getLimit() assert None == p.getOffset()
def testFilter(self): p = ParametersI() p.noPage() self.assertEquals(None, p.theFilter) p.page(2,3) self.assert_(p.isPagination()) self.assertEquals( rint(2), p.theFilter.offset ) self.assertEquals( rint(3), p.theFilter.limit ) p.noPage() self.assertFalse(p.isPagination()) self.assertEquals(None, p.theFilter.offset) self.assertEquals(None, p.theFilter.limit) self.assertEquals(None, p.getLimit()) self.assertEquals(None, p.getOffset())
def hql(self, args, loop = False): from omero_sys_ParametersI import ParametersI ice_map = dict() if args.admin: ice_map["omero.group"]="-1" c = self.ctx.conn(args) q = c.sf.getQueryService() p = ParametersI() p.page(args.offset, args.limit) rv = self.project(q, args.query, p, ice_map) has_details = self.display(rv) if args.quiet: return input = """ To see details for object, enter line number. To move ahead one page, enter 'p' To re-display list, enter 'r'. To quit, enter 'q' or just enter. """ if loop: input = input + """To run another query, press enter\n""" while True: id = self.ctx.input(input) id = id.lower() # Exit loop if not id: return True if id.startswith("q"): return False # Stay in loop if id.startswith("p"): p.page(p.getOffset().val + p.getLimit().val, p.getLimit()) self.ctx.dbg("\nCurrent page: offset=%s, limit=%s\n" % (p.theFilter.offset.val, p.theFilter.limit.val)) rv = self.project(q, args.query, p, ice_map) self.display(rv) elif id.startswith("r"): self.display(rv) else: try: id = long(id) obj = rv[id] if id not in has_details: self.ctx.out("No details available: %s" % id) continue else: obj = obj[0].val # Unwrap the object_list from IQuery.projection except: self.ctx.out("Invalid choice: %s" % id) continue keys = sorted(obj.__dict__) keys.remove("_id") keys.remove("_details") self.ctx.out("id = %s" % obj.id.val) for key in keys: value = self.unwrap(obj.__dict__[key]) if isinstance(value, (str, unicode)): value = "'%s'" % value if key.startswith("_"): key = key[1:] self.ctx.out("%s = %s" % (key, value)) continue
def hql(self, args, loop=False): from omero_sys_ParametersI import ParametersI ice_map = dict() if args.admin: ice_map["omero.group"] = "-1" c = self.ctx.conn(args) q = c.sf.getQueryService() p = ParametersI() p.page(args.offset, args.limit) rv = self.project(q, args.query, p, ice_map) has_details = self.display(rv, style=args.style, idsonly=args.ids_only) if self.ctx.isquiet or not sys.stdout.isatty(): return input = """ To see details for object, enter line number. To move ahead one page, enter 'p' To re-display list, enter 'r'. To quit, enter 'q' or just enter. """ if loop: input = input + """To run another query, press enter\n""" while True: id = self.ctx.input(input) id = id.lower() # Exit loop if not id: return True if id.startswith("q"): return False # Stay in loop if id.startswith("p"): p.page(p.getOffset().val + p.getLimit().val, p.getLimit()) self.ctx.dbg("\nCurrent page: offset=%s, limit=%s\n" % (p.theFilter.offset.val, p.theFilter.limit.val)) rv = self.project(q, args.query, p, ice_map) self.display(rv, style=args.style, idsonly=args.ids_only) elif id.startswith("r"): self.display(rv, style=args.style, idsonly=args.ids_only) else: try: id = int(id) obj = rv[id] if id not in has_details: self.ctx.out("No details available: %s" % id) continue else: # Unwrap the object_list from IQuery.projection obj = obj[0].val except: self.ctx.out("Invalid choice: %s" % id) continue keys = sorted(obj.__dict__) keys.remove("_id") keys.remove("_details") self.ctx.out("id = %s" % obj.id.val) for key in keys: value = self.unwrap(obj.__dict__[key]) if isinstance(value, str): value = "'%s'" % value if key.startswith("_"): key = key[1:] self.ctx.out("%s = %s" % (key, value)) continue