Scarab commit: svn commit: r10835 - trunk/src: java/org/tigris/scarab/actions webapp/WEB-INF/templates/screens/entry

Hussayn Dabbous <[email protected]>
Newsgroups gmane.comp.java.scarab.cvs
Message-ID <[email protected]>
Author: dabbous
Date: 2009-07-25 10:15:58-0700
New Revision: 10835

Modified:
   trunk/src/java/org/tigris/scarab/actions/AssignIssue.java
   trunk/src/java/org/tigris/scarab/actions/ModifyIssue.java
   trunk/src/java/org/tigris/scarab/actions/ReportIssue.java
   trunk/src/webapp/WEB-INF/templates/screens/entry/Wizard3.vm

Log:
SCB2993: Added preliminary support for javascript automation:

AssignIssue.java: Added handler code for potential NPE due to scripts which feed wrong
data. I prefer to see an error message on the GUI instead of getting a
stack trace.

ModifyIssue.java: Added the ability to add watchers and modify attributes in parallel.

ReportIssue.java: Added the ability to assign users/watchers upon entry of an issue.
This feature can only be used when you add you own automation scripts into the scarab GUI.
(I have added a javascript based observer support recently for that purpose)

Wizard3.vm: Added the list of assignable users as hidden input field. I currently need this so that
an automation script can add a watcher/assignee and have all necessary data at hand. This will
be removed later, because it potentially can cause a huge transport of data between Scarab
and the front end (think of the current self host which ahs ~7000 registered users.

Modified: trunk/src/java/org/tigris/scarab/actions/AssignIssue.java
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/java/org/tigris/scarab/actions/AssignIssue.java?view=diff&pathrev=10835&r1=10834&r2=10835
==============================================================================
--- trunk/src/java/org/tigris/scarab/actions/AssignIssue.java	(original)
+++ trunk/src/java/org/tigris/scarab/actions/AssignIssue.java	2009-07-25 10:15:58-0700
@@ -118,7 +118,21 @@
                     {
                         attributeId = params.get("watcher_attr_" + userId);
                     }
-                    userAttributes.put(userId, attributeId);
+                    if(attributeId == null)
+                    {
+                        // The specified userid has not been associated to any userAttribute
+                        // This happens typically if the specified userId does not exist,
+                        // or the userid has no permission to be assigned to this issue.
+                        // This can only be an application error (in the velocity templates)
+                        // Scarab drops the userID and does not assign a userAttribute
+                        // for this user to the issue.
+                        
+                        scarabR.setAlertMessage("Illegal attempt to assign user with id ["+userId+"] to a new issue. Probably this is a wrong automation setting. Please Check your javascript observers!");
+                    }
+                    else
+                    {
+                        userAttributes.put(userId, attributeId);
+                    }
                 }
                 else
                 {

Modified: trunk/src/java/org/tigris/scarab/actions/ModifyIssue.java
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/java/org/tigris/scarab/actions/ModifyIssue.java?view=diff&pathrev=10835&r1=10834&r2=10835
==============================================================================
--- trunk/src/java/org/tigris/scarab/actions/ModifyIssue.java	(original)
+++ trunk/src/java/org/tigris/scarab/actions/ModifyIssue.java	2009-07-25 10:15:58-0700
@@ -477,6 +477,11 @@
             modifiedAttribute = true;
         }
         
+        String assignWatcherUser = runData.getParameters().get("add_watcher");
+        if(assignWatcherUser != null && assignWatcherUser.length() > 0)
+        {
+            doAddwatchers(runData, context);
+        }
         
         while (iter2.hasNext())
         {

Modified: trunk/src/java/org/tigris/scarab/actions/ReportIssue.java
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/java/org/tigris/scarab/actions/ReportIssue.java?view=diff&pathrev=10835&r1=10834&r2=10835
==============================================================================
--- trunk/src/java/org/tigris/scarab/actions/ReportIssue.java	(original)
+++ trunk/src/java/org/tigris/scarab/actions/ReportIssue.java	2009-07-25 10:15:58-0700
@@ -570,11 +570,48 @@
                     }
                     doRedirect(data, context, templateCode, issue);
                 
-                  NotificationManagerFactory.getInstance()
+                    NotificationManagerFactory.getInstance()
                             .addActivityNotification(
                                     ActivityType.ISSUE_CREATED,
                                     activitySet, issue, user);                        
 
+                    String assignActiveUser = data.getParameters().get("add_user");
+                    if(assignActiveUser != null && assignActiveUser.length() > 0)
+                    {                      
+                        // Lets cross-call the AssignIssue Turbine action!
+                        AssignIssue assignAction = new AssignIssue();
+                        assignAction.doAdd(data, context);
+                        assignAction.doSave(data, context);
+                    }
+                  
+                    String assignWatcherUser = data.getParameters().get("add_watcher");
+                    if(assignWatcherUser != null && assignWatcherUser.length() > 0)
+                    {
+                        if (user.hasPermission(ScarabSecurity.ISSUE__ASSIGN, 
+                            issue.getModule()))
+                        {
+                            // We'll set the info required by AssignIssue.doAddmyself (the)
+                            // same that in doEditassignees in this same class.
+                            data.getParameters().add("id", issue.getUniqueId());
+                            data.getParameters().add("issue_ids", issue.getUniqueId());
+                            String watcher = data.getParameters().get("add_watcher");
+                            data.getParameters().remove("add_user");
+                            data.getParameters().add("add_user", watcher);
+                
+                            scarabR.resetAssociatedUsers();
+                            
+                            // Lets cross-call the AssignIssue Turbine action!
+                            AssignIssue assignAction = new AssignIssue();
+                            assignAction.doAdd(data, context);
+                            assignAction.doSave(data, context);
+                        }
+                        else
+                        {
+                            scarabR.setAlertMessage(NO_PERMISSION_MESSAGE);
+                        }
+                    }
+                  
+                  
                     cleanup(data, context);
                     data.getParameters().add("id", issue.getUniqueId().toString());
                     L10NMessage l10nMessage = 

Modified: trunk/src/webapp/WEB-INF/templates/screens/entry/Wizard3.vm
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/webapp/WEB-INF/templates/screens/entry/Wizard3.vm?view=diff&pathrev=10835&r1=10834&r2=10835
==============================================================================
--- trunk/src/webapp/WEB-INF/templates/screens/entry/Wizard3.vm	(original)
+++ trunk/src/webapp/WEB-INF/templates/screens/entry/Wizard3.vm	2009-07-25 10:15:58-0700
@@ -3,15 +3,43 @@
 #set ($issueType = $issue.IssueType)
 #set ($rmit      = $module.getRModuleIssueType($issueType))
 
+#set ($watchedAttrib = -1)
+#foreach ($selectUserAttr in $module.getUserAttributes($issueType))
+  #if ($selectUserAttr.getMultiValue() == true)
+    #set ($watchedAttrib = $selectUserAttr)
+    #break;
+  #end
+#end
+
+## ======================================================
+## Create a hidden list of assignable users.
+## This list is used for Scarab automated user assigning
+## through an automation process. Note that this introduces
+## a potentially huge list. I will rework that soon, so that
+## we can auto assign users without having this list at hand.
+## ======================================================
+#macro (watchingUsers)
+    #set ($archivingScarabUsers = $module.getArchivingScarabUsers())
+    #set ($users = $module.getUsers("Issue | View"))
+    ## Create a selection box
+    #foreach ($user in $users)
+      #if (!$archivingScarabUsers.contains($user))
+        #set ($optionName  = "watcher_attr_" + $user.UserId)
+        #set ($attributeId = $watchedAttrib.AttributeId)
+        <input type="hidden" name="$optionName" value="$attributeId"/>
+      #end
+    #end
+#end
+
 <div class="app" id="div2-1-0">
 
   <h3>$l10n.format("NewIssue", $rmit.DisplayName.toLowerCase())</h3>
 
   <form method="post" name="form" action="$link.setPage("entry,Wizard3.vm")" enctype="multipart/form-data">
     <input type="hidden" name="action" value="ReportIssue" />
-
     <input type="hidden" name="issueType" value="$issueType.IssueTypeId" />
-
+    #watchingUsers()
+    
     #set ($moduleAttributeGroups = $issueType.getAttributeGroups($module, true))
     #set ($showTemplates = true)
     #if ($data.Parameters.getString("oldscreen"))

------------------------------------------------------
http://scarab.tigris.org/ds/viewMessage.do?dsForumId=3577&dsMessageId=2375558
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.