String callType = activityForm.getActivityCallType();
activity.setCallTypeId(Integer.parseInt(callType));
}
if (CVUtility.notEmpty(activityForm.getActivityStartDate())) {
Calendar start = new GregorianCalendar();
Calendar startTime = new GregorianCalendar();
try {
logger.debug("dateformat: "+df.toString()+", lenient?: "+df.isLenient()+", locale: "+activityForm.getLocale());
start.setTime(df.parse(activityForm.getActivityStartDate()));
startTime.setTime(tf.parse(activityForm.getActivityStartTime()));
logger.debug("parsed start date: "+df.format(start.getTime()));
logger.debug("parsed start time: "+tf.format(startTime.getTime()));
} catch (ParseException e) {
logger.error("[fillBasic]: Can't parse start date or time", e);
}
start.set(Calendar.HOUR, startTime.get(Calendar.HOUR));
start.set(Calendar.MINUTE, startTime.get(Calendar.MINUTE));
start.set(Calendar.AM_PM, startTime.get(Calendar.AM_PM));
activity.setActivityStartDate(new Timestamp(start.getTimeInMillis()));
}
if (CVUtility.notEmpty(activityForm.getActivityEndDate())) {
Calendar end = new GregorianCalendar();
Calendar endTime = new GregorianCalendar();
try {
end.setTime(df.parse(activityForm.getActivityEndDate()));
endTime.setTime(tf.parse(activityForm.getActivityEndTime()));
logger.debug("parsed end date: "+df.format(end.getTime()));
logger.debug("parsed end time: "+tf.format(endTime.getTime()));
} catch (ParseException e) {
logger.error("[fillBasic]: Can't parse end date or time", e);
}
end.set(Calendar.HOUR, endTime.get(Calendar.HOUR));
end.set(Calendar.MINUTE, endTime.get(Calendar.MINUTE));
end.set(Calendar.AM_PM, endTime.get(Calendar.AM_PM));
activity.setActivityEndDate(new Timestamp(end.getTimeInMillis()));
}
if ((activityForm.getActivityOwnerID() != null)
&& (activityForm.getActivityOwnerID().length() > 0)) {
activity.setOwner(Integer.parseInt(activityForm.getActivityOwnerID()));
}
try {
String tmpPriority = activityForm.getActivityPriority();
if ((tmpPriority != null) && (!tmpPriority.equals(""))) {
activity.setPriority(Integer.parseInt(tmpPriority));
} else {
activity.setPriority(2);
}
} catch (Exception e) {
activity.setPriority(2);
}
if ((activityForm.getActivityNotes() != null) && (activityForm.getActivityNotes().length() > 0)) {
activity.setNotes(activityForm.getActivityNotes());
}
try {
String tmpStatus = activityForm.getActivityStatus();
if ((tmpStatus != null) && (!tmpStatus.equals(""))) {
activity.setStatus(Integer.parseInt(tmpStatus));
} else {
activity.setStatus(2);
}
} catch (Exception e) {
activity.setStatus(2);
}
activity.setVisibility(activityForm.getActivityVisibility());
String reminder = activityForm.getActivityReminder();
if (activityForm.getActivityReminder() != null && reminder.equals("on")) {
ActivityActionVO action = new ActivityActionVO();
action.setActionType(ActivityActionVO.AA_ALERT);
// FIXME externalize String
action.setMessage("Scheduled Alert: " + activity.getTitle());
action.setInterval(0);
action.setRepeat(0);
if (CVUtility.notEmpty(activityForm.getActivityRemindDate())
&& CVUtility.notEmpty(activityForm.getActivityReminderTime())) {
Calendar remind = new GregorianCalendar();
Calendar remindTime = new GregorianCalendar();
try {
remind.setTime(df.parse(activityForm.getActivityRemindDate()));
remindTime.setTime(tf.parse(activityForm.getActivityReminderTime()));
} catch (ParseException e) {
logger.error("[fillBasic]: Exception", e);
}
remind.set(Calendar.HOUR, remindTime.get(Calendar.HOUR));
remind.set(Calendar.MINUTE, remindTime.get(Calendar.MINUTE));
remind.set(Calendar.AM_PM, remindTime.get(Calendar.AM_PM));
action.setActionTime(new Timestamp(remind.getTimeInMillis()));
}
action.setRecipient(activity.getOwner());
activity.setActivityAction(action);
} // end if (activityForm.getActivityReminder() != null &&
// reminder.equals("on"))
String emailinvitation = activityForm.getActivityEmailInvitation();
if (activityForm.getActivityEmailInvitation() != null && emailinvitation.equals("on")) {
ActivityActionVO activityactionvo = new ActivityActionVO();
activityactionvo.setActionType(ActivityActionVO.AA_EMAIL);
activityactionvo.setMessage("Invitation : " + activity.getTitle());
activityactionvo.setInterval(0);
activityactionvo.setRepeat(0);
String[] attendeerequired = activityForm.getActivityAttendeesRequired();
String[] attendeeoptional = activityForm.getActivityAttendeesOptional();
if (attendeerequired != null) {
for (int i = 0; i < attendeerequired.length; i++) {
try {
int indexOfHash = attendeerequired[i].indexOf("#");
String idName = attendeerequired[i].substring(0, indexOfHash);
activityactionvo.setRecipient(Integer.parseInt(idName));
}// end of try block
catch (Exception e) {}// end of catch block
}// end of for( int i=0 ; i < attendeerequired.length ; i ++ )
}// end of if (attendeerequired != null)
if (attendeeoptional != null) {
for (int j = 0; j < attendeeoptional.length; j++) {
try {
int indexOfHash = attendeeoptional[j].indexOf("#");
String idName = attendeeoptional[j].substring(0, indexOfHash);
activityactionvo.setRecipient(Integer.parseInt(idName));
} // end of try block
catch (Exception e) {}// end of catch block
}// end of for( int j=0 ; j < attendeeoptional.length ; j ++ )
}// end of if (attendeeoptional != null)
activity.setActivityAction(activityactionvo);
}// end of if (activityForm.getActivityEmailInvitation() != null &&.......)
String freq = activityForm.getActivityRecurringFrequency();
if ((freq != null) && (freq.length() > 0)
&& (CVUtility.notEmpty(activityForm.getActivityRecurStartDate()))) {
RecurrenceVO recur = new RecurrenceVO();
Calendar recurStart = new GregorianCalendar();
try {
recurStart.setTime(df.parse(activityForm.getActivityRecurStartDate()));
} catch (ParseException e) {
logger.error("[fillBasic]: Exception", e);
}
recur.setStartDate(new Date(recurStart.getTimeInMillis()));
if (CVUtility.notEmpty(activityForm.getActivityRecurEndDate())) {
Calendar recurEnd = new GregorianCalendar();
try {
recurEnd.setTime(df.parse(activityForm.getActivityRecurEndDate()));
} catch (ParseException e) {
logger.error("[fillBasic]: Exception", e);
}
recur.setUntil(new Date(recurEnd.getTimeInMillis()));
}
recur.setTimePeriod(activityForm.getActivityRecurringFrequency());
HashMap mapRecurrence = new HashMap();
mapRecurrence.put("FREQUENCY", activityForm.getActivityRecurringFrequency());
boolean isRecurr = false;