1 /**
2 * Copyright 2005-2006 the original author or authors.
3 *
4 * Licensed under the Gnu General Pubic License, Version 2.0 (the
5 * "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/gpl-license.php
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the Gnu General Public License for more details.
14 */
15 package org.figure8.join.services.scripting.persistence;
16
17 import org.figure8.join.core.persistence.HibernateObjectDao;
18 import org.figure8.join.core.EntityObject;
19 import org.figure8.join.util.LogUtil;
20
21 import org.apache.commons.logging.Log;
22
23 import java.util.List;
24 /**
25 * Implementation of ScriptLogInfoDao using Hibernate ORM system.
26 * @author <a href="mailto:laurent.broudoux@free.fr">Laurent Broudoux</a>
27 * @version $Revision: 1.2 $
28 */
29 public class HibernateScriptLogInfoDao extends HibernateObjectDao implements ScriptLogInfoDao{
30
31
32
33 /** Get a commons logger */
34 private static final Log log = LogUtil.getLog(HibernateScriptLogInfoDao.class);
35
36
37
38
39 /**
40 * Retrieve all the info beans on available script logs for script having this name
41 * @param scriptName The name of the script to retrieve log for
42 * @return A list of {@link org.figure8.join.services.scripting.ScriptLogInfo} available for script
43 */
44 public List getScriptLogInfos(String scriptName){
45
46 List result = findNamedQueryStringParam("join.scriptlog_findByScript", "name", scriptName);
47 if (log.isDebugEnabled())
48 log.debug("Found " + result.size() + " script logs for script: " + scriptName);
49 return result;
50 }
51
52 /**
53 * Retrieve all the info beans on available script logs for script having this name and category
54 * @param scriptName The name of the script to retrieve log for
55 * @param scriptCategory The category of the script to retrive log for
56 * @return A list of {@link org.figure8.join.services.scripting.ScriptLogInfo} available for script
57 */
58 public List getScriptLogInfos(String scriptName, String scriptCategory){
59
60 List result = findNamedQueryStringParams("join.scriptlog_findByNameAndCategory",
61 "name", scriptName, "category", scriptCategory);
62 if (log.isDebugEnabled())
63 log.debug("Found " + result.size() + " script logs for script: " + scriptName + " & category: " + scriptCategory);
64 return result;
65 }
66
67 /**
68 * Retrieve all the info beans on available script logs for given entity
69 * @param entity The entity to retrieve ScriptLogInfo objects for
70 * @return A list of {@link org.figure8.join.services.scripting.ScriptLogInfo} available for entity
71 */
72 public List getScriptLogInfosForEntity(EntityObject entity){
73
74 List result = findNamedQueryStringParams("join.scriptlog_findByEntity",
75 "entityId", String.valueOf(entity.getId()), "entityClass", entity.getClass().getName());
76 if (log.isDebugEnabled())
77 log.debug("Found " + result.size() + " script logs for entity: " + entity.toString());
78 return result;
79 }
80
81 /**
82 * Retrieve all the info beans on available script logs for given entity
83 * @param entityId The id of entity to retrieve ScriptLogInfo objects for
84 * @param entityClass The class of entity to retrieve ScriptLogInfo objects for
85 * @return A list of {@link org.figure8.join.services.scripting.ScriptLogInfo} available for entity
86 */
87 public List getScriptLogInfosForEntity(long entityId, String entityClass){
88
89 List result = findNamedQueryStringParams("join.scriptlog_findByEntity",
90 "entityId", String.valueOf(entityId), "entityClass", entityClass);
91 if (log.isDebugEnabled())
92 log.debug("Found " + result.size() + " script logs for entity: " + entityClass + "[" + entityId + "]");
93 return result;
94 }
95
96
97
98
99 /** @return The org.figure8.join.services.scripting.ScriptLogInfo class */
100 public Class getPersistentClass(){
101 return org.figure8.join.services.scripting.ScriptLogInfo.class;
102 }
103 }