continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ri...@apache.org
Subject svn commit: r600828 - in /maven/continuum/branches/continuum-jpa/continuum-model-jpa/src: main/java/org/apache/maven/continuum/model/project/ main/java/org/apache/maven/continuum/store/api/ main/java/org/apache/maven/continuum/store/jpa/ test/java/org/...
Date Tue, 04 Dec 2007 08:04:17 GMT
Author: rinku
Date: Tue Dec  4 00:04:14 2007
New Revision: 600828

URL: http://svn.apache.org/viewvc?rev=600828&view=rev
Log:
o  updates for ProjectNotifier.

Added:
    maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/store/api/ProjectNotifierQuery.java
  (with props)
    maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/store/jpa/JpaProjectNotifierStore.java
  (with props)
    maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/java/org/apache/maven/continuum/store/jpa/JpaProjectNotifierStoreTest.java
  (with props)
    maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/resources/sql/project-notifier-table-data.sql
Modified:
    maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/model/project/ProjectNotifier.java
    maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/store/api/ProjectQuery.java
    maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/store/jpa/JpaProjectStore.java
    maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/resources/META-INF/spring-config.xml

Modified: maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/model/project/ProjectNotifier.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/model/project/ProjectNotifier.java?rev=600828&r1=600827&r2=600828&view=diff
==============================================================================
--- maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/model/project/ProjectNotifier.java
(original)
+++ maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/model/project/ProjectNotifier.java
Tue Dec  4 00:04:14 2007
@@ -11,8 +11,9 @@
 import org.apache.maven.continuum.model.CommonUpdatableModelEntity;
 
 /**
- * 
  * Configures one method for notifying users/developers when a build breaks.
+ * <p>
+ * TODO: Review this to use discriminators for different Notifier extensions.
  * 
  * @version $Id$
  */

Added: maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/store/api/ProjectNotifierQuery.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/store/api/ProjectNotifierQuery.java?rev=600828&view=auto
==============================================================================
--- maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/store/api/ProjectNotifierQuery.java
(added)
+++ maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/store/api/ProjectNotifierQuery.java
Tue Dec  4 00:04:14 2007
@@ -0,0 +1,189 @@
+/**
+ * 
+ */
+package org.apache.maven.continuum.store.api;
+
+import java.util.Date;
+
+import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.model.project.ProjectGroup;
+import org.apache.maven.continuum.model.project.ProjectNotifier;
+
+/**
+ * @author <a href='mailto:rahul.thakur.xdev@gmail.com'>Rahul Thakur</a>
+ * @version $Id$
+ * @since 1.2
+ */
+public class ProjectNotifierQuery implements Query<ProjectNotifier>
+{
+
+    /**
+     * ProjectNotifier creation date criteria.
+     */
+    private Date dateCreated;
+
+    /**
+     * ProjectNotifier update date criteria.
+     */
+    private Date dateUpdated;
+
+    /**
+     * ProjectNotifier Id criteria.
+     */
+    private Long id;
+
+    /**
+     * Determines if a ProjectNotifier is set up on a {@link Project} or a {@link ProjectGroup}.
+     */
+    private boolean isDefinedOnProject = false;
+
+    /**
+     * Determines if a {@link ProjectNotifier} is defined by a user.
+     */
+    private boolean isUserDefined = false;
+
+    /**
+     * ProjectNotifier model encoding criteria.
+     */
+    private String modelEncoding;
+
+    /**
+     * @return
+     * 
+     */
+    public Date getDateCreated()
+    {
+        return this.dateCreated;
+    }
+
+    /**
+     * @return
+     * @see org.apache.maven.continuum.model.CommonUpdatableEntity#getDateUpdated()
+     */
+    public Date getDateUpdated()
+    {
+        return this.dateUpdated;
+    }
+
+    /**
+     * @return
+     */
+    public Long getId()
+    {
+        return this.id;
+    }
+
+    /**
+     * @return
+     */
+    public String getModelEncoding()
+    {
+        return this.modelEncoding;
+    }
+
+    /**
+     * Determine if a date of creation was specified in the query.
+     * 
+     * @return <code>true</code> if a date of creation was specified, else <code>false</code>.
+     */
+    public boolean hasDateCreated()
+    {
+        return ( null != this.dateCreated );
+    }
+
+    /**
+     * Determine if an update date was specified in the query.
+     * 
+     * @return <code>true</code> if a date of update was specified, else <code>false</code>.
+     */
+    public boolean hasDateUpdated()
+    {
+        return ( null != this.dateUpdated );
+    }
+
+    /**
+     * 
+     * @return
+     */
+    public boolean hasId()
+    {
+        return ( null != this.id && this.id.longValue() > 0L );
+    }
+
+    /**
+     * Determine if there was a model encoding specified in the query.
+     * 
+     * @return <code>true</code> if there was a model encoding specified, else
<code>false</code>.
+     */
+    public boolean hasModelEncoding()
+    {
+        return ( null != this.modelEncoding && this.modelEncoding.length() > 0
);
+    }
+
+    /**
+     * @return the isDefinedOnProject
+     */
+    public boolean isDefinedOnProject()
+    {
+        return isDefinedOnProject;
+    }
+
+    /**
+     * @return the isUserDefined
+     */
+    public boolean isUserDefined()
+    {
+        return isUserDefined;
+    }
+
+    /**
+     * @param dateCreated
+     */
+    public void setDateCreated( Date dateCreated )
+    {
+        this.dateCreated = dateCreated;
+    }
+
+    /**
+     * @param dateUpdated
+     */
+    public void setDateUpdated( Date dateUpdated )
+    {
+        this.dateUpdated = dateUpdated;
+    }
+
+    /**
+     * @param isDefinedOnProject
+     *            the isDefinedOnProject to set
+     */
+    public void setDefinedOnProject( boolean isDefinedOnProject )
+    {
+        this.isDefinedOnProject = isDefinedOnProject;
+    }
+
+    /**
+     * @param id
+     */
+    public void setId( Long id )
+    {
+        this.id = id;
+    }
+
+    /**
+     * @param modelEncoding
+     */
+    public void setModelEncoding( String modelEncoding )
+    {
+        this.modelEncoding = modelEncoding;
+    }
+
+    /**
+     * @param isUserDefined
+     *            the isUserDefined to set
+     */
+    public void setUserDefined( boolean isUserDefined )
+    {
+        this.isUserDefined = isUserDefined;
+    }
+
+}

Propchange: maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/store/api/ProjectNotifierQuery.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/store/api/ProjectNotifierQuery.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/store/api/ProjectQuery.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/store/api/ProjectQuery.java?rev=600828&r1=600827&r2=600828&view=diff
==============================================================================
--- maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/store/api/ProjectQuery.java
(original)
+++ maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/store/api/ProjectQuery.java
Tue Dec  4 00:04:14 2007
@@ -3,6 +3,8 @@
  */
 package org.apache.maven.continuum.store.api;
 
+import java.util.Date;
+
 import org.apache.maven.continuum.model.project.Project;
 
 /**
@@ -16,9 +18,9 @@
 {
 
     /**
-     * Project id criteria.
+     * Project artifactId criteria.
      */
-    private Long id;
+    private String artifactId;
 
     /**
      * Project groupId criteria.
@@ -26,55 +28,108 @@
     private String groupId;
 
     /**
-     * Project artifactId criteria.
+     * Project id criteria.
      */
-    private String artifactId;
+    private Long id;
+
+    /**
+     * Project name criteria.
+     */
+    private String name;
 
     /**
      * Project Artifact version criteria.
      */
     private String version;
 
+    private int buildNumber;
+
+    private Date dateCreated;
+
+    private Date dateUpdated;
+
+    private String description;
+
+    private String modelEncoding;
+
     /**
-     * Project name criteria.
+     * @return the artifactId
      */
-    private String name;
+    public String getArtifactId()
+    {
+        return this.artifactId;
+    }
 
     /**
-     * Determines if a Project id criteria was specified in the query.
+     * @return build number as query critera
+     */
+    public int getBuildNumber()
+    {
+        return this.buildNumber;
+    }
+
+    /**
+     * Determines if a build number criteria was specified in the Project query.
      * 
      * @return
      */
-    public boolean hasId()
+    public boolean hasBuildNumber()
     {
-        return ( null != this.id && this.id >= 0 );
+        return ( this.buildNumber > 0 );
     }
 
     /**
-     * @return the id
+     * @return creation date as query criteria
      */
-    public Long getId()
+    public Date getDateCreated()
     {
-        return this.id;
+        return this.dateCreated;
     }
 
     /**
-     * @param id
-     *            the id to set
+     * Determines if there was a creation date criteria specified in the ProjectQuery.
+     * 
+     * @return <code>true</code> if a creation date was specified, else <code>false</code>.
      */
-    public void setId( Long id )
+    public boolean hasDateCreated()
     {
-        this.id = id;
+        return ( null != this.dateCreated );
     }
 
     /**
-     * Determines if a ProjectGroup Id criteria was specified.
+     * @return last update date from query criteria.
+     */
+    public Date getDateUpdated()
+    {
+        return this.dateUpdated;
+    }
+
+    /**
+     * Determine if there was a last update date criteria specified in the ProjectQuery.
      * 
-     * @return
+     * @return <code>true</code> if there was a last update date criteria specified,
else <code>false</code>.
      */
-    public boolean hasGroupId()
+    public boolean hasDateUpdated()
     {
-        return ( null != this.groupId );
+        return ( null != this.dateUpdated );
+    }
+
+    /**
+     * @return description criteria from the query.
+     */
+    public String getDescription()
+    {
+        return this.description;
+    }
+
+    /**
+     * Determines if there was description criteria specified in the ProjectQuery.
+     * 
+     * @return <code>true</code> if there was description criteria specified,
else <code>false</code>.
+     */
+    public boolean hasDescription()
+    {
+        return ( null != this.description && this.description.length() > 0 );
     }
 
     /**
@@ -86,12 +141,45 @@
     }
 
     /**
-     * @param groupId
-     *            the groupId to set
+     * @return the id
      */
-    public void setGroupId( String groupId )
+    public Long getId()
     {
-        this.groupId = groupId;
+        return this.id;
+    }
+
+    /**
+     * @return model encoding criteria from the query.
+     */
+    public String getModelEncoding()
+    {
+        return this.modelEncoding;
+    }
+
+    /**
+     * Determine if there is a model encoding specified in the ProjectQuery.
+     * 
+     * @return <code>true</code> if there is a model encoding specified, else
<code>false</code>.
+     */
+    public boolean hasModelEncoding()
+    {
+        return ( null != this.modelEncoding && this.modelEncoding.length() > 0
);
+    }
+
+    /**
+     * @return the name
+     */
+    public String getName()
+    {
+        return this.name;
+    }
+
+    /**
+     * @return the version
+     */
+    public String getVersion()
+    {
+        return this.version;
     }
 
     /**
@@ -105,20 +193,33 @@
     }
 
     /**
-     * @return the artifactId
+     * Determines if a ProjectGroup Id criteria was specified.
+     * 
+     * @return
      */
-    public String getArtifactId()
+    public boolean hasGroupId()
     {
-        return this.artifactId;
+        return ( null != this.groupId );
     }
 
     /**
-     * @param artifactId
-     *            the artifactId to set
+     * Determines if a Project id criteria was specified in the query.
+     * 
+     * @return
      */
-    public void setArtifactId( String artifactId )
+    public boolean hasId()
     {
-        this.artifactId = artifactId;
+        return ( null != this.id && this.id >= 0 );
+    }
+
+    /**
+     * Determines if a project name criteria was specified.
+     * 
+     * @return
+     */
+    public boolean hasName()
+    {
+        return ( null != this.name );
     }
 
     /**
@@ -132,38 +233,74 @@
     }
 
     /**
-     * @return the version
+     * @param artifactId
+     *            the artifactId to set
      */
-    public String getVersion()
+    public void setArtifactId( String artifactId )
     {
-        return this.version;
+        this.artifactId = artifactId;
     }
 
     /**
-     * @param version
-     *            the version to set
+     * @param buildNumber
+     *            criteria to set in the ProjectQuery
      */
-    public void setVersion( String version )
+    public void setBuildNumber( int buildNumber )
     {
-        this.version = version;
+        this.buildNumber = buildNumber;
     }
 
     /**
-     * Determines if a project name criteria was specified.
-     * 
-     * @return
+     * @param created
+     *            criteria to set in the Project Query.
      */
-    public boolean hasName()
+    public void setDateCreated( Date dateCreated )
     {
-        return ( null != this.name );
+        this.dateCreated = dateCreated;
     }
 
     /**
-     * @return the name
+     * @param updated
+     *            date criteria to set in the Project Query.
      */
-    public String getName()
+    public void setDateUpdated( Date dateUpdated )
     {
-        return this.name;
+        this.dateUpdated = dateUpdated;
+    }
+
+    /**
+     * @param description
+     */
+    public void setDescription( String description )
+    {
+        this.description = description;
+    }
+
+    /**
+     * @param groupId
+     *            the groupId to set
+     */
+    public void setGroupId( String groupId )
+    {
+        this.groupId = groupId;
+    }
+
+    /**
+     * @param id
+     *            the id to set
+     */
+    public void setId( Long id )
+    {
+        this.id = id;
+    }
+
+    /**
+     * @param modelEncoding
+     * @see org.apache.maven.continuum.model.CommonUpdatableModelEntity#setModelEncoding(java.lang.String)
+     */
+    public void setModelEncoding( String modelEncoding )
+    {
+        this.modelEncoding = modelEncoding;
     }
 
     /**
@@ -173,6 +310,15 @@
     public void setName( String name )
     {
         this.name = name;
+    }
+
+    /**
+     * @param version
+     *            the version to set
+     */
+    public void setVersion( String version )
+    {
+        this.version = version;
     }
 
 }

Added: maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/store/jpa/JpaProjectNotifierStore.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/store/jpa/JpaProjectNotifierStore.java?rev=600828&view=auto
==============================================================================
--- maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/store/jpa/JpaProjectNotifierStore.java
(added)
+++ maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/store/jpa/JpaProjectNotifierStore.java
Tue Dec  4 00:04:14 2007
@@ -0,0 +1,122 @@
+/**
+ * 
+ */
+package org.apache.maven.continuum.store.jpa;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.maven.continuum.model.project.ProjectNotifier;
+import org.apache.maven.continuum.store.api.EntityNotFoundException;
+import org.apache.maven.continuum.store.api.ProjectNotifierQuery;
+import org.apache.maven.continuum.store.api.Store;
+import org.apache.maven.continuum.store.api.StoreException;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * @author <a href='mailto:rahul.thakur.xdev@gmail.com'>Rahul Thakur</a>
+ * @version $Id$
+ * @since 1.2
+ */
+public class JpaProjectNotifierStore extends StoreSupport implements Store<ProjectNotifier,
ProjectNotifierQuery>
+{
+
+    /**
+     * @{inheritDoc}
+     * 
+     * @see org.apache.maven.continuum.store.api.Store#delete(java.lang.Object)
+     */
+    @Transactional( readOnly = false )
+    public void delete( ProjectNotifier entity ) throws StoreException
+    {
+        getJpaTemplate().remove( entity );
+    }
+
+    /**
+     * @{inheritDoc}
+     * 
+     * @see org.apache.maven.continuum.store.api.Store#lookup(java.lang.Long)
+     */
+    public ProjectNotifier lookup( Long id ) throws StoreException, EntityNotFoundException
+    {
+        return lookup( ProjectNotifier.class, id );
+    }
+
+    /**
+     * @{inheritDoc}
+     * 
+     * @see org.apache.maven.continuum.store.api.Store#query(org.apache.maven.continuum.store.api.Query)
+     */
+    public List<ProjectNotifier> query( ProjectNotifierQuery query ) throws StoreException
+    {
+        Map<String, Object> where = new HashMap<String, Object>();
+        StringBuffer sb = new StringBuffer();
+
+        if ( query.hasId() )
+        {
+            where.put( "id", query.getId() );
+            if ( sb.length() > 0 )
+                sb.append( "and" );
+            sb.append( " notifier.id =:id " );
+        }
+        if ( query.hasDateCreated() )
+        {
+            where.put( "dateCreated", query.getDateCreated() );
+            if ( sb.length() > 0 )
+                sb.append( "and" );
+            sb.append( " notifier.dateCreated =:dateCreated " );
+        }
+        if ( query.hasDateUpdated() )
+        {
+            where.put( "dateUpdated", query.getDateUpdated() );
+            if ( sb.length() > 0 )
+                sb.append( "and" );
+            sb.append( " notifier.dateUpdated =:dateUpdated " );
+        }
+        if ( query.hasModelEncoding() )
+        {
+            where.put( "modelEncoding", query.getModelEncoding() );
+            if ( sb.length() > 0 )
+                sb.append( "and" );
+            sb.append( " notifier.modelEncoding =:modelEncoding " );
+        }
+        if ( query.isDefinedOnProject() )
+        {
+            // TODO: Implement!
+            // Need to check what property is setup on the Notifier.
+            // May need to add a property ORM mapping to persist.
+        }
+        if ( query.isUserDefined() )
+        {
+            // TODO: Implement!
+            // Need to check what property is setup on the Notifier.
+            // May need to add a property ORM mapping to persist.
+        }
+
+        String whereClause = ( sb.length() > 0 ? " where " : "" ) + sb.toString();
+
+        List<ProjectNotifier> results =
+            find( "select notifier from ProjectNotifier as notifier " + whereClause, where,
0, 0 );
+
+        return results;
+    }
+
+    /**
+     * @{inheritDoc}
+     * 
+     * @see org.apache.maven.continuum.store.api.Store#save(java.lang.Object)
+     */
+    public ProjectNotifier save( ProjectNotifier entity ) throws StoreException
+    {
+        if ( null != entity )
+        {
+            if ( null == entity.getId() )
+                getJpaTemplate().persist( entity );
+            else
+                entity = getJpaTemplate().merge( entity );
+        }
+        return entity;
+    }
+
+}

Propchange: maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/store/jpa/JpaProjectNotifierStore.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/store/jpa/JpaProjectNotifierStore.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/store/jpa/JpaProjectStore.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/store/jpa/JpaProjectStore.java?rev=600828&r1=600827&r2=600828&view=diff
==============================================================================
--- maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/store/jpa/JpaProjectStore.java
(original)
+++ maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/main/java/org/apache/maven/continuum/store/jpa/JpaProjectStore.java
Tue Dec  4 00:04:14 2007
@@ -3,9 +3,12 @@
  */
 package org.apache.maven.continuum.store.jpa;
 
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.model.project.ProjectGroup;
 import org.apache.maven.continuum.store.api.EntityNotFoundException;
 import org.apache.maven.continuum.store.api.ProjectQuery;
 import org.apache.maven.continuum.store.api.Store;
@@ -66,8 +69,85 @@
      */
     public List<Project> query( ProjectQuery query ) throws StoreException
     {
-        // TODO Auto-generated method stub
-        return null;
+        Map<String, Object> where = new HashMap<String, Object>();
+        StringBuffer sb = new StringBuffer();
+
+        if ( query.hasId() )
+        {
+            where.put( "id", query.getId() );
+            if ( sb.length() > 0 )
+                sb.append( "and" );
+            sb.append( " project.id =:id " );
+        }
+        if ( query.hasDateCreated() )
+        {
+            where.put( "dateCreated", query.getDateCreated() );
+            if ( sb.length() > 0 )
+                sb.append( "and" );
+            sb.append( " project.dateCreated =:dateCreated " );
+        }
+        if ( query.hasDateUpdated() )
+        {
+            where.put( "dateUpdated", query.getDateUpdated() );
+            if ( sb.length() > 0 )
+                sb.append( "and" );
+            sb.append( " project.dateUpdated =:dateUpdated " );
+        }
+        if ( query.hasDescription() )
+        {
+            where.put( "description", query.getDescription() );
+            if ( sb.length() > 0 )
+                sb.append( "and" );
+            sb.append( " project.description =:description " );
+        }
+        if ( query.hasGroupId() )
+        {
+            where.put( "groupId", query.getGroupId() );
+            if ( sb.length() > 0 )
+                sb.append( "and" );
+            sb.append( " project.groupId =:groupId " );
+        }
+        if ( query.hasModelEncoding() )
+        {
+            where.put( "modelEncoding", query.getModelEncoding() );
+            if ( sb.length() > 0 )
+                sb.append( "and" );
+            sb.append( " project.modelEncoding =:modelEncoding " );
+        }
+        if ( query.hasName() )
+        {
+            where.put( "name", query.getName() );
+            if ( sb.length() > 0 )
+                sb.append( "and" );
+            sb.append( " project.name =:name " );
+        }
+        if ( query.hasArtifactId() )
+        {
+            where.put( "artifactId", query.getArtifactId() );
+            if ( sb.length() > 0 )
+                sb.append( "and" );
+            sb.append( " project.artifactId =:artifactId" );
+        }
+        if ( query.hasBuildNumber() )
+        {
+            where.put( "buildNumber", query.getBuildNumber() );
+            if ( sb.length() > 0 )
+                sb.append( "and" );
+            sb.append( " project.buildNumber =:buildNumber" );
+        }
+        if ( query.hasVersion() )
+        {
+            where.put( "version", query.getVersion() );
+            if ( sb.length() > 0 )
+                sb.append( "and" );
+            sb.append( " project.version =:version" );
+        }
+
+        String whereClause = ( sb.length() > 0 ? " where " : "" ) + sb.toString();
+
+        List<Project> results = find( "select project from Project as project " + whereClause,
where, 0, 0 );
+
+        return results;
     }
 
 }

Added: maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/java/org/apache/maven/continuum/store/jpa/JpaProjectNotifierStoreTest.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/java/org/apache/maven/continuum/store/jpa/JpaProjectNotifierStoreTest.java?rev=600828&view=auto
==============================================================================
--- maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/java/org/apache/maven/continuum/store/jpa/JpaProjectNotifierStoreTest.java
(added)
+++ maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/java/org/apache/maven/continuum/store/jpa/JpaProjectNotifierStoreTest.java
Tue Dec  4 00:04:14 2007
@@ -0,0 +1,76 @@
+/**
+ * 
+ */
+package org.apache.maven.continuum.store.jpa;
+
+import java.io.File;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.maven.continuum.model.project.ProjectGroup;
+import org.apache.maven.continuum.model.project.ProjectNotifier;
+import org.apache.maven.continuum.store.ApplicationContextAwareStoreTestCase;
+import org.apache.maven.continuum.store.api.ProjectNotifierQuery;
+import org.apache.maven.continuum.store.api.Store;
+import org.apache.maven.continuum.store.api.StoreException;
+import org.apache.openjpa.persistence.OpenJPAQuery;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+/**
+ * @author <a href='mailto:rahul.thakur.xdev@gmail.com'>Rahul Thakur</a>
+ * @version $Id$
+ * @since 1.2
+ */
+@RunWith( SpringJUnit4ClassRunner.class )
+@ContextConfiguration( locations = "/META-INF/spring-config.xml" )
+public class JpaProjectNotifierStoreTest extends ApplicationContextAwareStoreTestCase
+{
+    private static final String BEAN_REF__PROJECT_NOTIFIER_STORE = "projectNotifierStore";
+
+    @Override
+    @Before
+    public void setUp()
+    {
+        File testData = new File( "src/test/resources/sql/project-notifier-table-data.sql"
);
+        Assert.assertTrue( "Unable to find test data resource: " + testData.getAbsolutePath(),
testData.exists() );
+        Properties propMap = new Properties();
+        setUp( propMap );
+
+        // load test data from SQL file.
+        setSqlSource( testData );
+    }
+
+    @Test
+    public void testOpenJPASetup()
+    {
+        OpenJPAQuery q = em.createQuery( "select n from ProjectNotifier n" );
+        String[] sql = q.getDataStoreActions( null );
+        Assert.assertEquals( 0, sql.length );
+        Assert.assertTrue( sql[0].startsWith( "SELECT" ) );
+        List results = q.getResultList();
+        Assert.assertNotNull( results );
+        Assert.assertEquals( 1, results.size() );
+    }
+
+    @Test
+    public void testCreateProjectNotifier() throws StoreException
+    {
+        ProjectNotifier notifier = new ProjectNotifier();
+        notifier.setModelEncoding( "UTF-8" );        
+        Assert.assertTrue( null == notifier.getId() );
+        notifier = getProjectNotifierStore().save( notifier );
+        Assert.assertTrue( null != notifier.getId() );
+        Assert.assertTrue( notifier.getId() > 0L );        
+    }
+
+    private Store<ProjectNotifier, ProjectNotifierQuery> getProjectNotifierStore()
+    {
+        Store<ProjectNotifier, ProjectNotifierQuery> store = getStore( BEAN_REF__PROJECT_NOTIFIER_STORE
);
+        return store;
+    }
+}

Propchange: maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/java/org/apache/maven/continuum/store/jpa/JpaProjectNotifierStoreTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/java/org/apache/maven/continuum/store/jpa/JpaProjectNotifierStoreTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/resources/META-INF/spring-config.xml
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/resources/META-INF/spring-config.xml?rev=600828&r1=600827&r2=600828&view=diff
==============================================================================
--- maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/resources/META-INF/spring-config.xml
(original)
+++ maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/resources/META-INF/spring-config.xml
Tue Dec  4 00:04:14 2007
@@ -58,4 +58,18 @@
     </property>
   </bean>
 
+  <bean id="projectNotifierStoreTarget"
+    class="org.apache.maven.continuum.store.jpa.JpaProjectGroupStore">
+    <property name="entityManagerFactory" ref="entityManagerFactory" />
+  </bean>
+
+  <bean id="projectNotifierStore"
+    class="org.springframework.aop.framework.ProxyFactoryBean">
+    <property name="targetName" value="projectNotifierStoreTarget" />
+    <property name="autodetectInterfaces" value="true" />
+    <property name="interceptorNames">
+      <idref local="transactionInterceptor" />
+    </property>
+  </bean>
+
 </beans>

Added: maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/resources/sql/project-notifier-table-data.sql
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/resources/sql/project-notifier-table-data.sql?rev=600828&view=auto
==============================================================================
--- maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/resources/sql/project-notifier-table-data.sql
(added)
+++ maven/continuum/branches/continuum-jpa/continuum-model-jpa/src/test/resources/sql/project-notifier-table-data.sql
Tue Dec  4 00:04:14 2007
@@ -0,0 +1 @@
+# Test data for Project Notifier tests
\ No newline at end of file



Mime
View raw message