* @return ActivityForm
*/
public ActivityForm fillBasicForm(ActivityVO activity, ActivityForm activityForm)
{
try {
DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, activityForm.getLocale());
DateFormat tf = DateFormat.getTimeInstance(DateFormat.SHORT, activityForm.getLocale());
activityForm.setActivityType(String.valueOf(activity.getActivityType()));
activityForm.setActivityID(String.valueOf(activity.getActivityID()));
activityForm.setActivityTitle(activity.getTitle());
activityForm.setActivityPriority(String.valueOf(activity.getPriority()));
// Set the RelatedField Information:
activityForm.setActivityRelatedFieldID(Integer.toString(activity.getRelatedFieldID()));
activityForm.setActivityRelatedFieldValue(activity.getRelatedFieldValue());
activityForm.setActivityRelatedTypeID(Integer.toString(activity.getRelatedTypeID()));
activityForm.setActivityRelatedTypeValue(activity.getRelatedTypeValue());
if (activity.getNotes() != null) {
activityForm.setActivityNotes(String.valueOf(activity.getNotes()));
} else {
activityForm.setActivityNotes("");
}
activityForm.setActivityCallType(String.valueOf(activity.getCallTypeId()));
activityForm.setActivityID(String.valueOf(activity.getActivityID()));
if (activity.getActivityDetails() != null) {
activityForm.setActivityDetail(activity.getActivityDetails());
}
if (activity.getActivityStartDate() != null) {
Timestamp startTimeStamp = activity.getActivityStartDate();
Calendar start = new GregorianCalendar();
start.setTime(startTimeStamp);
activityForm.setActivityStartDate(df.format(start.getTime()));
activityForm.setActivityStartTime(tf.format(start.getTime()));
}
if (activity.getActivityEndDate() != null) {
Timestamp endTimeStamp = activity.getActivityEndDate();
Calendar end = new GregorianCalendar();
end.setTime(endTimeStamp);
activityForm.setActivityEndDate(df.format(end.getTime()));
activityForm.setActivityEndTime(tf.format(end.getTime()));
}
RecurrenceVO recurrenceVO = null;
if (activity.getRecurrence() != null) {
recurrenceVO = activity.getRecurrence();
activityForm.setActivityRecurringFrequency(recurrenceVO.getTimePeriod());
// if date is not null convert from timestamp to String
if (recurrenceVO.getStartDate() != null) {
Date recurStartDate = recurrenceVO.getStartDate();
Calendar recurStart = new GregorianCalendar();
recurStart.setTime(recurStartDate);
activityForm.setActivityRecurStartDate(df.format(recurStart.getTime()));
activityForm.setActivityRecurringStartTime(tf.format(recurStart.getTime()));
}
if (recurrenceVO.getUntil() != null) {
Date recurEndDate = recurrenceVO.getUntil();
Calendar recurEnd = new GregorianCalendar();
recurEnd.setTime(recurEndDate);
activityForm.setActivityRecurEndDate(df.format(recurEnd.getTime()));
}
HashMap mapRecurrence = recurrenceVO.getRecurrenceHM();
if (mapRecurrence != null) {
if (mapRecurrence.size() > 0) {
String frequency = (String)mapRecurrence.get("FREQUENCY");
String every = (String)mapRecurrence.get("EVERY");
String on = (String)mapRecurrence.get("ON");
activityForm.setActivityRecurringFrequency(frequency);
if (frequency.equals("DAY")) {
activityForm.setActivityRecurringDailyEvery("1");
activityForm.setActivityRecurringDailyDays(every);
if (Integer.parseInt(on) > 0) {
activityForm.setActivityRecurringDailyWeekdays("1");
}
} else if (frequency.equals("WEEK")) {
activityForm.setActivityRecurringWeeklyEvery(every);
StringTokenizer st = new StringTokenizer(on, ",");
String strweeklyon[] = new String[st.countTokens()];
int i = 0;
while (st.hasMoreTokens()) {
String strToken = st.nextToken();
if (strToken.equals("6")) {
strToken = "Su";
} else if (strToken.equals("0")) {
strToken = "Mo";
} else if (strToken.equals("1")) {
strToken = "Tu";
} else if (strToken.equals("2")) {
strToken = "We";
} else if (strToken.equals("3")) {
strToken = "Th";
} else if (strToken.equals("4")) {
strToken = "Fr";
} else if (strToken.equals("5")) {
strToken = "Sa";
}
strweeklyon[i] = strToken.trim();
i++;
}
String selectedweek[] = { "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" };
activityForm.setActivityRecurringWeeklyOn(strweeklyon);
activityForm.setActivitySelectedWeek(selectedweek);
activityForm.setActivityFindWeek(strweeklyon);
} else if (frequency.equals("MONTH")) {
String onstring = on;
int inton = Integer.parseInt(onstring.substring(0, 1));
activityForm.setActivityRecurringMonthlyEvery("" + inton);
if (inton == 0) {
String monthday = onstring.substring(2, onstring.length());
activityForm.setActivityRecurringMonthlyEveryDay(monthday);
activityForm.setActivityRecurringMonthlyOnWeek("-1");
activityForm.setActivityRecurringMonthlyOnDay("-1");
}
if (inton == 1) {
activityForm.setActivityRecurringMonthlyOnDay(onstring.substring(2, 3));
activityForm.setActivityRecurringMonthlyOnWeek(onstring.substring(4, 5));
}
} else if (frequency.equals("YEAR")) {
String onstring = on;
int inton = Integer.parseInt(onstring.substring(0, 1));
activityForm.setActivityRecurringYearlyEvery("" + inton);
if (inton == 0) {
activityForm.setActivityRecurringYearlyEveryMonth(every);
String yearday = onstring.substring(2, onstring.length());
activityForm.setActivityRecurringYearlyEveryDay(yearday);
activityForm.setActivityRecurringYearlyOnWeek("-1");
activityForm.setActivityRecurringYearlyOnDay("-1");
}
if (inton == 1) {
activityForm.setActivityRecurringYearlyOnMonth(every);
activityForm.setActivityRecurringYearlyOnWeek(onstring.substring(2, 3));
activityForm.setActivityRecurringYearlyOnDay(onstring.substring(4, 5));
}
}// end of else if (frequency.equals("YEAR"))
}// end of if (mapRecurrence.size()>0)
}// end of if (mapRecurrence != null)
}// end of if (actVo.getRecurrence() != null)
Collection activityAction = null;
if (activity.getActivityAction() != null) {
activityAction = activity.getActivityAction();
Iterator it = activityAction.iterator();
while (it.hasNext()) {
ActivityActionVO acVO = (ActivityActionVO)it.next();
String strActionType = acVO.getActionType();
if (strActionType.equals(ActivityActionVO.AA_ALERT)) {
activityForm.setActivityReminder("on");
if (acVO.getActionTime() != null) {
Timestamp remindTimeStamp = acVO.getActionTime();
Calendar remind = new GregorianCalendar();
remind.setTime(remindTimeStamp);
activityForm.setActivityRemindDate(df.format(remind.getTime()));
activityForm.setActivityReminderTime(tf.format(remind.getTime()));
}// end of if (acVO.getActionTime() != null)
}// end of if (strActionType.equals(ActivityActionVO.AA_ALERT))
else if (strActionType.equals(ActivityActionVO.AA_EMAIL)) {
activityForm.setActivityEmailInvitation("on");
}// end of else if (strActionType.equals(ActivityActionVO.AA_EMAIL))