continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r682300 [2/2] - in /continuum/branches/continuum-refactoring-evenisse: continuum-api/src/main/java/org/apache/continuum/dao/ continuum-api/src/main/java/org/apache/maven/continuum/store/ continuum-core/src/main/java/org/apache/maven/continu...
Date Mon, 04 Aug 2008 09:06:45 GMT
Added: continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/BuildDefinitionDaoImpl.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/BuildDefinitionDaoImpl.java?rev=682300&view=auto
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/BuildDefinitionDaoImpl.java (added)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/BuildDefinitionDaoImpl.java Mon Aug  4 02:06:43 2008
@@ -0,0 +1,278 @@
+package org.apache.continuum.dao;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.continuum.model.project.BuildDefinition;
+import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.model.project.ProjectGroup;
+import org.apache.maven.continuum.store.ContinuumObjectNotFoundException;
+import org.apache.maven.continuum.store.ContinuumStoreException;
+
+import javax.jdo.Extent;
+import javax.jdo.PersistenceManager;
+import javax.jdo.Query;
+import javax.jdo.Transaction;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
+ * @version $Id$
+ * @plexus.component role="org.apache.continuum.dao.BuildDefinitionDao"
+ */
+public class BuildDefinitionDaoImpl
+    extends AbstractDao
+    implements BuildDefinitionDao
+{
+    public BuildDefinition getBuildDefinition( int buildDefinitionId )
+        throws ContinuumStoreException
+    {
+        return (BuildDefinition) getObjectById( BuildDefinition.class, buildDefinitionId );
+    }
+
+    public void removeBuildDefinition( BuildDefinition buildDefinition )
+        throws ContinuumStoreException
+    {
+        removeObject( buildDefinition );
+    }
+
+    public BuildDefinition storeBuildDefinition( BuildDefinition buildDefinition )
+        throws ContinuumStoreException
+    {
+        updateObject( buildDefinition );
+
+        return buildDefinition;
+    }
+
+
+    public BuildDefinition addBuildDefinition( BuildDefinition buildDefinition )
+        throws ContinuumStoreException
+    {
+        return (BuildDefinition) addObject( buildDefinition );
+    }
+
+    public List<BuildDefinition> getAllBuildDefinitions()
+        throws ContinuumStoreException
+    {
+        PersistenceManager pm = getPersistenceManager();
+
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            Extent extent = pm.getExtent( BuildDefinition.class, true );
+
+            Query query = pm.newQuery( extent );
+
+            List result = (List) query.execute();
+
+            return result == null ? Collections.EMPTY_LIST : (List<BuildDefinition>) pm.detachCopyAll( result );
+        }
+        finally
+        {
+            tx.commit();
+
+            rollback( tx );
+        }
+    }
+
+    public Map getDefaultBuildDefinitions()
+    {
+        PersistenceManager pm = getPersistenceManager();
+
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            Extent extent = pm.getExtent( Project.class, true );
+
+            Query query = pm.newQuery( extent );
+
+            query.declareImports( "import org.apache.maven.continuum.model.project.BuildDefinition" );
+
+            query.setFilter( "this.buildDefinitions.contains(buildDef) && buildDef.defaultForProject == true" );
+
+            query.declareVariables( "BuildDefinition buildDef" );
+
+            query.setResult( "this.id, buildDef.id" );
+
+            List result = (List) query.execute();
+
+            // result = (List) pm.detachCopyAll( result );
+
+            Map builds = new HashMap();
+
+            if ( result != null && !result.isEmpty() )
+            {
+                for ( Object aResult : result )
+                {
+                    Object[] obj = (Object[]) aResult;
+
+                    builds.put( (Integer) obj[0], (Integer) obj[1] );
+                }
+
+                return builds;
+            }
+        }
+        finally
+        {
+            tx.commit();
+
+            rollback( tx );
+        }
+
+        return null;
+    }
+
+    public List<BuildDefinition> getDefaultBuildDefinitionsForProjectGroup( int projectGroupId )
+        throws ContinuumStoreException
+    {
+        PersistenceManager pm = getPersistenceManager();
+
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            Extent extent = pm.getExtent( ProjectGroup.class, true );
+
+            Query query = pm.newQuery( extent );
+
+            query.declareImports( "import " + BuildDefinition.class.getName() );
+
+            query.declareParameters( "int projectGroupId" );
+
+            query.setFilter(
+                "this.id == projectGroupId && this.buildDefinitions.contains(buildDef) && buildDef.defaultForProject == true" );
+
+            query.declareVariables( "BuildDefinition buildDef" );
+
+            query.setResult( "buildDef" );
+
+            List<BuildDefinition> result = (List<BuildDefinition>) query.execute( projectGroupId );
+
+            result = (List<BuildDefinition>) pm.detachCopyAll( result );
+
+            tx.commit();
+
+            if ( result != null )
+            {
+                return result;
+            }
+        }
+        finally
+        {
+            rollback( tx );
+        }
+
+        return new ArrayList<BuildDefinition>();
+    }
+
+    public List<BuildDefinition> getDefaultBuildDefinitionsForProjectGroup( ProjectGroup projectGroup )
+        throws ContinuumStoreException
+    {
+        return getDefaultBuildDefinitionsForProjectGroup( projectGroup.getId() );
+    }
+
+    public BuildDefinition getDefaultBuildDefinitionForProject( int projectId )
+        throws ContinuumStoreException
+    {
+        PersistenceManager pm = getPersistenceManager();
+
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            Extent extent = pm.getExtent( BuildDefinition.class, true );
+
+            Query query = pm.newQuery( extent );
+
+            query.declareImports( "import " + Project.class.getName() );
+
+            query.declareParameters( "int projectId" );
+
+            query.setFilter(
+                "project.id == projectId && project.buildDefinitions.contains(this) && this.defaultForProject == true" );
+
+            query.declareVariables( "Project project" );
+
+            query.setResult( "this" );
+
+            List<BuildDefinition> result = (List<BuildDefinition>) query.execute( projectId );
+
+            result = (List<BuildDefinition>) pm.detachCopyAll( result );
+
+            tx.commit();
+
+            if ( result != null && !result.isEmpty() )
+            {
+                return result.get( 0 );
+            }
+        }
+        finally
+        {
+            rollback( tx );
+        }
+
+        throw new ContinuumObjectNotFoundException( "no default build definition declared for project " + projectId );
+    }
+
+    public BuildDefinition getDefaultBuildDefinitionForProject( Project project )
+        throws ContinuumStoreException
+    {
+        return getDefaultBuildDefinitionForProject( project.getId() );
+    }
+
+    public List<BuildDefinition> getAllTemplates()
+        throws ContinuumStoreException
+    {
+        PersistenceManager pm = getPersistenceManager();
+
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            Extent extent = pm.getExtent( BuildDefinition.class, true );
+
+            Query query = pm.newQuery( extent );
+            query.setFilter( "this.template == true" );
+            List result = (List) query.execute();
+            return result == null ? Collections.EMPTY_LIST : (List) pm.detachCopyAll( result );
+        }
+        finally
+        {
+            tx.commit();
+
+            rollback( tx );
+        }
+    }
+}

Propchange: continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/BuildDefinitionDaoImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/BuildDefinitionDaoImpl.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/ProjectDaoImpl.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/ProjectDaoImpl.java?rev=682300&view=auto
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/ProjectDaoImpl.java (added)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/ProjectDaoImpl.java Mon Aug  4 02:06:43 2008
@@ -0,0 +1,294 @@
+package org.apache.continuum.dao;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.model.project.ProjectGroup;
+import org.apache.maven.continuum.store.ContinuumObjectNotFoundException;
+import org.apache.maven.continuum.store.ContinuumStoreException;
+
+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.List;
+
+/**
+ * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
+ * @version $Id$
+ * @plexus.component role="org.apache.continuum.dao.ProjectDao"
+ */
+public class ProjectDaoImpl
+    extends AbstractDao
+    implements ProjectDao
+{
+    public void removeProject( Project project )
+    {
+        removeObject( project );
+    }
+
+    public void updateProject( Project project )
+        throws ContinuumStoreException
+    {
+        updateObject( project );
+    }
+
+    public Project getProject( int projectId )
+        throws ContinuumStoreException
+    {
+        return (Project) getObjectById( Project.class, projectId );
+    }
+
+    public Project getProject( String groupId, String artifactId, String version )
+        throws ContinuumStoreException
+    {
+        PersistenceManager pm = getPersistenceManager();
+
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            Extent extent = pm.getExtent( Project.class, true );
+
+            Query query = pm.newQuery( extent );
+
+            query.declareImports( "import java.lang.String" );
+
+            query.declareParameters( "String groupId, String artifactId, String version" );
+
+            query.setFilter( "this.groupId == groupId && this.artifactId == artifactId && this.version == version" );
+
+            Object[] params = new Object[3];
+            params[0] = groupId;
+            params[1] = artifactId;
+            params[2] = version;
+
+            Collection result = (Collection) query.executeWithArray( params );
+
+            if ( result.size() == 0 )
+            {
+                tx.commit();
+
+                return null;
+            }
+
+            Object object = pm.detachCopy( result.iterator().next() );
+
+            tx.commit();
+
+            return (Project) object;
+        }
+        finally
+        {
+            rollback( tx );
+        }
+    }
+
+    public Project getProjectByName( String name )
+        throws ContinuumStoreException
+    {
+        PersistenceManager pm = getPersistenceManager();
+
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            Extent extent = pm.getExtent( Project.class, true );
+
+            Query query = pm.newQuery( extent );
+
+            query.declareImports( "import java.lang.String" );
+
+            query.declareParameters( "String name" );
+
+            query.setFilter( "this.name == name" );
+
+            Collection result = (Collection) query.execute( name );
+
+            if ( result.size() == 0 )
+            {
+                tx.commit();
+
+                return null;
+            }
+
+            Object object = pm.detachCopy( result.iterator().next() );
+
+            tx.commit();
+
+            return (Project) object;
+        }
+        finally
+        {
+            rollback( tx );
+        }
+    }
+
+    // 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 );
+
+        List<Project> groupProjects = new ArrayList<Project>();
+
+        for ( Project project : allProjects )
+        {
+            if ( project.getProjectGroup().getId() == projectGroupId )
+            {
+                groupProjects.add( project );
+            }
+        }
+        return groupProjects;
+    }
+
+    public Project getProjectWithBuilds( int projectId )
+        throws ContinuumStoreException
+    {
+        return (Project) getObjectById( Project.class, projectId, PROJECT_WITH_BUILDS_FETCH_GROUP );
+    }
+
+    public Project getProjectWithBuildDetails( int projectId )
+        throws ContinuumStoreException
+    {
+        return (Project) getObjectById( Project.class, projectId, PROJECT_BUILD_DETAILS_FETCH_GROUP );
+    }
+
+    public Project getProjectWithCheckoutResult( int projectId )
+        throws ContinuumStoreException
+    {
+        return (Project) getObjectById( Project.class, projectId, PROJECT_WITH_CHECKOUT_RESULT_FETCH_GROUP );
+    }
+
+    public List<Project> getProjectsInGroup( int projectGroupId )
+        throws 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" );
+
+            List result = (List) query.execute();
+
+            result = (List) pm.detachCopyAll( result );
+
+            tx.commit();
+
+            return result;
+        }
+        finally
+        {
+            rollback( tx );
+        }
+    }
+
+    public List<Project> getProjectsInGroupWithDependencies( int projectGroupId )
+        throws 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( PROJECT_DEPENDENCIES_FETCH_GROUP );
+
+            pm.getFetchPlan().addGroup( PROJECTGROUP_PROJECTS_FETCH_GROUP );
+
+            List result = (List) query.execute();
+
+            result = (List) pm.detachCopyAll( result );
+
+            tx.commit();
+
+            return result;
+        }
+        finally
+        {
+            rollback( tx );
+        }
+    }
+
+
+    public List<Project> getAllProjectsWithAllDetails()
+    {
+        return getAllObjectsDetached( Project.class, "name ascending", PROJECT_ALL_DETAILS_FETCH_GROUP );
+    }
+
+    public Project getProjectWithAllDetails( int projectId )
+        throws ContinuumStoreException
+    {
+        return (Project) getObjectById( Project.class, projectId, PROJECT_ALL_DETAILS_FETCH_GROUP );
+    }
+
+    public List<Project> getAllProjectsByName()
+    {
+        return getAllObjectsDetached( Project.class, "name ascending", null );
+    }
+
+
+    public List<Project> getAllProjectsByNameWithDependencies()
+    {
+        return getAllObjectsDetached( Project.class, "name ascending", PROJECT_DEPENDENCIES_FETCH_GROUP );
+    }
+
+    public List<Project> getAllProjectsByNameWithBuildDetails()
+    {
+        return getAllObjectsDetached( Project.class, "name ascending", PROJECT_BUILD_DETAILS_FETCH_GROUP );
+    }
+
+    public ProjectGroup getProjectGroupByProjectId( int projectId )
+        throws ContinuumObjectNotFoundException
+    {
+        try
+        {
+            return getProject( projectId ).getProjectGroup();
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new ContinuumObjectNotFoundException(
+                "unable to find project group containing project with id: " + projectId );
+
+        }
+    }
+}

Propchange: continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/ProjectDaoImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/ProjectDaoImpl.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/ProjectGroupDaoImpl.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/ProjectGroupDaoImpl.java?rev=682300&r1=682299&r2=682300&view=diff
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/ProjectGroupDaoImpl.java (original)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/ProjectGroupDaoImpl.java Mon Aug  4 02:06:43 2008
@@ -22,7 +22,6 @@
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.model.project.ProjectGroup;
 import org.apache.maven.continuum.store.ContinuumObjectNotFoundException;
-import org.apache.maven.continuum.store.ContinuumStore;
 import org.apache.maven.continuum.store.ContinuumStoreException;
 import org.codehaus.plexus.jdo.PlexusJdoUtils;
 
@@ -40,9 +39,9 @@
     implements ProjectGroupDao
 {
     /**
-     * @plexus.requirement role-hint="jdo"
+     * @plexus.requirement role=org.apache.continuum.dao.ProjectDao"
      */
-    private ContinuumStore store;
+    private ProjectDao projectDao;
 
     public ProjectGroup addProjectGroup( ProjectGroup group )
     {
@@ -68,7 +67,7 @@
             // because of the fetch groups
             for ( Project p : (List<Project>) pg.getProjects() )
             {
-                store.removeProject( p );
+                projectDao.removeProject( p );
             }
             removeObject( pg );
         }
@@ -105,7 +104,7 @@
     {
         try
         {
-            return store.getProject( projectId ).getProjectGroup();
+            return projectDao.getProject( projectId ).getProjectGroup();
         }
         catch ( ContinuumStoreException e )
         {

Modified: continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java?rev=682300&r1=682299&r2=682300&view=diff
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java (original)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java Mon Aug  4 02:06:43 2008
@@ -75,10 +75,32 @@
     // ContinuumStore Implementation
     // ----------------------------------------------------------------------
 
-    public Project getProjectByName( String name )
+    private ProjectGroup getProjectGroupWithBuildDetailsByProjectGroupId( int projectGroupId )
         throws ContinuumStoreException
     {
-        PersistenceManager pm = getPersistenceManager();
+        return (ProjectGroup) getObjectById( ProjectGroup.class, projectGroupId, PROJECT_BUILD_DETAILS_FETCH_GROUP );
+    }
+
+    private List<BuildDefinition> getDefaultBuildDefinitionsForProjectGroup( int projectGroupId )
+        throws ContinuumStoreException
+    {
+        ProjectGroup projectGroup = getProjectGroupWithBuildDetailsByProjectGroupId( projectGroupId );
+
+        List<BuildDefinition> bds = new ArrayList<BuildDefinition>();
+
+        for ( Iterator i = projectGroup.getBuildDefinitions().iterator(); i.hasNext(); )
+        {
+            BuildDefinition bd = (BuildDefinition) i.next();
+
+            // also applies to project group membership
+            if ( bd.isDefaultForProject() )
+            {
+                bds.add( bd );
+            }
+        }
+
+        return bds;
+/*        PersistenceManager pm = getPersistenceManager();
 
         Transaction tx = pm.currentTransaction();
 
@@ -86,38 +108,41 @@
         {
             tx.begin();
 
-            Extent extent = pm.getExtent( Project.class, true );
+            Extent extent = pm.getExtent( ProjectGroup.class, true );
 
             Query query = pm.newQuery( extent );
 
-            query.declareImports( "import java.lang.String" );
+            query.declareImports( "import " + BuildDefinition.class.getName() );
 
-            query.declareParameters( "String name" );
+            query.declareParameters( "int projectGroupId" );
 
-            query.setFilter( "this.name == name" );
+            query.setFilter(
+                "this.id == projectGroupId && this.buildDefinitions.contains(buildDef) && buildDef.defaultForProject == true" );
 
-            Collection result = (Collection) query.execute( name );
+            query.declareVariables( "BuildDefinition buildDef" );
 
-            if ( result.size() == 0 )
-            {
-                tx.commit();
+            query.setResult( "buildDef" );
 
-                return null;
-            }
+            List<BuildDefinition> result = (List<BuildDefinition>) query.execute( projectGroupId );
 
-            Object object = pm.detachCopy( result.iterator().next() );
+            pm.detachCopyAll( result );
 
             tx.commit();
 
-            return (Project) object;
+            if ( result != null )
+            {
+                return result;
+            }
         }
         finally
         {
             rollback( tx );
         }
+
+        return new ArrayList<BuildDefinition>();*/
     }
 
-    public Project getProject( String groupId, String artifactId, String version )
+    private BuildDefinition getDefaultBuildDefinitionForProject( int projectId )
         throws ContinuumStoreException
     {
         PersistenceManager pm = getPersistenceManager();
@@ -128,40 +153,40 @@
         {
             tx.begin();
 
-            Extent extent = pm.getExtent( Project.class, true );
+            Extent extent = pm.getExtent( BuildDefinition.class, true );
 
             Query query = pm.newQuery( extent );
 
-            query.declareImports( "import java.lang.String" );
+            query.declareImports( "import " + Project.class.getName() );
 
-            query.declareParameters( "String groupId, String artifactId, String version" );
+            query.declareParameters( "int projectId" );
 
-            query.setFilter( "this.groupId == groupId && this.artifactId == artifactId && this.version == version" );
+            query.setFilter(
+                "project.id == projectId && project.buildDefinitions.contains(this) && this.defaultForProject == true" );
 
-            Object[] params = new Object[3];
-            params[0] = groupId;
-            params[1] = artifactId;
-            params[2] = version;
+            query.declareVariables( "Project project" );
 
-            Collection result = (Collection) query.executeWithArray( params );
+            query.setResult( "this" );
 
-            if ( result.size() == 0 )
-            {
-                tx.commit();
+            query.setUnique( true );
 
-                return null;
-            }
+            BuildDefinition result = (BuildDefinition) query.execute( projectId );
 
-            Object object = pm.detachCopy( result.iterator().next() );
+            pm.detachCopy( result );
 
             tx.commit();
 
-            return (Project) object;
+            if ( result != null )
+            {
+                return result;
+            }
         }
         finally
         {
             rollback( tx );
         }
+
+        throw new ContinuumObjectNotFoundException( "no default build definition declared for project " + projectId );
     }
 
     /**
@@ -626,66 +651,6 @@
         }
     }
 
-
-    public BuildDefinition getDefaultBuildDefinitionForProject( int projectId )
-        throws ContinuumStoreException, ContinuumObjectNotFoundException
-    {
-        Project project;
-
-        try
-        {
-            project = getProjectWithBuildDetails( projectId );
-        }
-        catch ( Exception e )
-        {
-            project = null;
-        }
-
-        // check if the project has a default build definition defined
-        if ( project != null && project.getBuildDefinitions() != null )
-        {
-            for ( Iterator i = project.getBuildDefinitions().iterator(); i.hasNext(); )
-            {
-                BuildDefinition bd = (BuildDefinition) i.next();
-
-                if ( bd.isDefaultForProject() )
-                {
-                    return bd;
-                }
-            }
-        }
-
-        throw new ContinuumObjectNotFoundException( "no default build definition declared for project " + projectId );
-    }
-
-    public List<BuildDefinition> getDefaultBuildDefinitionsForProjectGroup( int projectGroupId )
-        throws ContinuumStoreException, ContinuumObjectNotFoundException
-    {
-        ProjectGroup projectGroup = getProjectGroupWithBuildDetailsByProjectGroupId( projectGroupId );
-
-        List<BuildDefinition> bds = new ArrayList<BuildDefinition>();
-
-        for ( Iterator i = projectGroup.getBuildDefinitions().iterator(); i.hasNext(); )
-        {
-            BuildDefinition bd = (BuildDefinition) i.next();
-
-            // also applies to project group membership
-            if ( bd.isDefaultForProject() )
-            {
-                bds.add( bd );
-            }
-        }
-
-        return bds;
-    }
-
-    private ProjectGroup getProjectGroupWithBuildDetailsByProjectGroupId( int projectGroupId )
-        throws ContinuumStoreException
-    {
-        return (ProjectGroup) getObjectById( ProjectGroup.class, projectGroupId, PROJECT_BUILD_DETAILS_FETCH_GROUP );
-    }
-
-
     public Map getDefaultBuildDefinitions()
     {
         PersistenceManager pm = getPersistenceManager();
@@ -798,86 +763,6 @@
         }
     }
 
-    public List<BuildDefinition> getAllTemplates()
-        throws ContinuumStoreException
-    {
-        PersistenceManager pm = getPersistenceManager();
-
-        Transaction tx = pm.currentTransaction();
-
-        try
-        {
-            tx.begin();
-
-            Extent extent = pm.getExtent( BuildDefinition.class, true );
-
-            Query query = pm.newQuery( extent );
-            query.setFilter( "this.template == true" );
-            List result = (List) query.execute();
-            return result == null ? Collections.EMPTY_LIST : (List) pm.detachCopyAll( result );
-        }
-        finally
-        {
-            tx.commit();
-
-            rollback( tx );
-        }
-    }
-
-    public List<BuildDefinition> getAllBuildDefinitions()
-        throws ContinuumStoreException
-    {
-        PersistenceManager pm = getPersistenceManager();
-
-        Transaction tx = pm.currentTransaction();
-
-        try
-        {
-            tx.begin();
-
-            Extent extent = pm.getExtent( BuildDefinition.class, true );
-
-            Query query = pm.newQuery( extent );
-
-            List result = (List) query.execute();
-
-            return result == null ? Collections.EMPTY_LIST : (List) pm.detachCopyAll( result );
-        }
-        finally
-        {
-            tx.commit();
-
-            rollback( tx );
-        }
-    }
-
-    public BuildDefinition getBuildDefinition( int buildDefinitionId )
-        throws ContinuumStoreException, ContinuumObjectNotFoundException
-    {
-        return (BuildDefinition) getObjectById( BuildDefinition.class, buildDefinitionId );
-    }
-
-    public void removeBuildDefinition( BuildDefinition buildDefinition )
-        throws ContinuumStoreException
-    {
-        removeObject( buildDefinition );
-    }
-
-    public BuildDefinition storeBuildDefinition( BuildDefinition buildDefinition )
-        throws ContinuumStoreException
-    {
-        updateObject( buildDefinition );
-
-        return buildDefinition;
-    }
-
-
-    public BuildDefinition addBuildDefinition( BuildDefinition buildDefinition )
-        throws ContinuumStoreException
-    {
-        return (BuildDefinition) addObject( buildDefinition );
-    }
-
     // ------------------------------------------------------
     //  BuildDefinitionTemplate
     // ------------------------------------------------------      
@@ -1339,12 +1224,6 @@
         return (Project) getObjectById( Project.class, projectId );
     }
 
-    public void updateProject( Project project )
-        throws ContinuumStoreException
-    {
-        updateObject( project );
-    }
-
     public void updateProfile( Profile profile )
         throws ContinuumStoreException
     {
@@ -1357,12 +1236,6 @@
         updateObject( schedule );
     }
 
-    public Project getProjectWithBuilds( int projectId )
-        throws ContinuumStoreException, ContinuumObjectNotFoundException
-    {
-        return (Project) getObjectById( Project.class, projectId, PROJECT_WITH_BUILDS_FETCH_GROUP );
-    }
-
     public void removeProfile( Profile profile )
     {
         removeObject( profile );
@@ -1373,12 +1246,6 @@
         removeObject( schedule );
     }
 
-    public Project getProjectWithCheckoutResult( int projectId )
-        throws ContinuumObjectNotFoundException, ContinuumStoreException
-    {
-        return (Project) getObjectById( Project.class, projectId, PROJECT_WITH_CHECKOUT_RESULT_FETCH_GROUP );
-    }
-
     public BuildResult getBuildResult( int buildId )
         throws ContinuumObjectNotFoundException, ContinuumStoreException
     {
@@ -1687,57 +1554,6 @@
         }
     }
 
-    public List<Project> getProjectsInGroupWithDependencies( 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( PROJECT_DEPENDENCIES_FETCH_GROUP );
-
-            pm.getFetchPlan().addGroup( PROJECTGROUP_PROJECTS_FETCH_GROUP );
-
-            List result = (List) query.execute();
-
-            result = (List) pm.detachCopyAll( result );
-
-            tx.commit();
-
-            return result;
-        }
-        finally
-        {
-            rollback( tx );
-        }
-    }
-
-    public List<ProjectGroup> getAllProjectGroupsWithBuildDetails()
-    {
-        return getAllObjectsDetached( ProjectGroup.class, "name ascending", PROJECT_BUILD_DETAILS_FETCH_GROUP );
-    }
-
-    public List<Project> getAllProjectsWithAllDetails()
-    {
-        return getAllObjectsDetached( Project.class, "name ascending", PROJECT_ALL_DETAILS_FETCH_GROUP );
-    }
-
-    public Project getProjectWithAllDetails( int projectId )
-        throws ContinuumObjectNotFoundException, ContinuumStoreException
-    {
-        return (Project) getObjectById( Project.class, projectId, PROJECT_ALL_DETAILS_FETCH_GROUP );
-    }
-
     public Schedule getSchedule( int scheduleId )
         throws ContinuumObjectNotFoundException, ContinuumStoreException
     {

Modified: continuum/branches/continuum-refactoring-evenisse/continuum-store/src/test/java/org/apache/maven/continuum/store/AbstractContinuumStoreTestCase.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-store/src/test/java/org/apache/maven/continuum/store/AbstractContinuumStoreTestCase.java?rev=682300&r1=682299&r2=682300&view=diff
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-store/src/test/java/org/apache/maven/continuum/store/AbstractContinuumStoreTestCase.java (original)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-store/src/test/java/org/apache/maven/continuum/store/AbstractContinuumStoreTestCase.java Mon Aug  4 02:06:43 2008
@@ -19,6 +19,7 @@
  * under the License.
  */
 
+import org.apache.continuum.dao.ProjectDao;
 import org.apache.continuum.dao.ProjectGroupDao;
 import org.apache.maven.continuum.installation.InstallationService;
 import org.apache.maven.continuum.model.project.BuildDefinition;
@@ -55,6 +56,8 @@
 
     protected ProjectGroupDao projectGroupDao;
 
+    protected ProjectDao projectDao;
+
     protected ProjectGroup defaultProjectGroup;
 
     protected ProjectGroup testProjectGroup2;
@@ -123,6 +126,8 @@
         store = createStore();
 
         projectGroupDao = (ProjectGroupDao) lookup( ProjectGroupDao.class.getName() );
+
+        projectDao = (ProjectDao) lookup( ProjectDao.class.getName() );
     }
 
     protected void createBuildDatabase()
@@ -475,8 +480,8 @@
         assertProjectGroupEquals( defaultProjectGroup, projectGroupDao.getProjectGroup( defaultProjectGroup.getId() ) );
         assertProjectGroupEquals( testProjectGroup2, projectGroupDao.getProjectGroup( testProjectGroup2.getId() ) );
 
-        assertProjectEquals( testProject1, store.getProject( testProject1.getId() ) );
-        assertProjectEquals( testProject2, store.getProject( testProject2.getId() ) );
+        assertProjectEquals( testProject1, projectDao.getProject( testProject1.getId() ) );
+        assertProjectEquals( testProject2, projectDao.getProject( testProject2.getId() ) );
 
         assertScheduleEquals( testSchedule1, store.getSchedule( testSchedule1.getId() ) );
         assertScheduleEquals( testSchedule2, store.getSchedule( testSchedule2.getId() ) );

Modified: continuum/branches/continuum-refactoring-evenisse/continuum-store/src/test/java/org/apache/maven/continuum/store/ContinuumStoreTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-store/src/test/java/org/apache/maven/continuum/store/ContinuumStoreTest.java?rev=682300&r1=682299&r2=682300&view=diff
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-store/src/test/java/org/apache/maven/continuum/store/ContinuumStoreTest.java (original)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-store/src/test/java/org/apache/maven/continuum/store/ContinuumStoreTest.java Mon Aug  4 02:06:43 2008
@@ -19,6 +19,7 @@
  * under the License.
  */
 
+import org.apache.continuum.dao.BuildDefinitionDao;
 import org.apache.maven.continuum.execution.ContinuumBuildExecutorConstants;
 import org.apache.maven.continuum.installation.InstallationService;
 import org.apache.maven.continuum.model.project.BuildDefinition;
@@ -58,6 +59,8 @@
     //
     // ----------------------------------------------------------------------
 
+    protected BuildDefinitionDao buildDefinitionDao;
+
     // ----------------------------------------------------------------------
     //  TEST METHODS
     // ----------------------------------------------------------------------
@@ -192,7 +195,7 @@
     public void testGetProject()
         throws ContinuumStoreException
     {
-        Project retrievedProject = store.getProject( testProject1.getId() );
+        Project retrievedProject = projectDao.getProject( testProject1.getId() );
         assertProjectEquals( testProject1, retrievedProject );
         checkProjectDefaultFetchGroup( retrievedProject );
     }
@@ -200,7 +203,7 @@
     public void testGetProjectWithDetails()
         throws ContinuumStoreException
     {
-        Project retrievedProject = store.getProjectWithAllDetails( testProject1.getId() );
+        Project retrievedProject = projectDao.getProjectWithAllDetails( testProject1.getId() );
         assertProjectEquals( testProject1, retrievedProject );
         checkProjectFetchGroup( retrievedProject, false, false, true, true );
 
@@ -213,7 +216,7 @@
     public void testGetProjectWithCheckoutResult()
         throws ContinuumStoreException
     {
-        Project retrievedProject = store.getProjectWithCheckoutResult( testProject1.getId() );
+        Project retrievedProject = projectDao.getProjectWithCheckoutResult( testProject1.getId() );
         assertProjectEquals( testProject1, retrievedProject );
         assertScmResultEquals( testCheckoutResult1, retrievedProject.getCheckoutResult() );
         checkProjectFetchGroup( retrievedProject, true, false, false, false );
@@ -224,7 +227,7 @@
     {
         try
         {
-            store.getProject( INVALID_ID );
+            projectDao.getProject( INVALID_ID );
             fail( "Should not find project with invalid ID" );
         }
         catch ( ContinuumObjectNotFoundException expected )
@@ -236,7 +239,7 @@
     public void testEditProject()
         throws ContinuumStoreException
     {
-        Project newProject = store.getProject( testProject2.getId() );
+        Project newProject = projectDao.getProject( testProject2.getId() );
 
         newProject.setName( "testEditProject2" );
         newProject.setDescription( "testEditProject updated description" );
@@ -244,9 +247,9 @@
 
         Project copy = createTestProject( newProject );
         copy.setId( newProject.getId() );
-        store.updateProject( newProject );
+        projectDao.updateProject( newProject );
 
-        Project retrievedProject = store.getProject( testProject2.getId() );
+        Project retrievedProject = projectDao.getProject( testProject2.getId() );
         assertProjectEquals( copy, retrievedProject );
 
     }
@@ -261,7 +264,7 @@
 
         try
         {
-            store.updateProject( newProject );
+            projectDao.updateProject( newProject );
             fail( "Should not have succeeded" );
         }
         catch ( ContinuumStoreException expected )
@@ -585,9 +588,9 @@
     public void testDeleteProject()
         throws ContinuumStoreException
     {
-        Project project = store.getProjectWithBuilds( testProject1.getId() );
+        Project project = projectDao.getProjectWithBuilds( testProject1.getId() );
 
-        store.removeProject( project );
+        projectDao.removeProject( project );
 
         ProjectGroup projectGroup = projectGroupDao.getProjectGroupWithProjects( defaultProjectGroup.getId() );
         assertEquals( "check size is now 1", 1, projectGroup.getProjects().size() );
@@ -620,7 +623,7 @@
     public void testDeleteBuildResult()
         throws ContinuumStoreException
     {
-        Project project = store.getProjectWithBuilds( testProject1.getId() );
+        Project project = projectDao.getProjectWithBuilds( testProject1.getId() );
 
         for ( Iterator i = project.getBuildResults().iterator(); i.hasNext(); )
         {
@@ -630,9 +633,9 @@
                 i.remove();
             }
         }
-        store.updateProject( project );
+        projectDao.updateProject( project );
 
-        project = store.getProjectWithBuilds( testProject1.getId() );
+        project = projectDao.getProjectWithBuilds( testProject1.getId() );
         assertEquals( "check size is now 1", 1, project.getBuildResults().size() );
         assertBuildResultEquals( testBuildResult2, (BuildResult) project.getBuildResults().get( 0 ) );
 
@@ -753,14 +756,14 @@
     public void testAddDeveloperToProject()
         throws ContinuumStoreException
     {
-        Project project = store.getProjectWithAllDetails( testProject1.getId() );
+        Project project = projectDao.getProjectWithAllDetails( testProject1.getId() );
 
         ProjectDeveloper developer = createTestDeveloper( 11, "email TADTP", "name TADTP", "scmId TADTP" );
         ProjectDeveloper copy = createTestDeveloper( developer );
         project.addDeveloper( developer );
-        store.updateProject( project );
+        projectDao.updateProject( project );
 
-        project = store.getProjectWithAllDetails( testProject1.getId() );
+        project = projectDao.getProjectWithAllDetails( testProject1.getId() );
         assertEquals( "check # devs", 2, project.getDevelopers().size() );
         assertDeveloperEquals( copy, (ProjectDeveloper) project.getDevelopers().get( 1 ) );
     }
@@ -768,16 +771,16 @@
     public void testEditDeveloper()
         throws ContinuumStoreException
     {
-        Project project = store.getProjectWithAllDetails( testProject1.getId() );
+        Project project = projectDao.getProjectWithAllDetails( testProject1.getId() );
 
         ProjectDeveloper newDeveloper = (ProjectDeveloper) project.getDevelopers().get( 0 );
         newDeveloper.setName( "name1.1" );
         newDeveloper.setEmail( "email1.1" );
 
         ProjectDeveloper copy = createTestDeveloper( newDeveloper );
-        store.updateProject( project );
+        projectDao.updateProject( project );
 
-        project = store.getProjectWithAllDetails( testProject1.getId() );
+        project = projectDao.getProjectWithAllDetails( testProject1.getId() );
         assertEquals( "check # devs", 1, project.getDevelopers().size() );
         assertDeveloperEquals( copy, (ProjectDeveloper) project.getDevelopers().get( 0 ) );
     }
@@ -785,11 +788,11 @@
     public void testDeleteDeveloper()
         throws ContinuumStoreException
     {
-        Project project = store.getProjectWithAllDetails( testProject1.getId() );
+        Project project = projectDao.getProjectWithAllDetails( testProject1.getId() );
         project.getDevelopers().remove( 0 );
-        store.updateProject( project );
+        projectDao.updateProject( project );
 
-        project = store.getProjectWithAllDetails( testProject1.getId() );
+        project = projectDao.getProjectWithAllDetails( testProject1.getId() );
         assertEquals( "check size is now 0", 0, project.getDevelopers().size() );
 
         // !! These actually aren't happening !!
@@ -799,14 +802,14 @@
     public void testAddDependencyToProject()
         throws ContinuumStoreException
     {
-        Project project = store.getProjectWithAllDetails( testProject1.getId() );
+        Project project = projectDao.getProjectWithAllDetails( testProject1.getId() );
 
         ProjectDependency dependency = createTestDependency( "TADTP groupId", "TADTP artifactId", "TADTP version" );
         ProjectDependency copy = createTestDependency( dependency );
         project.addDependency( dependency );
-        store.updateProject( project );
+        projectDao.updateProject( project );
 
-        project = store.getProjectWithAllDetails( testProject1.getId() );
+        project = projectDao.getProjectWithAllDetails( testProject1.getId() );
         assertEquals( "check # deps", 3, project.getDependencies().size() );
         assertDependencyEquals( copy, (ProjectDependency) project.getDependencies().get( 2 ) );
     }
@@ -814,16 +817,16 @@
     public void testEditDependency()
         throws ContinuumStoreException
     {
-        Project project = store.getProjectWithAllDetails( testProject1.getId() );
+        Project project = projectDao.getProjectWithAllDetails( testProject1.getId() );
 
         ProjectDependency newDependency = (ProjectDependency) project.getDependencies().get( 0 );
         newDependency.setGroupId( "groupId1.1" );
         newDependency.setArtifactId( "artifactId1.1" );
 
         ProjectDependency copy = createTestDependency( newDependency );
-        store.updateProject( project );
+        projectDao.updateProject( project );
 
-        project = store.getProjectWithAllDetails( testProject1.getId() );
+        project = projectDao.getProjectWithAllDetails( testProject1.getId() );
         assertEquals( "check # deps", 2, project.getDependencies().size() );
         assertDependencyEquals( copy, (ProjectDependency) project.getDependencies().get( 0 ) );
     }
@@ -831,12 +834,12 @@
     public void testDeleteDependency()
         throws ContinuumStoreException
     {
-        Project project = store.getProjectWithAllDetails( testProject1.getId() );
+        Project project = projectDao.getProjectWithAllDetails( testProject1.getId() );
         ProjectDependency dependency = (ProjectDependency) project.getDependencies().get( 1 );
         project.getDependencies().remove( 0 );
-        store.updateProject( project );
+        projectDao.updateProject( project );
 
-        project = store.getProjectWithAllDetails( testProject1.getId() );
+        project = projectDao.getProjectWithAllDetails( testProject1.getId() );
         assertEquals( "check size is now 1", 1, project.getDependencies().size() );
         assertDependencyEquals( dependency, (ProjectDependency) project.getDependencies().get( 0 ) );
 
@@ -847,14 +850,14 @@
     public void testAddNotifierToProject()
         throws ContinuumStoreException
     {
-        Project project = store.getProjectWithAllDetails( testProject1.getId() );
+        Project project = projectDao.getProjectWithAllDetails( testProject1.getId() );
 
         ProjectNotifier notifier = createTestNotifier( 13, true, false, true, "TADNTP type" );
         ProjectNotifier copy = createTestNotifier( notifier );
         project.addNotifier( notifier );
-        store.updateProject( project );
+        projectDao.updateProject( project );
 
-        project = store.getProjectWithAllDetails( testProject1.getId() );
+        project = projectDao.getProjectWithAllDetails( testProject1.getId() );
         assertEquals( "check # notifiers", 2, project.getNotifiers().size() );
         assertNotifierEquals( copy, (ProjectNotifier) project.getNotifiers().get( 1 ) );
     }
@@ -862,7 +865,7 @@
     public void testEditNotifier()
         throws ContinuumStoreException
     {
-        Project project = store.getProjectWithAllDetails( testProject1.getId() );
+        Project project = projectDao.getProjectWithAllDetails( testProject1.getId() );
 
         ProjectNotifier newNotifier = (ProjectNotifier) project.getNotifiers().get( 0 );
         // If we use "type1.1", jpox-rc2 store "type11", weird
@@ -870,9 +873,9 @@
         newNotifier.setType( type );
 
         ProjectNotifier copy = createTestNotifier( newNotifier );
-        store.updateProject( project );
+        projectDao.updateProject( project );
 
-        project = store.getProjectWithAllDetails( testProject1.getId() );
+        project = projectDao.getProjectWithAllDetails( testProject1.getId() );
         assertEquals( "check # notifiers", 1, project.getNotifiers().size() );
         assertNotifierEquals( copy, (ProjectNotifier) project.getNotifiers().get( 0 ) );
     }
@@ -880,11 +883,11 @@
     public void testDeleteNotifier()
         throws ContinuumStoreException
     {
-        Project project = store.getProjectWithAllDetails( testProject1.getId() );
+        Project project = projectDao.getProjectWithAllDetails( testProject1.getId() );
         project.getNotifiers().remove( 0 );
-        store.updateProject( project );
+        projectDao.updateProject( project );
 
-        project = store.getProjectWithAllDetails( testProject1.getId() );
+        project = projectDao.getProjectWithAllDetails( testProject1.getId() );
         assertEquals( "check size is now 0", 0, project.getNotifiers().size() );
 
         // !! These actually aren't happening !!
@@ -894,7 +897,7 @@
     public void testAddBuildDefinitionToProject()
         throws ContinuumStoreException
     {
-        Project project = store.getProjectWithAllDetails( testProject1.getId() );
+        Project project = projectDao.getProjectWithAllDetails( testProject1.getId() );
 
         Profile profile = store.getProfile( testProfile1.getId() );
         Schedule schedule = store.getSchedule( testSchedule1.getId() );
@@ -902,9 +905,9 @@
                                                                      "TABDTP goals", profile, schedule, false, false );
         BuildDefinition copy = createTestBuildDefinition( buildDefinition );
         project.addBuildDefinition( buildDefinition );
-        store.updateProject( project );
+        projectDao.updateProject( project );
 
-        project = store.getProjectWithAllDetails( testProject1.getId() );
+        project = projectDao.getProjectWithAllDetails( testProject1.getId() );
         assertEquals( "check # build defs", 3, project.getBuildDefinitions().size() );
         BuildDefinition retrievedBuildDefinition = (BuildDefinition) project.getBuildDefinitions().get( 2 );
         assertBuildDefinitionEquals( copy, retrievedBuildDefinition );
@@ -915,7 +918,7 @@
     public void testEditBuildDefinition()
         throws ContinuumStoreException
     {
-        Project project = store.getProjectWithAllDetails( testProject1.getId() );
+        Project project = projectDao.getProjectWithAllDetails( testProject1.getId() );
 
         BuildDefinition newBuildDefinition = (BuildDefinition) project.getBuildDefinitions().get( 0 );
         newBuildDefinition.setBuildFresh( true );
@@ -924,9 +927,9 @@
         newBuildDefinition.setArguments( arguments );
 
         BuildDefinition copy = createTestBuildDefinition( newBuildDefinition );
-        store.storeBuildDefinition( newBuildDefinition );
+        buildDefinitionDao.storeBuildDefinition( newBuildDefinition );
 
-        project = store.getProjectWithAllDetails( testProject1.getId() );
+        project = projectDao.getProjectWithAllDetails( testProject1.getId() );
         assertEquals( "check # build defs", 2, project.getBuildDefinitions().size() );
         BuildDefinition retrievedBuildDefinition = (BuildDefinition) project.getBuildDefinitions().get( 0 );
         assertBuildDefinitionEquals( copy, retrievedBuildDefinition );
@@ -937,12 +940,12 @@
     public void testDeleteBuildDefinition()
         throws ContinuumStoreException
     {
-        Project project = store.getProjectWithAllDetails( testProject1.getId() );
+        Project project = projectDao.getProjectWithAllDetails( testProject1.getId() );
         BuildDefinition buildDefinition = (BuildDefinition) project.getBuildDefinitions().get( 1 );
         project.getBuildDefinitions().remove( 0 );
-        store.updateProject( project );
+        projectDao.updateProject( project );
 
-        project = store.getProjectWithAllDetails( testProject1.getId() );
+        project = projectDao.getProjectWithAllDetails( testProject1.getId() );
         assertEquals( "check size is now 1", 1, project.getBuildDefinitions().size() );
         BuildDefinition retrievedBuildDefinition = (BuildDefinition) project.getBuildDefinitions().get( 0 );
         assertBuildDefinitionEquals( buildDefinition, retrievedBuildDefinition );
@@ -1070,7 +1073,7 @@
         throws Exception
     {
 
-        int all = store.getAllBuildDefinitions().size();
+        int all = buildDefinitionDao.getAllBuildDefinitions().size();
         BuildDefinition buildDefinition = new BuildDefinition();
         buildDefinition.setBuildFile( "pom.xml" );
         buildDefinition.setGoals( "clean" );
@@ -1080,7 +1083,7 @@
         template.setContinuumDefault( true );
         template.setType( ContinuumBuildExecutorConstants.MAVEN_TWO_BUILD_EXECUTOR );
         template = store.addBuildDefinitionTemplate( template );
-        buildDefinition = store.addBuildDefinition( buildDefinition );
+        buildDefinition = buildDefinitionDao.addBuildDefinition( buildDefinition );
 
         template.addBuildDefinition( buildDefinition );
 
@@ -1089,7 +1092,7 @@
         assertEquals( "test", template.getName() );
         assertTrue( template.isContinuumDefault() );
         assertEquals( 1, template.getBuildDefinitions().size() );
-        assertEquals( all + 1, store.getAllBuildDefinitions().size() );
+        assertEquals( all + 1, buildDefinitionDao.getAllBuildDefinitions().size() );
         assertEquals( 1, store.getAllBuildDefinitionTemplate().size() );
 
         template = store
@@ -1110,7 +1113,7 @@
     {
         try
         {
-            store.getProject( project.getId() );
+            projectDao.getProject( project.getId() );
             fail( "Project should no longer exist" );
         }
         catch ( ContinuumObjectNotFoundException expected )
@@ -1161,6 +1164,8 @@
     {
         super.setUp();
 
+        buildDefinitionDao = (BuildDefinitionDao) lookup( BuildDefinitionDao.class.getName() );
+
         createBuildDatabase();
     }
 

Modified: continuum/branches/continuum-refactoring-evenisse/continuum-test/src/main/java/org/apache/maven/continuum/AbstractContinuumTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-test/src/main/java/org/apache/maven/continuum/AbstractContinuumTest.java?rev=682300&r1=682299&r2=682300&view=diff
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-test/src/main/java/org/apache/maven/continuum/AbstractContinuumTest.java (original)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-test/src/main/java/org/apache/maven/continuum/AbstractContinuumTest.java Mon Aug  4 02:06:43 2008
@@ -19,6 +19,7 @@
  * under the License.
  */
 
+import org.apache.continuum.dao.ProjectDao;
 import org.apache.continuum.dao.ProjectGroupDao;
 import org.apache.maven.continuum.configuration.ConfigurationService;
 import org.apache.maven.continuum.execution.ContinuumBuildExecutor;
@@ -54,6 +55,8 @@
 {
     private ContinuumStore store;
 
+    private ProjectDao projectDao;
+
     private ProjectGroupDao projectGroupDao;
 
     // ----------------------------------------------------------------------
@@ -68,6 +71,8 @@
 
         getStore();
 
+        getProjectDao();
+
         getProjectGroupDao();
 
         setUpConfigurationService( (ConfigurationService) lookup( "configurationService" ) );
@@ -210,6 +215,15 @@
         return store;
     }
 
+    protected ProjectDao getProjectDao()
+    {
+        if ( projectDao == null )
+        {
+            projectDao = (ProjectDao) lookup( ProjectDao.class.getName() );
+        }
+        return projectDao;
+    }
+
     protected ProjectGroupDao getProjectGroupDao()
     {
         if ( projectGroupDao == null )
@@ -332,7 +346,7 @@
 
         projectGroupDao.updateProjectGroup( defaultProjectGroup );
 
-        project = store.getProject( project.getId() );
+        project = projectDao.getProject( project.getId() );
 
         assertNotNull( "project group == null", project.getProjectGroup() );
 
@@ -351,13 +365,13 @@
         return addProject( store, makeProject( name, nagEmailAddress, version ) );
     }
 
-    public static void setCheckoutDone( ContinuumStore store, Project project, ScmResult scmResult )
+    /*public static void setCheckoutDone( ContinuumStore store, Project project, ScmResult scmResult )
         throws ContinuumStoreException
     {
         project.setCheckoutResult( scmResult );
 
         store.updateProject( project );
-    }
+    }*/
 
     // ----------------------------------------------------------------------
     // Assertions



Mime
View raw message