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

COVERAGE SUMMARY FOR SOURCE FILE [LocalRepositoryDaoImpl.java]

nameclass, %method, %block, %line, %
LocalRepositoryDaoImpl.java100% (1/1)67%  (6/9)34%  (72/211)38%  (19.5/52)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class LocalRepositoryDaoImpl100% (1/1)67%  (6/9)34%  (72/211)38%  (19.5/52)
getLocalRepositoriesByLayout (String): List 0%   (0/1)0%   (0/55)0%   (0/12)
getLocalRepositoryByLocation (String): LocalRepository 0%   (0/1)0%   (0/65)0%   (0/16)
updateLocalRepository (LocalRepository): void 0%   (0/1)0%   (0/4)0%   (0/2)
getLocalRepositoryByName (String): LocalRepository 100% (1/1)77%  (50/65)84%  (13.5/16)
LocalRepositoryDaoImpl (): void 100% (1/1)100% (3/3)100% (1/1)
addLocalRepository (LocalRepository): LocalRepository 100% (1/1)100% (5/5)100% (1/1)
getAllLocalRepositories (): List 100% (1/1)100% (4/4)100% (1/1)
getLocalRepository (int): LocalRepository 100% (1/1)100% (6/6)100% (1/1)
removeLocalRepository (LocalRepository): 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 org.apache.continuum.model.repository.LocalRepository;
23import org.apache.maven.continuum.store.ContinuumStoreException;
24import org.springframework.stereotype.Repository;
25 
26import javax.jdo.Extent;
27import javax.jdo.PersistenceManager;
28import javax.jdo.Query;
29import javax.jdo.Transaction;
30import java.util.Collection;
31import java.util.Collections;
32import java.util.List;
33 
34/**
35 * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
36 * @version $Id: LocalRepositoryDaoImpl.java 735074 2009-01-16 18:13:10Z oching $
37 * @plexus.component role="org.apache.continuum.dao.LocalRepositoryDao"
38 */
39@Repository("localRepositoryDao")
40public class LocalRepositoryDaoImpl
41    extends AbstractDao
42    implements LocalRepositoryDao
43{
44    public LocalRepository addLocalRepository( LocalRepository repository )
45        throws ContinuumStoreException
46    {
47        return (LocalRepository) addObject( repository );
48    }
49 
50    public void updateLocalRepository( LocalRepository repository )
51        throws ContinuumStoreException
52    {
53        updateObject( repository );
54    }
55 
56    public void removeLocalRepository( LocalRepository repository )
57        throws ContinuumStoreException
58    {
59        removeObject( repository );
60    }
61 
62    public List<LocalRepository> getAllLocalRepositories()
63    {
64        return getAllObjectsDetached( LocalRepository.class );
65    }
66 
67    public List<LocalRepository> getLocalRepositoriesByLayout( String layout )
68    {
69        PersistenceManager pm = getPersistenceManager();
70 
71        Transaction tx = pm.currentTransaction();
72 
73        try
74        {
75            tx.begin();
76 
77            Extent extent = pm.getExtent( LocalRepository.class, true );
78 
79            Query query = pm.newQuery( extent );
80 
81            query.declareImports( "import java.lang.String" );
82 
83            query.declareParameters( "String layout" );
84 
85            query.setFilter( "this.layout == layout" );
86 
87            List result = (List) query.execute( layout );
88 
89            return result == null ? Collections.EMPTY_LIST : (List) pm.detachCopyAll( result );
90        }
91        finally
92        {
93            tx.commit();
94 
95            rollback( tx );
96        }
97    }
98 
99    public LocalRepository getLocalRepository( int repositoryId )
100        throws ContinuumStoreException
101    {
102        return (LocalRepository) getObjectById( LocalRepository.class, repositoryId );
103    }
104 
105    public LocalRepository getLocalRepositoryByName( String name )
106        throws ContinuumStoreException
107    {
108        PersistenceManager pm = getPersistenceManager();
109 
110        Transaction tx = pm.currentTransaction();
111 
112        try
113        {
114            tx.begin();
115 
116            Extent extent = pm.getExtent( LocalRepository.class, true );
117 
118            Query query = pm.newQuery( extent );
119 
120            query.declareImports( "import java.lang.String" );
121 
122            query.declareParameters( "String name" );
123 
124            query.setFilter( "this.name == name" );
125 
126            Collection result = (Collection) query.execute( name );
127 
128            if ( result.size() == 0 )
129            {
130                tx.commit();
131 
132                return null;
133            }
134 
135            Object object = pm.detachCopy( result.iterator().next() );
136 
137            tx.commit();
138 
139            return (LocalRepository) object;
140        }
141        finally
142        {
143            rollback( tx );
144        }
145    }
146 
147    public LocalRepository getLocalRepositoryByLocation( String location )
148        throws ContinuumStoreException
149    {
150        PersistenceManager pm = getPersistenceManager();
151 
152        Transaction tx = pm.currentTransaction();
153 
154        try
155        {
156            tx.begin();
157 
158            Extent extent = pm.getExtent( LocalRepository.class, true );
159 
160            Query query = pm.newQuery( extent );
161 
162            query.declareImports( "import java.lang.String" );
163 
164            query.declareParameters( "String location" );
165 
166            query.setFilter( "this.location == location" );
167 
168            Collection result = (Collection) query.execute( location );
169 
170            if ( result.size() == 0 )
171            {
172                tx.commit();
173 
174                return null;
175            }
176 
177            Object object = pm.detachCopy( result.iterator().next() );
178 
179            tx.commit();
180 
181            return (LocalRepository) object;
182        }
183        finally
184        {
185            rollback( tx );
186        }
187    }
188}

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