use of com.qcadoo.view.api.components.lookup.FilterValueHolder in project mes by qcadoo.
the class PalletStorageStateCriteriaModifier 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 ResourceCorrectionsCriteriaModifier 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 GenerateMaterialRequirementDetailsHooksMRCFO method setCriteriaModifierParameters.
private void setCriteriaModifierParameters(final ViewDefinitionState view) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity mRCForOrder = form.getEntity();
Entity order = mRCForOrder.getBelongsToField("order");
GridComponent gridProductsComponent = (GridComponent) view.getComponentByReference("coverageProducts");
FilterValueHolder gridProductsComponentHolder = gridProductsComponent.getFilterValue();
if (order != null) {
gridProductsComponentHolder.put(MRCCriteriaModifiersMRCFOOverideAspect.ORDER_PARAMETER, order.getId());
}
gridProductsComponent.setFilterValue(gridProductsComponentHolder);
}
use of com.qcadoo.view.api.components.lookup.FilterValueHolder in project mes by qcadoo.
the class OrdersForSubproductsHooks method setCriteriaModifierParameters.
private void setCriteriaModifierParameters(final ViewDefinitionState view) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
GridComponent gridOrders = (GridComponent) view.getComponentByReference(L_ORDERS);
GridComponent gridGeneratedOrders = (GridComponent) view.getComponentByReference(L_GENERATEAD_ORDERS);
FilterValueHolder gridGeneratedOrdersHolder = gridGeneratedOrders.getFilterValue();
FilterValueHolder gridOrdersHolder = gridOrders.getFilterValue();
List<Long> ids = Lists.newArrayList();
Entity entity = form.getEntity();
entity = entity.getDataDefinition().get(entity.getId());
if (Objects.nonNull(entity.getBelongsToField("ordersGroup"))) {
ids = entity.getBelongsToField("ordersGroup").getHasManyField("orders").stream().map(e -> e.getId()).collect(Collectors.toList());
} else if (Objects.nonNull(entity.getBelongsToField("order"))) {
ids.add(entity.getBelongsToField("order").getId());
}
String list = Joiner.on(",").join(ids);
gridGeneratedOrdersHolder.put(OrdersForSPCriteriaModifiers.ORDERS_PARAMETER, list);
gridGeneratedOrders.setFilterValue(gridGeneratedOrdersHolder);
gridOrdersHolder.put(OrdersForSPCriteriaModifiers.ORDERS_PARAMETER, list);
gridOrders.setFilterValue(gridOrdersHolder);
}
use of com.qcadoo.view.api.components.lookup.FilterValueHolder in project mes by qcadoo.
the class CoverageProductLoggingDetailsHooks method updateCriteriaModifiersState.
public void updateCriteriaModifiersState(final ViewDefinitionState view) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
LookupComponent companyLookup = (LookupComponent) view.getComponentByReference("company");
FilterValueHolder filterValueHolder = companyLookup.getFilterValue();
filterValueHolder.put(CoverageProductGeneratedFields.PRODUCT_ID, form.getPersistedEntityWithIncludedFormValues().getBelongsToField(CoverageProductFields.PRODUCT).getId());
companyLookup.setFilterValue(filterValueHolder);
}
Aggregations