continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r681490 [1/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 Thu, 31 Jul 2008 21:01:15 GMT
Author: evenisse
Date: Thu Jul 31 14:01:14 2008
New Revision: 681490

URL: http://svn.apache.org/viewvc?rev=681490&view=rev
Log:
Split ContinuumStore into few dao classes : extract ProjectGroupDao

Added:
    continuum/branches/continuum-refactoring-evenisse/continuum-api/src/main/java/org/apache/continuum/dao/
    continuum/branches/continuum-refactoring-evenisse/continuum-api/src/main/java/org/apache/continuum/dao/ProjectGroupDao.java   (with props)
    continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/
    continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/
    continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/AbstractDao.java   (with props)
    continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/ProjectGroupDaoImpl.java   (with props)
    continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/StoreUtilities.java   (with props)
Modified:
    continuum/branches/continuum-refactoring-evenisse/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java
    continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
    continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/builddefinition/DefaultBuildDefinitionService.java
    continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddAssignableRolesAction.java
    continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddBuildDefinitionToProjectGroupAction.java
    continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/RemoveAssignableRolesAction.java
    continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/RemoveBuildDefinitionFromProjectGroupAction.java
    continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/StoreProjectAction.java
    continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/StoreProjectGroupAction.java
    continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateBuildDefinitionFromProjectGroupAction.java
    continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/initialization/DefaultContinuumInitializer.java
    continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/notification/DefaultContinuumNotificationDispatcher.java
    continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
    continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/buildcontroller/BuildProjectTaskExecutorTest.java
    continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/builddefinition/DefaultBuildDefinitionServiceTest.java
    continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilderTest.java
    continuum/branches/continuum-refactoring-evenisse/continuum-data-management/data-management-cli/pom.xml
    continuum/branches/continuum-refactoring-evenisse/continuum-data-management/data-management-jdo/pom.xml
    continuum/branches/continuum-refactoring-evenisse/continuum-store/pom.xml
    continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java
    continuum/branches/continuum-refactoring-evenisse/continuum-store/src/test/java/org/apache/maven/continuum/store/AbstractContinuumStoreTestCase.java
    continuum/branches/continuum-refactoring-evenisse/continuum-store/src/test/java/org/apache/maven/continuum/store/ContinuumStoreTest.java
    continuum/branches/continuum-refactoring-evenisse/continuum-test/src/main/java/org/apache/maven/continuum/AbstractContinuumTest.java

Added: continuum/branches/continuum-refactoring-evenisse/continuum-api/src/main/java/org/apache/continuum/dao/ProjectGroupDao.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-api/src/main/java/org/apache/continuum/dao/ProjectGroupDao.java?rev=681490&view=auto
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-api/src/main/java/org/apache/continuum/dao/ProjectGroupDao.java (added)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-api/src/main/java/org/apache/continuum/dao/ProjectGroupDao.java Thu Jul 31 14:01:14 2008
@@ -0,0 +1,169 @@
+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.ProjectGroup;
+import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.store.ContinuumStoreException;
+import org.apache.maven.continuum.store.ContinuumObjectNotFoundException;
+
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
+ * @version $Id$
+ */
+public interface ProjectGroupDao
+{
+    /**
+     * Add the project group.
+     *
+     * @param group The project group
+     * @return The project group added
+     */
+    ProjectGroup addProjectGroup( ProjectGroup group );
+
+    /**
+     * Remove the project group.
+     *
+     * @param projectGroup the project group to remove
+     */
+    void removeProjectGroup( ProjectGroup projectGroup );
+
+    /**
+     * Return the project group associated to the project group id parameter.
+     *
+     * @param projectGroupId The project group id
+     * @return The project group
+     * @throws org.apache.maven.continuum.store.ContinuumStoreException if the project group can't be obtain
+     */
+    ProjectGroup getProjectGroup( int projectGroupId )
+        throws ContinuumStoreException, ContinuumObjectNotFoundException;
+
+    /**
+     * Return the project group associated to the groupId parameter.
+     *
+     * @param groupId The group id
+     * @return The project group
+     * @throws ContinuumStoreException if the project group can't be obtain
+     */
+    ProjectGroup getProjectGroupByGroupId( String groupId )
+        throws ContinuumStoreException;
+
+    /**
+     * Return the project group associated to the groupId parameter.
+     *
+     * @param groupId The group id
+     * @return The project group
+     * @throws ContinuumStoreException if the project group can't be obtain
+     */
+    ProjectGroup getProjectGroupByGroupIdWithBuildDetails( String groupId )
+        throws ContinuumStoreException;
+
+    /**
+     * Return the project group associated to the groupId parameter.
+     *
+     * @param groupId The group id
+     * @return The project group
+     * @throws ContinuumStoreException if the project group can't be obtain
+     */
+    ProjectGroup getProjectGroupByGroupIdWithProjects( String groupId )
+        throws ContinuumStoreException;
+
+    /**
+     * Return the project group of the project.
+     *
+     * @param projectId The project id
+     * @return The project group
+     * @throws ContinuumObjectNotFoundException
+     *          if the project group can't be obtain
+     */
+    ProjectGroup getProjectGroupByProjectId( int projectId )
+        throws ContinuumObjectNotFoundException;
+
+    /**
+     * Return the project group of the project.
+     *
+     * @param project The project
+     * @return The project group
+     * @throws ContinuumObjectNotFoundException
+     *          if the project group can't be obtain
+     */
+    ProjectGroup getProjectGroupByProject( Project project )
+        throws ContinuumObjectNotFoundException;
+
+    /**
+     * Save the modified project group.
+     *
+     * @param projectGroup The project group
+     * @throws ContinuumStoreException if the project group can't be saved
+     */
+    void updateProjectGroup( ProjectGroup projectGroup )
+        throws ContinuumStoreException;
+
+    /**
+     * Return the project group with projects populated.
+     *
+     * @param projectGroupId The project group id
+     * @return All project groups
+     * @throws ContinuumStoreException if the project group can't be obtain
+     */
+    ProjectGroup getProjectGroupWithProjects( int projectGroupId )
+        throws ContinuumStoreException;
+
+    /**
+     * Return all project groups with projects populated.
+     *
+     * @return All project groups
+     */
+    Collection<ProjectGroup> getAllProjectGroupsWithProjects();
+
+    /**
+     * Return all project groups with build details populated.
+     *
+     * @return All project groups
+     */
+    List<ProjectGroup> getAllProjectGroupsWithBuildDetails();
+
+    /**
+     * Return all project groups.
+     *
+     * @return All project groups
+     */
+    Collection<ProjectGroup> getAllProjectGroups();
+
+    /**
+     * Return all project groups with all associated objects populated. This method return the majority of the database.
+     *
+     * @return all project groups
+     */
+    Collection<ProjectGroup> getAllProjectGroupsWithTheLot();
+
+    /**
+     * Return the project group with associated build details populated.
+     *
+     * @param projectGroupId the project group id
+     * @return the project group
+     * @throws ContinuumStoreException if the project group can't be obtain
+     */
+    ProjectGroup getProjectGroupWithBuildDetailsByProjectGroupId( int projectGroupId )
+        throws ContinuumStoreException;
+}

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

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

Modified: continuum/branches/continuum-refactoring-evenisse/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java?rev=681490&r1=681489&r2=681490&view=diff
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java (original)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java Thu Jul 31 14:01:14 2008
@@ -156,21 +156,6 @@
     //  Project Group
     // ------------------------------------------------------
 
-    ProjectGroup addProjectGroup( ProjectGroup group );
-
-    ProjectGroup getProjectGroup( int projectGroupId )
-        throws ContinuumStoreException, ContinuumObjectNotFoundException;
-
-    public ProjectGroup getProjectGroupByProjectId( int projectId )
-        throws ContinuumObjectNotFoundException;
-
-    void updateProjectGroup( ProjectGroup group )
-        throws ContinuumStoreException;
-
-    Collection<ProjectGroup> getAllProjectGroupsWithProjects();
-
-    Collection<ProjectGroup> getAllProjectGroups();
-
     List<Project> getAllProjectsByName();
 
     List<Project> getAllProjectsByNameWithDependencies();
@@ -264,22 +249,12 @@
 
     void removeProject( Project project );
 
-    void removeProjectGroup( ProjectGroup projectGroup );
-
-    ProjectGroup getProjectGroupWithBuildDetailsByProjectGroupId( int projectGroupId )
-        throws ContinuumObjectNotFoundException, ContinuumStoreException;
-
     List<Project> getProjectsInGroup( int projectGroupId )
         throws ContinuumObjectNotFoundException, ContinuumStoreException;
 
     List<Project> getProjectsInGroupWithDependencies( int projectGroupId )
         throws ContinuumObjectNotFoundException, ContinuumStoreException;
 
-    ProjectGroup getProjectGroupWithProjects( int projectGroupId )
-        throws ContinuumObjectNotFoundException, ContinuumStoreException;
-
-    List<ProjectGroup> getAllProjectGroupsWithBuildDetails();
-
     List<Project> getAllProjectsWithAllDetails();
 
     Project getProjectWithAllDetails( int projectId )
@@ -288,15 +263,6 @@
     Schedule getSchedule( int scheduleId )
         throws ContinuumObjectNotFoundException, ContinuumStoreException;
 
-    ProjectGroup getProjectGroupByGroupId( String groupId )
-        throws ContinuumStoreException, ContinuumObjectNotFoundException;
-
-    ProjectGroup getProjectGroupByGroupIdWithBuildDetails( String groupId )
-        throws ContinuumStoreException, ContinuumObjectNotFoundException;
-
-    ProjectGroup getProjectGroupByGroupIdWithProjects( String groupId )
-        throws ContinuumStoreException, ContinuumObjectNotFoundException;
-
     BuildResult getLatestBuildResultForProject( int projectId );
 
     BuildResult getLatestBuildResultForBuildDefinition( int projectId, int buildDefinitionId );

Modified: continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?rev=681490&r1=681489&r2=681490&view=diff
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java (original)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java Thu Jul 31 14:01:14 2008
@@ -21,6 +21,7 @@
 
 import org.apache.commons.lang.ArrayUtils;
 import org.apache.continuum.configuration.ContinuumConfigurationException;
+import org.apache.continuum.dao.ProjectGroupDao;
 import org.apache.maven.continuum.build.settings.SchedulesActivationException;
 import org.apache.maven.continuum.build.settings.SchedulesActivator;
 import org.apache.maven.continuum.builddefinition.BuildDefinitionService;
@@ -126,6 +127,11 @@
     /**
      * @plexus.requirement
      */
+    private ProjectGroupDao projectGroupDao;
+
+    /**
+     * @plexus.requirement
+     */
     private ContinuumInitializer initializer;
 
     /**
@@ -233,7 +239,7 @@
     {
         try
         {
-            return store.getProjectGroup( projectGroupId );
+            return projectGroupDao.getProjectGroup( projectGroupId );
         }
         catch ( ContinuumObjectNotFoundException e )
         {
@@ -250,7 +256,7 @@
     {
         try
         {
-            return store.getProjectGroupWithProjects( projectGroupId );
+            return projectGroupDao.getProjectGroupWithProjects( projectGroupId );
         }
         catch ( ContinuumStoreException e )
         {
@@ -263,7 +269,7 @@
     {
         try
         {
-            return store.getProjectGroupByProjectId( projectId );
+            return projectGroupDao.getProjectGroupByProjectId( projectId );
         }
         catch ( ContinuumObjectNotFoundException e )
         {
@@ -290,7 +296,7 @@
         context.put( AbstractContinuumAction.KEY_PROJECT_GROUP_ID, new Integer( projectGroup.getId() ) );
         executeAction( "remove-assignable-roles", context );
 
-        store.removeProjectGroup( projectGroup );
+        projectGroupDao.removeProjectGroup( projectGroup );
     }
 
     public void addProjectGroup( ProjectGroup projectGroup )
@@ -300,7 +306,7 @@
 
         try
         {
-            pg = store.getProjectGroupByGroupId( projectGroup.getGroupId() );
+            pg = projectGroupDao.getProjectGroupByGroupId( projectGroup.getGroupId() );
         }
         catch ( ContinuumObjectNotFoundException e )
         {
@@ -318,7 +324,7 @@
             projectGroup.setName( projectGroup.getName().trim() );
             try
             {
-                ProjectGroup new_pg = store.addProjectGroup( projectGroup );
+                ProjectGroup new_pg = projectGroupDao.addProjectGroup( projectGroup );
 
                 buildDefinitionService.addBuildDefinitionTemplateToProjectGroup( new_pg.getId(), buildDefinitionService
                     .getDefaultMavenTwoBuildDefinitionTemplate() );
@@ -348,7 +354,7 @@
 
     public List<ProjectGroup> getAllProjectGroups()
     {
-        return new ArrayList<ProjectGroup>( store.getAllProjectGroups() );
+        return new ArrayList<ProjectGroup>( projectGroupDao.getAllProjectGroups() );
     }
 
     public ProjectGroup getProjectGroupByGroupId( String groupId )
@@ -356,7 +362,7 @@
     {
         try
         {
-            return store.getProjectGroupByGroupId( groupId );
+            return projectGroupDao.getProjectGroupByGroupId( groupId );
         }
         catch ( ContinuumObjectNotFoundException e )
         {
@@ -373,7 +379,7 @@
     {
         try
         {
-            return store.getProjectGroupByGroupIdWithBuildDetails( groupId );
+            return projectGroupDao.getProjectGroupByGroupIdWithBuildDetails( groupId );
         }
         catch ( ContinuumObjectNotFoundException e )
         {
@@ -1762,7 +1768,7 @@
             {
                 try
                 {
-                    projectGroup = store.getProjectGroupByGroupId( projectGroup.getGroupId() );
+                    projectGroup = projectGroupDao.getProjectGroupByGroupId( projectGroup.getGroupId() );
 
                     projectGroupId = projectGroup.getId();
 
@@ -1788,7 +1794,7 @@
                 }
             }
 
-            projectGroup = store.getProjectGroupWithBuildDetailsByProjectGroupId( projectGroupId );
+            projectGroup = projectGroupDao.getProjectGroupWithBuildDetailsByProjectGroupId( projectGroupId );
 
             /* add the project group loaded from database, which has more info, like id */
             result.getProjectGroups().remove( 0 );
@@ -1828,7 +1834,7 @@
 
         try
         {
-            store.updateProjectGroup( projectGroup );
+            projectGroupDao.updateProjectGroup( projectGroup );
 
             for ( Project project : projects )
             {
@@ -1965,7 +1971,7 @@
 
         try
         {
-            store.updateProjectGroup( projectGroup );
+            projectGroupDao.updateProjectGroup( projectGroup );
         }
         catch ( ContinuumStoreException cse )
         {
@@ -2073,7 +2079,7 @@
         projectGroup.addNotifier( notif );
         try
         {
-            store.updateProjectGroup( projectGroup );
+            projectGroupDao.updateProjectGroup( projectGroup );
         }
         catch ( ContinuumStoreException cse )
         {
@@ -2164,7 +2170,7 @@
 
                 try
                 {
-                    store.updateProjectGroup( projectGroup );
+                    projectGroupDao.updateProjectGroup( projectGroup );
                 }
                 catch ( ContinuumStoreException cse )
                 {
@@ -3016,7 +3022,7 @@
         projectGroup.setName( projectGroup.getName().trim() );
         try
         {
-            store.updateProjectGroup( projectGroup );
+            projectGroupDao.updateProjectGroup( projectGroup );
         }
         catch ( ContinuumStoreException cse )
         {
@@ -3099,7 +3105,7 @@
     {
         try
         {
-            return store.getProjectGroupWithBuildDetailsByProjectGroupId( projectGroupId );
+            return projectGroupDao.getProjectGroupWithBuildDetailsByProjectGroupId( projectGroupId );
         }
         catch ( ContinuumObjectNotFoundException e )
         {
@@ -3131,12 +3137,12 @@
     public Collection<ProjectGroup> getAllProjectGroupsWithProjects()
     {
         //TODO: check why this interface isn't throwing exceptions on this guy
-        return store.getAllProjectGroupsWithProjects();
+        return projectGroupDao.getAllProjectGroupsWithProjects();
     }
 
     public List<ProjectGroup> getAllProjectGroupsWithBuildDetails()
     {
-        return store.getAllProjectGroupsWithBuildDetails();
+        return projectGroupDao.getAllProjectGroupsWithBuildDetails();
     }
 
     public Collection<Project> getProjectsInGroup( int projectGroupId )
@@ -3241,7 +3247,7 @@
     {
         try
         {
-            return store.getProjectGroupByGroupIdWithProjects( Continuum.DEFAULT_PROJECT_GROUP_GROUP_ID );
+            return projectGroupDao.getProjectGroupByGroupIdWithProjects( Continuum.DEFAULT_PROJECT_GROUP_GROUP_ID );
         }
         catch ( ContinuumObjectNotFoundException e )
         {

Modified: continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/builddefinition/DefaultBuildDefinitionService.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/builddefinition/DefaultBuildDefinitionService.java?rev=681490&r1=681489&r2=681490&view=diff
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/builddefinition/DefaultBuildDefinitionService.java (original)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/builddefinition/DefaultBuildDefinitionService.java Thu Jul 31 14:01:14 2008
@@ -19,6 +19,7 @@
 package org.apache.maven.continuum.builddefinition;
 
 import org.apache.continuum.configuration.ContinuumConfigurationException;
+import org.apache.continuum.dao.ProjectGroupDao;
 import org.apache.maven.continuum.configuration.ConfigurationLoadingException;
 import org.apache.maven.continuum.configuration.ConfigurationService;
 import org.apache.maven.continuum.execution.ContinuumBuildExecutorConstants;
@@ -87,6 +88,11 @@
     private ContinuumStore store;
 
     /**
+     * @plexus.requirement
+     */
+    private ProjectGroupDao projectGroupDao;
+
+    /**
      * @plexus.requirement role-hint="default"
      */
     private ConfigurationService configurationService;
@@ -575,7 +581,8 @@
     {
         try
         {
-            ProjectGroup projectGroup = store.getProjectGroupWithBuildDetailsByProjectGroupId( projectGroupId );
+            ProjectGroup projectGroup =
+                projectGroupDao.getProjectGroupWithBuildDetailsByProjectGroupId( projectGroupId );
             if ( template.getBuildDefinitions().isEmpty() )
             {
                 return null;
@@ -587,7 +594,7 @@
                 bd = store.addBuildDefinition( cloneBuildDefinition( bd ) );
                 projectGroup.addBuildDefinition( bd );
             }
-            store.updateProjectGroup( projectGroup );
+            projectGroupDao.updateProjectGroup( projectGroup );
             return projectGroup;
 
         }

Modified: continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddAssignableRolesAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddAssignableRolesAction.java?rev=681490&r1=681489&r2=681490&view=diff
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddAssignableRolesAction.java (original)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddAssignableRolesAction.java Thu Jul 31 14:01:14 2008
@@ -19,6 +19,7 @@
  * under the License.
  */
 
+import org.apache.continuum.dao.ProjectGroupDao;
 import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.model.project.ProjectGroup;
 import org.apache.maven.continuum.store.ContinuumStore;
@@ -44,6 +45,11 @@
     private ContinuumStore store;
 
     /**
+     * @plexus.requirement
+     */
+    private ProjectGroupDao projectGroupDao;
+
+    /**
      * @plexus.requirement role-hint="default"
      */
     private RoleManager roleManager;
@@ -53,7 +59,7 @@
     {
         int projectGroupId = getProjectGroupId( context );
 
-        ProjectGroup projectGroup = store.getProjectGroup( projectGroupId );
+        ProjectGroup projectGroup = projectGroupDao.getProjectGroup( projectGroupId );
 
         // TODO: make the resource the name of the project group and hide the id from the user
 

Modified: continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddBuildDefinitionToProjectGroupAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddBuildDefinitionToProjectGroupAction.java?rev=681490&r1=681489&r2=681490&view=diff
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddBuildDefinitionToProjectGroupAction.java (original)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddBuildDefinitionToProjectGroupAction.java Thu Jul 31 14:01:14 2008
@@ -19,6 +19,7 @@
  * under the License.
  */
 
+import org.apache.continuum.dao.ProjectGroupDao;
 import org.apache.maven.continuum.model.project.BuildDefinition;
 import org.apache.maven.continuum.model.project.BuildDefinitionTemplate;
 import org.apache.maven.continuum.model.project.ProjectGroup;
@@ -37,12 +38,17 @@
 public class AddBuildDefinitionToProjectGroupAction
     extends AbstractBuildDefinitionContinuumAction
 {
+    /**
+     * @plexus.requirement
+     */
+    private ProjectGroupDao projectGroupDao;
+
 
     public void execute( Map map )
         throws Exception
     {
         int projectGroupId = getProjectGroupId( map );
-        ProjectGroup projectGroup = store.getProjectGroupWithBuildDetailsByProjectGroupId( projectGroupId );
+        ProjectGroup projectGroup = projectGroupDao.getProjectGroupWithBuildDetailsByProjectGroupId( projectGroupId );
         BuildDefinitionTemplate buildDefinitionTemplate = getBuildDefinitionTemplate( map );
         if ( buildDefinitionTemplate != null )
         {
@@ -54,7 +60,7 @@
 
                 projectGroup.addBuildDefinition( buildDefinition );
 
-                store.updateProjectGroup( projectGroup );
+                projectGroupDao.updateProjectGroup( projectGroup );
             }
         }
         else
@@ -65,7 +71,7 @@
 
             projectGroup.addBuildDefinition( buildDefinition );
 
-            store.updateProjectGroup( projectGroup );
+            projectGroupDao.updateProjectGroup( projectGroup );
         }
         //map.put( AbstractContinuumAction.KEY_BUILD_DEFINITION, buildDefinition );
     }

Modified: continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/RemoveAssignableRolesAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/RemoveAssignableRolesAction.java?rev=681490&r1=681489&r2=681490&view=diff
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/RemoveAssignableRolesAction.java (original)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/RemoveAssignableRolesAction.java Thu Jul 31 14:01:14 2008
@@ -23,6 +23,7 @@
 import org.apache.maven.continuum.model.project.ProjectGroup;
 import org.apache.maven.continuum.store.ContinuumStore;
 import org.apache.maven.continuum.store.ContinuumStoreException;
+import org.apache.continuum.dao.ProjectGroupDao;
 import org.codehaus.plexus.redback.role.RoleManager;
 import org.codehaus.plexus.redback.role.RoleManagerException;
 
@@ -44,6 +45,11 @@
     private ContinuumStore store;
 
     /**
+     * @plexus.requirement
+     */
+    private ProjectGroupDao projectGroupDao;
+
+    /**
      * @plexus.requirement role-hint="default"
      */
     private RoleManager roleManager;
@@ -53,7 +59,7 @@
     {
         int projectGroupId = getProjectGroupId( context );
 
-        ProjectGroup projectGroup = store.getProjectGroup( projectGroupId );
+        ProjectGroup projectGroup = projectGroupDao.getProjectGroup( projectGroupId );
 
         try
         {

Modified: continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/RemoveBuildDefinitionFromProjectGroupAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/RemoveBuildDefinitionFromProjectGroupAction.java?rev=681490&r1=681489&r2=681490&view=diff
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/RemoveBuildDefinitionFromProjectGroupAction.java (original)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/RemoveBuildDefinitionFromProjectGroupAction.java Thu Jul 31 14:01:14 2008
@@ -19,6 +19,7 @@
  * under the License.
  */
 
+import org.apache.continuum.dao.ProjectGroupDao;
 import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.model.project.BuildDefinition;
 import org.apache.maven.continuum.model.project.ProjectGroup;
@@ -36,6 +37,11 @@
 public class RemoveBuildDefinitionFromProjectGroupAction
     extends AbstractBuildDefinitionContinuumAction
 {
+    /**
+     * @plexus.requirement
+     */
+    private ProjectGroupDao projectGroupDao;
+
 
     public void execute( Map map )
         throws Exception
@@ -43,7 +49,7 @@
         BuildDefinition buildDefinition = getBuildDefinition( map );
         int projectGroupId = getProjectGroupId( map );
 
-        ProjectGroup projectGroup = store.getProjectGroupWithBuildDetailsByProjectGroupId( projectGroupId );
+        ProjectGroup projectGroup = projectGroupDao.getProjectGroupWithBuildDetailsByProjectGroupId( projectGroupId );
 
         if ( buildDefinition.isDefaultForProject() )
         {
@@ -52,6 +58,6 @@
 
         projectGroup.removeBuildDefinition( buildDefinition );
 
-        store.updateProjectGroup( projectGroup );
+        projectGroupDao.updateProjectGroup( projectGroup );
     }
 }

Modified: continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/StoreProjectAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/StoreProjectAction.java?rev=681490&r1=681489&r2=681490&view=diff
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/StoreProjectAction.java (original)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/StoreProjectAction.java Thu Jul 31 14:01:14 2008
@@ -19,6 +19,7 @@
  * under the License.
  */
 
+import org.apache.continuum.dao.ProjectGroupDao;
 import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.model.project.ProjectGroup;
@@ -36,6 +37,10 @@
 public class StoreProjectAction
     extends AbstractContinuumAction
 {
+    /**
+     * @plexus.requirement
+     */
+    private ProjectGroupDao projectGroupDao;
 
     /**
      * @plexus.requirement role-hint="jdo"
@@ -61,10 +66,10 @@
             project.setScmPassword( null );
             project.setScmUseCache( false );
         }
-        
+
         projectGroup.addProject( project );
 
-        store.updateProjectGroup( projectGroup );
+        projectGroupDao.updateProjectGroup( projectGroup );
 
         context.put( KEY_PROJECT_ID, new Integer( project.getId() ) );
 

Modified: continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/StoreProjectGroupAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/StoreProjectGroupAction.java?rev=681490&r1=681489&r2=681490&view=diff
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/StoreProjectGroupAction.java (original)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/StoreProjectGroupAction.java Thu Jul 31 14:01:14 2008
@@ -19,6 +19,7 @@
  * under the License.
  */
 
+import org.apache.continuum.dao.ProjectGroupDao;
 import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.model.project.ProjectGroup;
 import org.apache.maven.continuum.store.ContinuumStore;
@@ -40,6 +41,11 @@
      */
     private ContinuumStore store;
 
+    /**
+     * @plexus.requirement
+     */
+    private ProjectGroupDao projectGroupDao;
+
     public void execute( Map context )
         throws ContinuumException, ContinuumStoreException
     {
@@ -49,7 +55,7 @@
         //
         // ----------------------------------------------------------------------
 
-        projectGroup = store.addProjectGroup( projectGroup );
+        projectGroup = projectGroupDao.addProjectGroup( projectGroup );
 
         context.put( KEY_PROJECT_GROUP_ID, new Integer( projectGroup.getId() ) );
     }

Modified: continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateBuildDefinitionFromProjectGroupAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateBuildDefinitionFromProjectGroupAction.java?rev=681490&r1=681489&r2=681490&view=diff
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateBuildDefinitionFromProjectGroupAction.java (original)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateBuildDefinitionFromProjectGroupAction.java Thu Jul 31 14:01:14 2008
@@ -19,6 +19,7 @@
  * under the License.
  */
 
+import org.apache.continuum.dao.ProjectGroupDao;
 import org.apache.maven.continuum.model.project.BuildDefinition;
 import org.apache.maven.continuum.model.project.ProjectGroup;
 
@@ -35,6 +36,11 @@
 public class UpdateBuildDefinitionFromProjectGroupAction
     extends AbstractBuildDefinitionContinuumAction
 {
+    /**
+     * @plexus.requirement
+     */
+    private ProjectGroupDao projectGroupDao;
+
 
     public void execute( Map map )
         throws Exception
@@ -42,7 +48,7 @@
         BuildDefinition buildDefinition = getBuildDefinition( map );
         int projectGroupId = getProjectGroupId( map );
 
-        ProjectGroup projectGroup = store.getProjectGroupWithBuildDetailsByProjectGroupId( projectGroupId );
+        ProjectGroup projectGroup = projectGroupDao.getProjectGroupWithBuildDetailsByProjectGroupId( projectGroupId );
 
         resolveDefaultBuildDefinitionsForProjectGroup( buildDefinition, projectGroup );
 

Modified: continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/initialization/DefaultContinuumInitializer.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/initialization/DefaultContinuumInitializer.java?rev=681490&r1=681489&r2=681490&view=diff
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/initialization/DefaultContinuumInitializer.java (original)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/initialization/DefaultContinuumInitializer.java Thu Jul 31 14:01:14 2008
@@ -19,6 +19,7 @@
  * under the License.
  */
 
+import org.apache.continuum.dao.ProjectGroupDao;
 import org.apache.maven.continuum.Continuum;
 import org.apache.maven.continuum.builddefinition.BuildDefinitionService;
 import org.apache.maven.continuum.builddefinition.BuildDefinitionServiceException;
@@ -53,6 +54,11 @@
     /**
      * @plexus.requirement
      */
+    private ProjectGroupDao projectGroupDao;
+
+    /**
+     * @plexus.requirement
+     */
     private BuildDefinitionService buildDefinitionService;
 
     // ----------------------------------------------------------------------
@@ -110,7 +116,7 @@
         ProjectGroup group;
         try
         {
-            group = store.getProjectGroupByGroupId( Continuum.DEFAULT_PROJECT_GROUP_GROUP_ID );
+            group = projectGroupDao.getProjectGroupByGroupId( Continuum.DEFAULT_PROJECT_GROUP_GROUP_ID );
             getLogger().info( "Default Project Group exists" );
         }
         catch ( ContinuumObjectNotFoundException e )
@@ -129,7 +135,7 @@
             group.getBuildDefinitions().addAll(
                 buildDefinitionService.getDefaultMavenTwoBuildDefinitionTemplate().getBuildDefinitions() );
 
-            group = store.addProjectGroup( group );
+            group = projectGroupDao.addProjectGroup( group );
         }
     }
 }

Modified: continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/notification/DefaultContinuumNotificationDispatcher.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/notification/DefaultContinuumNotificationDispatcher.java?rev=681490&r1=681489&r2=681490&view=diff
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/notification/DefaultContinuumNotificationDispatcher.java (original)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/notification/DefaultContinuumNotificationDispatcher.java Thu Jul 31 14:01:14 2008
@@ -19,6 +19,7 @@
  * under the License.
  */
 
+import org.apache.continuum.dao.ProjectGroupDao;
 import org.apache.maven.continuum.model.project.BuildDefinition;
 import org.apache.maven.continuum.model.project.BuildResult;
 import org.apache.maven.continuum.model.project.Project;
@@ -56,6 +57,11 @@
      */
     private ContinuumStore store;
 
+    /**
+     * @plexus.requirement
+     */
+    private ProjectGroupDao projectGroupDao;
+
     // ----------------------------------------------------------------------
     // ContinuumNotificationDispatcher Implementation
     // ----------------------------------------------------------------------
@@ -114,7 +120,7 @@
             project = store.getProjectWithAllDetails( project.getId() );
 
             ProjectGroup projectGroup =
-                store.getProjectGroupWithBuildDetailsByProjectGroupId( project.getProjectGroup().getId() );
+                projectGroupDao.getProjectGroupWithBuildDetailsByProjectGroupId( project.getProjectGroup().getId() );
 
             Map<String, List<ProjectNotifier>> notifiersMap = new HashMap<String, List<ProjectNotifier>>();
             // perform the project level notifications

Modified: continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java?rev=681490&r1=681489&r2=681490&view=diff
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java (original)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java Thu Jul 31 14:01:14 2008
@@ -19,13 +19,6 @@
  * under the License.
  */
 
-import java.io.File;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
 import org.apache.maven.continuum.builddefinition.BuildDefinitionService;
 import org.apache.maven.continuum.configuration.ConfigurationService;
 import org.apache.maven.continuum.execution.ContinuumBuildExecutorConstants;
@@ -37,6 +30,13 @@
 import org.codehaus.plexus.taskqueue.TaskQueue;
 import org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor;
 
+import java.io.File;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
  * @version $Id$
@@ -69,7 +69,7 @@
 
         int projectCount = getStore().getAllProjectsByName().size();
 
-        int projectGroupCount = getStore().getAllProjectGroupsWithProjects().size();
+        int projectGroupCount = getProjectGroupDao().getAllProjectGroupsWithProjects().size();
 
         File rootPom = getTestFile( "src/test/resources/projects/continuum/continuum-notifiers/pom.xml" );
 
@@ -85,12 +85,13 @@
 
         System.err.println( "number of projects: " + getStore().getAllProjectsByName().size() );
 
-        System.err.println( "number of project groups: " + getStore().getAllProjectGroupsWithProjects().size() );
+        System.err.println(
+            "number of project groups: " + getProjectGroupDao().getAllProjectGroupsWithProjects().size() );
 
         assertEquals( "Total project count", projectCount + 3, getStore().getAllProjectsByName().size() );
 
         assertEquals( "Total project group count.", projectGroupCount + 1,
-                      getStore().getAllProjectGroupsWithProjects().size() );
+                      getProjectGroupDao().getAllProjectGroupsWithProjects().size() );
 
         Map projects = new HashMap();
 
@@ -102,7 +103,7 @@
 
             // validate project in project group
             assertTrue( "project not in project group",
-                        getStore().getProjectGroupByProjectId( project.getId() ) != null );
+                        getProjectGroupDao().getProjectGroupByProjectId( project.getId() ) != null );
         }
 
         assertTrue( "no irc notifier", projects.containsKey( "Continuum IRC Notifier" ) );
@@ -167,9 +168,9 @@
         // reattach
         project = continuum.getProject( project.getId() );
 
-        ProjectGroup projectGroup = getStore().getProjectGroupByProjectId( project.getId() );
+        ProjectGroup projectGroup = getProjectGroupDao().getProjectGroupByProjectId( project.getId() );
 
-        projectGroup = getStore().getProjectGroupWithBuildDetailsByProjectGroupId( projectGroup.getId() );
+        projectGroup = getProjectGroupDao().getProjectGroupWithBuildDetailsByProjectGroupId( projectGroup.getId() );
 
         List buildDefs = projectGroup.getBuildDefinitions();
 
@@ -348,9 +349,11 @@
 
         Project project = (Project) projects.get( 0 );
 
-        assertTrue( "project missing from the checkout queue", continuum.removeProjectFromCheckoutQueue( project.getId() ) );
+        assertTrue( "project missing from the checkout queue",
+                    continuum.removeProjectFromCheckoutQueue( project.getId() ) );
 
-        assertFalse( "project still exist on the checkout queue", continuum.removeProjectFromCheckoutQueue( project.getId() ) );
+        assertFalse( "project still exist on the checkout queue",
+                     continuum.removeProjectFromCheckoutQueue( project.getId() ) );
     }
 
     public void testAddAntProjectWithdefaultBuildDef()
@@ -365,11 +368,11 @@
         assertEquals( 1, continuum.getProjectGroupWithProjects( defaultProjectGroup.getId() ).getProjects().size() );
         project = continuum.getProjectWithAllDetails( projectId );
         assertNotNull( project );
-        
+
         BuildDefinitionService service = (BuildDefinitionService) lookup( BuildDefinitionService.class );
         assertEquals( 4, service.getAllBuildDefinitionTemplate().size() );
         assertEquals( 5, service.getAllBuildDefinitions().size() );
-        
+
         BuildDefinition buildDef = (BuildDefinition) service.getDefaultAntBuildDefinitionTemplate()
             .getBuildDefinitions().get( 0 );
         buildDef = service.cloneBuildDefinition( buildDef );
@@ -380,12 +383,12 @@
         assertEquals( 4, service.getAllBuildDefinitionTemplate().size() );
         assertEquals( 6, service.getAllBuildDefinitions().size() );
     }
-    
+
     private Continuum getContinuum()
         throws Exception
     {
         return (Continuum) lookup( Continuum.ROLE );
     }
-    
+
 
 }

Modified: continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/buildcontroller/BuildProjectTaskExecutorTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/buildcontroller/BuildProjectTaskExecutorTest.java?rev=681490&r1=681489&r2=681490&view=diff
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/buildcontroller/BuildProjectTaskExecutorTest.java (original)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/buildcontroller/BuildProjectTaskExecutorTest.java Thu Jul 31 14:01:14 2008
@@ -242,7 +242,7 @@
 
         int projectGroupId = AbstractContinuumAction.getProjectGroupId( pgContext );
 
-        projectGroup = continuumStore.getProjectGroupWithBuildDetailsByProjectGroupId( projectGroupId );
+        projectGroup = getProjectGroupDao().getProjectGroupWithBuildDetailsByProjectGroupId( projectGroupId );
 
         project = (Project) projectGroup.getProjects().get( 0 );
 

Modified: continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/builddefinition/DefaultBuildDefinitionServiceTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/builddefinition/DefaultBuildDefinitionServiceTest.java?rev=681490&r1=681489&r2=681490&view=diff
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/builddefinition/DefaultBuildDefinitionServiceTest.java (original)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/builddefinition/DefaultBuildDefinitionServiceTest.java Thu Jul 31 14:01:14 2008
@@ -18,8 +18,6 @@
  */
 package org.apache.maven.continuum.builddefinition;
 
-import java.util.List;
-
 import org.apache.log4j.Logger;
 import org.apache.maven.continuum.AbstractContinuumTest;
 import org.apache.maven.continuum.model.project.BuildDefinition;
@@ -27,15 +25,17 @@
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.model.project.ProjectGroup;
 
+import java.util.List;
+
 /**
  * @author <a href="mailto:olamy@apache.org">olamy</a>
- * @since 15 sept. 07
  * @version $Id$
+ * @since 15 sept. 07
  */
 public class DefaultBuildDefinitionServiceTest
     extends AbstractContinuumTest
 {
-    
+
     private Logger logger = Logger.getLogger( getClass() );
 
     private ProjectGroup projectGroup;
@@ -43,7 +43,7 @@
     private Project project;
 
     private BuildDefinition buildDefinition;
-    
+
     private BuildDefinitionTemplate buildDefinitionTemplate;
 
     protected void setUp()
@@ -54,14 +54,14 @@
 
         projectGroup = new ProjectGroup();
         projectGroup.setName( "test" );
-        projectGroup = getStore().addProjectGroup( projectGroup );
+        projectGroup = getProjectGroupDao().addProjectGroup( projectGroup );
 
         project = new Project();
         project.setGroupId( "foo" );
         project.setArtifactId( "bar" );
         project.setVersion( "0.1-alpha-1-SNAPSHOT" );
         projectGroup.addProject( project );
-        getStore().updateProjectGroup( projectGroup );
+        getProjectGroupDao().updateProjectGroup( projectGroup );
 
         buildDefinition = new BuildDefinition();
         buildDefinition.setTemplate( true );
@@ -70,13 +70,13 @@
         buildDefinition.setBuildFile( "pom.xml" );
         buildDefinition.setDescription( "desc template" );
         buildDefinition = getBuildDefinitionService().addBuildDefinition( buildDefinition );
-        
+
         buildDefinitionTemplate = new BuildDefinitionTemplate();
         buildDefinitionTemplate.setName( "test" );
         buildDefinitionTemplate = getBuildDefinitionService().addBuildDefinitionTemplate( buildDefinitionTemplate );
-        buildDefinitionTemplate = getBuildDefinitionService().addBuildDefinitionInTemplate( buildDefinitionTemplate,
-                                                                                            buildDefinition, false );
-        
+        buildDefinitionTemplate =
+            getBuildDefinitionService().addBuildDefinitionInTemplate( buildDefinitionTemplate, buildDefinition, false );
+
 
     }
 
@@ -94,7 +94,7 @@
             List<BuildDefinitionTemplate> templates = getBuildDefinitionService().getAllBuildDefinitionTemplate();
             assertEquals( 5, templates.size() );
             assertEquals( 5, getBuildDefinitionService().getAllBuildDefinitions().size() );
-            
+
             getBuildDefinitionService().addTemplateInProject( buildDefinitionTemplate.getId(), project );
             project = getStore().getProjectWithAllDetails( project.getId() );
             templates = getBuildDefinitionService().getAllBuildDefinitionTemplate();
@@ -119,8 +119,8 @@
             throw e;
         }
     }
-   
-    
+
+
     public void testGetDefaultBuildDef()
         throws Exception
     {
@@ -137,9 +137,9 @@
         assertNotNull( bd );
         assertEquals( "pom.xml", bd.getBuildFile() );
         assertEquals( "clean install", bd.getGoals() );
-    }    
-    
-    
+    }
+
+
     public void testAddBuildDefinitionTemplate()
         throws Exception
     {
@@ -165,6 +165,6 @@
         assertEquals( 0, template.getBuildDefinitions().size() );
         all = getBuildDefinitionService().getAllBuildDefinitions();
         assertEquals( 5, all.size() );
-        
+
     }
 }

Modified: continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilderTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilderTest.java?rev=681490&r1=681489&r2=681490&view=diff
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilderTest.java (original)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilderTest.java Thu Jul 31 14:01:14 2008
@@ -373,7 +373,7 @@
         logger.debug( "templates number " + service.getAllBuildDefinitionTemplate().size() );
 
         ContinuumStore store = (ContinuumStore) lookup( ContinuumStore.class , "jdo" );
-        logger.debug( "projectGroups number " + store.getAllProjectGroups().size() );        
+        logger.debug( "projectGroups number " + getProjectGroupDao().getAllProjectGroups().size() );        
         
         int all = service.getAllBuildDefinitions().size();
         

Modified: continuum/branches/continuum-refactoring-evenisse/continuum-data-management/data-management-cli/pom.xml
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-data-management/data-management-cli/pom.xml?rev=681490&r1=681489&r2=681490&view=diff
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-data-management/data-management-cli/pom.xml (original)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-data-management/data-management-cli/pom.xml Thu Jul 31 14:01:14 2008
@@ -58,6 +58,10 @@
       <artifactId>plexus-jdo2</artifactId>
     </dependency>
     <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+    </dependency>      
+    <dependency>
       <groupId>log4j</groupId>
       <artifactId>log4j</artifactId>
     </dependency>

Modified: continuum/branches/continuum-refactoring-evenisse/continuum-data-management/data-management-jdo/pom.xml
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-data-management/data-management-jdo/pom.xml?rev=681490&r1=681489&r2=681490&view=diff
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-data-management/data-management-jdo/pom.xml (original)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-data-management/data-management-jdo/pom.xml Thu Jul 31 14:01:14 2008
@@ -95,6 +95,11 @@
       <artifactId>jdom</artifactId>
       <version>1.0</version>
       <scope>test</scope>
-    </dependency>      
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 </project>

Modified: continuum/branches/continuum-refactoring-evenisse/continuum-store/pom.xml
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-store/pom.xml?rev=681490&r1=681489&r2=681490&view=diff
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-store/pom.xml (original)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-store/pom.xml Thu Jul 31 14:01:14 2008
@@ -58,6 +58,10 @@
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-utils</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+    </dependency>
   </dependencies>
   <build>
     <plugins>

Added: continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/AbstractDao.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/AbstractDao.java?rev=681490&view=auto
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/AbstractDao.java (added)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/AbstractDao.java Thu Jul 31 14:01:14 2008
@@ -0,0 +1,174 @@
+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.store.ContinuumObjectNotFoundException;
+import org.apache.maven.continuum.store.ContinuumStoreException;
+import org.codehaus.plexus.jdo.PlexusJdoUtils;
+import org.codehaus.plexus.jdo.PlexusObjectNotFoundException;
+import org.codehaus.plexus.jdo.PlexusStoreException;
+
+import javax.jdo.FetchPlan;
+import javax.jdo.PersistenceManager;
+import javax.jdo.PersistenceManagerFactory;
+import javax.jdo.Transaction;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
+ * @version $Id$
+ */
+public class AbstractDao
+{
+    // ----------------------------------------------------------------------
+    // Fetch Groups
+    // ----------------------------------------------------------------------
+
+    protected static final String PROJECT_WITH_BUILDS_FETCH_GROUP = "project-with-builds";
+
+    protected static final String PROJECT_WITH_CHECKOUT_RESULT_FETCH_GROUP = "project-with-checkout-result";
+
+    protected static final String BUILD_RESULT_WITH_DETAILS_FETCH_GROUP = "build-result-with-details";
+
+    protected static final String PROJECT_BUILD_DETAILS_FETCH_GROUP = "project-build-details";
+
+    protected static final String PROJECT_ALL_DETAILS_FETCH_GROUP = "project-all-details";
+
+    protected static final String PROJECT_DEPENDENCIES_FETCH_GROUP = "project-dependencies";
+
+    protected static final String PROJECTGROUP_PROJECTS_FETCH_GROUP = "projectgroup-projects";
+
+    protected static final String BUILD_TEMPLATE_BUILD_DEFINITIONS = "build-template-build-definitions";
+
+    /**
+     * @plexus.requirement
+     */
+    private StoreUtilities storeUtilities;
+
+    protected Object addObject( Object object )
+    {
+        return addObject( getPersistenceManager(), object );
+    }
+
+    private Object addObject( PersistenceManager pmf, Object object )
+    {
+        return PlexusJdoUtils.addObject( pmf, object );
+    }
+
+    protected void removeObject( Object o )
+    {
+        PlexusJdoUtils.removeObject( getPersistenceManager(), o );
+    }
+
+    protected void updateObject( Object object )
+        throws ContinuumStoreException
+    {
+        updateObject( getPersistenceManager(), object );
+    }
+
+    private void updateObject( PersistenceManager pmf, Object object )
+        throws ContinuumStoreException
+    {
+        try
+        {
+            PlexusJdoUtils.updateObject( pmf, object );
+        }
+        catch ( PlexusStoreException e )
+        {
+            throw new ContinuumStoreException( e.getMessage(), e );
+        }
+    }
+
+    protected Object getObjectById( Class clazz, int id )
+        throws ContinuumStoreException
+    {
+        return getObjectById( clazz, id, null );
+    }
+
+    protected Object getObjectById( Class clazz, int id, String fetchGroup )
+        throws ContinuumStoreException
+    {
+        try
+        {
+            return PlexusJdoUtils.getObjectById( getPersistenceManager(), clazz, id, fetchGroup );
+        }
+        catch ( PlexusObjectNotFoundException e )
+        {
+            throw new ContinuumObjectNotFoundException( e.getMessage() );
+        }
+        catch ( PlexusStoreException e )
+        {
+            throw new ContinuumStoreException( e.getMessage(), e );
+        }
+    }
+
+    protected Object getObjectFromQuery( Class clazz, String idField, String id, String fetchGroup )
+        throws ContinuumStoreException
+    {
+        try
+        {
+            return PlexusJdoUtils.getObjectFromQuery( getPersistenceManager(), clazz, idField, id, fetchGroup );
+        }
+        catch ( PlexusObjectNotFoundException e )
+        {
+            throw new ContinuumObjectNotFoundException( e.getMessage() );
+        }
+        catch ( PlexusStoreException e )
+        {
+            throw new ContinuumStoreException( e.getMessage(), e );
+        }
+    }
+
+    protected List getAllObjectsDetached( Class clazz, String ordering, String fetchGroup )
+    {
+        return getAllObjectsDetached( getPersistenceManager(), clazz, ordering, fetchGroup );
+    }
+
+    protected List getAllObjectsDetached( PersistenceManager pmf, Class clazz, String ordering, String fetchGroup )
+    {
+        return PlexusJdoUtils.getAllObjectsDetached( pmf, clazz, ordering, fetchGroup );
+    }
+
+    protected void rollback( Transaction tx )
+    {
+        PlexusJdoUtils.rollbackIfActive( tx );
+    }
+
+
+    protected PersistenceManager getPersistenceManager()
+    {
+        return getPersistenceManager( getContinuumPersistenceManagerFactory() );
+    }
+
+    private PersistenceManager getPersistenceManager( PersistenceManagerFactory pmf )
+    {
+        PersistenceManager pm = pmf.getPersistenceManager();
+
+        pm.getFetchPlan().setMaxFetchDepth( -1 );
+        pm.getFetchPlan().setDetachmentOptions( FetchPlan.DETACH_LOAD_FIELDS );
+
+        return pm;
+    }
+
+    protected PersistenceManagerFactory getContinuumPersistenceManagerFactory()
+    {
+        return storeUtilities.getContinuumPersistenceManagerFactory();
+    }
+}

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

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

Added: 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=681490&view=auto
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/ProjectGroupDaoImpl.java (added)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/ProjectGroupDaoImpl.java Thu Jul 31 14:01:14 2008
@@ -0,0 +1,166 @@
+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.ContinuumStore;
+import org.apache.maven.continuum.store.ContinuumStoreException;
+import org.codehaus.plexus.jdo.PlexusJdoUtils;
+
+import java.util.Arrays;
+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.ProjectGroupDao"
+ */
+public class ProjectGroupDaoImpl
+    extends AbstractDao
+    implements ProjectGroupDao
+{
+    /**
+     * @plexus.requirement role-hint="jdo"
+     */
+    private ContinuumStore store;
+
+    public ProjectGroup addProjectGroup( ProjectGroup group )
+    {
+        return (ProjectGroup) addObject( group );
+    }
+
+    public void removeProjectGroup( ProjectGroup projectGroup )
+    {
+        ProjectGroup pg = null;
+        try
+        {
+            pg = getProjectGroupWithProjects( projectGroup.getId() );
+        }
+        catch ( Exception e )
+        {
+            // Do nothing
+        }
+
+        if ( pg != null )
+        {
+            // TODO: why do we need to do this? if not - build results are not
+            // removed and a integrity constraint is violated. I assume its
+            // because of the fetch groups
+            for ( Project p : (List<Project>) pg.getProjects() )
+            {
+                store.removeProject( p );
+            }
+            removeObject( pg );
+        }
+    }
+
+    public ProjectGroup getProjectGroup( int projectGroupId )
+        throws ContinuumStoreException
+    {
+        return (ProjectGroup) getObjectById( ProjectGroup.class, projectGroupId );
+    }
+
+    public ProjectGroup getProjectGroupByGroupId( String groupId )
+        throws ContinuumStoreException
+    {
+        return (ProjectGroup) getObjectFromQuery( ProjectGroup.class, "groupId", groupId, null );
+    }
+
+    public ProjectGroup getProjectGroupByGroupIdWithBuildDetails( String groupId )
+        throws ContinuumStoreException
+    {
+        return (ProjectGroup) getObjectFromQuery( ProjectGroup.class, "groupId", groupId,
+                                                  PROJECT_BUILD_DETAILS_FETCH_GROUP );
+    }
+
+    public ProjectGroup getProjectGroupByGroupIdWithProjects( String groupId )
+        throws ContinuumStoreException
+    {
+        return (ProjectGroup) getObjectFromQuery( ProjectGroup.class, "groupId", groupId,
+                                                  PROJECTGROUP_PROJECTS_FETCH_GROUP );
+    }
+
+    public ProjectGroup getProjectGroupByProjectId( int projectId )
+        throws ContinuumObjectNotFoundException
+    {
+        try
+        {
+            return store.getProject( projectId ).getProjectGroup();
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new ContinuumObjectNotFoundException(
+                "unable to find project group containing project with id: " + projectId );
+
+        }
+    }
+
+    public ProjectGroup getProjectGroupByProject( Project project )
+        throws ContinuumObjectNotFoundException
+    {
+        return getProjectGroupByProjectId( project.getId() );
+    }
+
+    public void updateProjectGroup( ProjectGroup group )
+        throws ContinuumStoreException
+    {
+        updateObject( group );
+    }
+
+    public ProjectGroup getProjectGroupWithProjects( int projectGroupId )
+        throws ContinuumStoreException
+    {
+        return (ProjectGroup) getObjectById( ProjectGroup.class, projectGroupId, PROJECTGROUP_PROJECTS_FETCH_GROUP );
+    }
+
+    public Collection<ProjectGroup> getAllProjectGroupsWithProjects()
+    {
+        return getAllObjectsDetached( ProjectGroup.class, "name ascending", PROJECTGROUP_PROJECTS_FETCH_GROUP );
+    }
+
+    public List<ProjectGroup> getAllProjectGroupsWithBuildDetails()
+    {
+        return getAllObjectsDetached( ProjectGroup.class, "name ascending", PROJECT_BUILD_DETAILS_FETCH_GROUP );
+    }
+
+    public List<ProjectGroup> getAllProjectGroups()
+    {
+        return getAllObjectsDetached( ProjectGroup.class, "name ascending", null );
+    }
+
+    public List<ProjectGroup> getAllProjectGroupsWithTheLot()
+    {
+        List fetchGroups = Arrays.asList( new String[]{PROJECT_WITH_BUILDS_FETCH_GROUP,
+            PROJECTGROUP_PROJECTS_FETCH_GROUP, BUILD_RESULT_WITH_DETAILS_FETCH_GROUP,
+            PROJECT_WITH_CHECKOUT_RESULT_FETCH_GROUP, PROJECT_ALL_DETAILS_FETCH_GROUP,
+            PROJECT_BUILD_DETAILS_FETCH_GROUP} );
+        return PlexusJdoUtils.getAllObjectsDetached( getPersistenceManager(), ProjectGroup.class, "name ascending",
+                                                     fetchGroups );
+    }
+
+    public ProjectGroup getProjectGroupWithBuildDetailsByProjectGroupId( int projectGroupId )
+        throws ContinuumStoreException
+    {
+        return (ProjectGroup) getObjectById( ProjectGroup.class, projectGroupId, PROJECT_BUILD_DETAILS_FETCH_GROUP );
+    }
+}

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

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

Added: continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/StoreUtilities.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/StoreUtilities.java?rev=681490&view=auto
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/StoreUtilities.java (added)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/StoreUtilities.java Thu Jul 31 14:01:14 2008
@@ -0,0 +1,48 @@
+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.codehaus.plexus.jdo.JdoFactory;
+
+import javax.jdo.PersistenceManagerFactory;
+
+/**
+ * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
+ * @version $Id$
+ * @plexus.component role="org.apache.continuum.dao.StoreUtilities"
+ */
+public class StoreUtilities
+{
+    /**
+     * @plexus.requirement role-hint="continuum"
+     */
+    private JdoFactory continuumJdoFactory;
+
+    private PersistenceManagerFactory continuumPersistenceManagerFactory;
+
+    public PersistenceManagerFactory getContinuumPersistenceManagerFactory()
+    {
+        if ( continuumPersistenceManagerFactory == null )
+        {
+            continuumPersistenceManagerFactory = continuumJdoFactory.getPersistenceManagerFactory();
+        }
+        return continuumPersistenceManagerFactory;
+    }
+}

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

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

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=681490&r1=681489&r2=681490&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 Thu Jul 31 14:01:14 2008
@@ -19,24 +19,7 @@
  * under the License.
  */
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.jdo.Extent;
-import javax.jdo.FetchPlan;
-import javax.jdo.JDOHelper;
-import javax.jdo.JDOUserException;
-import javax.jdo.PersistenceManager;
-import javax.jdo.PersistenceManagerFactory;
-import javax.jdo.Query;
-import javax.jdo.Transaction;
-
+import org.apache.continuum.dao.AbstractDao;
 import org.apache.maven.continuum.execution.ContinuumBuildExecutorConstants;
 import org.apache.maven.continuum.model.project.BuildDefinition;
 import org.apache.maven.continuum.model.project.BuildDefinitionTemplate;
@@ -54,11 +37,26 @@
 import org.apache.maven.continuum.model.system.Profile;
 import org.apache.maven.continuum.model.system.SystemConfiguration;
 import org.apache.maven.continuum.project.ContinuumProjectState;
-import org.codehaus.plexus.jdo.JdoFactory;
 import org.codehaus.plexus.jdo.PlexusJdoUtils;
-import org.codehaus.plexus.jdo.PlexusObjectNotFoundException;
-import org.codehaus.plexus.jdo.PlexusStoreException;
 import org.codehaus.plexus.util.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.jdo.Extent;
+import javax.jdo.JDOHelper;
+import javax.jdo.JDOUserException;
+import javax.jdo.PersistenceManager;
+import javax.jdo.PersistenceManagerFactory;
+import javax.jdo.Query;
+import javax.jdo.Transaction;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
 
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
@@ -68,39 +66,10 @@
  * role-hint="jdo"
  */
 public class JdoContinuumStore
-    extends AbstractContinuumStore
+    extends AbstractDao
     implements ContinuumStore
 {
-    /**
-     * @plexus.requirement role-hint="continuum"
-     */
-    private JdoFactory continuumJdoFactory;
-
-    // ----------------------------------------------------------------------
-    //
-    // ----------------------------------------------------------------------
-
-    private PersistenceManagerFactory continuumPersistenceManagerFactory;
-
-    // ----------------------------------------------------------------------
-    // Fetch Groups
-    // ----------------------------------------------------------------------
-
-    private static final String PROJECT_WITH_BUILDS_FETCH_GROUP = "project-with-builds";
-
-    private static final String PROJECT_WITH_CHECKOUT_RESULT_FETCH_GROUP = "project-with-checkout-result";
-
-    private static final String BUILD_RESULT_WITH_DETAILS_FETCH_GROUP = "build-result-with-details";
-
-    private static final String PROJECT_BUILD_DETAILS_FETCH_GROUP = "project-build-details";
-
-    private static final String PROJECT_ALL_DETAILS_FETCH_GROUP = "project-all-details";
-
-    private static final String PROJECT_DEPENDENCIES_FETCH_GROUP = "project-dependencies";
-
-    private static final String PROJECTGROUP_PROJECTS_FETCH_GROUP = "projectgroup-projects";
-
-    private static final String BUILD_TEMPLATE_BUILD_DEFINITIONS = "build-template-build-definitions";
+    private static Logger log = LoggerFactory.getLogger( JdoContinuumStore.class );
 
     // ----------------------------------------------------------------------
     // ContinuumStore Implementation
@@ -617,7 +586,7 @@
         catch ( ContinuumObjectNotFoundException cne )
         {
             // ignore since we will try the project group
-            getLogger().debug( "no default build definition on project, trying project group" );
+            log.debug( "no default build definition on project, trying project group" );
         }
 
         // project group should have default build definition defined
@@ -642,6 +611,22 @@
         return bd;
     }
 
+    private 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 );
+
+        }
+    }
+
+
     public BuildDefinition getDefaultBuildDefinitionForProject( int projectId )
         throws ContinuumStoreException, ContinuumObjectNotFoundException
     {
@@ -694,6 +679,13 @@
         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();
@@ -987,23 +979,6 @@
         return PlexusJdoUtils.makePersistent( pm, object, detach );
     }
 
-    private Object getObjectFromQuery( Class clazz, String idField, String id, String fetchGroup )
-        throws ContinuumStoreException, ContinuumObjectNotFoundException
-    {
-        try
-        {
-            return PlexusJdoUtils.getObjectFromQuery( getPersistenceManager(), clazz, idField, id, fetchGroup );
-        }
-        catch ( PlexusObjectNotFoundException e )
-        {
-            throw new ContinuumObjectNotFoundException( e.getMessage() );
-        }
-        catch ( PlexusStoreException e )
-        {
-            throw new ContinuumStoreException( e.getMessage(), e );
-        }
-    }
-
     private void attachAndDelete( Object object )
     {
         PlexusJdoUtils.attachAndDelete( getPersistenceManager(), object );
@@ -1013,75 +988,6 @@
     // Transaction Management
     // ----------------------------------------------------------------------
 
-    private void rollback( Transaction tx )
-    {
-        PlexusJdoUtils.rollbackIfActive( tx );
-    }
-
-    public ProjectGroup getProjectGroup( int projectGroupId )
-        throws ContinuumStoreException, ContinuumObjectNotFoundException
-    {
-        return (ProjectGroup) getObjectById( ProjectGroup.class, projectGroupId );
-    }
-
-    private Object getObjectById( Class clazz, int id )
-        throws ContinuumStoreException, ContinuumObjectNotFoundException
-    {
-        return getObjectById( clazz, id, null );
-    }
-
-    private Object getObjectById( Class clazz, int id, String fetchGroup )
-        throws ContinuumStoreException, ContinuumObjectNotFoundException
-    {
-        try
-        {
-            return PlexusJdoUtils.getObjectById( getPersistenceManager(), clazz, id, fetchGroup );
-        }
-        catch ( PlexusObjectNotFoundException e )
-        {
-            throw new ContinuumObjectNotFoundException( e.getMessage() );
-        }
-        catch ( PlexusStoreException e )
-        {
-            throw new ContinuumStoreException( e.getMessage(), e );
-        }
-    }
-
-    public void updateProjectGroup( ProjectGroup group )
-        throws ContinuumStoreException
-    {
-        updateObject( group );
-    }
-
-    private void updateObject( Object object )
-        throws ContinuumStoreException
-    {
-        updateObject( getPersistenceManager(), object );
-    }
-
-    private void updateObject( PersistenceManager pmf, Object object )
-        throws ContinuumStoreException
-    {
-        try
-        {
-            PlexusJdoUtils.updateObject( pmf, object );
-        }
-        catch ( PlexusStoreException e )
-        {
-            throw new ContinuumStoreException( e.getMessage(), e );
-        }
-    }
-
-    public Collection<ProjectGroup> getAllProjectGroupsWithProjects()
-    {
-        return getAllObjectsDetached( ProjectGroup.class, "name ascending", PROJECTGROUP_PROJECTS_FETCH_GROUP );
-    }
-
-    public Collection<ProjectGroup> getAllProjectGroups()
-    {
-        return getAllObjectsDetached( ProjectGroup.class, "name ascending", null );
-    }
-
     public List<Project> getAllProjectsByName()
     {
         return getAllObjectsDetached( Project.class, "name ascending", null );
@@ -1750,31 +1656,6 @@
         removeObject( project );
     }
 
-    public void removeProjectGroup( ProjectGroup projectGroup )
-    {
-        ProjectGroup pg = null;
-        try
-        {
-            pg = getProjectGroupWithProjects( projectGroup.getId() );
-        }
-        catch ( Exception e )
-        {
-            // Do nothing
-        }
-
-        if ( pg != null )
-        {
-            // TODO: why do we need to do this? if not - build results are not
-            // removed and a integrity constraint is violated. I assume its
-            // because of the fetch groups
-            for ( Project p : (List<Project>) pg.getProjects() )
-            {
-                removeProject( p );
-            }
-            removeObject( pg );
-        }
-    }
-
     public List<Project> getProjectsInGroup( int projectGroupId )
         throws ContinuumObjectNotFoundException, ContinuumStoreException
     {
@@ -1841,18 +1722,6 @@
         }
     }
 
-    public ProjectGroup getProjectGroupWithProjects( int projectGroupId )
-        throws ContinuumObjectNotFoundException, ContinuumStoreException
-    {
-        return (ProjectGroup) getObjectById( ProjectGroup.class, projectGroupId, PROJECTGROUP_PROJECTS_FETCH_GROUP );
-    }
-
-    public ProjectGroup getProjectGroupWithBuildDetailsByProjectGroupId( int projectGroupId )
-        throws ContinuumObjectNotFoundException, ContinuumStoreException
-    {
-        return (ProjectGroup) getObjectById( ProjectGroup.class, projectGroupId, PROJECT_BUILD_DETAILS_FETCH_GROUP );
-    }
-
     public List<ProjectGroup> getAllProjectGroupsWithBuildDetails()
     {
         return getAllObjectsDetached( ProjectGroup.class, "name ascending", PROJECT_BUILD_DETAILS_FETCH_GROUP );
@@ -1881,11 +1750,6 @@
         return (Profile) getObjectById( Profile.class, profileId );
     }
 
-    private void removeObject( Object o )
-    {
-        PlexusJdoUtils.removeObject( getPersistenceManager(), o );
-    }
-
     private List getAllObjectsDetached( Class clazz )
     {
         return getAllObjectsDetached( clazz, null );
@@ -1896,11 +1760,6 @@
         return getAllObjectsDetached( clazz, null, fetchGroup );
     }
 
-    private List getAllObjectsDetached( Class clazz, String ordering, String fetchGroup )
-    {
-        return getAllObjectsDetached( getPersistenceManager(), clazz, ordering, fetchGroup );
-    }
-
     private List getAllObjectsDetached( PersistenceManager pmf, Class clazz )
     {
         return getAllObjectsDetached( pmf, clazz, null );
@@ -1911,67 +1770,12 @@
         return getAllObjectsDetached( pmf, clazz, null, fetchGroup );
     }
 
-    private List getAllObjectsDetached( PersistenceManager pmf, Class clazz, String ordering, String fetchGroup )
-    {
-        return PlexusJdoUtils.getAllObjectsDetached( pmf, clazz, ordering, fetchGroup );
-    }
-
-    public ProjectGroup addProjectGroup( ProjectGroup group )
-    {
-        return (ProjectGroup) addObject( group );
-    }
-
-    private Object addObject( Object object )
-    {
-        return addObject( getPersistenceManager(), object );
-    }
-
-    private Object addObject( PersistenceManager pmf, Object object )
-    {
-        return PlexusJdoUtils.addObject( pmf, object );
-    }
-
-    public ProjectGroup getProjectGroupByGroupId( String groupId )
-        throws ContinuumStoreException, ContinuumObjectNotFoundException
-    {
-        return (ProjectGroup) getObjectFromQuery( ProjectGroup.class, "groupId", groupId, null );
-    }
-
-    public ProjectGroup getProjectGroupByGroupIdWithBuildDetails( String groupId )
-        throws ContinuumStoreException, ContinuumObjectNotFoundException
-    {
-        return (ProjectGroup) getObjectFromQuery( ProjectGroup.class, "groupId", groupId,
-                                                  PROJECT_BUILD_DETAILS_FETCH_GROUP );
-    }
-
-    public ProjectGroup getProjectGroupByGroupIdWithProjects( String groupId )
-        throws ContinuumStoreException, ContinuumObjectNotFoundException
-    {
-        return (ProjectGroup) getObjectFromQuery( ProjectGroup.class, "groupId", groupId,
-                                                  PROJECTGROUP_PROJECTS_FETCH_GROUP );
-    }
-
     public Project getProjectWithBuildDetails( int projectId )
         throws ContinuumObjectNotFoundException, ContinuumStoreException
     {
         return (Project) getObjectById( Project.class, projectId, 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 );
-
-        }
-    }
-
     public SystemConfiguration addSystemConfiguration( SystemConfiguration systemConf )
     {
         return (SystemConfiguration) addObject( systemConf );
@@ -2003,21 +1807,6 @@
         }
     }
 
-    private PersistenceManager getPersistenceManager()
-    {
-        return getPersistenceManager( getContinuumPersistenceManagerFactory() );
-    }
-
-    private PersistenceManager getPersistenceManager( PersistenceManagerFactory pmf )
-    {
-        PersistenceManager pm = pmf.getPersistenceManager();
-
-        pm.getFetchPlan().setMaxFetchDepth( -1 );
-        pm.getFetchPlan().setDetachmentOptions( FetchPlan.DETACH_LOAD_FIELDS );
-
-        return pm;
-    }
-
     public void closeStore()
     {
         closePersistenceManagerFactory( getContinuumPersistenceManagerFactory(), 1 );
@@ -2094,13 +1883,4 @@
             }
         }
     }
-
-    private PersistenceManagerFactory getContinuumPersistenceManagerFactory()
-    {
-        if ( continuumPersistenceManagerFactory == null )
-        {
-            continuumPersistenceManagerFactory = continuumJdoFactory.getPersistenceManagerFactory();
-        }
-        return continuumPersistenceManagerFactory;
-    }
 }



Mime
View raw message