Search in sources :

Example 1 with SubjectImpl

use of gov.nih.nci.ctd2.dashboard.impl.SubjectImpl in project nci-ctd2-dashboard by CBIIT.

the class DashboardDaoImpl method findSubjectsBySynonym.

@Override
public List<Subject> findSubjectsBySynonym(String synonym, boolean exact) {
    Set<Subject> subjects = new HashSet<Subject>();
    // First grab the synonyms
    String query = "from SynonymImpl where displayName " + (exact ? " = :synonym" : "like concat('%', :synonym, '%')");
    List<Synonym> synonymList = queryWithClass(query, "synonym", synonym);
    for (Synonym o : synonymList) {
        // Second: find subjects with the synonym
        List<Subject> subjectList = queryWithClass("select o from SubjectImpl as o where :synonyms member of o.synonyms", "synonyms", o);
        for (Subject o2 : subjectList) {
            subjects.add(o2);
        }
    }
    return new ArrayList<Subject>(subjects);
}
Also used : ArrayList(java.util.ArrayList) Synonym(gov.nih.nci.ctd2.dashboard.model.Synonym) ObservedSubject(gov.nih.nci.ctd2.dashboard.model.ObservedSubject) Subject(gov.nih.nci.ctd2.dashboard.model.Subject) HashSet(java.util.HashSet)

Aggregations

ObservedSubject (gov.nih.nci.ctd2.dashboard.model.ObservedSubject)1 Subject (gov.nih.nci.ctd2.dashboard.model.Subject)1 Synonym (gov.nih.nci.ctd2.dashboard.model.Synonym)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1