@Test
  public void orderedScheduledBuilds_shouldCacheJobPlan() {
    when(mockTemplate.queryForList(eq("scheduledPlanIds"))).thenReturn(Arrays.asList(1L, 2L));

    final DefaultJobPlan firstJob = jobPlan(1);
    final DefaultJobPlan secondJob = jobPlan(2);
    List<JobPlan> expectedPlans =
        new ArrayList<JobPlan>() {
          {
            add(firstJob);
            add(secondJob);
          }
        };
    when(mockTemplate.queryForObject("scheduledPlan", arguments("id", 1L).asMap()))
        .thenReturn(firstJob);
    when(mockTemplate.queryForObject("scheduledPlan", arguments("id", 2L).asMap()))
        .thenReturn(secondJob);

    jobInstanceDao.setSqlMapClientTemplate(mockTemplate);
    jobInstanceDao.orderedScheduledBuilds();

    List<JobPlan> plans = jobInstanceDao.orderedScheduledBuilds();

    assertThat(plans, is(expectedPlans));

    verify(mockTemplate, times(2)).queryForObject(eq("scheduledPlan"), any());
    verify(mockTemplate, times(2)).queryForList(eq("scheduledPlanIds"));
  }
  @Test
  public void updateStatus_shouldRemoveCachedJobPlan() {
    when(mockTemplate.queryForList(eq("scheduledPlanIds"))).thenReturn(Arrays.asList(1L));

    final DefaultJobPlan firstJob = jobPlan(1);
    List<JobPlan> expectedPlans =
        new ArrayList<JobPlan>() {
          {
            add(firstJob);
          }
        };
    when(mockTemplate.queryForObject("scheduledPlan", arguments("id", 1L).asMap()))
        .thenReturn(firstJob);

    jobInstanceDao.setSqlMapClientTemplate(mockTemplate);
    jobInstanceDao.orderedScheduledBuilds(); // populate the cache

    JobInstance instance = instance(1);
    jobInstanceDao.updateStateAndResult(instance);

    List<JobPlan> plans = jobInstanceDao.orderedScheduledBuilds();

    assertThat(plans, is(expectedPlans));

    verify(mockTemplate, times(2))
        .queryForObject(
            "scheduledPlan", arguments("id", 1L).asMap()); // because the cache is cleared
    verify(mockTemplate, times(2)).queryForList(eq("scheduledPlanIds"));
  }
  @Test
  public void activeJobs_shouldRemoveCacheActiveJobOnUpdateJobStatus() {
    final ActiveJob first = new ActiveJob(1L, "pipeline", 1, "label", "stage", "first");
    final ActiveJob second = new ActiveJob(2L, "another", 2, "label", "stage", "job1");
    List<ActiveJob> expectedJobs = Arrays.asList(first, second);

    when(mockTemplate.queryForList("getActiveJobIds")).thenReturn(Arrays.asList(1L, 2L));
    when(mockTemplate.queryForObject("getActiveJobById", arguments("id", 1L).asMap()))
        .thenReturn(first);
    when(mockTemplate.queryForObject("getActiveJobById", arguments("id", 2L).asMap()))
        .thenReturn(second);

    jobInstanceDao.setSqlMapClientTemplate(mockTemplate);
    jobInstanceDao.activeJobs(); // cache it first

    jobInstanceDao.updateStateAndResult(instance(1L)); // should remove from cache

    List<ActiveJob> activeJobs = jobInstanceDao.activeJobs();

    assertThat(expectedJobs, is(activeJobs));

    verify(mockTemplate, times(2)).queryForList("getActiveJobIds");
    verify(mockTemplate, times(2)).queryForObject("getActiveJobById", arguments("id", 1L).asMap());
    verify(mockTemplate, times(1)).queryForObject("getActiveJobById", arguments("id", 2L).asMap());
  }
Beispiel #4
0
 public int getMaxC_id() {
   int maxC_id = -1;
   if (ibatisTemplate.queryForObject("getMaxC_id") != null) {
     maxC_id = (Integer) ibatisTemplate.queryForObject("getMaxC_id");
   }
   return maxC_id;
 }
Beispiel #5
0
  public List<BoardVo> getList() {
    System.out.println("BoardDaoList");
    List<BoardVo> list = (List<BoardVo>) sqlMapClientTemplate.queryForList("board.list");

    /*			String sql = "  SELECT no, view_cnt, member_name, title, TO_CHAR (reg_date, 'YYYY-MMDD HH:MM:SS'), member_no FROM board order by my_no desc, order_no";
     */ return list;
  }
Beispiel #6
0
 @SuppressWarnings("unchecked")
 public List<SysOrderDto> queryEffectiveOrderList(SysOrderDto dto) {
   Map<String, Object> paraMap = new HashMap<String, Object>();
   try {
     paraMap.put("fromOrderDate", dto.getFromOrderDate());
     paraMap.put("toOrderDate", dto.getToOrderDate());
     paraMap.put("fromPayDate", dto.getFromPayDate());
     paraMap.put("toPayDate", dto.getToPayDate());
     paraMap.put("status", dto.getStatus());
     paraMap.put("payDate", dto.getPayDate());
     paraMap.put("serviceCode", dto.getServiceCode());
     paraMap.put("inOrderName", dto.getInOrderName());
     paraMap.put("inOrderName", dto.getInOrderName());
     paraMap.put("inOrderName", dto.getInOrderName());
     paraMap.put("inOrderName", dto.getInOrderName());
     paraMap.put("serviceName", dto.getServiceName());
     paraMap.put("itemCode", dto.getItemCode());
     paraMap.put("inOrder", dto.getInOrder());
     paraMap.put("endDate", dto.getEndDate());
     paraMap.put("service1Remains", dto.getService1Remains());
     paraMap.put("service2Remains", dto.getService2Remains());
     paraMap.put("service3Remains", dto.getService3Remains());
   } catch (Exception e) {
     logger.error(e);
   }
   return sqlMapClientTemplate.queryForList("queryEffectiveOrderList", paraMap);
 }
Beispiel #7
0
 public void insert(BoardVo boardVo) {
   System.out.println(boardVo);
   sqlMapClientTemplate.insert("board.insert", boardVo);
   /*
   		String sql = "insert into board values (board_no_seq.nextval, ?, ?, ?, ?, 0, sysdate, ?, ?, ?)";
   */
 }
Beispiel #8
0
 /** 用户即将到期的订单统计 */
 public int getCountAboutToExpireOrder(Long userId, int dayEnd) {
   Map<String, Object> paramMap = new HashMap<String, Object>();
   paramMap.put("userId", userId);
   paramMap.put("dayEnd", dayEnd);
   paramMap.put("currentDate", new Date());
   Object obj = sqlMapClientTemplate.queryForObject("getCountAboutToExpireOrder", paramMap);
   return obj != null ? Integer.valueOf(obj.toString()) : 0;
 }
Beispiel #9
0
  public BoardVo getView(long no) {
    // System.out.println("BoardDao getView : " + no);
    BoardVo vo = (BoardVo) sqlMapClientTemplate.queryForObject("board.getView", no);
    return vo;

    /*
    		String sql = "SELECT no, view_cnt, member_no, member_name, title, content, TO_CHAR (reg_date, 'YYYY-MMDD HH:MM:SS') FROM board where no=?";
    */
  }
 @Override
 public int insertCruiseSequence(TVmCruiseSequence cruiseSequence) {
   int res = 0;
   Object id = sqlmapclienttemplate.insert("insertCruiseSequence", cruiseSequence);
   if (id != null && Integer.class.isInstance(id)) {
     res = Integer.parseInt(id.toString());
   }
   return res;
 }
 @Override
 public int deleteCruiseSequenceByCruise(int cruiseid) {
   int res = 0;
   Object rows = sqlmapclienttemplate.delete("deleteCruiseSequenceByCruise", cruiseid);
   if (rows != null && Integer.class.isInstance(rows)) {
     res = Integer.parseInt(rows.toString());
   }
   return res;
 }
 public Checkphone getCheckphoneBean(CheckphoneModel checkphoneModel) {
   Checkphone backcheckphone = null;
   List list =
       (List) sqlMapClientTemplate.queryForList("Checkphone.getCheckphone", checkphoneModel);
   if (list != null && list.size() > 0) {
     backcheckphone = (Checkphone) list.get(0);
   }
   return backcheckphone;
 }
  @Test
  public void activeJobs_shouldCacheCurrentlyActiveJobIds() {
    final ActiveJob first = new ActiveJob(1L, "pipeline", 1, "label", "stage", "job1");
    final ActiveJob second = new ActiveJob(2L, "another", 2, "label", "stage", "job1");
    List<ActiveJob> expectedJobs = Arrays.asList(first, second);

    when(mockTemplate.queryForList("getActiveJobIds")).thenReturn(Arrays.asList(1L, 2L));
    when(mockTemplate.queryForObject("getActiveJobById", arguments("id", 1L).asMap()))
        .thenReturn(first);
    when(mockTemplate.queryForObject("getActiveJobById", arguments("id", 2L).asMap()))
        .thenReturn(second);

    jobInstanceDao.setSqlMapClientTemplate(mockTemplate);
    jobInstanceDao.activeJobs(); // populate the cache
    List<ActiveJob> activeJobs = jobInstanceDao.activeJobs();

    assertThat(expectedJobs, is(activeJobs));
    verify(mockTemplate, times(1)).queryForList("getActiveJobIds");
    verify(mockTemplate, times(1)).queryForObject("getActiveJobById", arguments("id", 1L).asMap());
    verify(mockTemplate, times(1)).queryForObject("getActiveJobById", arguments("id", 2L).asMap());
  }
Beispiel #14
0
  public void updateform(long no, BoardVo boardVo) {
    System.out.println(boardVo);
    /*public BoardVo getView(long no){
    //System.out.println("BoardDao getView : " + no);
    BoardVo vo = (BoardVo) sqlMapClientTemplate.queryForObject("board.getView", no);
    return vo;*/

    System.out.println("boardDao : " + boardVo);
    sqlMapClientTemplate.insert("board.updateform", boardVo);
    /*
    		String sql = "insert into board values (board_no_seq.nextval, ?, ?, ?, ?, 0, sysdate, ?, ?, ?)";
    */
  }
  @Test
  public void buildByIdWithTransitions_shouldCacheWhenQueriedFor() {
    jobInstanceDao.setSqlMapClientTemplate(mockTemplate);

    JobInstance job = JobInstanceMother.assigned("job");
    job.setId(1L);
    when(mockTemplate.queryForObject("buildByIdWithTransitions", 1L)).thenReturn(job);

    JobInstance actual = jobInstanceDao.buildByIdWithTransitions(1L);
    assertThat(actual, is(job));
    assertThat(actual == job, is(false));

    jobInstanceDao.buildByIdWithTransitions(1L);
    verify(mockTemplate, times(1)).queryForObject("buildByIdWithTransitions", 1L);
  }
  @Test
  public void buildByIdWithTransitions_shouldClearFromCacheOnUpdateStatusOfJob() {
    jobInstanceDao.setSqlMapClientTemplate(mockTemplate);

    JobInstance job = JobInstanceMother.assigned("job");
    job.setId(1L);
    when(mockTemplate.queryForObject("buildByIdWithTransitions", 1L)).thenReturn(job);

    JobInstance actual = jobInstanceDao.buildByIdWithTransitions(1L);
    assertThat(actual, is(job));
    assertThat(actual == job, is(false));

    jobInstanceDao.updateStateAndResult(job); // Must clear cahced job instance

    jobInstanceDao.buildByIdWithTransitions(1L);
    verify(mockTemplate, times(2)).queryForObject("buildByIdWithTransitions", 1L);
  }
Beispiel #17
0
 public static void batchDelete(final String statementName, final List<Object> list) {
   try {
     if (list != null) {
       sqlMapClientTemplate.execute(
           new SqlMapClientCallback() {
             public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
               executor.startBatch();
               for (int i = 0, n = list.size(); i < n; i++) {
                 executor.delete(statementName, list.get(i));
               }
               executor.executeBatch();
               return null;
             }
           });
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Beispiel #18
0
 public int getOrdersCount(SysOrderDto dto) {
   Map<String, Object> paraMap = new HashMap<String, Object>();
   try {
     paraMap.put("fromOrderDate", dto.getFromOrderDate());
     paraMap.put("toOrderDate", dto.getToOrderDate());
     paraMap.put("fromPayDate", dto.getFromPayDate());
     paraMap.put("toPayDate", dto.getToPayDate());
     paraMap.put("status", dto.getStatus());
     paraMap.put("payDate", dto.getPayDate());
     paraMap.put("serviceCode", dto.getServiceCode());
     paraMap.put("inOrderName", dto.getInOrderName());
     paraMap.put("itemCode", dto.getItemCode());
     paraMap.put("inOrder", dto.getInOrder());
     paraMap.put("endDate", dto.getEndDate());
     paraMap.put("service1Remains", dto.getService1Remains());
     paraMap.put("service2Remains", dto.getService2Remains());
     paraMap.put("service3Remains", dto.getService3Remains());
   } catch (Exception e) {
     logger.error(e);
   }
   Object obj = sqlMapClientTemplate.queryForObject("queryOrderCount", paraMap);
   return obj != null ? Integer.valueOf(obj.toString()) : 0;
 }
Beispiel #19
0
  public void delete(long no, long member_no) {
    System.out.println(no + " : " + member_no);
    // 두개 이상을 넘길때 Map를 사용해라
    Map<String, String> map = new HashMap<String, String>();

    map.put("no", String.valueOf(no));
    map.put("member_no", String.valueOf(member_no));

    System.out.println(map);
    sqlMapClientTemplate.delete("board.delete", map);
    // String sql = "DELETE FROM guest_table WHERE no=? AND password=?";

    /*public BoardVo getView(long no){
    //System.out.println("BoardDao getView : " + no);
    BoardVo vo = (BoardVo) sqlMapClientTemplate.queryForObject("board.getView", no);
    return vo;*/

    // System.out.println("boardDao : " + boardVo);
    // sqlMapClientTemplate.insert("board.updateform", boardVo);
    /*
    		String sql = "insert into board values (board_no_seq.nextval, ?, ?, ?, ?, 0, sysdate, ?, ?, ?)";
    */
  }
Beispiel #20
0
 public void removeSysLog(Long id) {
   SysLogDto dto = new SysLogDto();
   dto.setId(id);
   sqlMapClientTemplate.delete("removeSysLogById", dto);
 }
Beispiel #21
0
 public void addSysLog(SysLogDto dto) {
   sqlMapClientTemplate.insert("addSysLog", dto);
 }
 public int delete(Object obj) throws DataAccessException {
   logger.debug("Ruuning statement: " + namespace + DELETE);
   validateNameSpace();
   return sqlMapClientTemplate.delete(namespace + DELETE, obj);
 }
 public Object select(Object primaryKey) throws DataAccessException {
   logger.debug("Ruuning statement: " + namespace + SELECT);
   validateNameSpace();
   return sqlMapClientTemplate.queryForObject(namespace + SELECT, primaryKey);
 }
Beispiel #24
0
 /** 当天新增订单数统计 */
 public int getNewOrdersStatisticsToDay() {
   return (Integer) sqlMapClientTemplate.queryForObject("getNewOrdersStatisticsToDay", new Date());
 }
Beispiel #25
0
 public SysOrderDto queryOrder(SysOrderDto dto) {
   return (SysOrderDto) sqlMapClientTemplate.queryForObject("queryOrder", dto);
 }
Beispiel #26
0
 /** 用户还未支付订单统计 */
 public int getCountOfHaveNotYetPaidOrder(Long userId) {
   return (Integer) sqlMapClientTemplate.queryForObject("getCountOfHaveNotYetPaidOrder", userId);
 }
 public Object insert(Object obj) throws DataAccessException {
   logger.debug("Ruuning statement: " + namespace + INSERT);
   validateNameSpace();
   return sqlMapClientTemplate.insert(namespace + INSERT, obj);
 }
Beispiel #28
0
 public int addOrder(SysOrderDto dto) {
   sqlMapClientTemplate.insert("addOrder", dto);
   return 1;
 }
 public int update(Object newObject) throws DataAccessException {
   logger.debug("Ruuning statement: " + namespace + UPDATE);
   validateNameSpace();
   return sqlMapClientTemplate.update(namespace + UPDATE, newObject);
 }
Beispiel #30
0
 public List<SysOrderDto> queryOrderByOrderIdList(SysOrderDto dto) {
   return sqlMapClientTemplate.queryForList("queryOrderByOrderIdList", dto);
 }