incubator-esme-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhir...@apache.org
Subject svn commit: r990072 - /incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Action.scala
Date Fri, 27 Aug 2010 09:03:01 GMT
Author: rhirsch
Date: Fri Aug 27 09:03:01 2010
New Revision: 990072

URL: http://svn.apache.org/viewvc?rev=990072&view=rev
Log:
[ESME-263] Action test with day isn't restricted to correct days of week
Patch by Imtiaz Ahmed Hajee Esmail 

Modified:
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Action.scala

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Action.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Action.scala?rev=990072&r1=990071&r2=990072&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Action.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/Action.scala Fri Aug
27 09:03:01 2010
@@ -265,6 +265,7 @@ class Action extends LongKeyedMapper[Act
     def testFunc = (testExpr(is): @unchecked) match {
       case Success(v, _) => Action.toFunc(v)
     }
+   
   }
   
   object uniqueId extends MappedUniqueId(this, 32) {
@@ -280,7 +281,14 @@ class Action extends LongKeyedMapper[Act
 
   def setTest(in: String): Box[Action] = try {
     testExpr(in) match {
-      case Success(v, _) => Full(this.theTest(v.toStr))
+      case Success(testAction: TestAction, _) =>
+         testAction.error match {
+            case Some(msg) =>
+              net.liftweb.common.Failure(msg  + " - " + testAction.toStr, Empty, Empty)
+            case None =>
+              Full(this.theTest(testAction.toStr))
+         }
+      //case Success(v, _) => Full(this.theTest(v.toStr))
       case Failure(m, _) => net.liftweb.common.Failure(m, Empty, Empty)
       case Error(m, _) => net.liftweb.common.Failure(m, Empty, Empty)
     }
@@ -318,7 +326,7 @@ class Action extends LongKeyedMapper[Act
     test={theTest.is}
     action={theAction.is}
     enabled={enabled.toString}></action>
-
+  
 }
 
 class PerformMatcher(val func: Action.TestFunc, val performId: Long,
@@ -351,6 +359,7 @@ object TestAction {
 }
 
 sealed trait TestAction {
+  var error: Option[String] = None
   def toStr: String
   def toDisplayStr: String = toStr
 }
@@ -489,6 +498,15 @@ case class DateTestAction(dateType: Date
       case xs => xs.mkString("(", ", ", ")")
     }
   )
+
+  error =
+    dateType match {
+      case DayDateType   => if (what.exists((x) => x < 1 || x > 7)) Some("Invalid
day value") else None
+      case DateDateType  => if (what.exists((x) => x < 1 || x > 31)) Some("Invalid
date value") else None
+      case MonthDateType => if (what.exists((x) => x < 1 || x > 11)) Some("Invalid
month value") else None
+      case HourDateType  => if (what.exists((x) => x < 0 || x > 23)) Some("Invalid
hour value") else None
+      case MinuteDateType  => if (what.exists((x) => x < 0 || x > 59)) Some("Invalid
minute value") else None
+    }
 }
 
 sealed trait OprType {



Mime
View raw message