Search in sources :

Example 11 with ViewContextHolder

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]);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) ViewContextHolder(com.qcadoo.mes.states.service.client.util.ViewContextHolder)

Example 12 with ViewContextHolder

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);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) ViewContextHolder(com.qcadoo.mes.states.service.client.util.ViewContextHolder) StateChangeContext(com.qcadoo.mes.states.StateChangeContext)

Example 13 with ViewContextHolder

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));
        }
    }
}
Also used : Entity(com.qcadoo.model.api.Entity) ViewContextHolder(com.qcadoo.mes.states.service.client.util.ViewContextHolder) GridComponent(com.qcadoo.view.api.components.GridComponent)

Aggregations

ViewContextHolder (com.qcadoo.mes.states.service.client.util.ViewContextHolder)13 Entity (com.qcadoo.model.api.Entity)12 FormComponent (com.qcadoo.view.api.components.FormComponent)10 StateChangeContext (com.qcadoo.mes.states.StateChangeContext)8 Transactional (org.springframework.transaction.annotation.Transactional)2 GridComponent (com.qcadoo.view.api.components.GridComponent)1