@Test public void testFindByClusterAndStateCurrent() throws Exception { createRecordsUntilStep(1); Assert.assertNotNull(clusterVersionDAO.findByClusterAndStateCurrent(cluster.getClusterName())); createRecordsUntilStep(2); Assert.assertNotNull(clusterVersionDAO.findByClusterAndStateCurrent(cluster.getClusterName())); createRecordsUntilStep(3); Assert.assertNotNull(clusterVersionDAO.findByClusterAndStateCurrent(cluster.getClusterName())); createRecordsUntilStep(4); Assert.assertNotNull(clusterVersionDAO.findByClusterAndStateCurrent(cluster.getClusterName())); createRecordsUntilStep(5); Assert.assertNotNull(clusterVersionDAO.findByClusterAndStateCurrent(cluster.getClusterName())); createRecordsUntilStep(6); Assert.assertNotNull(clusterVersionDAO.findByClusterAndStateCurrent(cluster.getClusterName())); createRecordsUntilStep(7); Assert.assertNotNull(clusterVersionDAO.findByClusterAndStateCurrent(cluster.getClusterName())); }
@RequiresSession public ClusterVersionEntity findByClusterAndStateCurrent(String clusterName) { final TypedQuery<ClusterVersionEntity> query = entityManagerProvider.get() .createNamedQuery("clusterVersionByClusterAndState", ClusterVersionEntity.class); query.setParameter("clusterName", clusterName); query.setParameter("state", RepositoryVersionState.CURRENT); try { List results = query.getResultList(); if (results.isEmpty()) { return null; } else { if (results.size() == 1) { return (ClusterVersionEntity) results.get(0); } } throw new NonUniqueResultException(); } catch (NoResultException ignored) { return null; } }
ClusterVersionDAO extends CrudDAO<ClusterVersionEntity, Long> { @RequiresSession public ClusterVersionEntity findByClusterAndStateCurrent(String clusterName) { final TypedQuery<ClusterVersionEntity> query = entityManagerProvider.get() .createNamedQuery("clusterVersionByClusterAndState", ClusterVersionEntity.class); query.setParameter("clusterName", clusterName); query.setParameter("state", RepositoryVersionState.CURRENT); try { List results = query.getResultList(); if (results.isEmpty()) { return null; } else { if (results.size() == 1) { return (ClusterVersionEntity) results.get(0); } } throw new NonUniqueResultException(); } catch (NoResultException ignored) { return null; } } }
ClusterVersionDAO extends CrudDAO<ClusterVersionEntity, Long> { @RequiresSession public ClusterVersionEntity findByClusterAndStateCurrent(String clusterName) { final TypedQuery<ClusterVersionEntity> query = entityManagerProvider.get() .createNamedQuery("clusterVersionByClusterAndState", ClusterVersionEntity.class); query.setParameter("clusterName", clusterName); query.setParameter("state", RepositoryVersionState.CURRENT); try { List results = query.getResultList(); if (results.isEmpty()) { return null; } else { if (results.size() == 1) { return (ClusterVersionEntity) results.get(0); } } throw new NonUniqueResultException(); } catch (NoResultException ignored) { return null; } } ClusterVersionDAO(); }
ClusterVersionDAO extends CrudDAO<ClusterVersionEntity, Long> { @RequiresSession public ClusterVersionEntity findByClusterAndStateCurrent(String clusterName) { final TypedQuery<ClusterVersionEntity> query = entityManagerProvider.get() .createNamedQuery("clusterVersionByClusterAndState", ClusterVersionEntity.class); query.setParameter("clusterName", clusterName); query.setParameter("state", RepositoryVersionState.CURRENT); try { List results = query.getResultList(); if (results.isEmpty()) { return null; } else { if (results.size() == 1) { return (ClusterVersionEntity) results.get(0); } } throw new NonUniqueResultException(); } catch (NoResultException ignored) { return null; } } ClusterVersionDAO(); @RequiresSession List<ClusterVersionEntity> findByStackAndVersion(String stackName,
      String stackVersion, String version); @RequiresSession ClusterVersionEntity findByClusterAndStackAndVersion(
      String clusterName, StackId stackId, String version); @RequiresSession List<ClusterVersionEntity> findByCluster(String clusterName); @RequiresSession ClusterVersionEntity findByClusterAndStateCurrent(String clusterName); @RequiresSession List<ClusterVersionEntity> findByClusterAndState(String clusterName, RepositoryVersionState state); @Override @Transactional void create(ClusterVersionEntity entity); @Transactional ClusterVersionEntity create(ClusterEntity cluster, RepositoryVersionEntity repositoryVersion,
                                     RepositoryVersionState state, long startTime, long endTime, String userName); @Transactional void updateVersions(Long clusterId, RepositoryVersionEntity target, RepositoryVersionEntity current); }
ClusterVersionDAO extends CrudDAO<ClusterVersionEntity, Long> { @RequiresSession public ClusterVersionEntity findByClusterAndStateCurrent(String clusterName) { final TypedQuery<ClusterVersionEntity> query = entityManagerProvider.get() .createNamedQuery("clusterVersionByClusterAndState", ClusterVersionEntity.class); query.setParameter("clusterName", clusterName); query.setParameter("state", RepositoryVersionState.CURRENT); try { List results = query.getResultList(); if (results.isEmpty()) { return null; } else { if (results.size() == 1) { return (ClusterVersionEntity) results.get(0); } } throw new NonUniqueResultException(); } catch (NoResultException ignored) { return null; } } ClusterVersionDAO(); @RequiresSession List<ClusterVersionEntity> findByStackAndVersion(String stackName,
      String stackVersion, String version); @RequiresSession ClusterVersionEntity findByClusterAndStackAndVersion(
      String clusterName, StackId stackId, String version); @RequiresSession List<ClusterVersionEntity> findByCluster(String clusterName); @RequiresSession ClusterVersionEntity findByClusterAndStateCurrent(String clusterName); @RequiresSession List<ClusterVersionEntity> findByClusterAndState(String clusterName, RepositoryVersionState state); @Override @Transactional void create(ClusterVersionEntity entity); @Transactional ClusterVersionEntity create(ClusterEntity cluster, RepositoryVersionEntity repositoryVersion,
                                     RepositoryVersionState state, long startTime, long endTime, String userName); @Transactional void updateVersions(Long clusterId, RepositoryVersionEntity target, RepositoryVersionEntity current);  }