Author: bleny Date: 2011-02-17 15:33:11 +0000 (Thu, 17 Feb 2011) New Revision: 1027 Log: fix sampling plan (filter on fishingZone for ObsVente) Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSamplingImpl.java trunk/wao-ui/src/main/webapp/SamplingPlan.tml 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-02-17 15:32:26 UTC (rev 1026) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSamplingImpl.java 2011-02-17 15:33:11 UTC (rev 1027) @@ -465,10 +465,15 @@ // Add join for FishingZone TopiaQuery query = builder.applySamplingFilter(filter). addDistinct(); + WaoQueryHelper.FishingZoneProperty fishingZoneProperty = + builder.getFishingZoneProperty(); + + // Depending on the program, the sampling plan is not organised + // the same way. In Obsmer, lines are cut by Facade, sector + // In ObsVente, it's by terrestrial location + if (filter.getObsProgram() == ObsProgram.OBSMER) { - WaoQueryHelper.FishingZoneProperty fishingZoneProperty = - builder.getFishingZoneProperty(); query.setSelect(sampleRowProperty.$alias(), fishingZoneProperty.facadeName(), @@ -481,19 +486,23 @@ fishingZoneProperty.sectorName(), fishingZoneProperty.districtCode(), sampleRowProperty.code()); - } else { + } else if (filter.getObsProgram() == ObsProgram.OBSVENTE) { WaoQueryHelper.TerrestrialLocationProperty terrestrialLocationProperty = WaoQueryHelper.newTerrestrialLocationProperty(); query.setSelect(sampleRowProperty.$alias(), terrestrialLocationProperty.coastFAOName(), terrestrialLocationProperty.countryName()). + // we still need to join to fishing zone for filters + addLeftJoin(sampleRowProperty.fishingZone(), fishingZoneProperty.$alias(), false). addLeftJoin(sampleRowProperty.terrestrialLocation(), terrestrialLocationProperty.$alias(), false). addLeftJoin(sampleRowProperty.dCF5Code(), dcf5CodeProperty.$alias(), false). // Order By facade, sector, districtCode, sampleRowCode addOrder(terrestrialLocationProperty.coastFAOName(), terrestrialLocationProperty.countryName(), sampleRowProperty.code()); + } else { + throw new IllegalArgumentException("obsProgram " + filter.getObsProgram()); } if (log.isDebugEnabled()) { Modified: trunk/wao-ui/src/main/webapp/SamplingPlan.tml =================================================================== --- trunk/wao-ui/src/main/webapp/SamplingPlan.tml 2011-02-17 15:32:26 UTC (rev 1026) +++ trunk/wao-ui/src/main/webapp/SamplingPlan.tml 2011-02-17 15:33:11 UTC (rev 1027) @@ -188,7 +188,7 @@ </p:else> </t:if> <t:if test="user.obsVente"> - <td class="width60 bright">16 ${message:wao.ui.field.SampleRow.samplingStrategy}</td> + <td class="width60 bright">${message:wao.ui.field.SampleRow.samplingStrategy}</td> </t:if> <t:loop source="months" value="month"> <td class="width50"><t:output value="month" format="dateFormat" /></td>