use of com.qcadoo.view.api.components.lookup.FilterValueHolder in project mes by qcadoo.
the class UseReplacementCriteriaModifiers method filter.
public void filter(final SearchCriteriaBuilder scb, final FilterValueHolder filterValue) {
if (filterValue.has("BASIC_PRODUCT_ID")) {
Entity basicProduct = dataDefinitionService.get(BasicConstants.PLUGIN_IDENTIFIER, BasicConstants.MODEL_PRODUCT).get(filterValue.getLong("BASIC_PRODUCT_ID"));
List<Entity> replacements = basicProduct.getHasManyField(ProductFields.SUBSTITUTE_COMPONENTS);
List<Long> ids = replacements.stream().filter(r -> Objects.nonNull(r.getBelongsToField(SubstituteComponentFields.PRODUCT))).map(r -> r.getBelongsToField(SubstituteComponentFields.PRODUCT).getId()).collect(Collectors.toList());
scb.add(SearchRestrictions.in("id", ids));
} else {
scb.add(SearchRestrictions.idEq(-1));
}
}
use of com.qcadoo.view.api.components.lookup.FilterValueHolder in project mes by qcadoo.
the class DivisionDetailsHooksPL method fillCriteriaModifiers.
public void fillCriteriaModifiers(final ViewDefinitionState viewDefinitionState) {
GridComponent workstations = (GridComponent) viewDefinitionState.getComponentByReference("workstations");
FormComponent form = (FormComponent) viewDefinitionState.getComponentByReference(QcadooViewConstants.L_FORM);
if (form.getEntityId() != null) {
FilterValueHolder filter = workstations.getFilterValue();
filter.put("division", form.getEntityId());
workstations.setFilterValue(filter);
}
workstations.reloadEntities();
}
use of com.qcadoo.view.api.components.lookup.FilterValueHolder in project mes by qcadoo.
the class OperationDurationDetailsInOrderHooks method setCriteriaModifierParameters.
private void setCriteriaModifierParameters(ViewDefinitionState view) {
FormComponent orderForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Long orderId = orderForm.getEntityId();
GridComponent grid = (GridComponent) view.getComponentByReference("operCompTimeCalculationsGrid");
FilterValueHolder holder = grid.getFilterValue();
holder.put(OperCompTimeCalculationsCM.ORDER_PARAMETER, orderId);
grid.setFilterValue(holder);
}
use of com.qcadoo.view.api.components.lookup.FilterValueHolder in project mes by qcadoo.
the class OrderTimePredictionHooks method setCriteriaModifierParameters.
private void setCriteriaModifierParameters(ViewDefinitionState view) {
LookupComponent techComponent = (LookupComponent) view.getComponentByReference("technology");
Entity tech = techComponent.getEntity();
GridComponent grid = (GridComponent) view.getComponentByReference("operCompTimeCalculationsGrid");
FilterValueHolder holder = grid.getFilterValue();
if (Objects.nonNull(tech)) {
holder.put(OperCompTimeCalculationsCM.TECHNOLOGY_PARAMETER, tech.getId());
grid.setFilterValue(holder);
} else {
if (holder.has(OperCompTimeCalculationsCM.TECHNOLOGY_PARAMETER)) {
holder.remove(OperCompTimeCalculationsCM.TECHNOLOGY_PARAMETER);
grid.setFilterValue(holder);
}
}
}
use of com.qcadoo.view.api.components.lookup.FilterValueHolder in project mes by qcadoo.
the class AllStoppagesFormHooks method onBeforeRender.
public final void onBeforeRender(final ViewDefinitionState view) throws JSONException {
if (Objects.isNull(((FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM)).getEntityId())) {
JSONObject context = view.getJsonContext();
if (view.isViewAfterRedirect() && context.has(L_CONTEXT_KEY_PRODUCTION_TRACKING)) {
Long productionTrackingId = context.getLong(L_CONTEXT_KEY_PRODUCTION_TRACKING);
Long orderId = context.getLong(L_CONTEXT_KEY_ORDER);
LookupComponent orderLookupComponent = (LookupComponent) view.getComponentByReference(L_ORDER);
orderLookupComponent.setFieldValue(orderId);
orderLookupComponent.setEnabled(false);
orderLookupComponent.requestComponentUpdateState();
LookupComponent productionTrackingComponent = (LookupComponent) view.getComponentByReference(L_PRODUCTION_TRACKING);
productionTrackingComponent.setFieldValue(productionTrackingId);
productionTrackingComponent.setEnabled(false);
productionTrackingComponent.requestComponentUpdateState();
} else if (view.isViewAfterRedirect() && context.has(L_CONTEXT_KEY_ORDER)) {
Long orderId = context.getLong(L_CONTEXT_KEY_ORDER);
LookupComponent orderLookupComponent = (LookupComponent) view.getComponentByReference(L_ORDER);
orderLookupComponent.setFieldValue(orderId);
orderLookupComponent.setEnabled(false);
orderLookupComponent.requestComponentUpdateState();
}
} else {
LookupComponent orderLookupComponent = (LookupComponent) view.getComponentByReference(L_ORDER);
LookupComponent productionTrackingComponent = (LookupComponent) view.getComponentByReference(L_PRODUCTION_TRACKING);
JSONObject context = view.getJsonContext();
if (Objects.nonNull(context) && context.has(L_CONTEXT_KEY_PRODUCTION_TRACKING)) {
orderLookupComponent.setEnabled(false);
productionTrackingComponent.setEnabled(false);
}
Entity order = orderLookupComponent.getEntity();
if (order != null) {
FilterValueHolder holder = productionTrackingComponent.getFilterValue();
holder.put(StoppageFields.ORDER, order.getId());
productionTrackingComponent.setFilterValue(holder);
}
}
}
Aggregations