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

COVERAGE SUMMARY FOR SOURCE FILE [BuildQueueDaoImpl.java]

nameclass, %method, %block, %line, %
BuildQueueDaoImpl.java100% (1/1)50%  (4/8)34%  (47/137)33%  (10.9/33)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class BuildQueueDaoImpl100% (1/1)50%  (4/8)34%  (47/137)33%  (10.9/33)
getBuildQueue (int): BuildQueue 0%   (0/1)0%   (0/6)0%   (0/1)
getBuildQueueByName (String): BuildQueue 0%   (0/1)0%   (0/65)0%   (0/16)
removeBuildQueue (BuildQueue): void 0%   (0/1)0%   (0/4)0%   (0/2)
storeBuildQueue (BuildQueue): BuildQueue 0%   (0/1)0%   (0/5)0%   (0/2)
getAllBuildQueues (): List 100% (1/1)78%  (35/45)88%  (7.9/9)
<static initializer> 100% (1/1)100% (4/4)100% (1/1)
BuildQueueDaoImpl (): void 100% (1/1)100% (3/3)100% (1/1)
addBuildQueue (BuildQueue): BuildQueue 100% (1/1)100% (5/5)100% (1/1)

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.Collections;
24import java.util.List;
25 
26import javax.jdo.Extent;
27import javax.jdo.PersistenceManager;
28import javax.jdo.Query;
29import javax.jdo.Transaction;
30 
31import org.apache.maven.continuum.model.project.BuildQueue;
32import org.apache.maven.continuum.store.ContinuumStoreException;
33import org.slf4j.Logger;
34import org.slf4j.LoggerFactory;
35import org.springframework.stereotype.Repository;
36 
37/**
38 * 
39 * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
40 * @plexus.component role="org.apache.continuum.dao.BuildQueueDao"
41 */
42@Repository("buildQueueDao")
43public class BuildQueueDaoImpl
44    extends AbstractDao
45    implements BuildQueueDao
46{
47    private static Logger log = LoggerFactory.getLogger( BuildQueueDaoImpl.class );
48 
49    public BuildQueue addBuildQueue( BuildQueue buildQueue )
50        throws ContinuumStoreException
51    {
52        return (BuildQueue) addObject( buildQueue );
53    }
54 
55    public List<BuildQueue> getAllBuildQueues()
56        throws ContinuumStoreException
57    {
58        PersistenceManager pm = getPersistenceManager();
59 
60        Transaction tx = pm.currentTransaction();
61 
62        try
63        {
64            tx.begin();
65 
66            Extent extent = pm.getExtent( BuildQueue.class, true );
67 
68            Query query = pm.newQuery( extent );
69 
70            List result = (List) query.execute();
71 
72            return result == null ? Collections.EMPTY_LIST : (List<BuildQueue>) pm.detachCopyAll( result );
73        }
74        finally
75        {
76            tx.commit();
77 
78            rollback( tx );
79        }
80    }
81 
82    public BuildQueue getBuildQueue( int buildQueueId )
83        throws ContinuumStoreException
84    {
85        return (BuildQueue) getObjectById( BuildQueue.class, buildQueueId );
86    }
87 
88    public BuildQueue getBuildQueueByName( String name )
89        throws ContinuumStoreException
90    {
91        PersistenceManager pm = getPersistenceManager();
92 
93        Transaction tx = pm.currentTransaction();
94 
95        try
96        {
97            tx.begin();
98 
99            Extent extent = pm.getExtent( BuildQueue.class, true );
100 
101            Query query = pm.newQuery( extent );
102 
103            query.declareImports( "import java.lang.String" );
104 
105            query.declareParameters( "String name" );
106 
107            query.setFilter( "this.name == name" );
108 
109            Collection result = (Collection) query.execute( name );
110 
111            if ( result.size() == 0 )
112            {
113                tx.commit();
114 
115                return null;
116            }
117 
118            Object object = pm.detachCopy( result.iterator().next() );
119 
120            tx.commit();
121 
122            return (BuildQueue) object;
123        }
124        finally
125        {
126            rollback( tx );
127        }
128    }
129    
130    public void removeBuildQueue( BuildQueue buildQueue )
131        throws ContinuumStoreException
132    {
133        removeObject( buildQueue );
134    }
135 
136    public BuildQueue storeBuildQueue( BuildQueue buildQueue )
137        throws ContinuumStoreException
138    {
139        updateObject( buildQueue );
140 
141        return buildQueue;
142    }
143}

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