You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@continuum.apache.org by br...@apache.org on 2005/08/12 04:46:23 UTC
svn commit: r232187 [1/3] - in /maven/continuum/trunk:
continuum-api/src/main/java/org/apache/maven/continuum/store/
continuum-core/src/main/java/org/apache/maven/continuum/notification/
continuum-core/src/test/java/org/apache/maven/continuum/buildqueu...
Author: brett
Date: Thu Aug 11 19:45:27 2005
New Revision: 232187
URL: http://svn.apache.org/viewcvs?rev=232187&view=rev
Log:
replacement model and tests. Have commented out some tests that address the old model in the core until I can migrate it in
Added:
maven/continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/ContinuumStoreTest.java (with props)
Removed:
maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/utils/WorkingDirectoryServiceTest.java
maven/continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/AbstractContinuumStoreTest.java
maven/continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/ContinuumTypicalUsageTest.java
maven/continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/JdoContinuumStoreTest.java
maven/continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/NewModelTest.java
Modified:
maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java
maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/DefaultContinuumNotificationDispatcher.java
maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/buildqueue/BuildQueueTest.java
maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/execution/shell/ShellBuildExecutorTest.java
maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcherTest.java
maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifierTest.java
maven/continuum/trunk/continuum-model/src/main/java/org/apache/maven/continuum/project/ContinuumProjectState.java
maven/continuum/trunk/continuum-model/src/main/mdo/continuum.mdo
maven/continuum/trunk/continuum-model/src/main/resources/META-INF/package.jdo
maven/continuum/trunk/continuum-store/pom.xml
maven/continuum/trunk/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java
maven/continuum/trunk/continuum-test/src/main/java/org/apache/maven/continuum/AbstractContinuumTest.java
maven/continuum/trunk/continuum-uml/continuum.zuml
maven/continuum/trunk/continuum-xmlrpc/src/test/java/org/apache/maven/continuum/xmlrpc/ContinuumXmlRpcTest.java
Modified: maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java?rev=232187&r1=232186&r2=232187&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java (original)
+++ maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java Thu Aug 11 19:45:27 2005
@@ -16,6 +16,12 @@
* limitations under the License.
*/
+import org.apache.maven.continuum.model.project.BuildResult;
+import org.apache.maven.continuum.model.project.Profile;
+import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.model.project.ProjectGroup;
+import org.apache.maven.continuum.model.project.Schedule;
+import org.apache.maven.continuum.model.system.Installation;
import org.apache.maven.continuum.project.ContinuumBuild;
import org.apache.maven.continuum.project.ContinuumBuildSettings;
import org.apache.maven.continuum.project.ContinuumNotifier;
@@ -31,15 +37,12 @@
/**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
* @version $Id$
+ * @todo remove old stuff
*/
public interface ContinuumStore
{
String ROLE = ContinuumStore.class.getName();
- // ----------------------------------------------------------------------
- // ContinuumProject Mutators
- // ----------------------------------------------------------------------
-
ContinuumProject addProject( ContinuumProject project )
throws ContinuumStoreException;
@@ -49,19 +52,12 @@
ContinuumProject updateProject( ContinuumProject project )
throws ContinuumStoreException;
- // ----------------------------------------------------------------------
- // ContinuumProject Queries
- // ----------------------------------------------------------------------
-
Collection getAllProjects()
throws ContinuumStoreException;
ContinuumProject getProjectByName( String name )
throws ContinuumStoreException;
- ContinuumProject getProjectByScmUrl( String scmUrl )
- throws ContinuumStoreException;
-
ContinuumProject getProject( String projectId )
throws ContinuumStoreException;
@@ -71,10 +67,6 @@
ScmResult getScmResultForProject( String projectId )
throws ContinuumStoreException;
- // ----------------------------------------------------------------------
- // Build
- // ----------------------------------------------------------------------
-
ContinuumBuild addBuild( String projectId, ContinuumBuild build )
throws ContinuumStoreException;
@@ -99,20 +91,12 @@
File getBuildOutputFile( String buildId )
throws ContinuumStoreException;
- // ----------------------------------------------------------------------
- // Notifiers
- // ----------------------------------------------------------------------
-
void removeNotifier( ContinuumNotifier notifier )
throws ContinuumStoreException;
ContinuumNotifier storeNotifier( ContinuumNotifier notifier )
throws ContinuumStoreException;
- // ----------------------------------------------------------------------
- // Schedules
- // ----------------------------------------------------------------------
-
ContinuumSchedule addSchedule( ContinuumSchedule schedule )
throws ContinuumStoreException;
@@ -128,10 +112,6 @@
ContinuumSchedule getSchedule( String scheduleId )
throws ContinuumStoreException;
- // ----------------------------------------------------------------------
- // Project Groups
- // ----------------------------------------------------------------------
-
ContinuumProjectGroup addProjectGroup( ContinuumProjectGroup projectGroup )
throws ContinuumStoreException;
@@ -144,23 +124,12 @@
ContinuumProjectGroup getProjectGroup( String projectGroupId )
throws ContinuumStoreException;
- ContinuumProjectGroup getProjectGroupByName( String name )
- throws ContinuumStoreException;
-
ContinuumProjectGroup getProjectGroupByGroupId( String groupId )
throws ContinuumStoreException;
Collection getProjectGroups()
throws ContinuumStoreException;
- // ----------------------------------------------------------------------
- // Build Group
- // ----------------------------------------------------------------------
-
- // ----------------------------------------------------------------------
- // Build settings
- // ----------------------------------------------------------------------
-
ContinuumBuildSettings addBuildSettings( ContinuumBuildSettings buildSettings )
throws ContinuumStoreException;
@@ -175,4 +144,73 @@
Collection getBuildSettings()
throws ContinuumStoreException;
+
+ ProjectGroup addProjectGroup( ProjectGroup group );
+
+ ProjectGroup getProjectGroup( int projectGroupId )
+ throws ContinuumObjectNotFoundException;
+
+ void updateProjectGroup( ProjectGroup group )
+ throws ContinuumStoreException;
+
+ Collection getAllProjectGroupsWithProjects();
+
+ List getAllProjectsByName();
+
+ List getAllSchedulesByName();
+
+ Schedule addSchedule( Schedule schedule );
+
+ List getAllProfilesByName();
+
+ Profile addProfile( Profile profile );
+
+ Installation addInstallation( Installation installation );
+
+ List getAllInstallations();
+
+ List getAllBuildsForAProjectByDate( int projectId );
+
+ Project getProject( int projectId )
+ throws ContinuumObjectNotFoundException;
+
+ void updateProject( Project project )
+ throws ContinuumStoreException;
+
+ void updateProfile( Profile profile )
+ throws ContinuumStoreException;
+
+ void updateSchedule( Schedule schedule )
+ throws ContinuumStoreException;
+
+ Project getProjectWithBuilds( int projectId )
+ throws ContinuumObjectNotFoundException;
+
+ void removeProfile( Profile profile );
+
+ void removeSchedule( Schedule schedule );
+
+ Project getProjectWithCheckoutResult( int projectId )
+ throws ContinuumObjectNotFoundException;
+
+ BuildResult getBuildResult( int buildId )
+ throws ContinuumObjectNotFoundException;
+
+ void removeProject( Project project );
+
+ void removeProjectGroup( ProjectGroup projectGroup );
+
+ ProjectGroup getProjectGroupWithBuildDetails( int projectGroupId )
+ throws ContinuumObjectNotFoundException;
+
+ List getAllProjectGroupsWithBuildDetails();
+
+ Project getProjectWithAllDetails( int projectId )
+ throws ContinuumObjectNotFoundException;
+
+ Schedule getSchedule( int scheduleId )
+ throws ContinuumObjectNotFoundException;
+
+ Profile getProfile( int profileId )
+ throws ContinuumObjectNotFoundException;
}
Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/DefaultContinuumNotificationDispatcher.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/DefaultContinuumNotificationDispatcher.java?rev=232187&r1=232186&r2=232187&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/DefaultContinuumNotificationDispatcher.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/DefaultContinuumNotificationDispatcher.java Thu Aug 11 19:45:27 2005
@@ -93,9 +93,7 @@
//
// ----------------------------------------------------------------------
- private void sendNotification( String messageId,
- ContinuumProject project,
- ContinuumBuild build )
+ private void sendNotification( String messageId, ContinuumProject project, ContinuumBuild build )
{
Map context = new HashMap();
@@ -107,10 +105,12 @@
try
{
+ // TODO: remove re-reading?
context.put( CONTEXT_PROJECT, store.getProject( project.getId() ) );
if ( build != null )
{
+ // TODO: remove?
build = store.getBuild( build.getId() );
context.put( CONTEXT_BUILD, build );
Modified: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/buildqueue/BuildQueueTest.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/buildqueue/BuildQueueTest.java?rev=232187&r1=232186&r2=232187&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/buildqueue/BuildQueueTest.java (original)
+++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/buildqueue/BuildQueueTest.java Thu Aug 11 19:45:27 2005
@@ -17,8 +17,7 @@
*/
import org.apache.maven.continuum.AbstractContinuumTest;
-import org.apache.maven.continuum.project.ContinuumProject;
-
+import org.apache.maven.continuum.model.project.Project;
import org.codehaus.plexus.taskqueue.Task;
import org.codehaus.plexus.taskqueue.TaskQueue;
@@ -42,9 +41,9 @@
public void testTestTheQueueWithASingleProject()
throws Exception
{
- ContinuumProject project = addMavenTwoProject( getStore(), "Build Queue Project 1" );
+ Project project = addProject( getStore(), "Build Queue Project 1" );
- String projectId = project.getId();
+ int projectId = project.getId();
buildProject( projectId, false );
@@ -67,9 +66,9 @@
public void testTheQueueWithMultipleProjects()
throws Exception
{
- String projectId1 = addMavenTwoProject( getStore(), "Build Queue Project 2" ).getId();
+ int projectId1 = addProject( getStore(), "Build Queue Project 2" ).getId();
- String projectId2 = addMavenTwoProject( getStore(), "Build Queue Project 3" ).getId();
+ int projectId2 = addProject( getStore(), "Build Queue Project 3" ).getId();
buildProject( projectId1, false );
@@ -105,7 +104,7 @@
{
String name = "Build Queue Project 4";
- String projectId = addMavenTwoProject( getStore(), name ).getId();
+ int projectId = addProject( getStore(), name ).getId();
buildProject( projectId, true );
@@ -132,22 +131,23 @@
//
// ----------------------------------------------------------------------
- private void buildProject( String projectId, boolean force )
+ private void buildProject( int projectId, boolean force )
throws Exception
{
- buildQueue.put( new BuildProjectTask( projectId, force ) );
+ buildQueue.put( new BuildProjectTask( Integer.toString( projectId ), force ) );
}
- private void assertNextBuildIs( String expectedProjectId )
+ private void assertNextBuildIs( int expectedProjectId )
throws Exception
{
Task task = buildQueue.take();
assertEquals( BuildProjectTask.class.getName(), task.getClass().getName() );
- BuildProjectTask buildProjectTask = ( BuildProjectTask ) task;
+ BuildProjectTask buildProjectTask = (BuildProjectTask) task;
- assertEquals( "Didn't get the expected project id.", expectedProjectId, buildProjectTask.getProjectId() );
+ assertEquals( "Didn't get the expected project id.", Integer.toString( expectedProjectId ),
+ buildProjectTask.getProjectId() );
}
private void assertNextBuildIsNull()
Modified: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/execution/shell/ShellBuildExecutorTest.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/execution/shell/ShellBuildExecutorTest.java?rev=232187&r1=232186&r2=232187&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/execution/shell/ShellBuildExecutorTest.java (original)
+++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/execution/shell/ShellBuildExecutorTest.java Thu Aug 11 19:45:27 2005
@@ -17,8 +17,6 @@
*/
import org.apache.maven.continuum.AbstractContinuumTest;
-import org.apache.maven.continuum.execution.ContinuumBuildExecutorException;
-import org.apache.maven.continuum.project.ShellProject;
/**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
@@ -27,6 +25,7 @@
public class ShellBuildExecutorTest
extends AbstractContinuumTest
{
+/* TODO
public void testNonAbsolutePath()
throws Exception
{
@@ -61,4 +60,5 @@
// expected
}
}
+*/
}
Modified: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcherTest.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcherTest.java?rev=232187&r1=232186&r2=232187&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcherTest.java (original)
+++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcherTest.java Thu Aug 11 19:45:27 2005
@@ -16,11 +16,11 @@
* limitations under the License.
*/
-import org.apache.maven.continuum.store.ContinuumStore;
+import org.apache.maven.continuum.AbstractContinuumTest;
+import org.apache.maven.continuum.model.project.Project;
import org.apache.maven.continuum.project.ContinuumBuild;
import org.apache.maven.continuum.project.ContinuumProjectState;
-import org.apache.maven.continuum.project.ContinuumProject;
-import org.apache.maven.continuum.AbstractContinuumTest;
+import org.apache.maven.continuum.store.ContinuumStore;
/**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
@@ -32,21 +32,21 @@
public void testNotificationDispatcher()
throws Exception
{
- ContinuumNotificationDispatcher notificationDispatcher =
- (ContinuumNotificationDispatcher) lookup( ContinuumNotificationDispatcher.ROLE );
+ ContinuumNotificationDispatcher notificationDispatcher = (ContinuumNotificationDispatcher) lookup(
+ ContinuumNotificationDispatcher.ROLE );
ContinuumStore store = getStore();
- ContinuumProject project = AbstractContinuumTest.addMavenTwoProject( store,
- "Notification Dispatcher Test Project" );
+ Project project = AbstractContinuumTest.addProject( store, "Notification Dispatcher Test Project" );
ContinuumBuild build = new ContinuumBuild();
build.setStartTime( System.currentTimeMillis() );
build.setState( ContinuumProjectState.BUILDING );
build.setForced( false );
- build = store.addBuild( project.getId(), build );
+ build = store.addBuild( Integer.toString( project.getId() ), build );
- notificationDispatcher.buildComplete( project, build );
+ // TODO
+// notificationDispatcher.buildComplete( project, build );
}
}
Modified: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifierTest.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifierTest.java?rev=232187&r1=232186&r2=232187&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifierTest.java (original)
+++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifierTest.java Thu Aug 11 19:45:27 2005
@@ -20,10 +20,8 @@
import org.apache.maven.continuum.notification.ContinuumNotificationDispatcher;
import org.apache.maven.continuum.project.ContinuumBuild;
import org.apache.maven.continuum.project.ContinuumProject;
-import org.apache.maven.continuum.project.ContinuumProjectState;
import org.apache.maven.continuum.scm.ScmFile;
import org.apache.maven.continuum.scm.ScmResult;
-
import org.codehaus.plexus.mailsender.MailMessage;
import org.codehaus.plexus.mailsender.test.MockMailSender;
import org.codehaus.plexus.notification.notifier.Notifier;
@@ -42,6 +40,7 @@
public class MailContinuumNotifierTest
extends AbstractContinuumTest
{
+/* TODO
public void testSuccessfulBuild()
throws Exception
{
@@ -86,6 +85,8 @@
dumpContent( mailMessage );
}
+*/
+
private void dumpContent( MailMessage mailMessage )
{
if ( false )
@@ -98,8 +99,7 @@
//
// ----------------------------------------------------------------------
- private MailMessage sendNotificationAndGetMessage( ContinuumProject project,
- ContinuumBuild build,
+ private MailMessage sendNotificationAndGetMessage( ContinuumProject project, ContinuumBuild build,
String buildOutput )
throws Exception
{
@@ -123,9 +123,7 @@
Notifier notifier = (Notifier) lookup( Notifier.ROLE, "mail" );
- notifier.sendNotification( ContinuumNotificationDispatcher.MESSAGE_ID_BUILD_COMPLETE,
- recipients,
- context );
+ notifier.sendNotification( ContinuumNotificationDispatcher.MESSAGE_ID_BUILD_COMPLETE, recipients, context );
// ----------------------------------------------------------------------
//
@@ -178,7 +176,7 @@
ScmFile file = new ScmFile();
- file.setPath( "/hey/yo/lets/go");
+ file.setPath( "/hey/yo/lets/go" );
scmResult.getFiles().add( file );
Modified: maven/continuum/trunk/continuum-model/src/main/java/org/apache/maven/continuum/project/ContinuumProjectState.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-model/src/main/java/org/apache/maven/continuum/project/ContinuumProjectState.java?rev=232187&r1=232186&r2=232187&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-model/src/main/java/org/apache/maven/continuum/project/ContinuumProjectState.java (original)
+++ maven/continuum/trunk/continuum-model/src/main/java/org/apache/maven/continuum/project/ContinuumProjectState.java Thu Aug 11 19:45:27 2005
@@ -65,6 +65,9 @@
private String name;
+ // TODO: maybe move these to another class
+ public static final int TRIGGER_FORCED = 1;
+
protected ContinuumProjectState( String name )
{
this.name = name;
Modified: maven/continuum/trunk/continuum-model/src/main/mdo/continuum.mdo
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-model/src/main/mdo/continuum.mdo?rev=232187&r1=232186&r2=232187&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-model/src/main/mdo/continuum.mdo (original)
+++ maven/continuum/trunk/continuum-model/src/main/mdo/continuum.mdo Thu Aug 11 19:45:27 2005
@@ -255,7 +255,7 @@
<field>
<name>continuumId</name>
<version>1.0.0+</version>
- <type>String</type>
+ <type>int</type>
</field>
</fields>
</class>
@@ -298,12 +298,17 @@
</association>
</field>
<field>
- <name>buildNumber</name>
+ <name>id</name>
<version>1.0.0+</version>
<type>int</type>
<identifier>true</identifier>
</field>
<field>
+ <name>buildNumber</name>
+ <version>1.0.0+</version>
+ <type>int</type>
+ </field>
+ <field>
<name>state</name>
<version>1.0.0+</version>
<type>int</type>
@@ -316,12 +321,14 @@
<field>
<name>startTime</name>
<version>1.0.0+</version>
- <type>Date</type>
+ <!-- TODO: Because JPOX persists as UTC and pulls back using the local time, we have to take over -->
+ <type>long</type>
</field>
<field>
<name>endTime</name>
<version>1.0.0+</version>
- <type>Date</type>
+ <!-- TODO: Because JPOX persists as UTC and pulls back using the local time, we have to take over -->
+ <type>long</type>
</field>
<field>
<name>error</name>
@@ -370,14 +377,6 @@
<type>String</type>
</field>
<field>
- <name>files</name>
- <version>1.0.0+</version>
- <association>
- <type>ScmFile</type>
- <multiplicity>*</multiplicity>
- </association>
- </field>
- <field>
<name>changes</name>
<version>1.0.0+</version>
<association>
@@ -389,19 +388,6 @@
</class>
<class>
- <name>ScmFile</name>
- <packageName>org.apache.maven.continuum.model.scm</packageName>
- <version>1.0.0+</version>
- <fields>
- <field>
- <name>path</name>
- <version>1.0.0+</version>
- <type>String</type>
- </field>
- </fields>
- </class>
-
- <class>
<name>ChangeSet</name>
<packageName>org.apache.maven.continuum.model.scm</packageName>
<version>1.0.0+</version>
@@ -419,7 +405,8 @@
<field>
<name>date</name>
<version>1.0.0+</version>
- <type>Date</type>
+ <!-- TODO: Because JPOX persists as UTC and pulls back using the local time, we have to take over -->
+ <type>long</type>
</field>
<field>
<name>files</name>
@@ -494,6 +481,12 @@
]]></description>
<fields>
<field>
+ <name>id</name>
+ <identifier>true</identifier>
+ <version>1.0.0+</version>
+ <type>int</type>
+ </field>
+ <field>
<name>active</name>
<version>1.0.0+</version>
<type>boolean</type>
@@ -528,6 +521,12 @@
<name>Profile</name>
<version>1.0.0+</version>
<fields>
+ <field>
+ <name>id</name>
+ <identifier>true</identifier>
+ <version>1.0.0+</version>
+ <type>int</type>
+ </field>
<field>
<name>active</name>
<version>1.0.0+</version>
Modified: maven/continuum/trunk/continuum-model/src/main/resources/META-INF/package.jdo
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-model/src/main/resources/META-INF/package.jdo?rev=232187&r1=232186&r2=232187&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-model/src/main/resources/META-INF/package.jdo (original)
+++ maven/continuum/trunk/continuum-model/src/main/resources/META-INF/package.jdo Thu Aug 11 19:45:27 2005
@@ -7,7 +7,7 @@
<jdo>
<package name="org.apache.maven.continuum.project">
<class name="ContinuumProject" detachable="true" identity-type="application"
- objectid-class="javax.jdo.identity.StringIdentity" table="project">
+ objectid-class="javax.jdo.identity.StringIdentity">
<inheritance strategy="new-table">
<discriminator strategy="class-name">
<column name="PROJECT_TYPE"/>
@@ -227,4 +227,175 @@
<field name="home" persistence-modifier="persistent"/>
</class>
</package>
+
+ <!-- Really new stuff, TODO: remove the rest -->
+ <package name="org.apache.maven.continuum.model.project">
+ <class name="ProjectGroup" identity-type="application" detachable="true"
+ objectid-class="javax.jdo.identity.IntIdentity">
+ <field name="id" primary-key="true" value-strategy="native"/>
+ <field name="groupId"/>
+ <field name="name"/>
+ <field name="description"/>
+ <field name="projects" mapped-by="projectGroup" default-fetch-group="true">
+ <collection element-type="Project" dependent-element="true"/>
+ </field>
+ <field name="buildDefinitions">
+ <collection element-type="BuildDefinition" dependent-element="true"/>
+ <join/>
+ </field>
+ <field name="notifiers">
+ <collection element-type="ProjectNotifier" dependent-element="true"/>
+ <join/>
+ </field>
+ <fetch-group name="project-build-details">
+ <field name="notifiers"/>
+ <field name="buildDefinitions"/>
+ </fetch-group>
+ </class>
+ <class name="Project" detachable="true" identity-type="application"
+ objectid-class="javax.jdo.identity.IntIdentity">
+ <field name="id" primary-key="true" value-strategy="native"/>
+ <field name="projectGroup" default-fetch-group="true"/>
+ <!-- Foreign key -->
+ <field name="name"/>
+ <field name="description"/>
+ <field name="scmUrl"/>
+ <field name="version"/>
+ <field name="workingDirectory"/>
+ <field name="state"/>
+ <field name="buildNumber"/>
+ <field name="url"/>
+ <field name="artifactId"/>
+ <field name="groupId"/>
+ <field name="buildResults" mapped-by="project">
+ <collection element-type="BuildResult" dependent-element="true"/>
+ </field>
+ <field name="checkoutResult" dependent="true"/>
+ <field name="buildDefinitions">
+ <collection element-type="BuildDefinition" dependent-element="true"/>
+ <join/>
+ </field>
+ <field name="notifiers">
+ <collection element-type="ProjectNotifier" dependent-element="true"/>
+ <join/>
+ </field>
+ <field name="developers">
+ <collection element-type="ProjectDeveloper" dependent-element="true"/>
+ </field>
+ <field name="dependencies">
+ <collection element-type="ProjectDependency" dependent-element="true"/>
+ </field>
+ <fetch-group name="project-with-builds">
+ <field name="buildResults"/>
+ </fetch-group>
+ <fetch-group name="project-with-checkout-result">
+ <field name="checkoutResult"/>
+ </fetch-group>
+ <fetch-group name="project-build-details">
+ <field name="notifiers"/>
+ <field name="buildDefinitions"/>
+ </fetch-group>
+ <fetch-group name="project-all-details">
+ <fetch-group name="project-build-details"/>
+ <field name="developers"/>
+ <field name="dependencies"/>
+ </fetch-group>
+ </class>
+ <class name="Schedule" detachable="true" identity-type="application"
+ objectid-class="javax.jdo.identity.IntIdentity">
+ <field name="id" primary-key="true" value-strategy="native"/>
+ <field name="active"/>
+ <field name="description"/>
+ <field name="name"/>
+ <field name="cronExpression"/>
+ <field name="delay"/>
+ </class>
+ <class name="Profile" detachable="true" identity-type="application"
+ objectid-class="javax.jdo.identity.IntIdentity">
+ <field name="id" primary-key="true" value-strategy="native"/>
+ <field name="active"/>
+ <field name="description"/>
+ <field name="name"/>
+ <field name="scmMode"/>
+ <field name="buildWithoutChanges"/>
+ <field name="builder" default-fetch-group="true"/>
+ <field name="jdk" default-fetch-group="true"/>
+ </class>
+ <class name="BuildResult" detachable="true" identity-type="application"
+ objectid-class="javax.jdo.identity.IntIdentity">
+ <field name="id" primary-key="true" value-strategy="native"/>
+ <field name="state"/>
+ <field name="trigger"/>
+ <field name="startTime"/>
+ <field name="endTime"/>
+ <field name="error"/>
+ <field name="success"/>
+ <field name="exitCode"/>
+ <field name="buildNumber"/>
+ <field name="scmResult" dependent="true"/>
+ <field name="project" default-fetch-group="true"/>
+ <fetch-group name="build-result-with-details">
+ <field name="scmResult"/>
+ </fetch-group>
+ </class>
+ <class name="BuildDefinition" detachable="true">
+ <field name="goals"/>
+ <field name="arguments"/>
+ <field name="buildFile"/>
+ <field name="schedule" default-fetch-group="true"/>
+ <field name="profile" default-fetch-group="true"/>
+ </class>
+ <class name="ProjectNotifier" detachable="true">
+ <field name="type"/>
+ <field name="recipientType"/>
+ <field name="sendOnSuccess"/>
+ <field name="sendOnFailure"/>
+ <field name="sendOnError"/>
+ <field name="configuration" default-fetch-group="true">
+ <map key-type="java.lang.String" value-type="java.lang.String" dependent-key="true" dependent-value="true"/>
+ <join/>
+ </field>
+ </class>
+ <class name="ProjectDeveloper" detachable="true">
+ <field name="scmId"/>
+ <field name="continuumId"/>
+ <field name="name"/>
+ <field name="email"/>
+ </class>
+ <class name="ProjectDependency" detachable="true">
+ <field name="groupId"/>
+ <field name="artifactId"/>
+ <field name="version"/>
+ </class>
+ </package>
+ <package name="org.apache.maven.continuum.model.scm">
+ <class name="ScmResult" detachable="true">
+ <field name="success"/>
+ <field name="providerMessage"/>
+ <field name="commandOutput"/>
+ <field name="changes" default-fetch-group="true">
+ <collection element-type="ChangeSet" dependent-element="true"/>
+ </field>
+ </class>
+ <class name="ChangeSet" detachable="true">
+ <field name="author"/>
+ <field name="comment"/>
+ <field name="date"/>
+ <field name="files" default-fetch-group="true">
+ <collection element-type="ChangeFile" dependent-element="true"/>
+ </field>
+ </class>
+ <class name="ChangeFile" detachable="true">
+ <field name="name"/>
+ <field name="revision"/>
+ </class>
+ </package>
+ <package name="org.apache.maven.continuum.model.system">
+ <class name="Installation" detachable="true">
+ <field name="name"/>
+ <field name="path"/>
+ <field name="version"/>
+ </class>
+ </package>
+
</jdo>
Modified: maven/continuum/trunk/continuum-store/pom.xml
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-store/pom.xml?rev=232187&r1=232186&r2=232187&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-store/pom.xml (original)
+++ maven/continuum/trunk/continuum-store/pom.xml Thu Aug 11 19:45:27 2005
@@ -26,7 +26,7 @@
<dependency>
<groupId>plexus</groupId>
<artifactId>plexus-jdo2</artifactId>
- </dependency>
+ </dependency>
<dependency>
<groupId>jdo</groupId>
<artifactId>jdo</artifactId>
@@ -37,20 +37,10 @@
<version>1.7.3.0</version>
<scope>test</scope>
</dependency>
-<!--
<dependency>
- <groupId>postgresql</groupId>
- <artifactId>postgresql</artifactId>
- <version>7.4</version>
- <classifier>jdbc3</classifier>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>incubator-derby</groupId>
- <artifactId>derby</artifactId>
- <version>10.0.2.1</version>
- <scope>test</scope>
+ <groupId>clover</groupId>
+ <artifactId>clover</artifactId>
+ <version>1.3.9</version>
</dependency>
--->
</dependencies>
</project>
Modified: maven/continuum/trunk/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java?rev=232187&r1=232186&r2=232187&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java (original)
+++ maven/continuum/trunk/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java Thu Aug 11 19:45:27 2005
@@ -16,6 +16,12 @@
* limitations under the License.
*/
+import org.apache.maven.continuum.model.project.BuildResult;
+import org.apache.maven.continuum.model.project.Profile;
+import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.model.project.ProjectGroup;
+import org.apache.maven.continuum.model.project.Schedule;
+import org.apache.maven.continuum.model.system.Installation;
import org.apache.maven.continuum.project.ContinuumBuild;
import org.apache.maven.continuum.project.ContinuumBuildSettings;
import org.apache.maven.continuum.project.ContinuumNotifier;
@@ -28,21 +34,24 @@
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
import javax.jdo.Extent;
+import javax.jdo.JDOHelper;
import javax.jdo.JDOObjectNotFoundException;
import javax.jdo.JDOUserException;
import javax.jdo.PersistenceManager;
import javax.jdo.PersistenceManagerFactory;
import javax.jdo.Query;
import javax.jdo.Transaction;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
/**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id$
+ * @todo cleanup old stuff
*/
public class JdoContinuumStore
extends AbstractContinuumStore
@@ -67,16 +76,22 @@
private static final String BUILD_DETAIL_FG = "build-detail";
- private static final String NOTIFIER_DETAIL_FG = "notifier-detail";
-
- private static final String BUILD_GROUP_DETAIL_FG = "build-group-detail";
-
private static final String PROJECT_GROUP_DETAIL_FG = "project-group-detail";
private static final String SCHEDULE_DETAIL_FG = "schedule-detail";
private static final String BUILD_SETTINGS_DETAIL_FG = "build-settings-detail";
+ private static final String PROJECT_WITH_BUILDS_FETCH_GROUP = "project-with-builds";
+
+ private static final String PROJECT_WITH_CHECKOUT_RESULT_FETCH_GROUP = "project-with-checkout-result";
+
+ private static final String BUILD_RESULT_WITH_DETAILS_FETCH_GROUP = "build-result-with-details";
+
+ private static final String PROJECT_BUILD_DETAILS_FETCH_GROUP = "project-build-details";
+
+ private static final String PROJECT_ALL_DETAILS_FETCH_GROUP = "project-all-details";
+
// ----------------------------------------------------------------------
// Component Lifecycle
// ----------------------------------------------------------------------
@@ -141,7 +156,7 @@
pm.deletePersistent( project );
- commit( tx );
+ tx.commit();
}
finally
{
@@ -200,11 +215,9 @@
pm.attachCopy( project, true );
- commit( tx );
+ tx.commit();
- return (ContinuumProject) getDetailedObject( ContinuumProject.class,
- project.getId(),
- PROJECT_DETAIL_FG );
+ return (ContinuumProject) getDetailedObject( ContinuumProject.class, project.getId(), PROJECT_DETAIL_FG );
}
finally
{
@@ -238,7 +251,7 @@
setProjectState( (ContinuumProject) it.next() );
}
- commit( tx );
+ tx.commit();
return result;
}
@@ -275,58 +288,14 @@
if ( result.size() == 0 )
{
- commit( tx );
-
- return null;
- }
-
- Object object = pm.detachCopy( result.iterator().next() );
-
- commit( tx );
-
- return (ContinuumProject) object;
- }
- finally
- {
- rollback( tx );
- }
- }
-
- public ContinuumProject getProjectByScmUrl( String scmUrl )
- throws ContinuumStoreException
- {
- PersistenceManager pm = pmf.getPersistenceManager();
-
- Transaction tx = pm.currentTransaction();
-
- try
- {
- tx.begin();
-
- Extent extent = pm.getExtent( ContinuumProject.class, true );
-
- Query query = pm.newQuery( extent );
-
- query.declareImports( "import java.lang.String" );
-
- query.declareParameters( "String scmUrl" );
-
- query.setFilter( "this.scmUrl == scmUrl" );
-
- query.getFetchPlan().addGroup( PROJECT_DETAIL_FG );
-
- Collection result = (Collection) query.execute( scmUrl );
-
- if ( result.size() == 0 )
- {
- commit( tx );
+ tx.commit();
return null;
}
Object object = pm.detachCopy( result.iterator().next() );
- commit( tx );
+ tx.commit();
return (ContinuumProject) object;
}
@@ -351,7 +320,7 @@
project = (ContinuumProject) pm.detachCopy( project );
- commit( tx );
+ tx.commit();
return project;
}
@@ -382,7 +351,7 @@
ContinuumProject project = getContinuumProject( pm, projectId, true );
- commit( tx );
+ tx.commit();
return project;
}
@@ -409,14 +378,14 @@
if ( scmResult == null )
{
- commit( tx );
+ tx.commit();
return null;
}
scmResult = (ScmResult) pm.detachCopy( scmResult );
- commit( tx );
+ tx.commit();
return scmResult;
}
@@ -426,9 +395,11 @@
}
}
- // ----------------------------------------------------------------------
- // Schedules
- // ----------------------------------------------------------------------
+ public ContinuumBuild addBuild( String projectId, ContinuumBuild build )
+ throws ContinuumStoreException
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
public ContinuumSchedule addSchedule( ContinuumSchedule schedule )
throws ContinuumStoreException
@@ -451,7 +422,7 @@
schedule = (ContinuumSchedule) pm.detachCopy( schedule );
- commit( tx );
+ tx.commit();
return schedule;
}
@@ -486,7 +457,7 @@
result = pm.detachCopyAll( result );
- commit( tx );
+ tx.commit();
return result;
}
@@ -499,7 +470,8 @@
public ContinuumSchedule updateSchedule( ContinuumSchedule schedule )
throws ContinuumStoreException
{
- return (ContinuumSchedule) updateObject( schedule, SCHEDULE_DETAIL_FG );
+ updateObject( schedule );
+ return schedule;
}
public void removeSchedule( String scheduleId )
@@ -539,7 +511,7 @@
pm.deletePersistent( schedule );
- commit( tx );
+ tx.commit();
}
finally
{
@@ -547,11 +519,7 @@
}
}
- // ----------------------------------------------------------------------
- // Builds
- // ----------------------------------------------------------------------
-
- public ContinuumBuild addBuild( String projectId, ContinuumBuild build )
+ public ContinuumBuild addBuild( int projectId, ContinuumBuild build )
throws ContinuumStoreException
{
PersistenceManager pm = pmf.getPersistenceManager();
@@ -562,7 +530,7 @@
{
tx.begin();
- ContinuumProject project = getContinuumProject( pm, projectId, false );
+ ContinuumProject project = getContinuumProject( pm, Integer.toString( projectId ), false );
build.setProject( project );
@@ -574,7 +542,7 @@
project.getBuilds().add( build );
- commit( tx );
+ tx.commit();
return (ContinuumBuild) getDetailedObject( ContinuumBuild.class, build.getId(), BUILD_DETAIL_FG );
}
@@ -587,7 +555,8 @@
public ContinuumBuild updateBuild( ContinuumBuild build )
throws ContinuumStoreException
{
- return (ContinuumBuild) updateObject( build, BUILD_DETAIL_FG );
+ updateObject( build );
+ return build;
}
public ContinuumBuild getBuild( String buildId )
@@ -613,7 +582,7 @@
if ( buildId == null )
{
- commit( tx );
+ tx.commit();
return null;
}
@@ -624,7 +593,7 @@
ContinuumBuild build = (ContinuumBuild) pm.detachCopy( object );
- commit( tx );
+ tx.commit();
return build;
}
@@ -661,7 +630,7 @@
builds = pm.detachCopyAll( builds );
- commit( tx );
+ tx.commit();
return builds;
}
@@ -688,14 +657,14 @@
if ( scmResult == null )
{
- commit( tx );
+ tx.commit();
return null;
}
List files = (List) pm.detachCopyAll( scmResult.getFiles() );
- commit( tx );
+ tx.commit();
return files;
}
@@ -714,13 +683,10 @@
public ContinuumNotifier storeNotifier( ContinuumNotifier notifier )
throws ContinuumStoreException
{
- return (ContinuumNotifier) updateObject( notifier, NOTIFIER_DETAIL_FG );
+ updateObject( notifier );
+ return notifier;
}
- // ----------------------------------------------------------------------
- // Project Groups
- // ----------------------------------------------------------------------
-
public ContinuumProjectGroup addProjectGroup( ContinuumProjectGroup projectGroup )
throws ContinuumStoreException
{
@@ -730,7 +696,8 @@
public ContinuumProjectGroup updateProjectGroup( ContinuumProjectGroup projectGroup )
throws ContinuumStoreException
{
- return (ContinuumProjectGroup) updateObject( projectGroup, PROJECT_GROUP_DETAIL_FG );
+ updateObject( projectGroup );
+ return projectGroup;
}
public Collection getProjectGroups()
@@ -754,7 +721,7 @@
result = pm.detachCopyAll( result );
- commit( tx );
+ tx.commit();
return result;
}
@@ -781,7 +748,7 @@
pm.deletePersistent( projectGroup );
- commit( tx );
+ tx.commit();
}
finally
{
@@ -792,34 +759,18 @@
public ContinuumProjectGroup getProjectGroup( String projectGroupId )
throws ContinuumStoreException
{
- return (ContinuumProjectGroup) getDetailedObject( ContinuumProjectGroup.class,
- projectGroupId,
+ return (ContinuumProjectGroup) getDetailedObject( ContinuumProjectGroup.class, projectGroupId,
PROJECT_GROUP_DETAIL_FG );
}
- public ContinuumProjectGroup getProjectGroupByName( String name )
- throws ContinuumStoreException
- {
- return (ContinuumProjectGroup) getObjectFromQuery( ContinuumProjectGroup.class,
- "name",
- name,
- PROJECT_GROUP_DETAIL_FG );
- }
-
public ContinuumProjectGroup getProjectGroupByGroupId( String groupId )
throws ContinuumStoreException
{
- return (ContinuumProjectGroup) getObjectFromQuery( ContinuumProjectGroup.class,
- "groupId",
- groupId,
+ return (ContinuumProjectGroup) getObjectFromQuery( ContinuumProjectGroup.class, "groupId", groupId,
PROJECT_GROUP_DETAIL_FG );
}
- // ----------------------------------------------------------------------
- // Build Settings
- // ----------------------------------------------------------------------
-
public ContinuumBuildSettings addBuildSettings( ContinuumBuildSettings buildSettings )
throws ContinuumStoreException
{
@@ -829,7 +780,8 @@
public ContinuumBuildSettings updateBuildSettings( ContinuumBuildSettings buildSettings )
throws ContinuumStoreException
{
- return (ContinuumBuildSettings) updateObject( buildSettings, BUILD_SETTINGS_DETAIL_FG );
+ updateObject( buildSettings );
+ return buildSettings;
}
public void removeBuildSettings( String buildSettingsId )
@@ -862,7 +814,7 @@
pm.deletePersistent( buildSettings );
- commit( tx );
+ tx.commit();
}
finally
{
@@ -873,8 +825,7 @@
public ContinuumBuildSettings getBuildSettings( String buildSettingsId )
throws ContinuumStoreException
{
- return (ContinuumBuildSettings) getDetailedObject( ContinuumBuildSettings.class,
- buildSettingsId,
+ return (ContinuumBuildSettings) getDetailedObject( ContinuumBuildSettings.class, buildSettingsId,
"build-settings-detail" );
}
@@ -899,7 +850,7 @@
result = pm.detachCopyAll( result );
- commit( tx );
+ tx.commit();
return result;
}
@@ -909,10 +860,6 @@
}
}
- // ----------------------------------------------------------------------
- //
- // ----------------------------------------------------------------------
-
private ContinuumProject setProjectState( ContinuumProject project )
throws ContinuumStoreException
{
@@ -930,13 +877,7 @@
return project;
}
- // ----------------------------------------------------------------------
- //
- // ----------------------------------------------------------------------
-
- private ContinuumProject getContinuumProject( PersistenceManager pm,
- String projectId,
- boolean details )
+ private ContinuumProject getContinuumProject( PersistenceManager pm, String projectId, boolean details )
{
if ( details )
{
@@ -948,17 +889,14 @@
return (ContinuumProject) pm.getObjectById( id );
}
- private ContinuumBuild getContinuumBuild( PersistenceManager pm,
- String buildId )
+ private ContinuumBuild getContinuumBuild( PersistenceManager pm, String buildId )
{
Object id = pm.newObjectIdInstance( ContinuumBuild.class, buildId );
return (ContinuumBuild) pm.getObjectById( id );
}
- private ContinuumSchedule getContinuumSchedule( PersistenceManager pm,
- String projectId,
- boolean details )
+ private ContinuumSchedule getContinuumSchedule( PersistenceManager pm, String projectId, boolean details )
{
if ( details )
{
@@ -970,10 +908,6 @@
return (ContinuumSchedule) pm.getObjectById( id );
}
- // ----------------------------------------------------------------------
- //
- // ----------------------------------------------------------------------
-
private Object addObject( Object object, String detailedFetchGroup )
{
PersistenceManager pm = pmf.getPersistenceManager();
@@ -1002,7 +936,7 @@
addedObject = pm.detachCopy( addedObject );
- commit( tx );
+ tx.commit();
return addedObject;
}
@@ -1047,7 +981,7 @@
object = pm.detachCopy( object );
- commit( tx );
+ tx.commit();
return object;
}
@@ -1061,10 +995,7 @@
}
}
- private Object getObjectFromQuery( Class clazz,
- String idField,
- String id,
- String fetchGroup )
+ private Object getObjectFromQuery( Class clazz, String idField, String id, String fetchGroup )
throws ContinuumStoreException
{
PersistenceManager pm = pmf.getPersistenceManager();
@@ -1094,16 +1025,15 @@
if ( result.size() > 1 )
{
- throw new ContinuumStoreException( "A query for object of " +
- "type " + clazz.getName() + " on the " +
- "field '" + idField + "' returned more than one object." );
+ throw new ContinuumStoreException( "A query for object of " + "type " + clazz.getName() + " on the " +
+ "field '" + idField + "' returned more than one object." );
}
pm.getFetchPlan().addGroup( fetchGroup );
Object object = pm.detachCopy( result.iterator().next() );
- commit( tx );
+ tx.commit();
return object;
}
@@ -1127,7 +1057,7 @@
pm.deletePersistent( object );
- commit( tx );
+ tx.commit();
}
finally
{
@@ -1135,7 +1065,55 @@
}
}
- private Object updateObject( Object object, String detailedFetchGroup )
+ // TODO ^^^^ REMOVE ^^^^
+
+ // ----------------------------------------------------------------------
+ // Transaction Management
+ // ----------------------------------------------------------------------
+
+ private void rollback( Transaction tx )
+ {
+ PersistenceManager pm = tx.getPersistenceManager();
+
+ try
+ {
+ if ( tx.isActive() )
+ {
+ tx.rollback();
+ }
+ }
+ finally
+ {
+ closePersistenceManager( pm );
+ }
+ }
+
+ private void closePersistenceManager( PersistenceManager pm )
+ {
+ try
+ {
+ pm.close();
+ }
+ catch ( JDOUserException e )
+ {
+ getLogger().warn( "Error while closing the persistence manager.", e );
+ }
+ }
+
+ public ProjectGroup getProjectGroup( int projectGroupId )
+ throws ContinuumObjectNotFoundException
+ {
+ return (ProjectGroup) getObjectById( ProjectGroup.class, projectGroupId );
+ }
+
+ private Object getObjectById( Class clazz, int id )
+ throws ContinuumObjectNotFoundException
+ {
+ return getObjectById( clazz, id, null );
+ }
+
+ private Object getObjectById( Class clazz, int id, String fetchGroup )
+ throws ContinuumObjectNotFoundException
{
PersistenceManager pm = pmf.getPersistenceManager();
@@ -1145,25 +1123,86 @@
{
tx.begin();
+ if ( fetchGroup != null )
+ {
+ pm.getFetchPlan().addGroup( fetchGroup );
+ }
+
+ Object objectId = pm.newObjectIdInstance( clazz, new Integer( id ) );
+
+ Object object = pm.getObjectById( objectId );
+
+ object = pm.detachCopy( object );
+
+ tx.commit();
+
+ return object;
+ }
+ catch ( JDOObjectNotFoundException e )
+ {
+ throw new ContinuumObjectNotFoundException( clazz.getName(), Integer.toString( id ) );
+ }
+ finally
+ {
+ rollback( tx );
+ }
+ }
+
+ public void updateProjectGroup( ProjectGroup group )
+ throws ContinuumStoreException
+ {
+ updateObject( group );
+ }
+
+ private void updateObject( Object object )
+ throws ContinuumStoreException
+ {
+ PersistenceManager pm = pmf.getPersistenceManager();
+
+ Transaction tx = pm.currentTransaction();
+
+ try
+ {
+ tx.begin();
+
+ if ( !JDOHelper.isDetached( object ) )
+ {
+ throw new ContinuumStoreException( "Not detached: " + object );
+ }
+
pm.attachCopy( object, true );
- commit( tx );
+ tx.commit();
+ }
+ finally
+ {
+ rollback( tx );
+ }
+ }
+
+ public Collection getAllProjectGroupsWithProjects()
+ {
+ PersistenceManager pm = pmf.getPersistenceManager();
+
+ Transaction tx = pm.currentTransaction();
+ try
+ {
tx.begin();
- tx = pm.currentTransaction();
+ Extent extent = pm.getExtent( ProjectGroup.class, true );
- Object id = pm.getObjectId( object );
+ Query query = pm.newQuery( extent );
- pm.getFetchPlan().addGroup( detailedFetchGroup );
+ query.setOrdering( "name ascending" );
- object = pm.getObjectById( id, true );
+ Collection result = (Collection) query.execute();
- object = pm.detachCopy( object );
+ result = pm.detachCopyAll( result );
- commit( tx );
+ tx.commit();
- return object;
+ return result;
}
finally
{
@@ -1171,41 +1210,243 @@
}
}
- // ----------------------------------------------------------------------
- // Transaction Management
- // ----------------------------------------------------------------------
+ public List getAllProjectsByName()
+ {
+ return getAllObjectsDetached( Project.class, "name ascending", null );
+ }
- private void commit( Transaction tx )
+ public List getAllSchedulesByName()
{
- tx.commit();
+ return getAllObjectsDetached( Schedule.class, "name ascending", null );
}
- private void rollback( Transaction tx )
+ public Schedule addSchedule( Schedule schedule )
{
- PersistenceManager pm = tx.getPersistenceManager();
+ return (Schedule) addObject( schedule );
+ }
+
+ public List getAllProfilesByName()
+ {
+ return getAllObjectsDetached( Profile.class, "name ascending", null );
+ }
+
+ public Profile addProfile( Profile profile )
+ {
+ return (Profile) addObject( profile );
+ }
+
+ public Installation addInstallation( Installation installation )
+ {
+ return (Installation) addObject( installation );
+ }
+
+ public List getAllInstallations()
+ {
+ return getAllObjectsDetached( Installation.class, "name ascending, version ascending", null );
+ }
+
+ public List getAllBuildsForAProjectByDate( int projectId )
+ {
+ PersistenceManager pm = pmf.getPersistenceManager();
+
+ Transaction tx = pm.currentTransaction();
try
{
- if ( tx.isActive() )
+ tx.begin();
+
+ Query q = pm.newQuery( "SELECT FROM " + BuildResult.class.getName() +
+ " WHERE project.id == :projectId PARAMETERS int projectId ORDER BY endTime DESC" );
+
+ List result = (List) q.execute( new Integer( projectId ) );
+
+ result = (List) pm.detachCopyAll( result );
+
+ tx.commit();
+
+ return result;
+ }
+ finally
+ {
+ rollback( tx );
+ }
+ }
+
+ public Project getProject( int projectId )
+ throws ContinuumObjectNotFoundException
+ {
+ return (Project) getObjectById( Project.class, projectId );
+ }
+
+ public void updateProject( Project project )
+ throws ContinuumStoreException
+ {
+ updateObject( project );
+ }
+
+ public void updateProfile( Profile profile )
+ throws ContinuumStoreException
+ {
+ updateObject( profile );
+ }
+
+ public void updateSchedule( Schedule schedule )
+ throws ContinuumStoreException
+ {
+ updateObject( schedule );
+ }
+
+ public Project getProjectWithBuilds( int projectId )
+ throws ContinuumObjectNotFoundException
+ {
+ return (Project) getObjectById( Project.class, projectId, PROJECT_WITH_BUILDS_FETCH_GROUP );
+ }
+
+ public void removeProfile( Profile profile )
+ {
+ removeObject( profile );
+ }
+
+ public void removeSchedule( Schedule schedule )
+ {
+ removeObject( schedule );
+ }
+
+ public Project getProjectWithCheckoutResult( int projectId )
+ throws ContinuumObjectNotFoundException
+ {
+ return (Project) getObjectById( Project.class, projectId, PROJECT_WITH_CHECKOUT_RESULT_FETCH_GROUP );
+ }
+
+ public BuildResult getBuildResult( int buildId )
+ throws ContinuumObjectNotFoundException
+ {
+ return (BuildResult) getObjectById( BuildResult.class, buildId, BUILD_RESULT_WITH_DETAILS_FETCH_GROUP );
+ }
+
+ public void removeProject( Project project )
+ {
+ removeObject( project );
+ }
+
+ public void removeProjectGroup( ProjectGroup projectGroup )
+ {
+ removeObject( projectGroup );
+ }
+
+ public ProjectGroup getProjectGroupWithBuildDetails( int projectGroupId )
+ throws ContinuumObjectNotFoundException
+ {
+ return (ProjectGroup) getObjectById( ProjectGroup.class, projectGroupId, PROJECT_BUILD_DETAILS_FETCH_GROUP );
+ }
+
+ public List getAllProjectGroupsWithBuildDetails()
+ {
+ return getAllObjectsDetached( ProjectGroup.class, "name ascending", PROJECT_BUILD_DETAILS_FETCH_GROUP );
+ }
+
+ public Project getProjectWithAllDetails( int projectId )
+ throws ContinuumObjectNotFoundException
+ {
+ return (Project) getObjectById( Project.class, projectId, PROJECT_ALL_DETAILS_FETCH_GROUP );
+ }
+
+ public Schedule getSchedule( int scheduleId )
+ throws ContinuumObjectNotFoundException
+ {
+ return (Schedule) getObjectById( Schedule.class, scheduleId );
+ }
+
+ public Profile getProfile( int profileId )
+ throws ContinuumObjectNotFoundException
+ {
+ return (Profile) getObjectById( Profile.class, profileId );
+ }
+
+ private void removeObject( Object o )
+ {
+ PersistenceManager pm = pmf.getPersistenceManager();
+
+ Transaction tx = pm.currentTransaction();
+
+ try
+ {
+ tx.begin();
+
+ o = pm.getObjectById( pm.getObjectId( o ) );
+
+ pm.deletePersistent( o );
+
+ tx.commit();
+ }
+ finally
+ {
+ rollback( tx );
+ }
+ }
+
+ private List getAllObjectsDetached( Class clazz, String ordering, String fetchGroup )
+ {
+ PersistenceManager pm = pmf.getPersistenceManager();
+
+ Transaction tx = pm.currentTransaction();
+
+ try
+ {
+ tx.begin();
+
+ Extent extent = pm.getExtent( clazz, true );
+
+ Query query = pm.newQuery( extent );
+
+ query.setOrdering( ordering );
+
+ if ( fetchGroup != null )
{
- tx.rollback();
+ pm.getFetchPlan().addGroup( fetchGroup );
}
+
+ List result = (List) query.execute();
+
+ result = (List) pm.detachCopyAll( result );
+
+ tx.commit();
+
+ return result;
}
finally
{
- closePersistenceManager( pm );
+ rollback( tx );
}
}
- private void closePersistenceManager( PersistenceManager pm )
+ public ProjectGroup addProjectGroup( ProjectGroup group )
{
+ return (ProjectGroup) addObject( group );
+ }
+
+ private Object addObject( Object object )
+ {
+ PersistenceManager pm = pmf.getPersistenceManager();
+
+ Transaction tx = pm.currentTransaction();
+
try
{
- pm.close();
+ tx.begin();
+
+ pm.makePersistent( object );
+
+ object = pm.detachCopy( object );
+
+ tx.commit();
+
+ return object;
}
- catch ( JDOUserException e )
+ finally
{
- getLogger().warn( "Error while closing the persistence manager.", e );
+ rollback( tx );
}
}
+
}