use of javax.persistence.NoResultException in project Asqatasun by Asqatasun.
the class ProcessResultDAOImpl method retrieveProcessResultListByWebResourceAndScope.
@Override
public Collection<ProcessResult> retrieveProcessResultListByWebResourceAndScope(WebResource webResource, Scope scope, String theme, Collection<String> testSolutions) {
StringBuilder sb = new StringBuilder();
sb.append("SELECT pr FROM ");
sb.append(getEntityClass().getName());
sb.append(" pr");
sb.append(" JOIN pr.subject w");
sb.append(" JOIN pr.test t");
sb.append(" JOIN pr.test.criterion.theme th");
sb.append(" JOIN t.scope s");
sb.append(" WHERE w=:webResource");
sb.append(" AND (s = :scope or s.id = :pageAndSiteScope) ");
if (theme != null && !theme.isEmpty() && !theme.equals(selectAllThemeKey)) {
sb.append("AND (th.code = :theme)");
}
if (!testSolutions.isEmpty()) {
sb.append(" AND (pr.definiteValue IN (:testSolution)) ");
}
Query query = entityManager.createQuery(sb.toString());
query.setParameter("webResource", webResource);
query.setParameter("scope", scope);
query.setParameter("pageAndSiteScope", pageAndSiteScopeId);
if (theme != null && !theme.isEmpty() && !theme.equals(selectAllThemeKey)) {
query.setParameter("theme", theme);
}
if (!testSolutions.isEmpty()) {
Collection<TestSolution> solutions = new ArrayList<>();
for (String solution : testSolutions) {
solutions.add(TestSolution.valueOf(solution));
}
query.setParameter("testSolution", solutions);
}
try {
return query.getResultList();
} catch (NoResultException e) {
return null;
}
}
use of javax.persistence.NoResultException in project Asqatasun by Asqatasun.
the class ProcessResultDAOImpl method hasAuditSiteScopeResult.
@Override
public boolean hasAuditSiteScopeResult(WebResource webResource, Scope scope) {
Query query = entityManager.createQuery("SELECT count(pr.id) FROM " + getEntityClass().getName() + " pr" + " JOIN pr.subject r" + " JOIN pr.test t" + " JOIN t.scope s" + " WHERE (r.id=:id)" + " AND (s = :scope or s.id = :pageAndSiteScope)");
query.setParameter("id", webResource.getId());
query.setParameter("pageAndSiteScope", pageAndSiteScopeId);
query.setParameter("scope", scope);
query.setHint(CACHEABLE_OPTION, TRUE);
try {
if ((Long) query.getSingleResult() > 0) {
return true;
} else {
return false;
}
} catch (NoResultException e) {
return false;
}
}
use of javax.persistence.NoResultException in project Asqatasun by Asqatasun.
the class ProcessResultDAOImpl method retrieveProcessResultListByWebResourceAndCriterion.
@Override
public Collection<ProcessResult> retrieveProcessResultListByWebResourceAndCriterion(WebResource webResource, Criterion criterion) {
Query query = entityManager.createQuery("SELECT distinct(pr) FROM " + getEntityClass().getName() + " pr" + " LEFT JOIN FETCH pr.remarkSet pk" + " LEFT JOIN FETCH pk.elementSet el" + " JOIN pr.subject r" + " JOIN pr.test t" + " JOIN t.criterion c" + " WHERE r=:webResource" + " AND c=:criterion");
query.setParameter("webResource", webResource);
query.setParameter("criterion", criterion);
try {
return query.getResultList();
} catch (NoResultException e) {
return null;
}
}
use of javax.persistence.NoResultException in project Asqatasun by Asqatasun.
the class CriterionStatisticsDAOImpl method findCriterionStatisticsByWebResource.
@Override
public Collection<CriterionStatistics> findCriterionStatisticsByWebResource(WebResource webResource, String theme, Collection<String> testSolutions) {
boolean hasTheme = false;
if (theme != null && !StringUtils.equals(theme, selectAllThemeKey)) {
hasTheme = true;
}
boolean hasTestSolution = false;
if (!testSolutions.isEmpty()) {
hasTestSolution = true;
}
StringBuilder strb = new StringBuilder();
strb.append("SELECT cs FROM ");
strb.append(getEntityClass().getName());
strb.append(" cs ");
strb.append(" JOIN cs.webResourceStatistics wrs ");
if (hasTheme) {
strb.append(" JOIN cs.criterion cr ");
}
strb.append(" WHERE wrs.webResource=:webResource ");
if (hasTheme) {
strb.append(" AND cr.theme.code=:theme ");
}
if (hasTestSolution) {
strb.append(" AND cs.criterionResult IN (:testSolution) ");
}
Query query = entityManager.createQuery(strb.toString());
query.setParameter("webResource", webResource);
if (hasTestSolution) {
Collection<TestSolution> solutions = new ArrayList<TestSolution>();
for (String solution : testSolutions) {
solutions.add(TestSolution.valueOf(solution));
}
query.setParameter("testSolution", solutions);
}
if (hasTheme) {
query.setParameter("theme", theme);
}
try {
return query.getResultList();
} catch (NoResultException e) {
return null;
}
}
use of javax.persistence.NoResultException in project Asqatasun by Asqatasun.
the class TestDAOImpl method retrieveTestFromAuditAndLabel.
@Override
public Test retrieveTestFromAuditAndLabel(Audit audit, String testLabel) {
Query query = entityManager.createQuery("SELECT t FROM " + getAuditEntityClass().getName() + " a" + " LEFT JOIN a.testList t" + " WHERE t.label=:testLabel" + " AND a = :audit");
query.setParameter("audit", audit);
query.setParameter("testLabel", testLabel);
try {
return (Test) query.getSingleResult();
} catch (NoResultException nre) {
return null;
}
}
Aggregations