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

COVERAGE SUMMARY FOR SOURCE FILE [AbstractDao.java]

nameclass, %method, %block, %line, %
AbstractDao.java100% (1/1)89%  (17/19)78%  (118/151)76%  (29/38)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AbstractDao100% (1/1)89%  (17/19)78%  (118/151)76%  (29/38)
attachAndDelete (Object): void 0%   (0/1)0%   (0/5)0%   (0/2)
makePersistent (PersistenceManager, Object, boolean): Object 0%   (0/1)0%   (0/5)0%   (0/1)
getObjectFromQuery (Class, String, String, String): Object 100% (1/1)35%  (8/23)20%  (1/5)
getObjectById (Class, int, String): Object 100% (1/1)64%  (14/22)60%  (3/5)
AbstractDao (): void 100% (1/1)100% (3/3)100% (1/1)
addObject (Object): Object 100% (1/1)100% (6/6)100% (1/1)
addObject (PersistenceManager, Object): Object 100% (1/1)100% (4/4)100% (1/1)
getAllObjectsDetached (Class): List 100% (1/1)100% (5/5)100% (1/1)
getAllObjectsDetached (Class, String): List 100% (1/1)100% (6/6)100% (1/1)
getAllObjectsDetached (Class, String, String): List 100% (1/1)100% (8/8)100% (1/1)
getAllObjectsDetached (PersistenceManager, Class, String, String): List 100% (1/1)100% (6/6)100% (1/1)
getContinuumPersistenceManagerFactory (): PersistenceManagerFactory 100% (1/1)100% (4/4)100% (1/1)
getObjectById (Class, int): Object 100% (1/1)100% (6/6)100% (1/1)
getPersistenceManager (): PersistenceManager 100% (1/1)100% (5/5)100% (1/1)
getPersistenceManager (PersistenceManagerFactory): PersistenceManager 100% (1/1)100% (15/15)100% (4/4)
removeObject (Object): void 100% (1/1)100% (5/5)100% (2/2)
rollback (Transaction): void 100% (1/1)100% (3/3)100% (2/2)
updateObject (Object): void 100% (1/1)100% (6/6)100% (2/2)
updateObject (PersistenceManager, Object): void 100% (1/1)100% (14/14)100% (5/5)

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.store.ContinuumObjectNotFoundException;
23import org.apache.maven.continuum.store.ContinuumStoreException;
24import org.codehaus.plexus.jdo.PlexusJdoUtils;
25import org.codehaus.plexus.jdo.PlexusObjectNotFoundException;
26import org.codehaus.plexus.jdo.PlexusStoreException;
27 
28import javax.annotation.Resource;
29import javax.jdo.FetchPlan;
30import javax.jdo.PersistenceManager;
31import javax.jdo.PersistenceManagerFactory;
32import javax.jdo.Transaction;
33import java.util.List;
34 
35/**
36 * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
37 * @version $Id: AbstractDao.java 742493 2009-02-09 13:45:14Z ctan $
38 */
39public class AbstractDao
40{
41    // ----------------------------------------------------------------------
42    // Fetch Groups
43    // ----------------------------------------------------------------------
44 
45    protected static final String PROJECT_WITH_BUILDS_FETCH_GROUP = "project-with-builds";
46 
47    protected static final String PROJECT_WITH_CHECKOUT_RESULT_FETCH_GROUP = "project-with-checkout-result";
48 
49    protected static final String BUILD_RESULT_WITH_DETAILS_FETCH_GROUP = "build-result-with-details";
50 
51    protected static final String PROJECT_BUILD_DETAILS_FETCH_GROUP = "project-build-details";
52 
53    protected static final String PROJECT_ALL_DETAILS_FETCH_GROUP = "project-all-details";
54 
55    protected static final String PROJECT_DEPENDENCIES_FETCH_GROUP = "project-dependencies";
56 
57    protected static final String PROJECTGROUP_PROJECTS_FETCH_GROUP = "projectgroup-projects";
58 
59    protected static final String BUILD_TEMPLATE_BUILD_DEFINITIONS = "build-template-build-definitions";
60 
61    /**
62    * @plexus.requirement
63    */
64    @Resource
65    private StoreUtilities storeUtilities;
66 
67    protected Object addObject( Object object )
68    {
69        return addObject( getPersistenceManager(), object );
70    }
71 
72    private Object addObject( PersistenceManager pmf, Object object )
73    {
74        return PlexusJdoUtils.addObject( pmf, object );
75    }
76 
77    protected void removeObject( Object o )
78    {
79        PlexusJdoUtils.removeObject( getPersistenceManager(), o );
80    }
81 
82    protected void updateObject( Object object )
83        throws ContinuumStoreException
84    {
85        updateObject( getPersistenceManager(), object );
86    }
87 
88    private void updateObject( PersistenceManager pmf, Object object )
89        throws ContinuumStoreException
90    {
91        try
92        {
93            PlexusJdoUtils.updateObject( pmf, object );
94        }
95        catch ( PlexusStoreException e )
96        {
97            throw new ContinuumStoreException( e.getMessage(), e );
98        }
99    }
100 
101    protected Object getObjectById( Class clazz, int id )
102        throws ContinuumStoreException
103    {
104        return getObjectById( clazz, id, null );
105    }
106 
107    protected Object getObjectById( Class clazz, int id, String fetchGroup )
108        throws ContinuumStoreException
109    {
110        try
111        {
112            return PlexusJdoUtils.getObjectById( getPersistenceManager(), clazz, id, fetchGroup );
113        }
114        catch ( PlexusObjectNotFoundException e )
115        {
116            throw new ContinuumObjectNotFoundException( e.getMessage() );
117        }
118        catch ( PlexusStoreException e )
119        {
120            throw new ContinuumStoreException( e.getMessage(), e );
121        }
122    }
123 
124    protected Object getObjectFromQuery( Class clazz, String idField, String id, String fetchGroup )
125        throws ContinuumStoreException
126    {
127        try
128        {
129            return PlexusJdoUtils.getObjectFromQuery( getPersistenceManager(), clazz, idField, id, fetchGroup );
130        }
131        catch ( PlexusObjectNotFoundException e )
132        {
133            throw new ContinuumObjectNotFoundException( e.getMessage() );
134        }
135        catch ( PlexusStoreException e )
136        {
137            throw new ContinuumStoreException( e.getMessage(), e );
138        }
139    }
140 
141    protected List getAllObjectsDetached( Class clazz )
142    {
143        return getAllObjectsDetached( clazz, null );
144    }
145 
146    protected List getAllObjectsDetached( Class clazz, String fetchGroup )
147    {
148        return getAllObjectsDetached( clazz, null, fetchGroup );
149    }
150 
151    protected List getAllObjectsDetached( Class clazz, String ordering, String fetchGroup )
152    {
153        return getAllObjectsDetached( getPersistenceManager(), clazz, ordering, fetchGroup );
154    }
155 
156    protected List getAllObjectsDetached( PersistenceManager pmf, Class clazz, String ordering, String fetchGroup )
157    {
158        return PlexusJdoUtils.getAllObjectsDetached( pmf, clazz, ordering, fetchGroup );
159    }
160 
161    protected void rollback( Transaction tx )
162    {
163        PlexusJdoUtils.rollbackIfActive( tx );
164    }
165 
166    protected void attachAndDelete( Object object )
167    {
168        PlexusJdoUtils.attachAndDelete( getPersistenceManager(), object );
169    }
170 
171    protected PersistenceManager getPersistenceManager()
172    {
173        return getPersistenceManager( getContinuumPersistenceManagerFactory() );
174    }
175 
176    private PersistenceManager getPersistenceManager( PersistenceManagerFactory pmf )
177    {
178        PersistenceManager pm = pmf.getPersistenceManager();
179 
180        pm.getFetchPlan().setMaxFetchDepth( -1 );
181        pm.getFetchPlan().setDetachmentOptions( FetchPlan.DETACH_LOAD_FIELDS );
182 
183        return pm;
184    }
185 
186    protected PersistenceManagerFactory getContinuumPersistenceManagerFactory()
187    {
188        return storeUtilities.getContinuumPersistenceManagerFactory();
189    }
190 
191    protected Object makePersistent( PersistenceManager pm, Object object, boolean detach )
192    {
193        return PlexusJdoUtils.makePersistent( pm, object, detach );
194    }
195 
196}

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