[Suiviobsmer-commits] r1261 - in trunk: wao-business/src/main/java/fr/ifremer/wao/service wao-ui/src/main/java/fr/ifremer/wao/ui/pages
Author: bleny Date: 2011-05-06 09:53:34 +0000 (Fri, 06 May 2011) New Revision: 1261 Log: fix a bug : print error messages in ObsDeb sampling plan when importing wrong file Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceBoatImpl.java trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSamplingImpl.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/ObsDebSamplingPlan.java Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceBoatImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceBoatImpl.java 2011-05-05 15:09:06 UTC (rev 1260) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceBoatImpl.java 2011-05-06 09:53:34 UTC (rev 1261) @@ -370,8 +370,8 @@ /** * Import boats from a CSV file. Warning, must be UTF-8 encoding. * Use of CsvReader to manage InputStream and create or update boats. - * Header file must be : NAVS_COD,CARN_NOM,CARN_LONGUEUR_HT,CARN_ANNEE, - * QUARTIER_IMMA,PER_COD, PER_NOM,PER_PRENOM. + * Header file must be : NAVS_COD, CARN_NOM, CARN_LONGUEUR_HT, CARN_ANNEE, + * QUARTIER_IMMA, PER_COD, PER_NOM,PER_PRENOM. * Existing boats (with same immatriculation) are updated. * * @param transaction current transaction @@ -481,13 +481,10 @@ // If not available, select it from database if (shipOwner == null) { shipOwner = shipOwnerDAO.findByCode(shipOwnerCode); - // If not exist yet, create it if (shipOwner == null) { - shipOwner = shipOwnerDAO.create( - ShipOwner.PROPERTY_CODE, shipOwnerCode); + shipOwner = shipOwnerDAO.create(ShipOwner.PROPERTY_CODE, shipOwnerCode); } - availableShipOwners.put(shipOwnerCode, shipOwner); } shipOwner.setFirstName(shipOwnerFirstName); 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 2011-05-05 15:09:06 UTC (rev 1260) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSamplingImpl.java 2011-05-06 09:53:34 UTC (rev 1261) @@ -901,6 +901,10 @@ List<Object> errorArgs, ConnectedUser user, SamplingFilter filter) throws Exception { + // ignore pagination when exporting + filter.setStartIndex(null); + filter.setEndIndex(null); + SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction); WaoQueryBuilder builder = context.newQueryBuilder(); WaoQueryHelper.SampleRowProperty sampleRowProperty = Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/ObsDebSamplingPlan.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/ObsDebSamplingPlan.java 2011-05-05 15:09:06 UTC (rev 1260) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/ObsDebSamplingPlan.java 2011-05-06 09:53:34 UTC (rev 1261) @@ -31,12 +31,15 @@ import fr.ifremer.wao.io.ImportResults; import fr.ifremer.wao.service.ServiceContact; import fr.ifremer.wao.service.ServiceSampling; +import fr.ifremer.wao.ui.components.Layout; import fr.ifremer.wao.ui.components.SamplingFilterComponent; +import fr.ifremer.wao.ui.data.ErrorReport; import fr.ifremer.wao.ui.data.ExportStreamResponse; import fr.ifremer.wao.ui.data.ImportEngine; import fr.ifremer.wao.ui.data.RequiresAuthentication; import fr.ifremer.wao.ui.data.SampleRowDataSource; import fr.ifremer.wao.ui.services.SampleRowModelFactory; +import org.apache.tapestry5.Block; import org.apache.tapestry5.ComponentResources; import org.apache.tapestry5.StreamResponse; import org.apache.tapestry5.annotations.InjectComponent; @@ -65,6 +68,9 @@ @Inject private Logger log; + @InjectComponent + private Layout layout; + @Inject private BeanModelSource beanModelSource; @@ -167,12 +173,15 @@ /********** IMPORT / EXPORT *********/ + public Block onSuccessFromImportForm() { + showImport = false; + return importZone.getBody(); + } + public ImportEngine getSamplingPlanImportEngine() { return new ImportEngine() { @Override - public ImportResults execute(InputStream input) - throws WaoException, WaoBusinessException { - // FIXME 20110505 bleny when an error occur, nothing is show in the UI + public ImportResults execute(InputStream input) throws WaoBusinessException { ImportResults results = serviceSampling.importSamplingPlanCsv(input, connectedUser); return results; } @@ -193,4 +202,14 @@ } }; } + + @Log + void onImported(ErrorReport report) { + for (String info : report.getInfos()) { + layout.addInfo(info); + } + for (String error : report.getErrors()) { + layout.addError(error); + } + } }
participants (1)
-
bleny@users.labs.libre-entreprise.org