continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r682441 - 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/continuum/bui...
Date Mon, 04 Aug 2008 16:58:26 GMT
Author: evenisse
Date: Mon Aug  4 09:58:26 2008
New Revision: 682441

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

Added:
    continuum/branches/continuum-refactoring-evenisse/continuum-api/src/main/java/org/apache/continuum/dao/BuildDefinitionTemplateDao.java
  (with props)
    continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/BuildDefinitionTemplateDaoImpl.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/builddefinition/DefaultBuildDefinitionService.java
    continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/AbstractDao.java
    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/ContinuumStoreTest.java

Added: continuum/branches/continuum-refactoring-evenisse/continuum-api/src/main/java/org/apache/continuum/dao/BuildDefinitionTemplateDao.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-api/src/main/java/org/apache/continuum/dao/BuildDefinitionTemplateDao.java?rev=682441&view=auto
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-api/src/main/java/org/apache/continuum/dao/BuildDefinitionTemplateDao.java
(added)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-api/src/main/java/org/apache/continuum/dao/BuildDefinitionTemplateDao.java
Mon Aug  4 09:58:26 2008
@@ -0,0 +1,70 @@
+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.BuildDefinitionTemplate;
+import org.apache.maven.continuum.store.ContinuumStoreException;
+
+import java.util.List;
+
+/**
+ * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
+ * @version $Id$
+ */
+public interface BuildDefinitionTemplateDao
+{
+    List<BuildDefinitionTemplate> getAllBuildDefinitionTemplate()
+        throws ContinuumStoreException;
+
+    BuildDefinitionTemplate getBuildDefinitionTemplate( int id )
+        throws ContinuumStoreException;
+
+    BuildDefinitionTemplate addBuildDefinitionTemplate( BuildDefinitionTemplate buildDefinitionTemplate
)
+        throws ContinuumStoreException;
+
+    BuildDefinitionTemplate updateBuildDefinitionTemplate( BuildDefinitionTemplate buildDefinitionTemplate
)
+        throws ContinuumStoreException;
+
+    void removeBuildDefinitionTemplate( BuildDefinitionTemplate buildDefinitionTemplate )
+        throws ContinuumStoreException;
+
+    public List<BuildDefinitionTemplate> getBuildDefinitionTemplatesWithType( String
type )
+        throws ContinuumStoreException;
+
+    public List<BuildDefinitionTemplate> getContinuumBuildDefinitionTemplates()
+        throws ContinuumStoreException;
+
+    /**
+     * @param type
+     * @return BuildDefinitionTemplate null if not found
+     * @throws ContinuumStoreException
+     */
+    BuildDefinitionTemplate getContinuumBuildDefinitionTemplateWithType( String type )
+        throws ContinuumStoreException;
+
+    /**
+     * the list returned will contains only continuumDefaults {@link org.apache.maven.continuum.model.project.BuildDefinition}
+     *
+     * @return List<BuildDefinitionTemplate>
+     * @throws ContinuumStoreException
+     */
+    List<BuildDefinitionTemplate> getContinuumDefaultdDefinitions()
+        throws ContinuumStoreException;
+}

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

Propchange: continuum/branches/continuum-refactoring-evenisse/continuum-api/src/main/java/org/apache/continuum/dao/BuildDefinitionTemplateDao.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=682441&r1=682440&r2=682441&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
Mon Aug  4 09:58:26 2008
@@ -20,7 +20,6 @@
  */
 
 import org.apache.maven.continuum.model.project.BuildDefinition;
-import org.apache.maven.continuum.model.project.BuildDefinitionTemplate;
 import org.apache.maven.continuum.model.project.BuildResult;
 import org.apache.maven.continuum.model.project.Project;
 
@@ -56,43 +55,6 @@
     //  BuildDefinitionTemplate
     // ------------------------------------------------------
 
-    List<BuildDefinitionTemplate> getAllBuildDefinitionTemplate()
-        throws ContinuumStoreException;
-
-    BuildDefinitionTemplate getBuildDefinitionTemplate( int id )
-        throws ContinuumStoreException, ContinuumObjectNotFoundException;
-
-    BuildDefinitionTemplate addBuildDefinitionTemplate( BuildDefinitionTemplate buildDefinitionTemplate
)
-        throws ContinuumStoreException;
-
-    BuildDefinitionTemplate updateBuildDefinitionTemplate( BuildDefinitionTemplate buildDefinitionTemplate
)
-        throws ContinuumStoreException;
-
-    void removeBuildDefinitionTemplate( BuildDefinitionTemplate buildDefinitionTemplate )
-        throws ContinuumStoreException;
-
-    public List<BuildDefinitionTemplate> getBuildDefinitionTemplatesWithType( String
type )
-        throws ContinuumStoreException;
-
-    public List<BuildDefinitionTemplate> getContinuumBuildDefinitionTemplates()
-        throws ContinuumStoreException;
-
-    /**
-     * @param type
-     * @return BuildDefinitionTemplate null if not found
-     * @throws ContinuumStoreException
-     */
-    BuildDefinitionTemplate getContinuumBuildDefinitionTemplateWithType( String type )
-        throws ContinuumStoreException;
-
-    /**
-     * the list returned will contains only continuumDefaults {@link BuildDefinition}
-     *
-     * @return List<BuildDefinitionTemplate>
-     * @throws ContinuumStoreException
-     */
-    List<BuildDefinitionTemplate> getContinuumDefaultdDefinitions()
-        throws ContinuumStoreException;
 
     List<BuildResult> getAllBuildsForAProjectByDate( int projectId );
 

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=682441&r1=682440&r2=682441&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
Mon Aug  4 09:58:26 2008
@@ -19,9 +19,10 @@
 package org.apache.maven.continuum.builddefinition;
 
 import org.apache.continuum.configuration.ContinuumConfigurationException;
+import org.apache.continuum.dao.BuildDefinitionDao;
+import org.apache.continuum.dao.BuildDefinitionTemplateDao;
 import org.apache.continuum.dao.ProjectDao;
 import org.apache.continuum.dao.ProjectGroupDao;
-import org.apache.continuum.dao.BuildDefinitionDao;
 import org.apache.maven.continuum.configuration.ConfigurationLoadingException;
 import org.apache.maven.continuum.configuration.ConfigurationService;
 import org.apache.maven.continuum.execution.ContinuumBuildExecutorConstants;
@@ -31,7 +32,6 @@
 import org.apache.maven.continuum.model.project.ProjectGroup;
 import org.apache.maven.continuum.model.project.Schedule;
 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.logging.AbstractLogEnabled;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
@@ -52,7 +52,6 @@
     extends AbstractLogEnabled
     implements BuildDefinitionService, Initializable
 {
-
     /**
      * @plexus.configuration default-value=""
      */
@@ -84,14 +83,14 @@
     private String defaultM2Arguments;
 
     /**
-     * @plexus.requirement role-hint="jdo"
+     * @plexus.requirement
      */
-    private ContinuumStore store;
+    private BuildDefinitionDao buildDefinitionDao;
 
     /**
      * @plexus.requirement
      */
-    private BuildDefinitionDao buildDefinitionDao;
+    private BuildDefinitionTemplateDao buildDefinitionTemplateDao;
 
     /**
      * @plexus.requirement
@@ -256,7 +255,7 @@
     {
         try
         {
-            return store.getContinuumBuildDefinitionTemplateWithType( type );
+            return buildDefinitionTemplateDao.getContinuumBuildDefinitionTemplateWithType(
type );
         }
         catch ( ContinuumStoreException e )
         {
@@ -440,7 +439,7 @@
     {
         try
         {
-            return store.getAllBuildDefinitionTemplate();
+            return buildDefinitionTemplateDao.getAllBuildDefinitionTemplate();
         }
         catch ( ContinuumStoreException e )
         {
@@ -453,7 +452,7 @@
     {
         try
         {
-            return store.getBuildDefinitionTemplate( id );
+            return buildDefinitionTemplateDao.getBuildDefinitionTemplate( id );
         }
         catch ( ContinuumStoreException e )
         {
@@ -469,8 +468,9 @@
             // first remove links to buildDefs
             // TODO in the same db transaction ?
             buildDefinitionTemplate.setBuildDefinitions( null );
-            buildDefinitionTemplate = store.updateBuildDefinitionTemplate( buildDefinitionTemplate
);
-            store.removeBuildDefinitionTemplate( buildDefinitionTemplate );
+            buildDefinitionTemplate =
+                buildDefinitionTemplateDao.updateBuildDefinitionTemplate( buildDefinitionTemplate
);
+            buildDefinitionTemplateDao.removeBuildDefinitionTemplate( buildDefinitionTemplate
);
         }
         catch ( ContinuumStoreException e )
         {
@@ -486,7 +486,7 @@
             BuildDefinitionTemplate stored = getBuildDefinitionTemplate( buildDefinitionTemplate.getId()
);
             stored.setName( buildDefinitionTemplate.getName() );
             stored.setBuildDefinitions( buildDefinitionTemplate.getBuildDefinitions() );
-            return store.updateBuildDefinitionTemplate( stored );
+            return buildDefinitionTemplateDao.updateBuildDefinitionTemplate( stored );
         }
         catch ( ContinuumStoreException e )
         {
@@ -499,7 +499,7 @@
     {
         try
         {
-            return store.addBuildDefinitionTemplate( buildDefinitionTemplate );
+            return buildDefinitionTemplateDao.addBuildDefinitionTemplate( buildDefinitionTemplate
);
         }
         catch ( ContinuumStoreException e )
         {
@@ -523,7 +523,7 @@
             buildDefinition.setTemplate( template );
             //stored.addBuildDefinition( addBuildDefinition( buildDefinition ) );
             stored.addBuildDefinition( buildDefinition );
-            return store.updateBuildDefinitionTemplate( stored );
+            return buildDefinitionTemplateDao.updateBuildDefinitionTemplate( stored );
         }
         catch ( ContinuumStoreException e )
         {
@@ -549,7 +549,7 @@
                 }
             }
             stored.setBuildDefinitions( buildDefinitions );
-            return store.updateBuildDefinitionTemplate( stored );
+            return buildDefinitionTemplateDao.updateBuildDefinitionTemplate( stored );
         }
         catch ( ContinuumStoreException e )
         {
@@ -620,7 +620,7 @@
     {
         try
         {
-            return store.getBuildDefinitionTemplatesWithType( type );
+            return buildDefinitionTemplateDao.getBuildDefinitionTemplatesWithType( type );
         }
         catch ( ContinuumStoreException e )
         {
@@ -633,7 +633,7 @@
     {
         try
         {
-            return store.getContinuumBuildDefinitionTemplates();
+            return buildDefinitionTemplateDao.getContinuumBuildDefinitionTemplates();
         }
         catch ( ContinuumStoreException e )
         {

Modified: 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=682441&r1=682440&r2=682441&view=diff
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/AbstractDao.java
(original)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/AbstractDao.java
Mon Aug  4 09:58:26 2008
@@ -141,7 +141,7 @@
         return getAllObjectsDetached( clazz, null );
     }
 
-    private List getAllObjectsDetached( Class clazz, String fetchGroup )
+    protected List getAllObjectsDetached( Class clazz, String fetchGroup )
     {
         return getAllObjectsDetached( clazz, null, fetchGroup );
     }

Added: continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/BuildDefinitionTemplateDaoImpl.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/BuildDefinitionTemplateDaoImpl.java?rev=682441&view=auto
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/BuildDefinitionTemplateDaoImpl.java
(added)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/BuildDefinitionTemplateDaoImpl.java
Mon Aug  4 09:58:26 2008
@@ -0,0 +1,190 @@
+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.BuildDefinitionTemplate;
+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.Collections;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
+ * @version $Id$
+ * @plexus.component role="org.apache.continuum.dao.BuildDefinitionTemplateDao"
+ */
+public class BuildDefinitionTemplateDaoImpl
+    extends AbstractDao
+    implements BuildDefinitionTemplateDao
+{
+    public List<BuildDefinitionTemplate> getAllBuildDefinitionTemplate()
+        throws ContinuumStoreException
+    {
+        return getAllObjectsDetached( BuildDefinitionTemplate.class, BUILD_TEMPLATE_BUILD_DEFINITIONS
);
+    }
+
+    public List<BuildDefinitionTemplate> getContinuumBuildDefinitionTemplates()
+        throws ContinuumStoreException
+    {
+        PersistenceManager pm = getPersistenceManager();
+
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            Extent extent = pm.getExtent( BuildDefinitionTemplate.class, true );
+
+            Query query = pm.newQuery( extent );
+            query.setFilter( "continuumDefault == true" );
+            pm.getFetchPlan().addGroup( BUILD_TEMPLATE_BUILD_DEFINITIONS );
+            List result = (List) query.execute();
+            return result == null ? Collections.EMPTY_LIST : (List) pm.detachCopyAll( result
);
+        }
+        finally
+        {
+            tx.commit();
+
+            rollback( tx );
+        }
+    }
+
+    public BuildDefinitionTemplate getBuildDefinitionTemplate( int id )
+        throws ContinuumStoreException
+    {
+        return (BuildDefinitionTemplate) getObjectById( BuildDefinitionTemplate.class, id,
+                                                        BUILD_TEMPLATE_BUILD_DEFINITIONS
);
+    }
+
+    public BuildDefinitionTemplate addBuildDefinitionTemplate( BuildDefinitionTemplate buildDefinitionTemplate
)
+        throws ContinuumStoreException
+    {
+        return (BuildDefinitionTemplate) addObject( buildDefinitionTemplate );
+    }
+
+    public BuildDefinitionTemplate updateBuildDefinitionTemplate( BuildDefinitionTemplate
buildDefinitionTemplate )
+        throws ContinuumStoreException
+    {
+        updateObject( buildDefinitionTemplate );
+
+        return buildDefinitionTemplate;
+    }
+
+    public void removeBuildDefinitionTemplate( BuildDefinitionTemplate buildDefinitionTemplate
)
+        throws ContinuumStoreException
+    {
+        removeObject( buildDefinitionTemplate );
+    }
+
+    public List<BuildDefinitionTemplate> getBuildDefinitionTemplatesWithType( String
type )
+        throws ContinuumStoreException
+    {
+        PersistenceManager pm = getPersistenceManager();
+
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            Extent extent = pm.getExtent( BuildDefinitionTemplate.class, true );
+
+            Query query = pm.newQuery( extent );
+            query.declareImports( "import java.lang.String" );
+            query.declareParameters( "String type" );
+            query.setFilter( "this.type == type" );
+            pm.getFetchPlan().addGroup( BUILD_TEMPLATE_BUILD_DEFINITIONS );
+            List result = (List) query.execute( type );
+            return result == null ? Collections.EMPTY_LIST : (List) pm.detachCopyAll( result
);
+        }
+        finally
+        {
+            tx.commit();
+
+            rollback( tx );
+        }
+    }
+
+    public BuildDefinitionTemplate getContinuumBuildDefinitionTemplateWithType( String type
)
+        throws ContinuumStoreException
+    {
+        PersistenceManager pm = getPersistenceManager();
+
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            Extent extent = pm.getExtent( BuildDefinitionTemplate.class, true );
+
+            Query query = pm.newQuery( extent );
+            query.declareImports( "import java.lang.String" );
+            query.declareParameters( "String type" );
+            query.setFilter( "continuumDefault == true && this.type == type" );
+            pm.getFetchPlan().addGroup( BUILD_TEMPLATE_BUILD_DEFINITIONS );
+            List result = (List) query.execute( type );
+            if ( result == null || result.isEmpty() )
+            {
+                return null;
+            }
+            return (BuildDefinitionTemplate) pm.detachCopy( result.get( 0 ) );
+        }
+        finally
+        {
+            tx.commit();
+
+            rollback( tx );
+        }
+    }
+
+    public List<BuildDefinitionTemplate> getContinuumDefaultdDefinitions()
+        throws ContinuumStoreException
+    {
+        PersistenceManager pm = getPersistenceManager();
+
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            Extent extent = pm.getExtent( BuildDefinitionTemplate.class, true );
+
+            Query query = pm.newQuery( extent );
+            query.setFilter( "continuumDefault == 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/BuildDefinitionTemplateDaoImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/BuildDefinitionTemplateDaoImpl.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=682441&r1=682440&r2=682441&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 09:58:26 2008
@@ -50,7 +50,6 @@
 import javax.jdo.Query;
 import javax.jdo.Transaction;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -680,164 +679,11 @@
         return null;
     }
 
-
-    public List<BuildDefinitionTemplate> getContinuumBuildDefinitionTemplates()
-        throws ContinuumStoreException
-    {
-        PersistenceManager pm = getPersistenceManager();
-
-        Transaction tx = pm.currentTransaction();
-
-        try
-        {
-            tx.begin();
-
-            Extent extent = pm.getExtent( BuildDefinitionTemplate.class, true );
-
-            Query query = pm.newQuery( extent );
-            query.setFilter( "continuumDefault == true" );
-            pm.getFetchPlan().addGroup( BUILD_TEMPLATE_BUILD_DEFINITIONS );
-            List result = (List) query.execute();
-            return result == null ? Collections.EMPTY_LIST : (List) pm.detachCopyAll( result
);
-        }
-        finally
-        {
-            tx.commit();
-
-            rollback( tx );
-        }
-    }
-
-
-    public BuildDefinitionTemplate getContinuumBuildDefinitionTemplateWithType( String type
)
-        throws ContinuumStoreException
-    {
-        PersistenceManager pm = getPersistenceManager();
-
-        Transaction tx = pm.currentTransaction();
-
-        try
-        {
-            tx.begin();
-
-            Extent extent = pm.getExtent( BuildDefinitionTemplate.class, true );
-
-            Query query = pm.newQuery( extent );
-            query.declareImports( "import java.lang.String" );
-            query.declareParameters( "String type" );
-            query.setFilter( "continuumDefault == true && this.type == type" );
-            pm.getFetchPlan().addGroup( BUILD_TEMPLATE_BUILD_DEFINITIONS );
-            List result = (List) query.execute( type );
-            if ( result == null || result.isEmpty() )
-            {
-                return null;
-            }
-            return (BuildDefinitionTemplate) pm.detachCopy( result.get( 0 ) );
-        }
-        finally
-        {
-            tx.commit();
-
-            rollback( tx );
-        }
-    }
-
     // ------------------------------------------------------
     //  BuildDefinitionTemplate
     // ------------------------------------------------------      
 
 
-    public BuildDefinitionTemplate addBuildDefinitionTemplate( BuildDefinitionTemplate buildDefinitionTemplate
)
-        throws ContinuumStoreException
-    {
-        return (BuildDefinitionTemplate) addObject( buildDefinitionTemplate );
-    }
-
-    public List<BuildDefinitionTemplate> getAllBuildDefinitionTemplate()
-        throws ContinuumStoreException
-    {
-        return getAllObjectsDetached( BuildDefinitionTemplate.class, BUILD_TEMPLATE_BUILD_DEFINITIONS
);
-    }
-
-    public BuildDefinitionTemplate getBuildDefinitionTemplate( int id )
-        throws ContinuumStoreException, ContinuumObjectNotFoundException
-    {
-        return (BuildDefinitionTemplate) getObjectById( BuildDefinitionTemplate.class, id,
-                                                        BUILD_TEMPLATE_BUILD_DEFINITIONS
);
-    }
-
-    public void removeBuildDefinitionTemplate( BuildDefinitionTemplate buildDefinitionTemplate
)
-        throws ContinuumStoreException
-    {
-        removeObject( buildDefinitionTemplate );
-    }
-
-    public BuildDefinitionTemplate updateBuildDefinitionTemplate( BuildDefinitionTemplate
buildDefinitionTemplate )
-        throws ContinuumStoreException
-    {
-        updateObject( buildDefinitionTemplate );
-
-        return buildDefinitionTemplate;
-    }
-
-    public List<BuildDefinitionTemplate> getContinuumDefaultdDefinitions()
-        throws ContinuumStoreException
-    {
-        PersistenceManager pm = getPersistenceManager();
-
-        Transaction tx = pm.currentTransaction();
-
-        try
-        {
-            tx.begin();
-
-            Extent extent = pm.getExtent( BuildDefinitionTemplate.class, true );
-
-            Query query = pm.newQuery( extent );
-            query.setFilter( "continuumDefault == true" );
-
-            List result = (List) query.execute();
-
-            return result == null ? Collections.EMPTY_LIST : (List) pm.detachCopyAll( result
);
-        }
-        finally
-        {
-            tx.commit();
-
-            rollback( tx );
-        }
-    }
-
-    public List<BuildDefinitionTemplate> getBuildDefinitionTemplatesWithType( String
type )
-        throws ContinuumStoreException
-    {
-        PersistenceManager pm = getPersistenceManager();
-
-        Transaction tx = pm.currentTransaction();
-
-        try
-        {
-            tx.begin();
-
-            Extent extent = pm.getExtent( BuildDefinitionTemplate.class, true );
-
-            Query query = pm.newQuery( extent );
-            query.declareImports( "import java.lang.String" );
-            query.declareParameters( "String type" );
-            query.setFilter( "this.type == type" );
-            pm.getFetchPlan().addGroup( BUILD_TEMPLATE_BUILD_DEFINITIONS );
-            List result = (List) query.execute( type );
-            return result == null ? Collections.EMPTY_LIST : (List) pm.detachCopyAll( result
);
-        }
-        finally
-        {
-            tx.commit();
-
-            rollback( tx );
-        }
-    }
-
-
     private Object makePersistent( PersistenceManager pm, Object object, boolean detach )
     {
         return PlexusJdoUtils.makePersistent( pm, object, detach );
@@ -1188,11 +1034,6 @@
         }
     }
 
-    private List getAllObjectsDetached( Class clazz, String fetchGroup )
-    {
-        return getAllObjectsDetached( clazz, null, fetchGroup );
-    }
-
     public Project getProjectWithBuildDetails( int projectId )
         throws ContinuumObjectNotFoundException, ContinuumStoreException
     {

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=682441&r1=682440&r2=682441&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 09:58:26 2008
@@ -20,6 +20,7 @@
  */
 
 import org.apache.continuum.dao.BuildDefinitionDao;
+import org.apache.continuum.dao.BuildDefinitionTemplateDao;
 import org.apache.maven.continuum.execution.ContinuumBuildExecutorConstants;
 import org.apache.maven.continuum.installation.InstallationService;
 import org.apache.maven.continuum.model.project.BuildDefinition;
@@ -52,12 +53,9 @@
 public class ContinuumStoreTest
     extends AbstractContinuumStoreTestCase
 {
-
     private static final int INVALID_ID = 15000;
 
-    // ----------------------------------------------------------------------
-    //
-    // ----------------------------------------------------------------------
+    private BuildDefinitionTemplateDao buildDefinitionTemplateDao;
 
     protected BuildDefinitionDao buildDefinitionDao;
 
@@ -1082,26 +1080,26 @@
         template.setName( "test" );
         template.setContinuumDefault( true );
         template.setType( ContinuumBuildExecutorConstants.MAVEN_TWO_BUILD_EXECUTOR );
-        template = store.addBuildDefinitionTemplate( template );
+        template = buildDefinitionTemplateDao.addBuildDefinitionTemplate( template );
         buildDefinition = buildDefinitionDao.addBuildDefinition( buildDefinition );
 
         template.addBuildDefinition( buildDefinition );
 
-        template = store.updateBuildDefinitionTemplate( template );
+        template = buildDefinitionTemplateDao.updateBuildDefinitionTemplate( template );
 
         assertEquals( "test", template.getName() );
         assertTrue( template.isContinuumDefault() );
         assertEquals( 1, template.getBuildDefinitions().size() );
         assertEquals( all + 1, buildDefinitionDao.getAllBuildDefinitions().size() );
-        assertEquals( 1, store.getAllBuildDefinitionTemplate().size() );
+        assertEquals( 1, buildDefinitionTemplateDao.getAllBuildDefinitionTemplate().size()
);
 
-        template = store
+        template = buildDefinitionTemplateDao
             .getContinuumBuildDefinitionTemplateWithType( ContinuumBuildExecutorConstants.MAVEN_TWO_BUILD_EXECUTOR
);
 
         assertNotNull( template );
         assertEquals( 1, template.getBuildDefinitions().size() );
 
-        assertEquals( 1, store.getAllBuildDefinitionTemplate().size() );
+        assertEquals( 1, buildDefinitionTemplateDao.getAllBuildDefinitionTemplate().size()
);
     }
 
     // ----------------------------------------------------------------------
@@ -1166,6 +1164,8 @@
 
         buildDefinitionDao = (BuildDefinitionDao) lookup( BuildDefinitionDao.class.getName()
);
 
+        buildDefinitionTemplateDao = (BuildDefinitionTemplateDao) lookup( BuildDefinitionTemplateDao.class.getName()
);
+
         createBuildDatabase();
     }
 



Mime
View raw message