use of com.qcadoo.mes.states.StateChangeContext in project mes by qcadoo.
the class PlannedEventReasonViewListeners method cancelStateChange.
public void cancelStateChange(final ViewDefinitionState view, final ComponentState form, final String[] args) {
final Entity stateChangeEntity = ((FormComponent) form).getEntity();
stateChangeEntity.setField(PlannedEventStateChangeFields.COMMENT_REQUIRED, false);
final StateChangeContext stateContext = stateChangeContextBuilder.build(plannedEventStateChangeAspect.getChangeEntityDescriber(), stateChangeEntity);
stateContext.setStatus(StateChangeStatus.CANCELED);
stateContext.save();
plannedEventStateChangeViewClient.showMessages(new ViewContextHolder(view, form), stateContext);
}
use of com.qcadoo.mes.states.StateChangeContext in project mes by qcadoo.
the class PlannedEventReasonViewListeners method continueStateChange.
public void continueStateChange(final ViewDefinitionState view, final ComponentState component, final String[] args) {
final FormComponent form = (FormComponent) component;
Entity eventStateChange = form.getPersistedEntityWithIncludedFormValues();
plannedEventStateChangeValidators.validate(eventStateChange.getDataDefinition(), eventStateChange);
form.setEntity(eventStateChange);
if (!eventStateChange.getErrors().isEmpty()) {
return;
}
form.performEvent(view, "save");
if (!form.isValid()) {
return;
}
final Entity stateChangeEntity = ((FormComponent) form).getEntity();
final StateChangeContext stateContext = stateChangeContextBuilder.build(plannedEventStateChangeAspect.getChangeEntityDescriber(), stateChangeEntity);
stateContext.setStatus(StateChangeStatus.IN_PROGRESS);
plannedEventStateChangeAspect.changeState(stateContext);
plannedEventStateChangeViewClient.showMessages(new ViewContextHolder(view, form), stateContext);
}
use of com.qcadoo.mes.states.StateChangeContext in project mes by qcadoo.
the class MaintenanceEventReasonViewListeners method continueStateChange.
public void continueStateChange(final ViewDefinitionState view, final ComponentState component, final String[] args) {
final FormComponent form = (FormComponent) component;
Entity eventStateChange = form.getPersistedEntityWithIncludedFormValues();
maintenanceEventStateChangeValidators.validate(eventStateChange.getDataDefinition(), eventStateChange);
form.setEntity(eventStateChange);
if (!eventStateChange.getErrors().isEmpty()) {
return;
}
form.performEvent(view, "save");
if (!form.isValid()) {
return;
}
final Entity stateChangeEntity = ((FormComponent) form).getEntity();
final StateChangeContext stateContext = stateChangeContextBuilder.build(maintenanceEventStateChangeAspect.getChangeEntityDescriber(), stateChangeEntity);
stateContext.setStatus(StateChangeStatus.IN_PROGRESS);
maintenanceEventStateChangeAspect.changeState(stateContext);
maintenanceEventStateChangeViewClient.showMessages(new ViewContextHolder(view, form), stateContext);
}
use of com.qcadoo.mes.states.StateChangeContext in project mes by qcadoo.
the class MaintenanceEventReasonViewListeners method cancelStateChange.
public void cancelStateChange(final ViewDefinitionState view, final ComponentState form, final String[] args) {
final Entity stateChangeEntity = ((FormComponent) form).getEntity();
final StateChangeContext stateContext = stateChangeContextBuilder.build(maintenanceEventStateChangeAspect.getChangeEntityDescriber(), stateChangeEntity);
stateContext.setStatus(StateChangeStatus.CANCELED);
stateContext.save();
maintenanceEventStateChangeViewClient.showMessages(new ViewContextHolder(view, form), stateContext);
}
use of com.qcadoo.mes.states.StateChangeContext in project mes by qcadoo.
the class AfterReviewEventsService method createAfterReviewEvents.
public void createAfterReviewEvents(final StateChangeContext stateChangeContext) {
Entity plannedEvent = stateChangeContext.getOwner();
if (!PlannedEventType.REVIEW.equals(PlannedEventType.from(plannedEvent))) {
return;
}
List<Entity> incorrectActions = plannedEvent.getHasManyField(PlannedEventFields.ACTIONS).stream().filter(action -> action.getStringField(ActionForPlannedEventFields.STATE).equals(ActionForPlannedEventState.INCORRECT.getStringValue())).collect(Collectors.toList());
List<String> createdActions = Lists.newArrayList();
for (Entity action : incorrectActions) {
createdActions.add(createAfterReviewEventForIncorrectAction(action, plannedEvent));
}
if (!createdActions.isEmpty()) {
stateChangeContext.addMessage("cmmsMachineParts.plannedEvent.afterReviewEventsCreated", StateMessageType.INFO, true, createdActions.stream().collect(Collectors.joining(", ")));
}
}
Aggregations