Author: chatellier
Date: 2010-12-02 14:54:03 +0000 (Thu, 02 Dec 2010)
New Revision: 336
Log:
G?\195?\169n?\195?\169ration du report des modifications
Added:
trunk/coser-ui/src/main/resources/icons/report.png
Modified:
trunk/coser-business/src/main/java/fr/ifremer/coser/command/Command.java
trunk/coser-business/src/main/java/fr/ifremer/coser/command/DeleteLineCommand.java
trunk/coser-business/src/main/java/fr/ifremer/coser/command/MergeSpeciesCommand.java
trunk/coser-business/src/main/java/fr/ifremer/coser/command/ModifyFieldCommand.java
trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java
trunk/coser-business/src/main/java/fr/ifremer/coser/services/PublicationService.java
trunk/coser-business/src/main/resources/i18n/coser-business_en_GB.properties
trunk/coser-business/src/main/resources/i18n/coser-business_fr_FR.properties
trunk/coser-business/src/site/site_en.xml
trunk/coser-business/src/site/site_fr.xml
trunk/coser-business/src/test/java/fr/ifremer/coser/services/CommandServiceTest.java
trunk/coser-business/src/test/java/fr/ifremer/coser/services/PublicationServiceTest.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlView.jaxx
trunk/coser-ui/src/main/resources/i18n/coser-ui_en_GB.properties
trunk/coser-ui/src/main/resources/i18n/coser-ui_fr_FR.properties
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/command/Command.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/command/Command.java 2010-12-02 14:53:46 UTC (rev 335)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/command/Command.java 2010-12-02 14:54:03 UTC (rev 336)
@@ -124,4 +124,13 @@
* @param representation string command representation
*/
public abstract void fromStringRepresentation(String representation);
+
+ /**
+ * Return human readable string for log output.
+ *
+ * @param container rarement utile, mais dans certains cas, sert a avoir les
+ * vrais valeur de champs au lieu des noms techniques
+ * @return log representation
+ */
+ public abstract String getLogString(AbstractDataContainer container);
}
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/command/DeleteLineCommand.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/command/DeleteLineCommand.java 2010-12-02 14:53:46 UTC (rev 335)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/command/DeleteLineCommand.java 2010-12-02 14:54:03 UTC (rev 336)
@@ -202,6 +202,11 @@
}
@Override
+ public String getLogString(AbstractDataContainer container) {
+ return _("coser.business.command.deleteline.log", _(category.getTranslationKey()), lineNumber);
+ }
+
+ @Override
public String toString() {
return "Delete line " + lineNumber + " on " + category;
}
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/command/MergeSpeciesCommand.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/command/MergeSpeciesCommand.java 2010-12-02 14:53:46 UTC (rev 335)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/command/MergeSpeciesCommand.java 2010-12-02 14:54:03 UTC (rev 336)
@@ -25,6 +25,8 @@
package fr.ifremer.coser.command;
+import static org.nuiton.i18n.I18n._;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
@@ -388,6 +390,16 @@
speciesNames = speciesNamesList.toArray(new String[speciesNamesList.size()]);
}
}
-
}
+
+ @Override
+ public String getLogString(AbstractDataContainer container) {
+ String speciesAsString = StringUtils.join(speciesNames, ", ");
+ return _("coser.business.command.mergespecies.log", newSpecyName, speciesAsString);
+ }
+
+ @Override
+ public String toString() {
+ return "Merge species to " + newSpecyName;
+ }
}
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/command/ModifyFieldCommand.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/command/ModifyFieldCommand.java 2010-12-02 14:53:46 UTC (rev 335)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/command/ModifyFieldCommand.java 2010-12-02 14:54:03 UTC (rev 336)
@@ -27,10 +27,12 @@
import static org.nuiton.i18n.I18n._;
+import java.beans.Introspector;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.beanutils.PropertyUtils;
+import org.apache.commons.lang.ArrayUtils;
import fr.ifremer.coser.CoserBusinessException;
import fr.ifremer.coser.CoserUtils;
@@ -138,7 +140,8 @@
String[] data = dataStorage.get(lineIndex);
beanData.setData(data);
try {
- String stringFieldProperty = fieldName + "AsString";
+ String beanFieldName = Introspector.decapitalize(fieldName);
+ String stringFieldProperty = beanFieldName + "AsString";
String dataValue = (String)PropertyUtils.getProperty(beanData, stringFieldProperty);
if (dataValue.equals(currentValue)) {
PropertyUtils.setProperty(beanData, stringFieldProperty, newValue);
@@ -180,7 +183,8 @@
String[] data = dataStorage.get(lineIndex);
beanData.setData(data);
try {
- String stringFieldProperty = fieldName + "AsString";
+ String beanFieldName = Introspector.decapitalize(fieldName);
+ String stringFieldProperty = beanFieldName + "AsString";
String dataValue = (String)PropertyUtils.getProperty(beanData, stringFieldProperty);
if (dataValue.equals(newValue)) {
PropertyUtils.setProperty(data, stringFieldProperty, currentValue);
@@ -240,7 +244,50 @@
@Override
public String toString() {
- String toString = "Modify field " + fieldName + " on line " + lineNumber;
- return toString;
+ return "Modify field " + fieldName + " on line " + lineNumber;
}
+
+ @Override
+ public String getLogString(AbstractDataContainer container) {
+ String realFieldName = getRealFieldName(container);
+ return _("coser.business.command.modifyfield.log", _(category.getTranslationKey()), lineNumber, realFieldName, currentValue, newValue);
+ }
+
+ /**
+ * Look for real field name.
+ *
+ * Les nom de champs utilisé par introspection et sauvegardé sont les
+ * nom anglais (toujours). Par contre pour la sortie log, l'utilisateur
+ * est plutôt interessé par le nom original du fichier.
+ *
+ * @param container le container pour lire les headers csv
+ * @return le nom original du fichier
+ */
+ protected String getRealFieldName(AbstractDataContainer container) {
+ String[] headers = null;
+ DataStorage dataStorage = null;
+ switch (category) {
+ case CATCH:
+ headers = Catch.EN_HEADERS;
+ dataStorage = container.getCatch();
+ break;
+ case HAUL:
+ headers = Haul.EN_HEADERS;
+ dataStorage = container.getHaul();
+ break;
+ case LENGTH:
+ headers = Length.EN_HEADERS;
+ dataStorage = container.getLength();
+ break;
+ case STRATA:
+ headers = Strata.EN_HEADERS;
+ dataStorage = container.getStrata();
+ break;
+ }
+
+ int index = ArrayUtils.indexOf(headers, fieldName);
+ // 0 = header
+ String realFieldName = dataStorage.get(0)[index];
+ return realFieldName;
+ }
}
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 2010-12-02 14:53:46 UTC (rev 335)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java 2010-12-02 14:54:03 UTC (rev 336)
@@ -1243,7 +1243,7 @@
*
* @param project project
* @param category category
- * @param fieldName fieldName
+ * @param headerName headerName
* @param searchString current value
* @param replaceString new value
* @param data current data
@@ -1252,7 +1252,7 @@
* @return modification flag
* @throws CoserBusinessException
*/
- public boolean replaceFieldValue(Project project, Category category, String fieldName,
+ public boolean replaceFieldValue(Project project, Category category, String headerName,
String searchString, String replaceString, String[] data, boolean isRegex, String commandUUID) throws CoserBusinessException {
boolean result = false;
@@ -1276,6 +1276,7 @@
// get current data value
try {
+ String fieldName = Introspector.decapitalize(headerName);
String stringFieldProperty = fieldName + "AsString";
String currentValue = (String)PropertyUtils.getProperty(beanData, stringFieldProperty);
@@ -1290,7 +1291,7 @@
String lineNumber = data[AbstractDataEntity.INDEX_LINE];
ModifyFieldCommand command = new ModifyFieldCommand();
command.setCommandUUID(commandUUID);
- command.setFieldName(fieldName);
+ command.setFieldName(headerName);
command.setLineNumber(lineNumber);
command.setCurrentValue(currentValue);
command.setNewValue(newValue);
@@ -1365,7 +1366,7 @@
if (!currentValue.equals(newValue)) {
ModifyFieldCommand command = new ModifyFieldCommand();
command.setCommandUUID(commandUUID);
- command.setFieldName(propertyName);
+ command.setFieldName(propertyHeader);
command.setLineNumber(lineNumber);
command.setCurrentValue(currentValue);
command.setNewValue(newValue);
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/PublicationService.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/services/PublicationService.java 2010-12-02 14:53:46 UTC (rev 335)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/PublicationService.java 2010-12-02 14:54:03 UTC (rev 336)
@@ -42,6 +42,7 @@
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -64,9 +65,10 @@
import fr.ifremer.coser.CoserConstants.Category;
import fr.ifremer.coser.bean.AbstractDataContainer;
import fr.ifremer.coser.bean.Project;
+import fr.ifremer.coser.command.Command;
+import fr.ifremer.coser.control.ControlError;
+import fr.ifremer.coser.control.ControlErrorGroup;
import fr.ifremer.coser.control.DiffCatchLengthControlError;
-import fr.ifremer.coser.control.ControlErrorGroup;
-import fr.ifremer.coser.control.ControlError;
import fr.ifremer.coser.data.Catch;
import fr.ifremer.coser.data.Length;
@@ -282,10 +284,10 @@
List<String> speciesGraph = new ArrayList<String>();
File imageDirectory = new File(exportHtmlFile.getParentFile(), "images");
imageDirectory.mkdirs();
- out = new PrintStream(exportHtmlFile);
+ out = new PrintStream(exportHtmlFile, "utf-8");
out.println("<html><head>");
- out.println("<title>" + _("coser.business.publication.htmlexporttitle", project.getName())+ "</title>");
+ out.println("<title>" + _("coser.business.publication.errorexporttitle", project.getName())+ "</title>");
out.println("<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>");
out.println("</head><body>");
@@ -318,7 +320,7 @@
Map<String, JFreeChart> charts = getCompareCatchLengthGraph(project, container, speciesGraph);
// render output html
- out.println("<h1 style='text-align:center'>" + _("coser.business.publication.htmlexporttitle", project.getName()) + "</h1>");
+ out.println("<h1 style='text-align:center'>" + _("coser.business.publication.errorexporttitle", project.getName()) + "</h1>");
for (Map.Entry<String, List<ControlErrorGroup>> categoriesEntry : validationCategoryChild.entrySet()) {
out.println("<h2>" + categoriesEntry.getKey() + "</h2>");
@@ -349,7 +351,7 @@
out.print(_(error.getDetailMessage()));
Set<String> lineNumbers = error.getLineNumbers();
if (CollectionUtils.isNotEmpty(lineNumbers)) {
- out.print(" (" + _("coser.business.publication.htmlexportlines") + " : ");
+ out.print(" (" + _("coser.business.publication.errorexportlines") + " : ");
Iterator<String> itLineNumbers = lineNumbers.iterator();
while (itLineNumbers.hasNext()) {
out.print(itLineNumbers.next());
@@ -390,4 +392,49 @@
}
return exportHtmlFile;
}
+
+ /**
+ * Extrait les logs des modifications faites sur un conteneur au format html.
+ *
+ * @param project project
+ * @param container data container
+ * @return extractedFile
+ * @throws CoserBusinessException
+ *
+ * @see AbstractDataContainer#getHistoryCommand()
+ */
+ public File extractLogAsHTML(Project project, AbstractDataContainer container) throws CoserBusinessException {
+ File exportHtmlFile = null;
+ PrintStream out = null;
+ try {
+ exportHtmlFile = File.createTempFile("log-", ".html");
+ if (log.isInfoEnabled()) {
+ log.info("Generating HTML report to " + exportHtmlFile.getAbsolutePath());
+ }
+
+ out = new PrintStream(exportHtmlFile, "utf-8");
+
+ out.println("<html><head>");
+ out.println("<title>" + _("coser.business.publication.logexporttitle", project.getName())+ "</title>");
+ out.println("<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>");
+ out.println("</head><body>");
+
+ out.println("<h1 style='text-align:center'>" + _("coser.business.publication.logexporttitle", project.getName()) + "</h1>");
+
+ // partie specific : commandes
+ out.println("<ol>");
+ for (Command command : container.getHistoryCommand()) {
+ out.println("<li>" + command.getLogString(container) + "</li>");
+ }
+ out.println("</ol>");
+ out.println("</body></html>");
+ }
+ catch (IOException ex) {
+ throw new CoserBusinessException("Can't export logs", ex);
+ }
+ finally {
+ IOUtils.closeQuietly(out);
+ }
+ return exportHtmlFile;
+ }
}
Modified: trunk/coser-business/src/main/resources/i18n/coser-business_en_GB.properties
===================================================================
--- trunk/coser-business/src/main/resources/i18n/coser-business_en_GB.properties 2010-12-02 14:53:46 UTC (rev 335)
+++ trunk/coser-business/src/main/resources/i18n/coser-business_en_GB.properties 2010-12-02 14:54:03 UTC (rev 336)
@@ -25,6 +25,9 @@
coser.business.category.strata=Stata
coser.business.category.typeEspece=Species type code
coser.business.chart.compareCatchLengthNumberTitle=Comparison of numbers and length and catch (%s)
+coser.business.command.deleteline.log=In file %s, line %s has been deleted
+coser.business.command.mergespecies.log=Species "%2$s" has been merged to "%1$s"
+coser.business.command.modifyfield.log=In file %s at line %s, field "%s" value as been modify from "%s" to "%s"
coser.business.common.number=Number
coser.business.common.year=Year
coser.business.control.error.allCategories=All categories
@@ -59,8 +62,9 @@
coser.business.control.step.observation=Checking observation number \: %s (%d%%)
coser.business.control.step.xworks=Line checks \: %s (%d%%)
coser.business.line=Line
-coser.business.publication.htmlexportlines=Lines
-coser.business.publication.htmlexporttitle=Error report for project %s
+coser.business.publication.errorexportlines=Lines
+coser.business.publication.errorexporttitle=Error report for project %s
+coser.business.publication.logexporttitle=Modifications list for project %s
coser.business.result.rsufiResultAlreadyExists=Result %s already exists \!
coser.business.selection.notValidatedControl=Not validated control \!
coser.config.control.diffcatchlength.description=Percentage difference allowed between catch and length (in percent, for example 5% set 5.0)
Modified: trunk/coser-business/src/main/resources/i18n/coser-business_fr_FR.properties
===================================================================
--- trunk/coser-business/src/main/resources/i18n/coser-business_fr_FR.properties 2010-12-02 14:53:46 UTC (rev 335)
+++ trunk/coser-business/src/main/resources/i18n/coser-business_fr_FR.properties 2010-12-02 14:54:03 UTC (rev 336)
@@ -25,6 +25,9 @@
coser.business.category.strata=Strates
coser.business.category.typeEspece=Code type des esp\u00E8ces
coser.business.chart.compareCatchLengthNumberTitle=Comparaison des nombres dans Capture et Taille (%s)
+coser.business.command.deleteline.log=Dans le fichier %s, la ligne %s a \u00E9t\u00E9 supprim\u00E9e
+coser.business.command.mergespecies.log=Les esp\u00E8ces "%2$s" ont \u00E9t\u00E9 fusionn\u00E9es en "%1$s"
+coser.business.command.modifyfield.log=Dans le ficher %s \u00E0 la ligne %s, le champs "%s" est pass\u00E9 de la valeur "%s" \u00E0 "%s"
coser.business.common.number=Nombre
coser.business.common.year=Ann\u00E9e
coser.business.control.error.allCategories=Toutes les cat\u00E9gories
@@ -59,8 +62,9 @@
coser.business.control.step.observation=V\u00E9rification du nombre d'observation \: %s (%d%%)
coser.business.control.step.xworks=Validation par lignes \: %s (%d%%)
coser.business.line=Ligne
-coser.business.publication.htmlexportlines=Lignes
-coser.business.publication.htmlexporttitle=Rapport d'erreur pour le projet %s
+coser.business.publication.errorexportlines=Lignes
+coser.business.publication.errorexporttitle=Rapport d'erreur pour le projet %s
+coser.business.publication.logexporttitle=Liste des modifications pour le projet %s
coser.business.result.rsufiResultAlreadyExists=Le r\u00E9sultat %D existe d\u00E9j\u00E0 \!
coser.business.selection.notValidatedControl=Contr\u00F4le non valid\u00E9 \!
coser.config.control.diffcatchlength.description=Pourcentage d'\u00E9cart tol\u00E9r\u00E9 entre les captures et les tailles (en pourcent, par exemple pour 5% mettre 5.0)
Modified: trunk/coser-business/src/site/site_en.xml
===================================================================
--- trunk/coser-business/src/site/site_en.xml 2010-12-02 14:53:46 UTC (rev 335)
+++ trunk/coser-business/src/site/site_en.xml 2010-12-02 14:54:03 UTC (rev 336)
@@ -26,10 +26,10 @@
<project name="${project.name}">
- <menu ref="parent"/>
-
<body>
+ <menu ref="parent"/>
+
<links>
<item name="[fr" href="../index.html" />
<item name="en]" href="index.html" />
Modified: trunk/coser-business/src/site/site_fr.xml
===================================================================
--- trunk/coser-business/src/site/site_fr.xml 2010-12-02 14:53:46 UTC (rev 335)
+++ trunk/coser-business/src/site/site_fr.xml 2010-12-02 14:54:03 UTC (rev 336)
@@ -26,10 +26,10 @@
<project name="${project.name}">
- <menu ref="parent"/>
-
<body>
+ <menu ref="parent"/>
+
<links>
<item name="[fr" href="index.html" />
<item name="en]" href="en/index.html" />
Modified: trunk/coser-business/src/test/java/fr/ifremer/coser/services/CommandServiceTest.java
===================================================================
--- trunk/coser-business/src/test/java/fr/ifremer/coser/services/CommandServiceTest.java 2010-12-02 14:53:46 UTC (rev 335)
+++ trunk/coser-business/src/test/java/fr/ifremer/coser/services/CommandServiceTest.java 2010-12-02 14:54:03 UTC (rev 336)
@@ -34,6 +34,8 @@
import fr.ifremer.coser.CoserConstants.Category;
import fr.ifremer.coser.bean.Project;
import fr.ifremer.coser.command.DeleteLineCommand;
+import fr.ifremer.coser.command.ModifyFieldCommand;
+import fr.ifremer.coser.data.Catch;
import fr.ifremer.coser.data.Length;
/**
@@ -128,4 +130,46 @@
project.getControl().getHistoryCommand().add(command);
commandService.undoAction(project, project.getControl());
}
+
+ /**
+ * Test la commande de modification de valeur des champs.
+ *
+ * @throws CoserBusinessException
+ */
+ @Test
+ public void testModifyFieldValue() throws CoserBusinessException {
+ Project project = createTestProject(projectService, false);
+ Assert.assertEquals(30, project.getControl().getLength().size());
+
+ ModifyFieldCommand command = new ModifyFieldCommand();
+ command.setLineNumber("4");
+ command.setCategory(Category.CATCH);
+ command.setFieldName("Number");
+ command.setCurrentValue("251.86");
+ command.setNewValue("392.98");
+
+ commandService.doAction(command, project, project.getControl());
+ Assert.assertEquals("392.98", project.getControl().getCatch().get(4)[Catch.INDEX_NUMBER]);
+ }
+
+ /**
+ * Test la commande de modification de valeur des champs alors que la valeur
+ * attendu avant de remplacer est fausse.
+ *
+ * @throws CoserBusinessException
+ */
+ @Test(expected=CoserBusinessException.class)
+ public void testModifyFieldValueError() throws CoserBusinessException {
+ Project project = createTestProject(projectService, false);
+ Assert.assertEquals(30, project.getControl().getLength().size());
+
+ ModifyFieldCommand command = new ModifyFieldCommand();
+ command.setLineNumber("4");
+ command.setCategory(Category.CATCH);
+ command.setFieldName("Number");
+ command.setCurrentValue("252.86");
+ command.setNewValue("392.98");
+
+ commandService.doAction(command, project, project.getControl());
+ }
}
Modified: trunk/coser-business/src/test/java/fr/ifremer/coser/services/PublicationServiceTest.java
===================================================================
--- trunk/coser-business/src/test/java/fr/ifremer/coser/services/PublicationServiceTest.java 2010-12-02 14:53:46 UTC (rev 335)
+++ trunk/coser-business/src/test/java/fr/ifremer/coser/services/PublicationServiceTest.java 2010-12-02 14:54:03 UTC (rev 336)
@@ -47,6 +47,8 @@
import fr.ifremer.coser.CoserConstants.Category;
import fr.ifremer.coser.CoserConstants.ValidationLevel;
import fr.ifremer.coser.bean.Project;
+import fr.ifremer.coser.command.DeleteLineCommand;
+import fr.ifremer.coser.command.ModifyFieldCommand;
import fr.ifremer.coser.control.DiffCatchLengthControlError;
import fr.ifremer.coser.control.ControlError;
@@ -59,15 +61,17 @@
* Last update : $Date$
* By : $Author$
*/
-public class PublicationServiceTest extends CoserTestAbstract {;
+public class PublicationServiceTest extends CoserTestAbstract {
protected ProjectService projectService;
protected PublicationService publicationService;
+ protected CommandService commandService;
@Before
public void initService() {
projectService = new ProjectService(config);
publicationService = new PublicationService(config);
+ commandService = new CommandService(config);
}
@Ignore
@@ -89,7 +93,7 @@
* @throws IOException
*/
@Test
- public void testExportHtml() throws CoserBusinessException, IOException {
+ public void testErrorExportHtml() throws CoserBusinessException, IOException {
Project project = createTestProject(projectService, false);
List<ControlError> validationErrors = new ArrayList<ControlError>();
@@ -118,6 +122,8 @@
validationErrors.add(error3);
File htmlExport = publicationService.exportErrorsAsHTML(project, project.getControl(), validationErrors);
+
+ // some asserts
String fileContent = FileUtils.readFileToString(htmlExport);
Assert.assertTrue(fileContent.indexOf("9999") > 0);
Assert.assertTrue(fileContent.indexOf("<img src=") > 0); // one chart
@@ -132,4 +138,43 @@
FileUtils.deleteDirectory(imagesDir);
htmlExport.delete();
}
+
+ /**
+ * Test le rapport de log en html.
+ *
+ * @throws CoserBusinessException
+ * @throws IOException
+ */
+ @Test
+ public void testLogExportHtml() throws CoserBusinessException, IOException {
+
+ Project project = createTestProject(projectService, false);
+ Assert.assertEquals(30, project.getControl().getLength().size());
+
+ // delete line 2
+ DeleteLineCommand command = new DeleteLineCommand();
+ command.setLineNumber("2");
+ command.setCategory(Category.LENGTH);
+ commandService.doAction(command, project, project.getControl());
+
+ ModifyFieldCommand command2 = new ModifyFieldCommand();
+ command2.setLineNumber("4");
+ command2.setCategory(Category.CATCH);
+ command2.setFieldName("Number");
+ command2.setCurrentValue("251.86");
+ command2.setNewValue("392.98");
+
+ commandService.doAction(command2, project, project.getControl());
+
+ File htmlExport = publicationService.extractLogAsHTML(project, project.getControl());
+
+ // some asserts
+ String fileContent = FileUtils.readFileToString(htmlExport);
+ Assert.assertTrue(fileContent.indexOf("line 2") > 0);
+ Assert.assertTrue(fileContent.indexOf("line 4") > 0);
+ Assert.assertTrue(fileContent.indexOf("from 251.86 to 392.98") > 0);
+
+ // clean all
+ //htmlExport.delete();
+ }
}
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java 2010-12-02 14:53:46 UTC (rev 335)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java 2010-12-02 14:54:03 UTC (rev 336)
@@ -329,7 +329,6 @@
// -1 because table model contains line number
String field = enHeaders[replaceView.getColumnIndex() - 1];
- field = Introspector.decapitalize(field);
String find = replaceView.getReplaceFindField().getText();
String replace = replaceView.getReplaceReplaceField().getText();
if (log.isWarnEnabled()) {
@@ -661,12 +660,23 @@
File htmlFile = null;
try {
htmlFile = publicationService.exportErrorsAsHTML(project, project.getControl(), controlErrors);
-
- Desktop.getDesktop().browse(htmlFile.toURI());
+ displayReport(controlView, htmlFile);
} catch (CoserBusinessException ex) {
throw new CoserException("Can't generate html report", ex);
+ }
+ }
+
+ /**
+ * Ouvre un fichier html dans le navigateur systeme.
+ *
+ * @param controlView view
+ * @param report report to open
+ */
+ protected void displayReport(ControlView controlView, File report) {
+ try {
+ Desktop.getDesktop().browse(report.toURI());
} catch (IOException ex) {
- JOptionPane.showMessageDialog(controlView, _("coser.ui.control.htmlReportCantBeOpened", htmlFile.getAbsolutePath()),
+ JOptionPane.showMessageDialog(controlView, _("coser.ui.control.htmlReportCantBeOpened", report.getAbsolutePath()),
_("coser.ui.control.htmlReportError"), JOptionPane.WARNING_MESSAGE);
}
}
@@ -1005,4 +1015,23 @@
JOptionPane.showMessageDialog(view, _("coser.ui.control.controlValidated"),
_("coser.ui.control.controlTitle"), JOptionPane.INFORMATION_MESSAGE);
}
+
+ /**
+ * Genere le log des modifications faites lors du control en HTML
+ * et l'ouvre dans le navigateur systeme.
+ *
+ * @param controlView
+ */
+ public void displayLogReport(ControlView controlView) {
+ PublicationService publicationService = controlView.getContextValue(PublicationService.class);
+ Project project = controlView.getContextValue(Project.class);
+
+ File htmlFile = null;
+ try {
+ htmlFile = publicationService.extractLogAsHTML(project, project.getControl());
+ displayReport(controlView, htmlFile);
+ } catch (CoserBusinessException ex) {
+ throw new CoserException("Can't generate html report", ex);
+ }
+ }
}
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlView.jaxx
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlView.jaxx 2010-12-02 14:53:46 UTC (rev 335)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlView.jaxx 2010-12-02 14:54:03 UTC (rev 336)
@@ -59,9 +59,13 @@
<JButton icon="chart_bar.png" text="coser.ui.graph.lengthStructure"
onActionPerformed="getHandler().displayLengthStructureGraph(this)"/>
<JToolBar.Separator />
+ <JButton icon="report.png" onActionPerformed="getHandler().displayLogReport(this)"
+ text="coser.ui.control.logreport" />
+ <JToolBar.Separator />
<JButton icon="accept.png" onActionPerformed="getHandler().validControl(this)"
text="coser.ui.control.validcontrol" toolTipText="coser.ui.control.validcontroltip"
enabled="{isCanValidControl()}"/>
+
</JToolBar>
</cell>
</row>
Modified: trunk/coser-ui/src/main/resources/i18n/coser-ui_en_GB.properties
===================================================================
--- trunk/coser-ui/src/main/resources/i18n/coser-ui_en_GB.properties 2010-12-02 14:53:46 UTC (rev 335)
+++ trunk/coser-ui/src/main/resources/i18n/coser-ui_en_GB.properties 2010-12-02 14:54:03 UTC (rev 336)
@@ -42,6 +42,7 @@
coser.ui.control.graphtitle=Graph
coser.ui.control.htmlReportCantBeOpened=HTML report as been generated in \:\n%s\nbut it can't be opened because default system browser in undefined \!
coser.ui.control.htmlReportError=Open error
+coser.ui.control.logreport=Modification report
coser.ui.control.progressStep=Step %d/%d \: %s
coser.ui.control.project.requiredauthor=Author field is required
coser.ui.control.project.requiredcatchFile=Catch file is required
Modified: trunk/coser-ui/src/main/resources/i18n/coser-ui_fr_FR.properties
===================================================================
--- trunk/coser-ui/src/main/resources/i18n/coser-ui_fr_FR.properties 2010-12-02 14:53:46 UTC (rev 335)
+++ trunk/coser-ui/src/main/resources/i18n/coser-ui_fr_FR.properties 2010-12-02 14:54:03 UTC (rev 336)
@@ -42,6 +42,7 @@
coser.ui.control.graphtitle=Graphique
coser.ui.control.htmlReportCantBeOpened=Le rapport HTML a \u00E9t\u00E9 g\u00E9n\u00E9r\u00E9 dans le fichier \:\n%s\nmais ne peut pas \u00EAtre ouvert automatiquement car le navigateur\npar d\u00E9faut du syst\u00E8me n'est pas d\u00E9fini \!
coser.ui.control.htmlReportError=Erreur d'ouverture
+coser.ui.control.logreport=Rapport des modifications
coser.ui.control.progressStep=\u00C9tape %d/%d \: %s
coser.ui.control.project.requiredauthor=Le champ 'auteur' est requis
coser.ui.control.project.requiredcatchFile=Le fichier 'capture' est requis
Added: trunk/coser-ui/src/main/resources/icons/report.png
===================================================================
(Binary files differ)
Property changes on: trunk/coser-ui/src/main/resources/icons/report.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream