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

COVERAGE SUMMARY FOR SOURCE FILE [ProjectScmRootDaoImpl.java]

nameclass, %method, %block, %line, %
ProjectScmRootDaoImpl.java100% (1/1)62%  (5/8)77%  (117/152)82%  (30.4/37)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ProjectScmRootDaoImpl100% (1/1)62%  (5/8)77%  (117/152)82%  (30.4/37)
getAllProjectScmRoots (): List 0%   (0/1)0%   (0/4)0%   (0/1)
getProjectScmRoot (int): ProjectScmRoot 0%   (0/1)0%   (0/6)0%   (0/1)
updateProjectScmRoot (ProjectScmRoot): void 0%   (0/1)0%   (0/4)0%   (0/2)
getProjectScmRootByProjectGroupAndScmRootAddress (int, String): ProjectScmRoot 100% (1/1)81%  (62/77)87%  (16.5/19)
getProjectScmRootByProjectGroup (int): List 100% (1/1)88%  (43/49)99%  (9.9/10)
ProjectScmRootDaoImpl (): void 100% (1/1)100% (3/3)100% (1/1)
addProjectScmRoot (ProjectScmRoot): ProjectScmRoot 100% (1/1)100% (5/5)100% (1/1)
removeProjectScmRoot (ProjectScmRoot): 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.project.ProjectScmRoot;
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 * @version $Id: $
38 *  @plexus.component role="org.apache.continuum.dao.ProjectScmRootDao"
39 */
40@Repository("projectScmRootDao")
41public class ProjectScmRootDaoImpl
42    extends AbstractDao
43    implements ProjectScmRootDao
44{
45    public ProjectScmRoot addProjectScmRoot( ProjectScmRoot projectScmRoot )
46        throws ContinuumStoreException
47    {
48        return (ProjectScmRoot) addObject( projectScmRoot );
49    }
50 
51    public List<ProjectScmRoot> getAllProjectScmRoots()
52    {
53        return getAllObjectsDetached( ProjectScmRoot.class );
54    }
55    
56    public List<ProjectScmRoot> getProjectScmRootByProjectGroup( int projectGroupId )
57    {
58        PersistenceManager pm = getPersistenceManager();
59 
60        Transaction tx = pm.currentTransaction();
61 
62        try
63        {
64            tx.begin();
65 
66            Extent extent = pm.getExtent( ProjectScmRoot.class, true );
67 
68            Query query = pm.newQuery( extent, "projectGroup.id == " + projectGroupId );
69 
70            List result = (List) query.execute();
71 
72            result = (List) pm.detachCopyAll( result );
73 
74            tx.commit();
75 
76            return result;
77        }
78        finally
79        {
80            rollback( tx );
81        }
82    }
83 
84    public void removeProjectScmRoot( ProjectScmRoot projectScmRoot )
85        throws ContinuumStoreException
86    {
87        removeObject( projectScmRoot );
88    }
89 
90    public void updateProjectScmRoot( ProjectScmRoot projectScmRoot )
91        throws ContinuumStoreException
92    {
93        updateObject( projectScmRoot );
94    }
95 
96    public ProjectScmRoot getProjectScmRootByProjectGroupAndScmRootAddress( int projectGroupId, String scmRootAddress )
97        throws ContinuumStoreException
98    {
99        PersistenceManager pm = getPersistenceManager();
100 
101        Transaction tx = pm.currentTransaction();
102 
103        try
104        {
105            tx.begin();
106 
107            Extent extent = pm.getExtent( ProjectScmRoot.class, true );
108 
109            Query query = pm.newQuery( extent );
110 
111            query.declareImports( "import java.lang.String" );
112 
113            query.declareParameters( "int projectGroupId, String scmRootAddress" );
114 
115            query.setFilter( "this.projectGroup.id == projectGroupId && this.scmRootAddress == scmRootAddress" );
116 
117            Object[] params = new Object[2];
118            params[0] = projectGroupId;
119            params[1] = scmRootAddress;
120            
121            Collection result = (Collection) query.executeWithArray( params );
122 
123            if ( result.size() == 0 )
124            {
125                tx.commit();
126 
127                return null;
128            }
129 
130            Object object = pm.detachCopy( result.iterator().next() );
131 
132            tx.commit();
133 
134            return (ProjectScmRoot) object;
135        }
136        finally
137        {
138            rollback( tx );
139        }
140    }
141    
142    public ProjectScmRoot getProjectScmRoot( int projectScmRootId )
143        throws ContinuumObjectNotFoundException, ContinuumStoreException
144    {
145        return (ProjectScmRoot) getObjectById( ProjectScmRoot.class, projectScmRootId );
146    }
147}

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