r15 - trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers
Author: sletellier Date: 2011-05-03 15:49:28 +0200 (Tue, 03 May 2011) New Revision: 15 Url: http://chorem.org/repositories/revision/vradi/15 Log: - #337 Make date humain readable - Fix javadocs Modified: trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/MailingManager.java trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/TemplateManager.java Modified: trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/MailingManager.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/MailingManager.java 2011-05-03 13:05:25 UTC (rev 14) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/MailingManager.java 2011-05-03 13:49:28 UTC (rev 15) @@ -787,8 +787,7 @@ for (Map.Entry<String, String[]> binding : fieldBindings.entrySet()) { String[] fqField = binding.getValue(); Object value = form.getField(fqField[0], fqField[1]); - fieldValues.put(binding.getKey(), - value != null ? value.toString() : null); + fieldValues.put(binding.getKey(), value); } // Extract files Modified: trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/TemplateManager.java =================================================================== --- trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/TemplateManager.java 2011-05-03 13:05:25 UTC (rev 14) +++ trunk/vradi-services/src/main/java/org/chorem/vradi/services/managers/TemplateManager.java 2011-05-03 13:49:28 UTC (rev 15) @@ -47,6 +47,7 @@ import com.sun.star.util.XRefreshable; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.chorem.vradi.VradiServiceConfiguration; import org.chorem.vradi.VradiServiceConfigurationHelper; import org.chorem.vradi.services.VradiException; import org.chorem.vradi.services.ooo.SingletonOOo; @@ -57,8 +58,12 @@ import java.io.File; import java.net.MalformedURLException; import java.net.URL; +import java.text.DateFormat; +import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Date; import java.util.List; +import java.util.Locale; import java.util.Map; /** @@ -227,7 +232,7 @@ * Creating a correct File URL that OpenOffice can handle. This is * necessary to be platform independent. * - * @param filelocation + * @param file * @return openoffice internal url * @throws VradiException in cas of MalformedURLException */ @@ -290,16 +295,25 @@ .queryInterface(XRefreshable.class, xEnumeratedFields); for (int i = 0; i < fieldCount; i++) { + Object value = myValues.get(fieldNames[i]); + + // sletellier 20110503 : make date humain readable (http://chorem.org/issues/show/337) + if (value instanceof Date) { + ApplicationConfig config = VradiServiceConfiguration.getConfig(); + Locale locale = VradiServiceConfigurationHelper.getLocale(config); + DateFormat dateFormat = new SimpleDateFormat("EEEE, d MMMM yyyy HH:mm:ss", locale); + value = dateFormat.format((Date) value); + } + if (log.isDebugEnabled()) { log.debug("Replacing " + fieldNames[i] + " with " - + myValues.get(fieldNames[i])); + + value); } - xPropertySets[i].setPropertyValue("Content", myValues - .get(fieldNames[i])); + xPropertySets[i].setPropertyValue("Content", value); - if (log.isDebugEnabled() && myValues.get(fieldNames[i]) == null) { + if (log.isDebugEnabled() && value == null) { log.debug("Field " + fieldNames[i] + " could not be found"); } } @@ -315,7 +329,7 @@ * <p/> * Source : http://user.services.openoffice.org/fr/forum/viewtopic.php?f=15&t=6357&p=31958 * - * @param image the file containing the image to insert + * @param imageUrl the url containing the image to insert * @throws VradiException */ protected void insertImageInEndOfDocument(String imageUrl) throws VradiException {
participants (1)
-
sletellier@users.chorem.org