List of usage examples for org.hibernate Query setEntity
@Deprecated @SuppressWarnings("unchecked") Query<R> setEntity(String name, Object val);
From source file:itensil.workflow.activities.state.ActivityStateStore.java
License:Open Source License
public int countAllActiveSteps() throws StateException { Query qry = getSession().getNamedQuery("FlowState.countAllActiveSteps"); qry.setEntity("flow", getFlow()); qry.setInteger("endSubState", SubState.ENTER_END.ordinal()); return ((Long) qry.iterate().next()).intValue(); }
From source file:itensil.workflow.activities.state.ActivityStateStore.java
License:Open Source License
@SuppressWarnings("unchecked") public Collection<Activity> getTokens() throws StateException { Query qry = getSession().getNamedQuery("FlowState.getTokens"); qry.setEntity("flow", getFlow()); return qry.list(); }
From source file:itensil.workflow.activities.state.ActivityStateStore.java
License:Open Source License
public int countTokens() throws StateException { Query qry = getSession().getNamedQuery("FlowState.countTokens"); qry.setEntity("flow", getFlow()); return ((Long) qry.iterate().next()).intValue(); }
From source file:itensil.workflow.activities.state.ActivityStateStore.java
License:Open Source License
@SuppressWarnings("unchecked") public Collection<StepLog<Activity>> getLogSteps(Activity token, Date since) throws StateException { Query qry = getSession().getNamedQuery("FlowState.getLogStepsByToken"); qry.setEntity("token", token); qry.setTimestamp("since", since); return qry.list(); }
From source file:itensil.workflow.activities.state.ActivityStateStore.java
License:Open Source License
@SuppressWarnings("unchecked") public Collection<StepLog<Activity>> getLogSteps(String stepId, Date since) throws StateException { Query qry = getSession().getNamedQuery("FlowState.getLogStepsByStep"); qry.setEntity("flow", getFlow()); qry.setString("stepId", stepId); qry.setTimestamp("since", since); return qry.list(); }
From source file:itensil.workflow.activities.state.ActivityStateStore.java
License:Open Source License
@SuppressWarnings("unchecked") public Collection<StepLog<Activity>> getLogSteps(Date since) throws StateException { Query qry = getSession().getNamedQuery("FlowState.getLogSteps"); qry.setEntity("flow", getFlow()); qry.setTimestamp("since", since); return qry.list(); }
From source file:itensil.workflow.activities.state.ActivityStateStore.java
License:Open Source License
@SuppressWarnings("unchecked") public Collection<StepLog<Activity>> getExitLogSteps(Activity token, String stepId) throws StateException { Query qry = getSession().getNamedQuery("FlowState.getExitLogSteps"); qry.setEntity("token", token); qry.setString("stepId", stepId); Integer sStateInts[] = { SubState.EXIT_STEP.ordinal(), SubState.EXIT_SWITCH.ordinal(), SubState.EXIT_TIMER.ordinal() }; qry.setParameterList("exitSubStates", sStateInts); return qry.list(); }
From source file:itensil.workflow.activities.UserActivities.java
License:Open Source License
/** * // www. j a v a2s . c o m * @param flow * @param pageNum * @param includeEnded * @return * @throws DAOException */ public List<Activity> getFlowAssignActivities(FlowState flow, int pageNum, boolean includeEnded) throws DAOException { Query qry = getSession().getNamedQuery("Activity.getFlowAssignActivities"); qry.setString("assignId", getUserId()); qry.setString("userSpaceId", user.getUserSpaceId()); qry.setEntity("flow", flow); qry.setInteger("filtSubState", includeEnded ? -1 : SubState.ENTER_END.ordinal()); qry.setMaxResults(getPageSize() + 1); qry.setFirstResult(getPageSize() * pageNum); return prepareActivities(qry.list()); }
From source file:itensil.workflow.activities.UserActivities.java
License:Open Source License
/** * //from w w w .ja va2s . c o m * @param flow * @param pageNum * @param includeEnded * @return * @throws DAOException */ public List<Activity> getFlowSubmitActivities(FlowState flow, int pageNum, boolean includeEnded) throws DAOException { Query qry = getSession().getNamedQuery("Activity.getFlowSubmitActivities"); qry.setString("submitId", getUserId()); qry.setString("userSpaceId", user.getUserSpaceId()); qry.setEntity("flow", flow); qry.setInteger("filtSubState", includeEnded ? -1 : SubState.ENTER_END.ordinal()); qry.setMaxResults(getPageSize() + 1); qry.setFirstResult(getPageSize() * pageNum); return prepareActivities(qry.list()); }
From source file:itensil.workflow.activities.UserActivities.java
License:Open Source License
/** * //from w w w . j a v a2s.c om * @param fState * @param role * @param assignUsr * @return * @throws AccessDeniedException * @throws NotFoundException * @throws LockException * @throws SAXException * @throws IOException */ @SuppressWarnings("unchecked") public FlowRole setFlowRole(FlowState fState, String role, User assignUsr) throws AccessDeniedException, NotFoundException, IOException, SAXException, LockException { MutableRepositoryNode flowNode = (MutableRepositoryNode) fState.getNode(); // grant file access if (!flowNode.hasPermission(DefaultNodePermission.writePermission(assignUsr))) { try { flowNode.grantPermission(new DefaultNodePermission(assignUsr, DefaultNodePermission.WRITE, true)); } catch (AccessDeniedException ade) { // TODO figure out what to do when assigner can't manage } } String prevAssignId = null; FlowRole roleEnt = fState.getRoles().get(role); if (roleEnt == null) { roleEnt = new FlowRole(); roleEnt.setFlow(fState); roleEnt.setRole(role); fState.getRoles().put(role, roleEnt); } else { prevAssignId = roleEnt.getAssignId(); } roleEnt.setAssignId(assignUsr.getUserId()); Session sess = getSession(); sess.saveOrUpdate(roleEnt); if (!Check.isEmpty(prevAssignId)) { // load up current activities assigned to previous user Query qry = sess.getNamedQuery("Activity.getFlowAssignActivities"); qry.setEntity("flow", fState); qry.setString("assignId", prevAssignId); qry.setString("userSpaceId", user.getUserSpaceId()); qry.setInteger("filtSubState", SubState.ENTER_END.ordinal()); List<Activity> actList = (List<Activity>) qry.list(); if (!actList.isEmpty()) { FlowModel flowMod = getModel(fState, null); for (Activity act : actList) { FlowModel actFlowMod = flowMod; // check for activity variation try { if (act.getVariationNode() != null) actFlowMod = getModel(fState, act); if (!act.getRoles().containsKey(role)) { reAssignActivityRoles(actFlowMod, act, role, prevAssignId, assignUsr.getUserId()); } } catch (AccessDeniedException ade) { log.warn("Activity Role assignment", ade); } } } } return roleEnt; }