Warning: Can't synchronize with repository "(default)" (/home/git/ome.git does not appear to be a Git repository.). Look in the Trac log for more information.
Notice: In order to edit this ticket you need to be either: a Product Owner, The owner or the reporter of the ticket, or, in case of a Task not yet assigned, a team_member"

Task #9107 (closed)

Opened 12 years ago

Closed 10 years ago

Last modified 10 years ago

Bug: permissions cannot be passed back via IQuery.projection

Reported by: jamoore Owned by: jamoore
Priority: minor Milestone: 5.0.2
Component: General Version: 5.0.1
Keywords: n.a. Cc: jburel, cneves, wmoore
Resources: n.a. Referenced By: n.a.
References: n.a. Remaining Time: 0.0d
Sprint: n.a.

Description

IQuery.projection only returns lists of rtypes. Since we don't have a rtype-wrapper class for permissions, they cannot be returned. One option would be to convert them to strings since it's trivial to go from strings to permissions in all languages.

$ bin/omero hql "select distinct g.details.permissions from ExperimenterGroup g"
Using session 8c9868a3-038e-41df-b628-a59a9f04685c (root@localhost:4064). Idle timeout: 10.0 min. Current group: system
Traceback (most recent call last):
  File "bin/omero", line 123, in <module>
    rv = omero.cli.argv()
  File "/Users/moore/GlencoeSoftware.git/git/omero.git/dist/lib/python/omero/cli.py", line 1184, in argv
    cli.invoke(args[1:])
  File "/Users/moore/GlencoeSoftware.git/git/omero.git/dist/lib/python/omero/cli.py", line 734, in invoke
    stop = self.onecmd(line, previous_args)
  File "/Users/moore/GlencoeSoftware.git/git/omero.git/dist/lib/python/omero/cli.py", line 803, in onecmd
    self.execute(line, previous_args)
  File "/Users/moore/GlencoeSoftware.git/git/omero.git/dist/lib/python/omero/cli.py", line 883, in execute
    args.func(args)
  File "/Users/moore/GlencoeSoftware.git/git/omero.git/dist/lib/python/omero/plugins/hql.py", line 36, in __call__
    self.hql(args)
  File "/Users/moore/GlencoeSoftware.git/git/omero.git/dist/lib/python/omero/plugins/hql.py", line 58, in hql
    rv = self.project(q, args.query, p, ice_map)
  File "/Users/moore/GlencoeSoftware.git/git/omero.git/dist/lib/python/omero/plugins/hql.py", line 212, in project
    rv = querySvc.projection(queryStr, params, ice_map)
  File "/Users/moore/GlencoeSoftware.git/git/omero.git/dist/lib/python/omero_api_IQuery_ice.py", line 151, in projection
    return _M_omero.api.IQuery._op_projection.invoke(self, ((query, params), _ctx))
omero.ApiUsageException: exception ::omero::ApiUsageException
{
    serverStackTrace = 
    serverExceptionClass = 
    message = Unsupported conversion to rtype from ome.model.internal.Permissions:rw----
}

Change History (6)

comment:1 Changed 12 years ago by jmoore

  • Milestone changed from OMERO-Beta4.4 to OMERO-Beta4.4.1
  • Owner set to jmoore

Not going to attempt this API change now unless someone absolutely needs it.

comment:2 Changed 12 years ago by jmoore

Possibly workaround: select str(permissions) from ... though this returns the long value (-52) rather than the string ("rw----").

A better workaround might be to register our ome_perms function with Hibernate.

comment:3 Changed 10 years ago by jamoore

  • Milestone changed from 5.x to 5.0.2
  • Version set to 5.0.1

If it works for everyone, I'd modify 5.0 to return a hash map which also includes canAnnotate, etc.

$ bin/omero hql "select p.details.permissions from Project p"                     
 #  | Col1                                                                                         
----+----------------------------------------------------------------------------------------------
 0  | {'canLink': True, 'canEdit': True, 'canDelete': True, 'perm': 'rw----', 'canAnnotate': True} 
 1  | {'canLink': True, 'canEdit': True, 'canDelete': True, 'perm': 'rw----', 'canAnnotate': True} 
 2  | {'canLink': True, 'canEdit': True, 'canDelete': True, 'perm': 'rw----', 'canAnnotate': True} 
 3  | {'canLink': True, 'canEdit': True, 'canDelete': True, 'perm': 'rw----', 'canAnnotate': True} 
 4  | {'canLink': True, 'canEdit': True, 'canDelete': True, 'perm': 'rw----', 'canAnnotate': True} 
 5  | {'canLink': True, 'canEdit': True, 'canDelete': True, 'perm': 'rw----', 'canAnnotate': True} 
 6  | {'canLink': True, 'canEdit': True, 'canDelete': True, 'perm': 'rw----', 'canAnnotate': True} 
 7  | {'canLink': True, 'canEdit': True, 'canDelete': True, 'perm': 'rw----', 'canAnnotate': True} 
 8  | {'canLink': True, 'canEdit': True, 'canDelete': True, 'perm': 'rw----', 'canAnnotate': True} 
 9  | {'canLink': True, 'canEdit': True, 'canDelete': True, 'perm': 'rw----', 'canAnnotate': True} 
 10 | {'canLink': True, 'canEdit': True, 'canDelete': True, 'perm': 'rw----', 'canAnnotate': True} 
(11 rows)

comment:4 Changed 10 years ago by jamoore

Commit passed to Carlos. Ticket to be closed once PR is opened:

 commit d034f888ea9a0c91ef0fef4814d484603228839e
Author: jmoore <josh@glencoesoftware.com>
Date:   Wed May 7 15:21:22 2014 +0200

    Pass back maps for Permissions in HQL projections (Fix #9107)

comment:5 Changed 10 years ago by jamoore

  • Resolution set to fixed
  • Status changed from new to closed

https://github.com/openmicroscopy/openmicroscopy/pull/2483/files opened by Chris & Carlos. Closing this ticket.

comment:6 Changed 10 years ago by Chris Allan <callan@…>

  • Remaining Time set to 0

(In [20967e100e5f7aadb78a91b5646bef86d1ebe345/ome.git] on branch develop) Pass back maps for Permissions in HQL projections (Fix #9107)

@cneves ran into an issue where he needed the accessors
on Permissions (canAnnotate, etc.) from a projection.
Rather than returning permissions.perm1, a single long
value that gives none of the canX context, you can now
return the permissions object itself which is transformed
into a map of the form:
`
{

'canAnnotate': True,
'canLink': True,
'canEdit': True,
`canDelete': True,
'perm': 'rw----',

}
`

Note: See TracTickets for help on using tickets. You may also have a look at Agilo extensions to the ticket.

1.3.13-PRO © 2008-2011 Agilo Software all rights reserved (this page was served in: 0.66985 sec.)

We're Hiring!