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

COVERAGE SUMMARY FOR SOURCE FILE [ProfileDaoImpl.java]

nameclass, %method, %block, %line, %
ProfileDaoImpl.java100% (1/1)86%  (6/7)30%  (28/93)33%  (8/24)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ProfileDaoImpl100% (1/1)86%  (6/7)30%  (28/93)33%  (8/24)
getProfileByName (String): Profile 0%   (0/1)0%   (0/65)0%   (0/16)
ProfileDaoImpl (): void 100% (1/1)100% (3/3)100% (1/1)
addProfile (Profile): Profile 100% (1/1)100% (5/5)100% (1/1)
getAllProfilesByName (): List 100% (1/1)100% (6/6)100% (1/1)
getProfile (int): Profile 100% (1/1)100% (6/6)100% (1/1)
removeProfile (Profile): void 100% (1/1)100% (4/4)100% (2/2)
updateProfile (Profile): 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.maven.continuum.model.system.Profile;
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.List;
32 
33/**
34 * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
35 * @version $Id: ProfileDaoImpl.java 735074 2009-01-16 18:13:10Z oching $
36 * @plexus.component role="org.apache.continuum.dao.ProfileDao"
37 */
38@Repository("profileDao")
39public class ProfileDaoImpl
40    extends AbstractDao
41    implements ProfileDao
42{
43    public Profile getProfileByName( String profileName )
44        throws ContinuumStoreException
45    {
46        PersistenceManager pm = getPersistenceManager();
47 
48        Transaction tx = pm.currentTransaction();
49 
50        try
51        {
52            tx.begin();
53 
54            Extent extent = pm.getExtent( Profile.class, true );
55 
56            Query query = pm.newQuery( extent );
57 
58            query.declareImports( "import java.lang.String" );
59 
60            query.declareParameters( "String name" );
61 
62            query.setFilter( "this.name == name" );
63 
64            Collection result = (Collection) query.execute( profileName );
65 
66            if ( result.size() == 0 )
67            {
68                tx.commit();
69 
70                return null;
71            }
72 
73            Object object = pm.detachCopy( result.iterator().next() );
74 
75            tx.commit();
76 
77            return (Profile) object;
78        }
79        finally
80        {
81            rollback( tx );
82        }
83    }
84 
85    public List<Profile> getAllProfilesByName()
86    {
87        return getAllObjectsDetached( Profile.class, "name ascending", null );
88    }
89 
90    public Profile addProfile( Profile profile )
91    {
92        return (Profile) addObject( profile );
93    }
94 
95    public Profile getProfile( int profileId )
96        throws ContinuumStoreException
97    {
98        return (Profile) getObjectById( Profile.class, profileId );
99    }
100 
101    public void updateProfile( Profile profile )
102        throws ContinuumStoreException
103    {
104        updateObject( profile );
105    }
106 
107    public void removeProfile( Profile profile )
108    {
109        removeObject( profile );
110    }
111}

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