You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@continuum.apache.org by ev...@apache.org on 2008/08/06 00:01:31 UTC
svn commit: r682986 [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...
Author: evenisse
Date: Tue Aug 5 15:01:30 2008
New Revision: 682986
URL: http://svn.apache.org/viewvc?rev=682986&view=rev
Log:
The end of ContinuumStore
Added:
continuum/branches/continuum-refactoring-evenisse/continuum-api/src/main/java/org/apache/continuum/dao/BuildResultDao.java (with props)
continuum/branches/continuum-refactoring-evenisse/continuum-api/src/main/java/org/apache/continuum/dao/DaoUtils.java (with props)
continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/BuildResultDaoImpl.java (with props)
continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/DaoUtilsImpl.java (with props)
Removed:
continuum/branches/continuum-refactoring-evenisse/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java
continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/maven/continuum/store/
Modified:
continuum/branches/continuum-refactoring-evenisse/continuum-api/src/main/java/org/apache/continuum/dao/BuildDefinitionDao.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/buildcontroller/DefaultBuildController.java
continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractBuildDefinitionContinuumAction.java
continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java
continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java
continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/scm/DefaultContinuumScm.java
continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/buildcontroller/DefaultBuildControllerTest.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/buildqueue/BuildQueueTest.java
continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/initialization/DefaultContinuumInitializerTest.java
continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/installation/DefaultInstallationServiceTest.java
continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcherTest.java
continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/profile/DefaultProfileServiceTest.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-core/src/test/resources/org/apache/maven/continuum/notification/ContinuumNotificationDispatcherTest.xml
continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/resources/org/apache/maven/continuum/notification/mail/MailContinuumNotifierTest.xml
continuum/branches/continuum-refactoring-evenisse/continuum-data-management/data-management-jdo/src/main/java/org/apache/maven/continuum/management/JdoDataManagementTool.java
continuum/branches/continuum-refactoring-evenisse/continuum-notifiers/continuum-notifier-api/src/main/java/org/apache/maven/continuum/notification/AbstractContinuumNotifier.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/continuum/dao/BuildDefinitionDaoImpl.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
continuum/branches/continuum-refactoring-evenisse/continuum-webapp/src/main/resources/META-INF/plexus/application.xml
Modified: continuum/branches/continuum-refactoring-evenisse/continuum-api/src/main/java/org/apache/continuum/dao/BuildDefinitionDao.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-api/src/main/java/org/apache/continuum/dao/BuildDefinitionDao.java?rev=682986&r1=682985&r2=682986&view=diff
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-api/src/main/java/org/apache/continuum/dao/BuildDefinitionDao.java (original)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-api/src/main/java/org/apache/continuum/dao/BuildDefinitionDao.java Tue Aug 5 15:01:30 2008
@@ -100,6 +100,21 @@
BuildDefinition getDefaultBuildDefinitionForProject( Project project )
throws ContinuumStoreException;
+ /**
+ * returns the default build definition of the project, if the project
+ * doesn't have on declared the default of the project group will be
+ * returned <p/> this should be the most common usage of the default build
+ * definition accessing methods
+ *
+ * @param projectId
+ * @return
+ * @throws ContinuumStoreException
+ * @throws org.apache.maven.continuum.store.ContinuumObjectNotFoundException
+ *
+ */
+ BuildDefinition getDefaultBuildDefinition( int projectId )
+ throws ContinuumStoreException;
+
List<BuildDefinition> getAllTemplates()
throws ContinuumStoreException;
}
Added: continuum/branches/continuum-refactoring-evenisse/continuum-api/src/main/java/org/apache/continuum/dao/BuildResultDao.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-api/src/main/java/org/apache/continuum/dao/BuildResultDao.java?rev=682986&view=auto
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-api/src/main/java/org/apache/continuum/dao/BuildResultDao.java (added)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-api/src/main/java/org/apache/continuum/dao/BuildResultDao.java Tue Aug 5 15:01:30 2008
@@ -0,0 +1,76 @@
+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.BuildResult;
+import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.store.ContinuumStoreException;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
+ * @version $Id$
+ */
+public interface BuildResultDao
+{
+ BuildResult getBuildResult( int buildId )
+ throws ContinuumStoreException;
+
+ void addBuildResult( Project project, BuildResult build )
+ throws ContinuumStoreException;
+
+ void updateBuildResult( BuildResult build )
+ throws ContinuumStoreException;
+
+ void removeBuildResult( BuildResult buildResult );
+
+ BuildResult getLatestBuildResultForProject( int projectId );
+
+ BuildResult getLatestBuildResultForBuildDefinition( int projectId, int buildDefinitionId );
+
+ List<BuildResult> getBuildResultsInSuccessForProject( int projectId, long fromDate );
+
+ long getNbBuildResultsForProject( int projectId );
+
+ List<BuildResult> getBuildResultsForProject( int projectId );
+
+ List<BuildResult> getBuildResultsForProject( int projectId, long startIndex, long endIndex );
+
+ List<BuildResult> getBuildResultsForProject( int projectId, long fromDate );
+
+ Map<Integer, BuildResult> getLatestBuildResultsByProjectGroupId( int projectGroupId );
+
+ Map<Integer, BuildResult> getLatestBuildResults();
+
+ List<BuildResult> getBuildResultByBuildNumber( int projectId, int buildNumber );
+
+ List<BuildResult> getBuildResultsByBuildDefinition( int projectId, int buildDefinitionId );
+
+ List<BuildResult> getBuildResultsByBuildDefinition( int projectId, int buildDefinitionId, long startIndex,
+ long endIndex );
+
+ Map<Integer, BuildResult> getBuildResultsInSuccess();
+
+ Map<Integer, BuildResult> getBuildResultsInSuccessByProjectGroupId( int projectGroupId );
+
+ List<BuildResult> getAllBuildsForAProjectByDate( int projectId );
+}
Propchange: continuum/branches/continuum-refactoring-evenisse/continuum-api/src/main/java/org/apache/continuum/dao/BuildResultDao.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: continuum/branches/continuum-refactoring-evenisse/continuum-api/src/main/java/org/apache/continuum/dao/BuildResultDao.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: continuum/branches/continuum-refactoring-evenisse/continuum-api/src/main/java/org/apache/continuum/dao/DaoUtils.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-api/src/main/java/org/apache/continuum/dao/DaoUtils.java?rev=682986&view=auto
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-api/src/main/java/org/apache/continuum/dao/DaoUtils.java (added)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-api/src/main/java/org/apache/continuum/dao/DaoUtils.java Tue Aug 5 15:01:30 2008
@@ -0,0 +1,45 @@
+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.ContinuumStoreException;
+
+import javax.jdo.PersistenceManagerFactory;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
+ * @version $Id$
+ */
+public interface DaoUtils
+{
+ void closeStore();
+
+ void eraseDatabase();
+
+ Map getProjectIdsAndBuildDefinitionsIdsBySchedule( int scheduleId )
+ throws ContinuumStoreException;
+
+ Map getProjectGroupIdsAndBuildDefinitionsIdsBySchedule( int scheduleId )
+ throws ContinuumStoreException;
+
+ Map getAggregatedProjectIdsAndBuildDefinitionIdsBySchedule( int scheduleId )
+ throws ContinuumStoreException;
+}
Propchange: continuum/branches/continuum-refactoring-evenisse/continuum-api/src/main/java/org/apache/continuum/dao/DaoUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: continuum/branches/continuum-refactoring-evenisse/continuum-api/src/main/java/org/apache/continuum/dao/DaoUtils.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
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=682986&r1=682985&r2=682986&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 Tue Aug 5 15:01:30 2008
@@ -22,6 +22,8 @@
import org.apache.commons.lang.ArrayUtils;
import org.apache.continuum.configuration.ContinuumConfigurationException;
import org.apache.continuum.dao.BuildDefinitionDao;
+import org.apache.continuum.dao.BuildResultDao;
+import org.apache.continuum.dao.DaoUtils;
import org.apache.continuum.dao.NotifierDao;
import org.apache.continuum.dao.ProjectDao;
import org.apache.continuum.dao.ProjectGroupDao;
@@ -59,7 +61,6 @@
import org.apache.maven.continuum.release.ContinuumReleaseManager;
import org.apache.maven.continuum.scm.queue.CheckOutTask;
import org.apache.maven.continuum.store.ContinuumObjectNotFoundException;
-import org.apache.maven.continuum.store.ContinuumStore;
import org.apache.maven.continuum.store.ContinuumStoreException;
import org.apache.maven.continuum.utils.PlexusContainerManager;
import org.apache.maven.continuum.utils.ProjectSorter;
@@ -124,9 +125,9 @@
private ConfigurationService configurationService;
/**
- * @plexus.requirement role-hint="jdo"
+ * @plexus.requirement
*/
- private ContinuumStore store;
+ private DaoUtils daoUtils;
/**
* @plexus.requirement
@@ -136,6 +137,11 @@
/**
* @plexus.requirement
*/
+ private BuildResultDao buildResultDao;
+
+ /**
+ * @plexus.requirement
+ */
private NotifierDao notifierDao;
/**
@@ -433,7 +439,7 @@
public Map<Integer, BuildResult> getLatestBuildResults( int projectGroupId )
{
- Map<Integer, BuildResult> result = store.getLatestBuildResultsByProjectGroupId( projectGroupId );
+ Map<Integer, BuildResult> result = buildResultDao.getLatestBuildResultsByProjectGroupId( projectGroupId );
if ( result == null )
{
@@ -445,7 +451,7 @@
public Map<Integer, BuildResult> getLatestBuildResults()
{
- Map<Integer, BuildResult> result = store.getLatestBuildResults();
+ Map<Integer, BuildResult> result = buildResultDao.getLatestBuildResults();
if ( result == null )
{
@@ -457,7 +463,7 @@
public Map<Integer, BuildResult> getBuildResultsInSuccess( int projectGroupId )
{
- Map<Integer, BuildResult> result = store.getBuildResultsInSuccessByProjectGroupId( projectGroupId );
+ Map<Integer, BuildResult> result = buildResultDao.getBuildResultsInSuccessByProjectGroupId( projectGroupId );
if ( result == null )
{
@@ -469,7 +475,7 @@
public Map<Integer, BuildResult> getBuildResultsInSuccess()
{
- Map<Integer, BuildResult> result = store.getBuildResultsInSuccess();
+ Map<Integer, BuildResult> result = buildResultDao.getBuildResultsInSuccess();
if ( result == null )
{
@@ -481,13 +487,13 @@
public BuildResult getLatestBuildResultForProject( int projectId )
{
- return store.getLatestBuildResultForProject( projectId );
+ return buildResultDao.getLatestBuildResultForProject( projectId );
}
public BuildResult getBuildResultByBuildNumber( int projectId, int buildNumber )
throws ContinuumException
{
- List<BuildResult> builds = store.getBuildResultByBuildNumber( projectId, buildNumber );
+ List<BuildResult> builds = buildResultDao.getBuildResultByBuildNumber( projectId, buildNumber );
if ( builds.isEmpty() )
{
@@ -797,7 +803,7 @@
BuildResult br = (BuildResult) o;
//Remove all modified dependencies to prevent SQL errors
br.setModifiedDependencies( null );
- store.updateBuildResult( br );
+ buildResultDao.updateBuildResult( br );
removeBuildResult( br );
}
@@ -910,7 +916,7 @@
try
{
- buildDefId = new Integer( store.getDefaultBuildDefinition( project.getId() ).getId() );
+ buildDefId = new Integer( buildDefinitionDao.getDefaultBuildDefinition( project.getId() ).getId() );
}
catch ( ContinuumStoreException e )
{
@@ -1077,7 +1083,7 @@
try
{
- projectsMap = store.getAggregatedProjectIdsAndBuildDefinitionIdsBySchedule( schedule.getId() );
+ projectsMap = daoUtils.getAggregatedProjectIdsAndBuildDefinitionIdsBySchedule( schedule.getId() );
if ( projectsMap == null || projectsMap.size() == 0 )
{
@@ -1260,7 +1266,7 @@
{
try
{
- return store.getBuildResult( buildId );
+ return buildResultDao.getBuildResult( buildId );
}
catch ( ContinuumStoreException e )
{
@@ -1279,7 +1285,7 @@
private void removeBuildResult( BuildResult buildResult )
throws ContinuumException
{
- store.removeBuildResult( buildResult );
+ buildResultDao.removeBuildResult( buildResult );
// cleanup some files
try
@@ -1326,7 +1332,7 @@
throws ContinuumException
{
ArrayList<BuildResult> buildResults =
- new ArrayList<BuildResult>( store.getBuildResultsForProject( projectId, 0 ) );
+ new ArrayList<BuildResult>( buildResultDao.getBuildResultsForProject( projectId, 0 ) );
Collections.reverse( buildResults );
@@ -2240,7 +2246,7 @@
{
try
{
- return store.getDefaultBuildDefinition( projectId );
+ return buildDefinitionDao.getDefaultBuildDefinition( projectId );
}
catch ( ContinuumObjectNotFoundException cne )
{
@@ -2879,9 +2885,9 @@
private void closeStore()
{
- if ( store != null )
+ if ( daoUtils != null )
{
- store.closeStore();
+ daoUtils.closeStore();
}
}
@@ -2928,13 +2934,13 @@
public long getNbBuildResultsForProject( int projectId )
{
- return store.getNbBuildResultsForProject( projectId );
+ return buildResultDao.getNbBuildResultsForProject( projectId );
}
public Collection<BuildResult> getBuildResultsForProject( int projectId )
throws ContinuumException
{
- return store.getBuildResultsForProject( projectId );
+ return buildResultDao.getBuildResultsForProject( projectId );
}
// ----------------------------------------------------------------------
Modified: continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java?rev=682986&r1=682985&r2=682986&view=diff
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java (original)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java Tue Aug 5 15:01:30 2008
@@ -20,6 +20,7 @@
*/
import org.apache.continuum.dao.BuildDefinitionDao;
+import org.apache.continuum.dao.BuildResultDao;
import org.apache.continuum.dao.ProjectDao;
import org.apache.maven.continuum.core.action.AbstractContinuumAction;
import org.apache.maven.continuum.execution.ContinuumBuildExecutor;
@@ -34,7 +35,6 @@
import org.apache.maven.continuum.notification.ContinuumNotificationDispatcher;
import org.apache.maven.continuum.project.ContinuumProjectState;
import org.apache.maven.continuum.store.ContinuumObjectNotFoundException;
-import org.apache.maven.continuum.store.ContinuumStore;
import org.apache.maven.continuum.store.ContinuumStoreException;
import org.apache.maven.continuum.utils.ContinuumUtils;
import org.apache.maven.continuum.utils.WorkingDirectoryService;
@@ -68,12 +68,12 @@
/**
* @plexus.requirement
*/
- private ProjectDao projectDao;
+ private BuildResultDao buildResultDao;
/**
- * @plexus.requirement role-hint="jdo"
+ * @plexus.requirement
*/
- private ContinuumStore store;
+ private ProjectDao projectDao;
/**
* @plexus.requirement
@@ -174,7 +174,7 @@
{
try
{
- context.setBuildResult( store.getBuildResult( Integer.valueOf( s ) ) );
+ context.setBuildResult( buildResultDao.getBuildResult( Integer.valueOf( s ) ) );
}
catch ( NumberFormatException e )
{
@@ -220,7 +220,7 @@
if ( s != null )
{
- BuildResult buildResult = store.getBuildResult( Integer.valueOf( s ) );
+ BuildResult buildResult = buildResultDao.getBuildResult( Integer.valueOf( s ) );
project.setState( buildResult.getState() );
}
else
@@ -259,9 +259,9 @@
try
{
- store.updateBuildResult( build );
+ buildResultDao.updateBuildResult( build );
- build = store.getBuildResult( build.getId() );
+ build = buildResultDao.getBuildResult( build.getId() );
context.setBuildResult( build );
}
@@ -345,7 +345,8 @@
context.setBuildDefinition( buildDefinition );
- BuildResult oldBuildResult = store.getLatestBuildResultForBuildDefinition( projectId, buildDefinitionId );
+ BuildResult oldBuildResult =
+ buildResultDao.getLatestBuildResultForBuildDefinition( projectId, buildDefinitionId );
context.setOldBuildResult( oldBuildResult );
@@ -650,8 +651,8 @@
if ( dependencyProject != null )
{
- List buildResults = store.getBuildResultsInSuccessForProject( dependencyProject.getId(),
- context.getOldBuildResult().getEndTime() );
+ List buildResults = buildResultDao.getBuildResultsInSuccessForProject( dependencyProject.getId(),
+ context.getOldBuildResult().getEndTime() );
if ( buildResults != null && !buildResults.isEmpty() )
{
getLogger().debug( "Dependency changed: " + dep.getGroupId() + ":" + dep.getArtifactId() + ":" +
@@ -755,9 +756,9 @@
try
{
- store.addBuildResult( context.getProject(), build );
+ buildResultDao.addBuildResult( context.getProject(), build );
- build = store.getBuildResult( build.getId() );
+ build = buildResultDao.getBuildResult( build.getId() );
context.setBuildResult( build );
@@ -771,7 +772,7 @@
private ScmResult getOldScmResult( int projectId, long fromDate )
{
- List<BuildResult> results = store.getBuildResultsForProject( projectId, fromDate );
+ List<BuildResult> results = buildResultDao.getBuildResultsForProject( projectId, fromDate );
ScmResult res = new ScmResult();
Modified: continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractBuildDefinitionContinuumAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractBuildDefinitionContinuumAction.java?rev=682986&r1=682985&r2=682986&view=diff
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractBuildDefinitionContinuumAction.java (original)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractBuildDefinitionContinuumAction.java Tue Aug 5 15:01:30 2008
@@ -28,7 +28,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 java.util.List;
Modified: continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java?rev=682986&r1=682985&r2=682986&view=diff
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java (original)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java Tue Aug 5 15:01:30 2008
@@ -19,6 +19,7 @@
* under the License.
*/
+import org.apache.continuum.dao.BuildResultDao;
import org.apache.continuum.dao.ProjectDao;
import org.apache.maven.continuum.configuration.ConfigurationService;
import org.apache.maven.continuum.execution.ContinuumBuildExecutionResult;
@@ -30,7 +31,6 @@
import org.apache.maven.continuum.model.scm.ScmResult;
import org.apache.maven.continuum.notification.ContinuumNotificationDispatcher;
import org.apache.maven.continuum.project.ContinuumProjectState;
-import org.apache.maven.continuum.store.ContinuumStore;
import org.apache.maven.continuum.utils.ContinuumUtils;
import java.io.File;
@@ -58,9 +58,9 @@
private BuildExecutorManager buildExecutorManager;
/**
- * @plexus.requirement role-hint="jdo"
+ * @plexus.requirement
*/
- private ContinuumStore store;
+ private BuildResultDao buildResultDao;
/**
* @plexus.requirement
@@ -109,11 +109,11 @@
buildResult.setBuildDefinition( getBuildDefinition( context ) );
- store.addBuildResult( project, buildResult );
+ buildResultDao.addBuildResult( project, buildResult );
context.put( KEY_BUILD_ID, Integer.toString( buildResult.getId() ) );
- buildResult = store.getBuildResult( buildResult.getId() );
+ buildResult = buildResultDao.getBuildResult( buildResult.getId() );
try
{
@@ -163,9 +163,9 @@
// Copy over the buildResult result
// ----------------------------------------------------------------------
- store.updateBuildResult( buildResult );
+ buildResultDao.updateBuildResult( buildResult );
- buildResult = store.getBuildResult( buildResult.getId() );
+ buildResult = buildResultDao.getBuildResult( buildResult.getId() );
context.put( KEY_PROJECT, project );
Modified: continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java?rev=682986&r1=682985&r2=682986&view=diff
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java (original)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java Tue Aug 5 15:01:30 2008
@@ -19,6 +19,7 @@
* under the License.
*/
+import org.apache.continuum.dao.BuildResultDao;
import org.apache.continuum.dao.ProjectDao;
import org.apache.continuum.scm.ContinuumScm;
import org.apache.continuum.scm.ContinuumScmConfiguration;
@@ -31,7 +32,6 @@
import org.apache.maven.continuum.notification.ContinuumNotificationDispatcher;
import org.apache.maven.continuum.project.ContinuumProjectState;
import org.apache.maven.continuum.store.ContinuumObjectNotFoundException;
-import org.apache.maven.continuum.store.ContinuumStore;
import org.apache.maven.continuum.store.ContinuumStoreException;
import org.apache.maven.continuum.utils.WorkingDirectoryService;
import org.apache.maven.scm.ScmException;
@@ -69,9 +69,9 @@
private WorkingDirectoryService workingDirectoryService;
/**
- * @plexus.requirement role-hint="jdo"
+ * @plexus.requirement
*/
- private ContinuumStore store;
+ private BuildResultDao buildResultDao;
/**
* @plexus.requirement
@@ -97,7 +97,7 @@
Date latestUpdateDate = null;
try
{
- BuildResult result = store.getLatestBuildResultForProject( project.getId() );
+ BuildResult result = buildResultDao.getLatestBuildResultForProject( project.getId() );
latestUpdateDate = new Date( result.getStartTime() );
}
Modified: continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/scm/DefaultContinuumScm.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/scm/DefaultContinuumScm.java?rev=682986&r1=682985&r2=682986&view=diff
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/scm/DefaultContinuumScm.java (original)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-core/src/main/java/org/apache/maven/continuum/scm/DefaultContinuumScm.java Tue Aug 5 15:01:30 2008
@@ -19,13 +19,13 @@
* under the License.
*/
+import org.apache.continuum.dao.BuildResultDao;
import org.apache.maven.continuum.core.action.AbstractContinuumAction;
import org.apache.maven.continuum.model.project.BuildResult;
import org.apache.maven.continuum.model.project.Project;
import org.apache.maven.continuum.model.scm.ChangeFile;
import org.apache.maven.continuum.model.scm.ChangeSet;
import org.apache.maven.continuum.model.scm.ScmResult;
-import org.apache.maven.continuum.store.ContinuumStore;
import org.apache.maven.continuum.utils.WorkingDirectoryService;
import org.apache.maven.scm.ScmException;
import org.apache.maven.scm.ScmFile;
@@ -68,9 +68,9 @@
private WorkingDirectoryService workingDirectoryService;
/**
- * @plexus.requirement role-hint="jdo"
+ * @plexus.requirement
*/
- private ContinuumStore store;
+ private BuildResultDao buildResultDao;
/**
* @plexus.configuration
@@ -319,7 +319,7 @@
{
try
{
- BuildResult result = store.getLatestBuildResultForProject( project.getId() );
+ BuildResult result = buildResultDao.getLatestBuildResultForProject( project.getId() );
return new Date( result.getStartTime() );
}
Modified: continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/buildcontroller/DefaultBuildControllerTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/buildcontroller/DefaultBuildControllerTest.java?rev=682986&r1=682985&r2=682986&view=diff
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/buildcontroller/DefaultBuildControllerTest.java (original)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/buildcontroller/DefaultBuildControllerTest.java Tue Aug 5 15:01:30 2008
@@ -19,6 +19,8 @@
* under the License.
*/
+import org.apache.continuum.dao.BuildDefinitionDao;
+import org.apache.continuum.dao.BuildResultDao;
import org.apache.maven.continuum.AbstractContinuumTest;
import org.apache.maven.continuum.execution.ContinuumBuildExecutorConstants;
import org.apache.maven.continuum.model.project.BuildDefinition;
@@ -48,12 +50,16 @@
{
super.setUp();
+ BuildDefinitionDao buildDefinitionDao = (BuildDefinitionDao) lookup( BuildDefinitionDao.class.getName() );
+
+ BuildResultDao buildResultDao = (BuildResultDao) lookup( BuildResultDao.class.getName() );
+
Project project1 = createProject( "project1" );
BuildDefinition bd1 = createBuildDefinition();
project1.addBuildDefinition( bd1 );
project1.setState( ContinuumProjectState.OK );
- projectId1 = addProject( getStore(), project1 ).getId();
- buildDefinitionId1 = getStore().getDefaultBuildDefinition( projectId1 ).getId();
+ projectId1 = addProject( project1 ).getId();
+ buildDefinitionId1 = buildDefinitionDao.getDefaultBuildDefinition( projectId1 ).getId();
project1 = getProjectDao().getProject( projectId1 );
BuildResult buildResult1 = new BuildResult();
buildResult1.setStartTime( Calendar.getInstance().getTimeInMillis() );
@@ -61,14 +67,14 @@
buildResult1.setState( ContinuumProjectState.OK );
buildResult1.setSuccess( true );
buildResult1.setBuildDefinition( bd1 );
- getStore().addBuildResult( project1, buildResult1 );
+ buildResultDao.addBuildResult( project1, buildResult1 );
BuildResult buildResult2 = new BuildResult();
buildResult2.setStartTime( Calendar.getInstance().getTimeInMillis() - 7200000 );
buildResult2.setEndTime( Calendar.getInstance().getTimeInMillis() - 7200000 );
buildResult2.setSuccess( true );
buildResult2.setState( ContinuumProjectState.OK );
buildResult2.setBuildDefinition( bd1 );
- getStore().addBuildResult( project1, buildResult2 );
+ buildResultDao.addBuildResult( project1, buildResult2 );
Project project2 = createProject( "project2" );
ProjectDependency dep1 = new ProjectDependency();
@@ -84,8 +90,8 @@
BuildDefinition bd2 = createBuildDefinition();
project2.addBuildDefinition( bd2 );
project2.setState( ContinuumProjectState.OK );
- projectId2 = addProject( getStore(), project2 ).getId();
- buildDefinitionId2 = getStore().getDefaultBuildDefinition( projectId2 ).getId();
+ projectId2 = addProject( project2 ).getId();
+ buildDefinitionId2 = buildDefinitionDao.getDefaultBuildDefinition( projectId2 ).getId();
controller = (DefaultBuildController) lookup( BuildController.ROLE );
}
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=682986&r1=682985&r2=682986&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 Tue Aug 5 15:01:30 2008
@@ -24,6 +24,7 @@
import org.apache.maven.continuum.model.project.BuildDefinitionTemplate;
import org.apache.maven.continuum.model.project.Project;
import org.apache.maven.continuum.model.project.ProjectGroup;
+import org.apache.continuum.dao.DaoUtils;
import java.util.List;
@@ -49,7 +50,8 @@
throws Exception
{
super.setUp();
- getStore().eraseDatabase();
+ DaoUtils daoUtils = (DaoUtils) lookup( DaoUtils.class.getName() );
+ daoUtils.eraseDatabase();
projectGroup = new ProjectGroup();
projectGroup.setName( "test" );
Modified: continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/buildqueue/BuildQueueTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/buildqueue/BuildQueueTest.java?rev=682986&r1=682985&r2=682986&view=diff
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/buildqueue/BuildQueueTest.java (original)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/buildqueue/BuildQueueTest.java Tue Aug 5 15:01:30 2008
@@ -45,7 +45,7 @@
public void testTestTheQueueWithASingleProject()
throws Exception
{
- Project project = addProject( getStore(), "Build Queue Project 1" );
+ Project project = addProject( "Build Queue Project 1" );
int projectId = project.getId();
@@ -70,9 +70,9 @@
public void testTheQueueWithMultipleProjects()
throws Exception
{
- int projectId1 = addProject( getStore(), "Build Queue Project 2" ).getId();
+ int projectId1 = addProject( "Build Queue Project 2" ).getId();
- int projectId2 = addProject( getStore(), "Build Queue Project 3" ).getId();
+ int projectId2 = addProject( "Build Queue Project 3" ).getId();
buildProject( projectId1, ContinuumProjectState.TRIGGER_SCHEDULED );
@@ -101,7 +101,7 @@
{
String name = "Build Queue Project 4";
- int projectId = addProject( getStore(), name ).getId();
+ int projectId = addProject( name ).getId();
buildProject( projectId, ContinuumProjectState.TRIGGER_FORCED );
Modified: continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/initialization/DefaultContinuumInitializerTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/initialization/DefaultContinuumInitializerTest.java?rev=682986&r1=682985&r2=682986&view=diff
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/initialization/DefaultContinuumInitializerTest.java (original)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/initialization/DefaultContinuumInitializerTest.java Tue Aug 5 15:01:30 2008
@@ -19,10 +19,10 @@
* under the License.
*/
+import org.apache.continuum.dao.DaoUtils;
import org.apache.maven.continuum.AbstractContinuumTest;
import org.apache.maven.continuum.configuration.ConfigurationService;
import org.apache.maven.continuum.model.project.Schedule;
-import org.apache.maven.continuum.store.ContinuumStore;
/**
* @author <a href="mailto:olamy@codehaus.org">olamy</a>
@@ -32,23 +32,17 @@
public class DefaultContinuumInitializerTest
extends AbstractContinuumTest
{
-
protected void setUp()
throws Exception
{
super.setUp();
- getContinuumStore().eraseDatabase();
+ DaoUtils daoUtils = (DaoUtils) lookup( DaoUtils.class.getName() );
+ daoUtils.eraseDatabase();
ContinuumInitializer continuumInitializer =
(ContinuumInitializer) lookup( ContinuumInitializer.ROLE, "default" );
continuumInitializer.initialize();
}
- public ContinuumStore getContinuumStore()
- throws Exception
- {
- return (ContinuumStore) lookup( ContinuumStore.ROLE, "jdo" );
- }
-
public void testDefaultSchedule()
throws Exception
{
Modified: continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/installation/DefaultInstallationServiceTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/installation/DefaultInstallationServiceTest.java?rev=682986&r1=682985&r2=682986&view=diff
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/installation/DefaultInstallationServiceTest.java (original)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/installation/DefaultInstallationServiceTest.java Tue Aug 5 15:01:30 2008
@@ -19,8 +19,7 @@
* under the License.
*/
-import java.util.List;
-
+import org.apache.continuum.dao.DaoUtils;
import org.apache.maven.continuum.AbstractContinuumTest;
import org.apache.maven.continuum.execution.ExecutorConfigurator;
import org.apache.maven.continuum.model.system.Installation;
@@ -28,6 +27,8 @@
import org.apache.maven.continuum.profile.ProfileService;
import org.codehaus.plexus.util.StringUtils;
+import java.util.List;
+
/**
* @author <a href="mailto:olamy@codehaus.org">olamy</a>
* @version $Id$
@@ -46,7 +47,8 @@
throws Exception
{
super.setUp();
- getStore().eraseDatabase();
+ DaoUtils daoUtils = (DaoUtils) lookup( DaoUtils.class.getName() );
+ daoUtils.eraseDatabase();
/*if ( getInstallationService().getAllInstallations().isEmpty() )
{
defaultInstallation = createDefault();
@@ -95,7 +97,7 @@
assertEquals( "bar", getted.getVarValue() );
assertEquals( 1, getInstallationService().getAllInstallations().size() );
}
-
+
public void testAddDuplicateInstallation()
throws Exception
{
@@ -114,7 +116,7 @@
// we must be here
}
assertEquals( 1, getInstallationService().getAllInstallations().size() );
- }
+ }
public void testRemove()
throws Exception
@@ -214,9 +216,9 @@
assertEquals( "automaticJdk", profile.getName() );
Installation jdk = profile.getJdk();
assertNotNull( jdk );
- assertEquals("automaticJdk", jdk.getName());
+ assertEquals( "automaticJdk", jdk.getName() );
}
-
+
public void testUpdateName()
throws Exception
{
@@ -226,13 +228,13 @@
installation.setVarName( "automaticvarName" );
installation.setVarValue( "automaticvarValue" );
installation = getInstallationService().add( installation, true );
-
+
installation.setName( "new name here" );
getInstallationService().update( installation );
-
+
Installation getted = getInstallationService().getInstallation( installation.getInstallationId() );
assertEquals( "new name here", getted.getName() );
-
+
}
}
Modified: continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcherTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcherTest.java?rev=682986&r1=682985&r2=682986&view=diff
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcherTest.java (original)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcherTest.java Tue Aug 5 15:01:30 2008
@@ -19,6 +19,7 @@
* under the License.
*/
+import org.apache.continuum.dao.BuildResultDao;
import org.apache.maven.continuum.AbstractContinuumTest;
import org.apache.maven.continuum.model.project.BuildResult;
import org.apache.maven.continuum.model.project.Project;
@@ -31,13 +32,23 @@
public class ContinuumNotificationDispatcherTest
extends AbstractContinuumTest
{
+ private BuildResultDao buildResultDao;
+
+ @Override
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+ buildResultDao = (BuildResultDao) lookup( BuildResultDao.class.getName() );
+ }
+
public void testNotificationDispatcher()
throws Exception
{
ContinuumNotificationDispatcher notificationDispatcher =
(ContinuumNotificationDispatcher) lookup( ContinuumNotificationDispatcher.ROLE );
- Project project = addProject( getStore(), "Notification Dispatcher Test Project" );
+ Project project = addProject( "Notification Dispatcher Test Project" );
project = getProjectDao().getProjectWithBuildDetails( project.getId() );
@@ -49,9 +60,9 @@
build.setTrigger( ContinuumProjectState.TRIGGER_SCHEDULED );
- getStore().addBuildResult( project, build );
+ buildResultDao.addBuildResult( project, build );
- build = getStore().getBuildResult( build.getId() );
+ build = buildResultDao.getBuildResult( build.getId() );
notificationDispatcher.buildComplete( project, null, build );
}
Modified: continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/profile/DefaultProfileServiceTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/profile/DefaultProfileServiceTest.java?rev=682986&r1=682985&r2=682986&view=diff
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/profile/DefaultProfileServiceTest.java (original)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/java/org/apache/maven/continuum/profile/DefaultProfileServiceTest.java Tue Aug 5 15:01:30 2008
@@ -1,11 +1,10 @@
package org.apache.maven.continuum.profile;
+import org.apache.continuum.dao.DaoUtils;
import org.apache.maven.continuum.AbstractContinuumTest;
import org.apache.maven.continuum.installation.InstallationService;
import org.apache.maven.continuum.model.system.Installation;
import org.apache.maven.continuum.model.system.Profile;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import java.util.List;
@@ -36,7 +35,7 @@
public class DefaultProfileServiceTest
extends AbstractContinuumTest
{
-
+
Installation jdk1;
String jdk1Name = "jdk1";
@@ -73,7 +72,8 @@
throws Exception
{
super.setUp();
- getStore().eraseDatabase();
+ DaoUtils daoUtils = (DaoUtils) lookup( DaoUtils.class.getName() );
+ daoUtils.eraseDatabase();
jdk1 = new Installation();
jdk1.setType( InstallationService.JDK_TYPE );
@@ -174,8 +174,8 @@
// we must be here
}
assertEquals( 3, getProfileService().getAllProfiles().size() );
- }
-
+ }
+
public void testDeleteProfile()
throws Exception
{
@@ -210,7 +210,7 @@
assertNotNull( getted );
assertEquals( newName, getted.getName() );
}
-
+
public void testupdateProfileDuplicateName()
throws Exception
{
@@ -230,7 +230,7 @@
Profile getted = getProfileService().getProfile( jdk1mvn205.getId() );
assertNotNull( getted );
assertEquals( jdk1mvn205Name, getted.getName() );
- }
+ }
public void testsetJdkInProfile()
throws Exception
@@ -275,7 +275,7 @@
InstallationService installationService = (InstallationService) lookup( InstallationService.ROLE, "default" );
installationService.delete( jdk2 );
}
-
+
public void testRemoveEnvVarFromProfile()
throws Exception
{
@@ -287,24 +287,24 @@
profile = getProfileService().getProfile( jdk1mvn205.getId() );
assertNotNull( profile.getJdk() );
assertEquals( 2, profile.getEnvironmentVariables().size() );
-
+
getProfileService().removeInstallationFromProfile( profile, mvnOpts1 );
-
+
profile = getProfileService().getProfile( jdk1mvn205.getId() );
assertNotNull( profile.getJdk() );
assertEquals( 1, profile.getEnvironmentVariables().size() );
-
+
getProfileService().removeInstallationFromProfile( profile, jdk2 );
-
+
profile = getProfileService().getProfile( jdk1mvn205.getId() );
assertNull( profile.getJdk() );
assertEquals( 1, profile.getEnvironmentVariables().size() );
-
+
getProfileService().removeInstallationFromProfile( profile, mvnOpts2 );
profile = getProfileService().getProfile( jdk1mvn205.getId() );
assertNull( profile.getJdk() );
assertEquals( 0, profile.getEnvironmentVariables().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=682986&r1=682985&r2=682986&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 Tue Aug 5 15:01:30 2008
@@ -19,12 +19,6 @@
* under the License.
*/
-import java.io.File;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
import org.apache.log4j.Logger;
import org.apache.maven.continuum.AbstractContinuumTest;
import org.apache.maven.continuum.builddefinition.BuildDefinitionService;
@@ -37,9 +31,14 @@
import org.apache.maven.continuum.model.project.ProjectNotifier;
import org.apache.maven.continuum.project.builder.ContinuumProjectBuilder;
import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
-import org.apache.maven.continuum.store.ContinuumStore;
import org.codehaus.plexus.util.StringUtils;
+import java.io.File;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
/**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
* @version $Id$
@@ -47,7 +46,7 @@
public class MavenTwoContinuumProjectBuilderTest
extends AbstractContinuumTest
{
-
+
private Logger logger = Logger.getLogger( getClass() );
/*
@@ -186,10 +185,8 @@
URL url = getClass().getClassLoader().getResource( "projects/continuum/pom.xml" );
-
ContinuumProjectBuildingResult result = projectBuilder.buildProjectsFromMetadata( url, null, null );
-
assertNotNull( result );
// ----------------------------------------------------------------------
@@ -343,8 +340,7 @@
public void testCreateProjectWithoutModules()
throws Exception
{
-
-
+
ContinuumProjectBuilder projectBuilder =
(ContinuumProjectBuilder) lookup( ContinuumProjectBuilder.ROLE, MavenTwoContinuumProjectBuilder.ID );
@@ -361,9 +357,9 @@
bd.setBuildFile( "pom.xml" );
bd.setType( ContinuumBuildExecutorConstants.MAVEN_TWO_BUILD_EXECUTOR );
-
+
BuildDefinitionService service = (BuildDefinitionService) lookup( BuildDefinitionService.class );
-
+
bd = service.addBuildDefinition( bd );
BuildDefinitionTemplate bdt = new BuildDefinitionTemplate();
bdt.setName( "maven2" );
@@ -372,18 +368,18 @@
assertEquals( 5, service.getAllBuildDefinitionTemplate().size() );
logger.debug( "templates number " + service.getAllBuildDefinitionTemplate().size() );
- logger.debug( "projectGroups number " + getProjectGroupDao().getAllProjectGroups().size() );
-
+ logger.debug( "projectGroups number " + getProjectGroupDao().getAllProjectGroups().size() );
+
int all = service.getAllBuildDefinitions().size();
-
+
ContinuumProjectBuildingResult result;
-
+
result = projectBuilder.buildProjectsFromMetadata( url, null, null, false, bdt );
assertEquals( 5, service.getAllBuildDefinitionTemplate().size() );
assertEquals( all + 1, service.getAllBuildDefinitions().size() );
-
+
assertNotNull( result );
assertNotNull( result.getErrors() );
@@ -434,7 +430,7 @@
assertFalse( true );
}
-
+
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
Modified: continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/resources/org/apache/maven/continuum/notification/ContinuumNotificationDispatcherTest.xml
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/resources/org/apache/maven/continuum/notification/ContinuumNotificationDispatcherTest.xml?rev=682986&r1=682985&r2=682986&view=diff
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/resources/org/apache/maven/continuum/notification/ContinuumNotificationDispatcherTest.xml (original)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/resources/org/apache/maven/continuum/notification/ContinuumNotificationDispatcherTest.xml Tue Aug 5 15:01:30 2008
@@ -33,11 +33,10 @@
<role>org.codehaus.plexus.velocity.VelocityComponent</role>
</requirement>
<requirement>
- <role>org.apache.maven.continuum.store.ContinuumStore</role>
- <role-hint>jdo</role-hint>
+ <role>org.apache.continuum.dao.ProjectDao</role>
</requirement>
<requirement>
- <role>org.apache.continuum.dao.ProjectDao</role>
+ <role>org.apache.continuum.dao.BuildResultDao</role>
</requirement>
<requirement>
<role>org.codehaus.plexus.mailsender.MailSender</role>
Modified: continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/resources/org/apache/maven/continuum/notification/mail/MailContinuumNotifierTest.xml
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/resources/org/apache/maven/continuum/notification/mail/MailContinuumNotifierTest.xml?rev=682986&r1=682985&r2=682986&view=diff
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/resources/org/apache/maven/continuum/notification/mail/MailContinuumNotifierTest.xml (original)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-core/src/test/resources/org/apache/maven/continuum/notification/mail/MailContinuumNotifierTest.xml Tue Aug 5 15:01:30 2008
@@ -34,11 +34,10 @@
<role>org.codehaus.plexus.velocity.VelocityComponent</role>
</requirement>
<requirement>
- <role>org.apache.maven.continuum.store.ContinuumStore</role>
- <role-hint>jdo</role-hint>
+ <role>org.apache.continuum.dao.ProjectDao</role>
</requirement>
<requirement>
- <role>org.apache.continuum.dao.ProjectDao</role>
+ <role>org.apache.continuum.dao.BuildResultDao</role>
</requirement>
<requirement>
<role>org.codehaus.plexus.mailsender.MailSender</role>
Modified: continuum/branches/continuum-refactoring-evenisse/continuum-data-management/data-management-jdo/src/main/java/org/apache/maven/continuum/management/JdoDataManagementTool.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-data-management/data-management-jdo/src/main/java/org/apache/maven/continuum/management/JdoDataManagementTool.java?rev=682986&r1=682985&r2=682986&view=diff
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-data-management/data-management-jdo/src/main/java/org/apache/maven/continuum/management/JdoDataManagementTool.java (original)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-data-management/data-management-jdo/src/main/java/org/apache/maven/continuum/management/JdoDataManagementTool.java Tue Aug 5 15:01:30 2008
@@ -19,6 +19,7 @@
* under the License.
*/
+import org.apache.continuum.dao.DaoUtils;
import org.apache.continuum.dao.InstallationDao;
import org.apache.continuum.dao.ProfileDao;
import org.apache.continuum.dao.ProjectGroupDao;
@@ -33,7 +34,6 @@
import org.apache.maven.continuum.model.project.io.stax.ContinuumStaxWriter;
import org.apache.maven.continuum.model.system.Installation;
import org.apache.maven.continuum.model.system.Profile;
-import org.apache.maven.continuum.store.ContinuumStore;
import org.apache.maven.continuum.store.ContinuumStoreException;
import org.codehaus.plexus.jdo.ConfigurableJdoFactory;
import org.codehaus.plexus.jdo.PlexusJdoUtils;
@@ -67,9 +67,9 @@
implements DataManagementTool
{
/**
- * @plexus.requirement role-hint="jdo"
+ * @plexus.requirement
*/
- private ContinuumStore store;
+ private DaoUtils daoUtils;
/**
* @plexus.requirement
@@ -155,7 +155,7 @@
public void eraseDatabase()
{
- store.eraseDatabase();
+ daoUtils.eraseDatabase();
}
public void restoreDatabase( File backupDirectory )
Modified: continuum/branches/continuum-refactoring-evenisse/continuum-notifiers/continuum-notifier-api/src/main/java/org/apache/maven/continuum/notification/AbstractContinuumNotifier.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-notifiers/continuum-notifier-api/src/main/java/org/apache/maven/continuum/notification/AbstractContinuumNotifier.java?rev=682986&r1=682985&r2=682986&view=diff
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-notifiers/continuum-notifier-api/src/main/java/org/apache/maven/continuum/notification/AbstractContinuumNotifier.java (original)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-notifiers/continuum-notifier-api/src/main/java/org/apache/maven/continuum/notification/AbstractContinuumNotifier.java Tue Aug 5 15:01:30 2008
@@ -20,6 +20,7 @@
*/
import org.apache.continuum.configuration.ContinuumConfigurationException;
+import org.apache.continuum.dao.BuildResultDao;
import org.apache.continuum.dao.ProjectDao;
import org.apache.maven.continuum.ContinuumException;
import org.apache.maven.continuum.configuration.ConfigurationException;
@@ -30,7 +31,6 @@
import org.apache.maven.continuum.model.project.Project;
import org.apache.maven.continuum.model.project.ProjectNotifier;
import org.apache.maven.continuum.project.ContinuumProjectState;
-import org.apache.maven.continuum.store.ContinuumStore;
import org.apache.maven.continuum.store.ContinuumStoreException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -54,12 +54,12 @@
/**
* @plexus.requirement
*/
- private ProjectDao projectDao;
+ private BuildResultDao buildResultDao;
/**
- * @plexus.requirement role-hint="jdo"
+ * @plexus.requirement
*/
- private ContinuumStore store;
+ private ProjectDao projectDao;
/**
* @plexus.configuration
@@ -241,8 +241,7 @@
{
if ( buildDef != null )
{
- builds =
- getContinuumStore().getBuildResultsByBuildDefinition( project.getId(), buildDef.getId(), 0, 2 );
+ builds = buildResultDao.getBuildResultsByBuildDefinition( project.getId(), buildDef.getId(), 0, 2 );
if ( builds.size() < 2 )
{
@@ -292,9 +291,4 @@
throw new NotificationException( "Unable to obtain project builds", e );
}
}
-
- protected ContinuumStore getContinuumStore()
- {
- return this.store;
- }
}
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=682986&r1=682985&r2=682986&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 Tue Aug 5 15:01:30 2008
@@ -185,4 +185,10 @@
{
return storeUtilities.getContinuumPersistenceManagerFactory();
}
+
+ protected Object makePersistent( PersistenceManager pm, Object object, boolean detach )
+ {
+ return PlexusJdoUtils.makePersistent( pm, object, detach );
+ }
+
}
Modified: continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/BuildDefinitionDaoImpl.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/BuildDefinitionDaoImpl.java?rev=682986&r1=682985&r2=682986&view=diff
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/BuildDefinitionDaoImpl.java (original)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/BuildDefinitionDaoImpl.java Tue Aug 5 15:01:30 2008
@@ -19,11 +19,15 @@
* under the License.
*/
+import org.apache.maven.continuum.execution.ContinuumBuildExecutorConstants;
import org.apache.maven.continuum.model.project.BuildDefinition;
import org.apache.maven.continuum.model.project.Project;
import org.apache.maven.continuum.model.project.ProjectGroup;
import org.apache.maven.continuum.store.ContinuumObjectNotFoundException;
import org.apache.maven.continuum.store.ContinuumStoreException;
+import org.codehaus.plexus.util.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import javax.jdo.Extent;
import javax.jdo.PersistenceManager;
@@ -44,6 +48,18 @@
extends AbstractDao
implements BuildDefinitionDao
{
+ private static Logger log = LoggerFactory.getLogger( BuildDefinitionDaoImpl.class );
+
+ /**
+ * @plexus.requirement role="org.apache.continuum.dao.ProjectDao"
+ */
+ private ProjectDao projectDao;
+
+ /**
+ * @plexus.requirement role="org.apache.continuum.dao.ProjectGroupDao"
+ */
+ private ProjectGroupDao projectGroupDao;
+
public BuildDefinition getBuildDefinition( int buildDefinitionId )
throws ContinuumStoreException
{
@@ -98,7 +114,7 @@
}
}
- public Map getDefaultBuildDefinitions()
+ public Map<Integer, Integer> getDefaultBuildDefinitions()
{
PersistenceManager pm = getPersistenceManager();
@@ -124,7 +140,7 @@
// result = (List) pm.detachCopyAll( result );
- Map builds = new HashMap();
+ Map<Integer, Integer> builds = new HashMap<Integer, Integer>();
if ( result != null && !result.isEmpty() )
{
@@ -250,6 +266,44 @@
return getDefaultBuildDefinitionForProject( project.getId() );
}
+ public BuildDefinition getDefaultBuildDefinition( int projectId )
+ throws ContinuumStoreException
+ {
+ //TODO: Move this method to a service class
+ BuildDefinition bd = null;
+
+ try
+ {
+ bd = getDefaultBuildDefinitionForProject( projectId );
+ }
+ catch ( ContinuumObjectNotFoundException cne )
+ {
+ // ignore since we will try the project group
+ log.debug( "no default build definition on project, trying project group" );
+ }
+
+ // project group should have default build definition defined
+ if ( bd == null )
+ {
+ ProjectGroup projectGroup = projectGroupDao.getProjectGroupByProjectId( projectId );
+
+ Project p = projectDao.getProject( projectId );
+
+ List<BuildDefinition> bds = getDefaultBuildDefinitionsForProjectGroup( projectGroup.getId() );
+
+ for ( BuildDefinition bdef : bds )
+ {
+ if ( p.getExecutorId().equals( bdef.getType() ) || ( StringUtils.isEmpty( bdef.getType() ) &&
+ ContinuumBuildExecutorConstants.MAVEN_TWO_BUILD_EXECUTOR.equals( p.getExecutorId() ) ) )
+ {
+ return bdef;
+ }
+ }
+ }
+
+ return bd;
+ }
+
public List<BuildDefinition> getAllTemplates()
throws ContinuumStoreException
{
Added: continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/BuildResultDaoImpl.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/BuildResultDaoImpl.java?rev=682986&view=auto
==============================================================================
--- continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/BuildResultDaoImpl.java (added)
+++ continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/BuildResultDaoImpl.java Tue Aug 5 15:01:30 2008
@@ -0,0 +1,565 @@
+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.BuildResult;
+import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.project.ContinuumProjectState;
+import org.apache.maven.continuum.store.ContinuumStoreException;
+
+import javax.jdo.Extent;
+import javax.jdo.JDOHelper;
+import javax.jdo.PersistenceManager;
+import javax.jdo.Query;
+import javax.jdo.Transaction;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
+ * @version $Id$
+ * @plexus.component role="org.apache.continuum.dao.BuildResultDao"
+ */
+public class BuildResultDaoImpl
+ extends AbstractDao
+ implements BuildResultDao
+{
+ public void updateBuildResult( BuildResult build )
+ throws ContinuumStoreException
+ {
+ PersistenceManager pm = getPersistenceManager();
+
+ Transaction tx = pm.currentTransaction();
+
+ Project project = build.getProject();
+ try
+ {
+ tx.begin();
+
+ if ( !JDOHelper.isDetached( build ) )
+ {
+ throw new ContinuumStoreException( "Not detached: " + build );
+ }
+
+ pm.makePersistent( build );
+
+ if ( !JDOHelper.isDetached( project ) )
+ {
+ throw new ContinuumStoreException( "Not detached: " + project );
+ }
+
+ project.setState( build.getState() );
+
+ pm.makePersistent( project );
+
+ tx.commit();
+ }
+ finally
+ {
+ rollback( tx );
+ }
+ }
+
+ public void addBuildResult( Project project, BuildResult build )
+ throws ContinuumStoreException
+ {
+ PersistenceManager pm = getPersistenceManager();
+
+ Transaction tx = pm.currentTransaction();
+
+ try
+ {
+ tx.begin();
+
+ pm.getFetchPlan().addGroup( PROJECT_WITH_BUILDS_FETCH_GROUP );
+
+ Object objectId = pm.newObjectIdInstance( Project.class, project.getId() );
+
+ project = (Project) pm.getObjectById( objectId );
+
+ build = (BuildResult) makePersistent( pm, build, false );
+
+ // TODO: these are in the wrong spot - set them on success (though
+ // currently some depend on latest build being the one in progress)
+ project.setLatestBuildId( build.getId() );
+
+ project.setState( build.getState() );
+
+ project.addBuildResult( build );
+
+ tx.commit();
+ }
+ finally
+ {
+ rollback( tx );
+ }
+ }
+
+ public BuildResult getLatestBuildResultForProject( int projectId )
+ {
+ PersistenceManager pm = getPersistenceManager();
+
+ Transaction tx = pm.currentTransaction();
+
+ try
+ {
+ tx.begin();
+
+ Extent extent = pm.getExtent( BuildResult.class, true );
+
+ Query query = pm.newQuery( extent );
+
+ query.declareParameters( "int projectId" );
+
+ query.setFilter( "this.project.id == projectId && this.project.latestBuildId == this.id" );
+
+ List<BuildResult> result = (List<BuildResult>) query.execute( projectId );
+
+ result = (List<BuildResult>) pm.detachCopyAll( result );
+
+ tx.commit();
+
+ if ( result != null && !result.isEmpty() )
+ {
+ return (BuildResult) result.get( 0 );
+ }
+ }
+ finally
+ {
+ rollback( tx );
+ }
+ return null;
+ }
+
+ public BuildResult getLatestBuildResultForBuildDefinition( int projectId, int buildDefinitionId )
+ {
+ PersistenceManager pm = getPersistenceManager();
+
+ Transaction tx = pm.currentTransaction();
+
+ try
+ {
+ tx.begin();
+
+ Extent extent = pm.getExtent( BuildResult.class, true );
+
+ Query query = pm.newQuery( extent );
+
+ query.declareParameters( "int projectId, int buildDefinitionId" );
+
+ query.setFilter( "this.project.id == projectId && this.buildDefinition.id == buildDefinitionId" );
+ query.setOrdering( "id descending" );
+
+ Object[] params = new Object[2];
+ params[0] = projectId;
+ params[1] = buildDefinitionId;
+
+ List<BuildResult> result = (List<BuildResult>) query.executeWithArray( params );
+
+ result = (List<BuildResult>) pm.detachCopyAll( result );
+
+ tx.commit();
+
+ if ( result != null && !result.isEmpty() )
+ {
+ return (BuildResult) result.get( 0 );
+ }
+ }
+ finally
+ {
+ rollback( tx );
+ }
+ return null;
+ }
+
+ public Map<Integer, BuildResult> getLatestBuildResultsByProjectGroupId( int projectGroupId )
+ {
+ PersistenceManager pm = getPersistenceManager();
+
+ Transaction tx = pm.currentTransaction();
+
+ try
+ {
+ tx.begin();
+
+ Extent extent = pm.getExtent( BuildResult.class, true );
+
+ Query query = pm.newQuery( extent );
+
+ String filter = "this.project.latestBuildId == this.id";
+
+ if ( projectGroupId > 0 )
+ {
+ query.declareParameters( "int projectGroupId" );
+ filter += " && this.project.projectGroup.id == projectGroupId";
+ }
+
+ query.setFilter( filter );
+
+ List<BuildResult> result;
+ if ( projectGroupId > 0 )
+ {
+ result = (List<BuildResult>) query.execute( projectGroupId );
+ }
+ else
+ {
+ result = (List<BuildResult>) query.execute();
+ }
+
+ result = (List<BuildResult>) pm.detachCopyAll( result );
+
+ tx.commit();
+
+ if ( result != null && !result.isEmpty() )
+ {
+ Map<Integer, BuildResult> builds = new HashMap<Integer, BuildResult>();
+
+ for ( BuildResult br : result )
+ {
+ builds.put( br.getProject().getId(), br );
+ }
+
+ return builds;
+ }
+ }
+ finally
+ {
+ rollback( tx );
+ }
+
+ return null;
+ }
+
+ public Map<Integer, BuildResult> getLatestBuildResults()
+ {
+ return getLatestBuildResultsByProjectGroupId( -1 );
+ }
+
+ public void removeBuildResult( BuildResult buildResult )
+ {
+ removeObject( buildResult );
+ }
+
+ public List<BuildResult> getAllBuildsForAProjectByDate( int projectId )
+ {
+ PersistenceManager pm = getPersistenceManager();
+
+ Transaction tx = pm.currentTransaction();
+
+ try
+ {
+ tx.begin();
+
+ Query query = pm.newQuery( "SELECT FROM " + BuildResult.class.getName() +
+ " WHERE project.id == projectId PARAMETERS int projectId ORDER BY endTime DESC" );
+
+ query.declareImports( "import java.lang.Integer" );
+
+ query.declareParameters( "Integer projectId" );
+
+ List result = (List) query.execute( projectId );
+
+ result = (List) pm.detachCopyAll( result );
+
+ tx.commit();
+
+ return result;
+ }
+ finally
+ {
+ rollback( tx );
+ }
+ }
+
+ public BuildResult getBuildResult( int buildId )
+ throws ContinuumStoreException
+ {
+ return (BuildResult) getObjectById( BuildResult.class, buildId, BUILD_RESULT_WITH_DETAILS_FETCH_GROUP );
+ }
+
+ public List<BuildResult> getBuildResultByBuildNumber( int projectId, int buildNumber )
+ {
+ PersistenceManager pm = getPersistenceManager();
+
+ Transaction tx = pm.currentTransaction();
+
+ try
+ {
+ tx.begin();
+
+ Extent extent = pm.getExtent( BuildResult.class, true );
+
+ Query query = pm.newQuery( extent );
+
+ query.declareParameters( "int projectId, int buildNumber" );
+
+ query.setFilter( "this.project.id == projectId && this.buildNumber == buildNumber" );
+
+ List result = (List) query.execute( projectId, buildNumber );
+
+ result = (List) pm.detachCopyAll( result );
+
+ tx.commit();
+
+ return result;
+ }
+ finally
+ {
+ rollback( tx );
+ }
+ }
+
+ public List<BuildResult> getBuildResultsByBuildDefinition( int projectId, int buildDefinitionId )
+ {
+ return getBuildResultsByBuildDefinition( projectId, buildDefinitionId, -1, -1 );
+ }
+
+ public List<BuildResult> getBuildResultsByBuildDefinition( int projectId, int buildDefinitionId, long startIndex,
+ long endIndex )
+ {
+ PersistenceManager pm = getPersistenceManager();
+
+ Transaction tx = pm.currentTransaction();
+
+ try
+ {
+ tx.begin();
+
+ Extent extent = pm.getExtent( BuildResult.class, true );
+
+ Query query = pm.newQuery( extent );
+
+ if ( startIndex >= 0 && endIndex >= 0 )
+ {
+ query.setRange( startIndex, endIndex );
+ }
+
+ query.declareParameters( "int projectId, int buildDefinitionId" );
+
+ query.setFilter( "this.project.id == projectId && this.buildDefinition.id == buildDefinitionId" );
+
+ query.setOrdering( "this.id descending" );
+
+ List<BuildResult> result = (List<BuildResult>) query.execute( projectId, buildDefinitionId );
+
+ result = (List<BuildResult>) pm.detachCopyAll( result );
+
+ tx.commit();
+
+ return result;
+ }
+ finally
+ {
+ rollback( tx );
+ }
+ }
+
+ public long getNbBuildResultsForProject( int projectId )
+ {
+ PersistenceManager pm = getPersistenceManager();
+
+ Transaction tx = pm.currentTransaction();
+
+ try
+ {
+ tx.begin();
+
+ Query query = pm.newQuery( BuildResult.class, "project.id == projectId" );
+
+ query.declareParameters( "int projectId" );
+
+ query.setResult( "count(this)" );
+
+ long result = (Long) query.execute( projectId );
+
+ tx.commit();
+
+ return result;
+ }
+ finally
+ {
+ rollback( tx );
+ }
+ }
+
+ public List<BuildResult> getBuildResultsForProject( int projectId )
+ {
+ return getBuildResultsForProject( projectId, -1, -1 );
+ }
+
+ public List<BuildResult> getBuildResultsForProject( int projectId, long startIndex, long endIndex )
+ {
+ PersistenceManager pm = getPersistenceManager();
+
+ Transaction tx = pm.currentTransaction();
+
+ try
+ {
+ tx.begin();
+
+ Extent extent = pm.getExtent( BuildResult.class, true );
+
+ Query query = pm.newQuery( extent );
+
+ query.declareParameters( "int projectId" );
+
+ query.setFilter( "this.project.id == projectId" );
+
+ query.setOrdering( "this.startTime descending" );
+
+ if ( startIndex >= 0 )
+ {
+ query.setRange( startIndex, endIndex );
+ }
+
+ List result = (List) query.execute( projectId );
+
+ result = (List) pm.detachCopyAll( result );
+
+ tx.commit();
+
+ return result;
+ }
+ finally
+ {
+ rollback( tx );
+ }
+ }
+
+ public List<BuildResult> getBuildResultsForProject( int projectId, long fromDate )
+ {
+ PersistenceManager pm = getPersistenceManager();
+
+ Transaction tx = pm.currentTransaction();
+
+ pm.getFetchPlan().addGroup( BUILD_RESULT_WITH_DETAILS_FETCH_GROUP );
+
+ try
+ {
+ tx.begin();
+
+ Extent extent = pm.getExtent( BuildResult.class, true );
+
+ Query query = pm.newQuery( extent );
+
+ query.declareParameters( "int projectId, long fromDate" );
+
+ query.setFilter( "this.project.id == projectId && this.startTime > fromDate" );
+
+ List result = (List) query.execute( projectId, fromDate );
+
+ result = (List) pm.detachCopyAll( result );
+
+ tx.commit();
+
+ return result;
+ }
+ finally
+ {
+ rollback( tx );
+ }
+ }
+
+ public List<BuildResult> getBuildResultsInSuccessForProject( int projectId, long fromDate )
+ {
+ List<BuildResult> buildResults = getBuildResultsForProject( projectId, fromDate );
+
+ List<BuildResult> results = new ArrayList<BuildResult>();
+
+ if ( buildResults != null )
+ {
+ for ( BuildResult res : buildResults )
+ {
+ if ( res.getState() == ContinuumProjectState.OK )
+ {
+ results.add( res );
+ }
+ }
+ }
+ return results;
+ }
+
+ public Map<Integer, BuildResult> getBuildResultsInSuccessByProjectGroupId( int projectGroupId )
+ {
+ PersistenceManager pm = getPersistenceManager();
+
+ Transaction tx = pm.currentTransaction();
+
+ try
+ {
+ tx.begin();
+
+ Extent extent = pm.getExtent( BuildResult.class, true );
+
+ Query query = pm.newQuery( extent );
+
+ String filter = "this.project.buildNumber == this.buildNumber";
+
+ if ( projectGroupId > 0 )
+ {
+ query.declareParameters( "int projectGroupId" );
+ filter += " && this.project.projectGroup.id == projectGroupId";
+ }
+
+ query.setFilter( filter );
+
+ List<BuildResult> result;
+
+ if ( projectGroupId > 0 )
+ {
+ result = (List<BuildResult>) query.execute( projectGroupId );
+ }
+ else
+ {
+ result = (List<BuildResult>) query.execute();
+ }
+
+ result = (List<BuildResult>) pm.detachCopyAll( result );
+
+ tx.commit();
+
+ if ( result != null && !result.isEmpty() )
+ {
+ Map<Integer, BuildResult> builds = new HashMap<Integer, BuildResult>();
+
+ for ( BuildResult br : result )
+ {
+ builds.put( br.getProject().getId(), br );
+ }
+
+ return builds;
+ }
+ }
+ finally
+ {
+ rollback( tx );
+ }
+
+ return null;
+ }
+
+ public Map<Integer, BuildResult> getBuildResultsInSuccess()
+ {
+ return getBuildResultsInSuccessByProjectGroupId( -1 );
+ }
+
+}
Propchange: continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/BuildResultDaoImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: continuum/branches/continuum-refactoring-evenisse/continuum-store/src/main/java/org/apache/continuum/dao/BuildResultDaoImpl.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision