Search in sources :

Example 1 with QualityControl

use of com.axelor.apps.quality.db.QualityControl in project axelor-open-suite by axelor.

the class QualityControlController method preFillOperations.

/**
 * Copy control point model to control point of selected quality process.
 *
 * @param request
 * @param response
 * @throws AxelorException
 */
@SuppressWarnings("unchecked")
public void preFillOperations(ActionRequest request, ActionResponse response) throws AxelorException {
    LinkedHashMap<String, Object> qualityProcessMap = (LinkedHashMap<String, Object>) request.getContext().get("qualityProcess");
    LinkedHashMap<String, Object> qualityControlMap = (LinkedHashMap<String, Object>) request.getContext().get("_qualityControl");
    QualityProcess qualityProcess = Beans.get(QualityProcessRepository.class).find(((Integer) qualityProcessMap.get("id")).longValue());
    QualityControl qualityControl = Beans.get(QualityControlRepository.class).find(((Integer) qualityControlMap.get("id")).longValue());
    Beans.get(QualityControlService.class).preFillOperations(qualityControl, qualityProcess);
    response.setCanClose(true);
}
Also used : QualityProcessRepository(com.axelor.apps.quality.db.repo.QualityProcessRepository) QualityControl(com.axelor.apps.quality.db.QualityControl) QualityControlService(com.axelor.apps.quality.service.QualityControlService) QualityControlRepository(com.axelor.apps.quality.db.repo.QualityControlRepository) LinkedHashMap(java.util.LinkedHashMap) QualityProcess(com.axelor.apps.quality.db.QualityProcess)

Example 2 with QualityControl

use of com.axelor.apps.quality.db.QualityControl 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)

Example 3 with QualityControl

use of com.axelor.apps.quality.db.QualityControl in project axelor-open-suite by axelor.

the class QualityMobileController method sendEmail.

/**
 * This method is used in mobile application.
 *
 * @param request
 * @param response
 *     <p>POST: /open-suite-webapp/ws/action Content-Type: application/json Fields: id
 *     <p>payload : { "action":
 *     "com.axelor.apps.quality.mobile.QualityMobileController:sendEmail", "data": { "context":
 *     {"id": 1} } }
 */
public void sendEmail(ActionRequest request, ActionResponse response) {
    try {
        boolean automaticMail = Beans.get(AppQualityService.class).getAppQuality().getAutomaticMail();
        if (request.getRawContext().get("id") == null || !automaticMail) {
            return;
        }
        QualityControl qualityControl = Beans.get(QualityControlRepository.class).find(Long.valueOf(request.getRawContext().get("id").toString()));
        Beans.get(QualityControlService.class).sendEmail(qualityControl);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : QualityControl(com.axelor.apps.quality.db.QualityControl) QualityControlService(com.axelor.apps.quality.service.QualityControlService) QualityControlRepository(com.axelor.apps.quality.db.repo.QualityControlRepository)

Example 4 with QualityControl

use of com.axelor.apps.quality.db.QualityControl in project axelor-open-suite by axelor.

the class QualityControlController method printQualityControl.

public void printQualityControl(ActionRequest request, ActionResponse response) throws AxelorException {
    QualityControl qualityControl = request.getContext().asType(QualityControl.class);
    qualityControl = Beans.get(QualityControlRepository.class).find(qualityControl.getId());
    String fileLink;
    String title = Beans.get(QualityControlPrintServiceImpl.class).getFileName(qualityControl);
    fileLink = Beans.get(QualityControlPrintServiceImpl.class).printQualityControl(qualityControl, ReportSettings.FORMAT_PDF);
    response.setView(ActionView.define(title).add("html", fileLink).map());
}
Also used : QualityControlPrintServiceImpl(com.axelor.apps.quality.service.print.QualityControlPrintServiceImpl) QualityControl(com.axelor.apps.quality.db.QualityControl)

Example 5 with QualityControl

use of com.axelor.apps.quality.db.QualityControl in project axelor-open-suite by axelor.

the class QualityControlController method preFillOperationsFromOptionals.

@SuppressWarnings("unchecked")
public void preFillOperationsFromOptionals(ActionRequest request, ActionResponse response) {
    Set<Map<String, Object>> optionalControlPoints = new HashSet<Map<String, Object>>();
    List<ControlPoint> optionalControlPointList = new ArrayList<ControlPoint>();
    Collection<Map<String, Object>> optionalControlPointSet = (Collection<Map<String, Object>>) request.getContext().get("optionalControlPointSet");
    if (optionalControlPointSet != null) {
        optionalControlPoints.addAll(optionalControlPointSet);
    }
    for (Map<String, Object> optionalControlPointData : optionalControlPoints) {
        ControlPoint optionalControlPoint = Beans.get(ControlPointRepository.class).find(Long.parseLong(optionalControlPointData.get("id").toString()));
        optionalControlPointList.add(optionalControlPoint);
    }
    LinkedHashMap<String, Object> qualityControlMap = (LinkedHashMap<String, Object>) request.getContext().get("_qualityControl");
    QualityControl qualityControl = Beans.get(QualityControlRepository.class).find(((Integer) qualityControlMap.get("id")).longValue());
    Beans.get(QualityControlService.class).preFillOperationsFromOptionals(qualityControl, optionalControlPointList);
    response.setCanClose(true);
}
Also used : QualityControl(com.axelor.apps.quality.db.QualityControl) ArrayList(java.util.ArrayList) QualityControlService(com.axelor.apps.quality.service.QualityControlService) ControlPoint(com.axelor.apps.quality.db.ControlPoint) LinkedHashMap(java.util.LinkedHashMap) Collection(java.util.Collection) QualityControlRepository(com.axelor.apps.quality.db.repo.QualityControlRepository) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) ControlPointRepository(com.axelor.apps.quality.db.repo.ControlPointRepository) HashSet(java.util.HashSet)

Aggregations

QualityControl (com.axelor.apps.quality.db.QualityControl)5 QualityControlRepository (com.axelor.apps.quality.db.repo.QualityControlRepository)4 QualityControlService (com.axelor.apps.quality.service.QualityControlService)4 LinkedHashMap (java.util.LinkedHashMap)2 ControlPoint (com.axelor.apps.quality.db.ControlPoint)1 QualityProcess (com.axelor.apps.quality.db.QualityProcess)1 ControlPointRepository (com.axelor.apps.quality.db.repo.ControlPointRepository)1 QualityProcessRepository (com.axelor.apps.quality.db.repo.QualityProcessRepository)1 QualityControlPrintServiceImpl (com.axelor.apps.quality.service.print.QualityControlPrintServiceImpl)1 AxelorException (com.axelor.exception.AxelorException)1 Context (com.axelor.rpc.Context)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Nullable (javax.annotation.Nullable)1