Package org.springframework.batch.item.database.support

Examples of org.springframework.batch.item.database.support.SqlPagingQueryProviderFactoryBean


 
  @Override
  public List<AuditTrailInfo> getAuditTrails(String transactionId,String conversationId,String correlationId,Integer level, int maxResult) {
   
   
    SqlPagingQueryProviderFactoryBean factory  = new SqlPagingQueryProviderFactoryBean();
   
   
    String sortClause = "SEQ_ID";
    String whereClause = "where 1=1 ";
    List<Object> args = new ArrayList<Object>();
   
    if(level != null){
      whereClause += " and LOGLEVEL <= ? ";
      sortClause = "LOGLEVEL";
      args.add(level);
    }
    if(StringUtils.hasText(correlationId)){
      whereClause += " and CORRELATION_ID = ? ";
      sortClause = "CORRELATION_ID";
      args.add(correlationId);
    }
   
    if(StringUtils.hasText(conversationId)){
      whereClause += " and CONVERSATION_ID = ? ";
      sortClause = "CONVERSATION_ID";
      args.add(conversationId);
    }
   
    if(StringUtils.hasText(transactionId)){
      whereClause += " and TRANSACTION_ID = ? ";
      sortClause = "TRANSACTION_ID";
      args.add(transactionId);
    }
   
    String selectClause = "select "
        +"SEQ_ID,"
        +"TRANSACTION_ID,"
        +"CONVERSATION_ID,"
        +"CORRELATION_ID,"
        +"OCCURRENCE,"
        +"LOGLEVEL,"
        +"CONTEXT,"
        +"INSTANCE_ID,"
        +"MESSAGE_TYPE";
   
    factory.setDataSource(getDataSource());
    factory.setFromClause("from COP_AUDIT_TRAIL_EVENT ");
   
    factory.setSelectClause(selectClause);
   
    factory.setWhereClause(whereClause);
    factory.setSortKey(sortClause);
   
    PagingQueryProvider queryProvider = null;
    try {
      queryProvider = (PagingQueryProvider)factory.getObject();
    } catch (Exception e) {
      logger.error(e.getMessage(),e);
      return null;
    }
   
View Full Code Here


   * @return a {@link PagingQueryProvider} with a where clause to narrow the
   * query
   * @throws Exception
   */
  private PagingQueryProvider getPagingQueryProvider(String fromClause, String whereClause) throws Exception {
    SqlPagingQueryProviderFactoryBean factory = new SqlPagingQueryProviderFactoryBean();
    factory.setDataSource(dataSource);
    fromClause = "%PREFIX%JOB_EXECUTION E, %PREFIX%JOB_INSTANCE I" + (fromClause == null ? "" : ", " + fromClause);
    factory.setFromClause(getQuery(fromClause));
    factory.setSelectClause(FIELDS);
    Map<String, Order> sortKeys = new HashMap<String, Order>();
    sortKeys.put("JOB_EXECUTION_ID", Order.DESCENDING);
    factory.setSortKeys(sortKeys);
    whereClause = "E.JOB_INSTANCE_ID=I.JOB_INSTANCE_ID" + (whereClause == null ? "" : " and " + whereClause);
    factory.setWhereClause(whereClause);

    return (PagingQueryProvider) factory.getObject();
  }
View Full Code Here

   * @return a {@link PagingQueryProvider} with a where clause to narrow the
   * query
   * @throws Exception
   */
  private PagingQueryProvider getPagingQueryProvider(String whereClause) {
    SqlPagingQueryProviderFactoryBean factory = new SqlPagingQueryProviderFactoryBean();
    factory.setDataSource(dataSource);
    factory.setFromClause(getQuery("%PREFIX%STEP_EXECUTION S, %PREFIX%JOB_EXECUTION J, %PREFIX%JOB_INSTANCE I"));
    factory.setSelectClause(FIELDS);
    Map<String, Order> sortKeys = new HashMap<String, Order>();
    sortKeys.put("STEP_EXECUTION_ID", Order.DESCENDING);
    factory.setSortKeys(sortKeys);
    if (whereClause != null) {
      factory.setWhereClause(whereClause
          + " AND S.JOB_EXECUTION_ID = J.JOB_EXECUTION_ID AND J.JOB_INSTANCE_ID = I.JOB_INSTANCE_ID");
    }
    try {
      return (PagingQueryProvider) factory.getObject();
    }
    catch (Exception e) {
      throw new IllegalStateException("Unexpected exception creating paging query provide", e);
    }
  }
View Full Code Here

  protected ItemReader<Foo> getItemReader() throws Exception {

    JdbcPagingItemReader<Foo> reader = new JdbcPagingItemReader<Foo>();
    reader.setDataSource(dataSource);
    SqlPagingQueryProviderFactoryBean factory = new SqlPagingQueryProviderFactoryBean();
    factory.setDataSource(dataSource);
    factory.setSelectClause("select ID, NAME, VALUE");
    factory.setFromClause("from T_FOOS");
    Map<String, Order> sortKeys = new LinkedHashMap<String, Order>();
    sortKeys.put("VALUE", Order.ASCENDING);
    factory.setSortKeys(sortKeys);
    reader.setQueryProvider(factory.getObject());
    reader.setRowMapper(new ParameterizedRowMapper<Foo>() {
      @Override
      public Foo mapRow(ResultSet rs, int i) throws SQLException {
        Foo foo = new Foo();
        foo.setId(rs.getInt(1));
View Full Code Here

  protected ItemReader<Foo> getItemReader() throws Exception {

    JdbcPagingItemReader<Foo> reader = new JdbcPagingItemReader<Foo>();
    reader.setDataSource(dataSource);
    SqlPagingQueryProviderFactoryBean factory = new SqlPagingQueryProviderFactoryBean();
    factory.setDataSource(dataSource);
    factory.setSelectClause("select ID, NAME, VALUE");
    factory.setFromClause("from T_FOOS");
    Map<String, Order> sortKeys = new LinkedHashMap<String, Order>();
    sortKeys.put("VALUE", Order.ASCENDING);
    factory.setSortKeys(sortKeys);
    reader.setQueryProvider(factory.getObject());
    reader.setRowMapper(new ParameterizedRowMapper<Foo>() {
      @Override
      public Foo mapRow(ResultSet rs, int i) throws SQLException {
        Foo foo = new Foo();
        foo.setId(rs.getInt(1));
View Full Code Here

    expected = "[{id=" + (minId + pageSize);
  }

  protected PagingQueryProvider getPagingQueryProvider() throws Exception {

    SqlPagingQueryProviderFactoryBean factory = new SqlPagingQueryProviderFactoryBean();
    factory.setDataSource(dataSource);
    factory.setSelectClause("select ID, NAME, VALUE");
    factory.setFromClause("from T_FOOS");
    Map<String, Order> sortKeys = new LinkedHashMap<String, Order>();
    sortKeys.put("VALUE", Order.ASCENDING);
    factory.setSortKeys(sortKeys);
    return factory.getObject();

  }
View Full Code Here

TOP

Related Classes of org.springframework.batch.item.database.support.SqlPagingQueryProviderFactoryBean

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.