Search in sources :

Example 6 with ViewContextHolder

use of com.qcadoo.mes.states.service.client.util.ViewContextHolder 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);
}
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 7 with ViewContextHolder

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

Example 8 with ViewContextHolder

use of com.qcadoo.mes.states.service.client.util.ViewContextHolder in project mes by qcadoo.

the class CopyOfTechnologyDetailsListeners method checkTechnology.

public void checkTechnology(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    final FormComponent technologyForm = (FormComponent) state;
    Long technologyId = (Long) state.getFieldValue();
    if (technologyId != null) {
        Entity technology1 = technologyServiceO.getTechnologyDD().get(technologyId);
        Entity order = getOrderWithTechnology(view);
        order = technologyServiceO.createTechnologyIfPktDisabled(order.getDataDefinition(), order);
        Entity technology2 = order.getBelongsToField(OrderFields.TECHNOLOGY);
        if (!Objects.equal(technology1.getId(), technology2.getId())) {
            Map<String, Object> parameters = Maps.newHashMap();
            parameters.put("form.id", technology2.getId());
            parameters.put("form.orderId", order.getId());
            String url = "../page/orders/copyOfTechnologyDetails.html";
            view.redirectTo(url, false, false, parameters);
        } else {
            copyOfTechnologyStateChangeVC.changeState(new ViewContextHolder(view, technologyForm), args[0], technology2);
        }
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) ViewContextHolder(com.qcadoo.mes.states.service.client.util.ViewContextHolder)

Example 9 with ViewContextHolder

use of com.qcadoo.mes.states.service.client.util.ViewContextHolder in project mes by qcadoo.

the class OrderStateReasonViewListeners method cancelStateChange.

public void cancelStateChange(final ViewDefinitionState view, final ComponentState form, final String[] args) {
    final Entity stateChangeEntity = ((FormComponent) form).getEntity();
    stateChangeEntity.setField(REASON_REQUIRED, false);
    final StateChangeContext stateContext = stateChangeContextBuilder.build(orderStateChangeService.getChangeEntityDescriber(), stateChangeEntity);
    stateContext.setStatus(StateChangeStatus.CANCELED);
    stateContext.save();
    orderStateChangeViewClient.showMessages(new ViewContextHolder(view, form), stateContext);
}
Also used : Entity(com.qcadoo.model.api.Entity) FormComponent(com.qcadoo.view.api.components.FormComponent) ViewContextHolder(com.qcadoo.mes.states.service.client.util.ViewContextHolder) StateChangeContext(com.qcadoo.mes.states.StateChangeContext)

Example 10 with ViewContextHolder

use of com.qcadoo.mes.states.service.client.util.ViewContextHolder in project mes by qcadoo.

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

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