use of com.qcadoo.view.api.ComponentState in project mes by qcadoo.
the class DeliveriesServiceImpl method getProductEntityByComponentName.
private Entity getProductEntityByComponentName(final ViewDefinitionState view, final String productName) {
ComponentState productComponentState = view.getComponentByReference(productName);
Entity product = null;
if (productComponentState instanceof LookupComponent) {
product = ((LookupComponent) productComponentState).getEntity();
}
return product;
}
use of com.qcadoo.view.api.ComponentState in project mes by qcadoo.
the class OperationDurationDetailsInOrderListenerOFSPG method saveDatesInSubOrders.
@Transactional
public final void saveDatesInSubOrders(final ViewDefinitionState view, final ComponentState state, final String[] args) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Long orderId = form.getEntityId();
List<Entity> orders = getOrdersForComponent(orderId);
if (!orders.isEmpty()) {
List<Entity> ordersTimeCalculations = dataDefinitionService.get(TimeNormsConstants.PLUGIN_PRODUCTION_SCHEDULING_IDENTIFIER, TimeNormsConstants.MODEL_ORDER_TIME_CALCULATION).find().createAlias("order", "ord", JoinType.LEFT).add(SearchRestrictions.in("ord.id", getOrdersForComponent(orderId).stream().map(entity -> entity.getId()).collect(Collectors.toList()))).list().getEntities();
Map<Long, Entity> ordersTimeCalculationsByOrder = ordersTimeCalculations.stream().collect(Collectors.toMap(x -> x.getBelongsToField(OrderTimeCalculationFields.ORDER).getId(), x -> x));
for (Entity order : orders) {
order.setField(OrderFields.DATE_FROM, getStartDate(ordersTimeCalculationsByOrder.get(order.getId())));
order.setField(OrderFields.DATE_TO, getFinishDate(ordersTimeCalculationsByOrder.get(order.getId())));
order.getDataDefinition().save(order);
}
form.addMessage("productionScheduling.info.saveDatesInSubOrdersSuccess", ComponentState.MessageType.SUCCESS);
} else {
form.addMessage("productionScheduling.info.saveDatesInSubOrdersNoOrders", ComponentState.MessageType.INFO);
}
state.performEvent(view, "reset", new String[0]);
}
use of com.qcadoo.view.api.ComponentState in project mes by qcadoo.
the class SupplyParametersHooksPFTD method onBeforeRender.
public void onBeforeRender(final ViewDefinitionState view) {
ComponentState warehouseIssueProductsSource = view.getComponentByReference(ParameterFieldsPFTD.WAREHOUSE_ISSUE_PRODUCTS_SOURCE);
supplyParametersListenersPFTD.toggleGenerateIssuesTo(view, warehouseIssueProductsSource, null);
toggleStateReservation(view);
}
use of com.qcadoo.view.api.ComponentState in project mes by qcadoo.
the class WorkPlanDetailsListeners method validateOrders.
private boolean validateOrders(final ComponentState state, final List<Entity> orders) {
List<String> numbers = Lists.newArrayList();
for (Entity order : orders) {
if (order.getBelongsToField(OrderFields.TECHNOLOGY) == null) {
numbers.add(order.getStringField(OrderFields.NUMBER));
}
}
if (!numbers.isEmpty()) {
String commaSeparatedNumbers = numbers.stream().map(i -> i).collect(Collectors.joining(", "));
state.addMessage("workPlans.workPlanDetails.window.workPlan.missingTechnologyInOrders", MessageType.FAILURE, commaSeparatedNumbers);
return false;
}
return true;
}
use of com.qcadoo.view.api.ComponentState in project mes by qcadoo.
the class WorkPlanDetailsListeners method checkIfInactiveOrders.
private boolean checkIfInactiveOrders(final ComponentState state, final List<Entity> orders) {
List<String> numbers = Lists.newArrayList();
for (Entity order : orders) {
if (!order.isActive()) {
numbers.add(order.getStringField(OrderFields.NUMBER));
}
}
if (!numbers.isEmpty()) {
String commaSeparatedNumbers = numbers.stream().map(i -> i).collect(Collectors.joining(", "));
state.addMessage("workPlans.workPlanDetails.window.workPlan.isInactiveOrders", MessageType.INFO, commaSeparatedNumbers);
return false;
}
return true;
}
Aggregations