KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opencms > workplace > CmsTaskDocu


1 /*
2 * File : $Source: /usr/local/cvs/opencms/src-modules/com/opencms/workplace/CmsTaskDocu.java,v $
3 * Date : $Date: 2005/06/27 23:22:07 $
4 * Version: $Revision: 1.2 $
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
30 package com.opencms.workplace;
31
32 import org.opencms.file.CmsObject;
33 import org.opencms.file.CmsUser;
34 import org.opencms.main.CmsException;
35 import org.opencms.util.CmsDateUtil;
36 import org.opencms.util.CmsStringUtil;
37 import org.opencms.workflow.CmsTaskLog;
38
39 import com.opencms.template.A_CmsXmlContent;
40
41 import java.util.Hashtable JavaDoc;
42 import java.util.List JavaDoc;
43 import java.util.Vector JavaDoc;
44
45 import org.w3c.dom.Element JavaDoc;
46
47 /**
48  * Class for building task list documentation. <BR>
49  * Called by CmsXmlTemplateFile for handling the special XML tag <code>&lt;TASKDOCU&gt;</code>.
50  *
51  * @author Michael Emmerich
52  * @version $Revision: 1.2 $ $Date: 2005/06/27 23:22:07 $
53  * @see com.opencms.workplace.CmsXmlWpTemplateFile
54  *
55  * @deprecated Will not be supported past the OpenCms 6 release.
56  */

57
58 public class CmsTaskDocu extends A_CmsWpElement implements I_CmsWpElement {
59     
60     /**
61      * This private helper method adds a <code>&lt;BR&gt;</code> tag to each line.
62      *
63      * @param value The string to add the br-tags.
64      * @return The resulting string with br-tags.
65      */

66     
67     private String JavaDoc addBrTags(String JavaDoc value) {
68         String JavaDoc lines[] = CmsStringUtil.splitAsArray(value, '\n');
69         String JavaDoc retValue = "";
70         for(int i = 0;i < lines.length;i++) {
71             retValue += lines[i] + "<BR>";
72         }
73         return retValue;
74     }
75     
76     /**
77      * Handling of the special workplace <CODE>&lt;TASKDOCU&gt;</CODE> tags.
78      * <P>
79      * Returns the processed code with the actual elements.
80      * <P>
81      * Projectlists can be referenced in any workplace template by <br>
82      * <CODE>&lt;TASKDOCU /&gt;</CODE>
83      *
84      * @param cms CmsObject Object for accessing resources.
85      * @param An XML element containing the <code>&lt;TASKDOCU&gt;</code> tag.
86      * @param doc Reference to the A_CmsXmlContent object of the initiating XLM document.
87      * @param callingObject reference to the calling object <em>(not used here)</em>.
88      * @param parameters Hashtable containing all user parameters <em>(not used here)</em>.
89      * @param lang CmsXmlLanguageFile conataining the currently valid language file.
90      * @return Processed button.
91      * @throws CmsException
92      */

93     
94     public Object JavaDoc handleSpecialWorkplaceTag(CmsObject cms, Element JavaDoc n, A_CmsXmlContent doc, Object JavaDoc callingObject,
95             Hashtable JavaDoc parameters, CmsXmlLanguageFile lang) throws CmsException {
96         
97         /** StringBuffer for the generated output */
98         StringBuffer JavaDoc result = new StringBuffer JavaDoc();
99         List JavaDoc taskdocs = new Vector JavaDoc();
100         CmsTaskLog tasklog;
101         
102         // Get the template definition values
103
CmsXmlWpTemplateFile template = getTaskDocuDefinitions(cms);
104         
105         // get the task id
106
String JavaDoc taskId = (String JavaDoc)parameters.get("taskid");
107         if(taskId != null) {
108             int id = new Integer JavaDoc(taskId).intValue();
109             taskdocs = cms.getTaskService().readTaskLogs(id);
110         }
111         
112         // go through all tasklogs
113
for(int i = 1;i <= taskdocs.size();i++) {
114             tasklog = (CmsTaskLog)taskdocs.get(taskdocs.size() - i);
115             int type = tasklog.getType();
116             
117             // check if this is a type to be displayed
118
if(type >= 100) {
119                 
120                 // add the time
121
java.sql.Timestamp JavaDoc time = tasklog.getStartTime();
122                 template.setData("DATE", CmsDateUtil.getDateTimeShort(time.getTime()));
123                 
124                 // add the user
125
CmsUser user = cms.getTaskService().readOwner(tasklog);
126                 template.setData("USER", CmsUser.getFullName(user));
127                 
128                 // set the message
129
template.setData("MESSAGE", addBrTags(tasklog.getComment()));
130                 
131                 // set the image
132
template.setData("ICON", template.getProcessedDataValue("ICON" + type, callingObject, parameters));
133                 
134                 // set the headline
135
template.setData("HEADLINE", lang.getLanguageValue("task.headline.m" + type));
136                 
137                 // generate the entry
138
result.append(template.getProcessedDataValue("LISTENTRY", callingObject, parameters));
139                 
140                 // generate the spacerline
141
result.append(template.getProcessedDataValue("LISTSEPETATOR", callingObject, parameters));
142             }
143         }
144         return result.toString();
145     }
146     
147     /**
148      * Indicates if the results of this class are cacheable.
149      *
150      * @param cms CmsObject Object for accessing system resources
151      * @param templateFile Filename of the template file
152      * @param elementName Element name of this template in our parent template.
153      * @param parameters Hashtable with all template class parameters.
154      * @param templateSelector template section that should be processed.
155      * @return <EM>true</EM> if cacheable, <EM>false</EM> otherwise.
156      */

157     
158     public boolean isCacheable(CmsObject cms, String JavaDoc templateFile, String JavaDoc elementName,
159             Hashtable JavaDoc parameters, String JavaDoc templateSelector) {
160         return false;
161     }
162 }
163
Popular Tags