Package org.nxplanner.domain

Examples of org.nxplanner.domain.Integration


        if (StringUtils.isEmpty(personId) || personId.equals("0")) {
            saveError(request, "integrations.error.noperson");
            return actionMapping.findForward("error");
        }
        Integration integration = new Integration();
        integration.setProjectId(Integer.parseInt(request.getParameter("projectId")));
        integration.setPersonId(Integer.parseInt(personId));
        integration.setComment(comment);
        integration.setState(Integration.PENDING);
        integration.setWhenRequested(new Date());

        List pendingIntegrations = getIntegrationsInState(session, Integration.PENDING, projectId);
        if (pendingIntegrations.size() == 0) {
            Integration activeIntegration = getFirstIntegrationInState(session, Integration.ACTIVE, projectId);
            if (activeIntegration == null) {
                startIntegration(integration);
            }
        }
View Full Code Here


    private void onLeaveRequest(Session session, HttpServletRequest request, int projectId) throws Exception {
        Integer oid = getLeaveOid(request);

        List pendingIntegrations = getIntegrationsInState(session, Integration.PENDING, projectId);
        Integration firstPendingIntegration = (Integration)pendingIntegrations.get(0);

        Integration leavingIntegration = (Integration)session.load(Integration.class, oid);
        session.delete(leavingIntegration);

        if (isNotificationEnabled(request) &&
                leavingIntegration.getId() == firstPendingIntegration.getId() &&
                pendingIntegrations.size() > 1) {
            fireIntegrationEvent(IntegrationListener.INTEGRATION_READY_EVENT,
                    (Integration)pendingIntegrations.get(1), request);
        }
    }
View Full Code Here

        return null;
    }

    private ActionForward onStartRequest(Session session, ActionMapping actionMapping, HttpServletRequest request, int projectId)
            throws Exception {
        Integration activeIntegration = getFirstIntegrationInState(session, Integration.ACTIVE, projectId);
        if (activeIntegration == null) {
            Integration integration = getFirstIntegrationInState(session, Integration.PENDING, projectId);
            startIntegration(integration);
            return actionMapping.findForward("display");
        } else {
            saveError(request, "integrations.error.alreadyactive");
            return actionMapping.findForward("error");
View Full Code Here

        terminateIntegration(session, Integration.FINISHED, request, projectId);
    }

    private void terminateIntegration(Session session, char terminalState, HttpServletRequest request, int projectId)
            throws Exception {
        Integration integration = getFirstIntegrationInState(session, Integration.ACTIVE, projectId);
        integration.setState(terminalState);
        integration.setWhenComplete(new Date());

        Integration readyIntegration = getFirstIntegrationInState(session, Integration.PENDING, projectId);
        if (isNotificationEnabled(request) && readyIntegration != null) {
            fireIntegrationEvent(IntegrationListener.INTEGRATION_READY_EVENT, readyIntegration, request);
        }
    }
View Full Code Here

        if (StringUtils.isEmpty(personId) || personId.equals("0")) {
            saveError(request, "integrations.error.noperson");
            return actionMapping.findForward("error");
        }
        Integration integration = new Integration();
        integration.setProjectId(Integer.parseInt(request.getParameter("projectId")));
        integration.setPersonId(Integer.parseInt(personId));
        integration.setComment(comment);
        integration.setState(Integration.PENDING);
        integration.setWhenRequested(new Date());

        List pendingIntegrations = getIntegrationsInState(session, Integration.PENDING, projectId);
        if (pendingIntegrations.size() == 0) {
            Integration activeIntegration = getFirstIntegrationInState(session, Integration.ACTIVE, projectId);
            if (activeIntegration == null) {
                startIntegration(integration);
            }
        }
View Full Code Here

    private void onLeaveRequest(Session session, HttpServletRequest request, int projectId) throws Exception {
        Integer oid = getLeaveOid(request);

        List pendingIntegrations = getIntegrationsInState(session, Integration.PENDING, projectId);
        Integration firstPendingIntegration = (Integration)pendingIntegrations.get(0);

        Integration leavingIntegration = (Integration)session.load(Integration.class, oid);
        session.delete(leavingIntegration);

        if (isNotificationEnabled(request) &&
                leavingIntegration.getId() == firstPendingIntegration.getId() &&
                pendingIntegrations.size() > 1) {
            fireIntegrationEvent(IntegrationListener.INTEGRATION_READY_EVENT,
                    (Integration)pendingIntegrations.get(1), request);
        }
    }
View Full Code Here

        return null;
    }

    private ActionForward onStartRequest(Session session, ActionMapping actionMapping, HttpServletRequest request, int projectId)
            throws Exception {
        Integration activeIntegration = getFirstIntegrationInState(session, Integration.ACTIVE, projectId);
        if (activeIntegration == null) {
            Integration integration = getFirstIntegrationInState(session, Integration.PENDING, projectId);
            startIntegration(integration);
            return actionMapping.findForward("display");
        } else {
            saveError(request, "integrations.error.alreadyactive");
            return actionMapping.findForward("error");
View Full Code Here

        terminateIntegration(session, Integration.FINISHED, request, projectId);
    }

    private void terminateIntegration(Session session, char terminalState, HttpServletRequest request, int projectId)
            throws Exception {
        Integration integration = getFirstIntegrationInState(session, Integration.ACTIVE, projectId);
        integration.setState(terminalState);
        integration.setWhenComplete(new Date());

        Integration readyIntegration = getFirstIntegrationInState(session, Integration.PENDING, projectId);
        if (isNotificationEnabled(request) && readyIntegration != null) {
            fireIntegrationEvent(IntegrationListener.INTEGRATION_READY_EVENT, readyIntegration, request);
        }
    }
View Full Code Here

        Logger.getRootLogger().setLevel(logLevel);
    }

    public void testJoin() throws Exception {
        mockSession.find3Return = new ArrayList();
        mockSession.find3Return.add(new Integration());
        support.request.setParameterValue("action.join", new String[]{""});
        support.request.setParameterValue("personId", new String[]{"1"});
        support.request.setParameterValue("comment", new String[]{"a comment"});
        replay();

        ActionForward forward = support.executeAction(action);

        verify();
        assertEquals(addProjectId("DISPLAY"), forward.getPath());
        assertTrue("no integration saved", mockSession.saveCalled);
        Integration integration = (Integration)mockSession.saveObject;
        assertEquals(PROJECT_ID, integration.getProjectId());
        assertEquals(1, integration.getPersonId());
        assertEquals("a comment", integration.getComment());
        assertEquals(Integration.PENDING, integration.getState());
        assertNotNull(integration.getWhenRequested());
        assertNull(integration.getWhenStarted());
        assertNull(integration.getWhenComplete());

        assertCommit();
    }
View Full Code Here

        ActionForward forward = support.executeAction(action);

        verify();
        assertEquals(addProjectId("DISPLAY"), forward.getPath());
        assertTrue("no integration saved", mockSession.saveCalled);
        Integration integration = (Integration)mockSession.saveObject;
        assertEquals(1, integration.getPersonId());
        assertEquals(PROJECT_ID, integration.getProjectId());
        assertEquals("a comment", integration.getComment());
        assertEquals(Integration.ACTIVE, integration.getState());
        assertNotNull(integration.getWhenRequested());
        assertNotNull(integration.getWhenStarted());
        assertNull(integration.getWhenComplete());

        assertCommit();
    }
View Full Code Here

TOP

Related Classes of org.nxplanner.domain.Integration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.