use of com.axelor.apps.quality.service.QualityControlService in project axelor-open-suite by axelor.
the class QualityControlController method sendEmail.
@SuppressWarnings("unchecked")
public void sendEmail(ActionRequest request, ActionResponse response) {
try {
Context context = request.getContext();
QualityControlService qualityControlService = Beans.get(QualityControlService.class);
if (!ObjectUtils.isEmpty(context.get("_ids"))) {
List<Long> idList = Lists.transform((List) context.get("_ids"), new Function<Object, Long>() {
@Nullable
@Override
public Long apply(@Nullable Object input) {
return Long.parseLong(input.toString());
}
});
QualityControlRepository qualityControlRepo = Beans.get(QualityControlRepository.class);
for (Long id : idList) {
QualityControl qualityControl = qualityControlRepo.find(id);
if (qualityControl.getStatusSelect() == QualityControlRepository.STATUS_FINISHED) {
qualityControlService.sendEmail(qualityControl);
}
}
} else if (!ObjectUtils.isEmpty(context.get("id"))) {
QualityControl qualityControl = context.asType(QualityControl.class);
qualityControlService.sendEmail(qualityControl);
}
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
Aggregations