[Suiviobsmer-commits] r1112 - in trunk/wao-business/src/main: java/fr/ifremer/wao/service xmi
Author: bleny Date: 2011-03-29 09:42:22 +0000 (Tue, 29 Mar 2011) New Revision: 1112 Log: bug fix import sampling plan Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSamplingImpl.java trunk/wao-business/src/main/xmi/wao.zargo 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-03-28 16:05:23 UTC (rev 1111) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSamplingImpl.java 2011-03-29 09:42:22 UTC (rev 1112) @@ -264,7 +264,7 @@ SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction); SampleRow oldRow = null; - if (row.getCode() == null) { + if (StringUtils.isEmpty(row.getCode())) { // all rows must have a unique code, the code has a year as prefix // like '2011_' so we must know on which year the row is active @@ -295,15 +295,32 @@ // We call the service in another transaction, to prevent // putting an entity in with the same id in the same session oldRow = getSampleRowByCode(null, row.getCode()); + + if (log.isDebugEnabled()) { + log.debug("we want to update row with code " + row.getCode()); + + if (oldRow == null) { + log.debug("no older row with code " + row.getCode() + " found."); + } else { + log.debug("older row with code " + oldRow.getCode() + " found (topiaId=" + + oldRow.getTopiaId() + ", historic size=" + oldRow.sizeSampleRowLog() + ")"); + } + } } boolean rowIsNew = oldRow == null; if (rowIsNew) { + if (log.isDebugEnabled()) { + log.debug("sample row is new, creating"); + } if (row.getTopiaId() == null) { context.prepareTopiaId(SampleRow.class, row); } dao.create(row); } else { + if (log.isDebugEnabled()) { + log.debug("sample row is not new, updating"); + } // check that code is not already used in another program if ( ! row.getObsProgram().equals(oldRow.getObsProgram())) { @@ -325,7 +342,8 @@ // update the row by copying the new data in the old entity // taking care to not remove any sample row log entries - BinderModelBuilder<SampleRow, SampleRow> sampleRowBinderModelBuilder = BinderModelBuilder.newEmptyBuilder(SampleRow.class); + BinderModelBuilder<SampleRow, SampleRow> sampleRowBinderModelBuilder = + BinderModelBuilder.newEmptyBuilder(SampleRow.class); if (ObsProgram.OBSDEB.equals(row.getObsProgram())) { sampleRowBinderModelBuilder.addSimpleProperties( SampleRow.PROPERTY_COMMENT, SampleRow.PROPERTY_COMMENT, Modified: trunk/wao-business/src/main/xmi/wao.zargo =================================================================== (Binary files differ)
participants (1)
-
bleny@users.labs.libre-entreprise.org