org.springframework.cloud.task.repository.dao.JdbcTaskExecutionDao Java Examples

The following examples show how to use org.springframework.cloud.task.repository.dao.JdbcTaskExecutionDao. 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: TaskExecutionDaoFactoryBeanTests.java    From spring-cloud-task with Apache License 2.0 6 votes vote down vote up
@Test
public void testDefaultDataSourceConfiguration() throws Exception {
	this.context = new AnnotationConfigApplicationContext(
			DefaultDataSourceConfiguration.class);

	DataSource dataSource = this.context.getBean(DataSource.class);

	TaskExecutionDaoFactoryBean factoryBean = new TaskExecutionDaoFactoryBean(
			dataSource);
	TaskExecutionDao taskExecutionDao = factoryBean.getObject();

	assertThat(taskExecutionDao instanceof JdbcTaskExecutionDao).isTrue();

	TaskExecutionDao taskExecutionDao2 = factoryBean.getObject();

	assertThat(taskExecutionDao == taskExecutionDao2).isTrue();
}
 
Example #2
Source File: TestDBUtils.java    From spring-cloud-task with Apache License 2.0 6 votes vote down vote up
/**
 * Create a pagingQueryProvider specific database type with a query containing a where
 * clause.
 * @param databaseProductName of the database.
 * @param whereClause to be applied to the query.
 * @return a PagingQueryProvider that will return the requested information.
 * @throws Exception exception thrown if error occurs creating
 * {@link PagingQueryProvider}.
 */
public static PagingQueryProvider getPagingQueryProvider(String databaseProductName,
		String whereClause) throws Exception {
	DataSource dataSource = getMockDataSource(databaseProductName);
	Map<String, Order> orderMap = new TreeMap<>();
	orderMap.put("START_TIME", Order.DESCENDING);
	orderMap.put("TASK_EXECUTION_ID", Order.DESCENDING);
	SqlPagingQueryProviderFactoryBean factoryBean = new SqlPagingQueryProviderFactoryBean();
	factoryBean.setSelectClause(JdbcTaskExecutionDao.SELECT_CLAUSE);
	factoryBean.setFromClause(JdbcTaskExecutionDao.FROM_CLAUSE);
	if (whereClause != null) {
		factoryBean.setWhereClause(whereClause);
	}
	factoryBean.setSortKeys(orderMap);
	factoryBean.setDataSource(dataSource);
	PagingQueryProvider pagingQueryProvider = null;
	try {
		pagingQueryProvider = factoryBean.getObject();
		pagingQueryProvider.init(dataSource);
	}
	catch (Exception e) {
		throw new IllegalStateException(e);
	}
	return pagingQueryProvider;
}
 
Example #3
Source File: TaskExecutionDaoFactoryBean.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
private void buildTaskExecutionDao(DataSource dataSource) {
	DataFieldMaxValueIncrementerFactory incrementerFactory = new DefaultDataFieldMaxValueIncrementerFactory(
			dataSource);
	this.dao = new JdbcTaskExecutionDao(dataSource, this.tablePrefix);
	String databaseType;
	try {
		databaseType = DatabaseType.fromMetaData(dataSource).name();
	}
	catch (MetaDataAccessException e) {
		throw new IllegalStateException(e);
	}
	((JdbcTaskExecutionDao) this.dao).setTaskIncrementer(incrementerFactory
			.getIncrementer(databaseType, this.tablePrefix + "SEQ"));
}
 
Example #4
Source File: SqlPagingQueryProviderFactoryBeanTests.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws Exception {
	this.factoryBean = new SqlPagingQueryProviderFactoryBean();
	this.factoryBean.setDataSource(TestDBUtils.getMockDataSource("MySQL"));
	this.factoryBean.setDatabaseType("Oracle");
	this.factoryBean.setSelectClause(JdbcTaskExecutionDao.SELECT_CLAUSE);
	this.factoryBean.setFromClause(JdbcTaskExecutionDao.FROM_CLAUSE);
	Map<String, Order> orderMap = new TreeMap<>();
	orderMap.put("START_TIME", Order.DESCENDING);
	orderMap.put("TASK_EXECUTION_ID", Order.DESCENDING);
	this.factoryBean.setSortKeys(orderMap);

}
 
Example #5
Source File: TaskLauncherTaskletTests.java    From composed-task-runner with Apache License 2.0 4 votes vote down vote up
@Bean
TaskExecutionDao taskExecutionDao(DataSource dataSource) {
	return new JdbcTaskExecutionDao(dataSource);
}
 
Example #6
Source File: TaskLauncherTaskletTests.java    From spring-cloud-dataflow with Apache License 2.0 4 votes vote down vote up
@Bean
TaskExecutionDao taskExecutionDao(DataSource dataSource) {
	return new JdbcTaskExecutionDao(dataSource);
}