use of com.qcadoo.mes.states.service.client.util.ViewContextHolder in project mes by qcadoo.
the class OrderDetailsListeners method changeState.
public void changeState(final ViewDefinitionState view, final ComponentState state, final String[] args) {
state.performEvent(view, "save", args);
FormComponent formComponent = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity order = formComponent.getPersistedEntityWithIncludedFormValues();
Entity technology = order.getBelongsToField(OrderFields.TECHNOLOGY);
if (Objects.nonNull(technology)) {
if (TechnologyStateStringValues.DRAFT.equals(technology.getStringField(TechnologyFields.STATE))) {
technologyStateChangeViewClient.changeState(new ViewContextHolder(view, state), TechnologyStateStringValues.ACCEPTED, technology);
} else if (TechnologyStateStringValues.CHECKED.equals(technology.getStringField(TechnologyFields.STATE))) {
technologyServiceO.changeTechnologyStateToAccepted(technology);
}
}
orderStateChangeViewClient.changeState(new ViewContextHolder(view, state), args[0]);
}
use of com.qcadoo.mes.states.service.client.util.ViewContextHolder in project mes by qcadoo.
the class OrderStateReasonViewListeners method continueStateChange.
public void continueStateChange(final ViewDefinitionState view, final ComponentState component, final String[] args) {
final FormComponent form = (FormComponent) component;
form.performEvent(view, "save");
if (!form.isValid()) {
return;
}
final Entity stateChangeEntity = ((FormComponent) form).getEntity();
final StateChangeContext stateContext = stateChangeContextBuilder.build(orderStateChangeService.getChangeEntityDescriber(), stateChangeEntity);
stateContext.setStatus(StateChangeStatus.IN_PROGRESS);
orderStateChangeService.changeState(stateContext);
orderStateChangeViewClient.showMessages(new ViewContextHolder(view, form), stateContext);
}
use of com.qcadoo.mes.states.service.client.util.ViewContextHolder in project mes by qcadoo.
the class OrdersListListeners method changeState.
public void changeState(final ViewDefinitionState view, final ComponentState state, final String[] args) {
GridComponent gridComponent = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
for (Long orderId : gridComponent.getSelectedEntitiesIds()) {
Entity order = getOrderDD().get(orderId);
order = getOrderDD().save(order);
if (order.isValid()) {
Entity technology = order.getBelongsToField(OrderFields.TECHNOLOGY);
if (TechnologyStateStringValues.DRAFT.equals(technology.getStringField(TechnologyFields.STATE))) {
technologyStateChangeViewClient.changeState(new ViewContextHolder(view, state), TechnologyStateStringValues.ACCEPTED, technology);
} else if (TechnologyStateStringValues.CHECKED.equals(technology.getStringField(TechnologyFields.STATE))) {
technologyServiceO.changeTechnologyStateToAccepted(technology);
}
orderStateChangeViewClient.changeState(new ViewContextHolder(view, state), args[0], order);
} else {
view.addMessage("orders.ordersList.changeState.validationErrors", ComponentState.MessageType.FAILURE, false, order.getStringField(OrderFields.NUMBER));
}
}
}
Aggregations