jobTrigger = simpleJobTrigger;
} else if ( scheduleRequest.getComplexJobTrigger() != null ) {
ComplexJobTriggerProxy proxyTrigger = scheduleRequest.getComplexJobTrigger();
ComplexJobTrigger complexJobTrigger = new ComplexJobTrigger();
complexJobTrigger.setStartTime( proxyTrigger.getStartTime() );
complexJobTrigger.setEndTime( proxyTrigger.getEndTime() );
if ( proxyTrigger.getDaysOfWeek().length > 0 ) {
if ( proxyTrigger.getWeeksOfMonth().length > 0 ) {
for ( int dayOfWeek : proxyTrigger.getDaysOfWeek() ) {
for ( int weekOfMonth : proxyTrigger.getWeeksOfMonth() ) {
QualifiedDayOfWeek qualifiedDayOfWeek = new QualifiedDayOfWeek();
qualifiedDayOfWeek.setDayOfWeek( DayOfWeek.values()[dayOfWeek] );
if ( weekOfMonth == JobScheduleRequest.LAST_WEEK_OF_MONTH ) {
qualifiedDayOfWeek.setQualifier( DayOfWeekQualifier.LAST );
} else {
qualifiedDayOfWeek.setQualifier( DayOfWeekQualifier.values()[weekOfMonth] );
}
complexJobTrigger.addDayOfWeekRecurrence( qualifiedDayOfWeek );
}
}
} else {
for ( int dayOfWeek : proxyTrigger.getDaysOfWeek() ) {
complexJobTrigger.addDayOfWeekRecurrence( dayOfWeek + 1 );
}
}
} else if ( proxyTrigger.getDaysOfMonth().length > 0 ) {
for ( int dayOfMonth : proxyTrigger.getDaysOfMonth() ) {
complexJobTrigger.addDayOfMonthRecurrence( dayOfMonth );
}
}
for ( int month : proxyTrigger.getMonthsOfYear() ) {
complexJobTrigger.addMonthlyRecurrence( month + 1 );
}
for ( int year : proxyTrigger.getYears() ) {
complexJobTrigger.addYearlyRecurrence( year );
}
Calendar calendar = Calendar.getInstance();
calendar.setTime( complexJobTrigger.getStartTime() );
complexJobTrigger.setHourlyRecurrence( calendar.get( Calendar.HOUR_OF_DAY ) );
complexJobTrigger.setMinuteRecurrence( calendar.get( Calendar.MINUTE ) );
complexJobTrigger.setUiPassParam( scheduleRequest.getComplexJobTrigger().getUiPassParam() );
jobTrigger = complexJobTrigger;
} else if ( scheduleRequest.getCronJobTrigger() != null ) {
if ( scheduler instanceof QuartzScheduler ) {
String cronString = scheduleRequest.getCronJobTrigger().getCronString();
String delims = "[ ]+"; //$NON-NLS-1$
String[] tokens = cronString.split( delims );
if ( tokens.length < 7 ) {
cronString += " *";
}
ComplexJobTrigger complexJobTrigger = QuartzScheduler.createComplexTrigger( cronString );
complexJobTrigger.setStartTime( scheduleRequest.getCronJobTrigger().getStartTime() );
complexJobTrigger.setEndTime( scheduleRequest.getCronJobTrigger().getEndTime() );
complexJobTrigger.setUiPassParam( scheduleRequest.getCronJobTrigger().getUiPassParam() );
jobTrigger = complexJobTrigger;
} else {
throw new IllegalArgumentException();
}
}