Search in sources :

Example 1 with RunForStateTransition

use of com.qcadoo.mes.states.annotation.RunForStateTransition in project mes by qcadoo.

the class TechnologyMasterAcceptingAspect method postHookOnAccepting.

@RunForStateTransition(targetState = TechnologyStateStringValues.ACCEPTED)
@After(CHANGE_STATE_EXECUTION_POINTCUT)
public void postHookOnAccepting(final StateChangeContext stateChangeContext) {
    Entity parameter = parameterService.getParameter();
    if (parameter.getBooleanField(ParameterFieldsT.ACCEPTED_TECHNOLOGY_MARKED_AS_DEFAULT)) {
        Entity owner = stateChangeContext.getOwner();
        owner.setField(TechnologyFields.MASTER, true);
        owner.getDataDefinition().save(owner);
    }
}
Also used : Entity(com.qcadoo.model.api.Entity) RunForStateTransition(com.qcadoo.mes.states.annotation.RunForStateTransition) After(org.aspectj.lang.annotation.After)

Example 2 with RunForStateTransition

use of com.qcadoo.mes.states.annotation.RunForStateTransition in project mes by qcadoo.

the class DeliveryStateValidationAspectTest method shouldPreValidationOnReceivedMethodBeCorrectlyAnnotated.

@Test
public final void shouldPreValidationOnReceivedMethodBeCorrectlyAnnotated() throws SecurityException, NoSuchMethodException {
    Method preValidationOnReceive = clazz.getMethod("preValidationOnReceived", StateChangeContext.class, int.class);
    assertNotNull(preValidationOnReceive);
    RunForStateTransitions transitions = preValidationOnReceive.getAnnotation(RunForStateTransitions.class);
    assertNotNull(transitions);
    assertEquals(2, transitions.value().length);
    RunForStateTransition firstTransition = transitions.value()[0];
    assertEquals(firstTransition.sourceState(), DeliveryStateStringValues.APPROVED);
    assertEquals(firstTransition.targetState(), DeliveryStateStringValues.RECEIVED);
    RunForStateTransition secondTransition = transitions.value()[1];
    assertEquals(secondTransition.sourceState(), DeliveryStateStringValues.APPROVED);
    assertEquals(secondTransition.targetState(), DeliveryStateStringValues.RECEIVE_CONFIRM_WAITING);
    RunInPhase runInPhase = preValidationOnReceive.getAnnotation(RunInPhase.class);
    assertNotNull(runInPhase);
    assertEquals(DeliveryStateChangePhase.PRE_VALIDATION, runInPhase.value()[0]);
    Before before = preValidationOnReceive.getAnnotation(Before.class);
    assertNotNull(before);
}
Also used : Before(org.aspectj.lang.annotation.Before) RunForStateTransition(com.qcadoo.mes.states.annotation.RunForStateTransition) RunInPhase(com.qcadoo.mes.states.annotation.RunInPhase) Method(java.lang.reflect.Method) RunForStateTransitions(com.qcadoo.mes.states.annotation.RunForStateTransitions) Test(org.junit.Test)

Example 3 with RunForStateTransition

use of com.qcadoo.mes.states.annotation.RunForStateTransition in project mes by qcadoo.

the class AssignmentToShiftListenerAspect method onCorrectedAfterAllOtherOpsSuccessfullyDone.

@RunInPhase(AssignmentToShiftStateChangePhase.LAST)
@RunForStateTransition(sourceState = AssignmentToShiftStateStringValues.DURING_CORRECTION, targetState = AssignmentToShiftStateStringValues.CORRECTED)
@After(PHASE_EXECUTION_POINTCUT)
public void onCorrectedAfterAllOtherOpsSuccessfullyDone(final StateChangeContext stateChangeContext, final int phase) {
    Entity assignmentToShift = stateChangeContext.getOwner();
    assignmentToShift.setField(AssignmentToShiftFields.STAFF_ASSIGNMENT_TO_SHIFTS, assignmentToShiftListenerService.addCorrectedStaffsListToAssignment(assignmentToShift));
    assignmentToShiftConfirmationStatusHelper.setShowLastResultsFlag(assignmentToShift, true);
    stateChangeContext.setOwner(assignmentToShift);
}
Also used : Entity(com.qcadoo.model.api.Entity) RunForStateTransition(com.qcadoo.mes.states.annotation.RunForStateTransition) After(org.aspectj.lang.annotation.After) RunInPhase(com.qcadoo.mes.states.annotation.RunInPhase)

Example 4 with RunForStateTransition

use of com.qcadoo.mes.states.annotation.RunForStateTransition in project mes by qcadoo.

the class AssignmentToShiftListenerAspect method onLeaveDraftStateAfterValidation.

@RunInPhase(AssignmentToShiftStateChangePhase.DEFAULT)
@RunForStateTransition(sourceState = AssignmentToShiftStateStringValues.DRAFT)
@Before(PHASE_EXECUTION_POINTCUT)
public void onLeaveDraftStateAfterValidation(final StateChangeContext stateChangeContext, final int phase) {
    Entity assignmentToShift = stateChangeContext.getOwner();
    assignmentToShiftConfirmationStatusHelper.clearFailureInfo(assignmentToShift);
    stateChangeContext.setOwner(assignmentToShift);
}
Also used : Entity(com.qcadoo.model.api.Entity) Before(org.aspectj.lang.annotation.Before) RunForStateTransition(com.qcadoo.mes.states.annotation.RunForStateTransition) RunInPhase(com.qcadoo.mes.states.annotation.RunInPhase)

Example 5 with RunForStateTransition

use of com.qcadoo.mes.states.annotation.RunForStateTransition in project mes by qcadoo.

the class AssignmentToShiftListenerAspect method onAcceptedAfterAllOtherOpsSuccessfullyDone.

@RunInPhase(AssignmentToShiftStateChangePhase.LAST)
@RunForStateTransition(sourceState = AssignmentToShiftStateStringValues.DRAFT, targetState = AssignmentToShiftStateStringValues.ACCEPTED)
@After(PHASE_EXECUTION_POINTCUT)
public void onAcceptedAfterAllOtherOpsSuccessfullyDone(final StateChangeContext stateChangeContext, final int phase) {
    Entity assignmentToShift = stateChangeContext.getOwner();
    assignmentToShift.setField(AssignmentToShiftFields.STAFF_ASSIGNMENT_TO_SHIFTS, assignmentToShiftListenerService.addAcceptedStaffsListToAssignment(assignmentToShift));
    assignmentToShift.setField(AssignmentToShiftFields.APPROVED_ATTENDANCE_LIST, true);
    assignmentToShiftConfirmationStatusHelper.setShowLastResultsFlag(assignmentToShift, true);
    stateChangeContext.setOwner(assignmentToShift);
}
Also used : Entity(com.qcadoo.model.api.Entity) RunForStateTransition(com.qcadoo.mes.states.annotation.RunForStateTransition) After(org.aspectj.lang.annotation.After) RunInPhase(com.qcadoo.mes.states.annotation.RunInPhase)

Aggregations

RunForStateTransition (com.qcadoo.mes.states.annotation.RunForStateTransition)10 RunInPhase (com.qcadoo.mes.states.annotation.RunInPhase)8 Entity (com.qcadoo.model.api.Entity)6 After (org.aspectj.lang.annotation.After)6 Before (org.aspectj.lang.annotation.Before)3 EntityList (com.qcadoo.model.api.EntityList)2 Method (java.lang.reflect.Method)2 Test (org.junit.Test)2 StateChangeEntityDescriber (com.qcadoo.mes.states.StateChangeEntityDescriber)1 RunForStateTransitions (com.qcadoo.mes.states.annotation.RunForStateTransitions)1 Date (java.util.Date)1