Scarab commit: svn commit: r10937 - trunk: . src/conf/classes src/java/org/tigris/scarab/om src/java/org/tigris/scarab/xmlrpc

Johannes Höchstädter <[email protected]>
Newsgroups gmane.comp.java.scarab.cvs
Message-ID <[email protected]>
Author: jhoech
Date: 2010-03-01 05:50:26-0800
New Revision: 10937

Modified:
   trunk/   (props changed)
   trunk/properties.xsl   (props changed)
   trunk/src/conf/classes/ScarabBundle_de.properties
   trunk/src/java/org/tigris/scarab/om/Issue.java
   trunk/src/java/org/tigris/scarab/xmlrpc/NewTicketHandler.java

Log:
MRG - Merged some revisions from b22-release branch starting from last revision of merge: 10904-10914

Modified: trunk/src/conf/classes/ScarabBundle_de.properties
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/conf/classes/ScarabBundle_de.properties?view=diff&pathrev=10937&r1=10936&r2=10937
==============================================================================
--- trunk/src/conf/classes/ScarabBundle_de.properties	(original)
+++ trunk/src/conf/classes/ScarabBundle_de.properties	2010-03-01 05:50:26-0800
@@ -1016,7 +1016,7 @@
 AttrMappedToModules=Dieses Attribut ist mit einem oder mehreren Modulen verbunden. Wird es gelöscht, und diese Löschung später rückgängig gemacht, muss es zu diesen Modulen wieder hinzugefügt werden.
 AttrMappedToIssueTypes=Dieses Attribut ist mit einem oder mehreren Ticket-Typen verbunden. Wird es gelöscht, und diese Löschung später rückgängig gemacht, muss es zu diesen Ticket-Typen wieder hinzugefügt werden.
 NoUserAttributeSelected=Kein Benutzerattribut zum Löschen ausgewählt.
-NoAttributeSelected=KeineAttribut zum löschen ausgewählt.
+NoAttributeSelected=Kein Attribut zum löschen ausgewählt.
 CannotDeleteAttributeFromLockedIssueType=Sie können keine Attribute ändern, weil dieser Ticket-Typ gesperrt ist.
 DeletedOptionsFromRequiredAttribute=Sie haben gerade alle aktiven Optionen aus diesem Pflichtattribut entfernt. Deshalb wurde die "Pflicht"-Markierung aufgehoben. Um das Feld wieder als Pflichfeld markieren zu können, müssen Sie vorher wieder mindestens eine aktive Option einfügen.
 CannotRequireAttributeWithNoOptions=Attribute können nur dann als aktiv markiert werden, wenn Sie mindestens eine aktive Option besitzen.
@@ -1176,7 +1176,7 @@
 
 ## ModuleAttributeEdit title
 EditModuleAttribute=Modulattribute ändern "{0}"
-NoAttributeToEdit=Fehler! Kein Attribut zum ädern ausgewählt.
+NoAttributeToEdit=Fehler! Kein Attribut zum ändern ausgewählt.
 
 ## UserAttributeEdit title
 EditGlobalUserAttribute=Globales Benutzerattribut "{0}" ändern

Modified: trunk/src/java/org/tigris/scarab/om/Issue.java
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/java/org/tigris/scarab/om/Issue.java?view=diff&pathrev=10937&r1=10936&r2=10937
==============================================================================
--- trunk/src/java/org/tigris/scarab/om/Issue.java	(original)
+++ trunk/src/java/org/tigris/scarab/om/Issue.java	2010-03-01 05:50:26-0800
@@ -1097,7 +1097,10 @@
 
 
     /**
-     * AttributeValues that are set for this Issue
+     * Returns AttributeValues that are set for this Issue.
+     * 
+     * @return : Map with mappings for : attrinbute-Name/attribute-value
+     * @throws TorqueException
      */
     public Map getAttributeValuesMap() throws TorqueException
     {
@@ -2129,6 +2132,17 @@
         return DependTypeManager.getAll();
     }
 
+    /**
+     * Stores depend into database and checks wheter this depend exists already.
+     * 
+     * @param activitySet : Instance of ActivitySet.
+     * @param depend : Instance of depend.
+     * @param childIssue : Issue which is target of dependency.
+     * @param user : Instance of user.
+     * @return : ActivitySet.
+     * @throws TorqueException
+     * @throws ScarabException
+     */
     public ActivitySet doAddDependency(ActivitySet activitySet, Depend depend, 
                                        Issue childIssue, ScarabUser user)
         throws TorqueException, ScarabException
@@ -3552,11 +3566,18 @@
     }
 
     /**
+     * 
      * Sets original AttributeValues for an new issue based on a hashmap of values
      * This is data is saved to the database and the proper ActivitySet is 
      * also recorded.
-     *
-     * @throws TorqueException when the workflow has an error to report
+     * 
+     * @param activitySet : Instance of activity set.
+     * @param attachment : Some attachment, e.g. reason of change.
+     * @param newValues : Map with mappings for attribute-values: id/attribute-value
+     * @param user : Instance of user.
+     * @return : Instance of activity set.
+     * @throws TorqueException
+     * @throws ScarabException
      */
     public ActivitySet setInitialAttributeValues(ActivitySet activitySet, 
             Attachment attachment, 
@@ -3757,6 +3778,12 @@
      * Make sure that workflow is valid for the initial values of a new issue. 
      * It will return a non-null String
      * which is the workflow error message otherwise it will return null.
+     * 
+     * @param newValues : Map with mapings of: id/attribute-value
+     * @param user : User instance.
+     * @return
+     * @throws TorqueException
+     * @throws ScarabException
      */
     public String doCheckInitialAttributeValueWorkflow(final HashMap newValues, 
                                                        final ScarabUser user)
@@ -3784,11 +3811,17 @@
         return msg;
     }
 
-    /**
-     * This method is used with the setAttributeValues() method to 
-     * Make sure that workflow is valid. It will return a non-null String
-     * which is the workflow error message otherwise it will return null.
-     */
+   /**
+    * This method is used with the setAttributeValues() method to 
+    * Make sure that workflow is valid. It will return a non-null String
+    * which is the workflow error message otherwise it will return null.
+    * 
+    * @param newAttVals : Map with mapings of: id/attribute-value
+    * @param user : User instance.
+    * @return
+    * @throws TorqueException
+    * @throws ScarabException
+    */
     public String doCheckAttributeValueWorkflow(final HashMap newAttVals, 
                                                 final ScarabUser user)
         throws TorqueException,ScarabException

Modified: trunk/src/java/org/tigris/scarab/xmlrpc/NewTicketHandler.java
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/java/org/tigris/scarab/xmlrpc/NewTicketHandler.java?view=diff&pathrev=10937&r1=10936&r2=10937
==============================================================================
--- trunk/src/java/org/tigris/scarab/xmlrpc/NewTicketHandler.java	(original)
+++ trunk/src/java/org/tigris/scarab/xmlrpc/NewTicketHandler.java	2010-03-01 05:50:26-0800
@@ -26,91 +26,85 @@
 *
 */
 
-import java.text.SimpleDateFormat;
 import java.util.HashMap;
 import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
+
 
 import org.apache.commons.collections.MapIterator;
 import org.apache.commons.collections.map.LinkedMap;
-import org.apache.fulcrum.intake.model.Field;
-import org.apache.fulcrum.intake.model.Group;
+
 import org.apache.log4j.Category;
 import org.apache.torque.TorqueException;
-import org.apache.torque.util.Criteria;
-import org.tigris.scarab.attribute.DateAttribute;
-import org.tigris.scarab.attribute.OptionAttribute;
-import org.tigris.scarab.notification.ActivityType;
-import org.tigris.scarab.notification.NotificationManagerFactory;
-import org.tigris.scarab.om.ActivityManager;
 import org.tigris.scarab.om.ActivitySet;
 import org.tigris.scarab.om.Attachment;
-import org.tigris.scarab.om.AttachmentManager;
-import org.tigris.scarab.om.AttachmentType;
-import org.tigris.scarab.om.AttachmentTypeManager;
-import org.tigris.scarab.om.Attribute;
-import org.tigris.scarab.om.AttributeManager;
-import org.tigris.scarab.om.AttributeOption;
-import org.tigris.scarab.om.AttributeOptionManager;
 import org.tigris.scarab.om.AttributeValue;
-import org.tigris.scarab.om.AttributeValueManager;
 import org.tigris.scarab.om.Issue;
 import org.tigris.scarab.om.IssueType;
-import org.tigris.scarab.om.IssueTypeManager;
 import org.tigris.scarab.om.Module;
-import org.tigris.scarab.om.ScarabModulePeer;
+import org.tigris.scarab.om.ModuleManager;
 import org.tigris.scarab.om.ScarabUser;
 import org.tigris.scarab.om.ScarabUserManager;
-import org.tigris.scarab.tools.localization.L10NKeySet;
 import org.tigris.scarab.util.ScarabException;
 
 /**
+ * Handler which provides all necessary methods to create an issues via xml-rpc interface.
+ * 
  * @author pti
  *
  */
 public class NewTicketHandler {
+	
 	Category logger = Category.getInstance(NewTicketHandler.class);
 
 	/**
-	 * @param module	The module to add the ticket to
-	 * @param issueType The issuetype as which the ticket should be entered
-	 * @param user      The user as which the ticket should be entered
-	 * @param attribs   A map with the attributes to be entered
-	 * @return
+	 * Creates a new issue from given parameters.
+	 * 
+	 * @param moduleCode		The module to add the ticket to (shortcut of moudle)
+	 * @param issueTypeName 	The issuetype as which the ticket should be entered (name of issue type)
+	 * @param userName      	The user as which the ticket should be entered (login name)
+	 * @param attribs   		A map with the attributes to be entered. (name/value mappings)
+	 * @return : Unique id of issue: {module shortcut}{count}
 	 * @throws TorqueException 
 	 * @throws ScarabException 
 	 */
-	public String createNewTicket( String moduleName, 
+	public String createNewTicket( String moduleCode, 
 								   String issueTypeName, 
 								   String userName, 
 								   Hashtable attribs) throws TorqueException, ScarabException {
-		Module module = getModuleByCode(moduleName);
+		
+		//init environment for the new issue
+		Module module = ModuleManager.getInstance(null, null, moduleCode);
 		IssueType issueType = IssueType.getInstance(issueTypeName);
 		Issue issue = module.getNewIssue(issueType);
 		ScarabUser user = ScarabUserManager.getInstance(userName);
-		HashMap values = getAttributes(issue);
-        ActivitySet activitySet = null;
+        
         Attachment reason = new Attachment();
         reason.setData("Created by xmlrpc");
         reason.setName("reason");
-        activitySet = issue
-            .setInitialAttributeValues(activitySet, reason, values, user);
         
-//        issue.setAttributeValues(activitySet, values, reason, user);
-        // Save any unsaved attachments as part of this ActivitySet as well
+        //init issue, set and store attributes
+		ActivitySet activitySet = null;
+        activitySet = issue.setInitialAttributeValues(activitySet, reason, new HashMap(), user);
+
+        // Save any unsaved attachments as part of this ActivitySet as well.
         setAttributes(issue,activitySet,reason,user,attribs);
         activitySet = issue.doSaveFileAttachments(activitySet, user);
         activitySet.save();
+        
         return issue.getUniqueId();
 	}
 
 	/**
-	 * @param attribs
-	 * @return
-	 * @throws TorqueException 
-	 * @throws ScarabException 
+	 * Gets new attribute values from given map, matches them against the attributes from the new issue.
+	 * Afterwards the resulting new attribute values will be set for the new issue.
+	 * 
+	 * @param issue				Issue where attriutes should be set.
+	 * @param activitySet		Activity set.
+	 * @param attachment		Attachment for issue: e.g. reason for change.
+	 * @param user				User for issue creation.
+	 * @param attribs			Map with name/value mappings for new attributes values.
+	 * @throws TorqueException
+	 * @throws ScarabException
 	 */
 	private void setAttributes(Issue issue, ActivitySet activitySet, Attachment attachment, ScarabUser user, Hashtable attribs) throws TorqueException, ScarabException {
 
@@ -132,35 +126,4 @@
         issue.setAttributeValues(activitySet, newValues, attachment, user);
 	}
 
-	/**
-	 * @param attribs
-	 * @return
-	 * @throws TorqueException 
-	 */
-	private HashMap getAttributes(Issue issue) throws TorqueException {
-
-			
-		return new HashMap(issue.getAttributeValuesMap());
-	}
-
-	/**
-	 * @param module
-	 * @throws TorqueException 
-	 */
-	private Module getModuleByCode(String module) throws TorqueException {
-        final Criteria crit = new Criteria();
-        if( module != null )
-        {
-            crit.add(ScarabModulePeer.MODULE_CODE, module);
-        }
-        final List result = ScarabModulePeer.doSelect(crit);
-        if (result.size() != 1)
-        {
-            throw new TorqueException ("Selected: " + result.size() + 
-                " rows. Expected 1."); //EXCEPTION
-        }
-        return (Module) result.get(0);		// TODO Auto-generated method stub
-		
-	}
-
 }

------------------------------------------------------
http://scarab.tigris.org/ds/viewMessage.do?dsForumId=3577&dsMessageId=2453413
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.