int startat = startATparam.intValue();
int endat = EndAtparam.intValue();
int begainindex = Math.max(startat - 100, 1);
int endindex = endat + 100;
EventList DL = new EventList();
DL.setSortMember(sortmem);
CVDal cvdl = new CVDal(dataSource);
if (searchString == null)
searchString = "";
String appendStr = "";
String strSQL = "";
String sortType = "";
if (sorttype == 'D') {
sortType = " DESC ";
}
strSQL = "select e.eventid eventid, e.title, detail,start,end, concat(ind.firstname, ' ', ind.lastname) ownername, e.owner, count(er.eventid) registeredattendees from individual ind , `event` e left outer join `eventregister` er on e.eventid = er.eventid where e.owner = ind.individualid group by e.eventid order by "
+ sortmem + sortType + " LIMIT " + (begainindex - 1) + " , " + (endindex + 1) + ";";
if (searchString.startsWith("SIMPLE :")) {
searchString = searchString.substring(8);
appendStr = " where (e.eventid like '%" + searchString + "%' OR e.title like '%"
+ searchString + "%' OR ind.firstname like '%" + searchString
+ "%' OR ind.lastname like '%" + searchString + "%' OR detail like '%" + searchString
+ "%' OR start like '%" + searchString + "%' OR end like '%" + searchString
+ "%' ) and ";
strSQL = strSQL.replaceFirst("where ", appendStr);
}
if ((null != searchString) && (searchString.startsWith("ADVANCE:"))) {
int searchIndex = (searchString.toUpperCase()).indexOf("WHERE");
strSQL = "select event.eventid eventid, event.title, detail,start,end, concat(ind.firstname, ' ', ind.lastname) ownername"
+ ", event.owner, count(er.eventid) registeredattendees from individual ind , "
+ "`event` left outer join `eventregister` er on event.eventid = er.eventid "
+ "where event.owner = ind.individualid and "
+ searchString.substring((searchIndex + 5), searchString.length())
+ " group by event.eventid order by "
+ sortmem
+ sortType
+ " LIMIT "
+ (begainindex - 1) + " , " + (endindex + 1) + ";";
}
cvdl.setSqlQuery(strSQL);
Collection v = cvdl.executeQuery();
cvdl.clearParameters();
cvdl.destroy();
Iterator it = v.iterator();
TimeZone tz = TimeZone.getTimeZone("EST");
int i = 0;
while (it.hasNext()) {
i++;
HashMap hm = (HashMap)it.next();
int ID = ((Long)hm.get("eventid")).intValue();
IntMember eventid = new IntMember("eventid", ID, 10, "", 'T', false, 10);
StringMember title = new StringMember("title", (String)hm.get("title"), 10, "", 'T', true);
StringMember detail = new StringMember("detail", (String)hm.get("detail"), 10, "", 'T', false);
DateMember start = new DateMember("start", (java.util.Date)hm.get("start"), 10, "URL", 'T',
false, 100, "EST");
DateMember end = new DateMember("end", (java.util.Date)hm.get("end"), 10, "URL", 'T', false,
100, "EST");
StringMember ownername = new StringMember("ownername", (String)hm.get("ownername"), 10, "",
'T', true);
// Object test = hm.get("registeredattendees");
int regAtt = ((Number)hm.get("registeredattendees")).intValue();
IntMember registeredattendees = new IntMember("registeredattendees", regAtt, 10, "", 'T',
false, 10);
int ownrid = ((Long)hm.get("owner")).intValue();
IntMember ownerid = new IntMember("ownerid", ownrid, 10, "", 'T', false, 10);
EventListElement ele = new EventListElement(ID);
ele.put("eventid", eventid);
ele.put("title", title);
ele.put("detail", detail);
ele.put("start", start);
ele.put("end", end);
ele.put("ownerid", ownerid);
ele.put("ownername", ownername);
ele.put("registeredattendees", registeredattendees);
// added by Sameer for generating fixed length sort key from i
StringBuffer sb = new StringBuffer("00000000000");
sb.setLength(11);
String str = (new Integer(i)).toString();
sb.replace((sb.length() - str.length()), (sb.length()), str);
String newOrd = sb.toString();
DL.put(newOrd, ele);
DL.setTotalNoOfRecords(DL.size());
DL.setListType("Event");
DL.setBeginIndex(begainindex);
DL.setEndIndex(endindex);
}
return DL;