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

COVERAGE SUMMARY FOR SOURCE FILE [ScheduleDaoImpl.java]

nameclass, %method, %block, %line, %
ScheduleDaoImpl.java100% (1/1)75%  (6/8)29%  (28/98)31%  (8/26)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ScheduleDaoImpl100% (1/1)75%  (6/8)29%  (28/98)31%  (8/26)
getScheduleByName (String): Schedule 0%   (0/1)0%   (0/65)0%   (0/16)
storeSchedule (Schedule): Schedule 0%   (0/1)0%   (0/5)0%   (0/2)
ScheduleDaoImpl (): void 100% (1/1)100% (3/3)100% (1/1)
addSchedule (Schedule): Schedule 100% (1/1)100% (5/5)100% (1/1)
getAllSchedulesByName (): List 100% (1/1)100% (6/6)100% (1/1)
getSchedule (int): Schedule 100% (1/1)100% (6/6)100% (1/1)
removeSchedule (Schedule): void 100% (1/1)100% (4/4)100% (2/2)
updateSchedule (Schedule): 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.project.Schedule;
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: ScheduleDaoImpl.java 735074 2009-01-16 18:13:10Z oching $
36 * @plexus.component role="org.apache.continuum.dao.ScheduleDao"
37 */
38@Repository("scheduleDao")
39public class ScheduleDaoImpl
40    extends AbstractDao
41    implements ScheduleDao
42{
43    public List<Schedule> getAllSchedulesByName()
44    {
45        return getAllObjectsDetached( Schedule.class, "name ascending", null );
46    }
47 
48    public Schedule addSchedule( Schedule schedule )
49    {
50        return (Schedule) addObject( schedule );
51    }
52 
53    public Schedule getScheduleByName( String name )
54        throws ContinuumStoreException
55    {
56        PersistenceManager pm = getPersistenceManager();
57 
58        Transaction tx = pm.currentTransaction();
59 
60        try
61        {
62            tx.begin();
63 
64            Extent extent = pm.getExtent( Schedule.class, true );
65 
66            Query query = pm.newQuery( extent );
67 
68            query.declareImports( "import java.lang.String" );
69 
70            query.declareParameters( "String name" );
71 
72            query.setFilter( "this.name == name" );
73 
74            Collection result = (Collection) query.execute( name );
75 
76            if ( result.size() == 0 )
77            {
78                tx.commit();
79 
80                return null;
81            }
82 
83            Object object = pm.detachCopy( result.iterator().next() );
84 
85            tx.commit();
86 
87            return (Schedule) object;
88        }
89        finally
90        {
91            rollback( tx );
92        }
93    }
94 
95    public Schedule storeSchedule( Schedule schedule )
96        throws ContinuumStoreException
97    {
98        updateObject( schedule );
99 
100        return schedule;
101    }
102 
103    public void updateSchedule( Schedule schedule )
104        throws ContinuumStoreException
105    {
106        updateObject( schedule );
107    }
108 
109    public void removeSchedule( Schedule schedule )
110    {
111        removeObject( schedule );
112    }
113 
114    public Schedule getSchedule( int scheduleId )
115        throws ContinuumStoreException
116    {
117        return (Schedule) getObjectById( Schedule.class, scheduleId );
118    }
119}

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