1 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 ; 31 32 46 public class MostRecentProjects extends BaseModule { 47 49 public String getMainMethod() { 50 return "view"; 51 } 52 53 public String getModuleDescription() { 54 return "Shows the most recently created projects"; 55 } 56 57 public String getModuleDisplayName() { 58 return "Most Recent " 59 + StringUtils.capitalise(ProjectConstants.PROJECT_NAME) + "s"; 60 } 61 62 public CoefficientContext view(CoefficientContext ctx) throws Exception { 63 HashMap searchParams = new HashMap (); 64 searchParams.put("active", new Boolean (true)); 65 HibernatePager hp = 66 new HibernatePager(Project.class, "registrationDate", 10, 67 searchParams, false); 68 if (hp.currentPage() 69 .size() > 0) { 70 HashMap map = new HashMap (); 71 map.put("pager", hp); 72 StringBuffer sb = 73 VelocityScreenUtil.getProcessedScreen("view-projects.vm", map); 74 75 ctx.setModuleContent(sb.toString(), getModuleDisplayName()); 77 } 78 return ctx; 79 } 80 } 81 | Popular Tags |