use of com.qcadoo.view.api.components.lookup.FilterValueHolder in project mes by qcadoo.
the class ProductionCountingReplacementHooks method fillFields.
private void fillFields(ViewDefinitionState view) {
if (view.isViewAfterRedirect()) {
JSONObject context = view.getJsonContext();
LookupComponent basicProductComponent = (LookupComponent) view.getComponentByReference(BASIC_PRODUCT);
LookupComponent productComponent = (LookupComponent) view.getComponentByReference(PRODUCT);
if (context.has(L_WINDOW_MAIN_TAB_FORM_BASIC_PRODUCT)) {
try {
basicProductComponent.setFieldValue(context.getLong(L_WINDOW_MAIN_TAB_FORM_BASIC_PRODUCT));
FilterValueHolder filterValueHolder = productComponent.getFilterValue();
filterValueHolder.put("BASIC_PRODUCT_ID", context.getLong(L_WINDOW_MAIN_TAB_FORM_BASIC_PRODUCT));
productComponent.setFilterValue(filterValueHolder);
} catch (JSONException ex) {
throw new RuntimeException(ex);
}
}
}
}
use of com.qcadoo.view.api.components.lookup.FilterValueHolder in project mes by qcadoo.
the class StaffService method setFilters.
private void setFilters(final ViewDefinitionState view) {
LookupComponent division = (LookupComponent) view.getComponentByReference(StaffFields.DIVISION);
LookupComponent workstation = (LookupComponent) view.getComponentByReference(StaffFields.WORKSTATION);
LookupComponent productionLine = (LookupComponent) view.getComponentByReference(StaffFields.PRODUCTION_LINE);
Entity divisionEntity = division.getEntity();
Entity productionLineEntity = productionLine.getEntity();
FilterValueHolder productionLineFilterValueHolder = productionLine.getFilterValue();
if (Objects.nonNull(division.getEntity())) {
productionLineFilterValueHolder.put(DIVISION_ID, divisionEntity.getId());
} else {
if (productionLineFilterValueHolder.has(DIVISION_ID)) {
productionLineFilterValueHolder.remove(DIVISION_ID);
}
}
productionLine.setFilterValue(productionLineFilterValueHolder);
FilterValueHolder workstationFilterValueHolder = workstation.getFilterValue();
if (Objects.nonNull(division.getEntity())) {
workstationFilterValueHolder.put(DIVISION_ID, divisionEntity.getId());
} else {
if (workstationFilterValueHolder.has(DIVISION_ID)) {
workstationFilterValueHolder.remove(DIVISION_ID);
}
}
if (Objects.nonNull(productionLineEntity)) {
workstationFilterValueHolder.put(L_PRODUCTION_LINE_ID, productionLineEntity.getId());
} else {
if (workstationFilterValueHolder.has(L_PRODUCTION_LINE_ID)) {
workstationFilterValueHolder.remove(L_PRODUCTION_LINE_ID);
}
}
workstation.setFilterValue(workstationFilterValueHolder);
}
use of com.qcadoo.view.api.components.lookup.FilterValueHolder in project mes by qcadoo.
the class ProductFamilySizesHooks method onBeforeRender.
public void onBeforeRender(final ViewDefinitionState view) throws JSONException {
JSONObject obj = view.getJsonContext();
if (obj.has("window.mainTab.product.id")) {
GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
FilterValueHolder holder = grid.getFilterValue();
holder.put(ProductFamilySizesCriteriaModifiers.L_PRODUCT_ID, obj.getLong("window.mainTab.product.id"));
grid.setFilterValue(holder);
}
}
use of com.qcadoo.view.api.components.lookup.FilterValueHolder in project mes by qcadoo.
the class ProductHooks method setCriteriaModifierParameters.
public void setCriteriaModifierParameters(final ViewDefinitionState view) {
LookupComponent parentLookup = (LookupComponent) view.getComponentByReference(ProductFields.PARENT);
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity product = form.getPersistedEntityWithIncludedFormValues();
FilterValueHolder holder = parentLookup.getFilterValue();
holder.put(ProductFields.MACHINE_PART, product.getBooleanField(ProductFields.MACHINE_PART));
parentLookup.setFilterValue(holder);
}
use of com.qcadoo.view.api.components.lookup.FilterValueHolder in project mes by qcadoo.
the class ProductSubstituteComponentDetailsHooks method fillFilterValues.
public void fillFilterValues(final ViewDefinitionState view) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity substituteComponent = form.getPersistedEntityWithIncludedFormValues();
Entity product = substituteComponent.getBelongsToField(SubstituteComponentFields.BASE_PRODUCT);
if (product != null) {
LookupComponent productLookup = (LookupComponent) view.getComponentByReference(SubstituteComponentFields.PRODUCT);
FilterValueHolder filter = productLookup.getFilterValue();
filter.put(SubstituteComponentFields.PRODUCT, product.getId());
productLookup.setFilterValue(filter);
}
}
Aggregations