View Javadoc

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;
16  
17  import org.figure8.join.core.EntityObject;
18  
19  import java.util.Date;
20  /**
21   * This is an entity object representing information about the log
22   * file produced by the execution of a script. These informations are
23   * related to the entity this script has been launched for, the name and
24   * file of the script and the log file itself.
25   * @author <a href="mailto:laurent.broudoux@free.fr">Laurent Broudoux</a>
26   * @version $Revision: 1.2 $
27   *
28   * @hibernate.class table="join_scriptlogs" lazy="true"
29   * @hibernate.cache usage="read-write"
30   *
31   * @hibernate.query name="join.scriptlog_findByScript"
32   *    query="from ScriptLogInfo info where info.scriptName = :name
33   *          order by info.creationDate desc"
34   * @hibernate.query name="join.scriptlog_findByEntity"
35   *    query="from ScriptLogInfo info where info.entityId = :entityId
36   *          and info.entityClass = :entityClass order by info.creationDate desc"
37   * @hibernate.query name="join.scriptlog_findByNameAndCategory"
38   *    query="from ScriptLogInfo info where info.scriptName = :name
39   *          and info.scriptCategory = :category order by info.creationDate desc"
40   */
41  public class ScriptLogInfo extends EntityObject{
42  
43     // Attributes ---------------------------------------------------------------
44  
45     /** The date of creation of this log */
46     private Date creationDate;
47     /** The unique identifier of entity referenced by this log */
48     private long entityId;
49     /** The class of entity referenced by this log */
50     private String entityClass;
51     /** The path of file corresponding to log */
52     private String logFile;
53     /** The name of executed script */
54     private String scriptName;
55     /** The category of executed script */
56     private String scriptCategory;
57     /** The path of file corresponding to script */
58     private String scriptFile;
59     /** The exception message if script has failed */
60     private String exceptionMsg;
61  
62  
63     // Constructors -------------------------------------------------------------
64  
65     /** Creates a new instance of ScriptLogInfo. */
66     public ScriptLogInfo(){
67     }
68  
69     /**
70      * Creates a new instance of ScriptLogInfo with mandatory attributes.
71      * @param logFile The path of file corresponding to log
72      * @param scriptName The name of the executed script
73      * @param scriptCategory The category of the executed script
74      * @param scriptFile The path of file containing executed script
75      */
76     public ScriptLogInfo(String logFile, String scriptName, String scriptCategory, String scriptFile){
77        this.logFile = logFile;
78        this.scriptName = scriptName;
79        this.scriptCategory = scriptCategory;
80        this.scriptFile = scriptFile;
81        // Set the creation date as now.
82        creationDate = new Date();
83     }
84  
85     /**
86      * Creates a new instance of ScriptLogInfo with attributes.
87      * @param entity The referenced entity object
88      * @param logFile The path of file corresponding to log
89      * @param scriptName The name of the executed script
90      * @param scriptCategory The category of the executed script
91      * @param scriptFile The path of file containing executed script
92      */
93     public ScriptLogInfo(EntityObject entity, String logFile, String scriptName, String scriptCategory, String scriptFile){
94        this.entityId = entity.getId();
95        this.entityClass = entity.getClass().getName();
96        this.logFile = logFile;
97        this.scriptName = scriptName;
98        this.scriptCategory = scriptCategory;
99        this.scriptFile = scriptFile;
100       // Set the creation date as now.
101       creationDate = new Date();
102    }
103 
104 
105    // Public -------------------------------------------------------------------
106 
107    /**
108     * @hibernate.property column="d_creation"
109     *    not-null="true" type="timestamp"
110     *    update="false"
111     * @return The date of creation of this log
112     */
113    public Date getCreationDate(){
114       return creationDate;
115    }
116    /** @param creationDate The date of creation of this log */
117    public void setCreationDate(Date creationDate){
118       this.creationDate = creationDate;
119    }
120 
121    /**
122     * @hibernate.property column="n_entityid" update="false"
123     * @return The referenced entity unique identifier
124     */
125    public long getEntityId(){
126       return entityId;
127    }
128    /** @param entityId The referenced entity unique identifier */
129    public void setEntityId(long entityId){
130       this.entityId = entityId;
131    }
132 
133    /**
134     * @hibernate.property column="s_entityclass"
135     *    update="false" length="200"
136     * @return The referenced entity class
137     */
138    public String getEntityClass(){
139       return entityClass;
140    }
141    /** @param entityClass The referenced entity class */
142    public void setEntityClass(String entityClass){
143       this.entityClass = entityClass;
144    }
145 
146    /**
147     * @hibernate.property column="s_logfile"
148     *    not-null="true" update="false"
149     *    length="255"
150     * @return The path of file corresponding to log
151     */
152    public String getLogFile(){
153       return logFile;
154    }
155    /** @param logFile The path of file corresponding to log */
156    public void setLogFile(String logFile){
157       this.logFile = logFile;
158    }
159 
160    /**
161     * @hibernate.property column="s_scriptname" length="100"
162     * @return The name of executed script
163     */
164    public String getScriptName(){
165       return scriptName;
166    }
167    /** @param scriptName The name of executed script */
168    public void setScriptName(String scriptName){
169       this.scriptName = scriptName;
170    }
171 
172    /**
173     * @hibernate.property column="s_scriptclass" length="255"
174     * @return The category of executed script
175     */
176    public String getScriptCategory(){
177       return scriptCategory;
178    }
179    /** @param scriptCategory The category of executed script */
180    public void setScriptCategory(String scriptCategory){
181       this.scriptCategory = scriptCategory;
182    }
183 
184    /**
185     * @hibernate.property column="s_scriptfile" length="255"
186     * @return The path of file correcponding to script
187     */
188    public String getScriptFile(){
189       return scriptFile;
190    }
191    /** @param scriptFile The path of file correcponding to script */
192    public void setScriptFile(String scriptFile){
193       this.scriptFile = scriptFile;
194    }
195 
196    /**
197     * @hibernate.property column="s_exceptionmsg" length="255"
198     * @return The exception message if script has failed
199     */
200    public String getExceptionMsg(){
201       return exceptionMsg;
202    }
203    /** @param exceptionMsg The exception message if script has failed */
204    public void setExceptionMsg(String exceptionMsg){
205       this.exceptionMsg = exceptionMsg;
206    }
207 }