@Test public void testGetAllServiceConfigs() throws Exception { ServiceConfigEntity serviceConfigEntity = null; serviceConfigEntity = createServiceConfig("HDFS", "admin", 1L, 1L, 10L, null); serviceConfigEntity = createServiceConfig("HDFS", "admin", 2L, 2L, 20L, null); serviceConfigEntity = createServiceConfig("HDFS", "admin", 3L, 3L, 30L, null); serviceConfigEntity = createServiceConfig("YARN", "admin", 1L, 4L, 40L, null); long clusterId = serviceConfigEntity.getClusterId(); List<ServiceConfigEntity> serviceConfigs = serviceConfigDAO.getAllServiceConfigsForClusterAndStack(clusterId, HDP_01); Assert.assertEquals(4, serviceConfigs.size()); serviceConfigs = serviceConfigDAO.getAllServiceConfigsForClusterAndStack(clusterId, HDP_02); Assert.assertEquals(0, serviceConfigs.size()); }
@RequiresSession public List<ServiceConfigEntity> getAllServiceConfigsForClusterAndStack(Long clusterId, StackId stackId) { StackEntity stackEntity = stackDAO.find(stackId.getStackName(), stackId.getStackVersion()); TypedQuery<ServiceConfigEntity> query = entityManagerProvider.get().createNamedQuery( "ServiceConfigEntity.findAllServiceConfigsByStack", ServiceConfigEntity.class); query.setParameter("clusterId", clusterId); query.setParameter("stack", stackEntity); return daoUtils.selectList(query); }
ServiceConfigDAO { @RequiresSession public List<ServiceConfigEntity> getAllServiceConfigsForClusterAndStack(Long clusterId, StackId stackId) { StackEntity stackEntity = stackDAO.find(stackId.getStackName(), stackId.getStackVersion()); TypedQuery<ServiceConfigEntity> query = entityManagerProvider.get().createNamedQuery( "ServiceConfigEntity.findAllServiceConfigsByStack", ServiceConfigEntity.class); query.setParameter("clusterId", clusterId); query.setParameter("stack", stackEntity); return daoUtils.selectList(query); } }
ServiceConfigDAO { @RequiresSession public List<ServiceConfigEntity> getAllServiceConfigsForClusterAndStack(Long clusterId, StackId stackId) { StackEntity stackEntity = stackDAO.find(stackId.getStackName(), stackId.getStackVersion()); TypedQuery<ServiceConfigEntity> query = entityManagerProvider.get().createNamedQuery( "ServiceConfigEntity.findAllServiceConfigsByStack", ServiceConfigEntity.class); query.setParameter("clusterId", clusterId); query.setParameter("stack", stackEntity); return daoUtils.selectList(query); }  }
ServiceConfigDAO { @RequiresSession public List<ServiceConfigEntity> getAllServiceConfigsForClusterAndStack(Long clusterId, StackId stackId) { StackEntity stackEntity = stackDAO.find(stackId.getStackName(), stackId.getStackVersion()); TypedQuery<ServiceConfigEntity> query = entityManagerProvider.get().createNamedQuery( "ServiceConfigEntity.findAllServiceConfigsByStack", ServiceConfigEntity.class); query.setParameter("clusterId", clusterId); query.setParameter("stack", stackEntity); return daoUtils.selectList(query); }  @RequiresSession ServiceConfigEntity find(Long serviceConfigId); @RequiresSession ServiceConfigEntity findByServiceAndVersion(String serviceName, Long version); @RequiresSession List<ServiceConfigEntity> findByService(Long clusterId, String serviceName); @RequiresSession List<ServiceConfigEntity> getLastServiceConfigVersionsForGroups(Collection<Long> configGroupIds); @RequiresSession List<Long> getServiceConfigVersionsByConfig(Long clusterId, String configType, Long configVersion); @RequiresSession List<ServiceConfigEntity> getLastServiceConfigs(Long clusterId); @RequiresSession List<ServiceConfigEntity> getLastServiceConfigsForService(Long clusterId, String serviceName); @RequiresSession List<ServiceConfigEntity> getAllServiceConfigsForClusterAndStack(Long clusterId,
      StackId stackId); @RequiresSession List<ServiceConfigEntity> getLatestServiceConfigs(Long clusterId,
      StackId stackId); @RequiresSession ServiceConfigEntity getLastServiceConfig(Long clusterId, String serviceName); @RequiresSession ServiceConfigEntity findMaxVersion(Long clusterId, String serviceName); @RequiresSession List<ServiceConfigEntity> getServiceConfigs(Long clusterId); @RequiresSession List<ServiceConfigEntity> findAll(); @RequiresSession Long findNextServiceConfigVersion(long clusterId, String serviceName); @Transactional void removeHostFromServiceConfigs(final Long hostId); @Transactional void create(ServiceConfigEntity serviceConfigEntity); @Transactional ServiceConfigEntity merge(ServiceConfigEntity serviceConfigEntity); @Transactional void remove(ServiceConfigEntity serviceConfigEntity); }
ServiceConfigDAO { @RequiresSession public List<ServiceConfigEntity> getAllServiceConfigsForClusterAndStack(Long clusterId, StackId stackId) { StackEntity stackEntity = stackDAO.find(stackId.getStackName(), stackId.getStackVersion()); TypedQuery<ServiceConfigEntity> query = entityManagerProvider.get().createNamedQuery( "ServiceConfigEntity.findAllServiceConfigsByStack", ServiceConfigEntity.class); query.setParameter("clusterId", clusterId); query.setParameter("stack", stackEntity); return daoUtils.selectList(query); }  @RequiresSession ServiceConfigEntity find(Long serviceConfigId); @RequiresSession ServiceConfigEntity findByServiceAndVersion(String serviceName, Long version); @RequiresSession List<ServiceConfigEntity> findByService(Long clusterId, String serviceName); @RequiresSession List<ServiceConfigEntity> getLastServiceConfigVersionsForGroups(Collection<Long> configGroupIds); @RequiresSession List<Long> getServiceConfigVersionsByConfig(Long clusterId, String configType, Long configVersion); @RequiresSession List<ServiceConfigEntity> getLastServiceConfigs(Long clusterId); @RequiresSession List<ServiceConfigEntity> getLastServiceConfigsForService(Long clusterId, String serviceName); @RequiresSession List<ServiceConfigEntity> getAllServiceConfigsForClusterAndStack(Long clusterId,
      StackId stackId); @RequiresSession List<ServiceConfigEntity> getLatestServiceConfigs(Long clusterId,
      StackId stackId); @RequiresSession ServiceConfigEntity getLastServiceConfig(Long clusterId, String serviceName); @RequiresSession ServiceConfigEntity findMaxVersion(Long clusterId, String serviceName); @RequiresSession List<ServiceConfigEntity> getServiceConfigs(Long clusterId); @RequiresSession List<ServiceConfigEntity> findAll(); @RequiresSession Long findNextServiceConfigVersion(long clusterId, String serviceName); @Transactional void removeHostFromServiceConfigs(final Long hostId); @Transactional void create(ServiceConfigEntity serviceConfigEntity); @Transactional ServiceConfigEntity merge(ServiceConfigEntity serviceConfigEntity); @Transactional void remove(ServiceConfigEntity serviceConfigEntity);  }