Search in sources :

Example 96 with LookupComponent

use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.

the class LineChangeoverNormsForOrdersServiceImpl method fillOrderForm.

@Override
public void fillOrderForm(final ViewDefinitionState view, final List<String> orderFields) {
    LookupComponent orderLookup = (LookupComponent) view.getComponentByReference(orderFields.get(0));
    Entity order = orderLookup.getEntity();
    if (order == null) {
        return;
    }
    FieldComponent technologyNumberField = (FieldComponent) view.getComponentByReference(orderFields.get(1));
    FieldComponent technologyGroupNumberField = (FieldComponent) view.getComponentByReference(orderFields.get(2));
    FieldComponent dateToFromField = (FieldComponent) view.getComponentByReference(orderFields.get(3));
    FieldComponent dateIsField = (FieldComponent) view.getComponentByReference(orderFields.get(4));
    orderLookup.setFieldValue(order.getId());
    orderLookup.requestComponentUpdateState();
    setUpTechnologyFields(order, technologyNumberField, technologyGroupNumberField);
    Date dateToFrom = null;
    String dateIs = null;
    if (L_PREVIOUS_ORDER_DATE_TO.equals(orderFields.get(3))) {
        Date effectiveDateTo = order.getDateField(OrderFields.EFFECTIVE_DATE_TO);
        Date correctedDateTo = order.getDateField(OrderFields.CORRECTED_DATE_TO);
        Date dateTo = order.getDateField(OrderFields.DATE_TO);
        if (effectiveDateTo != null) {
            dateToFrom = effectiveDateTo;
            dateIs = L_LINE_CHANGEOVER_NORMS_FOR_ORDERS_DATE_IS_EFFECTIVE;
        } else if (correctedDateTo != null) {
            dateToFrom = correctedDateTo;
            dateIs = L_LINE_CHANGEOVER_NORMS_FOR_ORDERS_DATE_IS_CORRECTED;
        } else if (dateTo != null) {
            dateToFrom = dateTo;
            dateIs = L_LINE_CHANGEOVER_NORMS_FOR_ORDERS_DATE_IS_PLANNED;
        }
    } else if (L_DATE_FROM.equals(orderFields.get(3))) {
        Date effectiveDateFrom = order.getDateField(OrderFields.EFFECTIVE_DATE_FROM);
        Date correctedDateFrom = order.getDateField(OrderFields.CORRECTED_DATE_FROM);
        Date dateFrom = order.getDateField(OrderFields.DATE_FROM);
        if (effectiveDateFrom != null) {
            dateToFrom = effectiveDateFrom;
            dateIs = L_LINE_CHANGEOVER_NORMS_FOR_ORDERS_DATE_IS_EFFECTIVE;
        } else if (correctedDateFrom != null) {
            dateToFrom = correctedDateFrom;
            dateIs = L_LINE_CHANGEOVER_NORMS_FOR_ORDERS_DATE_IS_CORRECTED;
        } else if (dateFrom != null) {
            dateToFrom = dateFrom;
            dateIs = L_LINE_CHANGEOVER_NORMS_FOR_ORDERS_DATE_IS_PLANNED;
        }
    }
    if (dateToFrom == null || dateIs == null) {
        dateToFromField.setFieldValue(null);
        dateIsField.setFieldValue(null);
    } else {
        dateToFromField.setFieldValue(new SimpleDateFormat(DateUtils.L_DATE_TIME_FORMAT, Locale.getDefault()).format(dateToFrom));
        dateIsField.setFieldValue(translationService.translate(dateIs, LocaleContextHolder.getLocale()));
    }
    dateToFromField.requestComponentUpdateState();
    dateIsField.requestComponentUpdateState();
}
Also used : Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 97 with LookupComponent

use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.

the class LineChangeoverNormsForOrderDetailsViewHooks method fillOrderForms.

public final void fillOrderForms(final ViewDefinitionState view) {
    FormComponent orderForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    LookupComponent orderLookup = (LookupComponent) view.getComponentByReference(OrderFieldsLCNFO.ORDER);
    LookupComponent previousOrderLookup = (LookupComponent) view.getComponentByReference(OrderFieldsLCNFO.PREVIOUS_ORDER);
    if (orderForm.getEntityId() == null) {
        return;
    }
    Entity order = orderForm.getPersistedEntityWithIncludedFormValues();
    orderLookup.setFieldValue(order.getId());
    orderLookup.requestComponentUpdateState();
    lineChangeoverNormsForOrdersService.fillOrderForm(view, LineChangeoverNormsForOrdersConstants.ORDER_FIELDS);
    if (previousOrderLookup.isEmpty()) {
        Entity previousOrder = lineChangeoverNormsForOrdersService.getPreviousOrderFromDB(order);
        if (previousOrder != null) {
            previousOrderLookup.setFieldValue(previousOrder.getId());
            previousOrderLookup.requestComponentUpdateState();
            lineChangeoverNormsForOrdersService.fillOrderForm(view, LineChangeoverNormsForOrdersConstants.PREVIOUS_ORDER_FIELDS);
        }
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent)

Example 98 with LookupComponent

use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.

the class LineChangeoverNormsForOrderDetailsViewHooks method findChangeoverNorm.

private Entity findChangeoverNorm(final ViewDefinitionState view) {
    LookupComponent orderLookup = (LookupComponent) view.getComponentByReference(OrderFieldsLCNFO.ORDER);
    LookupComponent previousOrderLookup = (LookupComponent) view.getComponentByReference(OrderFieldsLCNFO.PREVIOUS_ORDER);
    Entity order = orderLookup.getEntity();
    if (order == null) {
        return null;
    }
    Entity fromTechnology = extractTechnologyPrototypeFrom(previousOrderLookup.getEntity());
    Entity toTechnology = extractTechnologyPrototypeFrom(order);
    if (fromTechnology == null || toTechnology == null) {
        return null;
    }
    Entity productionLine = order.getBelongsToField(OrderFields.PRODUCTION_LINE);
    return changeoverNormsService.getMatchingChangeoverNorms(fromTechnology, toTechnology, productionLine);
}
Also used : Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent)

Example 99 with LookupComponent

use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.

the class LineChangeoverNormsForOrderDetailsListeners method showPreviousOrder.

public final void showPreviousOrder(final ViewDefinitionState view, final ComponentState componentState, final String[] args) {
    LookupComponent previousOrderLookup = (LookupComponent) view.getComponentByReference(OrderFieldsLCNFO.PREVIOUS_ORDER);
    Long previousOrderId = (Long) previousOrderLookup.getFieldValue();
    if (previousOrderId == null) {
        return;
    }
    Map<String, Object> parameters = Maps.newHashMap();
    parameters.put("form.id", previousOrderId);
    String url = "../page/orders/orderDetails.html";
    view.redirectTo(url, false, true, parameters);
}
Also used : LookupComponent(com.qcadoo.view.api.components.LookupComponent)

Example 100 with LookupComponent

use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.

the class LineChangeoverNormsForOrderDetailsListeners method checkIfOrderHasCorrectStateAndIsPrevious.

public final void checkIfOrderHasCorrectStateAndIsPrevious(final ViewDefinitionState view, final ComponentState componentState, final String[] args) {
    LookupComponent previousOrderLookup = (LookupComponent) view.getComponentByReference(OrderFieldsLCNFO.PREVIOUS_ORDER);
    LookupComponent orderLookup = (LookupComponent) view.getComponentByReference(OrderFieldsLCNFO.ORDER);
    Entity previousOrder = previousOrderLookup.getEntity();
    Entity order = orderLookup.getEntity();
    if (!lineChangeoverNormsForOrdersService.previousOrderEndsBeforeOrIsWithdrawed(previousOrder, order)) {
        previousOrderLookup.addMessage("orders.order.previousOrder.message.orderIsIncorrect", ComponentState.MessageType.FAILURE);
    }
}
Also used : Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent)

Aggregations

LookupComponent (com.qcadoo.view.api.components.LookupComponent)277 Entity (com.qcadoo.model.api.Entity)182 FieldComponent (com.qcadoo.view.api.components.FieldComponent)105 FormComponent (com.qcadoo.view.api.components.FormComponent)102 FilterValueHolder (com.qcadoo.view.api.components.lookup.FilterValueHolder)69 BigDecimal (java.math.BigDecimal)16 CheckBoxComponent (com.qcadoo.view.api.components.CheckBoxComponent)12 GridComponent (com.qcadoo.view.api.components.GridComponent)11 WindowComponent (com.qcadoo.view.api.components.WindowComponent)8 RibbonActionItem (com.qcadoo.view.api.ribbon.RibbonActionItem)7 Date (java.util.Date)6 JSONObject (org.json.JSONObject)6 ComponentState (com.qcadoo.view.api.ComponentState)5 AwesomeDynamicListComponent (com.qcadoo.view.api.components.AwesomeDynamicListComponent)5 JSONException (org.json.JSONException)5 DataDefinition (com.qcadoo.model.api.DataDefinition)3 RibbonGroup (com.qcadoo.view.api.ribbon.RibbonGroup)3 Optional (com.google.common.base.Optional)2 ProductFields (com.qcadoo.mes.basic.constants.ProductFields)2 DataDefinitionService (com.qcadoo.model.api.DataDefinitionService)2