Search in sources :

Example 1 with QualityControlRepository

use of com.axelor.apps.quality.db.repo.QualityControlRepository 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);
    }
}
Also used : Context(com.axelor.rpc.Context) QualityControl(com.axelor.apps.quality.db.QualityControl) QualityControlService(com.axelor.apps.quality.service.QualityControlService) QualityControlRepository(com.axelor.apps.quality.db.repo.QualityControlRepository) Nullable(javax.annotation.Nullable) AxelorException(com.axelor.exception.AxelorException)

Aggregations

QualityControl (com.axelor.apps.quality.db.QualityControl)1 QualityControlRepository (com.axelor.apps.quality.db.repo.QualityControlRepository)1 QualityControlService (com.axelor.apps.quality.service.QualityControlService)1 AxelorException (com.axelor.exception.AxelorException)1 Context (com.axelor.rpc.Context)1 Nullable (javax.annotation.Nullable)1