Untitled
unknown
java
a year ago
1.2 kB
2
Indexable
Never
public void updateTerminal(NgaTerminal ngaTerminal) throws PersistenceException { Long terminalId = ngaTerminal.getTerminalId(); try { NgaTerminalOld ngaTerminalOld; NgaTerminal terminalSelected = terminalRepository.findByTerminalId(terminalId); NgaTerminal terminalByCode = terminalRepository.findByZoneCode(ngaTerminal.getZone(), ngaTerminal.getSalepointCode(), ngaTerminal.getTerminalSalepointCode()); if (terminalByCode != null && !ngaTerminal.getTerminalId().equals(terminalByCode.getTerminalId())) { throw new PersistenceException("Impossible to update terminalId " + terminalId + " because there is another terminalId " + terminalByCode.getTerminalId() + " already present on legacy key " + terminalByCode.getZone() + "-" + terminalByCode.getSalepointCode() + "-" + terminalByCode.getTerminalSalepointCode()); } ngaTerminalOld = TerminalUtils.copyTerminal(terminalSelected); entityManager.persist(ngaTerminalOld); entityManager.flush(); terminalRepository.saveAndFlush( ngaTerminal); } catch (Exception e) { logger.error("NgaPersistenceServices|updateTerminal() - Error due to terminalId: ", terminalId,e); throw new PersistenceException(e.getMessage(), e); } }