@Override public BonSortie saveOrUpdateBonSortie(BonSortie bonSortie) throws ServiceException { try { if (bonSortie.getId() == null) { return bonSortieDao.create(bonSortie); } else { return bonSortieDao.update(bonSortie); } } catch (DataAccessException ex) { Logger.getLogger(OrdreSortieServiceImpl.class.getName()).log(Level.SEVERE, null, ex); } return null; }
@Override public void deleteBon(Long id) throws ServiceException { try { BonSortie bs = bonSortieDao.findById(id); if (bs != null) { if (bs.getOrdeSortie().getEtatType() != EtatType.acheve) { bs.setActive(false); bonSortieDao.update(bs); } } } catch (DataAccessException ex) { Logger.getLogger(OrdreSortieServiceImpl.class.getName()).log(Level.SEVERE, null, ex); } }
@Override public List<BonSortie> findAllBonSortie() throws ServiceException { try { return bonSortieDao.findAll(); } catch (DataAccessException ex) { Logger.getLogger(OrdreSortieServiceImpl.class.getName()).log(Level.SEVERE, null, ex); } return Collections.EMPTY_LIST; }
@Override public BonSortie findBonById(Long id) throws ServiceException { try { return bonSortieDao.findById(id); } catch (DataAccessException ex) { Logger.getLogger(OrdreSortieServiceImpl.class.getName()).log(Level.SEVERE, null, ex); } return null; }
@Override public List<BonSortie> findAllByOrdre(Long idOdre) throws ServiceException { try { OrdreSortie os = ordreSortieDao.findById(idOdre); if (os == null) { throw new ServiceException("Service not found"); } return bonSortieDao.findByOrdreSortie(os); } catch (DataAccessException ex) { Logger.getLogger(OrdreSortieServiceImpl.class.getName()).log(Level.SEVERE, null, ex); } return Collections.EMPTY_LIST; }
@Override public List<Affectation> findAllByBon(Long idBon) throws ServiceException { try { BonSortie bs = bonSortieDao.findById(idBon); if (bs == null) { throw new ServiceException("Service not found"); } return affectationDao.findByBonSortie(bs); } catch (DataAccessException ex) { Logger.getLogger(OrdreSortieServiceImpl.class.getName()).log(Level.SEVERE, null, ex); } return Collections.EMPTY_LIST; }
@Override public void imprimerBsp(Long idBsp, OutputStream stream) throws ServiceException { try { Document doc = new Document(); PdfWriter.getInstance(doc, stream); doc.setPageSize(PageSize.A4.rotate()); doc.open(); Util.produceHeader(doc); BonSortie bs = bonSortieDao.findById(idBsp); produceBspTable(bs, doc); doc.close(); } catch (DocumentException ex) { Logger.getLogger(OrdreSortieServiceImpl.class.getName()).log(Level.SEVERE, null, ex); } catch (Exception ex) { Logger.getLogger(OrdreSortieServiceImpl.class.getName()).log(Level.SEVERE, null, ex); } }