[Suiviobsmer-commits] r408 - in trunk: wao-business/src/main/java/fr/ifremer/wao/service wao-business/src/main/resources/i18n wao-business/src/main/xmi wao-business/src/test/java/fr/ifremer/wao wao-ui/src/main/java/fr/ifremer/wao/ui/data wao-ui/src/main/java/fr/ifremer/wao/ui/pages wao-ui/src/main/java/fr/ifremer/wao/ui/services
Author: fdesbois Date: 2010-04-01 17:14:29 +0000 (Thu, 01 Apr 2010) New Revision: 408 Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSamplingImpl.java trunk/wao-business/src/main/resources/i18n/wao-business-en_GB.properties trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties trunk/wao-business/src/main/xmi/wao.zargo trunk/wao-business/src/test/java/fr/ifremer/wao/TestManager.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/ExportStreamResponse.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Boats.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Contacts.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SampleRowForm.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/AppModule.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/WaoManager.java Log: - use ServiceTransformer for ServiceContact - clean old context usage in UI - clean ServiceSamplingImpl Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java 2010-04-01 16:46:41 UTC (rev 407) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java 2010-04-01 17:14:29 UTC (rev 408) @@ -27,9 +27,8 @@ import fr.ifremer.wao.io.ImportHelper.*; import fr.ifremer.wao.WaoBusinessException; import fr.ifremer.wao.WaoBusinessException.Type; +import fr.ifremer.wao.WaoDAOHelper; import fr.ifremer.wao.WaoExceptionO; -import fr.ifremer.wao.WaoDAOHelper; -import fr.ifremer.wao.WaoContextO; import fr.ifremer.wao.bean.ContactState; import java.io.IOException; import java.io.InputStream; @@ -74,6 +73,7 @@ import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.time.DurationFormatUtils; import org.nuiton.topia.TopiaContext; +import org.nuiton.topia.TopiaException; import org.nuiton.topia.persistence.TopiaEntity; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -89,26 +89,27 @@ * Mise a jour: $Date$ * par : $Author$ */ -public class ServiceContactImpl implements ServiceContact { +public class ServiceContactImpl extends ServiceContactAbstract { private static final Logger log = LoggerFactory.getLogger(ServiceContactImpl.class); - protected TopiaContext rootContext; +// protected TopiaContext rootContext; +// +// public ServiceContactImpl() throws WaoExceptionO { +// rootContext = context.getTopiaRootContext(); +// } - public ServiceContactImpl() throws WaoExceptionO { - rootContext = WaoContextO.getTopiaRootContext(); - } - @Override - public Map<String, Contact> getContacts(ContactFilter filter) throws WaoExceptionO { - Map<String, Contact> results = new HashMap<String, Contact>(); - TopiaContext transaction = null; - try { - long startTime = 0; - if (log.isDebugEnabled()) { - startTime = System.currentTimeMillis(); - } - transaction = rootContext.beginTransaction(); + public Map<String, Contact> executeGetContacts(TopiaContext transaction, + ContactFilter filter) throws TopiaException { +// Map<String, Contact> results = new HashMap<String, Contact>(); +// TopiaContext transaction = null; +// try { +// long startTime = 0; +// if (log.isDebugEnabled()) { +// startTime = System.currentTimeMillis(); +// } +// transaction = rootContext.beginTransaction(); ContactDAO dao = WaoDAOHelper.getContactDAO(transaction); @@ -123,61 +124,62 @@ } query.addLoad(Contact.SAMPLE_ROW + "." + SampleRow.SAMPLE_MONTH); - results = dao.findAllMappedByQuery(query); + return dao.findAllMappedByQuery(query); - if (log.isDebugEnabled()) { - long stopTime = System.currentTimeMillis(); - log.debug("W:[ getContacts ] Time = " + - DurationFormatUtils.formatDurationHMS( - stopTime - startTime)); - } - - //transaction.closeContext(); - } catch (Exception eee) { - WaoContextO.serviceException(transaction, - "Impossible de filtrer la liste des contacts", eee); - } finally { - WaoContextO.closeTransaction(transaction); - } - return results; +// if (log.isDebugEnabled()) { +// long stopTime = System.currentTimeMillis(); +// log.debug("W:[ getContacts ] Time = " + +// DurationFormatUtils.formatDurationHMS( +// stopTime - startTime)); +// } +// +// //transaction.closeContext(); +// } catch (Exception eee) { +// context.serviceException(transaction, +// "Impossible de filtrer la liste des contacts", eee); +// } finally { +// context.closeTransaction(transaction); +// } +// return results; } @Override - public int getNbContacts(ContactFilter filter) throws WaoExceptionO { - TopiaContext transaction = null; - int result = 0; - try { - long startTime = 0; - if (log.isDebugEnabled()) { - startTime = System.currentTimeMillis(); - } - transaction = rootContext.beginTransaction(); + public int executeGetNbContacts(TopiaContext transaction, + ContactFilter filter) throws TopiaException { +// TopiaContext transaction = null; +// int result = 0; +// try { +// long startTime = 0; +// if (log.isDebugEnabled()) { +// startTime = System.currentTimeMillis(); +// } +// transaction = rootContext.beginTransaction(); ContactDAO dao = WaoDAOHelper.getContactDAO(transaction); TopiaQuery query = dao.createQuery("C"); query = filter.prepareQueryForContact(query); - result = query.executeCount(); + return query.executeCount(); - if (log.isDebugEnabled()) { - long stopTime = System.currentTimeMillis(); - log.debug("W:[ getNbContacts ] Time = " + - DurationFormatUtils.formatDurationHMS( - stopTime - startTime)); - } - - //transaction.closeContext(); - } catch (Exception eee) { - WaoContextO.serviceException(transaction, - "Impossible de compter le nombre de contacts filtrés", eee); - } finally { - WaoContextO.closeTransaction(transaction); - } - return result; +// if (log.isDebugEnabled()) { +// long stopTime = System.currentTimeMillis(); +// log.debug("W:[ getNbContacts ] Time = " + +// DurationFormatUtils.formatDurationHMS( +// stopTime - startTime)); +// } +// +// //transaction.closeContext(); +// } catch (Exception eee) { +// context.serviceException(transaction, +// "Impossible de compter le nombre de contacts filtrés", eee); +// } finally { +// context.closeTransaction(transaction); +// } +// return result; } @Override - public Contact getNewContact(WaoUser user, SampleRow row, Boat boat) { + public Contact executeGetNewContact(WaoUser user, SampleRow row, Boat boat) { Contact result = new ContactImpl(); result.setObserver(user); result.setSampleRow(row); @@ -187,14 +189,15 @@ } @Override - public void saveContact(Contact contact, boolean delete) throws WaoExceptionO { - TopiaContext transaction = null; - try { - long startTime = 0; - if (log.isDebugEnabled()) { - startTime = System.currentTimeMillis(); - } - transaction = rootContext.beginTransaction(); + public void executeSaveContact(TopiaContext transaction, + Contact contact, boolean delete) throws TopiaException { +// TopiaContext transaction = null; +// try { +// long startTime = 0; +// if (log.isDebugEnabled()) { +// startTime = System.currentTimeMillis(); +// } +// transaction = rootContext.beginTransaction(); ContactDAO dao = WaoDAOHelper.getContactDAO(transaction); @@ -202,7 +205,7 @@ log.debug("Create date : " + contact.getTopiaCreateDate()); } - WaoContextO.prepareTopiaId(Contact.class, contact); + context.prepareTopiaId(Contact.class, contact); if (delete) { dao.delete(contact); } else { @@ -211,29 +214,29 @@ transaction.commitTransaction(); - if (log.isDebugEnabled()) { - long stopTime = System.currentTimeMillis(); - log.debug("W:[ saveContact ] Time = " + - DurationFormatUtils.formatDurationHMS( - stopTime - startTime)); - } - //transaction.closeContext(); - } catch (Exception eee) { - WaoContextO.serviceException(transaction, - "Impossible de sauvegarder le contact", eee); - } finally { - WaoContextO.closeTransaction(transaction); - } +// if (log.isDebugEnabled()) { +// long stopTime = System.currentTimeMillis(); +// log.debug("W:[ saveContact ] Time = " + +// DurationFormatUtils.formatDurationHMS( +// stopTime - startTime)); +// } +// //transaction.closeContext(); +// } catch (Exception eee) { +// context.serviceException(transaction, +// "Impossible de sauvegarder le contact", eee); +// } finally { +// context.closeTransaction(transaction); +// } } @Override - public InputStream exportContactCsv(ContactFilter filter) - throws WaoExceptionO { - TopiaContext transaction = null; - InputStream result = null; + public InputStream executeExportContactCsv(TopiaContext transaction, + ContactFilter filter) throws Exception { +// TopiaContext transaction = null; +// InputStream result = null; CsvWriter writer = null; try { - transaction = rootContext.beginTransaction(); +// transaction = rootContext.beginTransaction(); File file = File.createTempFile("wao-contacts-", ".csv"); file.deleteOnExit(); @@ -243,7 +246,7 @@ } FileOutputStream output = new FileOutputStream(file); - writer = new CsvWriter(output, ',', WaoContextO.getCsvCharset()); + writer = new CsvWriter(output, ',', context.getCsvCharset()); ExportHelper<ContactHeader> export = new ExportHelper<ContactHeader>(writer, CONTACT.getTotalHeaders()) { @@ -347,31 +350,35 @@ export.writeRecord(); } - result = new FileInputStream(file); + return new FileInputStream(file); //transaction.closeContext(); } catch (Exception eee) { - WaoContextO.serviceException(transaction, - "Impossible d'exporter les contacts", eee); + throw eee; +// context.serviceException(transaction, +// "Impossible d'exporter les contacts", eee); } finally { if (writer != null) { writer.close(); } - WaoContextO.closeTransaction(transaction); +// context.closeTransaction(transaction); } - return result; +// return result; } @Override - public ImportResults importContactCsv(WaoUser user, InputStream input) throws WaoExceptionO { - TopiaContext transaction = null; + public ImportResults executeImportContactCsv(TopiaContext transaction, + WaoUser user, InputStream input) + throws TopiaException, IOException, + WaoBusinessException, ParseException { +// TopiaContext transaction = null; ImportResults result = new ImportResultsImpl(); int currRow = 1; - CsvReader reader = null; - try { - transaction = rootContext.beginTransaction(); +// CsvReader reader = null; +// try { +// transaction = rootContext.beginTransaction(); - reader = new CsvReader(input, WaoContextO.getCsvCharset()); + CsvReader reader = new CsvReader(input, context.getCsvCharset()); reader.readHeaders(); ContactDAO dao = WaoDAOHelper.getContactDAO(transaction); @@ -549,23 +556,23 @@ transaction.commitTransaction(); //transaction.closeContext(); - } catch (ParseException eee) { - WaoContextO.serviceException(transaction, - "Erreur ligne " + currRow + " : " + - "Le format des dates est incorrect, il doit être de la forme : JJ/MM/AAAA", eee); - } catch (Exception eee) { - if (log.isDebugEnabled()) { - try { - log.debug("Ligne : " + currRow + " :: " + Arrays.toString(reader.getValues())); - } catch (IOException ex) { - log.error("Reader error", ex); - } - } - WaoContextO.serviceException(transaction, - "Impossible d'importer les contacts", eee); - } finally { - WaoContextO.closeTransaction(transaction); - } +// } catch (ParseException eee) { +// context.serviceException(transaction, +// "Erreur ligne " + currRow + " : " + +// "Le format des dates est incorrect, il doit être de la forme : JJ/MM/AAAA", eee); +// } catch (Exception eee) { +// if (log.isDebugEnabled()) { +// try { +// log.debug("Ligne : " + currRow + " :: " + Arrays.toString(reader.getValues())); +// } catch (IOException ex) { +// log.error("Reader error", ex); +// } +// } +// context.serviceException(transaction, +// "Impossible d'importer les contacts", eee); +// } finally { +// context.closeTransaction(transaction); +// } return result; } Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSamplingImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSamplingImpl.java 2010-04-01 16:46:41 UTC (rev 407) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSamplingImpl.java 2010-04-01 17:14:29 UTC (rev 408) @@ -26,9 +26,7 @@ import fr.ifremer.wao.io.ImportHelper; import fr.ifremer.wao.WaoBusinessException; import fr.ifremer.wao.WaoBusinessException.Type; -import fr.ifremer.wao.WaoExceptionO; import fr.ifremer.wao.WaoDAOHelper; -import fr.ifremer.wao.WaoException; import fr.ifremer.wao.bean.FacadeRow; import fr.ifremer.wao.bean.FacadeRowImpl; import fr.ifremer.wao.bean.ImportResults; @@ -56,7 +54,6 @@ import java.util.List; import java.util.Map; import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.time.DurationFormatUtils; import org.nuiton.topia.TopiaContext; import org.nuiton.topia.TopiaException; import org.nuiton.topia.framework.TopiaQuery; @@ -83,25 +80,16 @@ private static final Logger log = LoggerFactory.getLogger(ServiceSamplingImpl.class); -// protected TopiaContext rootContext; -// public ServiceSamplingImpl() { -// rootContext = context.getTopiaRootContext(); prepareBinderForProfession(); } @Override public void executeCreateUpdateSampleRow(TopiaContext transaction, SampleRow row, List<Boat> boats, SampleRowLog rowLog) - throws TopiaException, Exception { -// TopiaContext transaction = null; + throws Exception { TopiaContext transaction2 = null; try { -// long startTime = 0; -// if (log.isDebugEnabled()) { -// startTime = System.currentTimeMillis(); -// } -// transaction = rootContext.beginTransaction(); SampleRowLogDAO logDAO = WaoDAOHelper.getSampleRowLogDAO(transaction); context.prepareTopiaId(SampleRowLog.class, rowLog); @@ -248,24 +236,10 @@ } transaction.commitTransaction(); -// if (log.isDebugEnabled()) { -// long stopTime = System.currentTimeMillis(); -// log.debug("W:[ createUpdateSampleRow ] Time = " + -// DurationFormatUtils.formatDurationHMS( -// stopTime - startTime)); -// } - //transaction.closeContext(); } catch (Exception eee) { throw eee; -// context.serviceException(transaction, -// "Impossible de sauvegarder la ligne d'échantillon", eee); } finally { -// try { - transaction2.closeContext(); -// } catch (TopiaException eee) { -// log.error("Error closing transaction", eee); -// } -// context.closeTransaction(transaction); + transaction2.closeContext(); } } @@ -282,379 +256,174 @@ // fishingZoneDAO.update(zoneFromDB); // } -// @Override -// public List<SampleRowLog> getSampleRowLogs(SampleRow sampleRow) throws WaoException { -// TopiaContext transaction = null; -// List<SampleRowLog> results = new ArrayList<SampleRowLog>(); -// try { -// transaction = rootContext.beginTransaction(); -// -// SampleRowLogDAO dao = WaoDAOHelper.getSampleRowLogDAO(transaction); -// results = dao.createQuery().add(SampleRowLog.SAMPLE_ROW, sampleRow).addOrderDesc(TopiaEntity.TOPIA_CREATE_DATE).executeToEntityList(); -// -// transaction.closeContext(); -// } catch (Exception eee) { -// WaoContext.serviceException(transaction, -// "Impossible de récupérer l'historique de la ligne d'échantillonnage", eee); -// } -// return results; -// } - @Override public FacadeRow executeGetSampleRowsOrderedByFishingZone( TopiaContext transaction, - PeriodDates period, Company company) throws TopiaException { -// TopiaContext transaction = null; + PeriodDates period, Company company) + throws TopiaException, IllegalArgumentException { FacadeRow result = new FacadeRowImpl(); -// try { -// long startTime = 0; -// if (log.isDebugEnabled()) { -// startTime = System.currentTimeMillis(); -// } - if (period.getFromDate() == null || period.getThruDate() == null) { - throw new IllegalArgumentException("PeriodBegin date and/or PeriodEnd date can't be null !"); - } -// transaction = rootContext.beginTransaction(); + if (period.getFromDate() == null || period.getThruDate() == null) { + throw new IllegalArgumentException("PeriodBegin date and/or " + + "PeriodEnd date can't be null !"); + } - SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction); + SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction); - TopiaQuery query = dao.createQuery("S").addDistinct(). - addFrom(FishingZone.class.getName() + " F"). - add("S IN elements(F." + FishingZone.SAMPLE_ROW + ")"); + TopiaQuery query = dao.createQuery("S").addDistinct(). + addFrom(FishingZone.class.getName() + " F"). + add("S IN elements(F." + FishingZone.SAMPLE_ROW + ")"); - if (company != null) { - query.add("S." + SampleRow.COMPANY, company); - } + if (company != null) { + query.add("S." + SampleRow.COMPANY, company); + } - // Prepare period dates - period.initDayOfMonthExtremities(); - query.add("S." + SampleRow.PERIOD_BEGIN, Op.LT, period.getThruDate()). - add("S." + SampleRow.PERIOD_END, Op.GT, period.getFromDate()); + // Prepare period dates + period.initDayOfMonthExtremities(); + query.add("S." + SampleRow.PERIOD_BEGIN, Op.LT, period.getThruDate()). + add("S." + SampleRow.PERIOD_END, Op.GT, period.getFromDate()); - // Order By facade, sector, districtCode, sampleRowCode - String zoneOrder = "F." + FishingZone.FACADE_NAME + " , F." + FishingZone.SECTOR_NAME + ", F." + FishingZone.DISTRICT_CODE; - query.addOrder(zoneOrder).addOrder("S." + SampleRow.CODE).addSelect(zoneOrder); - // Load data - //query.addLoad(SampleRow.PROFESSION, SampleRow.COMPANY); + // Order By facade, sector, districtCode, sampleRowCode + String zoneOrder = "F." + FishingZone.FACADE_NAME + " , F." + FishingZone.SECTOR_NAME + ", F." + FishingZone.DISTRICT_CODE; + query.addOrder(zoneOrder).addOrder("S." + SampleRow.CODE).addSelect(zoneOrder); + // Load data + //query.addLoad(SampleRow.PROFESSION, SampleRow.COMPANY); -// if (log.isDebugEnabled()) { -// long stopTime = System.currentTimeMillis(); -// log.debug("W:[ before query getSampleRowsOrderedByFishingZone ] Time = " + -// DurationFormatUtils.formatDurationHMS( -// stopTime - startTime)); -// startTime = System.currentTimeMillis(); -// } - - if (log.isDebugEnabled()) { - log.debug("Query : " + query); - } + if (log.isDebugEnabled()) { + log.debug("Query : " + query); + } - query.addLoad(SampleRow.SAMPLE_MONTH); - List<SampleRow> results = dao.findAllByQuery(query); + query.addLoad(SampleRow.SAMPLE_MONTH); + List<SampleRow> results = dao.findAllByQuery(query); - for (SampleRow row : results) { - // use FacadeRow to complete ordering using maps - result.addRow(row); - } - -// if (log.isDebugEnabled()) { -// long stopTime = System.currentTimeMillis(); -// log.debug("W:[ getSampleRowsOrderedByFishingZone exec query ] Time = " + -// DurationFormatUtils.formatDurationHMS( -// stopTime - startTime)); -// } -// -// //transaction.closeContext(); -// } catch (Exception eee) { -// context.serviceException(transaction, -// "Impossible de récupérer la liste des lignes du plan d'échantillonnage", eee); -// } finally { -// context.closeTransaction(transaction); -// } + for (SampleRow row : results) { + // use FacadeRow to complete ordering using maps + result.addRow(row); + } return result; } @Override public List<String> executeGetPrograms(TopiaContext transaction, Company company) throws TopiaException { -// TopiaContext transaction = null; -// List<String> results = new ArrayList<String>(); -// try { -// long startTime = 0; -// if (log.isDebugEnabled()) { -// startTime = System.currentTimeMillis(); -// } -// transaction = rootContext.beginTransaction(); - SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction); - TopiaQuery query = dao.createQuery(); + SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction); + TopiaQuery query = dao.createQuery(); - if (company != null) { - query.add(SampleRow.COMPANY, company); - } + if (company != null) { + query.add(SampleRow.COMPANY, company); + } - return (List<String>)query.addDistinct(). - setSelect(SampleRow.PROGRAM_NAME).execute(); - -// if (log.isDebugEnabled()) { -// long stopTime = System.currentTimeMillis(); -// log.debug("W:[ getPrograms ] Time = " + -// DurationFormatUtils.formatDurationHMS( -// stopTime - startTime)); -// } -// -// //transaction.closeContext(); -// } catch (Exception eee) { -// context.serviceException(transaction, -// "Impossible de charger la liste des programmes", eee); -// } finally { -// context.closeTransaction(transaction); -// } -// return results; + return (List<String>)query.addDistinct(). + setSelect(SampleRow.PROGRAM_NAME).execute(); } @Override public List<SampleRow> executeGetSampleRowsByFilter( TopiaContext transaction, SamplingFilter filter) throws TopiaException { -// TopiaContext transaction = null; -// List<SampleRow> results = new ArrayList<SampleRow>(); -// try { -// long startTime = 0; -// if (log.isDebugEnabled()) { -// startTime = System.currentTimeMillis(); -// } -// transaction = rootContext.beginTransaction(); - SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction); - - TopiaQuery query = dao.createQuery("S"). - addDistinct().addOrder("S." + SampleRow.CODE); + SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction); - query = filter.prepareQueryForSampling(query, "S"); + TopiaQuery query = dao.createQuery("S"). + addDistinct().addOrder("S." + SampleRow.CODE); -// if (log.isDebugEnabled()) { -// long stopTime = System.currentTimeMillis(); -// log.debug("W:[ after prepareQueryForSampling ] Time = " + -// DurationFormatUtils.formatDurationHMS( -// stopTime - startTime)); -// startTime = System.currentTimeMillis(); -// } + query = filter.prepareQueryForSampling(query, "S"); - if (log.isDebugEnabled()) { - log.debug("Query : " + query); - } + if (log.isDebugEnabled()) { + log.debug("Query : " + query); + } - return dao.findAllByQuery(query); - -// if (log.isDebugEnabled()) { -// long stopTime = System.currentTimeMillis(); -// log.debug("W:[ getSampleRowsByFilter exec query ] Time = " + -// DurationFormatUtils.formatDurationHMS( -// stopTime - startTime)); -// startTime = System.currentTimeMillis(); -// } -// -// //transaction.closeContext(); -// } catch (Exception eee) { -// context.serviceException(transaction, -// "Impossible de récupérer la liste des lignes du plan d'échantillonnage", eee); -// } finally { -// context.closeTransaction(transaction); -// } -// return results; + return dao.findAllByQuery(query); } @Override public SampleRow executeGetSampleRow(TopiaContext transaction, List<Object> errorArgs, String sampleRowId) throws TopiaException { -// TopiaContext transaction = null; -// SampleRow result = null; -// try { -// long startTime = 0; -// if (log.isDebugEnabled()) { -// startTime = System.currentTimeMillis(); -// } -// transaction = rootContext.beginTransaction(); - errorArgs.add(sampleRowId); + errorArgs.add(sampleRowId); - SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction); + SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction); - SampleRow result = dao.findByTopiaId(sampleRowId); + SampleRow result = dao.findByTopiaId(sampleRowId); - result.sizeSampleMonth(); - result.sizeElligibleBoat(); + result.sizeSampleMonth(); + result.sizeElligibleBoat(); - return result; - -// if (log.isDebugEnabled()) { -// long stopTime = System.currentTimeMillis(); -// log.debug("W:[ getSampleRow ] Time = " + -// DurationFormatUtils.formatDurationHMS( -// stopTime - startTime)); -// } -// -// //transaction.closeContext(); -// } catch (Exception eee) { -// context.serviceException(transaction, -// "Impossible de charger la ligne d'échantillon ayant pour" + -// " identifiant : " + sampleRowId, -// eee); -// } finally { -// context.closeTransaction(transaction); -// } -// return result; + return result; } @Override public SampleRow executeGetSampleRowByCode(TopiaContext transaction, List<Object> errorArgs, WaoUser user, String sampleRowCode) throws TopiaException, WaoBusinessException { -// TopiaContext transaction = null; -// SampleRow result = null; -// try { -// long startTime = 0; -// if (log.isDebugEnabled()) { -// startTime = System.currentTimeMillis(); -// } -// if (log.isInfoEnabled()) { -// log.info("W:[ getSampleRowByCode ] : " + -// "sampleRowCode = " + sampleRowCode); -// } -// transaction = rootContext.beginTransaction(); - errorArgs.add(sampleRowCode); + errorArgs.add(sampleRowCode); - SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction); + SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction); - TopiaQuery query = dao.createQuery(). - add(SampleRow.CODE, sampleRowCode); + TopiaQuery query = dao.createQuery(). + add(SampleRow.CODE, sampleRowCode); - if (!user.isAdmin()) { - query.add(SampleRow.COMPANY, user.getCompany()); - } + if (!user.isAdmin()) { + query.add(SampleRow.COMPANY, user.getCompany()); + } - query.addLoad(SampleRow.SAMPLE_ROW_LOG); - SampleRow result = dao.findByQuery(query); + query.addLoad(SampleRow.SAMPLE_ROW_LOG); + SampleRow result = dao.findByQuery(query); - if (result == null) { - throw new WaoBusinessException(Type.NOT_EXISTS, - ServiceSampling.class, "La ligne du plan avec " + - "pour code " + sampleRowCode + " est introuvable !"); - } + if (result == null) { + throw new WaoBusinessException(Type.NOT_EXISTS, + ServiceSampling.class, "La ligne du plan avec " + + "pour code " + sampleRowCode + " est introuvable !"); + } - return result; - -// if (log.isDebugEnabled()) { -// long stopTime = System.currentTimeMillis(); -// log.debug("W:[ getSampleRowByCode ] Time = " + -// DurationFormatUtils.formatDurationHMS( -// stopTime - startTime)); -// } -// -// } catch (Exception eee) { -// context.serviceException(transaction, -// "Impossible de charger la ligne " + -// "d'échantillon ayant pour code : " + sampleRowCode, -// eee); -// } finally { -// context.closeTransaction(transaction); -// } -// return result; + return result; } @Override public void executeDeleteSampleRow(TopiaContext transaction, List<Object> errorArgs, SampleRow sampleRow) throws TopiaException { -// TopiaContext transaction = null; -// try { -// long startTime = 0; -// if (log.isDebugEnabled()) { -// startTime = System.currentTimeMillis(); -// } -// transaction = rootContext.beginTransaction(); - errorArgs.add(sampleRow.getCode()); + errorArgs.add(sampleRow.getCode()); - SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction); + SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction); - SampleRow row = dao.findByTopiaId(sampleRow.getTopiaId()); + SampleRow row = dao.findByTopiaId(sampleRow.getTopiaId()); - dao.delete(row); + dao.delete(row); - transaction.commitTransaction(); - -// if (log.isDebugEnabled()) { -// long stopTime = System.currentTimeMillis(); -// log.debug("W:[ deleteSampleRow ] Time = " + -// DurationFormatUtils.formatDurationHMS( -// stopTime - startTime)); -// } -// //transaction.closeContext(); -// } catch (Exception eee) { -// context.serviceException(transaction, -// "Impossible de supprimer la ligne d'échantillon : " + sampleRow.getCode(), -// eee); -// } finally { -// context.closeTransaction(transaction); -// } + transaction.commitTransaction(); } @Override public String executeGetNewSampleRowCode(TopiaContext transaction, Date beginDate) throws TopiaException { -// TopiaContext transaction = null; -// String result = null; if (beginDate == null) { return null; } -// try { -// long startTime = 0; -// if (log.isDebugEnabled()) { -// startTime = System.currentTimeMillis(); -// } -// transaction = rootContext.beginTransaction(); - Calendar begin = new GregorianCalendar(); - begin.setTime(beginDate); - int year = begin.get(Calendar.YEAR); + Calendar begin = new GregorianCalendar(); + begin.setTime(beginDate); + int year = begin.get(Calendar.YEAR); - SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction); - TopiaQuery query = - dao.createQuery().add(SampleRow.CODE, Op.LIKE, year + "_%"); + SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction); + TopiaQuery query = + dao.createQuery().add(SampleRow.CODE, Op.LIKE, year + "_%"); - String maxCode = - query.executeToString("MAX(" + SampleRow.CODE + ")"); + String maxCode = + query.executeToString("MAX(" + SampleRow.CODE + ")"); - if (log.isDebugEnabled()) { - log.debug("Max code found : " + maxCode); - } + if (log.isDebugEnabled()) { + log.debug("Max code found : " + maxCode); + } - int num = 1; - if (!StringUtils.isEmpty(maxCode)) { - String[] part = maxCode.split("_"); - num = Integer.parseInt(part[1]) + 1; - } - String str = StringUtils.leftPad("" + num, 4, "0"); - return year + "_" + str; - -// if (log.isDebugEnabled()) { -// long stopTime = System.currentTimeMillis(); -// log.debug("W:[ getNewSampleRowCode ] Time = " + -// DurationFormatUtils.formatDurationHMS( -// stopTime - startTime)); -// } -// -// //transaction.closeContext(); -// } catch (Exception eee) { -// context.serviceException(transaction, -// "Impossible de récupérer un nouveau code pour une ligne d'échantillonnage", -// eee); -// } finally { -// context.closeTransaction(transaction); -// } -// return result; + int num = 1; + if (!StringUtils.isEmpty(maxCode)) { + String[] part = maxCode.split("_"); + num = Integer.parseInt(part[1]) + 1; + } + String str = StringUtils.leftPad("" + num, 4, "0"); + return year + "_" + str; } @Override @@ -717,12 +486,9 @@ @Override public InputStream executeExportSamplingPlanCsv(TopiaContext transaction, List<Object> errorArgs, WaoUser user, PeriodDates period) - throws TopiaException, Exception { -// TopiaContext transaction = null; -// InputStream result = null; + throws Exception { CsvWriter writer = null; try { -// transaction = rootContext.beginTransaction(); DateFormat dateFormat = SAMPLING.getDateFormat(); errorArgs.add(dateFormat.format(period.getFromDate())); @@ -841,16 +607,10 @@ } catch (Exception eee) { throw eee; -// DateFormat dateFormat = SAMPLING.getDateFormat(); -// context.serviceException(transaction, -// "Impossible d'exporter le plan d'échantillonnage sur la période du " + -// dateFormat.format(period.getFromDate()) + " au " + -// dateFormat.format(period.getThruDate()), eee); } finally { if (writer != null) { writer.close(); } -// context.closeTransaction(transaction); } } @@ -860,85 +620,82 @@ List<Object> errorArgs, InputStream input) throws WaoBusinessException, IOException, TopiaException, ParseException { -// TopiaContext transaction = null; + ImportResults result = new ImportResultsImpl(); - //int[] result = new int[3]; int currRow = 0; SampleRow row = null; -// try { -// transaction = rootContext.beginTransaction(); - errorArgs.add(currRow); - errorArgs.add(null); + errorArgs.add(currRow); + errorArgs.add(null); - CsvReader reader = new CsvReader(input, context.getCsvCharset()); - reader.readHeaders(); + CsvReader reader = new CsvReader(input, context.getCsvCharset()); + reader.readHeaders(); - SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction); + SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction); - //int nbImported = 0; - //int nbRefused = 0; + //int nbImported = 0; + //int nbRefused = 0; - while(reader.readRecord()) { + while(reader.readRecord()) { - currRow++; + currRow++; - if (log.isTraceEnabled()) { - log.trace(" " + Arrays.asList(reader.getValues())); - } + if (log.isTraceEnabled()) { + log.trace(" " + Arrays.asList(reader.getValues())); + } - String code = ImportHelper.readSampleRowCode(reader); //reader.get(SAMPLING.PLAN_CODE.name()).trim(); + String code = ImportHelper.readSampleRowCode(reader); //reader.get(SAMPLING.PLAN_CODE.name()).trim(); - if (StringUtils.isEmpty(code)) { - continue; - } + if (StringUtils.isEmpty(code)) { + continue; + } - errorArgs.set(0, currRow); - errorArgs.set(1, code); - - String districts = ImportHelper.read(reader, - FISHING_ZONE.PECHE_DIVISION); - - row = dao.findByCode(code); - // Refuse existing SampleRow - if (row != null) { - result.addError(currRow, "[CODE = " + code + "] refusé : Code déjà existant"); - result.incNbRefused(); - // Refuse Fishing zones empty - } else if (StringUtils.isEmpty(districts)) { - result.addError(currRow, "[CODE = " + code + "] refusé : Zone de pêche non renseigné"); - result.incNbRefused(); //nbRefused++; - } else { - row = dao.create(SampleRow.CODE, code); + errorArgs.set(0, currRow); + errorArgs.set(1, code); - String companyName = ImportHelper.read(reader, SAMPLING.SOCIETE_NOM); + String districts = ImportHelper.read(reader, + FISHING_ZONE.PECHE_DIVISION); - // Create link with company if set in file - if (!StringUtils.isEmpty(companyName)) { - CompanyDAO companyDAO = WaoDAOHelper.getCompanyDAO(transaction); - Company company = companyDAO.findByName(companyName); - if (company == null) { - throw new WaoBusinessException(Type.IMPORT_ERROR, this.getClass(), - "Erreur à la ligne " + currRow + " [CODE = " + code + "] : " + - "La société portant le nom '" + companyName + "' n'existe pas dans l'application"); - } - row.setCompany(company); + row = dao.findByCode(code); + // Refuse existing SampleRow + if (row != null) { + result.addError(currRow, "[CODE = " + code + "] refusé : Code déjà existant"); + result.incNbRefused(); + // Refuse Fishing zones empty + } else if (StringUtils.isEmpty(districts)) { + result.addError(currRow, "[CODE = " + code + "] refusé : Zone de pêche non renseigné"); + result.incNbRefused(); //nbRefused++; + } else { + row = dao.create(SampleRow.CODE, code); + + String companyName = ImportHelper.read(reader, SAMPLING.SOCIETE_NOM); + + // Create link with company if set in file + if (!StringUtils.isEmpty(companyName)) { + CompanyDAO companyDAO = WaoDAOHelper.getCompanyDAO(transaction); + Company company = companyDAO.findByName(companyName); + if (company == null) { + throw new WaoBusinessException(Type.IMPORT_ERROR, this.getClass(), + "Erreur à la ligne " + currRow + " [CODE = " + code + "] : " + + "La société portant le nom '" + companyName + "' n'existe pas dans l'application"); } + row.setCompany(company); + } - // Import profession. Creation if not exist - Profession profession = importProfession(transaction, reader); - row.setProfession(profession); + // Import profession. Creation if not exist + Profession profession = importProfession(transaction, reader); + row.setProfession(profession); - // Import zones and set them to the row - // throw WaoException if FishingZone doesn't exist - importFishingZones(transaction, districts, currRow, row); + // Import zones and set them to the row + // throw WaoException if FishingZone doesn't exist + importFishingZones(transaction, districts, currRow, row); - updateRow(transaction, row, reader); - result.incNbImported(); //nbImported++; - } - // Commit row by row - transaction.commitTransaction(); + updateRow(transaction, row, reader); + result.incNbImported(); //nbImported++; } + // Commit row by row + transaction.commitTransaction(); + } //transaction.closeContext(); @@ -982,17 +739,6 @@ String especes = ImportHelper.read(reader, SAMPLING.METIER_ESPECES); ProfessionDAO dao = WaoDAOHelper.getProfessionDAO(transaction); -// Map<String, Object> existParams = new HashMap<String, Object>(); -// existParams.put(Profession.CODE_DCF5, codeDCF5); -// existParams.put(Profession.MESH_SIZE, maillage); -// existParams.put(Profession.SIZE, taille); -// existParams.put(Profession.OTHER, autre); -// -// Profession profession = dao.findByProperties(existParams); -// -// if (profession == null) { -// profession = dao.create(); -// } // Always create a new profession Profession profession = dao.create(); Modified: trunk/wao-business/src/main/resources/i18n/wao-business-en_GB.properties =================================================================== --- trunk/wao-business/src/main/resources/i18n/wao-business-en_GB.properties 2010-04-01 16:46:41 UTC (rev 407) +++ trunk/wao-business/src/main/resources/i18n/wao-business-en_GB.properties 2010-04-01 17:14:29 UTC (rev 408) @@ -22,6 +22,12 @@ wao.error.serviceBoat.getNbBoatsByFilter= wao.error.serviceBoat.importActivityCalendarCsv= wao.error.serviceBoat.importBoatCsv= +wao.error.serviceContact.exportContactCsv= +wao.error.serviceContact.getContacts= +wao.error.serviceContact.getNbContacts= +wao.error.serviceContact.getNewContact= +wao.error.serviceContact.importContactCsv= +wao.error.serviceContact.saveContact= wao.error.serviceNews.getNews= wao.error.serviceNews.saveNews= wao.error.serviceReferential.getFacades= Modified: trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties =================================================================== --- trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties 2010-04-01 16:46:41 UTC (rev 407) +++ trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties 2010-04-01 17:14:29 UTC (rev 408) @@ -22,6 +22,12 @@ wao.error.serviceBoat.getNbBoatsByFilter=Impossible de filtrer la liste des navires wao.error.serviceBoat.importActivityCalendarCsv=Probl\u00E8me d'import du fichier CSV des calendriers d'activit\u00E9 wao.error.serviceBoat.importBoatCsv=Probl\u00E8me d'import du fichier CSV. V\u00E9rifiez l'en-t\u00EAte du fichier \: [ NAVS_COD,CARN_NOM,CARN_LONGUEUR_HT,CARN_ANNEE,QUARTIER_IMMA,PER_COD,PER_NOM,PER_PRENOM,NAVS_ACTIVE ]. Voir documentation pour plus de d\u00E9tails. +wao.error.serviceContact.exportContactCsv= +wao.error.serviceContact.getContacts= +wao.error.serviceContact.getNbContacts= +wao.error.serviceContact.getNewContact= +wao.error.serviceContact.importContactCsv= +wao.error.serviceContact.saveContact= wao.error.serviceNews.getNews=Impossible de r\u00E9cup\u00E9rer l'ensemble des news wao.error.serviceNews.saveNews=Impossible d'enregistrer la news ayant pour titre '%1$s' wao.error.serviceReferential.getFacades=Impossible de charger la liste des facades @@ -29,18 +35,18 @@ wao.error.serviceReferential.getProfessions=Impossible de charger la liste des m\u00E9tiers wao.error.serviceReferential.getSectors=Impossible de charger la liste des zones de p\u00EAche wao.error.serviceReferential.importFishingZoneCsv=Probl\u00E8me d'import du fichier CSV. V\u00E9rifiez l'en-t\u00EAte du fichier \: [ PECHE_DIVISION,PECHE_ZONE,PECHE_FACADE ]. Voir documentation pour plus de d\u00E9tails. -wao.error.serviceSampling.createUpdateSampleRow= -wao.error.serviceSampling.deleteSampleRow= -wao.error.serviceSampling.exportSamplingPlanCsv= +wao.error.serviceSampling.createUpdateSampleRow=Impossible de sauvegarder la ligne d'\u00E9chantillon +wao.error.serviceSampling.deleteSampleRow=Impossible de supprimer la ligne d'\u00E9chantillon \: %1$s +wao.error.serviceSampling.exportSamplingPlanCsv=Impossible d'exporter le plan d'\u00E9chantillonnage sur la p\u00E9riode du %1$s au %2$s wao.error.serviceSampling.getNewProfession= wao.error.serviceSampling.getNewSampleMonth= wao.error.serviceSampling.getNewSampleRow= -wao.error.serviceSampling.getNewSampleRowCode= -wao.error.serviceSampling.getPrograms= -wao.error.serviceSampling.getSampleRow= -wao.error.serviceSampling.getSampleRowByCode= -wao.error.serviceSampling.getSampleRowsByFilter= -wao.error.serviceSampling.getSampleRowsOrderedByFishingZone= +wao.error.serviceSampling.getNewSampleRowCode=Impossible de r\u00E9cup\u00E9rer un nouveau code pour une ligne d'\u00E9chantillonnage +wao.error.serviceSampling.getPrograms=Impossible de charger la liste des programmes +wao.error.serviceSampling.getSampleRow=Impossible de charger la ligne d'\u00E9chantillon ayant pour identifiant \: %1$s +wao.error.serviceSampling.getSampleRowByCode=Impossible de charger la ligne d'\u00E9chantillon ayant pour code %1$s +wao.error.serviceSampling.getSampleRowsByFilter=Impossible de r\u00E9cup\u00E9rer la liste des lignes du plan d'\u00E9chantillonnage +wao.error.serviceSampling.getSampleRowsOrderedByFishingZone=Impossible de r\u00E9cup\u00E9rer la liste des lignes du plan d'\u00E9chantillonnage wao.error.serviceSampling.importSamplingPlanCsv= wao.error.serviceUser.connect=Une erreur est survenue lors de la demande de connexion wao.error.serviceUser.createUpdateCompany=Impossible de cr\u00E9er ou de mettre \u00E0 jour la soci\u00E9t\u00E9 Modified: trunk/wao-business/src/main/xmi/wao.zargo =================================================================== (Binary files differ) Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/TestManager.java =================================================================== --- trunk/wao-business/src/test/java/fr/ifremer/wao/TestManager.java 2010-04-01 16:46:41 UTC (rev 407) +++ trunk/wao-business/src/test/java/fr/ifremer/wao/TestManager.java 2010-04-01 17:14:29 UTC (rev 408) @@ -138,7 +138,7 @@ public ServiceSampling getServiceSampling() throws WaoExceptionO { ServiceSamplingImpl instance = new ServiceSamplingImpl(); - instance.setContext(context); + instance.setContext(getContext()); return instance; } @@ -156,7 +156,7 @@ public ServiceContact getServiceContact() throws WaoExceptionO { ServiceContactImpl instance = new ServiceContactImpl(); -// instance.setContext(context); + instance.setContext(context); return instance; } Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/ExportStreamResponse.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/ExportStreamResponse.java 2010-04-01 16:46:41 UTC (rev 407) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/ExportStreamResponse.java 2010-04-01 17:14:29 UTC (rev 408) @@ -21,7 +21,7 @@ package fr.ifremer.wao.ui.data; -import fr.ifremer.wao.WaoContextO; +import fr.ifremer.wao.WaoUtils; import java.util.Date; import org.apache.tapestry5.StreamResponse; import org.apache.tapestry5.services.Response; @@ -68,7 +68,7 @@ */ @Override public void prepareResponse(Response response) { - Date current = WaoContextO.getCurrentDate(); + Date current = WaoUtils.getCurrentDate(); filename += "-" + DateUtils.formatDate(current, "dd-MM-yyyy") + ".csv"; response.setHeader("Content-Disposition", "attachment; filename=\"" + filename +"\""); Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Boats.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Boats.java 2010-04-01 16:46:41 UTC (rev 407) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Boats.java 2010-04-01 17:14:29 UTC (rev 408) @@ -22,7 +22,7 @@ package fr.ifremer.wao.ui.pages; import fr.ifremer.wao.WaoBusinessException; -import fr.ifremer.wao.WaoContextO; +import fr.ifremer.wao.WaoException; import fr.ifremer.wao.WaoExceptionO; import fr.ifremer.wao.bean.BoatFilterImpl; import fr.ifremer.wao.entity.Boat; @@ -47,6 +47,7 @@ import fr.ifremer.wao.ui.components.Layout; import fr.ifremer.wao.ui.data.BoatDataSource; import fr.ifremer.wao.ui.data.ExportStreamResponse; +import fr.ifremer.wao.ui.services.WaoManager; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; @@ -613,8 +614,11 @@ /** /////////////////////// GLOBAL TO THE BLOCK /////////////////////// **/ + @Inject + private WaoManager manager; + public boolean isActivityCalendarImportRun() { - return WaoContextO.isActivityCalendarImportRun(); + return manager.isActivityCalendarImportRun(); } public Block getActiveBoatInfosBlock() { Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Contacts.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Contacts.java 2010-04-01 16:46:41 UTC (rev 407) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Contacts.java 2010-04-01 17:14:29 UTC (rev 408) @@ -22,7 +22,7 @@ package fr.ifremer.wao.ui.pages; import fr.ifremer.wao.WaoBusinessException; -import fr.ifremer.wao.WaoContextO; +import fr.ifremer.wao.WaoException; import fr.ifremer.wao.WaoExceptionO; import fr.ifremer.wao.bean.BoatFilter; import fr.ifremer.wao.bean.ContactFilter; @@ -45,6 +45,7 @@ import fr.ifremer.wao.ui.components.Layout; import fr.ifremer.wao.ui.data.ExportStreamResponse; import fr.ifremer.wao.ui.services.ContactModelFactory; +import fr.ifremer.wao.ui.services.WaoManager; import java.io.IOException; import java.io.InputStream; import java.text.DateFormat; @@ -556,6 +557,9 @@ @InjectComponent private Field inputDate; + @Inject + private WaoManager manager; + @Log void onValidateFormFromContactsForm() { contactsForm.clearErrors(); @@ -584,7 +588,7 @@ " ne peut pas être antérieure à celle de début"); } - Date current = WaoContextO.getCurrentDate(); + Date current = manager.getCurrentDate(); if (end != null && end.after(current)) { contactsForm.recordError(endDate, "La date de fin de la marée" + @@ -652,7 +656,7 @@ contactSelectedId = contactEdited.getTopiaId(); oldComment = null; contactEdited = null; - } catch (WaoExceptionO eee) { + } catch (WaoException eee) { layout.addError(eee.getMessage()); } } Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SampleRowForm.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SampleRowForm.java 2010-04-01 16:46:41 UTC (rev 407) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SampleRowForm.java 2010-04-01 17:14:29 UTC (rev 408) @@ -23,6 +23,7 @@ import fr.ifremer.wao.WaoBusinessException; import fr.ifremer.wao.WaoContextO; +import fr.ifremer.wao.WaoException; import fr.ifremer.wao.WaoExceptionO; import fr.ifremer.wao.entity.Boat; import fr.ifremer.wao.entity.Company; @@ -40,6 +41,7 @@ import fr.ifremer.wao.ui.base.GenericSelectModel; import fr.ifremer.wao.ui.base.WaoPage; import fr.ifremer.wao.ui.data.WaoPropertyChangeListener; +import fr.ifremer.wao.ui.services.WaoManager; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -307,6 +309,9 @@ /*************************** PROGRAM & MONTHS *****************************/ + @Inject + private WaoManager manager; + @Persist private SelectModel programSelectModel; @@ -409,7 +414,7 @@ public String getMonthStyle() { String style = " "; - Date current = WaoContextO.getCurrentDate(); + Date current = manager.getCurrentDate(); if (sampleMonth.isCurrentMonth()) { style += "selected"; } else if (current.after(sampleMonth.getPeriodDate())) { Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/AppModule.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/AppModule.java 2010-04-01 16:46:41 UTC (rev 407) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/AppModule.java 2010-04-01 17:14:29 UTC (rev 408) @@ -48,20 +48,8 @@ public class AppModule { public static void bind(ServiceBinder binder) { - // binder.bind(MyServiceInterface.class, MyServiceImpl.class); - - // Make bind() calls on the binder object to define most IoC services. - // Use service builder methods (example below) when the implementation - // is provided inline, or requires more initialization than simply - // invoking the constructor. -// binder.bind(ServiceNews.class, ServiceNewsImpl.class); -// binder.bind(ServiceUser.class, ServiceUserImpl.class); -// binder.bind(ServiceSampling.class, ServiceSamplingImpl.class); -// binder.bind(ServiceReferential.class, ServiceReferentialImpl.class); -// binder.bind(ServiceBoat.class, ServiceBoatImpl.class); - binder.bind(ServiceContact.class, ServiceContactImpl.class); - binder.bind(ContactModelFactory.class); binder.bind(ServiceSynthesis.class, ServiceSynthesisImpl.class); + binder.bind(ContactModelFactory.class); } @EagerLoad @@ -101,6 +89,12 @@ return instance; } + public ServiceContact buildServiceContact(WaoManager manager) { + ServiceContactImpl instance = new ServiceContactImpl(); + instance.setContext(manager.getContext()); + return instance; + } + public static void contributeApplicationDefaults( MappedConfiguration<String, String> configuration) { // Contributions to ApplicationDefaults will override any contributions to Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/WaoManager.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/WaoManager.java 2010-04-01 16:46:41 UTC (rev 407) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/WaoManager.java 2010-04-01 17:14:29 UTC (rev 408) @@ -23,6 +23,7 @@ import fr.ifremer.wao.WaoContextImplementor; import fr.ifremer.wao.WaoProperty; +import java.util.Date; import org.apache.tapestry5.ioc.services.RegistryShutdownListener; import org.nuiton.util.ApplicationConfig; import org.slf4j.Logger; @@ -75,6 +76,10 @@ return context.getConfiguration(); } + public Date getCurrentDate() { + return context.getCurrentDate(); + } + }
participants (1)
-
fdesbois@users.labs.libre-entreprise.org