List of usage examples for org.hibernate Criteria list
public List list() throws HibernateException;
From source file:au.org.theark.core.dao.StudyDao.java
License:Open Source License
public TitleType getTitleType(String name) { Criteria criteria = getSession().createCriteria(TitleType.class); criteria.add(Restrictions.eq("name", name)); TitleType titleType = new TitleType(); List<TitleType> results = criteria.list(); if (!results.isEmpty()) { titleType = (TitleType) results.get(0); }/* w w w .ja v a2s .com*/ return titleType; }
From source file:au.org.theark.core.dao.StudyDao.java
License:Open Source License
public MaritalStatus getMaritalStatus(String name) { Criteria criteria = getSession().createCriteria(MaritalStatus.class); criteria.add(Restrictions.eq("name", name)); MaritalStatus maritalStatus = new MaritalStatus(); List<MaritalStatus> results = criteria.list(); if (!results.isEmpty()) { maritalStatus = (MaritalStatus) results.get(0); }/*from w w w .j av a2 s .com*/ return maritalStatus; }
From source file:au.org.theark.core.dao.StudyDao.java
License:Open Source License
public PersonContactMethod getPersonContactMethod(String name) { Criteria criteria = getSession().createCriteria(PersonContactMethod.class); criteria.add(Restrictions.eq("name", name)); PersonContactMethod personContactMethod = new PersonContactMethod(); List<PersonContactMethod> results = criteria.list(); if (!results.isEmpty()) { personContactMethod = (PersonContactMethod) results.get(0); }// w w w.j a va 2s . c o m return personContactMethod; }
From source file:au.org.theark.core.dao.StudyDao.java
License:Open Source License
public List<SubjectVO> searchPageableSubjects(SubjectVO subjectVoCriteria, int first, int count) { Criteria criteria = buildGeneralSubjectCriteria(subjectVoCriteria); criteria.setFirstResult(first);//from w ww. ja v a 2s .c om criteria.setMaxResults(count); List<Long> longs = criteria.list(); List<LinkSubjectStudy> list = new ArrayList<LinkSubjectStudy>();//criteria.list(); for (Long l : longs) { try { list.add(getLinkSubjectStudy(l)); } catch (EntityNotFoundException e) { e.printStackTrace(); } } List<SubjectVO> subjectVOList = new ArrayList<SubjectVO>(); // TODO analyse for (Iterator iterator = list.iterator(); iterator.hasNext();) { LinkSubjectStudy linkSubjectStudy = (LinkSubjectStudy) iterator.next(); // Place the LinkSubjectStudy instance into a SubjectVO and add the // SubjectVO into a List SubjectVO subject = new SubjectVO(); subject.setLinkSubjectStudy(linkSubjectStudy); // Person person = subject.getLinkSubjectStudy().getPerson(); subject.setSubjectUID(linkSubjectStudy.getSubjectUID()); subjectVOList.add(subject); } return subjectVOList; }
From source file:au.org.theark.core.dao.StudyDao.java
License:Open Source License
public List<ConsentStatus> getRecordableConsentStatus() { Criteria criteria = getSession().createCriteria(ConsentStatus.class); criteria.add(Restrictions.not(Restrictions.ilike("name", "Not Consented", MatchMode.ANYWHERE))); return criteria.list(); }
From source file:au.org.theark.core.dao.StudyDao.java
License:Open Source License
/** * Look up a Person based on the supplied Long ID that represents a Person primary key. This id is the primary key of the Person table that can * represent a subject or contact./* w w w.j a v a2 s. c o m*/ * * @param personId * @return * @throws EntityNotFoundException * @throws ArkSystemException */ public Person getPerson(Long personId) throws EntityNotFoundException, ArkSystemException { Criteria personCriteria = getSession().createCriteria(Person.class); personCriteria.add(Restrictions.eq("id", personId)); List<Person> listOfPerson = personCriteria.list(); if (listOfPerson != null && listOfPerson.size() > 0) { return listOfPerson.get(0); } else { throw new EntityNotFoundException("The entity with id" + personId.toString() + " cannot be found."); } }
From source file:au.org.theark.core.dao.StudyDao.java
License:Open Source License
public List<ArkFunction> getModuleFunction(ArkModule arkModule) { ArkFunctionType arkFunctionType = getArkFunctionType(Constants.ARK_FUNCTION_TYPE_NON_REPORT); Criteria criteria = getSession().createCriteria(ArkModuleFunction.class); criteria.createAlias("arkFunction", "aliasArkFunction"); criteria.add(Restrictions.eq("arkModule", arkModule)); // Pass in an instance that represents arkFunctionType non-report criteria.add(Restrictions.eq("aliasArkFunction.arkFunctionType", arkFunctionType)); criteria.addOrder(Order.asc("functionSequence")); List<ArkModuleFunction> listOfArkModuleFunction = criteria.list(); List<ArkFunction> arkFunctionList = new ArrayList<ArkFunction>(); for (ArkModuleFunction arkModuleFunction : listOfArkModuleFunction) { arkFunctionList.add(arkModuleFunction.getArkFunction()); }//ww w. j a v a 2 s.c o m return arkFunctionList; }
From source file:au.org.theark.core.dao.StudyDao.java
License:Open Source License
public List<PhoneStatus> getPhoneStatus() { Criteria criteria = getSession().createCriteria(PhoneStatus.class); criteria.addOrder(Order.asc("name")); return criteria.list(); }
From source file:au.org.theark.core.dao.StudyDao.java
License:Open Source License
public List<Study> getStudiesForUser(ArkUser arkUser, Study study) { Criteria criteria = getSession().createCriteria(ArkUserRole.class); criteria.createAlias("arkStudy", "arkStudy"); criteria.add(Restrictions.eq("arkUser", arkUser));// Represents the user // either who is // logged in or one // that is provided if (study.getId() != null) { criteria.add(Restrictions.eq("arkStudy.id", study.getId())); }/*from www. j a va 2 s .c o m*/ if (study.getName() != null) { criteria.add(Restrictions.ilike("arkStudy.name", study.getName(), MatchMode.ANYWHERE)); } criteria.setProjection(Projections.distinct(Projections.property("study"))); List<Study> studies = (List<Study>) criteria.list(); return studies; }
From source file:au.org.theark.core.dao.StudyDao.java
License:Open Source License
public FileFormat getFileFormatByName(String name) { FileFormat fileFormat = null;/* w w w. j a va2 s . c om*/ Criteria criteria = getSession().createCriteria(FileFormat.class); criteria.add(Restrictions.eq("name", name)); List<FileFormat> results = criteria.list(); if (results.size() > 0) { fileFormat = (FileFormat) results.get(0); } return fileFormat; }