Author: bpoussin Date: 2009-05-12 05:33:42 +0000 (Tue, 12 May 2009) New Revision: 2212 Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/entities/PopulationImpl.java Log: bug fix matrix capturability without semantics Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/entities/PopulationImpl.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/entities/PopulationImpl.java 2009-05-11 07:47:07 UTC (rev 2211) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/entities/PopulationImpl.java 2009-05-12 05:33:42 UTC (rev 2212) @@ -462,6 +462,35 @@ // setCapturability(mat); // } + @Override + public void setCapturability(MatrixND value) { + List[] sems = value.getSemantics(); + + boolean allNull = true; + for (List l : sems) { + for (Object o : l) { + allNull = (o == null); + } + } + + // toutes les semantiques de la matrice sont null + // on cree une nouvelle matrice avec les bonnes dimensions et les + // bonnes semantiques avec les valeurs de la matrice passee en parametre + if (allNull) { + List[] newsems = new List[]{getPopulationGroup(), + getPopulationSeasonInfo(),}; + + MatrixND newmat = MatrixFactory.getInstance().create( + n_("isisfish.population.capturability"), + newsems, + new String[] { n_("isisfish.population.group"), + n_("isisfish.population.season") }); + newmat.paste(value); + value = newmat; + } + super.setCapturability(value); + } + /* * @see fr.ifremer.isisfish.entities.PopulationAbstract#getCapturability() */ @@ -493,7 +522,21 @@ sems, new String[] { n_("isisfish.population.group"), n_("isisfish.population.season") }); - newmat.pasteSemantics(mat); + + boolean allNull = true; + for (List l : mat.getSemantics()) { + for (Object o : l) { + allNull = (o == null); + } + } + + // les dimensions de la matrice en base sont toutes null, on + // fait en simple copy de matrice sans utiliser la semantique + if (allNull) { + newmat.paste(mat); + } else { + newmat.pasteSemantics(mat); + } mat = newmat; // perhaps call setCapturability, but if possible wait the user // call setCapturability explicitly with this new matrix