Java Code Examples for org.quartz.JobDetail#getGroup()

The following examples show how to use org.quartz.JobDetail#getGroup() . 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: QuarzSchedulerDAOImpl.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void insertJob(Job spagobiJob) {

	logger.debug("IN");

	try {
		Assert.assertNotNull(spagobiJob, "Input parameter [spagobiJob] cannot be null");
		JobDetail quartzJob = QuartzNativeObjectsConverter.convertJobToNativeObject(spagobiJob);
		if (quartzJob.getDescription() == null)
			quartzJob.setDescription("");
		String jobGroupName = quartzJob.getGroup() != null ? quartzJob.getGroup() : Scheduler.DEFAULT_GROUP;
		quartzJob.setGroup(jobGroupName);
		adjustTenant(quartzJob);
		scheduler.addJob(quartzJob, true);
	} catch (Throwable t) {
		throw new SpagoBIDAOException("An unexpected error occured while inserting job [" + spagobiJob + "]", t);
	} finally {
		logger.debug("OUT");
	}
}
 
Example 2
Source File: QuarzSchedulerDAOImpl.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public Tenant findTenant(JobDetail jobDetail) {
	logger.debug("IN");
	try {
		Assert.assertNotNull(jobDetail, "Input parameter [jobDetail] cannot be null");
		String groupName = jobDetail.getGroup();
		int index = groupName.indexOf(GROUP_NAME_SEPARATOR);
		if (index < 0) {
			SpagoBIRuntimeException e = new SpagoBIRuntimeException("Cannot find tenant name from string [" + groupName + "]");
			e.addHint("Job group name should start with [<tenant name>" + GROUP_NAME_SEPARATOR + "]. Check job definition.");
			throw e;
		}
		String tenant = groupName.substring(0, index);
		LogMF.debug(logger, "Tenant : [{0}]", tenant);
		return new Tenant(tenant);
	} catch (Throwable t) {
		throw new SpagoBIDAOException("An unexpected error occured while finding tenant for job [" + jobDetail + "]", t);
	} finally {
		logger.debug("OUT");
	}

}
 
Example 3
Source File: SchedulerServiceSupplier.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Builds the job list xml string.
 * 
 * @param toReturn the to return
 * 
 * @return the string
 * 
 * @throws SourceBeanException the source bean exception
 */
public  String buildJobListXmlString(List toReturn) throws SourceBeanException {
	StringBuffer buffer = new StringBuffer("<ROWS>");
	Iterator it = toReturn.iterator();
	while (it.hasNext()) {
		JobDetail job = (JobDetail) it.next();
		String jobName = job.getName();
		String jobGroupName = job.getGroup();
		String jobDescription = job.getDescription();
		String jobClassName = job.getJobClass().getName();
		String jobDurability = job.isDurable() ? "true" : "false";
		String jobRequestRecovery = job.requestsRecovery() ? "true" : "false";
		String jobVolatility = job.isVolatile() ? "true" : "false";
		buffer.append("<ROW ");
		buffer.append(" jobName=\"" + (jobName != null ? jobName : "") + "\"");
		buffer.append(" jobGroupName=\"" + (jobGroupName != null ? jobGroupName : "") + "\"");
		buffer.append(" jobDescription=\"" + (jobDescription != null ? jobDescription : "") + "\"");
		buffer.append(" jobClass=\"" + (jobClassName != null ? jobClassName : "") + "\"");
		buffer.append(" jobDurability=\"" + jobDurability + "\"");
		buffer.append(" jobRequestRecovery=\"" + jobRequestRecovery + "\"");
		buffer.append(" jobVolatility=\"" + jobVolatility + "\"");
		buffer.append(" />");
	}
	buffer.append("</ROWS>");
	return buffer.toString();
}
 
Example 4
Source File: JobDetailSupport.java    From AsuraFramework with Apache License 2.0 6 votes vote down vote up
/**
 * @param jobDetail
 * @return CompositeData
 */
public static CompositeData toCompositeData(JobDetail jobDetail) {
	try {
		return new CompositeDataSupport(COMPOSITE_TYPE, ITEM_NAMES,
				new Object[] {
						jobDetail.getName(),
						jobDetail.getGroup(),
						jobDetail.getDescription(),
						jobDetail.getJobClass().getName(),
						JobDataMapSupport.toTabularData(jobDetail
								.getJobDataMap()), jobDetail.isVolatile(),
						jobDetail.isDurable(),
						jobDetail.requestsRecovery(), });
	} catch (OpenDataException e) {
		throw new RuntimeException(e);
	}
}
 
Example 5
Source File: QuarzSchedulerDAOImpl.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
private void adjustTenant(JobDetail quartzJob) {
	String jobGroupName = quartzJob.getGroup();
	LogMF.debug(logger, "before: jobGroupName = [{0}]", jobGroupName);
	jobGroupName = this.applyTenant(jobGroupName);
	LogMF.debug(logger, "after: jobGroupName = [{0}]", jobGroupName);
	quartzJob.setGroup(jobGroupName);
}
 
Example 6
Source File: SchedulerServiceSupplier.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Serialize job detail.
 * 
 * @param job the job
 * 
 * @return the string
 * 
 * @throws SourceBeanException the source bean exception
 */
public  String serializeJobDetail(JobDetail job) throws SourceBeanException {
	StringBuffer buffer = new StringBuffer("<JOB_DETAIL ");
	String jobName = job.getName();
	String jobGroupName = job.getGroup();
	String jobDescription = job.getDescription();
	String jobClassName = job.getJobClass().getName();
	String jobDurability = job.isDurable() ? "true" : "false";
	String jobRequestRecovery = job.requestsRecovery() ? "true" : "false";
	String jobVolatility = job.isVolatile() ? "true" : "false";
	JobDataMap jobDataMap = job.getJobDataMap();
	buffer.append(" jobName=\"" + (jobName != null ? jobName : "") + "\"");
	buffer.append(" jobGroupName=\"" + (jobGroupName != null ? jobGroupName : "") + "\"");
	buffer.append(" jobDescription=\"" + (jobDescription != null ? jobDescription : "") + "\"");
	buffer.append(" jobClass=\"" + (jobClassName != null ? jobClassName : "") + "\"");
	buffer.append(" jobDurability=\"" + jobDurability + "\"");
	buffer.append(" jobRequestRecovery=\"" + jobRequestRecovery + "\"");
	buffer.append(" jobVolatility=\"" + jobVolatility + "\"");
	buffer.append(" >");
	buffer.append("<JOB_PARAMETERS>");
	if (jobDataMap != null && !jobDataMap.isEmpty()) {
		String[] keys = jobDataMap.getKeys();
		if (keys != null && keys.length > 0) {
			for (int i = 0; i < keys.length; i++) {
				buffer.append("<JOB_PARAMETER ");
				String key = keys[i];
				String value = jobDataMap.getString(key);
				if (value == null) {
					SpagoBITracer.warning("SCHEDULER", this.getClass().getName(), "loadJobDetailIntoResponse", 
					"Job parameter '" + key + "' has no String value!!");	
				}
				buffer.append(" name=\"" + key + "\"");
				buffer.append(" value=\"" + value + "\"");
				buffer.append(" />");
			}
		}
	}
	buffer.append("</JOB_PARAMETERS>");
	buffer.append("</JOB_DETAIL>");
	return buffer.toString();
}
 
Example 7
Source File: RAMJobStore.java    From AsuraFramework with Apache License 2.0 4 votes vote down vote up
static String getJobNameKey(JobDetail jobDetail) {
    return jobDetail.getGroup() + "_$x$x$_" + jobDetail.getName();
}
 
Example 8
Source File: QuartzAdapter.java    From javamelody with Apache License 2.0 4 votes vote down vote up
String getJobGroup(JobDetail jobDetail) {
	return jobDetail.getGroup();
}