cvdl.setSqlQuery(strQuery);
Collection col;
col = cvdl.executeQuery();
Iterator it = col.iterator();
int i=0 ;
TimeSlipList timeSlipList = new TimeSlipList();
while( it.hasNext() )
{
i++;
HashMap hm = ( HashMap )it.next();
int timeSlipID = ((Long)hm.get("TimeSlipID")).intValue();
StringMember reference = null, description, projectName = null, taskName =null, createdBy=null;
PureDateMember date=null;
PureTimeMember startTime=null, endTime=null;
IntMember creator, taskId;
IntMember referencetype = new IntMember( "Reference" ,0 , 10 , "", 'T' , true , 10 );
IntMember intmem = new IntMember( "ID" , timeSlipID , 10 , "URL", 'T' , true , 10 );
//IntMember projectId = new IntMember( "ProjectID" , projectID , 10 , "URL", 'T' , true , 10 );
Time tStartTime = (Time)hm.get("Start");
Time tEndTime = (Time)hm.get("End");
Calendar calendarStart = Calendar.getInstance();
calendarStart.setTime(tStartTime);
Calendar calendarEnd = Calendar.getInstance();
calendarEnd.setTime(tEndTime);
//int startHrsmm[] = CVUtility.convertTimeTo24HrsFormat(StartTime);
int startHrs = calendarStart.get(Calendar.HOUR_OF_DAY);//startHrsmm[0];
int startMins = calendarStart.get(Calendar.MINUTE);//startHrsmm[1];
//int endHrsmm[] = CVUtility.convertTimeTo24HrsFormat(EndTime);
int endHrs = calendarEnd.get(Calendar.HOUR_OF_DAY);//endHrsmm[0];
int endMins = calendarEnd.get(Calendar.MINUTE);//endHrsmm[1];
float Duration = 0;
Double dBreakTime = (Double)hm.get("BreakTime");
float BreakTime = dBreakTime.floatValue();
float remMin = 0;
if ( startMins != 0 && endMins != 0 && (startMins-endMins !=0))
{
if(endMins > startMins)
remMin = 60/(endMins - startMins);
else
remMin = 60/(startMins - endMins);
}
Duration = (endHrs - startHrs) + remMin - BreakTime ;
totalDuration += Duration;
if( hm.get( "ActivityID" ) != null && hm.get( "ProjectID" ) !=null && hm.get( "TicketID" ) !=null ){
int activityId = ((Integer)hm.get("ActivityID")).intValue();
int projectId = ((Long)hm.get("ProjectID")).intValue();
int ticketId = ((Long)hm.get("TicketID")).intValue();
if( projectId != 0){
String title = " Project : ";
strQuery = "select ProjectTitle from project where ProjectID = "+projectId;
cvdl.setSqlQuery(strQuery);
Collection colProject = null;
colProject = cvdl.executeQuery();
if (colProject != null)
{
Iterator projectIterator = colProject.iterator();
while( projectIterator.hasNext() )
{
HashMap hm1 = ( HashMap )projectIterator.next();
title = title + (String) hm1.get( "ProjectTitle" );
}
}
if( activityId != 0){
strQuery = "select Title from activity where activityId = "+activityId;
cvdl.setSqlQuery(strQuery);
Collection colActivity = null;
colActivity = cvdl.executeQuery();
if (colActivity != null)
{
Iterator activityIterator = colActivity.iterator();
while( activityIterator.hasNext() )
{
HashMap hm1 = ( HashMap )activityIterator.next();
title = title +"/"+ (String) hm1.get( "Title" );
}
}
}
reference = new StringMember( "Reference", title ,10 , "", 'T' , false );
}
if( ticketId != 0){
strQuery = "select subject from ticket where ticketid = "+ticketId;
cvdl.setSqlQuery(strQuery);
Collection colTicket = null;
colTicket = cvdl.executeQuery();
if (colTicket != null)
{
Iterator itTicket = colTicket.iterator();
while( itTicket.hasNext() )
{
HashMap hm1 = ( HashMap )itTicket.next();
reference = new StringMember( "Reference", " Ticket : "+(String) hm1.get( "subject" ) ,10 , "", 'T' , false );
}
}
}
}
else{
referencetype = new IntMember( "ReferenceType" ,4 , 10 , "", 'T' , true , 10 );
reference = new StringMember( "Reference", "" ,10 , "", 'T' , false );
}
if( hm.get( "Description" ) !=null)
description = new StringMember( "Description", (String) hm.get( "Description" ) ,10 , "", 'T' , false );
else
description = new StringMember( "Description", "" ,10 , "", 'T' , false );
if( hm.get( "Date" ) !=null)
date = new PureDateMember( "Date" ,(java.util.Date)hm.get("Date"),10 , "URL" , 'T' , false ,100 ,"EST");
else
date = new PureDateMember( "Date" ,null,10 , "URL" , 'T' , false ,100 ,"EST" );
if( hm.get( "Start" ) !=null)
startTime = new PureTimeMember( "StartTime" ,(java.util.Date)hm.get("Start"),10 , "URL" , 'T' , false ,100 ,"EST");
else
startTime = new PureTimeMember( "StartTime" ,null,10 , "URL" , 'T' , false ,100 ,"EST");
if( hm.get( "End" ) !=null)
endTime = new PureTimeMember( "EndTime" ,(java.util.Date)hm.get("End"),10 , "URL" , 'T' , false ,100 ,"EST");
else
endTime = new PureTimeMember( "EndTime" ,null,10 , "URL" , 'T' , false ,100 ,"EST");
TimeSlipListElement ele = new TimeSlipListElement(timeSlipID);
ele.put("ID", intmem );
ele.put("Description", description );
ele.put("Reference", reference );
ele.put("ReferenceType", referencetype );
ele.put("Task" , taskName );
if ( Duration > 1.0 )
{
StringMember duration = new StringMember( "Duration" , Float.toString(Duration)+ " hours" , 10 , "URL", 'T' , false );
ele.put("Duration" , duration );
}
else if ( Duration == 1.0 )
{
StringMember duration = new StringMember( "Duration" , Float.toString(Duration)+ " hour" , 10 , "URL", 'T' , false );
ele.put("Duration" , duration );
}
else if ( Duration > 0.0 && Duration < 1.0 )
{
StringMember duration = new StringMember( "Duration" , Float.toString(Duration*60)+ " minutes" , 10 , "URL", 'T' , false );
ele.put("Duration" , duration );
}
else
{
StringMember duration = new StringMember( "Duration" , "" , 10 , "URL", 'T' , false );
ele.put("Duration" , duration );
}
ele.put("Date" , date );
ele.put("StartTime" , startTime);
ele.put("EndTime" , endTime);
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();
timeSlipList.put(newOrd , ele);
//timeSlipList.setTotalNoOfRecords( timeSlipList.size() );
timeSlipList.setListType( "Timeslip" );
//Set timeslip list in vo
tvo.setTimeSlipList(timeSlipList);
tvo.setTotalDuration(totalDuration);