incubator-esme-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhir...@apache.org
Subject svn commit: r952130 - in /incubator/esme/trunk/server/src/main/scala/org/apache/esme: lib/ActionMgr.scala model/Action.scala model/User.scala
Date Mon, 07 Jun 2010 08:02:20 GMT
Author: rhirsch
Date: Mon Jun  7 08:02:19 2010
New Revision: 952130

URL: http://svn.apache.org/viewvc?rev=952130&view=rev
Log:
[ESME-92] Actions display user-ids rather than user nicknames
Patch by Imtiaz Ahmed Hajee Esmail 

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

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/ActionMgr.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/ActionMgr.scala?rev=952130&r1=952129&r2=952130&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/ActionMgr.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/ActionMgr.scala Mon Jun
 7 08:02:19 2010
@@ -38,6 +38,7 @@ import util._
 import common._
 import Helpers._
 
+import org.apache.esme._
 import model._
 import JqJsCmds._
 import JsCmds._ 
@@ -91,7 +92,8 @@ object ActionMgr {
                                                    "name" -> i.name.is,
                                                    "enabled" -> ajaxCheckbox(!i.disabled,
                                                                              e => {i.disabled(!e).save;
DisplayMessage("messages", <b>{S.?("base_action_msg_active",i.name)}</b>,  3 seconds,
3 seconds) & Noop} ),
-                                                   "test" -> i.testText,
+                                                   //"test" -> i.testText,
+                                                   "test" -> TestAction.testTextToDisplayStr(i.testText),
                                                    "action" -> i.actionText,
                                                    "createdDate" -> getDateHtml(i.createdDate),
                                                    "remove" -%> a(() => {i.removed(true).save
; updateSpan() & DisplayMessage("messages", <b>{S.?("base_action_msg_removed", i.name)}</b>,
 3 seconds, 3 seconds)}, Text("delete"))

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=952130&r1=952129&r2=952130&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 Mon Jun
 7 08:02:19 2010
@@ -334,8 +334,25 @@ class PerformMatcher(val func: Action.Te
  * The condition causing an action to be performed
  * Note: toStr must return a String which would be parsed to an identical object!
  */
+
+object TestAction {
+  import MsgParser._
+  def testTextToDisplayStr(in: String) = {
+    try {
+      testExpr(in) match {
+        case Success(v, _) => v.toDisplayStr
+        case Failure(m, _) => "ERROR"
+        case Error(m, _) => "ERROR"
+      }
+    } catch {
+      case e: Exception => "ERROR"
+    }
+  }
+}
+
 sealed trait TestAction {
   def toStr: String
+  def toDisplayStr: String = toStr
 }
 case object AnyAction extends TestAction {
   def toStr = "any"
@@ -356,6 +373,7 @@ case class AndAction(left: TestAction, r
 
 case class AtUserAction(userId: Long) extends TestAction {
   def toStr = "@"+userId
+  override def toDisplayStr = "@" + User.getNickname(userId)
 }
 
 case class ConvAction(convId: Long) extends TestAction {
@@ -376,6 +394,7 @@ case object ResentAction extends TestAct
 
 case class ResentAction(userId: Long) extends TestAction {
   def toStr = "resent:" + userId
+  override def toDisplayStr = "resent:" + User.getNickname(userId)
 }
 
 case class RegexAction(re: String) extends TestAction {
@@ -431,6 +450,11 @@ case class AtSendAction(users: List[Long
       case x :: Nil => "@"+x
       case xs => xs.map(v => "@"+v).mkString("(", ", ", ")")
     })
+
+  override def toDisplayStr = "to "+opr.toStr+" "+(users match {
+      case x :: Nil => "@"+ User.getNickname(x)
+      case xs => xs.map(v => "@"+ User.getNickname(v)).mkString("(", ", ", ")")
+    })
 }
 
 case object LoginAction extends TestAction {

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/User.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/User.scala?rev=952130&r1=952129&r2=952130&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/User.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/User.scala Mon Jun  7
08:02:19 2010
@@ -185,6 +185,13 @@ object User extends User with KeyedMetaM
   }
 
   def currentUser: Box[User] = curUser.is
+
+  def getNickname(userId: long) = {
+    User.find(userId) match {
+      case Full(u) => u.nickname.is
+      case _ => "ERROR"
+    }
+  }
 }
 
 /**



Mime
View raw message