incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danhayw...@apache.org
Subject svn commit: r1049330 - in /incubator/isis/trunk: core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/value/ support/prototype/viewer-bdd/src/test/java/org/apache/isis/support/prototype/scenarios/ viewer/bdd/common/src/main/java/org/apach...
Date Tue, 14 Dec 2010 23:30:41 GMT
Author: danhaywood
Date: Tue Dec 14 23:30:41 2010
New Revision: 1049330

URL: http://svn.apache.org/viewvc?rev=1049330&view=rev
Log:
fixing ISIS-18; applied Sabine's DateParser fix, and have fixed bug in BDD viewer which was
not reporting a failure in setProperty(...) when it failed to parse 'dd-MMM-yyyy' under de_DE
date formats.  Right now ISIS-18 is not yet fixed, but it does at least indicate where the
problem is when run the tests in support/prototype/viewer-bdd

Removed:
    incubator/isis/trunk/support/prototype/viewer-bdd/src/test/java/org/apache/isis/support/prototype/scenarios/
Modified:
    incubator/isis/trunk/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/value/ValueSemanticsProviderAbstractTemporal.java
    incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/fixtures/DateParser.java
    incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/fixtures/UsingIsisViewerPeer.java

Modified: incubator/isis/trunk/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/value/ValueSemanticsProviderAbstractTemporal.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/value/ValueSemanticsProviderAbstractTemporal.java?rev=1049330&r1=1049329&r2=1049330&view=diff
==============================================================================
--- incubator/isis/trunk/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/value/ValueSemanticsProviderAbstractTemporal.java
(original)
+++ incubator/isis/trunk/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/value/ValueSemanticsProviderAbstractTemporal.java
Tue Dec 14 23:30:41 2010
@@ -43,13 +43,13 @@ import org.apache.isis.core.metamodel.sp
 
 public abstract class ValueSemanticsProviderAbstractTemporal extends ValueSemanticsProviderAbstract
implements DateValueFacet {
 
+    //public static final String PREFERRED_FORMAT_KEY = ""
     protected static final String ISO_ENCODING_FORMAT = "iso_encoding";
     private static final TimeZone UTC_TIME_ZONE;
 
     static {
         TimeZone timeZone = TimeZone.getTimeZone("Etc/UTC");
         if (timeZone == null) {
-            // for dotnet compatibility - Etc/UTC fails in dotnet
             timeZone = TimeZone.getTimeZone("UTC");
         }
         UTC_TIME_ZONE = timeZone;

Modified: incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/fixtures/DateParser.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/fixtures/DateParser.java?rev=1049330&r1=1049329&r2=1049330&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/fixtures/DateParser.java
(original)
+++ incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/fixtures/DateParser.java
Tue Dec 14 23:30:41 2010
@@ -13,101 +13,98 @@ import java.util.TimeZone;
  */
 public class DateParser {
 
-	/**
-	 * Taken from the {@link org.apache.isis.applib.value.Date}
-	 */
-	private static final TimeZone UTC_TIME_ZONE;
-
-	static {
-		// for dotnet compatibility -
-		TimeZone timeZone = TimeZone.getTimeZone("Etc/UTC");
-		if (timeZone == null) {
-			// for dotnet compatibility - "Etc/UTC fails in dotnet
-			timeZone = TimeZone.getTimeZone("UTC");
-		}
-		UTC_TIME_ZONE = timeZone;
-	}
-
-	private static final String DEFAULT_DATE_MASK = "dd-MMM-yyyy";
-	private static final String DEFAULT_TIME_MASK = "hh:mm";
-
-	private String dateMask = DEFAULT_DATE_MASK;
-	private String timeMask = DEFAULT_TIME_MASK;
-	private DateFormat dateAndTimeFormat = null;
-	private DateFormat dateOnlyFormat = null;
-	private DateFormat timeOnlyFormat = null;
-
-	public DateParser() {
-	}
-
-	public Date parse(String dateAndOrTimeStr) {
-		try {
-			return getDateAndTimeFormat().parse(dateAndOrTimeStr);
-		} catch (ParseException e) {
-			try {
-				return getDateFormat().parse(dateAndOrTimeStr);
-			} catch (ParseException e2) {
-				try {
-					return getTimeFormat().parse(dateAndOrTimeStr);
-				} catch (ParseException e3) {
-					return null;
-				}
-			}
-		}
-	}
-
-	public void setDateFormat(String dateMask) {
-		this.dateMask = dateMask;
-		invalidateFormats();
-	}
-
-	public void setTimeFormat(String timeMask) {
-		this.timeMask = timeMask;
-		invalidateFormats();
-	}
-
-	private void invalidateFormats() {
-		this.dateAndTimeFormat = null;
-	}
-
-	public String format(Date resultDate) {
-		return getDateAndTimeFormat().format(resultDate);
-	}
-
-	private DateFormat getDateAndTimeFormat() {
-		if (dateAndTimeFormat == null) {
-			dateAndTimeFormat = getUTCDateFormat(combinedMask());
-		}
-		return dateAndTimeFormat;
-	}
-
-	private DateFormat getTimeFormat() {
-		if (timeOnlyFormat == null) {
-			timeOnlyFormat = getUTCDateFormat(timeMask);
-		}
-		return timeOnlyFormat;
-	}
-
-	private DateFormat getDateFormat() {
-		if (dateOnlyFormat == null) {
-			dateOnlyFormat = getUTCDateFormat(dateMask);
-		}
-		return dateOnlyFormat;
-	}
-
-	private DateFormat getUTCDateFormat(String dateTimeMask) {
-		DateFormat dateFormat = new SimpleDateFormat(dateTimeMask);
-		dateFormat.setTimeZone(UTC_TIME_ZONE);
-		return dateFormat;
-	}
-
-	private String combinedMask() {
-		return MessageFormat.format("{0} {1}", dateMask, timeMask);
-	}
-
-	@Override
-	public String toString() {
-		return combinedMask();
-	}
+    /**
+     * Taken from the {@link org.apache.isis.applib.value.Date}
+     */
+    private static final TimeZone UTC_TIME_ZONE;
+    static {
+        TimeZone timeZone = TimeZone.getTimeZone("Etc/UTC");
+        if (timeZone == null) {
+            timeZone = TimeZone.getTimeZone("UTC");
+        }
+        UTC_TIME_ZONE = timeZone;
+    }
+
+    private static final String DEFAULT_DATE_MASK = "dd-MMM-yyyy";
+    private static final String DEFAULT_TIME_MASK = "hh:mm";
+
+    private String dateMask = DEFAULT_DATE_MASK;
+    private String timeMask = DEFAULT_TIME_MASK;
+    private DateFormat dateAndTimeFormat = null;
+    private DateFormat dateOnlyFormat = null;
+    private DateFormat timeOnlyFormat = null;
+
+    public DateParser() {
+    }
+
+    public Date parse(String dateAndOrTimeStr) {
+        try {
+            return getDateAndTimeFormat().parse(dateAndOrTimeStr);
+        } catch (ParseException e) {
+            try {
+                return getDateFormat().parse(dateAndOrTimeStr);
+            } catch (ParseException e2) {
+                try {
+                    return getTimeFormat().parse(dateAndOrTimeStr);
+                } catch (ParseException e3) {
+                    return null;
+                }
+            }
+        }
+    }
+
+    public void setDateFormat(String dateMask) {
+        this.dateMask = dateMask;
+        invalidateFormats();
+    }
+
+    public void setTimeFormat(String timeMask) {
+        this.timeMask = timeMask;
+        invalidateFormats();
+    }
+
+    private void invalidateFormats() {
+        this.dateAndTimeFormat = null;
+    }
+
+    public String format(Date resultDate) {
+        return getDateAndTimeFormat().format(resultDate);
+    }
+
+    private DateFormat getDateAndTimeFormat() {
+        if (dateAndTimeFormat == null) {
+            dateAndTimeFormat = getUTCDateFormat(combinedMask());
+        }
+        return dateAndTimeFormat;
+    }
+
+    private DateFormat getTimeFormat() {
+        if (timeOnlyFormat == null) {
+            timeOnlyFormat = getUTCDateFormat(timeMask);
+        }
+        return timeOnlyFormat;
+    }
+
+    private DateFormat getDateFormat() {
+        if (dateOnlyFormat == null) {
+            dateOnlyFormat = getUTCDateFormat(dateMask);
+        }
+        return dateOnlyFormat;
+    }
+
+    private DateFormat getUTCDateFormat(String dateTimeMask) {
+        DateFormat dateFormat = new SimpleDateFormat(dateTimeMask);
+        dateFormat.setTimeZone(UTC_TIME_ZONE);
+        return dateFormat;
+    }
+
+    private String combinedMask() {
+        return MessageFormat.format("{0} {1}", dateMask, timeMask);
+    }
+
+    @Override
+    public String toString() {
+        return combinedMask();
+    }
 
 }

Modified: incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/fixtures/UsingIsisViewerPeer.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/fixtures/UsingIsisViewerPeer.java?rev=1049330&r1=1049329&r2=1049330&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/fixtures/UsingIsisViewerPeer.java
(original)
+++ incubator/isis/trunk/viewer/bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/fixtures/UsingIsisViewerPeer.java
Tue Dec 14 23:30:41 2010
@@ -8,6 +8,7 @@ import java.util.Map;
 import org.apache.isis.core.commons.exceptions.NotYetImplementedException;
 import org.apache.isis.core.commons.lang.StringUtils;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.TextEntryParseException;
 import org.apache.isis.core.metamodel.facets.object.parseable.ParseableFacet;
 import org.apache.isis.core.metamodel.runtimecontext.spec.feature.ObjectActionSet;
 import org.apache.isis.core.metamodel.spec.ObjectSpecification;
@@ -313,7 +314,11 @@ public class UsingIsisViewerPeer extends
         if (parseableFacet != null) {
             try {
                 return parseableFacet.parseTextEntry(contextAdapter, cellText);
+            } catch (final TextEntryParseException ex) {
+                throw ScenarioBoundValueException.arg(contextBinding, paramCell, "(cannot
parse '"+cellText+"')");
             } catch (final IllegalArgumentException ex) {
+                // REVIEW: isn't what is thrown, but perhaps 
+                // TextEntryParseException should inherit from IllegalArgumentException?

                 throw ScenarioBoundValueException.arg(contextBinding, paramCell, "(cannot
parse '"+cellText+"')");
             }
         }



Mime
View raw message