This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository observe. See http://git.codelutin.com/observe.git commit f745d403cea48073d0e7f6de635fc3311935ae98 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sat Apr 11 08:07:54 2015 +0200 refs #6938 Suppression de méthodes sur les dao (on utilise le chargement via le modèle de sélection) + ajout de méthode pour supprimer une marée --- .../src/main/java/fr/ird/observe/DataService.java | 44 ++++++++++++++++++++++ .../entities/longline/TripLonglineDAOImpl.java | 32 +--------------- .../observe/entities/seine/TripSeineDAOImpl.java | 32 +--------------- 3 files changed, 46 insertions(+), 62 deletions(-) diff --git a/observe-business/src/main/java/fr/ird/observe/DataService.java b/observe-business/src/main/java/fr/ird/observe/DataService.java index c810802..029675a 100644 --- a/observe-business/src/main/java/fr/ird/observe/DataService.java +++ b/observe-business/src/main/java/fr/ird/observe/DataService.java @@ -139,9 +139,16 @@ public class DataService { protected final PropertyChangeSupport pcs = new PropertyChangeSupport(this); + private boolean skipTransactionListener; + private TopiaTransactionListener transactionListener = new TopiaTransactionListener() { public void commit(TopiaTransactionEvent event) { + + if (skipTransactionListener) { + return; + } + java.util.Set<TopiaEntity> entities = event.getEntities(); // pour recenser les referentiels modifies @@ -2389,4 +2396,41 @@ public class DataService { firePropertyChangedEvent(event, "Data [" + entity + "] changed", listeners); } } + + public void deleteTrip(DataSource source, String tripId) throws DataSourceException { + + String txName = "deleteTrip"; + TopiaContext tx = beginTransaction(source, txName); + try { + + if (Entities.isSeineId(tripId)) { + + TripSeineDAO dao = (TripSeineDAO) source.getDAO(tx, TripSeine.class); + TripSeine result = dao.findByTopiaId(tripId); + dao.delete(result); + + } else { + + TripLonglineDAO dao = (TripLonglineDAO) source.getDAO(tx, TripLongline.class); + TripLongline result = dao.findByTopiaId(tripId); + dao.delete(result); + + } + + skipTransactionListener = true; + try { + + commitTransaction(source, tx, txName); + + } finally { + skipTransactionListener = false; + } + + } catch (Exception e) { + throw new DataSourceException(e, txName); + } finally { + closeTransaction(source, tx, txName); + } + + } } diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/longline/TripLonglineDAOImpl.java b/observe-entities/src/main/java/fr/ird/observe/entities/longline/TripLonglineDAOImpl.java index f64a5d2..525361b 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/longline/TripLonglineDAOImpl.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/longline/TripLonglineDAOImpl.java @@ -53,13 +53,6 @@ public class TripLonglineDAOImpl<E extends TripLongline> extends TripLonglineDAO return -1; } - public List<E> findAllStub(ReferenceLocale referenceLocale) throws TopiaException { - - List<E> result = StubSqlQuery.findAll(context, referenceLocale); - return result; - - } - public List<E> findAllStubByProgramId(String programId, ReferenceLocale referenceLocale) throws TopiaException { List<E> result = StubSqlQuery.findAll(context, programId, referenceLocale); @@ -88,27 +81,6 @@ public class TripLonglineDAOImpl<E extends TripLongline> extends TripLonglineDAO this.referenceLocale = referenceLocale; } - public static <E extends TripLongline> List<E> findAll(TopiaContextImplementor context, ReferenceLocale referenceLocale) throws TopiaException { - - String sql = "SELECT" + - " t.topiaId," + - " t.startDate," + - " t.endDate," + - " t.open," + - " p.lastName," + - " p.firstName," + - " v." + referenceLocale.getColumnName() + - " FROM observe_longline.trip t, observe_common.person p, observe_common.vessel v" + - " WHERE " + - " t.observer = p.topiaId" + - " AND t.vessel = v.topiaId" + - " ORDER BY t.endDate"; - - StubSqlQuery<E> request = new StubSqlQuery<E>(sql, null, referenceLocale); - return request.findMultipleResult(context); - - } - public static <E extends TripLongline> List<E> findAll(TopiaContextImplementor context, String programId, ReferenceLocale referenceLocale) throws TopiaException { String sql = "SELECT" + @@ -156,9 +128,7 @@ public class TripLonglineDAOImpl<E extends TripLongline> extends TripLonglineDAO @Override protected PreparedStatement prepareQuery(Connection connection) throws SQLException { PreparedStatement preparedStatement = connection.prepareStatement(sql); - if (id!=null) { - preparedStatement.setString(1, id); - } + preparedStatement.setString(1, id); return preparedStatement; } diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/seine/TripSeineDAOImpl.java b/observe-entities/src/main/java/fr/ird/observe/entities/seine/TripSeineDAOImpl.java index 8c02673..08a63a9 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/seine/TripSeineDAOImpl.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/seine/TripSeineDAOImpl.java @@ -58,13 +58,6 @@ public class TripSeineDAOImpl<E extends TripSeine> extends TripSeineDAOAbstract< return -1; } - public List<E> findAllStub(ReferenceLocale referenceLocale) throws TopiaException { - - List<E> result = StubSqlQuery.findAll(context, referenceLocale); - return result; - - } - public List<E> findAllStubByProgramId(String programId, ReferenceLocale referenceLocale) throws TopiaException { List<E> result = StubSqlQuery.findAll(context, programId, referenceLocale); @@ -109,27 +102,6 @@ public class TripSeineDAOImpl<E extends TripSeine> extends TripSeineDAOAbstract< } - static <E extends TripSeine> List<E> findAll(TopiaContextImplementor context, ReferenceLocale referenceLocale) throws TopiaException { - - String sql = "SELECT" + - " t.topiaId," + - " t.startDate," + - " t.endDate," + - " t.open," + - " p.lastName," + - " p.firstName," + - " v." + referenceLocale.getColumnName() + - " FROM observe_seine.trip t, observe_common.person p, observe_common.vessel v" + - " WHERE " + - " t.observer = p.topiaId" + - " AND t.vessel = v.topiaId" + - " ORDER BY t.endDate"; - - StubSqlQuery<E> request = new StubSqlQuery<E>(sql, null, referenceLocale); - return request.findMultipleResult(context); - - } - static <E extends TripSeine> E find(TopiaContextImplementor context, String tripId, ReferenceLocale referenceLocale) throws TopiaException { String sql = "SELECT" + @@ -161,9 +133,7 @@ public class TripSeineDAOImpl<E extends TripSeine> extends TripSeineDAOAbstract< @Override protected PreparedStatement prepareQuery(Connection connection) throws SQLException { PreparedStatement preparedStatement = connection.prepareStatement(sql); - if (id != null) { - preparedStatement.setString(1, id); - } + preparedStatement.setString(1, id); return preparedStatement; } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.