@Test public void testStageSorting() throws Exception { List<SortRequestProperty> sortProperties = new ArrayList<SortRequestProperty>(); SortRequest sortRequest = new SortRequestImpl(sortProperties); Predicate predicate = new PredicateBuilder().property( StageResourceProvider.STAGE_CLUSTER_NAME).equals("c1").toPredicate(); sortProperties.add(new SortRequestProperty( StageResourceProvider.STAGE_LOG_INFO, SortRequest.Order.ASC)); Request request = PropertyHelper.getReadRequest(new HashSet<String>(Arrays.<String>asList()), null, null, null, sortRequest); List<StageEntity> entities = stageDao.findAll(request, predicate); assertEquals(5, entities.size()); String lastInfo = null; for (StageEntity entity : entities) { if (lastInfo == null) { lastInfo = entity.getLogInfo(); continue; } String currentInfo = entity.getLogInfo(); assertTrue(lastInfo.compareTo(currentInfo) <= 0); lastInfo = currentInfo; } sortProperties.clear(); sortProperties.add(new SortRequestProperty( StageResourceProvider.STAGE_LOG_INFO, SortRequest.Order.DESC)); entities = stageDao.findAll(request, predicate); assertEquals(5, entities.size()); lastInfo = null; for (StageEntity entity : entities) { if (null == lastInfo) { lastInfo = entity.getLogInfo(); continue; } String currentInfo = entity.getLogInfo(); assertTrue(lastInfo.compareTo(currentInfo) >= 0); lastInfo = currentInfo; } }
@RequiresSession public List<StageEntity> findAll() { return daoUtils.selectAll(entityManagerProvider.get(), StageEntity.class); }
StageDAO { @RequiresSession public List<StageEntity> findAll() { return daoUtils.selectAll(entityManagerProvider.get(), StageEntity.class); } }
StageDAO { @RequiresSession public List<StageEntity> findAll() { return daoUtils.selectAll(entityManagerProvider.get(), StageEntity.class); }  }
StageDAO { @RequiresSession public List<StageEntity> findAll() { return daoUtils.selectAll(entityManagerProvider.get(), StageEntity.class); }  @RequiresSession StageEntity findByPK(StageEntityPK stageEntityPK); @RequiresSession List<StageEntity> findAll(); @RequiresSession long getLastRequestId(); @RequiresSession StageEntity findByActionId(String actionId); @RequiresSession List<StageEntity> findByRequestId(long requestId); @RequiresSession List<Long> findIdsByRequestId(long requestId); @RequiresSession List<StageEntity> findByStageIds(Long requestId, Set<Long> stageIds); @RequiresSession List<StageEntity> findByRequestIdAndCommandStatuses(Long requestId, Collection<HostRoleStatus> statuses); @RequiresSession List<StageEntity> findByStatuses(Collection<HostRoleStatus> statuses); @RequiresSession Map<Long, String> findRequestContext(List<Long> requestIds); @RequiresSession String findRequestContext(long requestId); @Transactional void create(StageEntity stageEntity); @Transactional StageEntity merge(StageEntity stageEntity); @Transactional void remove(StageEntity stageEntity); @Transactional void removeByPK(StageEntityPK stageEntityPK); @RequiresSession List<StageEntity> findAll(Request request, Predicate predicate); @Transactional void updateStageStatus(StageEntity stage, HostRoleStatus desiredStatus,
      ActionManager actionManager); @Transactional void updateStatus(StageEntityPK stageEntityPK, HostRoleStatus status, HostRoleStatus displayStatus); }
StageDAO { @RequiresSession public List<StageEntity> findAll() { return daoUtils.selectAll(entityManagerProvider.get(), StageEntity.class); }  @RequiresSession StageEntity findByPK(StageEntityPK stageEntityPK); @RequiresSession List<StageEntity> findAll(); @RequiresSession long getLastRequestId(); @RequiresSession StageEntity findByActionId(String actionId); @RequiresSession List<StageEntity> findByRequestId(long requestId); @RequiresSession List<Long> findIdsByRequestId(long requestId); @RequiresSession List<StageEntity> findByStageIds(Long requestId, Set<Long> stageIds); @RequiresSession List<StageEntity> findByRequestIdAndCommandStatuses(Long requestId, Collection<HostRoleStatus> statuses); @RequiresSession List<StageEntity> findByStatuses(Collection<HostRoleStatus> statuses); @RequiresSession Map<Long, String> findRequestContext(List<Long> requestIds); @RequiresSession String findRequestContext(long requestId); @Transactional void create(StageEntity stageEntity); @Transactional StageEntity merge(StageEntity stageEntity); @Transactional void remove(StageEntity stageEntity); @Transactional void removeByPK(StageEntityPK stageEntityPK); @RequiresSession List<StageEntity> findAll(Request request, Predicate predicate); @Transactional void updateStageStatus(StageEntity stage, HostRoleStatus desiredStatus,
      ActionManager actionManager); @Transactional void updateStatus(StageEntityPK stageEntityPK, HostRoleStatus status, HostRoleStatus displayStatus);  }