use of com.qcadoo.view.api.components.lookup.FilterValueHolder in project mes by qcadoo.
the class WorkPlanDetailsHooks method setCriteriaModifierParameters.
private void setCriteriaModifierParameters(final ViewDefinitionState view) {
// set technologies id
FormComponent workPlanForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
if (workPlanForm.getEntityId() == null) {
return;
}
List<Long> technologyIDs = Lists.newArrayList();
List<Entity> orders = workPlanForm.getPersistedEntityWithIncludedFormValues().getManyToManyField(WorkPlanFields.ORDERS);
if (orders.isEmpty()) {
return;
}
for (Entity order : orders) {
if (order.isActive() && order.getBelongsToField(OrderFields.TECHNOLOGY_PROTOTYPE) != null) {
technologyIDs.add(order.getBelongsToField(OrderFields.TECHNOLOGY_PROTOTYPE).getId());
}
}
GridComponent atachmentsGrid = (GridComponent) view.getComponentByReference(L_ATTCHMENT_GRID);
FilterValueHolder atachmentsGridHolder = atachmentsGrid.getFilterValue();
atachmentsGridHolder.put(WorkPlansCriteriaModifiers.TECHNOLOGY_IDS, technologyIDs);
atachmentsGrid.setFilterValue(atachmentsGridHolder);
}
use of com.qcadoo.view.api.components.lookup.FilterValueHolder in project mes by qcadoo.
the class SalesPlanFillTechnologyHooks method onBeforeRender.
public void onBeforeRender(final ViewDefinitionState view) throws JSONException {
String productFamilyId = view.getJsonContext().get("window.mainTab.salesPlanProduct.gridLayout.productFamilyId").toString();
Entity productFamily = dataDefinitionService.get(BasicConstants.PLUGIN_IDENTIFIER, BasicConstants.MODEL_PRODUCT).get(Long.parseLong(productFamilyId));
FieldComponent productFamilyField = (FieldComponent) view.getComponentByReference("productFamily");
productFamilyField.setFieldValue(productFamily.getStringField(ProductFields.NUMBER));
LookupComponent technologyLookup = (LookupComponent) view.getComponentByReference(SalesPlanProductFields.TECHNOLOGY);
FilterValueHolder technologyFilterValueHolder = technologyLookup.getFilterValue();
technologyFilterValueHolder.put(TechnologyCriteriaModifiersO.PRODUCT_PARAMETER, productFamily.getId());
technologyLookup.setFilterValue(technologyFilterValueHolder);
technologyLookup.setRequired(true);
}
use of com.qcadoo.view.api.components.lookup.FilterValueHolder in project mes by qcadoo.
the class SalesPlanProductDetailsHooks method onBeforeRender.
public void onBeforeRender(final ViewDefinitionState view) {
List<String> referenceNames = Lists.newArrayList(L_PLANNED_QUANTITY_UNIT, L_ORDERED_QUANTITY_UNIT, ORDERED_TO_WAREHOUSE_UNIT, L_SURPLUS_FROM_PLAN_UNIT);
LookupComponent productLookup = (LookupComponent) view.getComponentByReference(SalesPlanProductFields.PRODUCT);
FilterValueHolder filterValueHolder = productLookup.getFilterValue();
Entity product = productLookup.getEntity();
String unit = "";
if (product != null) {
unit = product.getStringField(ProductFields.UNIT);
LookupComponent technologyLookup = (LookupComponent) view.getComponentByReference(SalesPlanProductFields.TECHNOLOGY);
FilterValueHolder technologyFilterValueHolder = technologyLookup.getFilterValue();
technologyFilterValueHolder.put(TechnologyCriteriaModifiersO.PRODUCT_PARAMETER, product.getId());
technologyLookup.setFilterValue(technologyFilterValueHolder);
}
for (String referenceName : referenceNames) {
FieldComponent field = (FieldComponent) view.getComponentByReference(referenceName);
field.setFieldValue(unit);
field.requestComponentUpdateState();
}
Entity salesPlanProduct = ((FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM)).getEntity();
Long salesPlanId = salesPlanProduct.getBelongsToField(SalesPlanProductFields.SALES_PLAN).getId();
filterValueHolder.put(ProductCriteriaModifiersMO.L_SALES_PLAN_ID, salesPlanId);
Entity productFromDb = salesPlanProduct.getBelongsToField(SalesPlanProductFields.PRODUCT);
if (productFromDb != null) {
filterValueHolder.put(ProductCriteriaModifiersMO.L_PRODUCT_ID, productFromDb.getId());
}
productLookup.setFilterValue(filterValueHolder);
}
use of com.qcadoo.view.api.components.lookup.FilterValueHolder in project mes by qcadoo.
the class WarehouseStockReportDetailsHooks method setCriteriaModifierParameters.
private void setCriteriaModifierParameters(final ViewDefinitionState view, final Entity warehouseStockReport) {
LookupComponent storageLocationLookup = (LookupComponent) view.getComponentByReference("storageLocationLookup");
Entity location = warehouseStockReport.getBelongsToField(WarehouseStockReportFields.LOCATION);
FilterValueHolder filterValueHolder = storageLocationLookup.getFilterValue();
if (location != null) {
filterValueHolder.put(WarehouseStockReportFields.LOCATION, location.getId());
} else {
filterValueHolder.put(WarehouseStockReportFields.LOCATION, 0L);
}
storageLocationLookup.setFilterValue(filterValueHolder);
}
use of com.qcadoo.view.api.components.lookup.FilterValueHolder in project mes by qcadoo.
the class ProductsToIssueCriteriaModifier 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.or(SearchRestrictions.in(LOCATION_TO_ID, locationIds), SearchRestrictions.in(LOCATION_FROM_ID, locationIds)));
}
}
}
Aggregations