Java Code Examples for org.springframework.jdbc.core.JdbcOperations

The following are top voted examples for showing how to use org.springframework.jdbc.core.JdbcOperations. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: spring-data-jdbc   File: JdbcRepositoryFactory.java   Source Code and License 6 votes vote down vote up
@Override
protected Object getTargetRepository(RepositoryInformation metadata) {
    entityClass = metadata.getDomainType();
    @SuppressWarnings("rawtypes")
    ReflectionJdbcRepository repository = getTargetRepositoryViaReflection(metadata, entityClass);
    repository.setDataSource(datasource);
    repository.afterPropertiesSet();
    this.repository = repository;

    generator = SqlGeneratorFactory.getInstance().getGenerator(datasource);
    template = new NamedParameterJdbcTemplate((JdbcOperations) extractRepositoryField(repository, FIELD_JDBC_OPS));
    rowMapper = extractRepositoryField(repository, FIELD_ROWMAPPER);
    tableDescription = extractRepositoryField(repository, FIELD_TABLE_DESCRIPTION);

    return repository;
}
 
Example 2
Project: db-queue   File: QueueRunnerFactoryTest.java   Source Code and License 6 votes vote down vote up
@Test
public void should_return_external_executor_runner() throws Exception {
    QueueConsumer queueConsumer = mock(QueueConsumer.class);
    QueueSettings settings = QueueSettings.builder().withBetweenTaskTimeout(Duration.ZERO).withNoTaskTimeout(Duration.ZERO)
            .withProcessingMode(ProcessingMode.USE_EXTERNAL_EXECUTOR).build();
    QueueLocation location = QueueLocation.builder().withTableName("testTable")
            .withQueueId(new QueueId("testQueue")).build();
    when(queueConsumer.getQueueConfig()).thenReturn(new QueueConfig(location, settings));

    QueueRunner queueRunner = QueueRunner.Factory.createQueueRunner(queueConsumer,
            new QueueDao(new QueueShardId("s1"), mock(JdbcOperations.class), mock(TransactionOperations.class)),
            mock(TaskLifecycleListener.class),
            mock(Executor.class));

    assertThat(queueRunner, CoreMatchers.instanceOf(QueueRunnerInExternalExecutor.class));

}
 
Example 3
Project: db-queue   File: QueueRunnerFactoryTest.java   Source Code and License 6 votes vote down vote up
@Test
public void should_return_separate_transactions_runner() throws Exception {
    QueueConsumer queueConsumer = mock(QueueConsumer.class);
    QueueSettings settings = QueueSettings.builder().withBetweenTaskTimeout(Duration.ZERO).withNoTaskTimeout(Duration.ZERO)
            .withProcessingMode(ProcessingMode.SEPARATE_TRANSACTIONS).build();
    QueueLocation location = QueueLocation.builder().withTableName("testTable")
            .withQueueId(new QueueId("testQueue")).build();
    when(queueConsumer.getQueueConfig()).thenReturn(new QueueConfig(location, settings));

    QueueRunner queueRunner = QueueRunner.Factory.createQueueRunner(queueConsumer,
            new QueueDao(new QueueShardId("s1"), mock(JdbcOperations.class), mock(TransactionOperations.class)),
            mock(TaskLifecycleListener.class),
            null);

    assertThat(queueRunner, CoreMatchers.instanceOf(QueueRunnerInSeparateTransactions.class));
}
 
Example 4
Project: db-queue   File: QueueRunnerFactoryTest.java   Source Code and License 6 votes vote down vote up
@Test
public void should_return_wrap_in_transaction_runner() throws Exception {
    QueueConsumer queueConsumer = mock(QueueConsumer.class);
    QueueSettings settings = QueueSettings.builder().withBetweenTaskTimeout(Duration.ZERO).withNoTaskTimeout(Duration.ZERO)
            .withProcessingMode(ProcessingMode.WRAP_IN_TRANSACTION).build();
    QueueLocation location = QueueLocation.builder().withTableName("testTable")
            .withQueueId(new QueueId("testQueue")).build();
    when(queueConsumer.getQueueConfig()).thenReturn(new QueueConfig(location, settings));

    QueueRunner queueRunner = QueueRunner.Factory.createQueueRunner(queueConsumer,
            new QueueDao(new QueueShardId("s1"), mock(JdbcOperations.class), mock(TransactionOperations.class)),
            mock(TaskLifecycleListener.class),
            null);

    assertThat(queueRunner, CoreMatchers.instanceOf(QueueRunnerInTransaction.class));
}
 
Example 5
Project: lams   File: NamedParameterBatchUpdateUtils.java   Source Code and License 6 votes vote down vote up
public static int[] executeBatchUpdateWithNamedParameters(final ParsedSql parsedSql,
		final SqlParameterSource[] batchArgs, JdbcOperations jdbcOperations) {
	if (batchArgs.length <= 0) {
		return new int[] {0};
	}
	String sqlToUse = NamedParameterUtils.substituteNamedParameters(parsedSql, batchArgs[0]);
	return jdbcOperations.batchUpdate(
			sqlToUse,
			new BatchPreparedStatementSetter() {

				@Override
				public void setValues(PreparedStatement ps, int i) throws SQLException {
					Object[] values = NamedParameterUtils.buildValueArray(parsedSql, batchArgs[i], null);
					int[] columnTypes = NamedParameterUtils.buildSqlTypeArray(parsedSql, batchArgs[i]);
					setStatementParameters(values, ps, columnTypes);
				}

				@Override
				public int getBatchSize() {
					return batchArgs.length;
				}
			});
}
 
Example 6
Project: neo-java   File: BlockDbH2Impl.java   Source Code and License 6 votes vote down vote up
/**
 * return a map of the objects, divided into their transactions indexes.
 *
 * @param jdbcOperations
 *            the jdbc operations to use.
 * @param sqlKey
 *            the sql key to use.
 * @param sqlArgsBaList
 *            the byte arrays to use for SQL arguments.
 * @param mapToObject
 *            the mapToObject to use.
 * @param <T>
 *            the object type to use.
 * @return a map of the objects, divided into their transactions indexes.
 */
private <T> Map<Integer, List<T>> getMapList(final JdbcOperations jdbcOperations, final String sqlKey,
		final AbstractMapToObject<T> mapToObject, final byte[]... sqlArgsBaList) {
	final String sql = getSql(sqlKey);

	final List<Map<String, Object>> mapList = jdbcOperations.queryForList(sql, (Object[]) sqlArgsBaList);

	final Map<Integer, List<T>> tMapList = new TreeMap<>();
	for (final Map<String, Object> map : mapList) {
		final byte[] transactionIndexBa = (byte[]) map.get(TRANSACTION_INDEX);
		final T t = mapToObject.toObject(map);
		final int transactionIndex = getTransactionIndex(transactionIndexBa);
		if (!tMapList.containsKey(transactionIndex)) {
			tMapList.put(transactionIndex, new ArrayList<>());
		}
		tMapList.get(transactionIndex).add(t);
	}

	return tMapList;
}
 
Example 7
Project: neo-java   File: BlockDbH2Impl.java   Source Code and License 6 votes vote down vote up
/**
 * gets the inputs for each transaction in the block, and adds them to the
 * transaction.
 *
 * @param block
 *            the block to use
 * @param jdbcOperations
 *            the jdbc operations to use.
 * @param blockIndexBa
 *            the block index to use.
 */
private void getTransactionInputsWithIndex(final Block block, final JdbcOperations jdbcOperations,
		final byte[] blockIndexBa) {
	final Map<Integer, List<CoinReference>> inputsMap = getMapList(jdbcOperations,
			"getTransactionInputsWithBlockIndex", new CoinReferenceMapToObject(), blockIndexBa);
	for (final int txIx : inputsMap.keySet()) {
		final List<CoinReference> inputs = inputsMap.get(txIx);

		if (txIx >= block.getTransactionList().size()) {
			throw new RuntimeException(
					"txIx \"" + txIx + "\" exceeds txList.size \"" + block.getTransactionList().size()
							+ "\" for block index \"" + block.getIndexAsLong() + "\" hash \"" + block.hash + "\"");
		} else {
			block.getTransactionList().get(txIx).inputs.addAll(inputs);
		}
	}
}
 
Example 8
Project: Spring-Security-Third-Edition   File: DefaultCalendarService.java   Source Code and License 6 votes vote down vote up
@Autowired
public DefaultCalendarService(final EventDao eventDao,
                              final CalendarUserDao userDao,
                              final JdbcOperations jdbcOperations,
                              final PasswordEncoder passwordEncoder) {
    if (eventDao == null) {
        throw new IllegalArgumentException("eventDao cannot be null");
    }
    if (userDao == null) {
        throw new IllegalArgumentException("userDao cannot be null");
    }
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    if (passwordEncoder == null) {
        throw new IllegalArgumentException("passwordEncoder cannot be null");
    }
    this.eventDao = eventDao;
    this.userDao = userDao;
    this.jdbcOperations = jdbcOperations;
    this.passwordEncoder = passwordEncoder;
}
 
Example 9
Project: Spring-Security-Third-Edition   File: DefaultCalendarService.java   Source Code and License 6 votes vote down vote up
@Autowired
public DefaultCalendarService(final EventDao eventDao,
                              final CalendarUserDao userDao,
                              final JdbcOperations jdbcOperations,
                              final PasswordEncoder passwordEncoder) {
    if (eventDao == null) {
        throw new IllegalArgumentException("eventDao cannot be null");
    }
    if (userDao == null) {
        throw new IllegalArgumentException("userDao cannot be null");
    }
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    if (passwordEncoder == null) {
        throw new IllegalArgumentException("passwordEncoder cannot be null");
    }
    this.eventDao = eventDao;
    this.userDao = userDao;
    this.jdbcOperations = jdbcOperations;
    this.passwordEncoder = passwordEncoder;
}
 
Example 10
Project: Spring-Security-Third-Edition   File: DefaultCalendarService.java   Source Code and License 6 votes vote down vote up
@Autowired
public DefaultCalendarService(final EventDao eventDao,
                              final CalendarUserDao userDao,
                              final JdbcOperations jdbcOperations) {
    if (eventDao == null) {
        throw new IllegalArgumentException("eventDao cannot be null");
    }
    if (userDao == null) {
        throw new IllegalArgumentException("userDao cannot be null");
    }
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.eventDao = eventDao;
    this.userDao = userDao;
    this.jdbcOperations = jdbcOperations;
}
 
Example 11
Project: Spring-Security-Third-Edition   File: DefaultCalendarService.java   Source Code and License 6 votes vote down vote up
@Autowired
public DefaultCalendarService(final EventDao eventDao,
                              final CalendarUserDao userDao,
                              final JdbcOperations jdbcOperations,
                              final PasswordEncoder passwordEncoder) {
    if (eventDao == null) {
        throw new IllegalArgumentException("eventDao cannot be null");
    }
    if (userDao == null) {
        throw new IllegalArgumentException("userDao cannot be null");
    }
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    if (passwordEncoder == null) {
        throw new IllegalArgumentException("passwordEncoder cannot be null");
    }
    this.eventDao = eventDao;
    this.userDao = userDao;
    this.jdbcOperations = jdbcOperations;
    this.passwordEncoder = passwordEncoder;
}
 
Example 12
Project: Spring-Security-Third-Edition   File: DefaultCalendarService.java   Source Code and License 6 votes vote down vote up
@Autowired
public DefaultCalendarService(final EventDao eventDao,
                              final CalendarUserDao userDao,
                              final JdbcOperations jdbcOperations,
                              final PasswordEncoder passwordEncoder) {
    if (eventDao == null) {
        throw new IllegalArgumentException("eventDao cannot be null");
    }
    if (userDao == null) {
        throw new IllegalArgumentException("userDao cannot be null");
    }
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    if (passwordEncoder == null) {
        throw new IllegalArgumentException("passwordEncoder cannot be null");
    }
    this.eventDao = eventDao;
    this.userDao = userDao;
    this.jdbcOperations = jdbcOperations;
    this.passwordEncoder = passwordEncoder;
}
 
Example 13
Project: Spring-Security-Third-Edition   File: DefaultCalendarService.java   Source Code and License 6 votes vote down vote up
@Autowired
public DefaultCalendarService(final EventDao eventDao,
                              final CalendarUserDao userDao,
                              final JdbcOperations jdbcOperations,
                              final PasswordEncoder passwordEncoder) {
    if (eventDao == null) {
        throw new IllegalArgumentException("eventDao cannot be null");
    }
    if (userDao == null) {
        throw new IllegalArgumentException("userDao cannot be null");
    }
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    if (passwordEncoder == null) {
        throw new IllegalArgumentException("passwordEncoder cannot be null");
    }
    this.eventDao = eventDao;
    this.userDao = userDao;
    this.jdbcOperations = jdbcOperations;
    this.passwordEncoder = passwordEncoder;
}
 
Example 14
Project: Spring-Security-Third-Edition   File: DefaultCalendarService.java   Source Code and License 6 votes vote down vote up
@Autowired
public DefaultCalendarService(final EventDao eventDao,
                              final CalendarUserDao userDao,
                              final JdbcOperations jdbcOperations,
                              final PasswordEncoder passwordEncoder) {
    if (eventDao == null) {
        throw new IllegalArgumentException("eventDao cannot be null");
    }
    if (userDao == null) {
        throw new IllegalArgumentException("userDao cannot be null");
    }
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    if (passwordEncoder == null) {
        throw new IllegalArgumentException("passwordEncoder cannot be null");
    }
    this.eventDao = eventDao;
    this.userDao = userDao;
    this.jdbcOperations = jdbcOperations;
    this.passwordEncoder = passwordEncoder;
}
 
Example 15
Project: plugin-bt-jira   File: JiraUpdateDao.java   Source Code and License 6 votes vote down vote up
/**
 * Add the given versions to the given project
 * 
 * @param dataSource
 *            The data source of JIRA database.
 * @param jira
 *            the JIRA project identifier.
 * @param versions
 *            the version names to add
 * @return the {@link Map} where value is the created version identifier.
 */
public Map<String, Integer> addVersions(final DataSource dataSource, final int jira,
		final Collection<String> versions) {
	final Map<String, Integer> result = new HashMap<>();
	final JdbcOperations jdbcTemplate = new JdbcTemplate(dataSource);
	int nextId = prepareForNextId(dataSource, VERSION_NODE, versions.size());
	int nextSequence = getNextVersionSequence(jira, jdbcTemplate);
	for (final String version : versions) {
		jdbcTemplate.update("INSERT INTO projectversion (ID,PROJECT,vname,SEQUENCE) values(?,?,?,?)", nextId, jira,
				version, nextSequence);
		result.put(version, nextId);
		nextId++;
		nextSequence++;
	}
	return result;
}
 
Example 16
Project: plugin-bt-jira   File: JiraUpdateDao.java   Source Code and License 6 votes vote down vote up
/**
 * Return current sequence.
 */
protected int getCurrentSequence(final String sequenceName, final JdbcOperations jdbcTemplate) {
	final Long currentSequence;
	final List<Long> sequence = jdbcTemplate
			.queryForList("SELECT SEQ_ID FROM SEQUENCE_VALUE_ITEM WHERE SEQ_NAME = ?", Long.class, sequenceName);
	if (sequence.isEmpty()) {
		// New sequence, start from an arbitrary sequence to be sure JIRA
		// does not fill it
		currentSequence = 10000L;
		jdbcTemplate.update("INSERT INTO SEQUENCE_VALUE_ITEM (SEQ_NAME,SEQ_ID) values(?,?)", sequenceName,
				currentSequence);
	} else {
		currentSequence = sequence.get(0);
	}
	return currentSequence.intValue();
}
 
Example 17
Project: plugin-bt-jira   File: JiraUpdateDaoTest.java   Source Code and License 6 votes vote down vote up
@Test
public void testPrepareForNextIdConcurrent() throws Exception {
	final JiraUpdateDao dao = new JiraUpdateDao() {

		private boolean mock = true;

		@Override
		protected int getCurrentSequence(final String sequenceName, final JdbcOperations jdbcTemplate) {
			if (mock) {
				mock = false;
				return -10000;
			}
			return super.getCurrentSequence(sequenceName, jdbcTemplate);
		}

	};
	Assert.assertEquals(10100, dao.prepareForNextId(datasource, "ChangeGroup", 2000));
}
 
Example 18
Project: plugin-bt-jira   File: JiraUpdateDao.java   Source Code and License 6 votes vote down vote up
/**
 * Indicate the installation and activation of "script runner" plug-in.
 * 
 * @param dataSource
 *            The data source of JIRA database.
 * @param jira
 *            the JIRA project identifier.
 * @param issues
 *            The issues to add. The ID property of each inserted issue is
 *            also updated in these objects.
 * @param workflowStepMapping
 *            the {@link Map} linking type identifier to a {@link Map}
 *            linking status name to steps.
 */
public void addIssues(final DataSource dataSource, final int jira, final List<JiraIssueRow> issues,
		final Map<Integer, Workflow> workflowStepMapping) {
	final JdbcOperations jdbcTemplate = new JdbcTemplate(dataSource);
	int nextId = prepareForNextId(dataSource, ISSUE_NODE, issues.size());
	reserveProjectCounter(dataSource, jira, issues);
	int nextCurrentStepId = prepareForNextId(dataSource, "OSCurrentStep", issues.size());
	int nextWfEntryId = prepareForNextId(dataSource, "OSWorkflowEntry", issues.size());
	int counter = 0;
	for (final JiraIssueRow issueRow : issues) {
		issueRow.setId(nextId);
		log.info("Inserting issue {}-{}({}) {}/{}", issueRow.getPkey(), issueRow.getIssueNum(), issueRow.getId(),
				counter, issues.size());
		Workflow workflow = workflowStepMapping.get(issueRow.getType());
		if (workflow == null) {
			workflow = workflowStepMapping.get(0);
		}

		addIssue(jira, jdbcTemplate, nextId, nextCurrentStepId, nextWfEntryId, issueRow, workflow);
		nextId++;
		nextWfEntryId++;
		nextCurrentStepId++;
		counter++;
	}
}
 
Example 19
Project: plugin-bt-jira   File: JiraUpdateDao.java   Source Code and License 6 votes vote down vote up
/**
 * Add an issue, workflow entry, corresponding step of current status and link author to this issue (user activity
 * dashboard)
 */
private void addIssue(final int jira, final JdbcOperations jdbcTemplate, final int nextId, final int nextCurrentStepId, final int nextWfEntryId,
		final JiraIssueRow issueRow, final Workflow workflow) {
	final INamableBean<Integer> workflowStep = workflow.getStatusToSteps().get(issueRow.getStatusText());

	// Insert workflow activity
	jdbcTemplate.update("INSERT INTO OS_WFENTRY (ID,NAME,STATE) values(?,?,?)", nextWfEntryId, workflow.getName(), 1);
	jdbcTemplate.update("INSERT INTO OS_CURRENTSTEP (ID,ENTRY_ID,STEP_ID,ACTION_ID,START_DATE,STATUS) values(?,?,?,?,?,?)", nextCurrentStepId,
			nextWfEntryId, workflowStep.getId(), 0, issueRow.getCreated(), workflowStep.getName());

	// Insert issue
	jdbcTemplate.update(
			"INSERT INTO jiraissue"
					+ " (ID,issuenum,WATCHES,VOTES,PROJECT,REPORTER,ASSIGNEE,CREATOR,issuetype,SUMMARY,DESCRIPTION,PRIORITY,RESOLUTION,RESOLUTIONDATE,"
					+ "issuestatus,CREATED,UPDATED,WORKFLOW_ID,DUEDATE) values(?,?,1,0,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
			nextId, issueRow.getIssueNum(), jira, issueRow.getReporter(), issueRow.getAssignee(), issueRow.getAuthor(), issueRow.getType(),
			issueRow.getSummary(), issueRow.getDescription(), issueRow.getPriority(), issueRow.getResolution(), issueRow.getResolutionDate(),
			issueRow.getStatus(), issueRow.getCreated(), issueRow.getUpdated(), nextWfEntryId, issueRow.getDueDate());

	// Add user relation
	jdbcTemplate.update("INSERT INTO userassociation (SOURCE_NAME,SINK_NODE_ID,SINK_NODE_ENTITY,ASSOCIATION_TYPE,CREATED) values(?,?,?,?,?)",
			issueRow.getAuthor(), nextId, "Issue", "WatchIssue", issueRow.getUpdated());
}
 
Example 20
Project: simple-openid-provider   File: OAuth2Configuration.java   Source Code and License 5 votes vote down vote up
public OAuth2Configuration(ResourceLoader resourceLoader, OpenIdProviderProperties properties,
		ObjectProvider<JdbcOperations> jdbcOperations, ObjectProvider<AuthenticationManager> authenticationManager,
		ObjectProvider<HazelcastInstance> hazelcastInstance) {
	this.resourceLoader = resourceLoader;
	this.properties = properties;
	this.jdbcOperations = jdbcOperations.getObject();
	this.authenticationManager = authenticationManager.getObject();
	this.hazelcastInstance = hazelcastInstance.getObject();
}
 
Example 21
Project: plugin-bt-jira   File: JiraUpdateDao.java   Source Code and License 5 votes vote down vote up
/**
 * Associate an issue to a set of items;
 */
private void associatedItems(final JdbcOperations jdbcTemplate, final int issueId, final Collection<Integer> items,
		final String nodetype, final String associationType) {
	for (final Integer item : items) {
		jdbcTemplate
				.update("INSERT INTO nodeassociation (SOURCE_NODE_ID,SOURCE_NODE_ENTITY,SINK_NODE_ID,SINK_NODE_ENTITY,ASSOCIATION_TYPE)"
						+ " values(?,?,?,?,?)", issueId, ISSUE_NODE, item, nodetype, associationType);
	}
}
 
Example 22
Project: Spring-Security-Third-Edition   File: JdbcCalendarUserDao.java   Source Code and License 5 votes vote down vote up
@Autowired
public JdbcCalendarUserDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 23
Project: Spring-Security-Third-Edition   File: JdbcEventDao.java   Source Code and License 5 votes vote down vote up
@Autowired
public JdbcEventDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 24
Project: Spring-Security-Third-Edition   File: JdbcCalendarUserDao.java   Source Code and License 5 votes vote down vote up
@Autowired
public JdbcCalendarUserDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 25
Project: Spring-Security-Third-Edition   File: JdbcEventDao.java   Source Code and License 5 votes vote down vote up
@Autowired
public JdbcEventDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 26
Project: Spring-Security-Third-Edition   File: JdbcCalendarUserDao.java   Source Code and License 5 votes vote down vote up
@Autowired
public JdbcCalendarUserDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 27
Project: Spring-Security-Third-Edition   File: JdbcEventDao.java   Source Code and License 5 votes vote down vote up
@Autowired
public JdbcEventDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 28
Project: Spring-Security-Third-Edition   File: JdbcCalendarUserDao.java   Source Code and License 5 votes vote down vote up
@Autowired
public JdbcCalendarUserDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 29
Project: plugin-bt-jira   File: JiraUpdateDao.java   Source Code and License 5 votes vote down vote up
/**
 * Associate a single custom field values to a given issue.
 */
private int associateCustomFieldValue(final JdbcOperations jdbcTemplate, final int issueId, final int nextId,
		final int cfId, final String column, final Iterable<Object> values) {
	int nextIdl = nextId;
	// Persist single/multiple values
	for (final Object value : values) {
		jdbcTemplate.update("INSERT INTO customfieldvalue (ID,ISSUE,CUSTOMFIELD," + column + ") values(?,?,?,?)",
				nextIdl, issueId, cfId, value);
		nextIdl++;
	}
	return nextIdl;
}
 
Example 30
Project: plugin-bt-jira   File: JiraUpdateDao.java   Source Code and License 5 votes vote down vote up
/**
 * Associate issue to custom values. Custom component must exist.
 * 
 * @param dataSource
 *            The data source of JIRA database.
 * @param issues
 *            The issues to add.
 * @param customFields
 *            Existing custom field definitions.
 */
public void associateCustomFieldsValues(final DataSource dataSource, final List<JiraIssueRow> issues,
		final Map<String, CustomFieldEditor> customFields) {
	final JdbcOperations jdbcTemplate = new JdbcTemplate(dataSource);

	// Compute total amount of custom values to create
	int nextId = prepareForNextId(dataSource, "CustomFieldValue", countCustomFieldValues(issues));
	for (final JiraIssueRow issueRow : issues) {
		nextId = associateCutomFieldValues(customFields, jdbcTemplate, nextId, issueRow);
	}
}
 
Example 31
Project: Spring-Security-Third-Edition   File: JdbcEventDao.java   Source Code and License 5 votes vote down vote up
@Autowired
public JdbcEventDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 32
Project: Spring-Security-Third-Edition   File: JdbcCalendarUserDao.java   Source Code and License 5 votes vote down vote up
@Autowired
public JdbcCalendarUserDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 33
Project: Spring-Security-Third-Edition   File: JdbcEventDao.java   Source Code and License 5 votes vote down vote up
@Autowired
public JdbcEventDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 34
Project: Spring-Security-Third-Edition   File: JdbcCalendarUserDao.java   Source Code and License 5 votes vote down vote up
@Autowired
public JdbcCalendarUserDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 35
Project: Spring-Security-Third-Edition   File: JdbcEventDao.java   Source Code and License 5 votes vote down vote up
@Autowired
public JdbcEventDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 36
Project: Spring-Security-Third-Edition   File: JdbcCalendarUserDao.java   Source Code and License 5 votes vote down vote up
@Autowired
public JdbcCalendarUserDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 37
Project: Spring-Security-Third-Edition   File: JdbcEventDao.java   Source Code and License 5 votes vote down vote up
@Autowired
public JdbcEventDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 38
Project: Spring-Security-Third-Edition   File: JdbcCalendarUserDao.java   Source Code and License 5 votes vote down vote up
@Autowired
public JdbcCalendarUserDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 39
Project: Spring-Security-Third-Edition   File: JdbcEventDao.java   Source Code and License 5 votes vote down vote up
@Autowired
public JdbcEventDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 40
Project: Spring-Security-Third-Edition   File: JdbcCalendarUserDao.java   Source Code and License 5 votes vote down vote up
@Autowired
public JdbcCalendarUserDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 41
Project: Spring-Security-Third-Edition   File: JdbcEventDao.java   Source Code and License 5 votes vote down vote up
@Autowired
public JdbcEventDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 42
Project: Spring-Security-Third-Edition   File: JdbcCalendarUserDao.java   Source Code and License 5 votes vote down vote up
@Autowired
public JdbcCalendarUserDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 43
Project: Spring-Security-Third-Edition   File: JdbcEventDao.java   Source Code and License 5 votes vote down vote up
@Autowired
public JdbcEventDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 44
Project: Spring-Security-Third-Edition   File: JdbcCalendarUserDao.java   Source Code and License 5 votes vote down vote up
@Autowired
public JdbcCalendarUserDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 45
Project: Spring-Security-Third-Edition   File: JdbcEventDao.java   Source Code and License 5 votes vote down vote up
@Autowired
public JdbcEventDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 46
Project: Spring-Security-Third-Edition   File: JdbcCalendarUserDao.java   Source Code and License 5 votes vote down vote up
@Autowired
public JdbcCalendarUserDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 47
Project: Spring-Security-Third-Edition   File: JdbcEventDao.java   Source Code and License 5 votes vote down vote up
@Autowired
public JdbcEventDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 48
Project: plugin-bt-jira   File: JiraUpdateDao.java   Source Code and License 5 votes vote down vote up
/**
 * Associate custom field values to a given issue.
 */
@SuppressWarnings("unchecked")
private int associateCutomFieldValues(final Map<String, CustomFieldEditor> customFields,
		final JdbcOperations jdbcTemplate, final int nextId, final JiraIssueRow issueRow) {
	int nextIdl = nextId;
	for (final Entry<String, Object> entry : issueRow.getCustomFields().entrySet()) {
		final String cfName = entry.getKey();
		final CustomField customField = customFields.get(cfName);
		final int cfId = customField.getId();
		final Object cfValue = entry.getValue();

		// Determine the right 'customfieldvalue' column
		final String column = JiraDao.MANAGED_TYPE.get(customField.getFieldType()).getCustomColumn();
		final Collection<Object> values;
		if (cfValue instanceof Collection) {
			// Multi-values
			values = (Collection<Object>) cfValue;
		} else {
			// Single value
			values = new ArrayList<>(1);
			values.add(cfValue);
		}
		nextIdl = associateCustomFieldValue(jdbcTemplate, issueRow.getId(), nextIdl, cfId, column, values);

	}
	return nextIdl;
}
 
Example 49
Project: Spring-Security-Third-Edition   File: JdbcEventDao.java   Source Code and License 5 votes vote down vote up
@Autowired
public JdbcEventDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 50
Project: Spring-Security-Third-Edition   File: JdbcCalendarUserDao.java   Source Code and License 5 votes vote down vote up
@Autowired
public JdbcCalendarUserDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 51
Project: Spring-Security-Third-Edition   File: JdbcEventDao.java   Source Code and License 5 votes vote down vote up
@Autowired
public JdbcEventDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 52
Project: Spring-Security-Third-Edition   File: JdbcCalendarUserDao.java   Source Code and License 5 votes vote down vote up
@Autowired
public JdbcCalendarUserDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 53
Project: Spring-Security-Third-Edition   File: JdbcEventDao.java   Source Code and License 5 votes vote down vote up
@Autowired
public JdbcEventDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 54
Project: Spring-Security-Third-Edition   File: JdbcCalendarUserDao.java   Source Code and License 5 votes vote down vote up
@Autowired
public JdbcCalendarUserDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 55
Project: Spring-Security-Third-Edition   File: JdbcEventDao.java   Source Code and License 5 votes vote down vote up
@Autowired
public JdbcEventDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 56
Project: Spring-Security-Third-Edition   File: JdbcCalendarUserDao.java   Source Code and License 5 votes vote down vote up
@Autowired
public JdbcCalendarUserDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 57
Project: Spring-Security-Third-Edition   File: JdbcEventDao.java   Source Code and License 5 votes vote down vote up
@Autowired
public JdbcEventDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 58
Project: Spring-Security-Third-Edition   File: JdbcCalendarUserDao.java   Source Code and License 5 votes vote down vote up
@Autowired
public JdbcCalendarUserDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 59
Project: Spring-Security-Third-Edition   File: JdbcEventDao.java   Source Code and License 5 votes vote down vote up
@Autowired
public JdbcEventDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 60
Project: Spring-Security-Third-Edition   File: JdbcCalendarUserDao.java   Source Code and License 5 votes vote down vote up
@Autowired
public JdbcCalendarUserDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}