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.businessobjects.commons;
16  
17  import org.figure8.join.core.EntityObject;
18  /**
19   * This is an entity representing a process status.
20   * <br/>
21   * Some process are well identified within Join workflow such as that returned
22   * by the MANAGED_TYPES constant from this class. Defining status for these process
23   * allow you to better monitor them.
24   * <br/>
25   * Some status should also be marked as "terminal" in order to help Join detecting
26   * process end and thus workflow transition. An exemple is the end of the assembly
27   * creation process : when assembly has reached a terminal status, Join may propose
28   * users to deploy this assembly onto an environnment ; thus starting a new deployment
29   * preparation process, and so on...
30   * @author <a href="mailto:laurent.broudoux@free.fr">Laurent Broudoux</a>
31   * @version $Revision: 1.2 $
32   *
33   * @hibernate.class table="join_status" lazy="true"
34   * @hibernate.cache usage="read-write"
35   *
36   * @hibernate.query name="join.status_findByKey" query="from Status st where st.key = :key"
37   * @hibernate.query name="join.status_findByType" query="from Status st where st.type = :type"
38   */
39  public class Status extends EntityObject{
40  
41     // Static -------------------------------------------------------------------
42     
43     /** Constant for the status type corresponding to build process. */
44     public static final String BUILD_TYPE = "build";
45     /** Constant for the status type corresponding to assembly process. */
46     public static final String ASSEMBLY_TYPE = "assembly";
47     /** Constant for the status type corresponding to deployment preparation process. */
48     public static final String DEPLOYMENT_PREPARATION_TYPE = "deployment preparation";
49     /** Constant for the status type corresponding to deployment realisation process. */
50     public static final String DEPLOYMENT_REALIZATION_TYPE = "deployment realization";
51     
52     /** Constant for the list of managed status types (one type by process). */
53     public static final String[] MANAGED_TYPES = new String[]{BUILD_TYPE, ASSEMBLY_TYPE,
54        DEPLOYMENT_PREPARATION_TYPE, DEPLOYMENT_REALIZATION_TYPE};
55     
56     
57     // Attributes ---------------------------------------------------------------
58     
59     /** The unique key of this status */
60     private String key;
61     /** The display label of this status */
62     private String label;
63     /** The type of process this status is for */
64     private String type;
65     /** Whether this status is terminal in process */
66     private boolean terminal = false;
67     /** Whether this status corresponds to a 'cancel' status in process */
68     private boolean cancelled = false;
69     
70     
71     // Constructors -------------------------------------------------------------
72     
73     /** Creates a new insatnce of Status. */
74     public Status(){
75     }
76     
77     /**
78      * Creates a new instance of Status with mandatory attributes.
79      * @param key The unique key for status
80      * @param label The display label for status
81      * @param type The type of process this status is for
82      */
83     public Status(String key, String label, String type){
84        this.key = key;
85        this.label = label;
86        this.type = type;
87     }
88     
89     
90     // Public -------------------------------------------------------------------
91     
92     /**
93      * @hibernate.property column="s_key"
94      *    not-null="true" unique="true"
95      *    length="20"
96      * @return This status unique key
97      */
98     public String getKey(){
99        return key;
100    }
101    /** @param key This status unique key */
102    public void setKey(String key){
103       this.key = key;
104    }
105    
106    /**
107     * @hibernate.property column="s_label"
108     *    not-null="true" length="40"
109     * @return The display label for status
110     */
111    public String getLabel(){
112       return label;
113    }
114    /** @param label This status label for display */
115    public void setLabel(String label){
116       this.label = label;
117    }
118    
119    /**
120     * @hibernate.property column="s_type" length="30"
121     * @return The type of process this status is for
122     */
123    public String getType(){
124       return type;
125    }
126    /** @param type The type of process this status is for */
127    public void setType(String type){
128       this.type = type;  
129    }
130    
131    /**
132     * @hibernate.property column="b_terminal" type="boolean"
133     * @return Whether this status is terminal in process
134     */
135    public boolean isTerminal(){
136       return terminal;
137    }
138    /** @param terminal Whether this status is terminal in process */
139    public void setTerminal(boolean terminal){
140       this.terminal = terminal;
141    }
142    
143    /**
144     * @hibernate.property column="b_cancelled" type="boolean"
145     * @return Whether status is a cancelled one
146     */
147    public boolean isCancelled(){
148       return cancelled;
149    }
150    /** @param cancelled Whether this status is a cancel step in process */
151    public void setCancelled(boolean cancelled){
152       this.cancelled = cancelled;
153    }
154 }