/** * Creates a new mock flow execution context for the specified active flow session. */ public MockFlowExecutionContext(FlowSession flowSession) { setActiveSession(flowSession); this.flow = flowSession.getDefinition(); }
public FlowDefinition getActiveFlow() { return flowExecution.getActiveSession().getDefinition(); }
/** * Creates a new mock flow execution context -- automatically installs a root flow definition and active flow * session. */ public MockFlowExecutionContext() { setActiveSession(new MockFlowSession()); this.flow = activeSession.getDefinition(); }
public FlowDefinition getActiveFlow() { return getFlowExecutionContext().getActiveSession().getDefinition(); }
private boolean isParentPersistenceContext(FlowSession flowSession) { return ((!flowSession.isRoot()) && isPersistenceContext(flowSession.getParent().getDefinition())); }
private boolean isParentPersistenceContext(FlowSession flowSession) { return ((!flowSession.isRoot()) && isPersistenceContext(flowSession.getParent().getDefinition())); }
/** * Assert that the active flow session is for the flow with the provided id. * @param expectedActiveFlowId the flow id that should have a session active in the tested flow execution */ protected void assertActiveFlowEquals(String expectedActiveFlowId) { assertEquals("The active flow id '" + getFlowExecution().getActiveSession().getDefinition().getId() + "' does not equal the expected active flow id '" + expectedActiveFlowId + "'", expectedActiveFlowId, getFlowExecution().getActiveSession().getDefinition().getId()); }
public void sessionEnding(RequestContext context, FlowSession session, String outcome, MutableAttributeMap<?> output) { if (isParentPersistenceContext(session)) { return; } if (isPersistenceContext(session.getDefinition())) { final EntityManager em = getEntityManager(session); Boolean commitStatus = session.getState().getAttributes().getBoolean("commit"); if (Boolean.TRUE.equals(commitStatus)) { transactionTemplate.execute(new TransactionCallbackWithoutResult() { protected void doInTransactionWithoutResult(TransactionStatus status) { em.joinTransaction(); } }); } unbind(em); em.close(); } }
public void sessionEnding(RequestContext context, FlowSession session, String outcome, MutableAttributeMap<?> output) { if (isParentPersistenceContext(session)) { return; } if (isPersistenceContext(session.getDefinition())) { final Session hibernateSession = getHibernateSession(session); Boolean commitStatus = session.getState().getAttributes().getBoolean("commit"); if (Boolean.TRUE.equals(commitStatus)) { transactionTemplate.execute(new TransactionCallbackWithoutResult() { protected void doInTransactionWithoutResult(TransactionStatus status) { sessionFactory.getCurrentSession(); // nothing to do; a flush will happen on commit automatically as this is a read-write // transaction } }); } unbind(hibernateSession); hibernateSession.close(); } }
public void sessionEnded(RequestContext context, FlowSession session, String outcome, AttributeMap<?> output) { if (isParentPersistenceContext(session)) { if (!isPersistenceContext(session.getDefinition())) { bind(getHibernateSession(session.getParent())); } } }
public void sessionEnded(RequestContext context, FlowSession session, String outcome, AttributeMap<?> output) { if (isParentPersistenceContext(session)) { if (!isPersistenceContext(session.getDefinition())) { bind(getEntityManager(session.getParent())); } } }
public void sessionStarting(RequestContext context, FlowSession session, MutableAttributeMap<?> input) { boolean reusePersistenceContext = false; if (isParentPersistenceContext(session)) { if (isPersistenceContext(session.getDefinition())) { setEntityManager(session, getEntityManager(session.getParent())); reusePersistenceContext = true; } else { unbind(getEntityManager(session.getParent())); } } if (isPersistenceContext(session.getDefinition()) && (!reusePersistenceContext)) { EntityManager em = entityManagerFactory.createEntityManager(); session.getScope().put(PERSISTENCE_CONTEXT_ATTRIBUTE, em); bind(em); } }
public void sessionStarting(RequestContext context, FlowSession session, MutableAttributeMap<?> input) { boolean reusePersistenceContext = false; if (isParentPersistenceContext(session)) { if (isPersistenceContext(session.getDefinition())) { setHibernateSession(session, getHibernateSession(session.getParent())); reusePersistenceContext = true; } else { unbind(getHibernateSession(session.getParent())); } } if (isPersistenceContext(session.getDefinition()) && (!reusePersistenceContext)) { Session hibernateSession = createSession(context); setHibernateSession(session, hibernateSession); bind(hibernateSession); } }
private FlowExecutionException wrap(Exception e) { if (isActive()) { FlowSession session = getActiveSession(); String flowId = session.getDefinition().getId(); String stateId = session.getState() != null ? session.getState().getId() : null; return new FlowExecutionException(flowId, stateId, "Exception thrown in state '" + stateId + "' of flow '" + flowId + "'", e); } else { return new FlowExecutionException(flow.getId(), null, "Exception thrown within inactive flow '" + flow.getId() + "'", e); } }
/** * Creates a new mock flow execution context -- automatically installs a root flow definition and active flow * session. */ public MockFlowExecutionContext() { setActiveSession(new MockFlowSession()); this.flow = activeSession.getDefinition(); }
/** * Assert that the active flow session is for the flow with the provided id. * @param expectedActiveFlowId the flow id that should have a session active in the tested flow execution */ protected void assertActiveFlowEquals(String expectedActiveFlowId) { assertEquals("The active flow id '" + getFlowExecution().getActiveSession().getDefinition().getId() + "' does not equal the expected active flow id '" + expectedActiveFlowId + "'", expectedActiveFlowId, getFlowExecution().getActiveSession().getDefinition().getId()); }
/** * Assert that the active flow session is for the flow with the provided id. * @param expectedActiveFlowId the flow id that should have a session active in the tested flow execution */ protected void assertActiveFlowEquals(String expectedActiveFlowId) { assertEquals("The active flow id '" + getFlowExecution().getActiveSession().getDefinition().getId() + "' does not equal the expected active flow id '" + expectedActiveFlowId + "'", expectedActiveFlowId, getFlowExecution().getActiveSession().getDefinition().getId()); }
public void sessionEnded(RequestContext context, FlowSession session, String outcome, AttributeMap<?> output) { if (isParentPersistenceContext(session)) { if (!isPersistenceContext(session.getDefinition())) { bind(getHibernateSession(session.getParent())); } } }
private FlowExecutionException wrap(Exception e) { if (isActive()) { FlowSession session = getActiveSession(); String flowId = session.getDefinition().getId(); String stateId = session.getState() != null ? session.getState().getId() : null; return new FlowExecutionException(flowId, stateId, "Exception thrown in state '" + stateId + "' of flow '" + flowId + "'", e); } else { return new FlowExecutionException(flow.getId(), null, "Exception thrown within inactive flow '" + flow.getId() + "'", e); } }
private FlowExecutionException wrap(Exception e) { if (isActive()) { FlowSession session = getActiveSession(); String flowId = session.getDefinition().getId(); String stateId = session.getState() != null ? session.getState().getId() : null; return new FlowExecutionException(flowId, stateId, "Exception thrown in state '" + stateId + "' of flow '" + flowId + "'", e); } else { return new FlowExecutionException(flow.getId(), null, "Exception thrown within inactive flow '" + flow.getId() + "'", e); } }