Search in sources :

Example 66 with FilterValueHolder

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

the class ProductionCountingReplacementHooks method fillFields.

private void fillFields(ViewDefinitionState view) {
    if (view.isViewAfterRedirect()) {
        JSONObject context = view.getJsonContext();
        LookupComponent basicProductComponent = (LookupComponent) view.getComponentByReference(BASIC_PRODUCT);
        LookupComponent productComponent = (LookupComponent) view.getComponentByReference(PRODUCT);
        if (context.has(L_WINDOW_MAIN_TAB_FORM_BASIC_PRODUCT)) {
            try {
                basicProductComponent.setFieldValue(context.getLong(L_WINDOW_MAIN_TAB_FORM_BASIC_PRODUCT));
                FilterValueHolder filterValueHolder = productComponent.getFilterValue();
                filterValueHolder.put("BASIC_PRODUCT_ID", context.getLong(L_WINDOW_MAIN_TAB_FORM_BASIC_PRODUCT));
                productComponent.setFilterValue(filterValueHolder);
            } catch (JSONException ex) {
                throw new RuntimeException(ex);
            }
        }
    }
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) JSONObject(org.json.JSONObject) LookupComponent(com.qcadoo.view.api.components.LookupComponent) JSONException(org.json.JSONException)

Example 67 with FilterValueHolder

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

the class StaffService method setFilters.

private void setFilters(final ViewDefinitionState view) {
    LookupComponent division = (LookupComponent) view.getComponentByReference(StaffFields.DIVISION);
    LookupComponent workstation = (LookupComponent) view.getComponentByReference(StaffFields.WORKSTATION);
    LookupComponent productionLine = (LookupComponent) view.getComponentByReference(StaffFields.PRODUCTION_LINE);
    Entity divisionEntity = division.getEntity();
    Entity productionLineEntity = productionLine.getEntity();
    FilterValueHolder productionLineFilterValueHolder = productionLine.getFilterValue();
    if (Objects.nonNull(division.getEntity())) {
        productionLineFilterValueHolder.put(DIVISION_ID, divisionEntity.getId());
    } else {
        if (productionLineFilterValueHolder.has(DIVISION_ID)) {
            productionLineFilterValueHolder.remove(DIVISION_ID);
        }
    }
    productionLine.setFilterValue(productionLineFilterValueHolder);
    FilterValueHolder workstationFilterValueHolder = workstation.getFilterValue();
    if (Objects.nonNull(division.getEntity())) {
        workstationFilterValueHolder.put(DIVISION_ID, divisionEntity.getId());
    } else {
        if (workstationFilterValueHolder.has(DIVISION_ID)) {
            workstationFilterValueHolder.remove(DIVISION_ID);
        }
    }
    if (Objects.nonNull(productionLineEntity)) {
        workstationFilterValueHolder.put(L_PRODUCTION_LINE_ID, productionLineEntity.getId());
    } else {
        if (workstationFilterValueHolder.has(L_PRODUCTION_LINE_ID)) {
            workstationFilterValueHolder.remove(L_PRODUCTION_LINE_ID);
        }
    }
    workstation.setFilterValue(workstationFilterValueHolder);
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent)

Example 68 with FilterValueHolder

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

the class ProductFamilySizesHooks method onBeforeRender.

public void onBeforeRender(final ViewDefinitionState view) throws JSONException {
    JSONObject obj = view.getJsonContext();
    if (obj.has("window.mainTab.product.id")) {
        GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
        FilterValueHolder holder = grid.getFilterValue();
        holder.put(ProductFamilySizesCriteriaModifiers.L_PRODUCT_ID, obj.getLong("window.mainTab.product.id"));
        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 69 with FilterValueHolder

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

the class ProductHooks method setCriteriaModifierParameters.

public void setCriteriaModifierParameters(final ViewDefinitionState view) {
    LookupComponent parentLookup = (LookupComponent) view.getComponentByReference(ProductFields.PARENT);
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity product = form.getPersistedEntityWithIncludedFormValues();
    FilterValueHolder holder = parentLookup.getFilterValue();
    holder.put(ProductFields.MACHINE_PART, product.getBooleanField(ProductFields.MACHINE_PART));
    parentLookup.setFilterValue(holder);
}
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 70 with FilterValueHolder

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

the class ProductSubstituteComponentDetailsHooks method fillFilterValues.

public void fillFilterValues(final ViewDefinitionState view) {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity substituteComponent = form.getPersistedEntityWithIncludedFormValues();
    Entity product = substituteComponent.getBelongsToField(SubstituteComponentFields.BASE_PRODUCT);
    if (product != null) {
        LookupComponent productLookup = (LookupComponent) view.getComponentByReference(SubstituteComponentFields.PRODUCT);
        FilterValueHolder filter = productLookup.getFilterValue();
        filter.put(SubstituteComponentFields.PRODUCT, product.getId());
        productLookup.setFilterValue(filter);
    }
}
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)

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