Search in sources :

Example 81 with FilterValueHolder

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

the class ResourcesCriteriaModifier method restrictToUserLocations.

public void restrictToUserLocations(final SearchCriteriaBuilder scb, final FilterValueHolder filterValue) {
    Long currentUserId = securityService.getCurrentUserId();
    if (Objects.nonNull(currentUserId)) {
        EntityList userLocations = userDataDefinition().get(currentUserId).getHasManyField(UserFieldsMF.USER_LOCATIONS);
        if (!userLocations.isEmpty()) {
            Set<Integer> locationIds = userLocations.stream().map(ul -> ul.getBelongsToField(UserLocationFields.LOCATION)).mapToInt(e -> e.getId().intValue()).boxed().collect(Collectors.toSet());
            scb.add(SearchRestrictions.in(LOCATION_ID, locationIds));
        }
    }
}
Also used : DataDefinitionService(com.qcadoo.model.api.DataDefinitionService) SearchRestrictions(com.qcadoo.model.api.search.SearchRestrictions) QcadooSecurityConstants(com.qcadoo.security.constants.QcadooSecurityConstants) Set(java.util.Set) Autowired(org.springframework.beans.factory.annotation.Autowired) Collectors(java.util.stream.Collectors) DataDefinition(com.qcadoo.model.api.DataDefinition) EntityList(com.qcadoo.model.api.EntityList) Objects(java.util.Objects) FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) UserFieldsMF(com.qcadoo.mes.materialFlow.constants.UserFieldsMF) UserLocationFields(com.qcadoo.mes.materialFlow.constants.UserLocationFields) Service(org.springframework.stereotype.Service) SearchCriteriaBuilder(com.qcadoo.model.api.search.SearchCriteriaBuilder) SecurityService(com.qcadoo.security.api.SecurityService) EntityList(com.qcadoo.model.api.EntityList)

Example 82 with FilterValueHolder

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

the class OperationDurationInOrderDetailsHooksOFSPG method setCriteriaModifierParameters.

private void setCriteriaModifierParameters(final ViewDefinitionState view) {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Long orderId = form.getEntityId();
    if (orderId == null) {
        return;
    }
    GridComponent orderTimeCalculationsGrid = (GridComponent) view.getComponentByReference("orderTimeCalculationsGrid");
    FilterValueHolder gridHolder = orderTimeCalculationsGrid.getFilterValue();
    gridHolder.put(OrderTimeCalculationCM.PARENT_COMPONENTS_ORDER, orderId);
    orderTimeCalculationsGrid.setFilterValue(gridHolder);
}
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 83 with FilterValueHolder

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

the class GenerateMaterialRequirementCoverageHooks method updateMRCCriteriaModifiersState.

private void updateMRCCriteriaModifiersState(final ViewDefinitionState view) {
    FormComponent materialRequirementCoverageForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    if (materialRequirementCoverageForm.getEntityId() == null) {
        return;
    }
    GridComponent gridComponent = (GridComponent) view.getComponentByReference("coverageProducts");
    FilterValueHolder filterValueHolder = gridComponent.getFilterValue();
    filterValueHolder.put("coverageOrdersSelected", materialRequirementCoverageForm.getPersistedEntityWithIncludedFormValues().getHasManyField("coverageOrders").size() > 0);
    gridComponent.setFilterValue(filterValueHolder);
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder)

Example 84 with FilterValueHolder

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

the class MRCForOrderDetailsHooksOFSPG method setCriteriaModifierParameters.

private void setCriteriaModifierParameters(final ViewDefinitionState view) {
    FormComponent coverageForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity coverageEntity = coverageForm.getPersistedEntityWithIncludedFormValues();
    Entity order = coverageEntity.getBelongsToField(CoverageForOrderFields.ORDER);
    List<Entity> coverageOrders = coverageEntity.getHasManyField(MaterialRequirementCoverageFields.COVERAGE_ORDERS);
    GridComponent gridGeneratedOrders = (GridComponent) view.getComponentByReference(GENERATED_ORDERS_GRID);
    FilterValueHolder gridGeneratedOrdersHolder = gridGeneratedOrders.getFilterValue();
    if (order != null) {
        gridGeneratedOrdersHolder.put(CoverageForOrderCriteriaModifiersOFSPG.ORDER_PARAMETER, order.getId());
    } else if (!coverageOrders.isEmpty()) {
        String list = Joiner.on(",").join(getOrdersIds(coverageEntity));
        gridGeneratedOrdersHolder.put(CoverageForOrderCriteriaModifiersOFSPG.ORDERS_PARAMETER, list);
    }
    gridGeneratedOrders.setFilterValue(gridGeneratedOrdersHolder);
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) GridComponent(com.qcadoo.view.api.components.GridComponent)

Example 85 with FilterValueHolder

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

the class TechnologyDetailsHooksPFTD method setCriteriaModifierParameters.

private void setCriteriaModifierParameters(final ViewDefinitionState view) {
    FormComponent technologyForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Long technologyId = technologyForm.getEntityId();
    if (Objects.isNull(technologyId)) {
        return;
    }
    GridComponent rangeTechnologyOperationComponent = (GridComponent) view.getComponentByReference(RANGE_TECHNOLOGY_OPERATION_COMPONENT);
    FilterValueHolder rangeTechnologyOperationComponentFilterValueHolder = rangeTechnologyOperationComponent.getFilterValue();
    rangeTechnologyOperationComponentFilterValueHolder.put(TechnologyDetailsCriteriaModifiers.L_TECHNOLOGY_ID, technologyId);
    rangeTechnologyOperationComponent.setFilterValue(rangeTechnologyOperationComponentFilterValueHolder);
    FieldComponent rangeField = (FieldComponent) view.getComponentByReference(TechnologyFieldsPFTD.RANGE);
    String range = (String) rangeField.getFieldValue();
    Entity division = null;
    if (Range.ONE_DIVISION.getStringValue().equals(range)) {
        Entity techEntity = technologyForm.getPersistedEntityWithIncludedFormValues();
        division = techEntity.getBelongsToField(TechnologyFieldsPFTD.DIVISION);
    } else {
        GridComponent workstationsTechnologyOperationComponent = (GridComponent) view.getComponentByReference(WORKSTATIONS_TECHNOLOGY_OPERATION_COMPONENT);
        Set<Long> selectedEntitiesIds = workstationsTechnologyOperationComponent.getSelectedEntitiesIds();
        if (!selectedEntitiesIds.isEmpty()) {
            Entity toc = getTechnologyOperationComponentDD().get(selectedEntitiesIds.stream().findFirst().get());
            division = toc.getBelongsToField(TechnologyOperationComponentFields.DIVISION);
        }
    }
    LookupComponent workstationsForTOCLookupComponent = (LookupComponent) view.getComponentByReference(WORKSTATIONS_FOR_TOC_LOOKUP);
    FilterValueHolder workstationsForTOCLookupComponentHolder = workstationsForTOCLookupComponent.getFilterValue();
    if (Objects.nonNull(division)) {
        workstationsForTOCLookupComponentHolder.put(WorkstationFields.DIVISION, division.getId());
    } else if (workstationsForTOCLookupComponentHolder.has(WorkstationFields.DIVISION)) {
        workstationsForTOCLookupComponentHolder.remove(WorkstationFields.DIVISION);
    }
    workstationsForTOCLookupComponent.setFilterValue(workstationsForTOCLookupComponentHolder);
    GridComponent gridProductsComponent = (GridComponent) view.getComponentByReference(L_PRODUCTS_COMPONENT);
    GridComponent gridProductsIntermediateIn = (GridComponent) view.getComponentByReference(L_PRODUCTS_FLOW_INTERMEDIATE_IN);
    GridComponent gridProductsIntermediateOut = (GridComponent) view.getComponentByReference(L_PRODUCTS_FLOW_INTERMEDIATE_OUT);
    GridComponent gridProductsFinal = (GridComponent) view.getComponentByReference(L_PRODUCTS_FINAL);
    GridComponent gridProductsWaste = (GridComponent) view.getComponentByReference(L_PRODUCTS_FLOW_WASTE_RECEPTION_WAREHOUSE);
    FilterValueHolder gridProductsComponentInHolder = gridProductsComponent.getFilterValue();
    gridProductsComponentInHolder.put(ProductsFlowInCriteriaModifiers.TECHNOLOGY_PARAMETER, technologyId);
    gridProductsComponent.setFilterValue(gridProductsComponentInHolder);
    FilterValueHolder gridProductsIntermediateInHolder = gridProductsIntermediateIn.getFilterValue();
    gridProductsIntermediateInHolder.put(ProductsFlowInCriteriaModifiers.TECHNOLOGY_PARAMETER, technologyId);
    gridProductsIntermediateIn.setFilterValue(gridProductsIntermediateInHolder);
    FilterValueHolder gridProductsIntermediateOutHolder = gridProductsIntermediateOut.getFilterValue();
    gridProductsIntermediateOutHolder.put(ProductsFlowInCriteriaModifiers.TECHNOLOGY_PARAMETER, technologyId);
    gridProductsIntermediateOut.setFilterValue(gridProductsIntermediateOutHolder);
    FilterValueHolder gridProductsFinalOutHolder = gridProductsFinal.getFilterValue();
    gridProductsFinalOutHolder.put(ProductsFlowInCriteriaModifiers.TECHNOLOGY_PARAMETER, technologyId);
    gridProductsFinal.setFilterValue(gridProductsFinalOutHolder);
    FilterValueHolder gridProductsWasteOutHolder = gridProductsWaste.getFilterValue();
    gridProductsWasteOutHolder.put(ProductsFlowInCriteriaModifiers.TECHNOLOGY_PARAMETER, technologyId);
    gridProductsWaste.setFilterValue(gridProductsWasteOutHolder);
}
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) GridComponent(com.qcadoo.view.api.components.GridComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

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