Java 类org.springframework.jdbc.core.simple.SimpleJdbcTemplate 实例源码

项目:openid4java    文件:JdbcNonceVerifierTest.java   
@Override
public NonceVerifier createVerifier(int maxAge) {
    DataSource dataSource = new SingleConnectionDataSource(
            "org.hsqldb.jdbcDriver",
            "jdbc:hsqldb:mem:saasstore_security_client", "sa", "", true);
    SimpleJdbcTemplate jdbcTemplate = new SimpleJdbcTemplate(dataSource);
    jdbcTemplate.getJdbcOperations().execute(
            "DROP TABLE IF EXISTS openid_nonce;");
    jdbcTemplate
            .getJdbcOperations()
            .execute(
                    "CREATE TABLE openid_nonce (  "
                            + "opurl varchar(255) NOT NULL,  nonce varchar(25) NOT NULL,  "
                            + "date datetime DEFAULT NULL,  PRIMARY KEY (opurl,nonce))");

    JdbcNonceVerifier jdbcNonceVerifier = new JdbcNonceVerifier(maxAge,
            "openid_nonce");
    jdbcNonceVerifier.setDataSource(dataSource);
    return jdbcNonceVerifier;
}
项目:omr    文件:RedmineDAOImpl.java   
/**
 * Consulta issues pelo id. Traz detalhes do repositorio e nome do projeto
 * 
 * @return
 */
public List<IssueVO> pesquisarIssues(Long... issueId) {

    final String queryIssue = 
    " select " +
    "       i.id, " +
    "       st.is_closed, " +
    "   r.url, " +
    "       r.root_url, " +
    "       r.project_id, " +
    "       p.name," +
    "       p.parent_id " + 
    " from issues i " +
    " inner join repositories r on r.project_id = i.project_id " +
    " inner join issue_statuses st on st.id = i.status_id " +
    " inner join projects p on p.id = r.project_id" + 
    " where i.id in (:ids) ";

    SimpleJdbcTemplate simpleJdbcTemplate = getSimpleJdbcTemplate();
    List<IssueVO> issue = simpleJdbcTemplate.query(queryIssue, new IssueVORowMapper(), Collections.singletonMap("ids", Arrays.asList(issueId)));

    return issue;
}
项目:omr    文件:RedmineDAOImpl.java   
/**
 * Consulta issues pelo id. Traz detalhes do repositorio e nome do projeto
 * 
 * @return
 */
public List<IssueVO> pesquisarIssues(Long... issueId) {

    final String queryIssue = 
    " select " +
    "       i.id, " +
    "       st.is_closed, " +
    "   r.url, " +
    "       r.root_url, " +
    "       r.project_id, " +
    "       p.name," +
    "       p.parent_id " + 
    " from issues i " +
    " inner join repositories r on r.project_id = i.project_id " +
    " inner join issue_statuses st on st.id = i.status_id " +
    " inner join projects p on p.id = r.project_id" + 
    " where i.id in (:ids) ";

    SimpleJdbcTemplate simpleJdbcTemplate = getSimpleJdbcTemplate();
    List<IssueVO> issue = simpleJdbcTemplate.query(queryIssue, new IssueVORowMapper(), Collections.singletonMap("ids", Arrays.asList(issueId)));

    return issue;
}
项目:omr    文件:RedmineDAOImpl.java   
/**
 * Consulta issues pelo id. Traz detalhes do repositorio e nome do projeto
 * 
 * @return
 */
public List<IssueVO> pesquisarIssues(Long... issueId) {

    final String queryIssue = 
    " select " +
    "       i.id, " +
    "       st.is_closed, " +
    "   r.url, " +
    "       r.root_url, " +
    "       r.project_id, " +
    "       p.name," +
    "       p.parent_id " + 
    " from issues i " +
    " inner join repositories r on r.project_id = i.project_id " +
    " inner join issue_statuses st on st.id = i.status_id " +
    " inner join projects p on p.id = r.project_id" + 
    " where i.id in (:ids) ";

    SimpleJdbcTemplate simpleJdbcTemplate = getSimpleJdbcTemplate();
    List<IssueVO> issue = simpleJdbcTemplate.query(queryIssue, new IssueVORowMapper(), Collections.singletonMap("ids", Arrays.asList(issueId)));

    return issue;
}
项目:omr    文件:RedmineDAOImpl.java   
/**
 * Consulta issues pelo id. Traz detalhes do repositorio e nome do projeto
 * 
 * @return
 */
public List<IssueVO> pesquisarIssues(Long... issueId) {

    final String queryIssue = 
    " select " +
    "       i.id, " +
    "       st.is_closed, " +
    "   r.url, " +
    "       r.root_url, " +
    "       r.project_id, " +
    "       p.name," +
    "       p.parent_id " + 
    " from issues i " +
    " inner join repositories r on r.project_id = i.project_id " +
    " inner join issue_statuses st on st.id = i.status_id " +
    " inner join projects p on p.id = r.project_id" + 
    " where i.id in (:ids) ";

    SimpleJdbcTemplate simpleJdbcTemplate = getSimpleJdbcTemplate();
    List<IssueVO> issue = simpleJdbcTemplate.query(queryIssue, new IssueVORowMapper(), Collections.singletonMap("ids", Arrays.asList(issueId)));

    return issue;
}
项目:omr    文件:RedmineDAOImpl.java   
/**
 * Consulta issues pelo id. Traz detalhes do repositorio e nome do projeto
 * 
 * @return
 */
public List<IssueVO> pesquisarIssues(Long... issueId) {

    final String queryIssue = 
    " select " +
    "       i.id, " +
    "       st.is_closed, " +
    "   r.url, " +
    "       r.root_url, " +
    "       r.project_id, " +
    "       p.name," +
    "       p.parent_id " + 
    " from issues i " +
    " inner join repositories r on r.project_id = i.project_id " +
    " inner join issue_statuses st on st.id = i.status_id " +
    " inner join projects p on p.id = r.project_id" + 
    " where i.id in (:ids) ";

    SimpleJdbcTemplate simpleJdbcTemplate = getSimpleJdbcTemplate();
    List<IssueVO> issue = simpleJdbcTemplate.query(queryIssue, new IssueVORowMapper(), Collections.singletonMap("ids", Arrays.asList(issueId)));

    return issue;
}
项目:firefly    文件:QueryFileInfoProcessor.java   
protected FileInfo loadData(ServerRequest sr) throws IOException, DataAccessException {

        if (!(sr instanceof TableServerRequest)) {
            throw new IllegalArgumentException("FileInfoProcessor.loadData Requires an TableServerRequest");
        }
        TableServerRequest request= (TableServerRequest)sr;
        SimpleJdbcTemplate jdbc = JdbcFactory.getSimpleTemplate(getDbInstance());

        String sql = getSql(request);
        Object[] params = getSqlParams(request);

        final FileInfoRowMapper fim = makeRowMapper(request);
        ParameterizedRowMapper<FileInfo> mapper = new ParameterizedRowMapper<FileInfo>() {
            public FileInfo mapRow(ResultSet resultSet, int i) throws SQLException {
                return fim.mapRow(resultSet, i);
            }
        };

        LOGGER.info("Executing SQL query: " + sql,
                 "         Parameters: " + "{" + CollectionUtil.toString(params) + "}");
        FileInfo val = jdbc.queryForObject(sql, mapper, params);

        return val;

    }
项目:opennmszh    文件:TemporaryDatabase.java   
public void setupDatabase() throws Exception {

        setDataSource(new SimpleDataSource(m_driver, m_url + getTestDatabase(),
                m_adminUser, m_adminPassword));
        setAdminDataSource(new SimpleDataSource(m_driver, m_url + "template1",
                m_adminUser, m_adminPassword));

        if (!m_useExisting) {
            // Synchronize around a static mutex to prevent multiple connections
            // to the template1 database
            synchronized(TEMPLATE1_MUTEX) {
                createTestDatabase();
            }
        }

        // Test connecting to test database.
        Connection connection = getConnection();
        connection.close();

        setJdbcTemplate(new SimpleJdbcTemplate(this));
    }
项目:alfresco-repository    文件:ExportDbTest.java   
@Before
public void setUp() throws Exception
{
    ctx = ApplicationContextHelper.getApplicationContext();
    dataSource = (DataSource) ctx.getBean("dataSource");
    tx = (PlatformTransactionManager) ctx.getBean("transactionManager"); 
    jdbcTemplate = new SimpleJdbcTemplate(dataSource);
    exporter = new ExportDb(ctx);
    exporter.setNamePrefix("export_test_");
    dialect = (Dialect) ctx.getBean("dialect");
}
项目:cacheonix-core    文件:SimpleJdbcClinic.java   
@Autowired
public void init(DataSource dataSource) {
    this.simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource);

    this.insertOwner = new SimpleJdbcInsert(dataSource)
        .withTableName("owners")
        .usingGeneratedKeyColumns("id");
    this.insertPet = new SimpleJdbcInsert(dataSource)
        .withTableName("pets")
        .usingGeneratedKeyColumns("id");
    this.insertVisit = new SimpleJdbcInsert(dataSource)
        .withTableName("visits")
        .usingGeneratedKeyColumns("id");
}
项目:Tank    文件:JdbcMessageDAO.java   
public Collection<Integer> listConversationsSince(int id)
        throws DataAccessException {
    MapSqlParameterSource params = new MapSqlParameterSource();
    try {
        params.addValue(ID, id, Types.INTEGER);
        SimpleJdbcTemplate template = new SimpleJdbcTemplate(
                getNamedParameterJdbcTemplate());
        return template.query(SELECT_CONVERSATIONS, ID_MAPPER, params);
    } catch (EmptyResultDataAccessException erdae) {
        return Collections.emptyList();
    }
}
项目:Tank    文件:JdbcMessageDAO.java   
public int getMessageContentId(int headerId) throws DataAccessException {
    try {
        MapSqlParameterSource params = new MapSqlParameterSource();
        params.addValue(ID, headerId, Types.INTEGER);
        SimpleJdbcTemplate template = new SimpleJdbcTemplate(
                getNamedParameterJdbcTemplate());
        return template.queryForInt(SELECT_CONTENT_ID, params);
    } catch (EmptyResultDataAccessException erdae) {
        return -1;
    }
}
项目:Tank    文件:JdbcMessageDAO.java   
public int getMessageContentSize(int id) throws DataAccessException {
    try {
        MapSqlParameterSource params = new MapSqlParameterSource();
        params.addValue(ID, id, Types.INTEGER);
        SimpleJdbcTemplate template = new SimpleJdbcTemplate(
                getNamedParameterJdbcTemplate());
        return template.queryForInt(SELECT_CONTENT_SIZE, params);
    } catch (EmptyResultDataAccessException erdae) {
        return -1;
    }
}
项目:Tank    文件:JdbcMessageDAO.java   
public Conversation getConversation(int id) throws DataAccessException {
    try {
        MapSqlParameterSource params = new MapSqlParameterSource();
        params.addValue(ID, id, Types.INTEGER);
        SimpleJdbcTemplate template = new SimpleJdbcTemplate(
                getNamedParameterJdbcTemplate());
        return template.queryForObject(SELECT_SUMMARY, CONVERSATION_MAPPER,
                params);
    } catch (EmptyResultDataAccessException erdae) {
        return null;
    }
}
项目:Tank    文件:JdbcMessageDAO.java   
public byte[] loadMessageContent(int id) throws DataAccessException {
    try {
        MapSqlParameterSource params = new MapSqlParameterSource();
        params.addValue(ID, id, Types.INTEGER);
        SimpleJdbcTemplate template = new SimpleJdbcTemplate(
                getNamedParameterJdbcTemplate());
        return template.queryForObject(SELECT_CONTENT, CONTENT_MAPPER,
                params);
    } catch (EmptyResultDataAccessException erdae) {
        return null;
    }
}
项目:Tank    文件:JdbcMessageDAO.java   
public RequestHeader loadRequestHeader(int id) throws DataAccessException {
    MapSqlParameterSource params = new MapSqlParameterSource();
    try {
        params.addValue(ID, id, Types.INTEGER);
        SimpleJdbcTemplate template = new SimpleJdbcTemplate(
                getNamedParameterJdbcTemplate());
        return template.queryForObject(SELECT_REQUEST, REQUEST_MAPPER,
                params);
    } catch (EmptyResultDataAccessException erdae) {
        return null;
    }
}
项目:Tank    文件:JdbcMessageDAO.java   
public MutableResponseHeader loadResponseHeader(int id)
        throws DataAccessException {
    try {
        MapSqlParameterSource params = new MapSqlParameterSource();
        params.addValue(ID, id, Types.INTEGER);
        SimpleJdbcTemplate template = new SimpleJdbcTemplate(
                getNamedParameterJdbcTemplate());
        return template.queryForObject(SELECT_RESPONSE, RESPONSE_MAPPER,
                params);
    } catch (EmptyResultDataAccessException erdae) {
        return null;
    }
}
项目:omr    文件:RedmineDAOImpl.java   
/**
 * Detecta repositorios registrados no redmine e seus respectivos projetos que foram afetados pela mudança, a partir da URL alterada
 * @param urlAlteracao
 * @param repoUUID
 * @return
 */
protected List<RepositorioVO> affectedRepoUUID(String urlAlteracao, String repoUUID) {
    final String queryRepositoriosAfetados = " select " + 
    "     p.id, " + 
    "     p.name, " + 
    "         p.parent_id, " +      
    "     r.id repository_id, " + 
    "     r.url, " + 
    "     r.repouuid, " + 
    "     r.root_url " + 
    " from  " +
    "     repositories r "+ 
    " inner join projects p on " + 
    "     p.id = r.id  " + 
    " where   " + 
    "     r.repouuid = ? and " + 
    "     instr(concat(r.root_url,'/',?),r.url)  " + 
    " order by  " +
    "     length(url) desc";

    SimpleJdbcTemplate jdbcTemplate = getSimpleJdbcTemplate();

    List<RepositorioVO> repositorioVOs = jdbcTemplate.query(queryRepositoriosAfetados, new RepositorioRowMapper(), repoUUID, urlAlteracao);

    determinaProjetosAfetados(repositorioVOs);

    return repositorioVOs;
}
项目:omr    文件:RedmineDAOImpl.java   
/**
 * Consulta projetos afetados pela mudança realizada na url informada.
 * 
 * @return
 */
protected List<RepositorioVO> affectedRepoNoUUID(String urlAlteracao) {

    final String queryRepositoriosAfetados = " select " + 
    "     p.id, " + 
    "     p.name, " + 
    "         p.parent_id, " +      
    "     r.id repository_id, " + 
    "     r.url, " + 
    "     r.root_url " + 
    " from  " +
    "     repositories r "+ 
    " inner join projects p on " + 
    "     p.id = r.id  " + 
    " where   " + 
    "     instr(concat(r.root_url,'/',?),r.url)  " + 
    " order by  " +
    "     length(url) desc";

    SimpleJdbcTemplate jdbcTemplate = getSimpleJdbcTemplate();

    List<RepositorioVO> repositorioVOs = jdbcTemplate.query(queryRepositoriosAfetados, new RepositorioRowMapper(false), urlAlteracao);

    determinaProjetosAfetados(repositorioVOs);

    return repositorioVOs;
}
项目:omr    文件:RedmineDAOImpl.java   
@Override
@SuppressWarnings("pmd.AvoidDuplicateLiterals")
public int logTime(CitationVO citacaoIssueVO) {
    Integer activityId = this.findDefaultActivityId();

    SimpleJdbcTemplate simpleJdbcTemplate = getSimpleJdbcTemplate();

    @SuppressWarnings("pmd.AvoidDuplicateLiterals")
    String logTimeQuery = " INSERT INTO time_entries( " +
        " project_id,  " +
        " user_id,  " +
        " issue_id,  " +
        " hours,  " +
        " comments,  " +
        " activity_id,  " +
        " spent_on,  " +
        " tyear,  " +
        " tmonth,  " +
        " tweek,  " +
        " created_on, " + 
        " updated_on)  " +
        " VALUES(" +
        " ?, ?, ?, ?, ?, ?, " +
        "curdate(), year(curdate()), month(curdate()), week(curdate()), curdate(), curdate())"; 

    Integer affected = simpleJdbcTemplate.update(logTimeQuery, 
            citacaoIssueVO.getIssueVO().getProjectVO().getId(),
            citacaoIssueVO.getRedmineUserVO().getId(),
            citacaoIssueVO.getIssueVO().getId(),
            citacaoIssueVO.getHorasDespendidas(),
            "Lançamento automático de esforço a partir da mensagem de commit!",
            activityId);

    return affected;

}
项目:omr    文件:RedmineDAOImpl.java   
/**
 * Recupera o id padrao de TimeEntryActivity para que seja possível efetuar o log time com este numero
 */
@Override
public Integer findDefaultActivityId() {
    SimpleJdbcTemplate jdbcTemplate = getSimpleJdbcTemplate();

    Integer activityId;
    try {
        activityId = jdbcTemplate.queryForInt("select id from enumerations where type='TimeEntryActivity' and is_default=1");
    } catch (EmptyResultDataAccessException e) {
        throw new JazzSVNHookRTException("Nao foi possivel identificar o codigo de atividade padrao para registrar o LogTime! Defina um código de atividade padrão no Redmine.", e);
    }

    return activityId;
}
项目:omr    文件:RedmineDAOImpl.java   
/**
 * Detecta repositorios registrados no redmine e seus respectivos projetos que foram afetados pela mudança, a partir da URL alterada
 * @param urlAlteracao
 * @param repoUUID
 * @return
 */
protected List<RepositorioVO> affectedRepoUUID(String urlAlteracao, String repoUUID) {
    final String queryRepositoriosAfetados = " select " + 
    "     p.id, " + 
    "     p.name, " + 
    "         p.parent_id, " +      
    "     r.id repository_id, " + 
    "     r.url, " + 
    "     r.repouuid, " + 
    "     r.root_url " + 
    " from  " +
    "     repositories r "+ 
    " inner join projects p on " + 
    "     p.id = r.id  " + 
    " where   " + 
    "     r.repouuid = ? and " + 
    "     instr(concat(r.root_url,'/',?),r.url)  " + 
    " order by  " +
    "     length(url) desc";

    SimpleJdbcTemplate jdbcTemplate = getSimpleJdbcTemplate();

    List<RepositorioVO> repositorioVOs = jdbcTemplate.query(queryRepositoriosAfetados, new RepositorioRowMapper(), repoUUID, urlAlteracao);

    determinaProjetosAfetados(repositorioVOs);

    return repositorioVOs;
}
项目:omr    文件:RedmineDAOImpl.java   
/**
 * Consulta projetos afetados pela mudança realizada na url informada.
 * 
 * @return
 */
protected List<RepositorioVO> affectedRepoNoUUID(String urlAlteracao) {

    final String queryRepositoriosAfetados = " select " + 
    "     p.id, " + 
    "     p.name, " + 
    "         p.parent_id, " +      
    "     r.id repository_id, " + 
    "     r.url, " + 
    "     r.root_url " + 
    " from  " +
    "     repositories r "+ 
    " inner join projects p on " + 
    "     p.id = r.id  " + 
    " where   " + 
    "     instr(concat(r.root_url,'/',?),r.url)  " + 
    " order by  " +
    "     length(url) desc";

    SimpleJdbcTemplate jdbcTemplate = getSimpleJdbcTemplate();

    List<RepositorioVO> repositorioVOs = jdbcTemplate.query(queryRepositoriosAfetados, new RepositorioRowMapper(false), urlAlteracao);

    determinaProjetosAfetados(repositorioVOs);

    return repositorioVOs;
}
项目:omr    文件:RedmineDAOImpl.java   
@Override
@SuppressWarnings("pmd.AvoidDuplicateLiterals")
public int logTime(CitationVO citacaoIssueVO) {
    Integer activityId = this.findDefaultActivityId();

    SimpleJdbcTemplate simpleJdbcTemplate = getSimpleJdbcTemplate();

    @SuppressWarnings("pmd.AvoidDuplicateLiterals")
    String logTimeQuery = " INSERT INTO time_entries( " +
        " project_id,  " +
        " user_id,  " +
        " issue_id,  " +
        " hours,  " +
        " comments,  " +
        " activity_id,  " +
        " spent_on,  " +
        " tyear,  " +
        " tmonth,  " +
        " tweek,  " +
        " created_on, " + 
        " updated_on)  " +
        " VALUES(" +
        " ?, ?, ?, ?, ?, ?, " +
        "curdate(), year(curdate()), month(curdate()), week(curdate()), curdate(), curdate())"; 

    Integer affected = simpleJdbcTemplate.update(logTimeQuery, 
            citacaoIssueVO.getIssueVO().getProjectVO().getId(),
            citacaoIssueVO.getRedmineUserVO().getId(),
            citacaoIssueVO.getIssueVO().getId(),
            citacaoIssueVO.getHorasDespendidas(),
            "Lançamento automático de esforço a partir da mensagem de commit!",
            activityId);

    return affected;

}
项目:omr    文件:RedmineDAOImpl.java   
/**
 * Recupera o id padrao de TimeEntryActivity para que seja possível efetuar o log time com este numero
 */
@Override
public Integer findDefaultActivityId() {
    SimpleJdbcTemplate jdbcTemplate = getSimpleJdbcTemplate();

    Integer activityId;
    try {
        activityId = jdbcTemplate.queryForInt("select id from enumerations where type='TimeEntryActivity' and is_default=1");
    } catch (EmptyResultDataAccessException e) {
        throw new JazzSVNHookRTException("Nao foi possivel identificar o codigo de atividade padrao para registrar o LogTime! Defina um código de atividade padrão no Redmine.", e);
    }

    return activityId;
}
项目:omr    文件:RedmineDAOImpl.java   
/**
 * Detecta repositorios registrados no redmine e seus respectivos projetos que foram afetados pela mudança, a partir da URL alterada
 * @param urlAlteracao
 * @param repoUUID
 * @return
 */
protected List<RepositorioVO> affectedRepoUUID(String urlAlteracao, String repoUUID) {
    final String queryRepositoriosAfetados = " select " + 
    "     p.id, " + 
    "     p.name, " + 
    "         p.parent_id, " +      
    "     r.id repository_id, " + 
    "     r.url, " + 
    "     r.repouuid, " + 
    "     r.root_url " + 
    " from  " +
    "     repositories r "+ 
    " inner join projects p on " + 
    "     p.id = r.id  " + 
    " where   " + 
    "     r.repouuid = ? and " + 
    "     instr(concat(r.root_url,'/',?),r.url)  " + 
    " order by  " +
    "     length(url) desc";

    SimpleJdbcTemplate jdbcTemplate = getSimpleJdbcTemplate();

    List<RepositorioVO> repositorioVOs = jdbcTemplate.query(queryRepositoriosAfetados, new RepositorioRowMapper(), repoUUID, urlAlteracao);

    determinaProjetosAfetados(repositorioVOs);

    return repositorioVOs;
}
项目:omr    文件:RedmineDAOImpl.java   
/**
 * Consulta projetos afetados pela mudança realizada na url informada.
 * 
 * @return
 */
protected List<RepositorioVO> affectedRepoNoUUID(String urlAlteracao) {

    final String queryRepositoriosAfetados = " select " + 
    "     p.id, " + 
    "     p.name, " + 
    "         p.parent_id, " +      
    "     r.id repository_id, " + 
    "     r.url, " + 
    "     r.root_url " + 
    " from  " +
    "     repositories r "+ 
    " inner join projects p on " + 
    "     p.id = r.id  " + 
    " where   " + 
    "     instr(concat(r.root_url,'/',?),r.url)  " + 
    " order by  " +
    "     length(url) desc";

    SimpleJdbcTemplate jdbcTemplate = getSimpleJdbcTemplate();

    List<RepositorioVO> repositorioVOs = jdbcTemplate.query(queryRepositoriosAfetados, new RepositorioRowMapper(false), urlAlteracao);

    determinaProjetosAfetados(repositorioVOs);

    return repositorioVOs;
}
项目:omr    文件:RedmineDAOImpl.java   
@Override
@SuppressWarnings("pmd.AvoidDuplicateLiterals")
public int logTime(CitationVO citacaoIssueVO) {
    Integer activityId = this.findDefaultActivityId();

    SimpleJdbcTemplate simpleJdbcTemplate = getSimpleJdbcTemplate();

    @SuppressWarnings("pmd.AvoidDuplicateLiterals")
    String logTimeQuery = " INSERT INTO time_entries( " +
        " project_id,  " +
        " user_id,  " +
        " issue_id,  " +
        " hours,  " +
        " comments,  " +
        " activity_id,  " +
        " spent_on,  " +
        " tyear,  " +
        " tmonth,  " +
        " tweek,  " +
        " created_on, " + 
        " updated_on)  " +
        " VALUES(" +
        " ?, ?, ?, ?, ?, ?, " +
        "curdate(), year(curdate()), month(curdate()), week(curdate()), curdate(), curdate())"; 

    Integer affected = simpleJdbcTemplate.update(logTimeQuery, 
            citacaoIssueVO.getIssueVO().getProjectVO().getId(),
            citacaoIssueVO.getRedmineUserVO().getId(),
            citacaoIssueVO.getIssueVO().getId(),
            citacaoIssueVO.getHorasDespendidas(),
            "Lançamento automático de esforço a partir da mensagem de commit!",
            activityId);

    return affected;

}
项目:omr    文件:RedmineDAOImpl.java   
/**
 * Recupera o id padrao de TimeEntryActivity para que seja possível efetuar o log time com este numero
 */
@Override
public Integer findDefaultActivityId() {
    SimpleJdbcTemplate jdbcTemplate = getSimpleJdbcTemplate();

    Integer activityId;
    try {
        activityId = jdbcTemplate.queryForInt("select id from enumerations where type='TimeEntryActivity' and is_default=1");
    } catch (EmptyResultDataAccessException e) {
        throw new JazzSVNHookRTException("Nao foi possivel identificar o codigo de atividade padrao para registrar o LogTime! Defina um código de atividade padrão no Redmine.", e);
    }

    return activityId;
}
项目:omr    文件:RedmineDAOImpl.java   
/**
 * Detecta repositorios registrados no redmine e seus respectivos projetos que foram afetados pela mudança, a partir da URL alterada
 * @param urlAlteracao
 * @param repoUUID
 * @return
 */
protected List<RepositorioVO> affectedRepoUUID(String urlAlteracao, String repoUUID) {
    final String queryRepositoriosAfetados = " select " + 
    "     p.id, " + 
    "     p.name, " + 
    "         p.parent_id, " +      
    "     r.id repository_id, " + 
    "     r.url, " + 
    "     r.repouuid, " + 
    "     r.root_url " + 
    " from  " +
    "     repositories r "+ 
    " inner join projects p on " + 
    "     p.id = r.id  " + 
    " where   " + 
    "     r.repouuid = ? and " + 
    "     instr(concat(r.root_url,'/',?),r.url)  " + 
    " order by  " +
    "     length(url) desc";

    SimpleJdbcTemplate jdbcTemplate = getSimpleJdbcTemplate();

    List<RepositorioVO> repositorioVOs = jdbcTemplate.query(queryRepositoriosAfetados, new RepositorioRowMapper(), repoUUID, urlAlteracao);

    determinaProjetosAfetados(repositorioVOs);

    return repositorioVOs;
}
项目:omr    文件:RedmineDAOImpl.java   
/**
 * Consulta projetos afetados pela mudança realizada na url informada.
 * 
 * @return
 */
protected List<RepositorioVO> affectedRepoNoUUID(String urlAlteracao) {

    final String queryRepositoriosAfetados = " select " + 
    "     p.id, " + 
    "     p.name, " + 
    "         p.parent_id, " +      
    "     r.id repository_id, " + 
    "     r.url, " + 
    "     r.root_url " + 
    " from  " +
    "     repositories r "+ 
    " inner join projects p on " + 
    "     p.id = r.id  " + 
    " where   " + 
    "     instr(concat(r.root_url,'/',?),r.url)  " + 
    " order by  " +
    "     length(url) desc";

    SimpleJdbcTemplate jdbcTemplate = getSimpleJdbcTemplate();

    List<RepositorioVO> repositorioVOs = jdbcTemplate.query(queryRepositoriosAfetados, new RepositorioRowMapper(false), urlAlteracao);

    determinaProjetosAfetados(repositorioVOs);

    return repositorioVOs;
}
项目:omr    文件:RedmineDAOImpl.java   
@Override
@SuppressWarnings("pmd.AvoidDuplicateLiterals")
public int logTime(CitationVO citacaoIssueVO) {
    Integer activityId = this.findDefaultActivityId();

    SimpleJdbcTemplate simpleJdbcTemplate = getSimpleJdbcTemplate();

    @SuppressWarnings("pmd.AvoidDuplicateLiterals")
    String logTimeQuery = " INSERT INTO time_entries( " +
        " project_id,  " +
        " user_id,  " +
        " issue_id,  " +
        " hours,  " +
        " comments,  " +
        " activity_id,  " +
        " spent_on,  " +
        " tyear,  " +
        " tmonth,  " +
        " tweek,  " +
        " created_on, " + 
        " updated_on)  " +
        " VALUES(" +
        " ?, ?, ?, ?, ?, ?, " +
        "curdate(), year(curdate()), month(curdate()), week(curdate()), curdate(), curdate())"; 

    Integer affected = simpleJdbcTemplate.update(logTimeQuery, 
            citacaoIssueVO.getIssueVO().getProjectVO().getId(),
            citacaoIssueVO.getRedmineUserVO().getId(),
            citacaoIssueVO.getIssueVO().getId(),
            citacaoIssueVO.getHorasDespendidas(),
            "Lançamento automático de esforço a partir da mensagem de commit!",
            activityId);

    return affected;

}
项目:omr    文件:RedmineDAOImpl.java   
/**
 * Recupera o id padrao de TimeEntryActivity para que seja possível efetuar o log time com este numero
 */
@Override
public Integer findDefaultActivityId() {
    SimpleJdbcTemplate jdbcTemplate = getSimpleJdbcTemplate();

    Integer activityId;
    try {
        activityId = jdbcTemplate.queryForInt("select id from enumerations where type='TimeEntryActivity' and is_default=1");
    } catch (EmptyResultDataAccessException e) {
        throw new JazzSVNHookRTException("Nao foi possivel identificar o codigo de atividade padrao para registrar o LogTime! Defina um código de atividade padrão no Redmine.", e);
    }

    return activityId;
}
项目:omr    文件:RedmineDAOImpl.java   
/**
 * Detecta repositorios registrados no redmine e seus respectivos projetos que foram afetados pela mudança, a partir da URL alterada
 * @param urlAlteracao
 * @param repoUUID
 * @return
 */
protected List<RepositorioVO> affectedRepoUUID(String urlAlteracao, String repoUUID) {
    final String queryRepositoriosAfetados = " select " + 
    "     p.id, " + 
    "     p.name, " + 
    "         p.parent_id, " +      
    "     r.id repository_id, " + 
    "     r.url, " + 
    "     r.repouuid, " + 
    "     r.root_url " + 
    " from  " +
    "     repositories r "+ 
    " inner join projects p on " + 
    "     p.id = r.id  " + 
    " where   " + 
    "     r.repouuid = ? and " + 
    "     instr(concat(r.root_url,'/',?),r.url)  " + 
    " order by  " +
    "     length(url) desc";

    SimpleJdbcTemplate jdbcTemplate = getSimpleJdbcTemplate();

    List<RepositorioVO> repositorioVOs = jdbcTemplate.query(queryRepositoriosAfetados, new RepositorioRowMapper(), repoUUID, urlAlteracao);

    determinaProjetosAfetados(repositorioVOs);

    return repositorioVOs;
}
项目:omr    文件:RedmineDAOImpl.java   
/**
 * Consulta projetos afetados pela mudança realizada na url informada.
 * 
 * @return
 */
protected List<RepositorioVO> affectedRepoNoUUID(String urlAlteracao) {

    final String queryRepositoriosAfetados = " select " + 
    "     p.id, " + 
    "     p.name, " + 
    "         p.parent_id, " +      
    "     r.id repository_id, " + 
    "     r.url, " + 
    "     r.root_url " + 
    " from  " +
    "     repositories r "+ 
    " inner join projects p on " + 
    "     p.id = r.id  " + 
    " where   " + 
    "     instr(concat(r.root_url,'/',?),r.url)  " + 
    " order by  " +
    "     length(url) desc";

    SimpleJdbcTemplate jdbcTemplate = getSimpleJdbcTemplate();

    List<RepositorioVO> repositorioVOs = jdbcTemplate.query(queryRepositoriosAfetados, new RepositorioRowMapper(false), urlAlteracao);

    determinaProjetosAfetados(repositorioVOs);

    return repositorioVOs;
}
项目:omr    文件:RedmineDAOImpl.java   
@Override
@SuppressWarnings("pmd.AvoidDuplicateLiterals")
public int logTime(CitationVO citacaoIssueVO) {
    Integer activityId = this.findDefaultActivityId();

    SimpleJdbcTemplate simpleJdbcTemplate = getSimpleJdbcTemplate();

    @SuppressWarnings("pmd.AvoidDuplicateLiterals")
    String logTimeQuery = " INSERT INTO time_entries( " +
        " project_id,  " +
        " user_id,  " +
        " issue_id,  " +
        " hours,  " +
        " comments,  " +
        " activity_id,  " +
        " spent_on,  " +
        " tyear,  " +
        " tmonth,  " +
        " tweek,  " +
        " created_on, " + 
        " updated_on)  " +
        " VALUES(" +
        " ?, ?, ?, ?, ?, ?, " +
        "curdate(), year(curdate()), month(curdate()), week(curdate()), curdate(), curdate())"; 

    Integer affected = simpleJdbcTemplate.update(logTimeQuery, 
            citacaoIssueVO.getIssueVO().getProjectVO().getId(),
            citacaoIssueVO.getRedmineUserVO().getId(),
            citacaoIssueVO.getIssueVO().getId(),
            citacaoIssueVO.getHorasDespendidas(),
            "Lançamento automático de esforço a partir da mensagem de commit!",
            activityId);

    return affected;

}
项目:omr    文件:RedmineDAOImpl.java   
/**
 * Recupera o id padrao de TimeEntryActivity para que seja possível efetuar o log time com este numero
 */
@Override
public Integer findDefaultActivityId() {
    SimpleJdbcTemplate jdbcTemplate = getSimpleJdbcTemplate();

    Integer activityId;
    try {
        activityId = jdbcTemplate.queryForInt("select id from enumerations where type='TimeEntryActivity' and is_default=1");
    } catch (EmptyResultDataAccessException e) {
        throw new JazzSVNHookRTException("Nao foi possivel identificar o codigo de atividade padrao para registrar o LogTime! Defina um código de atividade padrão no Redmine.", e);
    }

    return activityId;
}
项目:firefly    文件:SqlUtil.java   
public static String createTempTable(DataSource dataSource, String tableName, ColumnDef... content) {

        SimpleJdbcTemplate jdbc = new SimpleJdbcTemplate(dataSource);
        String[] tokens = new String[content.length];
        Arrays.fill(tokens, "?");
        String sqlCreateTable = "create temp table " + tableName + " ( " + CollectionUtil.toString(content, ",") + ") with no log";
        String sqlInsert = "insert into tbcdids values (" + CollectionUtil.toString(tokens, ",") + ")";

        jdbc.update(sqlCreateTable);
        jdbc.batchUpdate(sqlInsert, makeListOfObjectArray(content));

        return tableName;
    }
项目:qafe-platform    文件:SQLQueryDAO.java   
/**
 * @param sql
 * @param namedParameters
 * @param stmt
 * @param template
 * @return
 */
@SuppressWarnings("unchecked")
private Object handleInsert(String sql, MapSqlParameterSource namedParameters, Insert stmt, SimpleJdbcTemplate template) {
    Object result = null;
    int rowsUpdate = template.update(sql, namedParameters);
    result = String.valueOf(rowsUpdate);
    return result;
}
项目:qafe-platform    文件:ConflictDetectionUtil.java   
public static void validateChecksum(SimpleJdbcTemplate template, String updateQuery,
        Map<String, Object> localRecord, Long oldChecksum) {

    if (oldChecksum != null) {
        Map<String, Object> localRecordContent = getContent(localRecord);
        String sqlSelectByPk = createSelectByPkQuery(localRecordContent.keySet(), updateQuery);
        Map<String, Object> remoteRecord = template.queryForMap(sqlSelectByPk, localRecord);
        if (hasChanged(remoteRecord, oldChecksum)) {
            throw new UpdateConflictException(localRecordContent);
        }
    }
}