use of com.qcadoo.view.api.components.lookup.FilterValueHolder in project mes by qcadoo.
the class OperationalTaskDetailsListeners method onDivisionChange.
public void onDivisionChange(final ViewDefinitionState view, final ComponentState state, final String[] args) {
LookupComponent workstationLookup = (LookupComponent) view.getComponentByReference(OperationalTaskFields.WORKSTATION);
FilterValueHolder filterValueHolder = workstationLookup.getFilterValue();
if (filterValueHolder.has(OperationalTaskFields.DIVISION)) {
filterValueHolder.remove(OperationalTaskFields.DIVISION);
workstationLookup.setFilterValue(filterValueHolder);
}
workstationLookup.setFieldValue(null);
workstationLookup.requestComponentUpdateState();
}
use of com.qcadoo.view.api.components.lookup.FilterValueHolder in project mes by qcadoo.
the class OrderDetailsListeners method changeOrderProduct.
public void changeOrderProduct(final ViewDefinitionState view, final ComponentState state, final String[] args) {
LookupComponent productLookup = (LookupComponent) view.getComponentByReference(OrderFields.PRODUCT);
LookupComponent technologyLookup = (LookupComponent) view.getComponentByReference(OrderFields.TECHNOLOGY_PROTOTYPE);
FieldComponent defaultTechnologyField = (FieldComponent) view.getComponentByReference(OrderFields.DEFAULT_TECHNOLOGY);
Entity product = productLookup.getEntity();
defaultTechnologyField.setFieldValue(null);
technologyLookup.setFieldValue(null);
if (Objects.nonNull(product)) {
FilterValueHolder holder = technologyLookup.getFilterValue();
holder.put(TechnologyCriteriaModifiersO.PRODUCT_PARAMETER, product.getId());
technologyLookup.setFilterValue(holder);
Entity defaultTechnologyEntity = technologyServiceO.getDefaultTechnology(product);
if (Objects.nonNull(defaultTechnologyEntity)) {
String defaultTechnologyValue = expressionService.getValue(defaultTechnologyEntity, "#number + ' - ' + #name", view.getLocale());
defaultTechnologyField.setFieldValue(defaultTechnologyValue);
technologyLookup.setFieldValue(defaultTechnologyEntity.getId());
}
}
}
use of com.qcadoo.view.api.components.lookup.FilterValueHolder in project mes by qcadoo.
the class ProductionLineScheduleDetailsHooks method setOrderLookupCriteriaModifier.
private void setOrderLookupCriteriaModifier(final ViewDefinitionState view) {
FormComponent scheduleForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Long scheduleId = scheduleForm.getEntityId();
LookupComponent orderLookup = (LookupComponent) view.getComponentByReference(L_ORDERS_LOOKUP);
FilterValueHolder valueHolder = orderLookup.getFilterValue();
valueHolder.put(ProductionLineScheduleOrderCriteriaModifiers.SCHEDULE_PARAMETER, scheduleId);
orderLookup.setFilterValue(valueHolder);
}
use of com.qcadoo.view.api.components.lookup.FilterValueHolder in project mes by qcadoo.
the class ModelCardProductDetailsHooks method onBeforeRender.
public void onBeforeRender(final ViewDefinitionState view) {
LookupComponent productLookup = (LookupComponent) view.getComponentByReference(ModelCardProductFields.PRODUCT);
FilterValueHolder filterValueHolder = productLookup.getFilterValue();
Entity product = productLookup.getEntity();
String unit = "";
if (product != null) {
unit = product.getStringField(ProductFields.UNIT);
LookupComponent technologyLookup = (LookupComponent) view.getComponentByReference(ModelCardProductFields.TECHNOLOGY);
FilterValueHolder technologyFilterValueHolder = technologyLookup.getFilterValue();
technologyFilterValueHolder.put(TechnologyCriteriaModifiersO.PRODUCT_PARAMETER, product.getId());
technologyLookup.setFilterValue(technologyFilterValueHolder);
}
FieldComponent quantityUnit = (FieldComponent) view.getComponentByReference(L_QUANTITY_UNIT);
quantityUnit.setFieldValue(unit);
quantityUnit.requestComponentUpdateState();
Entity modelCardProduct = ((FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM)).getEntity();
Long modelCardId = modelCardProduct.getBelongsToField(ModelCardProductFields.MODEL_CARD).getId();
filterValueHolder.put(ProductCriteriaModifiersPFTD.L_MODEL_CARD_ID, modelCardId);
Entity productFromDb = modelCardProduct.getBelongsToField(ModelCardProductFields.PRODUCT);
if (productFromDb != null) {
filterValueHolder.put(ProductCriteriaModifiersPFTD.L_PRODUCT_ID, productFromDb.getId());
}
productLookup.setFilterValue(filterValueHolder);
}
use of com.qcadoo.view.api.components.lookup.FilterValueHolder in project mes by qcadoo.
the class OrderDetailsHooksPFTD method onBeforeRender.
public void onBeforeRender(final ViewDefinitionState view) {
orderDetailsRibbonHelper.setButtonEnabled(view, "materialFlow", "warehouseIssues", OrderDetailsRibbonHelper.HAS_CHECKED_OR_ACCEPTED_TECHNOLOGY::test);
orderDetailsRibbonHelper.setButtonEnabled(view, "materialFlow", "componentAvailability", OrderDetailsRibbonHelper.HAS_CHECKED_OR_ACCEPTED_TECHNOLOGY::test);
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
ComponentState staffTab = view.getComponentByReference("staffTab");
if (form.getEntityId() != null) {
Entity order = dataDefinitionService.get(OrdersConstants.PLUGIN_IDENTIFIER, OrdersConstants.MODEL_ORDER).get(form.getEntityId());
staffTab.setVisible(TypeOfProductionRecording.CUMULATED.getStringValue().equals(order.getStringField(OrderFieldsPC.TYPE_OF_PRODUCTION_RECORDING)));
LookupComponent technologyLookup = (LookupComponent) view.getComponentByReference(OrderFields.TECHNOLOGY_PROTOTYPE);
LookupComponent productionLineLookup = (LookupComponent) view.getComponentByReference(OrderFields.PRODUCTION_LINE);
Entity technology = technologyLookup.getEntity();
Entity productionLine = productionLineLookup.getEntity();
if (technology != null && productionLine != null) {
FieldComponent plannedStaffField = (FieldComponent) view.getComponentByReference("plannedStaff");
Optional<Integer> plannedStaff = technologyService.getPlannedStaff(technology, productionLine);
if (plannedStaff.isPresent()) {
plannedStaffField.setFieldValue(plannedStaff.get());
} else {
plannedStaffField.setFieldValue(null);
}
}
FieldComponent actualStaff = (FieldComponent) view.getComponentByReference("actualStaff");
actualStaff.setFieldValue(order.getManyToManyField(OrderFields.STAFF).size());
LookupComponent staffLookup = (LookupComponent) view.getComponentByReference("staffLookup");
FilterValueHolder valueHolder = staffLookup.getFilterValue();
valueHolder.put(StaffCriteriaModifierPFTD.L_ORDER_ID, form.getEntityId());
if (productionLine != null) {
valueHolder.put(StaffCriteriaModifierPFTD.L_PRODUCTION_LINE_ID, productionLine.getId());
} else if (valueHolder.has(StaffCriteriaModifierPFTD.L_PRODUCTION_LINE_ID)) {
valueHolder.remove(StaffCriteriaModifierPFTD.L_PRODUCTION_LINE_ID);
}
staffLookup.setFilterValue(valueHolder);
} else {
staffTab.setVisible(false);
}
}
Aggregations