EMMA Coverage Report (generated Sun Sep 18 11:34:27 PHT 2011)
[all classes][org.apache.continuum.dao]

COVERAGE SUMMARY FOR SOURCE FILE [ContinuumReleaseResultDaoImpl.java]

nameclass, %method, %block, %line, %
ContinuumReleaseResultDaoImpl.java100% (1/1)50%  (4/8)8%   (16/207)11%  (5/47)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ContinuumReleaseResultDaoImpl100% (1/1)50%  (4/8)8%   (16/207)11%  (5/47)
getContinuumReleaseResult (int): ContinuumReleaseResult 0%   (0/1)0%   (0/6)0%   (0/1)
getContinuumReleaseResult (int, String, long, long): ContinuumReleaseResult 0%   (0/1)0%   (0/87)0%   (0/21)
getContinuumReleaseResultsByProject (int): List 0%   (0/1)0%   (0/49)0%   (0/10)
getContinuumReleaseResultsByProjectGroup (int): List 0%   (0/1)0%   (0/49)0%   (0/10)
ContinuumReleaseResultDaoImpl (): void 100% (1/1)100% (3/3)100% (1/1)
addContinuumReleaseResult (ContinuumReleaseResult): ContinuumReleaseResult 100% (1/1)100% (5/5)100% (1/1)
getAllContinuumReleaseResults (): List 100% (1/1)100% (4/4)100% (1/1)
removeContinuumReleaseResult (ContinuumReleaseResult): void 100% (1/1)100% (4/4)100% (2/2)

1package org.apache.continuum.dao;
2 
3/*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements.  See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership.  The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License.  You may obtain a copy of the License at
11 *
12 *   http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied.  See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21 
22import java.util.Collection;
23import java.util.List;
24 
25import javax.jdo.Extent;
26import javax.jdo.PersistenceManager;
27import javax.jdo.Query;
28import javax.jdo.Transaction;
29 
30import org.apache.continuum.model.release.ContinuumReleaseResult;
31import org.apache.maven.continuum.store.ContinuumObjectNotFoundException;
32import org.apache.maven.continuum.store.ContinuumStoreException;
33import org.springframework.stereotype.Repository;
34 
35/**
36 * @author <a href="mailto:ctan@apache.org">Maria Catherine Tan</a>
37 * @plexus.component role="org.apache.continuum.dao.ContinuumReleaseResultDao"
38 */
39@Repository("continuumReleaseResultDao")
40public class ContinuumReleaseResultDaoImpl
41    extends AbstractDao
42    implements ContinuumReleaseResultDao
43{
44    public ContinuumReleaseResult addContinuumReleaseResult( ContinuumReleaseResult releaseResult )
45        throws ContinuumStoreException
46    {
47        return (ContinuumReleaseResult) addObject( releaseResult );
48    }
49 
50    public List<ContinuumReleaseResult> getAllContinuumReleaseResults()
51    {
52        return getAllObjectsDetached( ContinuumReleaseResult.class );
53    }
54 
55    public ContinuumReleaseResult getContinuumReleaseResult( int releaseResultId )
56        throws ContinuumObjectNotFoundException, ContinuumStoreException
57    {
58        return (ContinuumReleaseResult) getObjectById( ContinuumReleaseResult.class, releaseResultId );
59    }
60 
61    public ContinuumReleaseResult getContinuumReleaseResult( int projectId, String releaseGoal, long startTime, long endTime )
62        throws ContinuumStoreException
63    {
64        PersistenceManager pm = getPersistenceManager();
65 
66        Transaction tx = pm.currentTransaction();
67 
68        try
69        {
70            tx.begin();
71            
72            Extent extent = pm.getExtent( ContinuumReleaseResult.class, true );
73 
74            Query query = pm.newQuery( extent );
75 
76            query.declareImports( "import java.lang.String" );
77            
78            query.declareParameters( "int projectId, String releaseGoal, long startTime, long endTime" );
79            
80            query.setFilter( "this.project.id == projectId && this.releaseGoal == releaseGoal && this.startTime == startTime && this.endTime == endTime" );
81            
82            Object[] params = new Object[4];
83            params[0] = projectId;
84            params[1] = releaseGoal;
85            params[2] = startTime;
86            params[3] = endTime;
87 
88            Collection result = (Collection) query.executeWithArray( params );
89 
90            if ( result.size() == 0 )
91            {
92                tx.commit();
93 
94                return null;
95            }
96 
97            Object object = pm.detachCopy( result.iterator().next() );
98 
99            tx.commit();
100            
101            return (ContinuumReleaseResult) object;
102        }
103        finally
104        {
105            rollback( tx );
106        }
107 
108    }
109    
110    public List<ContinuumReleaseResult> getContinuumReleaseResultsByProjectGroup( int projectGroupId )
111    {
112        PersistenceManager pm = getPersistenceManager();
113 
114        Transaction tx = pm.currentTransaction();
115 
116        try
117        {
118            tx.begin();
119 
120            Extent extent = pm.getExtent( ContinuumReleaseResult.class, true );
121 
122            Query query = pm.newQuery( extent, "projectGroup.id == " + projectGroupId );
123 
124            List result = (List) query.execute();
125 
126            result = (List) pm.detachCopyAll( result );
127 
128            tx.commit();
129 
130            return result;
131        }
132        finally
133        {
134            rollback( tx );
135        }
136    }
137 
138    public List<ContinuumReleaseResult> getContinuumReleaseResultsByProject( int projectId )
139    {
140        PersistenceManager pm = getPersistenceManager();
141 
142        Transaction tx = pm.currentTransaction();
143 
144        try
145        {
146            tx.begin();
147 
148            Extent extent = pm.getExtent( ContinuumReleaseResult.class, true );
149 
150            Query query = pm.newQuery( extent, "project.id == " + projectId );
151 
152            List result = (List) query.execute();
153 
154            result = (List) pm.detachCopyAll( result );
155 
156            tx.commit();
157 
158            return result;
159        }
160        finally
161        {
162            rollback( tx );
163        }
164    }
165 
166    public void removeContinuumReleaseResult( ContinuumReleaseResult releaseResult )
167        throws ContinuumStoreException
168    {
169        removeObject( releaseResult );
170    }
171 
172}

[all classes][org.apache.continuum.dao]
EMMA 2.0.5312 (C) Vladimir Roubtsov