1 19 20 package za.org.coefficient.modules.fileUpload; 21 22 import za.org.coefficient.interfaces.CoefficientContext; 23 import za.org.coefficient.modules.BaseModule; 24 import za.org.coefficient.util.common.HibernatePager; 25 import za.org.coefficient.util.ejb.VelocityScreenUtil; 26 import za.org.coefficient.util.ejb.SecurityUtil; 27 28 import java.util.HashMap ; 29 30 44 public class MostRecentFileUploads extends BaseModule { 45 47 public String getMainMethod() { 48 return "view"; 49 } 50 51 public String getModuleDescription() { 52 return "Shows the most recently created file uploads"; 53 } 54 55 public String getModuleDisplayName() { 56 return "Most Recent File Uploads" ; 57 } 58 59 public CoefficientContext view(CoefficientContext ctx) throws Exception { 60 HashMap searchParams = new HashMap (); 61 searchParams.put("active", new Boolean (true)); 62 String query = "select upload from " + ProjectUpload.class.getName() 63 + " as upload where upload.folderItem.currentVersion = upload.id and upload.folderItem.maxReadRole.id = ? order by upload.timestamp"; 64 HibernatePager hp = 65 new HibernatePager(query, new Object []{SecurityUtil.getRoleForDescription(SecurityUtil.GUEST_ROLE_DESC).getId()}); 66 if (hp.currentPage().size() > 0) { 67 HashMap map = new HashMap (); 68 map.put("pager", hp); 69 StringBuffer sb = 70 VelocityScreenUtil.getProcessedScreen("view-uploads.vm", map); 71 72 ctx.setModuleContent(sb.toString(), getModuleDisplayName()); 74 } 75 return ctx; 76 } 77 } 78 | Popular Tags |