Commit ac8085cc authored by Matija Obreza's avatar Matija Obreza
Browse files

Fix: Accession#stoRage no longer exists

parent 16a8e647
......@@ -30,7 +30,6 @@ import javax.persistence.PersistenceContext;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Join;
import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
......@@ -100,7 +99,6 @@ public class AccessionRepositoryCustomImpl implements AccessionRepositoryCustom,
return res;
}
@Override
public List<Accession> findById(List<? extends AccessionIdentifier3> identifiers) {
......@@ -139,8 +137,7 @@ public class AccessionRepositoryCustomImpl implements AccessionRepositoryCustom,
return res;
}
@Override
public List<Accession> find(FaoInstitute institute, Set<? extends AccessionIdentifier3> accessionIds) throws NonUniqueAccessionException {
boolean uniqueAcceNumbs = institute.hasUniqueAcceNumbs();
......@@ -149,7 +146,7 @@ public class AccessionRepositoryCustomImpl implements AccessionRepositoryCustom,
Root<Accession> root = cq.from(Accession.class);
cq.distinct(true);
cq.select(root);
root.fetch("stoRage", JoinType.LEFT);
// root.fetch("stoRage", JoinType.LEFT);
Join<Accession, Taxonomy2> tax = null;
if (!uniqueAcceNumbs) {
......@@ -171,7 +168,8 @@ public class AccessionRepositoryCustomImpl implements AccessionRepositoryCustom,
} else {
// A lot of .. (acceNumb=? and genus=?)
for (AccessionIdentifier3 ah : accessionIds) {
restrictions.add(criteriaBuilder.and(criteriaBuilder.equal(root.get("accessionNumber"), ah.getAccessionNumber()), criteriaBuilder.equal(tax.get("genus"), ah.getGenus())));
restrictions.add(criteriaBuilder.and(criteriaBuilder.equal(root.get("accessionNumber"), ah.getAccessionNumber()), criteriaBuilder.equal(tax.get("genus"), ah
.getGenus())));
}
}
cq.where(criteriaBuilder.and(criteriaBuilder.equal(root.get("institute"), institute), criteriaBuilder.or(restrictions.toArray(EMPTY_PREDICATE_ARRAY))));
......@@ -202,7 +200,7 @@ public class AccessionRepositoryCustomImpl implements AccessionRepositoryCustom,
Root<Accession> root = cq.from(Accession.class);
cq.distinct(true);
cq.select(root);
root.fetch("stoRage", JoinType.LEFT);
// root.fetch("stoRage", JoinType.LEFT);
Join<Object, Object> tax = root.join("taxonomy");
List<Predicate> restrictions = new ArrayList<Predicate>();
......@@ -214,34 +212,34 @@ public class AccessionRepositoryCustomImpl implements AccessionRepositoryCustom,
} else {
restrictions.add(criteriaBuilder.and(criteriaBuilder.equal(root.get("accessionNumber"), acceNumb), criteriaBuilder.equal(tax.get("genus"), genus)));
}
cq.where(criteriaBuilder.and(criteriaBuilder.equal(root.get("institute"), institute), criteriaBuilder.or(restrictions.toArray(new Predicate[] {}))));
return em.createQuery(cq).getSingleResult();
}
@Override
public List<AccessionData> findActiveAndHistoric(Collection<UUID> accessionUuids) {
if (accessionUuids.isEmpty()) {
return Collections.emptyList();
}
List<AccessionData> activeAndHistoric=new ArrayList<>(accessionUuids.size());
List<AccessionData> activeAndHistoric = new ArrayList<>(accessionUuids.size());
CriteriaQuery<Accession> cq = criteriaBuilder.createQuery(Accession.class);
Root<Accession> active = cq.from(Accession.class);
cq.distinct(true);
cq.select(active);
cq.where(active.get("accessionId").get("uuid").in(accessionUuids));
activeAndHistoric.addAll(em.createQuery(cq).getResultList());
CriteriaQuery<AccessionHistoric> cqhist = criteriaBuilder.createQuery(AccessionHistoric.class);
Root<AccessionHistoric> historic = cqhist.from(AccessionHistoric.class);
cqhist.distinct(true);
cqhist.select(historic);
cqhist.where(historic.get("accessionId").get("uuid").in(accessionUuids));
activeAndHistoric.addAll(em.createQuery(cqhist).getResultList());
return activeAndHistoric;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment