Author: chatellier Date: 2011-01-07 08:47:43 +0000 (Fri, 07 Jan 2011) New Revision: 482 Log: Ajout d'une methode pour recuperer le nom de campagne d'un projet Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java =================================================================== --- trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java 2011-01-06 17:04:05 UTC (rev 481) +++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java 2011-01-07 08:47:43 UTC (rev 482) @@ -62,6 +62,7 @@ import org.apache.commons.collections.CollectionUtils; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; +import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.commons.math.util.MathUtils; @@ -79,6 +80,7 @@ import org.nuiton.math.matrix.MatrixND; import org.nuiton.math.matrix.MatrixProvider; import org.nuiton.util.FileUtil; +import org.nuiton.util.StringUtil; import org.nuiton.util.ZipUtil; import fr.ifremer.coser.CoserBusinessConfig; @@ -1186,7 +1188,7 @@ } /** - * Convert a string line to parameized command. + * Convert a string line to parameterized command. * * @param line line to convert * @return command @@ -2851,6 +2853,23 @@ } /** + * Look for project survey name in container data. + * + * @param container data container + * @return survey name + */ + public String getProjectSurveyName(AbstractDataContainer container) { + String result = null; + + Iterator<String[]> itCatchData = container.getCatch().iterator(true); + while (StringUtils.isEmpty(result) && itCatchData.hasNext()) { + result = itCatchData.next()[Catch.INDEX_SURVEY]; + } + + return result; + } + + /** * Retourne tous les projets qui ont des résultats. * * De la forme d'une liste de de path (à la tree path) : Modified: trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java =================================================================== --- trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java 2011-01-06 17:04:05 UTC (rev 481) +++ trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java 2011-01-07 08:47:43 UTC (rev 482) @@ -460,4 +460,20 @@ MatrixND matrix = projectService.getLengthStructure(project, selection); Assert.assertNotNull(matrix); } + + /** + * Test la recuperation du nom de la campagne. + * + * @throws CoserBusinessException + */ + @Test + public void getProjectSurveyName() throws CoserBusinessException { + Project project = createTestProject(projectService, true); + String survey = projectService.getProjectSurveyName(project.getControl()); + Assert.assertEquals("COSER_TEST", survey); + + Selection selection = projectService.initProjectSelection(project); + survey = projectService.getProjectSurveyName(selection); + Assert.assertEquals("COSER_TEST", survey); + } }