Search in sources :

Example 21 with FilterValueHolder

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

the class ProductionCountingAttributeValueDetailsHooks method setFilters.

private void setFilters(ViewDefinitionState view) {
    LookupComponent attributeLookup = (LookupComponent) view.getComponentByReference(ProductionCountingAttributeValueFields.ATTRIBUTE);
    LookupComponent attributeValueLookup = (LookupComponent) view.getComponentByReference(ProductionCountingAttributeValueFields.ATTRIBUTE_VALUE);
    FilterValueHolder attributeValueLookupFilters = attributeValueLookup.getFilterValue();
    if (Objects.nonNull(attributeLookup.getEntity())) {
        attributeValueLookupFilters.put(L_ATTRIBUTE_ID, attributeLookup.getEntity().getId());
    } else if (attributeValueLookupFilters.has(L_ATTRIBUTE_ID)) {
        attributeValueLookupFilters.remove(L_ATTRIBUTE_ID);
    }
    attributeValueLookup.setFilterValue(attributeValueLookupFilters);
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) LookupComponent(com.qcadoo.view.api.components.LookupComponent)

Example 22 with FilterValueHolder

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

the class ProductionCountingQuantityAdvancedDetailsHooks method setCriteriaModifierParameters.

private void setCriteriaModifierParameters(final ViewDefinitionState view) {
    FormComponent productionCountingQuantityForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    LookupComponent technologyOperationComponentLookup = (LookupComponent) view.getComponentByReference(ProductionCountingQuantityFields.TECHNOLOGY_OPERATION_COMPONENT);
    Entity productionCountingQuantity = productionCountingQuantityForm.getEntity();
    Entity order = productionCountingQuantity.getBelongsToField(ProductionCountingQuantityFields.ORDER);
    Entity basicProductionCounting = productionCountingQuantity.getBelongsToField(ProductionCountingQuantityFields.BASIC_PRODUCTION_COUNTING);
    if (order != null) {
        Entity technology = order.getBelongsToField(OrderFields.TECHNOLOGY);
        if (technology != null) {
            FilterValueHolder filterValueHolder = technologyOperationComponentLookup.getFilterValue();
            filterValueHolder.put(OrderFields.TECHNOLOGY, technology.getId());
            technologyOperationComponentLookup.setFilterValue(filterValueHolder);
            return;
        }
    }
    if (basicProductionCounting != null) {
        Entity basicProductionCountingOrder = basicProductionCounting.getBelongsToField(BasicProductionCountingFields.ORDER);
        if (basicProductionCountingOrder != null) {
            Entity technology = basicProductionCountingOrder.getBelongsToField(OrderFields.TECHNOLOGY);
            if (technology != null) {
                FilterValueHolder filterValueHolder = technologyOperationComponentLookup.getFilterValue();
                filterValueHolder.put(OrderFields.TECHNOLOGY, technology.getId());
                technologyOperationComponentLookup.setFilterValue(filterValueHolder);
            }
        }
    }
}
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)

Example 23 with FilterValueHolder

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

the class ProductDetailsHooks method setCriteriaModifierParameters.

private void setCriteriaModifierParameters(final ViewDefinitionState view) {
    LookupComponent assortmentLookup = (LookupComponent) view.getComponentByReference(ProductFields.ASSORTMENT);
    LookupComponent modelLookup = (LookupComponent) view.getComponentByReference(ProductFields.MODEL);
    Entity assortment = assortmentLookup.getEntity();
    FilterValueHolder filterValueHolder = modelLookup.getFilterValue();
    if (Objects.isNull(assortment)) {
        if (filterValueHolder.has(ModelCriteriaModifiers.L_ASSORTMENT_ID)) {
            filterValueHolder.remove(ModelCriteriaModifiers.L_ASSORTMENT_ID);
        }
    } else {
        filterValueHolder.put(ModelCriteriaModifiers.L_ASSORTMENT_ID, assortment.getId());
    }
    modelLookup.setFilterValue(filterValueHolder);
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent)

Example 24 with FilterValueHolder

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

the class ProductFamilySizesHooks method addOnBeforeRender.

public void addOnBeforeRender(final ViewDefinitionState view) throws JSONException {
    JSONObject obj = view.getJsonContext();
    if (obj.has("window.mainTab.product.productId")) {
        GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
        FilterValueHolder holder = grid.getFilterValue();
        holder.put(ProductFamilySizesCriteriaModifiers.L_PRODUCT_ID, obj.getLong("window.mainTab.product.productId"));
        grid.setFilterValue(holder);
    }
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) JSONObject(org.json.JSONObject) GridComponent(com.qcadoo.view.api.components.GridComponent)

Example 25 with FilterValueHolder

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

the class ProductReplacementsHooks method onBeforeRender.

public void onBeforeRender(final ViewDefinitionState view) throws JSONException {
    JSONObject obj = view.getJsonContext();
    if (obj.has("window.mainTab.product.productId")) {
        GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
        FilterValueHolder holder = grid.getFilterValue();
        holder.put("PRODUCT_ID", obj.getLong("window.mainTab.product.productId"));
        grid.setFilterValue(holder);
    }
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) JSONObject(org.json.JSONObject) GridComponent(com.qcadoo.view.api.components.GridComponent)

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