Search in sources :

Example 1 with ControlPoint

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

the class QualityControlServiceImpl method preFillOperations.

/**
 * Copy control point model to control point and set it to the quality control.
 *
 * @param qualityControl Set control point model to control point of this object.
 * @throws AxelorException
 */
@Override
@Transactional(rollbackOn = { Exception.class })
public void preFillOperations(QualityControl qualityControl, QualityProcess process) throws AxelorException {
    List<ControlPointModel> controlPointModelList = process.getControlPointModelList();
    List<ControlPointModel> optionalControlPointModelList = process.getOptionalControlPointModelList();
    List<QualityCorrectiveAction> qualityCorrectiveActionList = process.getQualityCorrectiveActionList();
    if (controlPointModelList != null) {
        qualityControl.getControlPointList().clear();
        for (ControlPointModel model : controlPointModelList) {
            ControlPoint point = new ControlPoint();
            this.createControlPointListItem(model, point, qualityControl);
            qualityControl.addControlPointListItem(point);
        }
    }
    if (optionalControlPointModelList != null) {
        qualityControl.getOptionalControlPointList().clear();
        for (ControlPointModel model : optionalControlPointModelList) {
            ControlPoint point = new ControlPoint();
            this.createControlPointListItem(model, point, qualityControl);
            qualityControl.addOptionalControlPointListItem(point);
        }
    }
    if (qualityCorrectiveActionList != null) {
        qualityControl.getQualityCorrectiveActionList().clear();
        for (QualityCorrectiveAction qualityCorrectiveAction : qualityCorrectiveActionList) {
            qualityCorrectiveAction = Beans.get(QualityCorrectiveActionRepository.class).copy(qualityCorrectiveAction, true);
            qualityControl.addQualityCorrectiveActionListItem(qualityCorrectiveAction);
        }
    }
}
Also used : QualityCorrectiveAction(com.axelor.apps.quality.db.QualityCorrectiveAction) ControlPointModel(com.axelor.apps.quality.db.ControlPointModel) ControlPoint(com.axelor.apps.quality.db.ControlPoint) Transactional(com.google.inject.persist.Transactional)

Example 2 with ControlPoint

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

the class QualityControlServiceImpl method preFillOperationsFromOptionals.

@Override
@Transactional
public void preFillOperationsFromOptionals(QualityControl qualityControl, List<ControlPoint> optionalControlPointList) {
    for (ControlPoint optionalControlPoint : optionalControlPointList) {
        optionalControlPoint = Beans.get(ControlPointRepository.class).copy(optionalControlPoint, true);
        optionalControlPoint.setOptionalQualityControl(null);
        qualityControl.addControlPointListItem(optionalControlPoint);
    }
    Beans.get(QualityControlRepository.class).save(qualityControl);
}
Also used : ControlPoint(com.axelor.apps.quality.db.ControlPoint) QualityControlRepository(com.axelor.apps.quality.db.repo.QualityControlRepository) Transactional(com.google.inject.persist.Transactional)

Example 3 with ControlPoint

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

ControlPoint (com.axelor.apps.quality.db.ControlPoint)3 QualityControlRepository (com.axelor.apps.quality.db.repo.QualityControlRepository)2 Transactional (com.google.inject.persist.Transactional)2 ControlPointModel (com.axelor.apps.quality.db.ControlPointModel)1 QualityControl (com.axelor.apps.quality.db.QualityControl)1 QualityCorrectiveAction (com.axelor.apps.quality.db.QualityCorrectiveAction)1 ControlPointRepository (com.axelor.apps.quality.db.repo.ControlPointRepository)1 QualityControlService (com.axelor.apps.quality.service.QualityControlService)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1