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));
}
}
}
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);
}
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);
}
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);
}
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);
}
Aggregations