continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r506479 - in /maven/continuum/trunk: continuum-api/src/main/java/org/apache/maven/continuum/ continuum-api/src/main/java/org/apache/maven/continuum/store/ continuum-core/src/main/java/org/apache/maven/continuum/ continuum-core/src/test/java...
Date Mon, 12 Feb 2007 15:19:58 GMT
Author: evenisse
Date: Mon Feb 12 07:19:35 2007
New Revision: 506479

URL: http://svn.apache.org/viewvc?view=rev&rev=506479
Log:
Fix some jdo calls for performance improvment

Modified:
    maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
    maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
    maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
    maven/continuum/trunk/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/SummaryAction.java
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/component/BuildDefinitionSummaryAction.java
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/component/NotifierSummaryAction.java

Modified: maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java?view=diff&rev=506479&r1=506478&r2=506479
==============================================================================
--- maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
(original)
+++ maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
Mon Feb 12 07:19:35 2007
@@ -80,6 +80,9 @@
     public ProjectGroup getProjectGroupWithProjects( int projectGroupId )
         throws ContinuumException;
 
+    public ProjectGroup getProjectGroupWithBuildDetails( int projectGroupId )
+        throws ContinuumException;
+
     public ProjectGroup getProjectGroupByGroupId( String groupId )
         throws ContinuumException;
 
@@ -115,7 +118,11 @@
 
     BuildResult getLatestBuildResultForProject( int projectId );
 
+    Map getLatestBuildResults( int projectGroupId );
+
     Map getLatestBuildResults();
+
+    Map getBuildResultsInSuccess( int projectGroupId );
 
     Map getBuildResultsInSuccess();
 

Modified: maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java?view=diff&rev=506479&r1=506478&r2=506479
==============================================================================
--- maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java
(original)
+++ maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java
Mon Feb 12 07:19:35 2007
@@ -225,11 +225,15 @@
 
     List getBuildResultsForProject( int projectId, long fromDate );
 
+    Map getLatestBuildResults( int projectGroupId );
+
     Map getLatestBuildResults();
 
     List getBuildResultByBuildNumber( int projectId, int buildNumber );
 
     Map getBuildResultsInSuccess();
+
+    Map getBuildResultsInSuccess( int projectGroupId );
 
     void addBuildResult( Project project, BuildResult build )
         throws ContinuumStoreException, ContinuumObjectNotFoundException;

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?view=diff&rev=506479&r1=506478&r2=506479
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
Mon Feb 12 07:19:35 2007
@@ -201,19 +201,18 @@
     public ProjectGroup getProjectGroup( int projectGroupId )
         throws ContinuumException
     {
-        List projectGroups = store.getAllProjectGroupsWithBuildDetails();
-
-        for ( Iterator i = projectGroups.iterator(); i.hasNext(); )
+        try
         {
-            ProjectGroup pg = (ProjectGroup) i.next();
-
-            if ( pg.getId() == projectGroupId )
-            {
-                return pg;
-            }
+            return store.getProjectGroup( projectGroupId );
+        }
+        catch ( ContinuumObjectNotFoundException e )
+        {
+            throw new ContinuumException( "invalid group id", e );
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new ContinuumException( "Error while querying for project group.", e );
         }
-
-        throw new ContinuumException( "invalid group id" );
     }
 
     public ProjectGroup getProjectGroupWithProjects( int projectGroupId )
@@ -383,6 +382,18 @@
         return store.getAllProjectsByNameWithDependencies();
     }
 
+    public Map getLatestBuildResults( int projectGroupId )
+    {
+        Map result = store.getLatestBuildResults( projectGroupId );
+
+        if ( result == null )
+        {
+            result = new HashMap();
+        }
+
+        return result;
+    }
+
     public Map getLatestBuildResults()
     {
         Map result = store.getLatestBuildResults();
@@ -395,6 +406,18 @@
         return result;
     }
 
+    public Map getBuildResultsInSuccess( int projectGroupId )
+    {
+        Map result = store.getBuildResultsInSuccess( projectGroupId );
+
+        if ( result == null )
+        {
+            result = new HashMap();
+        }
+
+        return result;
+    }
+
     public Map getBuildResultsInSuccess()
     {
         Map result = store.getBuildResultsInSuccess();
@@ -1410,7 +1433,7 @@
     public ProjectNotifier getGroupNotifier( int projectGroupId, int notifierId )
         throws ContinuumException
     {
-        ProjectGroup projectGroup = getProjectGroup( projectGroupId );
+        ProjectGroup projectGroup = getProjectGroupWithBuildDetails( projectGroupId );
 
         List notifiers = projectGroup.getNotifiers();
 
@@ -1447,7 +1470,7 @@
     public ProjectNotifier updateGroupNotifier( int projectGroupId, ProjectNotifier notifier
)
         throws ContinuumException
     {
-        ProjectGroup projectGroup = getProjectGroup( projectGroupId );
+        ProjectGroup projectGroup = getProjectGroupWithBuildDetails( projectGroupId );
 
         ProjectNotifier notif = getGroupNotifier( projectGroupId, notifier.getId() );
 
@@ -1559,7 +1582,7 @@
 
         notif.setFrom( ProjectNotifier.FROM_USER );
 
-        ProjectGroup projectGroup = getProjectGroup( projectGroupId );
+        ProjectGroup projectGroup = getProjectGroupWithBuildDetails( projectGroupId );
 
         projectGroup.addNotifier( notif );
         try
@@ -1637,7 +1660,7 @@
     public void removeGroupNotifier( int projectGroupId, int notifierId )
         throws ContinuumException
     {
-        ProjectGroup projectGroup = getProjectGroup( projectGroupId );
+        ProjectGroup projectGroup = getProjectGroupWithBuildDetails( projectGroupId );
 
         ProjectNotifier n = getGroupNotifier( projectGroupId, notifierId );
 

Modified: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java?view=diff&rev=506479&r1=506478&r2=506479
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
(original)
+++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
Mon Feb 12 07:19:35 2007
@@ -305,7 +305,7 @@
             continuum.addNotifier( p.getId(), new ProjectNotifier() );
         }
 
-        projectGroup = continuum.getProjectGroup( projectGroup.getId() );
+        projectGroup = continuum.getProjectGroupWithBuildDetails( projectGroup.getId() );
 
         assertEquals( 1, projectGroup.getNotifiers().size() );
 

Modified: maven/continuum/trunk/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java?view=diff&rev=506479&r1=506478&r2=506479
==============================================================================
--- maven/continuum/trunk/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java
(original)
+++ maven/continuum/trunk/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java
Mon Feb 12 07:19:35 2007
@@ -228,7 +228,7 @@
         // might define their own build definitions
         if ( projectGroupSource != null )
         {
-        	for ( Iterator i = projectGroupSource.keySet().iterator(); i.hasNext(); )
+            for ( Iterator i = projectGroupSource.keySet().iterator(); i.hasNext(); )
             {
                 Integer projectGroupId = (Integer) i.next();
                 List projectsInGroup = getProjectsInGroup( projectGroupId.intValue() );
@@ -243,7 +243,6 @@
                 }
             }
         }
-        
         return aggregate;
     }
 
@@ -484,7 +483,7 @@
         return null;
     }
 
-    public Map getLatestBuildResults()
+    public Map getLatestBuildResults( int projectGroupId )
     {
         PersistenceManager pm = getPersistenceManager();
 
@@ -498,9 +497,25 @@
 
             Query query = pm.newQuery( extent );
 
-            query.setFilter( "this.project.latestBuildId == this.id" );
+            String filter = "this.project.latestBuildId == this.id";
 
-            List result = (List) query.execute();
+            if ( projectGroupId > 0 )
+            {
+                query.declareParameters( "int projectGroupId" );
+                filter += " && this.project.projectGroup.id == projectGroupId";
+            }
+
+            query.setFilter( filter );
+
+            List result = null;
+            if ( projectGroupId > 0 )
+            {
+                result = (List) query.execute( new Integer( projectGroupId ) );
+            }
+            else
+            {
+                result = (List) query.execute();
+            }
 
             result = (List) pm.detachCopyAll( result );
 
@@ -528,6 +543,11 @@
         return null;
     }
 
+    public Map getLatestBuildResults()
+    {
+        return getLatestBuildResults( -1 );
+    }
+
     public void removeNotifier( ProjectNotifier notifier )
         throws ContinuumStoreException
     {
@@ -545,7 +565,6 @@
     public BuildDefinition getDefaultBuildDefinition( int projectId )
         throws ContinuumStoreException, ContinuumObjectNotFoundException
     {
-
         BuildDefinition bd = null;
 
         try
@@ -616,6 +635,7 @@
                 return bd;
             }
         }
+
         return null;
     }
 
@@ -810,7 +830,6 @@
                 groupProjects.add( project );
             }
         }
-
         return groupProjects;
     }
 
@@ -1070,11 +1089,10 @@
                 }
             }
         }
-
         return results;
     }
 
-    public Map getBuildResultsInSuccess()
+    public Map getBuildResultsInSuccess( int projectGroupId )
     {
         PersistenceManager pm = getPersistenceManager();
 
@@ -1088,9 +1106,26 @@
 
             Query query = pm.newQuery( extent );
 
-            query.setFilter( "this.project.buildNumber == this.buildNumber" );
+            String filter = "this.project.buildNumber == this.buildNumber";
 
-            List result = (List) query.execute();
+            if ( projectGroupId > 0 )
+            {
+                query.declareParameters( "int projectGroupId" );
+                filter += " && this.project.projectGroup.id == projectGroupId";
+            }
+
+            query.setFilter( filter );
+
+            List result = null;
+
+            if ( projectGroupId > 0 )
+            {
+                result = (List) query.execute( new Integer( projectGroupId ) );
+            }
+            else
+            {
+                result = (List) query.execute();
+            }
 
             result = (List) pm.detachCopyAll( result );
 
@@ -1118,6 +1153,11 @@
         return null;
     }
 
+    public Map getBuildResultsInSuccess()
+    {
+        return getBuildResultsInSuccess( -1 );
+    }
+
     public void removeProject( Project project )
     {
         removeObject( project );
@@ -1149,34 +1189,7 @@
     public List getProjectsInGroup( int projectGroupId )
         throws ContinuumObjectNotFoundException, ContinuumStoreException
     {
-        PersistenceManager pm = getPersistenceManager();
-
-        Transaction tx = pm.currentTransaction();
-
-        try
-        {
-            tx.begin();
-
-            Extent extent = pm.getExtent( Project.class, true );
-
-            Query query = pm.newQuery( extent, "projectGroup.id == " + projectGroupId );
-
-            query.setOrdering( "name ascending" );
-            
-            pm.getFetchPlan().addGroup( PROJECTGROUP_PROJECTS_FETCH_GROUP );
-
-            List result = (List) query.execute();
-
-            result = (List) pm.detachCopyAll( result );
-
-            tx.commit();
-
-            return result;
-        }
-        finally
-        {
-            rollback( tx );
-        }
+        return getProjectGroupWithProjects( projectGroupId ).getProjects();
     }
 
     public List getProjectsInGroupWithDependencies( int projectGroupId )
@@ -1333,26 +1346,16 @@
     public ProjectGroup getProjectGroupByProjectId( int projectId )
         throws ContinuumObjectNotFoundException
     {
-        // todo this chunk should be optimized in the store by a good query
-        Collection projectGroups = getAllProjectGroupsWithProjects();
-
-        for ( Iterator i = projectGroups.iterator(); i.hasNext(); )
+        try
         {
-            ProjectGroup projectGroup = (ProjectGroup) i.next();
-
-            for ( Iterator j = projectGroup.getProjects().iterator(); j.hasNext(); )
-            {
-                Project project = (Project) j.next();
-
-                if ( projectId == project.getId() )
-                {
-                    return projectGroup;
-                }
-            }
+            return getProject( projectId ).getProjectGroup();
         }
+        catch ( ContinuumStoreException e )
+        {
+            throw new ContinuumObjectNotFoundException(
+                "unable to find project group containing project with id: " + projectId );
 
-        throw new ContinuumObjectNotFoundException(
-            "unable to find project group containing project with id: " + projectId );
+        }
     }
 
     public SystemConfiguration addSystemConfiguration( SystemConfiguration systemConf )

Modified: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java?view=diff&rev=506479&r1=506478&r2=506479
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java
Mon Feb 12 07:19:35 2007
@@ -119,9 +119,9 @@
     public String members()
         throws ContinuumException
     {
-        projectGroup = getContinuum().getProjectGroup( projectGroupId );
+        projectGroup = getContinuum().getProjectGroupWithProjects( projectGroupId );
 
-        groupProjects = getContinuum().getProjectsInGroup( projectGroupId );
+        groupProjects = projectGroup.getProjects();
 
         populateProjectGroupUsers( projectGroup );
 
@@ -149,7 +149,6 @@
     public String remove()
         throws ContinuumException
     {
-        //todo add confirm page like removing build definition
         if ( confirmed )
         {
             getContinuum().removeProjectGroup( projectGroupId );
@@ -166,13 +165,13 @@
     public String edit()
         throws ContinuumException
     {
-        projectGroup = getProjectGroup( projectGroupId );
+        projectGroup = getContinuum().getProjectGroupWithProjects( projectGroupId );
 
         name = projectGroup.getName();
 
         description = projectGroup.getDescription();
 
-        projectList = getContinuum().getProjectsInGroup( projectGroupId );
+        projectList = projectGroup.getProjects();
 
         if ( projectList != null )
         {
@@ -246,7 +245,7 @@
                 }
             }
 
-            ProjectGroup newProjectGroup = getProjectGroup( new Integer( id[0] ).intValue()
);
+            ProjectGroup newProjectGroup = getContinuum().getProjectGroup( new Integer( id[0]
).intValue() );
 
             if ( newProjectGroup.getId() != projectGroup.getId() )
             {
@@ -436,12 +435,6 @@
     public ProjectGroup getProjectGroup()
     {
         return projectGroup;
-    }
-
-    public ProjectGroup getProjectGroup( int projectGroupId )
-        throws ContinuumException
-    {
-        return getContinuum().getProjectGroup( projectGroupId );
     }
 
     public void setProjectGroup( ProjectGroup projectGroup )

Modified: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/SummaryAction.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/SummaryAction.java?view=diff&rev=506479&r1=506478&r2=506479
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/SummaryAction.java
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/SummaryAction.java
Mon Feb 12 07:19:35 2007
@@ -45,16 +45,8 @@
 
     private String projectGroupName;
 
-    private int nbSuccesses;
-
-    private int nbFailures;
-
-    private int nbErrors;
-
     private List summary;
 
-    private List projects;
-
     public String execute()
         throws ContinuumException
     {
@@ -63,9 +55,9 @@
         //TODO: Create a summary jpox request so code will be more simple and performance
will be better
         projectsInGroup = getContinuum().getProjectsInGroup( projectGroupId );
 
-        Map buildResults = getContinuum().getLatestBuildResults();
+        Map buildResults = getContinuum().getLatestBuildResults( projectGroupId );
 
-        Map buildResultsInSuccess = getContinuum().getBuildResultsInSuccess();
+        Map buildResultsInSuccess = getContinuum().getBuildResultsInSuccess( projectGroupId
);
 
         summary = new ArrayList();
 
@@ -101,19 +93,6 @@
 
             model.setState( project.getState() );
 
-            if ( project.getState() == 2 )
-            {
-                nbSuccesses++;
-            }
-            else if ( project.getState() == 3 )
-            {
-                nbFailures++;
-            }
-            else if ( project.getState() == 4 )
-            {
-                nbErrors++;
-            }
-
             model.setBuildNumber( project.getBuildNumber() );
 
             if ( buildResultsInSuccess != null )
@@ -142,29 +121,9 @@
         return SUCCESS;
     }
 
-    public int getNbSuccesses()
-    {
-        return nbSuccesses;
-    }
-
-    public int getNbFailures()
-    {
-        return nbFailures;
-    }
-
-    public int getNbErrors()
-    {
-        return nbErrors;
-    }
-
     public List getProjects()
     {
         return summary;
-    }
-
-    public void setProjects( List projects )
-    {
-        this.projects = projects;
     }
 
     public int getProjectGroupId()

Modified: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/component/BuildDefinitionSummaryAction.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/component/BuildDefinitionSummaryAction.java?view=diff&rev=506479&r1=506478&r2=506479
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/component/BuildDefinitionSummaryAction.java
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/component/BuildDefinitionSummaryAction.java
Mon Feb 12 07:19:35 2007
@@ -82,7 +82,7 @@
         {
             groupBuildDefinitionSummaries = gatherGroupBuildDefinitionSummaries( projectGroupId
);
 
-            projectGroup = getContinuum().getProjectGroup( projectGroupId );
+            projectGroup = getContinuum().getProjectGroupWithProjects( projectGroupId );
 
             for ( Iterator i = projectGroup.getProjects().iterator(); i.hasNext(); )
             {
@@ -128,7 +128,7 @@
     {
         List summaryList = new ArrayList();
 
-        projectGroup = getContinuum().getProjectGroup( projectGroupId );
+        projectGroup = getContinuum().getProjectGroupWithBuildDetails( projectGroupId );
 
         for ( Iterator i = projectGroup.getBuildDefinitions().iterator(); i.hasNext(); )
         {

Modified: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/component/NotifierSummaryAction.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/component/NotifierSummaryAction.java?view=diff&rev=506479&r1=506478&r2=506479
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/component/NotifierSummaryAction.java
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/component/NotifierSummaryAction.java
Mon Feb 12 07:19:35 2007
@@ -166,7 +166,7 @@
         throws ContinuumException
     {
         List summaryList = new ArrayList();
-        projectGroup = getContinuum().getProjectGroup( projectGroupId );
+        projectGroup = getContinuum().getProjectGroupWithBuildDetails( projectGroupId );
 
         for ( Iterator i = projectGroup.getNotifiers().iterator(); i.hasNext(); )
         {



Mime
View raw message