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);
}
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);
}
}
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);
}
}
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());
}
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);
}
Aggregations