@PostConstruct public void init() { try { this.allLazyModel = new LazyActivityModel(activityFacade); int cnt = (int) activityFacade.getTotalCount(); allLazyModel.setRowCount(cnt); } catch (IllegalArgumentException e) { logger.log(Level.SEVERE, "Failed to initialize LazyActivityModel.", e); this.allLazyModel = null; } }
public String findLastActivity(int id) { Iterator<Activity> itr = activityFacade.activityOnID(id).listIterator(); long currentTime = new Date().getTime(); while (itr.hasNext()) { long fetchedTime = itr.next().getTimestamp().getTime(); if ((currentTime - fetchedTime) / 1000 >= 0 && (currentTime - fetchedTime) / 1000 <= 20) { return String.format("less than a minute ago."); } else if ((currentTime - fetchedTime) / 1000 > 20 && (currentTime - fetchedTime) / 1000 <= 118) { return String.format("about %s minute ago.", 1); } else if ((currentTime - fetchedTime) / 1000 > 118 && (currentTime - fetchedTime) / 1000 < 1800) { return String.format("%s minutes ago.", (currentTime - fetchedTime) / 60000); } else if ((currentTime - fetchedTime) / 1000 > 1800 && (currentTime - fetchedTime) / 1000 <= 7056) { return String.format("about %s hour ago.", 1); } else if ((currentTime - fetchedTime) / 1000 > 7056 && (currentTime - fetchedTime) / 1000 <= 45400) { return String.format("%s hours ago.", (currentTime - fetchedTime) / 3600000); } else if ((currentTime - fetchedTime) / 1000 > 45400 && (currentTime - fetchedTime) / 1000 <= 170000) { return String.format("about %s day ago.", 1); } else if ((currentTime - fetchedTime) / 1000 > 170000 && (currentTime - fetchedTime) / 1000 <= 1300000) { return String.format("%s days ago.", (currentTime - fetchedTime) / 86400000); } else if ((currentTime - fetchedTime) / 1000 > 1300000 && (currentTime - fetchedTime) / 1000 <= 2500000) { return String.format("about %s month ago.", 1); } else if ((currentTime - fetchedTime) / 1000 > 2500000 && (currentTime - fetchedTime) / 1000 < 25000000) { return String.format("%s months ago.", (currentTime - fetchedTime) / 1000 / 2600000); } else { return String.format("about %s year ago.", 1); } } return "more than a year ago"; // dummy }
public String findLastActivityOnProject(Project project) { Activity itr = activityFacade.lastActivityOnProject(project); long currentTime = new Date().getTime(); long getLastUpdate = itr.getTimestamp().getTime(); if ((currentTime - getLastUpdate) / 1000 >= 0 && (currentTime - getLastUpdate) / 1000 <= 20) { return String.format("less than a minute ago."); } else if ((currentTime - getLastUpdate) / 1000 > 20 && (currentTime - getLastUpdate) / 1000 <= 118) { return String.format("about %s minute ago.", 1); } else if ((currentTime - getLastUpdate) / 1000 > 118 && (currentTime - getLastUpdate) / 1000 < 1800) { return String.format("%s minutes ago.", (currentTime - getLastUpdate) / 60000); } else if ((currentTime - getLastUpdate) / 1000 > 1800 && (currentTime - getLastUpdate) / 1000 <= 7056) { return String.format("about %s hour ago.", 1); } else if ((currentTime - getLastUpdate) / 1000 > 7056 && (currentTime - getLastUpdate) / 1000 <= 45400) { return String.format("%s hours ago.", (currentTime - getLastUpdate) / 3600000); } else if ((currentTime - getLastUpdate) / 1000 > 45400 && (currentTime - getLastUpdate) / 1000 <= 170000) { return String.format("about %s day ago.", 1); } else if ((currentTime - getLastUpdate) / 1000 > 170000 && (currentTime - getLastUpdate) / 1000 <= 1300000) { return String.format("%s days ago.", (currentTime - getLastUpdate) / 86400000); } else if ((currentTime - getLastUpdate) / 1000 > 1300000 && (currentTime - getLastUpdate) / 1000 <= 2500000) { return String.format("about %s month ago.", 1); } else if ((currentTime - getLastUpdate) / 1000 > 2500000 && (currentTime - getLastUpdate) / 1000 < 25000000) { return String.format("%s months ago.", (currentTime - getLastUpdate) / 1000 / 2600000); } else { return String.format("about %s year ago.", 1); } }