Search in sources :

Example 11 with FilterValueHolder

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

the class UseReplacementCriteriaModifiers method filter.

public void filter(final SearchCriteriaBuilder scb, final FilterValueHolder filterValue) {
    if (filterValue.has("BASIC_PRODUCT_ID")) {
        Entity basicProduct = dataDefinitionService.get(BasicConstants.PLUGIN_IDENTIFIER, BasicConstants.MODEL_PRODUCT).get(filterValue.getLong("BASIC_PRODUCT_ID"));
        List<Entity> replacements = basicProduct.getHasManyField(ProductFields.SUBSTITUTE_COMPONENTS);
        List<Long> ids = replacements.stream().filter(r -> Objects.nonNull(r.getBelongsToField(SubstituteComponentFields.PRODUCT))).map(r -> r.getBelongsToField(SubstituteComponentFields.PRODUCT).getId()).collect(Collectors.toList());
        scb.add(SearchRestrictions.in("id", ids));
    } else {
        scb.add(SearchRestrictions.idEq(-1));
    }
}
Also used : DataDefinitionService(com.qcadoo.model.api.DataDefinitionService) SearchRestrictions(com.qcadoo.model.api.search.SearchRestrictions) Autowired(org.springframework.beans.factory.annotation.Autowired) SubstituteComponentFields(com.qcadoo.mes.basic.constants.SubstituteComponentFields) Collectors(java.util.stream.Collectors) FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) Objects(java.util.Objects) Entity(com.qcadoo.model.api.Entity) List(java.util.List) BasicConstants(com.qcadoo.mes.basic.constants.BasicConstants) Service(org.springframework.stereotype.Service) ProductFields(com.qcadoo.mes.basic.constants.ProductFields) SearchCriteriaBuilder(com.qcadoo.model.api.search.SearchCriteriaBuilder) Entity(com.qcadoo.model.api.Entity)

Example 12 with FilterValueHolder

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

the class DivisionDetailsHooksPL method fillCriteriaModifiers.

public void fillCriteriaModifiers(final ViewDefinitionState viewDefinitionState) {
    GridComponent workstations = (GridComponent) viewDefinitionState.getComponentByReference("workstations");
    FormComponent form = (FormComponent) viewDefinitionState.getComponentByReference(QcadooViewConstants.L_FORM);
    if (form.getEntityId() != null) {
        FilterValueHolder filter = workstations.getFilterValue();
        filter.put("division", form.getEntityId());
        workstations.setFilterValue(filter);
    }
    workstations.reloadEntities();
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) FormComponent(com.qcadoo.view.api.components.FormComponent) GridComponent(com.qcadoo.view.api.components.GridComponent)

Example 13 with FilterValueHolder

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

the class OperationDurationDetailsInOrderHooks method setCriteriaModifierParameters.

private void setCriteriaModifierParameters(ViewDefinitionState view) {
    FormComponent orderForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Long orderId = orderForm.getEntityId();
    GridComponent grid = (GridComponent) view.getComponentByReference("operCompTimeCalculationsGrid");
    FilterValueHolder holder = grid.getFilterValue();
    holder.put(OperCompTimeCalculationsCM.ORDER_PARAMETER, orderId);
    grid.setFilterValue(holder);
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder)

Example 14 with FilterValueHolder

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

the class OrderTimePredictionHooks method setCriteriaModifierParameters.

private void setCriteriaModifierParameters(ViewDefinitionState view) {
    LookupComponent techComponent = (LookupComponent) view.getComponentByReference("technology");
    Entity tech = techComponent.getEntity();
    GridComponent grid = (GridComponent) view.getComponentByReference("operCompTimeCalculationsGrid");
    FilterValueHolder holder = grid.getFilterValue();
    if (Objects.nonNull(tech)) {
        holder.put(OperCompTimeCalculationsCM.TECHNOLOGY_PARAMETER, tech.getId());
        grid.setFilterValue(holder);
    } else {
        if (holder.has(OperCompTimeCalculationsCM.TECHNOLOGY_PARAMETER)) {
            holder.remove(OperCompTimeCalculationsCM.TECHNOLOGY_PARAMETER);
            grid.setFilterValue(holder);
        }
    }
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent) GridComponent(com.qcadoo.view.api.components.GridComponent)

Example 15 with FilterValueHolder

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

the class AllStoppagesFormHooks method onBeforeRender.

public final void onBeforeRender(final ViewDefinitionState view) throws JSONException {
    if (Objects.isNull(((FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM)).getEntityId())) {
        JSONObject context = view.getJsonContext();
        if (view.isViewAfterRedirect() && context.has(L_CONTEXT_KEY_PRODUCTION_TRACKING)) {
            Long productionTrackingId = context.getLong(L_CONTEXT_KEY_PRODUCTION_TRACKING);
            Long orderId = context.getLong(L_CONTEXT_KEY_ORDER);
            LookupComponent orderLookupComponent = (LookupComponent) view.getComponentByReference(L_ORDER);
            orderLookupComponent.setFieldValue(orderId);
            orderLookupComponent.setEnabled(false);
            orderLookupComponent.requestComponentUpdateState();
            LookupComponent productionTrackingComponent = (LookupComponent) view.getComponentByReference(L_PRODUCTION_TRACKING);
            productionTrackingComponent.setFieldValue(productionTrackingId);
            productionTrackingComponent.setEnabled(false);
            productionTrackingComponent.requestComponentUpdateState();
        } else if (view.isViewAfterRedirect() && context.has(L_CONTEXT_KEY_ORDER)) {
            Long orderId = context.getLong(L_CONTEXT_KEY_ORDER);
            LookupComponent orderLookupComponent = (LookupComponent) view.getComponentByReference(L_ORDER);
            orderLookupComponent.setFieldValue(orderId);
            orderLookupComponent.setEnabled(false);
            orderLookupComponent.requestComponentUpdateState();
        }
    } else {
        LookupComponent orderLookupComponent = (LookupComponent) view.getComponentByReference(L_ORDER);
        LookupComponent productionTrackingComponent = (LookupComponent) view.getComponentByReference(L_PRODUCTION_TRACKING);
        JSONObject context = view.getJsonContext();
        if (Objects.nonNull(context) && context.has(L_CONTEXT_KEY_PRODUCTION_TRACKING)) {
            orderLookupComponent.setEnabled(false);
            productionTrackingComponent.setEnabled(false);
        }
        Entity order = orderLookupComponent.getEntity();
        if (order != null) {
            FilterValueHolder holder = productionTrackingComponent.getFilterValue();
            holder.put(StoppageFields.ORDER, order.getId());
            productionTrackingComponent.setFilterValue(holder);
        }
    }
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) Entity(com.qcadoo.model.api.Entity) JSONObject(org.json.JSONObject) LookupComponent(com.qcadoo.view.api.components.LookupComponent)

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