use of com.qcadoo.view.api.components.lookup.FilterValueHolder in project mes by qcadoo.
the class PalletMoveToStorageLocationHelperHooks method setStorageLocationFilters.
@Override
protected void setStorageLocationFilters(final ViewDefinitionState view) {
DataDefinition locationDD = dataDefinitionService.get(MaterialFlowConstants.PLUGIN_IDENTIFIER, MaterialFlowConstants.MODEL_LOCATION);
AwesomeDynamicListComponent adl = (AwesomeDynamicListComponent) view.getComponentByReference("palletStorageStateDtos");
for (FormComponent form : adl.getFormComponents()) {
LookupComponent newStorageLocation = (LookupComponent) form.findFieldComponentByName("newStorageLocation");
FilterValueHolder filter = newStorageLocation.getFilterValue();
Entity dto = form.getPersistedEntityWithIncludedFormValues();
String locationNumber = dto.getStringField("locationNumber");
Entity location = locationDD.find().add(SearchRestrictions.eq(LocationFields.NUMBER, locationNumber)).setMaxResults(1).uniqueResult();
filter.put(StorageLocationFields.LOCATION, location.getId());
newStorageLocation.setFilterValue(filter);
}
}
use of com.qcadoo.view.api.components.lookup.FilterValueHolder in project mes by qcadoo.
the class StocktakingDetailsHooks method setCriteriaModifierParameters.
private void setCriteriaModifierParameters(final ViewDefinitionState view, final Entity stocktaking) {
LookupComponent storageLocationLookup = (LookupComponent) view.getComponentByReference("storageLocationLookup");
Entity location = stocktaking.getBelongsToField(StocktakingFields.LOCATION);
FilterValueHolder filterValueHolder = storageLocationLookup.getFilterValue();
if (location != null) {
filterValueHolder.put(StocktakingFields.LOCATION, location.getId());
} else {
filterValueHolder.put(StocktakingFields.LOCATION, 0L);
}
storageLocationLookup.setFilterValue(filterValueHolder);
}
use of com.qcadoo.view.api.components.lookup.FilterValueHolder in project mes by qcadoo.
the class CostNormsGeneratorHooks method onBeforeRender.
public void onBeforeRender(final ViewDefinitionState view) {
FormComponent costNormsGeneratorForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
LookupComponent productLookup = (LookupComponent) view.getComponentByReference("productsLookup");
Entity costNormsGenerator = costNormsGeneratorForm.getEntity();
String costsSource = costNormsGenerator.getStringField(CostNormsGeneratorFields.COSTS_SOURCE);
FilterValueHolder filterValueHolder = productLookup.getFilterValue();
filterValueHolder.put("costsSource", costsSource);
productLookup.setFilterValue(filterValueHolder);
}
use of com.qcadoo.view.api.components.lookup.FilterValueHolder in project mes by qcadoo.
the class StorageLocationsStateCriteriaModifier 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 WarehouseStocksCriteriaModifier 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));
}
}
}
Aggregations