@Override @Transaction public void deleteNote(TopiaContext transaction, String topiaId) throws TopiaException, LogicException { NoteDAO dao = SandraDAOHelper.getNoteDAO(transaction); Note note = dao.findByTopiaId(topiaId); if (note == null) { throw new LogicException("error.service.note.unfound"); } dao.delete(note); String name = SandraConfigHelper.getNoteDir(SandraConfig.getConfig()) + File.separator + note.getNom(); boolean deleted = new File(name).delete(); if (!deleted) { log.error("Cant delete note : " + name); } }
NoteDAO dao = SandraDAOHelper.getNoteDAO(transaction); Note noteByNom = dao.findByNom(note.getNom()); if (noteByNom != null) { throw new LogicException("error.service.note.exist"); note2 = dao.create(); if (log.isInfoEnabled()) { log.info("has created note " + note2.getTopiaId()); note2 = dao.findByTopiaId(topiaId); if (log.isInfoEnabled()) { log.info("update note " + note2.getTopiaId()); dao.update(note2); return note2;
if (notes != null) { for (Note note : notes) { noteDAO.delete(note);
@Override @Transaction public InputStream getFileNote(TopiaContext transaction, String topiaId) throws TopiaException, LogicException { NoteDAO dao = SandraDAOHelper.getNoteDAO(transaction); Note note = dao.findByTopiaId(topiaId); if (note == null) { throw new LogicException("error.service.note.unfound"); } String name = SandraConfigHelper.getNoteDir(SandraConfig.getConfig()) + File.separator + note.getNom(); InputStream inputStream; try { inputStream = new FileInputStream(name); } catch (FileNotFoundException ex) { throw new LogicException("error.service.file.unfound", ex); } return inputStream; }
@Override public <U extends TopiaEntity> List<U> findUsages(Class<U> type, E entity) throws TopiaException { List<?> result = new ArrayList(); List tmp; if (type == InfoAccess.class) { InfoAccessDAO dao = (InfoAccessDAO) getContext().getDAO(InfoAccess.class); tmp = dao.findAllByEleveur(entity); result.addAll(tmp); } if (type == Note.class) { NoteDAO dao = (NoteDAO) getContext().getDAO(Note.class); tmp = dao.findAllByEleveur(entity); result.addAll(tmp); } if (type == Etape.class) { EtapeDAO dao = (EtapeDAO) getContext().getDAO(Etape.class); tmp = dao.findAllByEleveur(entity); result.addAll(tmp); } if (type == ActionSecurite.class) { ActionSecuriteDAO dao = (ActionSecuriteDAO) getContext().getDAO(ActionSecurite.class); tmp = dao.findAllByEleveur(entity); result.addAll(tmp); } return (List<U>) result; }
if (notes != null) { for (Note note : notes) { noteDAO.delete(note);
@Override @Transaction public InputStream getFileNote(TopiaContext transaction, String topiaId) throws TopiaException, LogicException { NoteDAO dao = SandraDAOHelper.getNoteDAO(transaction); Note note = dao.findByTopiaId(topiaId); if (note == null) { throw new LogicException("error.service.note.unfound"); } String name = SandraConfigHelper.getNoteDir(SandraConfig.getConfig()) + File.separator + note.getNom(); InputStream inputStream; try { inputStream = new FileInputStream(name); } catch (FileNotFoundException ex) { throw new LogicException("error.service.file.unfound", ex); } return inputStream; }
NoteDAO dao = SandraDAOHelper.getNoteDAO(transaction); Note noteByNom = dao.findByNom(note.getNom()); if (noteByNom != null) { throw new LogicException("error.service.note.exist"); note2 = dao.create(); if (log.isInfoEnabled()) { log.info("has created note " + note2.getTopiaId()); note2 = dao.findByTopiaId(topiaId); if (log.isInfoEnabled()) { log.info("update note " + note2.getTopiaId()); dao.update(note2); return note2;
@Override @Transaction public void deleteNote(TopiaContext transaction, String topiaId) throws TopiaException, LogicException { NoteDAO dao = SandraDAOHelper.getNoteDAO(transaction); Note note = dao.findByTopiaId(topiaId); if (note == null) { throw new LogicException("error.service.note.unfound"); } dao.delete(note); String name = SandraConfigHelper.getNoteDir(SandraConfig.getConfig()) + File.separator + note.getNom(); boolean deleted = new File(name).delete(); if (!deleted) { log.error("Cant delete note : " + name); } }
@Override @Transaction public void addNote(TopiaContext transaction, String eleveurTopiaId, String noteTopiaId) throws TopiaException, LogicException { EleveurDAO eleveurDAO = SandraDAOHelper.getEleveurDAO(transaction); Eleveur eleveur = eleveurDAO.findByTopiaId(eleveurTopiaId); if (eleveur == null) { throw new LogicException("error.service.eleveur.unfound"); } NoteDAO noteDAO = SandraDAOHelper.getNoteDAO(transaction); Note note = noteDAO.findByTopiaId(noteTopiaId); if (note == null) { throw new LogicException("error.service.note.unfound"); } eleveur.addNotes(note); eleveurDAO.update(eleveur); }
@Override @Transaction public void addNote(TopiaContext transaction, String eleveurTopiaId, String noteTopiaId) throws TopiaException, LogicException { EleveurDAO eleveurDAO = SandraDAOHelper.getEleveurDAO(transaction); Eleveur eleveur = eleveurDAO.findByTopiaId(eleveurTopiaId); if (eleveur == null) { throw new LogicException("error.service.eleveur.unfound"); } NoteDAO noteDAO = SandraDAOHelper.getNoteDAO(transaction); Note note = noteDAO.findByTopiaId(noteTopiaId); if (note == null) { throw new LogicException("error.service.note.unfound"); } eleveur.addNotes(note); eleveurDAO.update(eleveur); }