continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r788577 - in /continuum/trunk: continuum-api/src/main/java/org/apache/continuum/dao/ProjectDao.java continuum-store/src/main/java/org/apache/continuum/dao/ProjectDaoImpl.java
Date Fri, 26 Jun 2009 05:06:38 GMT
Author: evenisse
Date: Fri Jun 26 05:06:38 2009
New Revision: 788577

URL: http://svn.apache.org/viewvc?rev=788577&view=rev
Log:
-Reimplement getProjectsWithDependenciesByGroupId by working only in the DB instead of to
get all datas and filter them in java
-Remove unused code
merge 788573:788574 from continuum-1.3.x branch

Modified:
    continuum/trunk/continuum-api/src/main/java/org/apache/continuum/dao/ProjectDao.java
    continuum/trunk/continuum-store/src/main/java/org/apache/continuum/dao/ProjectDaoImpl.java

Modified: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/dao/ProjectDao.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/continuum/dao/ProjectDao.java?rev=788577&r1=788576&r2=788577&view=diff
==============================================================================
--- continuum/trunk/continuum-api/src/main/java/org/apache/continuum/dao/ProjectDao.java (original)
+++ continuum/trunk/continuum-api/src/main/java/org/apache/continuum/dao/ProjectDao.java Fri
Jun 26 05:06:38 2009
@@ -65,8 +65,6 @@
     List<Project> getProjectsInGroupWithDependencies( int projectGroupId )
         throws ContinuumStoreException;
 
-    List<Project> getAllProjectsWithAllDetails();
-
     Project getProjectWithAllDetails( int projectId )
         throws ContinuumStoreException;
 

Modified: continuum/trunk/continuum-store/src/main/java/org/apache/continuum/dao/ProjectDaoImpl.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-store/src/main/java/org/apache/continuum/dao/ProjectDaoImpl.java?rev=788577&r1=788576&r2=788577&view=diff
==============================================================================
--- continuum/trunk/continuum-store/src/main/java/org/apache/continuum/dao/ProjectDaoImpl.java
(original)
+++ continuum/trunk/continuum-store/src/main/java/org/apache/continuum/dao/ProjectDaoImpl.java
Fri Jun 26 05:06:38 2009
@@ -19,6 +19,16 @@
  * under the License.
  */
 
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.jdo.Extent;
+import javax.jdo.PersistenceManager;
+import javax.jdo.Query;
+import javax.jdo.Transaction;
+
 import org.apache.continuum.model.project.ProjectGroupSummary;
 import org.apache.continuum.model.project.ProjectSummaryResult;
 import org.apache.maven.continuum.model.project.Project;
@@ -27,17 +37,6 @@
 import org.apache.maven.continuum.store.ContinuumStoreException;
 import org.springframework.stereotype.Repository;
 
-import javax.jdo.Extent;
-import javax.jdo.PersistenceManager;
-import javax.jdo.Query;
-import javax.jdo.Transaction;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
 /**
  * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
  * @version $Id$
@@ -154,22 +153,33 @@
         }
     }
 
-    // todo get this natively supported in the store
     public List<Project> getProjectsWithDependenciesByGroupId( int projectGroupId )
     {
-        List<Project> allProjects =
-            getAllObjectsDetached( Project.class, "name ascending", PROJECT_DEPENDENCIES_FETCH_GROUP
);
+        PersistenceManager pm = getPersistenceManager();
 
-        List<Project> groupProjects = new ArrayList<Project>();
+        Transaction tx = pm.currentTransaction();
 
-        for ( Project project : allProjects )
+        try
         {
-            if ( project.getProjectGroup().getId() == projectGroupId )
-            {
-                groupProjects.add( project );
-            }
+            tx.begin();
+
+            Extent extent = pm.getExtent( Project.class, true );
+
+            Query query = pm.newQuery( extent, "projectGroup.id == " + projectGroupId );
+
+            pm.getFetchPlan().addGroup( PROJECT_DEPENDENCIES_FETCH_GROUP );
+            List<Project> result = (List<Project>) query.execute();
+
+            result = (List<Project>) pm.detachCopyAll( result );
+
+            tx.commit();
+
+            return result;
+        }
+        finally
+        {
+            rollback( tx );
         }
-        return groupProjects;
     }
 
     public Project getProjectWithBuilds( int projectId )
@@ -207,9 +217,9 @@
 
             query.setOrdering( "name ascending" );
 
-            List result = (List) query.execute();
+            List<Project> result = (List<Project>) query.execute();
 
-            result = (List) pm.detachCopyAll( result );
+            result = (List<Project>) pm.detachCopyAll( result );
 
             tx.commit();
 
@@ -242,9 +252,9 @@
 
             pm.getFetchPlan().addGroup( PROJECTGROUP_PROJECTS_FETCH_GROUP );
 
-            List result = (List) query.execute();
+            List<Project> result = (List<Project>) query.execute();
 
-            result = (List) pm.detachCopyAll( result );
+            result = (List<Project>) pm.detachCopyAll( result );
 
             tx.commit();
 
@@ -256,12 +266,6 @@
         }
     }
 
-
-    public List<Project> getAllProjectsWithAllDetails()
-    {
-        return getAllObjectsDetached( Project.class, "name ascending", PROJECT_ALL_DETAILS_FETCH_GROUP
);
-    }
-
     public Project getProjectWithAllDetails( int projectId )
         throws ContinuumStoreException
     {
@@ -349,7 +353,7 @@
             int projectGroupId = result.getProjectGroupId();
             int size = new Long( result.getSize() ).intValue();
             int state = result.getProjectState();
-            
+
             if ( map.containsKey( projectGroupId ) )
             {
                 summary = map.get( projectGroupId );



Mime
View raw message