Java Code Examples for org.quartz.Trigger#getEndTime()

The following examples show how to use org.quartz.Trigger#getEndTime() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TriggerSupport.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
public static CompositeData toCompositeData(Trigger trigger) {
    try {
        return new CompositeDataSupport(COMPOSITE_TYPE, ITEM_NAMES,
                new Object[] {
                        trigger.getKey().getName(),
                        trigger.getKey().getGroup(),
                        trigger.getJobKey().getName(),
                        trigger.getJobKey().getGroup(),
                        trigger.getDescription(),
                        JobDataMapSupport.toTabularData(trigger
                                .getJobDataMap()),
                        trigger.getCalendarName(),
                        ((OperableTrigger)trigger).getFireInstanceId(),
                        trigger.getMisfireInstruction(),
                        trigger.getPriority(), trigger.getStartTime(),
                        trigger.getEndTime(), trigger.getNextFireTime(),
                        trigger.getPreviousFireTime(),
                        trigger.getFinalFireTime() });
    } catch (OpenDataException e) {
        throw new RuntimeException(e);
    }
}
 
Example 2
Source File: TriggerSupport.java    From AsuraFramework with Apache License 2.0 6 votes vote down vote up
public static CompositeData toCompositeData(Trigger trigger) {
	try {
		return new CompositeDataSupport(COMPOSITE_TYPE, ITEM_NAMES,
				new Object[] {
						trigger.getName(),
						trigger.getGroup(),
						trigger.getJobName(),
						trigger.getJobGroup(),
						trigger.getDescription(),
						JobDataMapSupport.toTabularData(trigger
								.getJobDataMap()), trigger.isVolatile(),
						trigger.getCalendarName(),
						trigger.getFireInstanceId(),
						trigger.getMisfireInstruction(),
						trigger.getPriority(), trigger.getStartTime(),
						trigger.getEndTime(), trigger.getNextFireTime(),
						trigger.getPreviousFireTime(),
						trigger.getFinalFireTime() });
	} catch (OpenDataException e) {
		throw new RuntimeException(e);
	}
}
 
Example 3
Source File: SchedulerServiceSupplier.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Builds the triggers list xml string.
 * 
 * @param triggers the triggers
 * 
 * @return the string
 * 
 * @throws SourceBeanException the source bean exception
 */
public  String buildTriggersListXmlString(Trigger[] triggers) throws SourceBeanException {
	StringBuffer buffer = new StringBuffer("<ROWS>");
	if (triggers != null && triggers.length > 0) {
		for (int i = 0; i < triggers.length; i++) {
			Trigger trigger = triggers[i];
			if(trigger.getName().startsWith("schedule_uuid_")) {
				continue;
			}
			buffer.append("<ROW ");
			String triggerName = trigger.getName();
			String triggerGroup = trigger.getGroup();
			String triggerDescription = trigger.getDescription();
			String triggerCalendarName = trigger.getCalendarName();
			Date triggerStartTime = trigger.getStartTime();
			String triggerStartTimeStr = triggerStartTime != null ? triggerStartTime.toString(): "";
			Date triggerEndTime = trigger.getEndTime();
			String triggerEndTimeStr = triggerEndTime != null ? triggerEndTime.toString(): "";
			buffer.append(" triggerName=\"" + (triggerName != null ? triggerName : "") + "\"");
			buffer.append(" triggerGroup=\"" + (triggerGroup != null ? triggerGroup : "") + "\"");
			buffer.append(" triggerDescription=\"" + (triggerDescription != null ? triggerDescription : "") + "\"");
			buffer.append(" triggerCalendarName=\"" + (triggerCalendarName != null ? triggerCalendarName : "") + "\"");
			buffer.append(" triggerStartTime=\"" + triggerStartTimeStr + "\"");
			buffer.append(" triggerEndTime=\"" + triggerEndTimeStr + "\"");
			buffer.append(" />");
		}
	}
	buffer.append("</ROWS>");
	return buffer.toString();
}
 
Example 4
Source File: PointbaseDelegate.java    From AsuraFramework with Apache License 2.0 4 votes vote down vote up
public int insertTrigger(Connection conn, Trigger trigger, String state,
        JobDetail jobDetail) throws SQLException, IOException {

    ByteArrayOutputStream baos = serializeJobData(trigger.getJobDataMap());
    int len = baos.toByteArray().length;
    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    
    PreparedStatement ps = null;

    int insertResult = 0;

    try {
        ps = conn.prepareStatement(rtp(INSERT_TRIGGER));
        ps.setString(1, trigger.getName());
        ps.setString(2, trigger.getGroup());
        ps.setString(3, trigger.getJobName());
        ps.setString(4, trigger.getJobGroup());
        setBoolean(ps, 5, trigger.isVolatile());
        ps.setString(6, trigger.getDescription());
        ps.setBigDecimal(7, new BigDecimal(String.valueOf(trigger
                .getNextFireTime().getTime())));
        long prevFireTime = -1;
        if (trigger.getPreviousFireTime() != null) {
            prevFireTime = trigger.getPreviousFireTime().getTime();
        }
        ps.setBigDecimal(8, new BigDecimal(String.valueOf(prevFireTime)));
        ps.setString(9, state);
        if (trigger instanceof SimpleTrigger && ((SimpleTrigger)trigger).hasAdditionalProperties() == false ) {
            ps.setString(10, TTYPE_SIMPLE);
        } else if (trigger instanceof CronTrigger && ((CronTrigger)trigger).hasAdditionalProperties() == false ) {
            ps.setString(10, TTYPE_CRON);
        } else {
            ps.setString(10, TTYPE_BLOB);
        }
        ps.setBigDecimal(11, new BigDecimal(String.valueOf(trigger
                .getStartTime().getTime())));
        long endTime = 0;
        if (trigger.getEndTime() != null) {
            endTime = trigger.getEndTime().getTime();
        }
        ps.setBigDecimal(12, new BigDecimal(String.valueOf(endTime)));
        ps.setString(13, trigger.getCalendarName());
        ps.setInt(14, trigger.getMisfireInstruction());
        ps.setBinaryStream(15, bais, len);
        ps.setInt(16, trigger.getPriority());
        
        insertResult = ps.executeUpdate();
    } finally {
        closeStatement(ps);
    }

    if (insertResult > 0) {
        String[] trigListeners = trigger.getTriggerListenerNames();
        for (int i = 0; trigListeners != null && i < trigListeners.length; i++) {
            insertTriggerListener(conn, trigger, trigListeners[i]);
        }
    }

    return insertResult;
}
 
Example 5
Source File: PointbaseDelegate.java    From AsuraFramework with Apache License 2.0 4 votes vote down vote up
public int updateTrigger(Connection conn, Trigger trigger, String state,
        JobDetail jobDetail) throws SQLException, IOException {

    ByteArrayOutputStream baos = serializeJobData(trigger.getJobDataMap());
    int len = baos.toByteArray().length;
    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
            
    PreparedStatement ps = null;

    int insertResult = 0;


    try {
        ps = conn.prepareStatement(rtp(UPDATE_TRIGGER));
            
        ps.setString(1, trigger.getJobName());
        ps.setString(2, trigger.getJobGroup());
        setBoolean(ps, 3, trigger.isVolatile());
        ps.setString(4, trigger.getDescription());
        long nextFireTime = -1;
        if (trigger.getNextFireTime() != null) {
            nextFireTime = trigger.getNextFireTime().getTime();
        }
        ps.setBigDecimal(5, new BigDecimal(String.valueOf(nextFireTime)));
        long prevFireTime = -1;
        if (trigger.getPreviousFireTime() != null) {
            prevFireTime = trigger.getPreviousFireTime().getTime();
        }
        ps.setBigDecimal(6, new BigDecimal(String.valueOf(prevFireTime)));
        ps.setString(7, state);
        if (trigger instanceof SimpleTrigger && ((SimpleTrigger)trigger).hasAdditionalProperties() == false ) {
            //                updateSimpleTrigger(conn, (SimpleTrigger)trigger);
            ps.setString(8, TTYPE_SIMPLE);
        } else if (trigger instanceof CronTrigger && ((CronTrigger)trigger).hasAdditionalProperties() == false ) {
            //                updateCronTrigger(conn, (CronTrigger)trigger);
            ps.setString(8, TTYPE_CRON);
        } else {
            //                updateBlobTrigger(conn, trigger);
            ps.setString(8, TTYPE_BLOB);
        }
        ps.setBigDecimal(9, new BigDecimal(String.valueOf(trigger
                .getStartTime().getTime())));
        long endTime = 0;
        if (trigger.getEndTime() != null) {
            endTime = trigger.getEndTime().getTime();
        }
        ps.setBigDecimal(10, new BigDecimal(String.valueOf(endTime)));
        ps.setString(11, trigger.getCalendarName());
        ps.setInt(12, trigger.getMisfireInstruction());
        
        ps.setInt(13, trigger.getPriority());
        ps.setBinaryStream(14, bais, len);
        ps.setString(15, trigger.getName());
        ps.setString(16, trigger.getGroup());

        insertResult = ps.executeUpdate();
    } finally {
        closeStatement(ps);
    }

    if (insertResult > 0) {
        deleteTriggerListeners(conn, trigger.getName(), trigger.getGroup());

        String[] trigListeners = trigger.getTriggerListenerNames();
        for (int i = 0; trigListeners != null && i < trigListeners.length; i++) {
            insertTriggerListener(conn, trigger, trigListeners[i]);
        }
    }

    return insertResult;
}
 
Example 6
Source File: StdJDBCDelegate.java    From AsuraFramework with Apache License 2.0 4 votes vote down vote up
/**
 * <p>
 * Insert the base trigger data.
 * </p>
 * 
 * @param conn
 *          the DB Connection
 * @param trigger
 *          the trigger to insert
 * @param state
 *          the state that the trigger should be stored in
 * @return the number of rows inserted
 */
public int insertTrigger(Connection conn, Trigger trigger, String state,
        JobDetail jobDetail) throws SQLException, IOException {

    ByteArrayOutputStream baos = null;
    if(trigger.getJobDataMap().size() > 0) {
        baos = serializeJobData(trigger.getJobDataMap());
    }
    
    PreparedStatement ps = null;

    int insertResult = 0;

    try {
        ps = conn.prepareStatement(rtp(INSERT_TRIGGER));
        ps.setString(1, trigger.getName());
        ps.setString(2, trigger.getGroup());
        ps.setString(3, trigger.getJobName());
        ps.setString(4, trigger.getJobGroup());
        setBoolean(ps, 5, trigger.isVolatile());
        ps.setString(6, trigger.getDescription());
        if(trigger.getNextFireTime() != null)
         ps.setBigDecimal(7, new BigDecimal(String.valueOf(trigger
                 .getNextFireTime().getTime())));
        else
        	ps.setBigDecimal(7, null);
        long prevFireTime = -1;
        if (trigger.getPreviousFireTime() != null) {
            prevFireTime = trigger.getPreviousFireTime().getTime();
        }
        ps.setBigDecimal(8, new BigDecimal(String.valueOf(prevFireTime)));
        ps.setString(9, state);
        if (trigger instanceof SimpleTrigger && ((SimpleTrigger)trigger).hasAdditionalProperties() == false ) {
            ps.setString(10, TTYPE_SIMPLE);
        } else if (trigger instanceof CronTrigger && ((CronTrigger)trigger).hasAdditionalProperties() == false ) {
            ps.setString(10, TTYPE_CRON);
        } else {
            ps.setString(10, TTYPE_BLOB);
        }
        ps.setBigDecimal(11, new BigDecimal(String.valueOf(trigger
                .getStartTime().getTime())));
        long endTime = 0;
        if (trigger.getEndTime() != null) {
            endTime = trigger.getEndTime().getTime();
        }
        ps.setBigDecimal(12, new BigDecimal(String.valueOf(endTime)));
        ps.setString(13, trigger.getCalendarName());
        ps.setInt(14, trigger.getMisfireInstruction());
        setBytes(ps, 15, baos);
        ps.setInt(16, trigger.getPriority());
        
        insertResult = ps.executeUpdate();
    } finally {
        closeStatement(ps);
    }

    if (insertResult > 0) {
        String[] trigListeners = trigger.getTriggerListenerNames();
        for (int i = 0; trigListeners != null && i < trigListeners.length; i++) {
            insertTriggerListener(conn, trigger, trigListeners[i]);
        }
    }

    return insertResult;
}
 
Example 7
Source File: StdJDBCDelegate.java    From AsuraFramework with Apache License 2.0 4 votes vote down vote up
/**
 * <p>
 * Update the base trigger data.
 * </p>
 * 
 * @param conn
 *          the DB Connection
 * @param trigger
 *          the trigger to insert
 * @param state
 *          the state that the trigger should be stored in
 * @return the number of rows updated
 */
public int updateTrigger(Connection conn, Trigger trigger, String state,
        JobDetail jobDetail) throws SQLException, IOException {

    // save some clock cycles by unnecessarily writing job data blob ...
    boolean updateJobData = trigger.getJobDataMap().isDirty();
    ByteArrayOutputStream baos = null;
    if(updateJobData && trigger.getJobDataMap().size() > 0) {
        baos = serializeJobData(trigger.getJobDataMap());
    }
            
    PreparedStatement ps = null;

    int insertResult = 0;


    try {
        if(updateJobData) {
            ps = conn.prepareStatement(rtp(UPDATE_TRIGGER));
        } else {
            ps = conn.prepareStatement(rtp(UPDATE_TRIGGER_SKIP_DATA));
        }
            
        ps.setString(1, trigger.getJobName());
        ps.setString(2, trigger.getJobGroup());
        setBoolean(ps, 3, trigger.isVolatile());
        ps.setString(4, trigger.getDescription());
        long nextFireTime = -1;
        if (trigger.getNextFireTime() != null) {
            nextFireTime = trigger.getNextFireTime().getTime();
        }
        ps.setBigDecimal(5, new BigDecimal(String.valueOf(nextFireTime)));
        long prevFireTime = -1;
        if (trigger.getPreviousFireTime() != null) {
            prevFireTime = trigger.getPreviousFireTime().getTime();
        }
        ps.setBigDecimal(6, new BigDecimal(String.valueOf(prevFireTime)));
        ps.setString(7, state);
        if (trigger instanceof SimpleTrigger && ((SimpleTrigger)trigger).hasAdditionalProperties() == false ) {
            //                updateSimpleTrigger(conn, (SimpleTrigger)trigger);
            ps.setString(8, TTYPE_SIMPLE);
        } else if (trigger instanceof CronTrigger && ((CronTrigger)trigger).hasAdditionalProperties() == false ) {
            //                updateCronTrigger(conn, (CronTrigger)trigger);
            ps.setString(8, TTYPE_CRON);
        } else {
            //                updateBlobTrigger(conn, trigger);
            ps.setString(8, TTYPE_BLOB);
        }
        ps.setBigDecimal(9, new BigDecimal(String.valueOf(trigger
                .getStartTime().getTime())));
        long endTime = 0;
        if (trigger.getEndTime() != null) {
            endTime = trigger.getEndTime().getTime();
        }
        ps.setBigDecimal(10, new BigDecimal(String.valueOf(endTime)));
        ps.setString(11, trigger.getCalendarName());
        ps.setInt(12, trigger.getMisfireInstruction());
        ps.setInt(13, trigger.getPriority());

        if(updateJobData) {
            setBytes(ps, 14, baos);
            ps.setString(15, trigger.getName());
            ps.setString(16, trigger.getGroup());
        } else {
            ps.setString(14, trigger.getName());
            ps.setString(15, trigger.getGroup());
        }

        insertResult = ps.executeUpdate();
    } finally {
        closeStatement(ps);
    }

    if (insertResult > 0) {
        deleteTriggerListeners(conn, trigger.getName(), trigger.getGroup());

        String[] trigListeners = trigger.getTriggerListenerNames();
        for (int i = 0; trigListeners != null && i < trigListeners.length; i++) {
            insertTriggerListener(conn, trigger, trigListeners[i]);
        }
    }

    return insertResult;
}
 
Example 8
Source File: NavigableEventLogListener.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
private void info (EVENTTYPE eventType, Trigger trig, JobExecutionContext context, JobExecutionException exception, CompletedExecutionInstruction instructionCode) {
    JobDetail
        detail = (context != null)?context.getJobDetail():null;
    final JobDataMap
        dataMap = (context != null)?context.getMergedJobDataMap():null;
    final String
        jobName = (detail != null)?detail.getKey().getName():null,
        jobDesc = (detail != null)?detail.getDescription():null;
    final Class
        jobClass = (detail != null)?detail.getJobClass():null;
    final Trigger
        trigger = (trig != null)?trig:((context != null)?context.getTrigger():null);
    final String
        trigName = (trigger != null)?trigger.getKey().getName():null,
        trigDesc = (trigger != null)?trigger.getDescription():null;
    final Date
        trigStart = (trigger != null)?trigger.getStartTime():null,
        trigEnd = (trigger != null)?trigger.getEndTime():null;

    StringBuilder
        sb = new StringBuilder();

    switch (eventType)
    {
        case JOB_EXECUTING:
        {
            sb.append("Job Executing: [");
            sb.append("name: ").append(jobName).append(", description: ").append((jobDesc != null)?jobDesc:"")
                    .append(", class: ").append(jobClass.getName());
            sb.append("]");
            break;
        }
        case JOB_VETOED:
        {
            sb.append("Job Vetoed: [");
            sb.append("name: ").append(jobName).append(", description: ").append((jobDesc != null)?jobDesc:"")
                    .append(", class: ").append(jobClass.getName());
            break;
        }
        case JOB_EXECUTED:
        {
            sb.append("Job Executed: [");
            sb.append("name: ").append(jobName).append(", description: ").append((jobDesc != null)?jobDesc:"")
              .append(", class: ").append(jobClass.getName());

            if (exception != null)
            {
                sb.append (", exception: ").append(exception.getMessage());
                if (exception.getCause() != null)
                {
                  sb.append(", exception cause: ").append(exception.getCause().getClass().getName());
                }
            }
            sb.append("]");

            break;
        }
        case TRIGGER_FIRED:
        {
            sb.append("Trigger Fired: [");
            sb.append("trigger: ").append(trigName).append(", trigger description: ").append((trigDesc != null)?trigDesc:"")
              .append(", start: ").append((trigStart != null)?trigStart.toString():null)
              .append(", end: ").append((trigEnd != null)?trigEnd.toString():null);
            sb.append(", job: ").append(jobName).append(", job description: ").append((jobDesc != null)?jobDesc:"")
                    .append(", class: ").append(jobClass.getName());
            sb.append("]");
            break;
        }
        case TRIGGER_MISFIRED:
        {
            sb.append("Trigger Misfired: [");
            sb.append("trigger: ").append(trigName).append(", trigger description: ").append((trigDesc != null)?trigDesc:"")
              .append(", start: ").append((trigStart!=null)?trigStart.toString():null)
              .append(", end: ").append((trigEnd!=null)?trigEnd.toString():null);
            sb.append("]");
            break;
        }
        case TRIGGER_COMPLETED:
        {
            sb.append("Trigger Completed: [");
            sb.append("trigger: ").append(trigName).append(", trigger description: ").append((trigDesc != null)?trigDesc:"")
              .append(", start: ").append((trigStart!=null)?trigStart.toString():null)
              .append(", end: ").append((trigEnd!=null)?trigEnd.toString():null);
            sb.append(", job: ").append(jobName).append(", job description: ").append((jobDesc != null)?jobDesc:"")
              .append(", class: ").append(jobClass.getName())
              .append(", execution result: ").append(instructionCode);
            sb.append("]");
            break;
        }
    }
    if (log.isDebugEnabled())
    {
    	log.debug(sb.toString());
    }
}
 
Example 9
Source File: NavigableEventLogListener.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
private void info (EVENTTYPE eventType, Trigger trig, JobExecutionContext context, JobExecutionException exception, CompletedExecutionInstruction instructionCode) {
    JobDetail
        detail = (context != null)?context.getJobDetail():null;
    final JobDataMap
        dataMap = (context != null)?context.getMergedJobDataMap():null;
    final String
        jobName = (detail != null)?detail.getKey().getName():null,
        jobDesc = (detail != null)?detail.getDescription():null;
    final Class
        jobClass = (detail != null)?detail.getJobClass():null;
    final Trigger
        trigger = (trig != null)?trig:((context != null)?context.getTrigger():null);
    final String
        trigName = (trigger != null)?trigger.getKey().getName():null,
        trigDesc = (trigger != null)?trigger.getDescription():null;
    final Date
        trigStart = (trigger != null)?trigger.getStartTime():null,
        trigEnd = (trigger != null)?trigger.getEndTime():null;

    StringBuilder
        sb = new StringBuilder();

    switch (eventType)
    {
        case JOB_EXECUTING:
        {
            sb.append("Job Executing: [");
            sb.append("name: ").append(jobName).append(", description: ").append((jobDesc != null)?jobDesc:"")
                    .append(", class: ").append(jobClass.getName());
            sb.append("]");
            break;
        }
        case JOB_VETOED:
        {
            sb.append("Job Vetoed: [");
            sb.append("name: ").append(jobName).append(", description: ").append((jobDesc != null)?jobDesc:"")
                    .append(", class: ").append(jobClass.getName());
            break;
        }
        case JOB_EXECUTED:
        {
            sb.append("Job Executed: [");
            sb.append("name: ").append(jobName).append(", description: ").append((jobDesc != null)?jobDesc:"")
              .append(", class: ").append(jobClass.getName());

            if (exception != null)
            {
                sb.append (", exception: ").append(exception.getMessage());
                if (exception.getCause() != null)
                {
                  sb.append(", exception cause: ").append(exception.getCause().getClass().getName());
                }
            }
            sb.append("]");

            break;
        }
        case TRIGGER_FIRED:
        {
            sb.append("Trigger Fired: [");
            sb.append("trigger: ").append(trigName).append(", trigger description: ").append((trigDesc != null)?trigDesc:"")
              .append(", start: ").append((trigStart != null)?trigStart.toString():null)
              .append(", end: ").append((trigEnd != null)?trigEnd.toString():null);
            sb.append(", job: ").append(jobName).append(", job description: ").append((jobDesc != null)?jobDesc:"")
                    .append(", class: ").append(jobClass.getName());
            sb.append("]");
            break;
        }
        case TRIGGER_MISFIRED:
        {
            sb.append("Trigger Misfired: [");
            sb.append("trigger: ").append(trigName).append(", trigger description: ").append((trigDesc != null)?trigDesc:"")
              .append(", start: ").append((trigStart!=null)?trigStart.toString():null)
              .append(", end: ").append((trigEnd!=null)?trigEnd.toString():null);
            sb.append("]");
            break;
        }
        case TRIGGER_COMPLETED:
        {
            sb.append("Trigger Completed: [");
            sb.append("trigger: ").append(trigName).append(", trigger description: ").append((trigDesc != null)?trigDesc:"")
              .append(", start: ").append((trigStart!=null)?trigStart.toString():null)
              .append(", end: ").append((trigEnd!=null)?trigEnd.toString():null);
            sb.append(", job: ").append(jobName).append(", job description: ").append((jobDesc != null)?jobDesc:"")
              .append(", class: ").append(jobClass.getName())
              .append(", execution result: ").append(instructionCode);
            sb.append("]");
            break;
        }
    }
    if (log.isDebugEnabled())
    {
    	log.debug(sb.toString());
    }
}