@Test public void testEditCrisisType() { CrisisTypeDTO addCrisisType = new CrisisTypeDTO(); addCrisisType.setName(sampleCrisisTypeName); entityManager.getTransaction().begin(); CrisisTypeDTO result = crisisTypeResourceFacadeImp .addCrisisType(addCrisisType); entityManager.getTransaction().commit(); result.setName(sampleCrisisTypeName + "2"); entityManager.getTransaction().begin(); result = crisisTypeResourceFacadeImp.editCrisisType(result); entityManager.getTransaction().commit(); assertEquals(sampleCrisisTypeName + "2", result.getName()); entityManager.getTransaction().begin(); crisisTypeResourceFacadeImp.deleteCrisisType(result .getCrisisTypeId()); entityManager.getTransaction().commit(); }
@Override public CrisisTypeDTO editCrisisType(CrisisTypeDTO crisisType) { try { CrisisType cType = getById(crisisType.getCrisisTypeId()); if (cType != null) { cType = em.merge(crisisType.toEntity()); em.flush(); em.refresh(cType); logger.info("Updated crisisType: " + cType.getName() + ", " + cType.getCrisisTypeId()); return cType != null ? new CrisisTypeDTO(cType) : null; } else { logger.error("Not found"); throw new RuntimeException("Not found"); } } catch (Exception e) { logger.error("Exception in merging/updating crisisType: " + crisisType.getCrisisTypeId(), e); } return null; }
CrisisTypeResourceFacadeImp extends CoreDBServiceFacadeImp<CrisisType, Long> implements CrisisTypeResourceFacade { @Override public CrisisTypeDTO editCrisisType(CrisisTypeDTO crisisType) { try { CrisisType cType = getById(crisisType.getCrisisTypeId()); if (cType != null) { cType = em.merge(crisisType.toEntity()); em.flush(); em.refresh(cType); logger.info("Updated crisisType: " + cType.getName() + ", " + cType.getCrisisTypeId()); return cType != null ? new CrisisTypeDTO(cType) : null; } else { logger.error("Not found"); throw new RuntimeException("Not found"); } } catch (Exception e) { logger.error("Exception in merging/updating crisisType: " + crisisType.getCrisisTypeId(), e); } return null; } }
CrisisTypeResourceFacadeImp extends CoreDBServiceFacadeImp<CrisisType, Long> implements CrisisTypeResourceFacade { @Override public CrisisTypeDTO editCrisisType(CrisisTypeDTO crisisType) { try { CrisisType cType = getById(crisisType.getCrisisTypeId()); if (cType != null) { cType = em.merge(crisisType.toEntity()); em.flush(); em.refresh(cType); logger.info("Updated crisisType: " + cType.getName() + ", " + cType.getCrisisTypeId()); return cType != null ? new CrisisTypeDTO(cType) : null; } else { logger.error("Not found"); throw new RuntimeException("Not found"); } } catch (Exception e) { logger.error("Exception in merging/updating crisisType: " + crisisType.getCrisisTypeId(), e); } return null; } CrisisTypeResourceFacadeImp(); }
CrisisTypeResourceFacadeImp extends CoreDBServiceFacadeImp<CrisisType, Long> implements CrisisTypeResourceFacade { @Override public CrisisTypeDTO editCrisisType(CrisisTypeDTO crisisType) { try { CrisisType cType = getById(crisisType.getCrisisTypeId()); if (cType != null) { cType = em.merge(crisisType.toEntity()); em.flush(); em.refresh(cType); logger.info("Updated crisisType: " + cType.getName() + ", " + cType.getCrisisTypeId()); return cType != null ? new CrisisTypeDTO(cType) : null; } else { logger.error("Not found"); throw new RuntimeException("Not found"); } } catch (Exception e) { logger.error("Exception in merging/updating crisisType: " + crisisType.getCrisisTypeId(), e); } return null; } CrisisTypeResourceFacadeImp(); @Override List<CrisisTypeDTO> getAllCrisisTypes(); @Override CrisisTypeDTO addCrisisType(CrisisTypeDTO crisisType); @Override CrisisTypeDTO editCrisisType(CrisisTypeDTO crisisType); @Override Integer deleteCrisisType(Long id); @Override List<CrisisTypeDTO> findByCriteria(String columnName, Object value); @Override CrisisTypeDTO findCrisisTypeByID(Long id); @Override boolean isCrisisTypeExists(Long id); @Override List<CollectionDTO> getAllCrisisForCrisisTypeID(Long id); }
CrisisTypeResourceFacadeImp extends CoreDBServiceFacadeImp<CrisisType, Long> implements CrisisTypeResourceFacade { @Override public CrisisTypeDTO editCrisisType(CrisisTypeDTO crisisType) { try { CrisisType cType = getById(crisisType.getCrisisTypeId()); if (cType != null) { cType = em.merge(crisisType.toEntity()); em.flush(); em.refresh(cType); logger.info("Updated crisisType: " + cType.getName() + ", " + cType.getCrisisTypeId()); return cType != null ? new CrisisTypeDTO(cType) : null; } else { logger.error("Not found"); throw new RuntimeException("Not found"); } } catch (Exception e) { logger.error("Exception in merging/updating crisisType: " + crisisType.getCrisisTypeId(), e); } return null; } CrisisTypeResourceFacadeImp(); @Override List<CrisisTypeDTO> getAllCrisisTypes(); @Override CrisisTypeDTO addCrisisType(CrisisTypeDTO crisisType); @Override CrisisTypeDTO editCrisisType(CrisisTypeDTO crisisType); @Override Integer deleteCrisisType(Long id); @Override List<CrisisTypeDTO> findByCriteria(String columnName, Object value); @Override CrisisTypeDTO findCrisisTypeByID(Long id); @Override boolean isCrisisTypeExists(Long id); @Override List<CollectionDTO> getAllCrisisForCrisisTypeID(Long id);  }