KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > za > org > coefficient > modules > project > MostActiveProjects


1 /*
2  * Coefficient - facilitates project based collaboration
3  * Copyright (C) 2003, Dylan Etkin, CSIR icomtek
4  * PO Box 395
5  * Pretoria 0001, RSA
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  * This library 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. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */

19
20 package za.org.coefficient.modules.project;
21
22 import org.apache.commons.lang.StringUtils;
23
24 import za.org.coefficient.core.Project;
25 import za.org.coefficient.interfaces.CoefficientContext;
26 import za.org.coefficient.modules.BaseModule;
27 import za.org.coefficient.util.common.HibernatePager;
28 import za.org.coefficient.util.ejb.VelocityScreenUtil;
29
30 import java.util.HashMap JavaDoc;
31
32 /**
33  * @pojo2ejb.class
34  * name="MostActiveProjects"
35  * jndi-prefix="za/org/coefficient/permanent/"
36  * interface-extends="za.org.coefficient.interfaces.Module"
37  * interface-local-extends="za.org.coefficient.interfaces.ModuleLocal"
38  *
39  * @web.resource-env-ref
40  * name="za/org/coefficient/permanent/MostActiveProjects"
41  * type="za.org.coefficient.modules.project.MostActiveProjects"
42  * @web.resource-env-ref
43  * name="MostActiveProjects"
44  * type="za.org.coefficient.modules.project.MostActiveProjects"
45  */

46 public class MostActiveProjects extends BaseModule {
47     //~ Methods ================================================================
48

49     public String JavaDoc getMainMethod() {
50         return "view";
51     }
52
53     public String JavaDoc getModuleDescription() {
54         return "Shows the most active projects";
55     }
56
57     public String JavaDoc getModuleDisplayName() {
58         return "Most Active "
59             + StringUtils.capitalise(ProjectConstants.PROJECT_NAME) + "s";
60     }
61
62     public CoefficientContext view(CoefficientContext ctx) throws Exception JavaDoc {
63         HashMap JavaDoc searchParams = new HashMap JavaDoc();
64         searchParams.put("active", new Boolean JavaDoc(true));
65         HibernatePager hp =
66             new HibernatePager(Project.class, "statistics.currentData.rank", 10,
67                 searchParams, false);
68         HashMap JavaDoc map = new HashMap JavaDoc();
69         map.put("pager", hp);
70         map.put("project_name", ProjectConstants.PROJECT_NAME);
71         map.put("mod", "MostActiveProjects");
72         if(ctx.getCurrentUser() != null) {
73             map.put("loggedIn", new Boolean JavaDoc(true));
74         }
75         StringBuffer JavaDoc sb =
76             VelocityScreenUtil.getProcessedScreen("view-projects.vm", map);
77         
78         // Set the html into the context
79
ctx.setModuleContent(sb.toString(), getModuleDisplayName());
80         return ctx;
81     }
82 }
83
Popular Tags