use of com.axelor.apps.production.db.WorkCenterGroup in project axelor-open-suite by axelor.
the class ProdProcessLineController method setWorkCenterGroup.
public void setWorkCenterGroup(ActionRequest request, ActionResponse response) {
try {
Long prodProcessId = request.getContext().asType(ProdProcessLine.class).getId();
ProdProcessLine prodProcess = Beans.get(ProdProcessLineRepository.class).find(prodProcessId);
Map<String, Object> workCenterGroupMap = ((LinkedHashMap<String, Object>) request.getContext().get("workCenterGroupWizard"));
if (workCenterGroupMap != null && workCenterGroupMap.containsKey("id")) {
WorkCenterGroup workCenterGroup = Beans.get(WorkCenterGroupRepository.class).find(Long.valueOf(workCenterGroupMap.get("id").toString()));
Beans.get(ProdProcessLineService.class).setWorkCenterGroup(prodProcess, workCenterGroup);
}
response.setCanClose(true);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.production.db.WorkCenterGroup in project axelor-open-suite by axelor.
the class ProdProcessLineServiceImpl method copyWorkCenterGroup.
/**
* Create a work center group from a template. Since a template is also a work center group, we
* copy and set template field to false.
*/
protected ProdProcessLine copyWorkCenterGroup(ProdProcessLine prodProcessLine, WorkCenterGroup workCenterGroup) {
WorkCenterGroup workCenterGroupCopy = JPA.copy(workCenterGroup, false);
workCenterGroupCopy.setWorkCenterGroupModel(workCenterGroup);
workCenterGroupCopy.setTemplate(false);
workCenterGroup.getWorkCenterSet().forEach((workCenterGroupCopy::addWorkCenterSetItem));
prodProcessLine.setWorkCenterGroup(workCenterGroupCopy);
return Beans.get(ProdProcessLineRepository.class).save(prodProcessLine);
}
use of com.axelor.apps.production.db.WorkCenterGroup in project axelor-open-suite by axelor.
the class ProdProcessLineServiceImpl method getMainWorkCenterFromGroup.
@Override
public WorkCenter getMainWorkCenterFromGroup(ProdProcessLine prodProcessLine) throws AxelorException {
WorkCenterGroup workCenterGroup = prodProcessLine.getWorkCenterGroup();
if (workCenterGroup == null) {
return null;
}
Set<WorkCenter> workCenterSet = workCenterGroup.getWorkCenterSet();
if (workCenterSet == null || workCenterSet.isEmpty()) {
throw new AxelorException(TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.NO_WORK_CENTER_GROUP));
}
return workCenterSet.stream().min(Comparator.comparing(WorkCenter::getSequence)).orElseThrow(() -> new AxelorException(TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.NO_WORK_CENTER_GROUP)));
}
Aggregations