You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@continuum.apache.org by tr...@apache.org on 2005/07/20 05:44:18 UTC
svn commit: r219839 - in /maven/continuum/trunk:
continuum-api/src/main/java/org/apache/maven/continuum/store/
continuum-core/src/main/java/org/apache/maven/continuum/store/
continuum-core/src/test/java/org/apache/maven/continuum/store/
continuum-model...
Author: trygvis
Date: Tue Jul 19 20:44:17 2005
New Revision: 219839
URL: http://svn.apache.org/viewcvs?rev=219839&view=rev
Log:
o Hey yo.
Added:
maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store/NewModelTest.java (with props)
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/store/JdoContinuumStore.java
maven/continuum/trunk/continuum-model/src/main/resources/META-INF/package.jdo
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=219839&r1=219838&r2=219839&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 Tue Jul 19 20:44:17 2005
@@ -22,6 +22,8 @@
import org.apache.maven.continuum.project.ContinuumBuild;
import org.apache.maven.continuum.project.ContinuumProject;
import org.apache.maven.continuum.project.ContinuumSchedule;
+import org.apache.maven.continuum.project.ContinuumProjectGroup;
+import org.apache.maven.continuum.project.ContinuumBuildGroup;
import org.apache.maven.continuum.scm.ScmResult;
/**
@@ -124,4 +126,23 @@
ContinuumSchedule getSchedule( String scheduleId )
throws ContinuumStoreException;
+ // ----------------------------------------------------------------------
+ // Project Groups
+ // ----------------------------------------------------------------------
+
+ String addProjectGroup( ContinuumProjectGroup projectGroup )
+ throws ContinuumStoreException;
+
+ ContinuumProjectGroup getProjectGroup( String projectGroupId )
+ throws ContinuumStoreException;
+
+ // ----------------------------------------------------------------------
+ // Build Group
+ // ----------------------------------------------------------------------
+
+ String addBuildGroup( ContinuumBuildGroup buildGroup )
+ throws ContinuumStoreException;
+
+ ContinuumBuildGroup getBuildGroup( String buildGroupId )
+ throws ContinuumStoreException;
}
Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java?rev=219839&r1=219838&r2=219839&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java Tue Jul 19 20:44:17 2005
@@ -33,6 +33,8 @@
import org.apache.maven.continuum.project.ContinuumProject;
import org.apache.maven.continuum.project.ContinuumProjectState;
import org.apache.maven.continuum.project.ContinuumSchedule;
+import org.apache.maven.continuum.project.ContinuumProjectGroup;
+import org.apache.maven.continuum.project.ContinuumBuildGroup;
import org.apache.maven.continuum.scm.ScmResult;
import org.codehaus.plexus.jdo.JdoFactory;
@@ -75,26 +77,7 @@
public String addProject( ContinuumProject project )
throws ContinuumStoreException
{
- PersistenceManager pm = pmf.getPersistenceManager();
-
- Transaction tx = pm.currentTransaction();
-
- try
- {
- tx.begin();
-
- Object object = makePersistent( pm, project );
-
- project = (ContinuumProject) object;
-
- commit( tx );
-
- return project.getId();
- }
- finally
- {
- rollback( tx );
- }
+ return ((ContinuumProject)addObject( project ) ).getId();
}
public void removeProject( String projectId )
@@ -132,6 +115,8 @@
}
}
+ project.setProjectGroup( null );
+
pm.deletePersistent( project );
commit( tx );
@@ -228,7 +213,7 @@
query.setFilter( "this.name == name" );
- Collection result = ( (Collection) query.execute( name ) );
+ Collection result = (Collection) query.execute( name );
if ( result.size() == 0 )
{
@@ -268,7 +253,7 @@
query.setFilter( "this.scmUrl == scmUrl" );
- Collection result = ( (Collection) query.execute( scmUrl ) );
+ Collection result = (Collection) query.execute( scmUrl );
if ( result.size() == 0 )
{
@@ -386,24 +371,7 @@
public String addSchedule( ContinuumSchedule schedule )
throws ContinuumStoreException
{
- PersistenceManager pm = pmf.getPersistenceManager();
-
- Transaction tx = pm.currentTransaction();
-
- try
- {
- tx.begin();
-
- schedule = (ContinuumSchedule) makePersistent( pm, schedule );
-
- commit( tx );
-
- return schedule.getId();
- }
- finally
- {
- rollback( tx );
- }
+ return ((ContinuumSchedule)addObject( schedule ) ).getId();
}
public ContinuumSchedule getSchedule( String projectId )
@@ -536,7 +504,7 @@
build.setProject( project );
- build = (ContinuumBuild) makePersistent( pm, build );
+ build = (ContinuumBuild) makePersistent( pm, build, false );
project.setLatestBuildId( build.getId() );
@@ -709,6 +677,42 @@
}
// ----------------------------------------------------------------------
+ // Project Groups
+ // ----------------------------------------------------------------------
+
+ public String addProjectGroup( ContinuumProjectGroup projectGroup )
+ throws ContinuumStoreException
+ {
+ return ((ContinuumProjectGroup)addObject( projectGroup )).getId();
+ }
+
+ public ContinuumProjectGroup getProjectGroup( String projectGroupId )
+ throws ContinuumStoreException
+ {
+ return (ContinuumProjectGroup) getDetailedObject( ContinuumProjectGroup.class,
+ projectGroupId,
+ "project-group-detail" );
+ }
+
+ // ----------------------------------------------------------------------
+ // Build Group
+ // ----------------------------------------------------------------------
+
+ public String addBuildGroup( ContinuumBuildGroup buildGroup )
+ throws ContinuumStoreException
+ {
+ return ((ContinuumBuildGroup) addObject( buildGroup )).getId();
+ }
+
+ public ContinuumBuildGroup getBuildGroup( String buildGroupId )
+ throws ContinuumStoreException
+ {
+ return (ContinuumBuildGroup) getDetailedObject( ContinuumBuildGroup.class,
+ buildGroupId,
+ "build-group-detail" );
+ }
+
+ // ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
@@ -773,18 +777,106 @@
return (ContinuumSchedule) pm.getObjectById( id );
}
- private Object makePersistent( PersistenceManager pm, Object object )
+ private ContinuumProjectGroup getContinuumProjectGroup( PersistenceManager pm,
+ String projectGroupId,
+ boolean details )
+ {
+ if ( details )
+ {
+ pm.getFetchPlan().addGroup( "project-group-detail" );
+ }
+
+ Object id = pm.newObjectIdInstance( ContinuumProjectGroup.class, projectGroupId );
+
+ ContinuumProjectGroup projectGroup = (ContinuumProjectGroup) pm.getObjectById( id );
+
+ return projectGroup;
+ }
+
+ // ----------------------------------------------------------------------
+ //
+ // ----------------------------------------------------------------------
+
+ private Object addObject( Object object )
+ {
+ PersistenceManager pm = pmf.getPersistenceManager();
+
+ Transaction tx = pm.currentTransaction();
+
+ try
+ {
+ tx.begin();
+
+ pm.makePersistent( object );
+
+ Object id = pm.getObjectId( object );
+
+ object = pm.getObjectById( id );
+
+ object = pm.detachCopy( object );
+
+ commit( tx );
+
+ return object;
+ }
+ finally
+ {
+ rollback( tx );
+ }
+ }
+
+ private Object makePersistent( PersistenceManager pm, Object object, boolean detach )
{
pm.makePersistent( object );
Object id = pm.getObjectId( object );
- return pm.getObjectById( id );
+ object = pm.getObjectById( id );
+
+ if ( detach )
+ {
+ object = pm.detachCopy( object );
+ }
+
+ return object;
}
private void makePersistentAll( PersistenceManager pm, Collection object )
{
pm.makePersistentAll( object );
+ }
+
+ private Object getDetailedObject( Class clazz, String id, String fetchGroup )
+ throws ContinuumObjectNotFoundException
+ {
+ PersistenceManager pm = pmf.getPersistenceManager();
+
+ Transaction tx = pm.currentTransaction();
+
+ try
+ {
+ tx.begin();
+
+ pm.getFetchPlan().addGroup( fetchGroup );
+
+ Object objectId = pm.newObjectIdInstance( clazz, id );
+
+ Object object = pm.getObjectById( objectId );
+
+ object = pm.detachCopy( object );
+
+ commit( tx );
+
+ return object;
+ }
+ catch ( JDOObjectNotFoundException e )
+ {
+ throw new ContinuumObjectNotFoundException( clazz.getName(), id );
+ }
+ finally
+ {
+ rollback( tx );
+ }
}
private void attachAndDelete( Object object )
Added: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store/NewModelTest.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store/NewModelTest.java?rev=219839&view=auto
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store/NewModelTest.java (added)
+++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store/NewModelTest.java Tue Jul 19 20:44:17 2005
@@ -0,0 +1,133 @@
+package org.apache.maven.continuum.store;
+
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.AbstractContinuumTest;
+import org.apache.maven.continuum.project.MavenTwoProject;
+import org.apache.maven.continuum.project.ContinuumProjectGroup;
+import org.apache.maven.continuum.project.ContinuumProject;
+import org.apache.maven.continuum.project.ContinuumBuildGroup;
+
+/**
+ * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
+ * @version $Id$
+ */
+public class NewModelTest
+ extends AbstractContinuumTest
+{
+ public void testBasic()
+ throws Exception
+ {
+ // ----------------------------------------------------------------------
+ // Create the missing group
+ // ----------------------------------------------------------------------
+
+ ContinuumProjectGroup plexusGroup = new ContinuumProjectGroup();
+
+ plexusGroup.setGroupId( "org.codehaus.plexus" );
+
+ plexusGroup.setName( "Plexus" );
+
+ String plexusGroupId = getStore().addProjectGroup( plexusGroup );
+
+ plexusGroup = getStore().getProjectGroup( plexusGroupId );
+
+ // ----------------------------------------------------------------------
+ // Add projects from URL metadata
+ // ----------------------------------------------------------------------
+
+ ContinuumProject componentA = makeStubMavenTwoProject( "component a", "a" );
+
+ componentA.setProjectGroup( plexusGroup );
+
+ String projectIdA = addMavenTwoProject( getStore(),
+ componentA );
+
+ ContinuumProject componentB = makeStubMavenTwoProject( "component b", "b" );
+
+ componentB.setProjectGroup( plexusGroup );
+
+ String projectIdB = addMavenTwoProject( getStore(),
+ componentB );
+
+ // ----------------------------------------------------------------------
+ //
+ // ----------------------------------------------------------------------
+
+ plexusGroup = getStore().getProjectGroup( plexusGroupId );
+
+ assertNotNull( plexusGroup.getProjects() );
+
+ assertEquals( 2, plexusGroup.getProjects().size() );
+
+ ContinuumProject plexusComponentA = getStore().getProject( projectIdA );
+
+ ContinuumProject plexusComponentB = getStore().getProject( projectIdB );
+
+ assertNotNull( plexusComponentA.getProjectGroup() );
+
+ assertNotNull( plexusComponentB.getProjectGroup() );
+
+ assertEquals( plexusGroup.getId(), plexusComponentA.getProjectGroup().getId() );
+
+ assertEquals( plexusGroup.getId(), plexusComponentB.getProjectGroup().getId() );
+
+ // ----------------------------------------------------------------------
+ //
+ // ----------------------------------------------------------------------
+
+ ContinuumBuildGroup buildGroup = new ContinuumBuildGroup();
+
+ buildGroup.setName( "Plexus Hey Yo");
+
+ String buildGroupId = getStore().addBuildGroup( buildGroup );
+
+ buildGroup = getStore().getBuildGroup( buildGroupId );
+
+ componentA.getBuildGroups().add( buildGroup );
+
+ getStore().updateProject( componentA );
+
+ componentA = getStore().getProject( componentA.getId() );
+
+ assertNotNull( componentA.getBuildGroups() );
+
+ assertEquals( 1, componentA.getBuildGroups().size() );
+
+ assertEquals( buildGroupId, ((ContinuumBuildGroup) componentA.getBuildGroups().iterator().next()).getId() );
+
+ // ----------------------------------------------------------------------
+ //
+ // ----------------------------------------------------------------------
+
+ getStore().removeProject( componentA.getId() );
+
+ getStore().removeProject( componentB.getId() );
+
+ buildGroup = getStore().getBuildGroup( buildGroupId );
+
+ assertNotNull( buildGroup );
+
+ assertEquals( 0, buildGroup.getProjects().size() );
+
+ plexusGroup = getStore().getProjectGroup( plexusGroupId );
+
+ assertNotNull( plexusGroup );
+
+// assertEquals( 0, plexusGroup.getProjects().size() );
+ }
+}
Propchange: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store/NewModelTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store/NewModelTest.java
------------------------------------------------------------------------------
svn:keywords = Id
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=219839&r1=219838&r2=219839&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 Tue Jul 19 20:44:17 2005
@@ -76,8 +76,8 @@
<field name="delay" persistence-modifier="persistent"/>
<field name="cronExpression" persistence-modifier="persistent"/>
<fetch-group name="schedule-detail">
- <field name="projects"/>
- </fetch-group>
+ <field name="projects"/>
+ </fetch-group>
</class>
<class name="ContinuumNotifier" detachable="true" identity-type="datastore">
@@ -142,6 +142,10 @@
<collection element-type="ContinuumBuildSettings"/>
<join/>
</field>
+ <fetch-group name="build-group-detail">
+ <field name="projects"/>
+ <field name="buildSettings"/>
+ </fetch-group>
</class>
<class name="ContinuumProjectGroup" detachable="true" identity-type="application">
@@ -158,6 +162,10 @@
<collection element-type="ContinuumBuildSettings"/>
<join/>
</field>
+ <fetch-group name="project-group-detail">
+ <field name="projects"/>
+ <field name="buildSettings"/>
+ </fetch-group>
</class>
<class name="ContinuumBuildSettings" detachable="true" identity-type="application">
@@ -202,16 +210,16 @@
<field name="revision" persistence-modifier="persistent"/>
</class>
</package>
-
+
<!-- Profiles -->
-
+
<package name="org.apache.maven.continuum.profile">
<class name="ContinuumProfile" detachable="true" identity-type="datastore">
<field name="jdk" persistence-modifier="persistent"/>
</class>
<class name="ContinuumJdk" detachable="true" identity-type="datastore">
<field name="version" persistence-modifier="persistent"/>
- <field name="home" persistence-modifier="persistent"/>
- </class>
- </package>
+ <field name="home" persistence-modifier="persistent"/>
+ </class>
+ </package>
</jdo>