use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.
the class LineChangeoverNormsForOrdersServiceImpl method fillOrderForm.
@Override
public void fillOrderForm(final ViewDefinitionState view, final List<String> orderFields) {
LookupComponent orderLookup = (LookupComponent) view.getComponentByReference(orderFields.get(0));
Entity order = orderLookup.getEntity();
if (order == null) {
return;
}
FieldComponent technologyNumberField = (FieldComponent) view.getComponentByReference(orderFields.get(1));
FieldComponent technologyGroupNumberField = (FieldComponent) view.getComponentByReference(orderFields.get(2));
FieldComponent dateToFromField = (FieldComponent) view.getComponentByReference(orderFields.get(3));
FieldComponent dateIsField = (FieldComponent) view.getComponentByReference(orderFields.get(4));
orderLookup.setFieldValue(order.getId());
orderLookup.requestComponentUpdateState();
setUpTechnologyFields(order, technologyNumberField, technologyGroupNumberField);
Date dateToFrom = null;
String dateIs = null;
if (L_PREVIOUS_ORDER_DATE_TO.equals(orderFields.get(3))) {
Date effectiveDateTo = order.getDateField(OrderFields.EFFECTIVE_DATE_TO);
Date correctedDateTo = order.getDateField(OrderFields.CORRECTED_DATE_TO);
Date dateTo = order.getDateField(OrderFields.DATE_TO);
if (effectiveDateTo != null) {
dateToFrom = effectiveDateTo;
dateIs = L_LINE_CHANGEOVER_NORMS_FOR_ORDERS_DATE_IS_EFFECTIVE;
} else if (correctedDateTo != null) {
dateToFrom = correctedDateTo;
dateIs = L_LINE_CHANGEOVER_NORMS_FOR_ORDERS_DATE_IS_CORRECTED;
} else if (dateTo != null) {
dateToFrom = dateTo;
dateIs = L_LINE_CHANGEOVER_NORMS_FOR_ORDERS_DATE_IS_PLANNED;
}
} else if (L_DATE_FROM.equals(orderFields.get(3))) {
Date effectiveDateFrom = order.getDateField(OrderFields.EFFECTIVE_DATE_FROM);
Date correctedDateFrom = order.getDateField(OrderFields.CORRECTED_DATE_FROM);
Date dateFrom = order.getDateField(OrderFields.DATE_FROM);
if (effectiveDateFrom != null) {
dateToFrom = effectiveDateFrom;
dateIs = L_LINE_CHANGEOVER_NORMS_FOR_ORDERS_DATE_IS_EFFECTIVE;
} else if (correctedDateFrom != null) {
dateToFrom = correctedDateFrom;
dateIs = L_LINE_CHANGEOVER_NORMS_FOR_ORDERS_DATE_IS_CORRECTED;
} else if (dateFrom != null) {
dateToFrom = dateFrom;
dateIs = L_LINE_CHANGEOVER_NORMS_FOR_ORDERS_DATE_IS_PLANNED;
}
}
if (dateToFrom == null || dateIs == null) {
dateToFromField.setFieldValue(null);
dateIsField.setFieldValue(null);
} else {
dateToFromField.setFieldValue(new SimpleDateFormat(DateUtils.L_DATE_TIME_FORMAT, Locale.getDefault()).format(dateToFrom));
dateIsField.setFieldValue(translationService.translate(dateIs, LocaleContextHolder.getLocale()));
}
dateToFromField.requestComponentUpdateState();
dateIsField.requestComponentUpdateState();
}
use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.
the class LineChangeoverNormsForOrderDetailsViewHooks method fillOrderForms.
public final void fillOrderForms(final ViewDefinitionState view) {
FormComponent orderForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
LookupComponent orderLookup = (LookupComponent) view.getComponentByReference(OrderFieldsLCNFO.ORDER);
LookupComponent previousOrderLookup = (LookupComponent) view.getComponentByReference(OrderFieldsLCNFO.PREVIOUS_ORDER);
if (orderForm.getEntityId() == null) {
return;
}
Entity order = orderForm.getPersistedEntityWithIncludedFormValues();
orderLookup.setFieldValue(order.getId());
orderLookup.requestComponentUpdateState();
lineChangeoverNormsForOrdersService.fillOrderForm(view, LineChangeoverNormsForOrdersConstants.ORDER_FIELDS);
if (previousOrderLookup.isEmpty()) {
Entity previousOrder = lineChangeoverNormsForOrdersService.getPreviousOrderFromDB(order);
if (previousOrder != null) {
previousOrderLookup.setFieldValue(previousOrder.getId());
previousOrderLookup.requestComponentUpdateState();
lineChangeoverNormsForOrdersService.fillOrderForm(view, LineChangeoverNormsForOrdersConstants.PREVIOUS_ORDER_FIELDS);
}
}
}
use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.
the class LineChangeoverNormsForOrderDetailsViewHooks method findChangeoverNorm.
private Entity findChangeoverNorm(final ViewDefinitionState view) {
LookupComponent orderLookup = (LookupComponent) view.getComponentByReference(OrderFieldsLCNFO.ORDER);
LookupComponent previousOrderLookup = (LookupComponent) view.getComponentByReference(OrderFieldsLCNFO.PREVIOUS_ORDER);
Entity order = orderLookup.getEntity();
if (order == null) {
return null;
}
Entity fromTechnology = extractTechnologyPrototypeFrom(previousOrderLookup.getEntity());
Entity toTechnology = extractTechnologyPrototypeFrom(order);
if (fromTechnology == null || toTechnology == null) {
return null;
}
Entity productionLine = order.getBelongsToField(OrderFields.PRODUCTION_LINE);
return changeoverNormsService.getMatchingChangeoverNorms(fromTechnology, toTechnology, productionLine);
}
use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.
the class LineChangeoverNormsForOrderDetailsListeners method showPreviousOrder.
public final void showPreviousOrder(final ViewDefinitionState view, final ComponentState componentState, final String[] args) {
LookupComponent previousOrderLookup = (LookupComponent) view.getComponentByReference(OrderFieldsLCNFO.PREVIOUS_ORDER);
Long previousOrderId = (Long) previousOrderLookup.getFieldValue();
if (previousOrderId == null) {
return;
}
Map<String, Object> parameters = Maps.newHashMap();
parameters.put("form.id", previousOrderId);
String url = "../page/orders/orderDetails.html";
view.redirectTo(url, false, true, parameters);
}
use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.
the class LineChangeoverNormsForOrderDetailsListeners method checkIfOrderHasCorrectStateAndIsPrevious.
public final void checkIfOrderHasCorrectStateAndIsPrevious(final ViewDefinitionState view, final ComponentState componentState, final String[] args) {
LookupComponent previousOrderLookup = (LookupComponent) view.getComponentByReference(OrderFieldsLCNFO.PREVIOUS_ORDER);
LookupComponent orderLookup = (LookupComponent) view.getComponentByReference(OrderFieldsLCNFO.ORDER);
Entity previousOrder = previousOrderLookup.getEntity();
Entity order = orderLookup.getEntity();
if (!lineChangeoverNormsForOrdersService.previousOrderEndsBeforeOrIsWithdrawed(previousOrder, order)) {
previousOrderLookup.addMessage("orders.order.previousOrder.message.orderIsIncorrect", ComponentState.MessageType.FAILURE);
}
}
Aggregations