01: /*
02: * Copyright (c) 2006 Your Corporation. All Rights Reserved.
03: */
04:
05: package com.technoetic.xplanner.security.auth;
06:
07: import java.util.Collection;
08: import java.util.List;
09:
10: import org.springframework.orm.hibernate.support.HibernateDaoSupport;
11:
12: import com.technoetic.xplanner.domain.Project;
13:
14: /**
15: * User: mprokopowicz
16: * Date: Mar 29, 2006
17: * Time: 5:36:07 PM
18: */
19: public class AuthorizerQueryHelper extends HibernateDaoSupport {
20:
21: public Collection getAllPermissions() {
22: Collection permission = getHibernateTemplate()
23: .findByNamedQuery("security.personal.permissions");
24: permission.addAll(getHibernateTemplate().findByNamedQuery(
25: "security.role.permissions"));
26: return permission;
27: }
28:
29: public Collection getAllPermissionsToPerson() {
30: return getHibernateTemplate().findByNamedQuery(
31: "security.person.permissions");
32: }
33:
34: public Collection getRolesForPrincipalOnProject(int principalId,
35: int projectId, boolean includeWildcardProject) {
36: return getHibernateTemplate().findByNamedQueryAndNamedParam(
37: "security.roles",
38: new String[] { "personId", "projectId",
39: "includeWildcardProject" },
40: new Object[] { new Integer(principalId),
41: new Integer(projectId),
42: new Integer(includeWildcardProject ? 1 : 0) });
43: }
44:
45: public List getAllUnhidenProjects() {
46: return getHibernateTemplate().find(
47: "from project in " + Project.class
48: + " where project.hidden = false");
49: }
50: }
|