Scarab commit: svn commit: r11105 - branches/release/1.0.22/src/java/org/tigris/scarab/om

[email protected] Fri, 13 Apr 2012 00:02:36 -0700 (PDT)
Newsgroups gmane.comp.java.scarab.cvs
Message-ID <[email protected]>
Author: mcoss
Date: 2012-04-13 00:02:36-0700
New Revision: 11105

Modified:
   branches/release/1.0.22/src/java/org/tigris/scarab/om/Module.java
   branches/release/1.0.22/src/java/org/tigris/scarab/om/ScarabModule.java

Log:
FIX - Moved query for duplicate modules into separate method.

Modified: branches/release/1.0.22/src/java/org/tigris/scarab/om/Module.java
Url: http://scarab.tigris.org/source/browse/scarab/branches/release/1.0.22/src/java/org/tigris/scarab/om/Module.java?view=diff&pathrev=11105&r1=11104&r2=11105
==============================================================================
--- branches/release/1.0.22/src/java/org/tigris/scarab/om/Module.java	(original)
+++ branches/release/1.0.22/src/java/org/tigris/scarab/om/Module.java	2012-04-13 00:02:36-0700
@@ -261,6 +261,12 @@
     int getDedupeSequence(IssueType issueType)
         throws TorqueException;
 
+    /**
+     * Gets duplicate modules for given real module name and parent.
+     */
+    List getDuplicatesByNameAndParent(String realName, Integer parentId) 
+    	throws TorqueException;
+    
     List getRModuleAttributes(IssueType issueType, boolean activeOnly,
                                      String attributeType)
         throws TorqueException;

Modified: branches/release/1.0.22/src/java/org/tigris/scarab/om/ScarabModule.java
Url: http://scarab.tigris.org/source/browse/scarab/branches/release/1.0.22/src/java/org/tigris/scarab/om/ScarabModule.java?view=diff&pathrev=11105&r1=11104&r2=11105
==============================================================================
--- branches/release/1.0.22/src/java/org/tigris/scarab/om/ScarabModule.java	(original)
+++ branches/release/1.0.22/src/java/org/tigris/scarab/om/ScarabModule.java	2012-04-13 00:02:36-0700
@@ -741,6 +741,22 @@
     }
 
     /**
+     * Return duplicates for given name and parent.
+     * @param realName : Real name.
+     * @param parentId  : Id of parent module.
+     * @return : List of duplicates.
+     * @throws TorqueException
+     */
+    public List getDuplicatesByNameAndParent(String realName, Integer parentId) throws TorqueException{
+    	
+    	final Criteria crit = new Criteria();
+        crit.add(ScarabModulePeer.MODULE_NAME, realName);
+        crit.add(ScarabModulePeer.PARENT_ID, parentId);
+        return ScarabModulePeer.doSelect(crit);
+        
+    }
+    
+    /**
      * Saves the module into the database. Note that this
      * cannot be used within a activitySet if the module isNew()
      * because dbCon.commit() is called within the method. An
@@ -752,17 +768,10 @@
         // if new, make sure the code has a value.
         if (isNew())
         {
-            final Criteria crit = new Criteria();
-            crit.add(ScarabModulePeer.MODULE_NAME, getRealName());
-            crit.add(ScarabModulePeer.PARENT_ID, getParentId());
-            // FIXME: this should be done with a method in Module
-            // that takes the two criteria values as a argument so that other 
-            // implementations can benefit from being able to get the 
-            // list of modules. -- do not agree - jdm
 
             List result;
             try {
-                result = ScarabModulePeer.doSelect(crit);
+                result = getDuplicatesByNameAndParent(getRealName(), getParentId());
             }
             catch (TorqueException te)
             {

------------------------------------------------------
http://scarab.tigris.org/ds/viewMessage.do?dsForumId=3577&dsMessageId=2947947