int startMonth = startDate.getMonth();
int startDay = startDate.getDate();
Date startDateTime = new Date( startYear, startMonth, startDay, startHour, startMin );
Date endDate = scheduleEditorWizardPanel.getEndDate();
MonthOfYear monthOfYear = scheduleEditor.getRecurrenceEditor().getSelectedMonth();
List<DayOfWeek> daysOfWeek = scheduleEditor.getRecurrenceEditor().getSelectedDaysOfWeek();
Integer dayOfMonth = scheduleEditor.getRecurrenceEditor().getSelectedDayOfMonth();
WeekOfMonth weekOfMonth = scheduleEditor.getRecurrenceEditor().getSelectedWeekOfMonth();
if ( isBlockoutDialog ) {
jsJobTrigger.setBlockDuration( calculateBlockoutDuration() );
} else {
// blockDuration is only valid for blockouts
jsJobTrigger.setBlockDuration( new Long( -1 ) );
}
if ( scheduleType == ScheduleType.RUN_ONCE ) { // Run once types
jsJobTrigger.setType( "simpleJobTrigger" ); //$NON-NLS-1$
jsJobTrigger.setRepeatInterval( 0 );
jsJobTrigger.setRepeatCount( 0 );
jsJobTrigger.setNativeStartTime( DateTimeFormat.getFormat( PredefinedFormat.ISO_8601 ).format( startDateTime ) );
} else if ( ( scheduleType == ScheduleType.SECONDS ) || ( scheduleType == ScheduleType.MINUTES )
|| ( scheduleType == ScheduleType.HOURS ) ) {
int repeatInterval = 0;
try { // Simple Trigger Types
repeatInterval = Integer.parseInt( scheduleEditorWizardPanel.getRepeatInterval() );
} catch ( Exception e ) {
// ignored
}
jsJobTrigger.setType( "simpleJobTrigger" ); //$NON-NLS-1$
jsJobTrigger.setRepeatInterval( repeatInterval );
jsJobTrigger.setRepeatCount( -1 );
jsJobTrigger.setNativeStartTime( DateTimeFormat.getFormat( PredefinedFormat.ISO_8601 ).format( startDateTime ) );
if ( endDate != null ) {
jsJobTrigger.setNativeEndTime( DateTimeFormat.getFormat( PredefinedFormat.ISO_8601 ).format( endDate ) );
}
} else if ( scheduleType == ScheduleType.DAILY ) {
if ( scheduleEditor.getRecurrenceEditor().isEveryNDays() ) {
int repeatInterval = 0;
try { // Simple Trigger Types
repeatInterval = Integer.parseInt( scheduleEditorWizardPanel.getRepeatInterval() );
} catch ( Exception e ) {
// ignored
}
jsJobTrigger.setType( "simpleJobTrigger" ); //$NON-NLS-1$
jsJobTrigger.setRepeatInterval( repeatInterval );
jsJobTrigger.setRepeatCount( -1 );
jsJobTrigger.setNativeStartTime( DateTimeFormat.getFormat( PredefinedFormat.ISO_8601 ).format( startDateTime ) );
if ( endDate != null ) {
jsJobTrigger.setNativeEndTime( DateTimeFormat.getFormat( PredefinedFormat.ISO_8601 ).format( endDate ) );
}
} else {
JsArrayInteger jsDaysOfWeek = (JsArrayInteger) JavaScriptObject.createArray();
int i = 0;
for ( DayOfWeek dayOfWeek : daysOfWeek ) {
jsDaysOfWeek.set( i++, dayOfWeek.ordinal() + 1 );
}
JsArrayInteger hours = (JsArrayInteger) JavaScriptObject.createArray();
hours.set( 0, startHour );
JsArrayInteger minutes = (JsArrayInteger) JavaScriptObject.createArray();
hours.set( 0, startMin );
JsArrayInteger seconds = (JsArrayInteger) JavaScriptObject.createArray();
hours.set( 0, 0 );
jsJobTrigger.setType( "complexJobTrigger" ); //$NON-NLS-1$
jsJobTrigger.setDayOfWeekRecurrences( jsDaysOfWeek );
jsJobTrigger.setHourRecurrences( hours );
jsJobTrigger.setMinuteRecurrences( minutes );
jsJobTrigger.setSecondRecurrences( seconds );
jsJobTrigger.setNativeStartTime( DateTimeFormat.getFormat( PredefinedFormat.ISO_8601 ).format( startDateTime ) );
if ( endDate != null ) {
jsJobTrigger.setNativeEndTime( DateTimeFormat.getFormat( PredefinedFormat.ISO_8601 ).format( endDate ) );
}
}
} else if ( scheduleType == ScheduleType.CRON ) { // Cron jobs
jsJobTrigger.setType( "cronJobTrigger" ); //$NON-NLS-1$
} else if ( ( scheduleType == ScheduleType.WEEKLY ) && ( daysOfWeek.size() > 0 ) ) {
JsArrayInteger jsDaysOfWeek = (JsArrayInteger) JavaScriptObject.createArray();
int i = 0;
for ( DayOfWeek dayOfWeek : daysOfWeek ) {
jsDaysOfWeek.set( i++, dayOfWeek.ordinal() + 1 );
}
JsArrayInteger hours = (JsArrayInteger) JavaScriptObject.createArray();
hours.set( 0, startHour );
JsArrayInteger minutes = (JsArrayInteger) JavaScriptObject.createArray();
hours.set( 0, startMin );
JsArrayInteger seconds = (JsArrayInteger) JavaScriptObject.createArray();
hours.set( 0, 0 );
jsJobTrigger.setType( "complexJobTrigger" ); //$NON-NLS-1$
jsJobTrigger.setDayOfWeekRecurrences( jsDaysOfWeek );
jsJobTrigger.setHourRecurrences( hours );
jsJobTrigger.setMinuteRecurrences( minutes );
jsJobTrigger.setSecondRecurrences( seconds );
jsJobTrigger.setNativeStartTime( DateTimeFormat.getFormat( PredefinedFormat.ISO_8601 ).format( startDateTime ) );
if ( endDate != null ) {
jsJobTrigger.setNativeEndTime( DateTimeFormat.getFormat( PredefinedFormat.ISO_8601 ).format( endDate ) );
}
} else if ( ( scheduleType == ScheduleType.MONTHLY )
|| ( ( scheduleType == ScheduleType.YEARLY ) && ( monthOfYear != null ) ) ) {
jsJobTrigger.setType( "complexJobTrigger" ); //$NON-NLS-1$
if ( dayOfMonth != null ) {
JsArrayInteger jsDaysOfMonth = (JsArrayInteger) JavaScriptObject.createArray();
jsDaysOfMonth.set( 0, dayOfMonth );
JsArrayInteger hours = (JsArrayInteger) JavaScriptObject.createArray();
hours.set( 0, startHour );
JsArrayInteger minutes = (JsArrayInteger) JavaScriptObject.createArray();
hours.set( 0, startMin );
JsArrayInteger seconds = (JsArrayInteger) JavaScriptObject.createArray();
hours.set( 0, 0 );
jsJobTrigger.setType( "complexJobTrigger" ); //$NON-NLS-1$
if ( monthOfYear != null ) {
JsArrayInteger jsMonthsOfYear = (JsArrayInteger) JavaScriptObject.createArray();
jsMonthsOfYear.set( 0, monthOfYear.ordinal() + 1 );
jsJobTrigger.setMonthlyRecurrences( jsMonthsOfYear );
}
jsJobTrigger.setDayOfMonthRecurrences( jsDaysOfMonth );
jsJobTrigger.setHourRecurrences( hours );
jsJobTrigger.setMinuteRecurrences( minutes );
jsJobTrigger.setSecondRecurrences( seconds );
jsJobTrigger.setNativeStartTime( DateTimeFormat.getFormat( PredefinedFormat.ISO_8601 ).format( startDateTime ) );
if ( endDate != null ) {
jsJobTrigger.setNativeEndTime( DateTimeFormat.getFormat( PredefinedFormat.ISO_8601 ).format( endDate ) );
}
} else if ( ( daysOfWeek.size() > 0 ) && ( weekOfMonth != null ) ) {
JsArrayInteger jsDaysOfWeek = (JsArrayInteger) JavaScriptObject.createArray();
int i = 0;
for ( DayOfWeek dayOfWeek : daysOfWeek ) {
jsDaysOfWeek.set( i++, dayOfWeek.ordinal() + 1 );
}
JsArrayInteger hours = (JsArrayInteger) JavaScriptObject.createArray();
hours.set( 0, startHour );
JsArrayInteger minutes = (JsArrayInteger) JavaScriptObject.createArray();
hours.set( 0, startMin );
JsArrayInteger seconds = (JsArrayInteger) JavaScriptObject.createArray();
hours.set( 0, 0 );
jsJobTrigger.setType( "complexJobTrigger" ); //$NON-NLS-1$
if ( monthOfYear != null ) {
JsArrayInteger jsMonthsOfYear = (JsArrayInteger) JavaScriptObject.createArray();
jsMonthsOfYear.set( 0, monthOfYear.ordinal() + 1 );
jsJobTrigger.setMonthlyRecurrences( jsMonthsOfYear );
}
jsJobTrigger.setHourRecurrences( hours );
jsJobTrigger.setMinuteRecurrences( minutes );
jsJobTrigger.setSecondRecurrences( seconds );