Author: bleny Date: 2010-11-19 18:10:04 +0000 (Fri, 19 Nov 2010) New Revision: 793 Log: sample row form can edit multiple DCF5 codes since migration Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ProfessionImpl.java trunk/wao-business/src/main/xmi/wao.zargo trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SampleRowForm.java trunk/wao-ui/src/main/resources/fr/ifremer/wao/ui/pages/SampleRowForm.properties trunk/wao-ui/src/main/webapp/SampleRowForm.tml Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ProfessionImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ProfessionImpl.java 2010-11-19 17:13:34 UTC (rev 792) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ProfessionImpl.java 2010-11-19 18:10:04 UTC (rev 793) @@ -29,6 +29,8 @@ import org.slf4j.LoggerFactory; import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; /** * ProfessionImpl @@ -64,4 +66,22 @@ } return code; } + + @Override + public void setDcf5code(String codes, String separatorRegex) { + String[] splitCodes = codes.split(separatorRegex); + List<DCFFiveCode> dcfFives = new ArrayList<DCFFiveCode>(splitCodes.length); + for (String code : splitCodes) { + String[] codeParts = code.split("_"); + DCFFiveCode dcfFive = new DCFFiveCodeImpl(); + + dcfFive.setFishingGearDCF(codeParts[0]); + if (codeParts.length == 2) { + dcfFive.setTargetSpeciesDCF(codeParts[1]); + } + + dcfFives.add(dcfFive); + } + setDcf5code(dcfFives); + } } Modified: trunk/wao-business/src/main/xmi/wao.zargo =================================================================== (Binary files differ) 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-11-19 17:13:34 UTC (rev 792) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SampleRowForm.java 2010-11-19 18:10:04 UTC (rev 793) @@ -61,13 +61,13 @@ import org.apache.tapestry5.annotations.SessionState; import org.apache.tapestry5.beaneditor.BeanModel; import org.apache.tapestry5.corelib.components.Form; -import org.apache.tapestry5.corelib.components.Zone; import org.apache.tapestry5.internal.OptionModelImpl; import org.apache.tapestry5.internal.SelectModelImpl; import org.apache.tapestry5.ioc.annotations.Inject; import org.apache.tapestry5.ioc.services.PropertyAccess; import org.apache.tapestry5.services.BeanModelSource; import org.nuiton.util.PeriodDates; +import org.nuiton.util.StringUtil; import org.slf4j.Logger; import java.text.DateFormat; @@ -219,95 +219,24 @@ edited = true; } + private String dcf5codes; - - @Property - private boolean refreshDcf5CodeZone; - - @Property - private int dcf5CodeIndex; - - @Persist - private DCFFiveCode currentDcf5Code; - - @Property - private String currentDCFGear; - - @Property - private String currentDCFSpecies; - - @Property - private DCFFiveCode dcf5Code; - - @InjectComponent - private Zone dcf5CodeZone; - - private List<DCFFiveCode> rowDCF5codes; - - public DCFFiveCode getCurrentDcf5Code() { - if (currentDcf5Code == null) { - currentDcf5Code = new DCFFiveCodeImpl(); - } - return currentDcf5Code; - } - - public void setCurrentDcf5Code(DCFFiveCode currentDcf5Code) { - this.currentDcf5Code = currentDcf5Code; - } - - public List<DCFFiveCode> getRowDCF5codes() { - if (rowDCF5codes == null) { + public String getDcf5codes() { + if (dcf5codes == null) { Collection<DCFFiveCode> codes = getSampleRow().getProfession().getDcf5code(); - if (codes == null) { - rowDCF5codes = new ArrayList<DCFFiveCode>(); + if (CollectionUtils.isEmpty(codes)) { + dcf5codes = ""; } else { - rowDCF5codes = new ArrayList<DCFFiveCode>(codes); + dcf5codes = StringUtil.join(codes, ", ", true); } - getSampleRow().getProfession().setDcf5code(rowDCF5codes); } - return rowDCF5codes; + return dcf5codes; } - public void onChangeFromCurrentDCFGear(String currentDCFGear) { - getCurrentDcf5Code().setFishingGearDCF(currentDCFGear); + public void setDcf5codes(String dcf5codes) { + this.dcf5codes = dcf5codes; } - public void onChangeFromCurrentDCFSpecies(String currentDCFSpecies) { - getCurrentDcf5Code().setTargetSpeciesDCF(currentDCFSpecies); - } - - public Object onActionFromAddCurrentDcf5Code() { - getRowDCF5codes().add(currentDcf5Code); - - log.debug("added " + currentDcf5Code.getFishingGearDCF() + "_" + - currentDcf5Code.getTargetSpeciesDCF()); - - getSampleRow().getProfession().setDcf5code(rowDCF5codes); - - currentDcf5Code = null; - - refreshDcf5CodeZone = true; - return dcf5CodeZone; - } - - public Object onActionFromRemoveDcf5Code(int dcf5CodeIndex) { - - if (log.isDebugEnabled()) { - log.debug("dcf5codes before removing " + dcf5CodeIndex + " : " + - getSampleRow().getProfession().getDcf5code()); - } - - getRowDCF5codes().remove(dcf5CodeIndex); - getSampleRow().getProfession().setDcf5code(rowDCF5codes); - - if (log.isDebugEnabled()) { - log.debug("dcf5codes after removing " + getSampleRow().getProfession().getDcf5code()); - } - - refreshDcf5CodeZone = true; - return dcf5CodeZone; - } - /*************************** FISHING ZONE *********************************/ /** Select model for the FishingZone list **/ @@ -751,6 +680,9 @@ // Save sampleMonths getSampleRow().setSampleMonth(getSampleMonths()); + // save dcf5 codes + getSampleRow().getProfession().setDcf5code(getDcf5codes(), ", "); + serviceSampling.createUpdateSampleRow(sampleRow, boats, getSampleRowLog()); return SamplingPlan.class; Modified: trunk/wao-ui/src/main/resources/fr/ifremer/wao/ui/pages/SampleRowForm.properties =================================================================== --- trunk/wao-ui/src/main/resources/fr/ifremer/wao/ui/pages/SampleRowForm.properties 2010-11-19 17:13:34 UTC (rev 792) +++ trunk/wao-ui/src/main/resources/fr/ifremer/wao/ui/pages/SampleRowForm.properties 2010-11-19 18:10:04 UTC (rev 793) @@ -24,7 +24,7 @@ ### # FOR PROFESSION PART professionSelect-label: Code m\u00e9tier -codeDCF5-label: Code DCF Niv. 5* +dcf5codes-label: Code DCF Niv. 5* meshSize-label: Maillage (mm) size-label: Taille (mm) other-label: Autre information Modified: trunk/wao-ui/src/main/webapp/SampleRowForm.tml =================================================================== --- trunk/wao-ui/src/main/webapp/SampleRowForm.tml 2010-11-19 17:13:34 UTC (rev 792) +++ trunk/wao-ui/src/main/webapp/SampleRowForm.tml 2010-11-19 18:10:04 UTC (rev 793) @@ -60,28 +60,9 @@ <t:beaneditor t:id="professionEditor" t:object="sampleRow.profession" t:include="meshSize, size, other, libelle, species" /> </div> - <div class="t-beaneditor acenter"> + <div class="t-beaneditor"> <div class="t-beaneditor-row"> - <t:zone id="so-sampleRowForm-dcf5CodeZone" t:id="dcf5CodeZone" t:update="show"> - <t:nuiton.subForm t:visible="refreshDcf5CodeZone"> - <t:label t:for="currentDCFGear" /> : - <input t:type="textfield" t:value="currentDCFGear" size="3" t:id="currentDCFGear" t:mixins="ck/onEvent" t:event="change" />_<input t:type="textfield" t:value="currentDCFSpecies" size="3" t:id="currentDCFSpecies" t:mixins="ck/onEvent" t:event="change" /> - <a t:type="actionlink" t:id="addCurrentDcf5Code" title="Ajouter ce code DCF5" t:zone="so-sampleRowForm-dcf5CodeZone"> - <img src="${asset:context:img/add-16px.png}" /> - </a> - - <ul> - <li t:type="loop" t:source="rowDCF5codes" t:value="dcf5Code" t:index="dcf5CodeIndex" t:volatile="true"> - <span t:type="ck/Tooltip" t:value="${dcf5Code.fishingGearDCF} - ${dcf5Code.fishingGearDCFDescription} ; ${dcf5Code.targetSpeciesDCF} - ${dcf5Code.targetSpeciesDCFDescription}" t:effect="appear"> - ${dcf5Code.fishingGearDCF}_${dcf5Code.targetSpeciesDCF} - </span> - <a t:type="actionlink" t:id="removeDcf5Code" t:context="dcf5CodeIndex" title="Supprimer ce code DCF5" t:zone="so-sampleRowForm-dcf5CodeZone"> - <img src="${asset:context:img/remove-22px.png}" /> - </a> - </li> - </ul> - </t:nuiton.subForm> - </t:zone> + <t:label t:for="dcf5codes" /> <input t:type="textfield" t:value="dcf5codes" t:id="dcf5codes" /> </div> </div> </p:else>