Search in sources :

Example 56 with FilterValueHolder

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

the class OperationalTaskDetailsListeners method onDivisionChange.

public void onDivisionChange(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    LookupComponent workstationLookup = (LookupComponent) view.getComponentByReference(OperationalTaskFields.WORKSTATION);
    FilterValueHolder filterValueHolder = workstationLookup.getFilterValue();
    if (filterValueHolder.has(OperationalTaskFields.DIVISION)) {
        filterValueHolder.remove(OperationalTaskFields.DIVISION);
        workstationLookup.setFilterValue(filterValueHolder);
    }
    workstationLookup.setFieldValue(null);
    workstationLookup.requestComponentUpdateState();
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) LookupComponent(com.qcadoo.view.api.components.LookupComponent)

Example 57 with FilterValueHolder

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

the class OrderDetailsListeners method changeOrderProduct.

public void changeOrderProduct(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    LookupComponent productLookup = (LookupComponent) view.getComponentByReference(OrderFields.PRODUCT);
    LookupComponent technologyLookup = (LookupComponent) view.getComponentByReference(OrderFields.TECHNOLOGY_PROTOTYPE);
    FieldComponent defaultTechnologyField = (FieldComponent) view.getComponentByReference(OrderFields.DEFAULT_TECHNOLOGY);
    Entity product = productLookup.getEntity();
    defaultTechnologyField.setFieldValue(null);
    technologyLookup.setFieldValue(null);
    if (Objects.nonNull(product)) {
        FilterValueHolder holder = technologyLookup.getFilterValue();
        holder.put(TechnologyCriteriaModifiersO.PRODUCT_PARAMETER, product.getId());
        technologyLookup.setFilterValue(holder);
        Entity defaultTechnologyEntity = technologyServiceO.getDefaultTechnology(product);
        if (Objects.nonNull(defaultTechnologyEntity)) {
            String defaultTechnologyValue = expressionService.getValue(defaultTechnologyEntity, "#number + ' - ' + #name", view.getLocale());
            defaultTechnologyField.setFieldValue(defaultTechnologyValue);
            technologyLookup.setFieldValue(defaultTechnologyEntity.getId());
        }
    }
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Example 58 with FilterValueHolder

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

the class ProductionLineScheduleDetailsHooks method setOrderLookupCriteriaModifier.

private void setOrderLookupCriteriaModifier(final ViewDefinitionState view) {
    FormComponent scheduleForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Long scheduleId = scheduleForm.getEntityId();
    LookupComponent orderLookup = (LookupComponent) view.getComponentByReference(L_ORDERS_LOOKUP);
    FilterValueHolder valueHolder = orderLookup.getFilterValue();
    valueHolder.put(ProductionLineScheduleOrderCriteriaModifiers.SCHEDULE_PARAMETER, scheduleId);
    orderLookup.setFilterValue(valueHolder);
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) FormComponent(com.qcadoo.view.api.components.FormComponent) LookupComponent(com.qcadoo.view.api.components.LookupComponent)

Example 59 with FilterValueHolder

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

the class ModelCardProductDetailsHooks method onBeforeRender.

public void onBeforeRender(final ViewDefinitionState view) {
    LookupComponent productLookup = (LookupComponent) view.getComponentByReference(ModelCardProductFields.PRODUCT);
    FilterValueHolder filterValueHolder = productLookup.getFilterValue();
    Entity product = productLookup.getEntity();
    String unit = "";
    if (product != null) {
        unit = product.getStringField(ProductFields.UNIT);
        LookupComponent technologyLookup = (LookupComponent) view.getComponentByReference(ModelCardProductFields.TECHNOLOGY);
        FilterValueHolder technologyFilterValueHolder = technologyLookup.getFilterValue();
        technologyFilterValueHolder.put(TechnologyCriteriaModifiersO.PRODUCT_PARAMETER, product.getId());
        technologyLookup.setFilterValue(technologyFilterValueHolder);
    }
    FieldComponent quantityUnit = (FieldComponent) view.getComponentByReference(L_QUANTITY_UNIT);
    quantityUnit.setFieldValue(unit);
    quantityUnit.requestComponentUpdateState();
    Entity modelCardProduct = ((FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM)).getEntity();
    Long modelCardId = modelCardProduct.getBelongsToField(ModelCardProductFields.MODEL_CARD).getId();
    filterValueHolder.put(ProductCriteriaModifiersPFTD.L_MODEL_CARD_ID, modelCardId);
    Entity productFromDb = modelCardProduct.getBelongsToField(ModelCardProductFields.PRODUCT);
    if (productFromDb != null) {
        filterValueHolder.put(ProductCriteriaModifiersPFTD.L_PRODUCT_ID, productFromDb.getId());
    }
    productLookup.setFilterValue(filterValueHolder);
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) Entity(com.qcadoo.model.api.Entity) FormComponent(com.qcadoo.view.api.components.FormComponent) LookupComponent(com.qcadoo.view.api.components.LookupComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Example 60 with FilterValueHolder

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

the class OrderDetailsHooksPFTD method onBeforeRender.

public void onBeforeRender(final ViewDefinitionState view) {
    orderDetailsRibbonHelper.setButtonEnabled(view, "materialFlow", "warehouseIssues", OrderDetailsRibbonHelper.HAS_CHECKED_OR_ACCEPTED_TECHNOLOGY::test);
    orderDetailsRibbonHelper.setButtonEnabled(view, "materialFlow", "componentAvailability", OrderDetailsRibbonHelper.HAS_CHECKED_OR_ACCEPTED_TECHNOLOGY::test);
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    ComponentState staffTab = view.getComponentByReference("staffTab");
    if (form.getEntityId() != null) {
        Entity order = dataDefinitionService.get(OrdersConstants.PLUGIN_IDENTIFIER, OrdersConstants.MODEL_ORDER).get(form.getEntityId());
        staffTab.setVisible(TypeOfProductionRecording.CUMULATED.getStringValue().equals(order.getStringField(OrderFieldsPC.TYPE_OF_PRODUCTION_RECORDING)));
        LookupComponent technologyLookup = (LookupComponent) view.getComponentByReference(OrderFields.TECHNOLOGY_PROTOTYPE);
        LookupComponent productionLineLookup = (LookupComponent) view.getComponentByReference(OrderFields.PRODUCTION_LINE);
        Entity technology = technologyLookup.getEntity();
        Entity productionLine = productionLineLookup.getEntity();
        if (technology != null && productionLine != null) {
            FieldComponent plannedStaffField = (FieldComponent) view.getComponentByReference("plannedStaff");
            Optional<Integer> plannedStaff = technologyService.getPlannedStaff(technology, productionLine);
            if (plannedStaff.isPresent()) {
                plannedStaffField.setFieldValue(plannedStaff.get());
            } else {
                plannedStaffField.setFieldValue(null);
            }
        }
        FieldComponent actualStaff = (FieldComponent) view.getComponentByReference("actualStaff");
        actualStaff.setFieldValue(order.getManyToManyField(OrderFields.STAFF).size());
        LookupComponent staffLookup = (LookupComponent) view.getComponentByReference("staffLookup");
        FilterValueHolder valueHolder = staffLookup.getFilterValue();
        valueHolder.put(StaffCriteriaModifierPFTD.L_ORDER_ID, form.getEntityId());
        if (productionLine != null) {
            valueHolder.put(StaffCriteriaModifierPFTD.L_PRODUCTION_LINE_ID, productionLine.getId());
        } else if (valueHolder.has(StaffCriteriaModifierPFTD.L_PRODUCTION_LINE_ID)) {
            valueHolder.remove(StaffCriteriaModifierPFTD.L_PRODUCTION_LINE_ID);
        }
        staffLookup.setFilterValue(valueHolder);
    } else {
        staffTab.setVisible(false);
    }
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent) ComponentState(com.qcadoo.view.api.ComponentState)

Aggregations

FilterValueHolder (com.qcadoo.view.api.components.lookup.FilterValueHolder)119 LookupComponent (com.qcadoo.view.api.components.LookupComponent)69 Entity (com.qcadoo.model.api.Entity)64 FormComponent (com.qcadoo.view.api.components.FormComponent)45 GridComponent (com.qcadoo.view.api.components.GridComponent)26 FieldComponent (com.qcadoo.view.api.components.FieldComponent)13 Collectors (java.util.stream.Collectors)11 Autowired (org.springframework.beans.factory.annotation.Autowired)11 Service (org.springframework.stereotype.Service)11 DataDefinitionService (com.qcadoo.model.api.DataDefinitionService)10 SearchCriteriaBuilder (com.qcadoo.model.api.search.SearchCriteriaBuilder)10 SearchRestrictions (com.qcadoo.model.api.search.SearchRestrictions)10 Objects (java.util.Objects)10 DataDefinition (com.qcadoo.model.api.DataDefinition)9 JSONObject (org.json.JSONObject)9 UserFieldsMF (com.qcadoo.mes.materialFlow.constants.UserFieldsMF)8 UserLocationFields (com.qcadoo.mes.materialFlow.constants.UserLocationFields)8 EntityList (com.qcadoo.model.api.EntityList)8 SecurityService (com.qcadoo.security.api.SecurityService)8 QcadooSecurityConstants (com.qcadoo.security.constants.QcadooSecurityConstants)8