Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/opencms/file/CmsProject.java


1   /*
2   * File   : $Source: /usr/local/cvs/opencms/src/com/opencms/file/CmsProject.java,v $
3   * Date   : $Date: 2003/04/01 15:20:18 $
4   * Version: $Revision: 1.36 $
5   *
6   * This library is part of OpenCms -
7   * the Open Source Content Mananagement System
8   *
9   * Copyright (C) 2001  The OpenCms Group
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about OpenCms, please see the
22  * OpenCms Website: http://www.opencms.org
23  *
24  * You should have received a copy of the GNU Lesser General Public
25  * License along with this library; if not, write to the Free Software
26  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27  */
28  
29  package com.opencms.file;
30  
31  import com.opencms.core.I_CmsConstants;
32  import com.opencms.util.SqlHelper;
33  
34  import java.sql.ResultSet;
35  import java.sql.SQLException;
36  import java.sql.Timestamp;
37  
38  /**
39   * Describes a project. A project is used to handle versions of
40   * one resource.
41   *
42   * @author Andreas Schouten
43   * @author Michael Emmerich
44   * @author Anders Fugmann
45   * @author Jan Krag
46   * @version $Revision: 1.36 $ $Date: 2003/04/01 15:20:18 $
47   */
48  public class CmsProject implements I_CmsConstants, Cloneable{
49  
50      /**
51       * The id of this project.
52       */
53      private int m_id = C_UNKNOWN_ID;
54  
55      /**
56       * The user_id of the owner.
57       */
58      private int m_ownerId = C_UNKNOWN_ID;
59  
60      /**
61       * The group_id of the group, who may access the project.
62       */
63      private int m_groupId = C_UNKNOWN_ID;
64  
65      /**
66       * The manager group_id of the group, who may manage the project.
67       */
68      private int m_managergroupId = C_UNKNOWN_ID;
69  
70      /**
71       * The task_id for this project.
72       */
73      private int m_taskId = C_UNKNOWN_ID;
74  
75      /**
76       * The name of this project.
77       */
78      private String m_name = null;
79  
80      /**
81       * The description of this project.
82       */
83      private String m_description = null;
84  
85       /**
86       * The manager group  of this resource.
87       */
88      private int m_managerGroupId;
89  
90      /**
91       * The creation date of this project.
92       */
93      private long m_createdate = C_UNKNOWN_LONG;
94  
95      /**
96       * The state of this project.
97       */
98      private int m_flags = C_PROJECT_STATE_UNLOCKED;
99  
100     /**
101      * The project type
102      */
103     private int m_type = C_UNKNOWN_ID;
104 
105     /**
106      * Construct a new CmsProject.
107      */
108     public CmsProject(int projectId, String name, String description, int taskId,
109                       int ownerId, int group, int managerGroup, int flags,
110                       Timestamp createdate, int type) {
111 
112         m_id = projectId;
113         m_name = name;
114         m_description = description;
115         m_taskId = taskId;
116         m_ownerId = ownerId;
117         m_groupId = group;
118         m_groupId=group;
119         m_managergroupId = managerGroup;
120         m_managerGroupId=managerGroup;
121         m_flags = flags;
122         m_type = type;
123         if( createdate != null) {
124             m_createdate = createdate.getTime();
125         } else {
126             m_createdate = C_UNKNOWN_LONG;
127         }
128     }
129 
130     /**
131      * Construct a new CmsProject that can be used to check if the provided id is the online project id.
132      */
133     public CmsProject(int projectId, int flags) {
134         m_id = projectId;
135         m_flags = flags;
136     }
137     
138 /**
139  * Construct a new CmsProject, from a ResultSet.
140  * Creation date: (10/02/00)
141  * @param rs java.sql.ResultSet
142  */
143 public CmsProject(ResultSet res, com.opencms.file.genericSql.CmsQueries m_cq) throws SQLException {
144                  this(res.getInt(m_cq.get("C_PROJECTS_PROJECT_ID")),
145                             res.getString(m_cq.get("C_PROJECTS_PROJECT_NAME")),
146                             res.getString(m_cq.get("C_PROJECTS_PROJECT_DESCRIPTION")),
147                             res.getInt(m_cq.get("C_PROJECTS_TASK_ID")),
148                             res.getInt(m_cq.get("C_PROJECTS_USER_ID")),
149                             res.getInt(m_cq.get("C_PROJECTS_GROUP_ID")),
150                             res.getInt(m_cq.get("C_PROJECTS_MANAGERGROUP_ID")),
151                             res.getInt(m_cq.get("C_PROJECTS_PROJECT_FLAGS")),
152                             SqlHelper.getTimestamp(res,m_cq.get("C_PROJECTS_PROJECT_CREATEDATE")),
153                             res.getInt(m_cq.get("C_PROJECTS_PROJECT_TYPE")));
154 }
155     /**
156     * Clones the CmsProject by creating a new CmsProject Object.
157     * @return Cloned CmsProject.
158     */
159     public Object clone() {
160         CmsProject project=new CmsProject(this.m_id,new String (this.m_name),
161                                        new String(m_description),this.m_taskId,
162                                        this.m_ownerId,this.m_groupId,this.m_managerGroupId,
163                                        this.m_flags,new Timestamp(this.m_createdate),
164                                        this.m_type);
165         return project;
166     }
167     /**
168      * Compares the overgiven object with this object.
169      *
170      * @return true, if the object is identically else it returns false.
171      */
172     public boolean equals(Object obj) {
173         boolean equal=false;
174         // check if the object is a CmsProject object
175         if (obj instanceof CmsProject) {
176             // same ID than the current project?
177             if (((CmsProject)obj).getId() == m_id){
178                 equal = true;
179             }
180         }
181         return equal;
182     }
183     /**
184      * Returns the creation date of this project.
185      *
186      * @return the creation date of this project.
187      */
188     public long getCreateDate() {
189         return(m_createdate);
190     }
191     /**
192      * Returns the description of this project.
193      *
194      * @return description The description of this project.
195      */
196     public String getDescription() {
197         if ((m_description== null) || (m_description.length()<1) ) {
198             return "(No project description)";
199         } else {
200             return m_description;
201         }
202     }
203     /**
204      * Returns the state of this project.<BR/>
205      * This may be C_PROJECT_STATE_UNLOCKED, C_PROJECT_STATE_LOCKED,
206      * C_PROJECT_STATE_ARCHIVE.
207      *
208      * @return the state of this project.
209      */
210     public int getFlags() {
211         return(m_flags);
212     }
213     /**
214      * Returns the groupid of this project.
215      *
216      * @return the groupid of this project.
217      */
218     public int getGroupId() {
219         return(m_groupId);
220     }
221     /**
222      * Returns the id of this project.
223      *
224      * @return the id of this project.
225      */
226     public int getId() {
227         return(m_id);
228     }
229     /**
230      * Returns <code>true</code> if this project is the Online project.<p>
231      * 
232      * @return <code>true</code> if this project is the Online project
233      */
234     public boolean isOnlineProject() {
235         return (m_id == I_CmsConstants.C_PROJECT_ONLINE_ID); 
236     }    
237     /**
238      * Returns the manager groupid of this project.
239      *
240      * @return the manager groupid of this project.
241      */
242     public int getManagerGroupId() {
243         return( m_managergroupId );
244     }
245     /**
246      * Returns the name of this project.
247      *
248      * @return the name of this project.
249      */
250     public String getName() {
251         return(m_name);
252     }
253     /**
254      * Returns the userid of the project owner.
255      *
256      * @return the userid of the project owner.
257      */
258     public int getOwnerId() {
259         return(m_ownerId);
260     }
261 
262     /**
263      * Returns the taskid of this project.
264      *
265      * @return the taskid of this project.
266      */
267    public  int getTaskId() {
268         return(this.m_taskId);
269     }
270     /**
271      * Gets the type.
272      *
273      * @return the type.
274      */
275     public int getType() {
276         return m_type;
277     }
278 
279     /**
280      * Do static export after publish.
281      *
282      * @return true is static export is enabled.
283      */
284     public boolean doStaticExport(){
285         if(m_type > 9){
286             return true;
287         } else {
288             return false;
289         }
290     }
291     /**
292      * Sets the description of this project.
293      *
294      * @param description The description of this project.
295      */
296     public void setDescription(String description) {
297         m_description = description;
298     }
299 
300     /**
301      * Sets the state of this project.<BR/>
302      * This may be C_PROJECT_STATE_UNLOCKED, C_PROJECT_STATE_LOCKED,
303      * C_PROJECT_STATE_ARCHIVE.
304      *
305      * @param flags The flag to bes set.
306      */
307     public void setFlags(int flags) {
308         m_flags = flags;
309     }
310 
311     /**
312      * Sets the type.
313      *
314      * @param the type.
315      */
316     void setType(int id) {
317         m_type = id;
318     }
319     /**
320      * Returns a string-representation for this object.
321      * This can be used for debugging.
322      *
323      * @return string-representation for this object.
324      */
325     public String toString() {
326         StringBuffer output=new StringBuffer();
327         output.append("[Project]:");
328         output.append(m_name);
329         output.append(" , Id=");
330         output.append(m_id);
331         output.append(" :");
332         output.append(m_description);
333         return output.toString();
334     }
335 }