Author: alex.guizar(a)jboss.com
Date: 2009-07-30 15:25:26 -0400 (Thu, 30 Jul 2009)
New Revision: 5397
Removed:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/exe/Execution.java
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/JbpmContext.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/ContextSession.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/GraphSession.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/LoggingSession.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/TaskMgmtSession.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/def/Identifiable.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/el/parser/ELParser.java
jbpm3/branches/jbpm-3.2-soa/modules/identity/src/main/java/org/jbpm/identity/hibernate/IdentitySession.java
Log:
fix some eclipse warnings
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/JbpmContext.java
===================================================================
---
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/JbpmContext.java 2009-07-30
18:57:16 UTC (rev 5396)
+++
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/JbpmContext.java 2009-07-30
19:25:26 UTC (rev 5397)
@@ -140,10 +140,11 @@
}
/**
- * obtains the current JbpmContext from a thread local. The current JbpmContexts are
maintained in
+ * obtains the current JbpmContext from a thread local. The current contexts are
maintained in
* a stack so that you can do nested context operations for different jbpm
configurations.
*
- * @deprecated method moved to {@link JbpmConfiguration}.
+ * <p>it is <strong>strongly recommended</strong> that client code
invokes
+ * {@link JbpmConfiguration#getCurrentJbpmContext()} in preference to this
method.</p>
*/
public static JbpmContext getCurrentJbpmContext() {
JbpmContext currentJbpmContext = null;
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/ContextSession.java
===================================================================
---
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/ContextSession.java 2009-07-30
18:57:16 UTC (rev 5396)
+++
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/ContextSession.java 2009-07-30
19:25:26 UTC (rev 5397)
@@ -30,8 +30,9 @@
*/
public class ContextSession {
+ final Session session;
+ /** @deprecated */
final JbpmSession jbpmSession;
- final Session session;
/**
* @deprecated use {@link #ContextSession(Session)} instead
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/GraphSession.java
===================================================================
---
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/GraphSession.java 2009-07-30
18:57:16 UTC (rev 5396)
+++
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/GraphSession.java 2009-07-30
19:25:26 UTC (rev 5397)
@@ -47,6 +47,7 @@
public class GraphSession {
final Session session;
+ /** @deprecated */
final JbpmSession jbpmSession;
/** @deprecated use {@link #GraphSession(Session)} instead */
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/LoggingSession.java
===================================================================
---
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/LoggingSession.java 2009-07-30
18:57:16 UTC (rev 5396)
+++
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/LoggingSession.java 2009-07-30
19:25:26 UTC (rev 5397)
@@ -37,8 +37,9 @@
public class LoggingSession {
+ final Session session;
+ /** @deprecated */
final JbpmSession jbpmSession;
- final Session session;
/** @deprecated use {@link #LoggingSession(Session)} instead */
public LoggingSession(JbpmSession jbpmSession) {
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/TaskMgmtSession.java
===================================================================
---
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/TaskMgmtSession.java 2009-07-30
18:57:16 UTC (rev 5396)
+++
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/TaskMgmtSession.java 2009-07-30
19:25:26 UTC (rev 5397)
@@ -36,6 +36,7 @@
public class TaskMgmtSession {
final Session session;
+ /** @deprecated */
final JbpmSession jbpmSession;
/** @deprecated use {@link #TaskMgmtSession(Session)} instead */
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/def/Identifiable.java
===================================================================
---
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/def/Identifiable.java 2009-07-30
18:57:16 UTC (rev 5396)
+++
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/def/Identifiable.java 2009-07-30
19:25:26 UTC (rev 5397)
@@ -22,12 +22,11 @@
package org.jbpm.graph.def;
/**
- * Implemteded by elemtes that support an id
+ * Implemented by elements that support an id
*
* @author Thomas.Diesler(a)jboss.com
* @since 04-Dec-2008
*/
-public interface Identifiable
-{
+public interface Identifiable {
long getId();
}
Deleted:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/exe/Execution.java
===================================================================
---
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/exe/Execution.java 2009-07-30
18:57:16 UTC (rev 5396)
+++
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/exe/Execution.java 2009-07-30
19:25:26 UTC (rev 5397)
@@ -1,39 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jbpm.graph.exe;
-
-import org.jbpm.graph.def.ProcessDefinition;
-
-/**
- * Introduce the concept of Execution.
- *
- * This implementation is equivalent to the jBPM3
- *
- * @link{ProcessInstance}
- */
-public class Execution extends ProcessInstance {
-
- public Execution(ProcessDefinition pd) {
- super(pd);
- }
-
-}
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/el/parser/ELParser.java
===================================================================
---
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/el/parser/ELParser.java 2009-07-30
18:57:16 UTC (rev 5396)
+++
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/el/parser/ELParser.java 2009-07-30
19:25:26 UTC (rev 5397)
@@ -80,15 +80,13 @@
if (elems != null) {
ret = new ExpressionString (elems.toArray ());
}
- {if (true) return ret;}
- throw new Error("Missing return statement in function");
+ return ret;
}
final public String AttrValueString() throws ParseException {
ELToken t;
t = jj_consume_token(NON_EXPRESSION_TEXT);
- {if (true) return t.image;}
- throw new Error("Missing return statement in function");
+ return t.image;
}
final public Expression AttrValueExpression() throws ParseException {
@@ -96,8 +94,7 @@
jj_consume_token(START_EXPRESSION);
exp = Expression();
jj_consume_token(END_EXPRESSION);
- {if (true) return exp;}
- throw new Error("Missing return statement in function");
+ return exp;
}
final public Expression Expression() throws ParseException {
@@ -126,8 +123,7 @@
throw new ParseException();
}
}
- {if (true) return ret;}
- throw new Error("Missing return statement in function");
+ return ret;
}
final public Expression OrExpression() throws ParseException {
@@ -170,14 +166,13 @@
expressions.add (expression);
}
if (operators != null) {
- {if (true) return new BinaryOperatorExpression (startExpression,
+ return new BinaryOperatorExpression (startExpression,
operators,
- expressions);}
+ expressions);
}
else {
- {if (true) return startExpression;}
+ return startExpression;
}
- throw new Error("Missing return statement in function");
}
final public Expression AndExpression() throws ParseException {
@@ -220,14 +215,13 @@
expressions.add (expression);
}
if (operators != null) {
- {if (true) return new BinaryOperatorExpression (startExpression,
+ return new BinaryOperatorExpression (startExpression,
operators,
- expressions);}
+ expressions);
}
else {
- {if (true) return startExpression;}
+ return startExpression;
}
- throw new Error("Missing return statement in function");
}
final public Expression EqualityExpression() throws ParseException {
@@ -297,14 +291,13 @@
expressions.add (expression);
}
if (operators != null) {
- {if (true) return new BinaryOperatorExpression (startExpression,
+ return new BinaryOperatorExpression (startExpression,
operators,
- expressions);}
+ expressions);
}
else {
- {if (true) return startExpression;}
+ return startExpression;
}
- throw new Error("Missing return statement in function");
}
final public Expression RelationalExpression() throws ParseException {
@@ -410,14 +403,13 @@
expressions.add (expression);
}
if (operators != null) {
- {if (true) return new BinaryOperatorExpression (startExpression,
+ return new BinaryOperatorExpression (startExpression,
operators,
- expressions);}
+ expressions);
}
else {
- {if (true) return startExpression;}
+ return startExpression;
}
- throw new Error("Missing return statement in function");
}
final public Expression AddExpression() throws ParseException {
@@ -461,14 +453,13 @@
expressions.add (expression);
}
if (operators != null) {
- {if (true) return new BinaryOperatorExpression (startExpression,
+ return new BinaryOperatorExpression (startExpression,
operators,
- expressions);}
+ expressions);
}
else {
- {if (true) return startExpression;}
+ return startExpression;
}
- throw new Error("Missing return statement in function");
}
final public Expression MultiplyExpression() throws ParseException {
@@ -543,14 +534,13 @@
expressions.add (expression);
}
if (operators != null) {
- {if (true) return new BinaryOperatorExpression (startExpression,
+ return new BinaryOperatorExpression (startExpression,
operators,
- expressions);}
+ expressions);
}
else {
- {if (true) return startExpression;}
+ return startExpression;
}
- throw new Error("Missing return statement in function");
}
final public Expression ConditionalExpression() throws ParseException {
@@ -560,8 +550,7 @@
trueBranch = Expression();
jj_consume_token(COLON);
falseBranch = Expression();
- {if (true) return new ConditionalExpression(condition, trueBranch, falseBranch);}
- throw new Error("Missing return statement in function");
+ return new ConditionalExpression(condition, trueBranch, falseBranch);
}
final public Expression UnaryExpression() throws ParseException {
@@ -626,15 +615,14 @@
}
expression = Value();
if (operators != null) {
- {if (true) return new UnaryOperatorExpression (null, operators, expression);}
+ return new UnaryOperatorExpression (null, operators, expression);
}
else if (singleOperator != null) {
- {if (true) return new UnaryOperatorExpression (singleOperator, null, expression);}
+ return new UnaryOperatorExpression (singleOperator, null, expression);
}
else {
- {if (true) return expression;}
+ return expression;
}
- throw new Error("Missing return statement in function");
}
final public Expression Value() throws ParseException {
@@ -660,12 +648,11 @@
suffixes.add (suffix);
}
if (suffixes == null) {
- {if (true) return prefix;}
+ return prefix;
}
else {
- {if (true) return new ComplexValue (prefix, suffixes);}
+ return new ComplexValue (prefix, suffixes);
}
- throw new Error("Missing return statement in function");
}
/**
@@ -703,15 +690,13 @@
}
}
}
- {if (true) return ret;}
- throw new Error("Missing return statement in function");
+ return ret;
}
final public NamedValue NamedValue() throws ParseException {
ELToken t;
t = jj_consume_token(IDENTIFIER);
- {if (true) return new NamedValue (t.image);}
- throw new Error("Missing return statement in function");
+ return new NamedValue (t.image);
}
final public FunctionInvocation FunctionInvocation() throws ParseException {
@@ -755,8 +740,7 @@
;
}
jj_consume_token(RPAREN);
- {if (true) return new FunctionInvocation(qualifiedName, argumentList);}
- throw new Error("Missing return statement in function");
+ return new FunctionInvocation(qualifiedName, argumentList);
}
final public ValueSuffix ValueSuffix() throws ParseException {
@@ -773,8 +757,7 @@
jj_consume_token(-1);
throw new ParseException();
}
- {if (true) return suffix;}
- throw new Error("Missing return statement in function");
+ return suffix;
}
final public PropertySuffix PropertySuffix() throws ParseException {
@@ -782,8 +765,7 @@
String property;
jj_consume_token(DOT);
property = Identifier();
- {if (true) return new PropertySuffix (property);}
- throw new Error("Missing return statement in function");
+ return new PropertySuffix (property);
}
final public ArraySuffix ArraySuffix() throws ParseException {
@@ -791,8 +773,7 @@
jj_consume_token(LBRACKET);
index = Expression();
jj_consume_token(RBRACKET);
- {if (true) return new ArraySuffix (index);}
- throw new Error("Missing return statement in function");
+ return new ArraySuffix (index);
}
final public Literal Literal() throws ParseException {
@@ -819,60 +800,51 @@
jj_consume_token(-1);
throw new ParseException();
}
- {if (true) return ret;}
- throw new Error("Missing return statement in function");
+ return ret;
}
final public BooleanLiteral BooleanLiteral() throws ParseException {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case TRUE:
jj_consume_token(TRUE);
- {if (true) return BooleanLiteral.TRUE;}
- break;
+ return BooleanLiteral.TRUE;
case FALSE:
jj_consume_token(FALSE);
- {if (true) return BooleanLiteral.FALSE;}
- break;
+ return BooleanLiteral.FALSE;
default:
jj_la1[34] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
- throw new Error("Missing return statement in function");
}
final public StringLiteral StringLiteral() throws ParseException {
ELToken t;
t = jj_consume_token(STRING_LITERAL);
- {if (true) return StringLiteral.fromToken (t.image);}
- throw new Error("Missing return statement in function");
+ return StringLiteral.fromToken (t.image);
}
final public IntegerLiteral IntegerLiteral() throws ParseException {
ELToken t;
t = jj_consume_token(INTEGER_LITERAL);
- {if (true) return new IntegerLiteral (t.image);}
- throw new Error("Missing return statement in function");
+ return new IntegerLiteral (t.image);
}
final public FloatingPointLiteral FloatingPointLiteral() throws ParseException {
ELToken t;
t = jj_consume_token(FLOATING_POINT_LITERAL);
- {if (true) return new FloatingPointLiteral (t.image);}
- throw new Error("Missing return statement in function");
+ return new FloatingPointLiteral (t.image);
}
final public NullLiteral NullLiteral() throws ParseException {
jj_consume_token(NULL);
- {if (true) return NullLiteral.SINGLETON;}
- throw new Error("Missing return statement in function");
+ return NullLiteral.SINGLETON;
}
final public String Identifier() throws ParseException {
ELToken t;
t = jj_consume_token(IDENTIFIER);
- {if (true) return t.image;}
- throw new Error("Missing return statement in function");
+ return t.image;
}
final public String QualifiedName() throws ParseException {
@@ -885,10 +857,9 @@
}
localPart = Identifier();
if (prefix == null)
- {if (true) return localPart;}
+ return localPart;
else
- {if (true) return prefix + ":" + localPart;}
- throw new Error("Missing return statement in function");
+ return prefix + ":" + localPart;
}
final private boolean jj_2_1(int xla) {
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/identity/src/main/java/org/jbpm/identity/hibernate/IdentitySession.java
===================================================================
---
jbpm3/branches/jbpm-3.2-soa/modules/identity/src/main/java/org/jbpm/identity/hibernate/IdentitySession.java 2009-07-30
18:57:16 UTC (rev 5396)
+++
jbpm3/branches/jbpm-3.2-soa/modules/identity/src/main/java/org/jbpm/identity/hibernate/IdentitySession.java 2009-07-30
19:25:26 UTC (rev 5397)
@@ -26,10 +26,13 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.HibernateException;
-import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.jbpm.db.JbpmSession;
+import org.hibernate.criterion.Projections;
+import org.hibernate.criterion.Restrictions;
+
+import org.jbpm.JbpmContext;
+import org.jbpm.JbpmException;
import org.jbpm.identity.Entity;
import org.jbpm.identity.Group;
import org.jbpm.identity.Membership;
@@ -37,127 +40,103 @@
import org.jbpm.identity.assignment.ExpressionSession;
import org.jbpm.identity.security.IdentityService;
-public class IdentitySession implements IdentityService, ExpressionSession
-{
+public class IdentitySession implements IdentityService, ExpressionSession {
+
private static final Log log = LogFactory.getLog(IdentitySession.class);
Session session;
private Transaction transaction;
- public IdentitySession(Session session)
- {
+ public IdentitySession(Session session) {
this.session = session;
}
- public IdentitySession()
- {
- JbpmSession currentJbpmSession = JbpmSession.getCurrentJbpmSession();
- if ((currentJbpmSession == null) || (currentJbpmSession.getSession() == null) ||
(!currentJbpmSession.getSession().isOpen()))
- {
- throw new RuntimeException("no active JbpmSession to create an identity
session");
- }
- session = currentJbpmSession.getSession();
+ public IdentitySession() {
+ JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
+ if (jbpmContext == null) throw new RuntimeException("no active jbpm
context");
+
+ session = jbpmContext.getSession();
+ if (session == null) throw new JbpmException("no active hibernate
session");
}
// IdentityService methods //////////////////////////////////////////////////
- public Object verify(String userName, String pwd)
- {
- Object userId = null;
- Query query = session.createQuery("select user.id " + "from
org.jbpm.identity.User as user where user.name = :userName and user.password =
:password");
- query.setString("userName", userName);
- query.setString("password", pwd);
- userId = (Long)query.uniqueResult();
- return userId;
+ public Object verify(String userName, String pwd) {
+ return session.createCriteria(User.class)
+ .setProjection(Projections.property("id"))
+ .add(Restrictions.eq("name", userName))
+ .add(Restrictions.eq("password", pwd))
+ .uniqueResult();
}
- public User getUserById(Object userId)
- {
- return (User)session.load(User.class, (Long)userId);
+ public User getUserById(Object userId) {
+ return (User) session.load(User.class, (Long) userId);
}
// transaction convenience methods //////////////////////////////////////////
- public Session getSession()
- {
+ public Session getSession() {
return session;
}
- public Transaction getTransaction()
- {
+ public Transaction getTransaction() {
return transaction;
}
- public void beginTransaction()
- {
- try
- {
+ public void beginTransaction() {
+ try {
transaction = session.beginTransaction();
}
- catch (HibernateException e)
- {
+ catch (HibernateException e) {
log.error(e);
throw new RuntimeException("couldn't begin a transaction", e);
}
}
- public void commitTransaction()
- {
- if (transaction == null)
- {
+ public void commitTransaction() {
+ if (transaction == null) {
throw new RuntimeException("can't commit : no transaction started");
}
- try
- {
+ try {
session.flush();
transaction.commit();
}
- catch (HibernateException e)
- {
+ catch (HibernateException e) {
log.error(e);
throw new RuntimeException("couldn't commit transaction", e);
}
transaction = null;
}
- public void rollbackTransaction()
- {
- if (transaction == null)
- {
+ public void rollbackTransaction() {
+ if (transaction == null) {
throw new RuntimeException("can't rollback : no transaction
started");
}
- try
- {
+ try {
transaction.rollback();
}
- catch (HibernateException e)
- {
+ catch (HibernateException e) {
log.error(e);
throw new RuntimeException("couldn't rollback transaction", e);
}
transaction = null;
}
- public void commitTransactionAndClose()
- {
+ public void commitTransactionAndClose() {
commitTransaction();
close();
}
- public void rollbackTransactionAndClose()
- {
+ public void rollbackTransactionAndClose() {
rollbackTransaction();
close();
}
- public void close()
- {
- try
- {
+ public void close() {
+ try {
session.close();
}
- catch (HibernateException e)
- {
+ catch (HibernateException e) {
log.error(e);
throw new RuntimeException("couldn't close the hibernate connection",
e);
}
@@ -165,94 +144,69 @@
// identity methods /////////////////////////////////////////////////////////
- public void saveUser(User user)
- {
+ public void saveUser(User user) {
session.save(user);
}
- public void saveGroup(Group group)
- {
+ public void saveGroup(Group group) {
session.save(group);
}
- public void saveEntity(Entity entity)
- {
+ public void saveEntity(Entity entity) {
session.save(entity);
}
- public void saveMembership(Membership membership)
- {
+ public void saveMembership(Membership membership) {
session.save(membership);
}
- public User loadUser(long userId)
- {
- return (User)session.load(User.class, new Long(userId));
+ public User loadUser(long userId) {
+ return (User) session.load(User.class, new Long(userId));
}
- public Group loadGroup(long groupId)
- {
- return (Group)session.load(Group.class, new Long(groupId));
+ public Group loadGroup(long groupId) {
+ return (Group) session.load(Group.class, new Long(groupId));
}
- public void deleteGroup(Group group)
- {
+ public void deleteGroup(Group group) {
session.delete(group);
}
-
- public void deleteUser(User user)
- {
+
+ public void deleteUser(User user) {
session.delete(user);
}
-
- public User getUserByName(String userName)
- {
- User user = null;
- Query query = session.createQuery("select u " + "from
org.jbpm.identity.User as u " + "where u.name = :userName");
- query.setString("userName", userName);
- List users = query.list();
- if ((users != null) && (users.size() > 0))
- {
- user = (User)users.get(0);
- }
- return user;
+
+ public User getUserByName(String userName) {
+ List users = session.createCriteria(User.class).add(Restrictions.eq("name",
userName)).list();
+ return users.isEmpty() ? null : (User) users.get(0);
}
- public Group getGroupByName(String groupName)
- {
- Group group = null;
- Query query = session.createQuery("select g " + "from
org.jbpm.identity.Group as g " + "where g.name = :groupName");
- query.setString("groupName", groupName);
- List groups = query.list();
- if ((groups != null) && (groups.size() > 0))
- {
- group = (Group)groups.get(0);
- }
- return group;
+ public Group getGroupByName(String groupName) {
+ List groups = session.createCriteria(Group.class)
+ .add(Restrictions.eq("name", groupName))
+ .list();
+ return groups.isEmpty() ? null : (Group) groups.get(0);
}
- public List getUsers()
- {
- Query query = session.createQuery("select u " + "from
org.jbpm.identity.User as u");
- return query.list();
+ public List getUsers() {
+ return session.createCriteria(User.class).list();
}
- public List getGroupNamesByUserAndGroupType(String userName, String groupType)
- {
- Query query = session.createQuery("select membership.group.name from
org.jbpm.identity.Membership as membership where membership.user.name = :userName "
- + " and membership.group.type = :groupType");
- query.setString("userName", userName);
- query.setString("groupType", groupType);
- return query.list();
+ public List getGroupNamesByUserAndGroupType(String userName, String groupType) {
+ return session.createCriteria(Membership.class)
+ .createAlias("group", "g")
+ .createAlias("user", "u")
+ .add(Restrictions.eq("u.name", userName))
+ .add(Restrictions.eq("g.type", groupType))
+ .setProjection(Projections.property("g.name"))
+ .list();
}
- public User getUserByGroupAndRole(String groupName, String role)
- {
- User user = null;
- Query query = session.createQuery("select m.user " + "from
org.jbpm.identity.Membership as m where m.group.name = :groupName and m.role =
:role");
- query.setString("groupName", groupName);
- query.setString("role", role);
- user = (User)query.uniqueResult();
- return user;
+ public User getUserByGroupAndRole(String groupName, String role) {
+ return (User) session.createCriteria(Membership.class)
+ .createAlias("group", "g")
+ .add(Restrictions.eq("role", role))
+ .add(Restrictions.eq("g.name", groupName))
+ .uniqueResult();
}
}