List of usage examples for org.hibernate Criteria addOrder
public Criteria addOrder(Order order);
From source file:au.org.theark.core.dao.StudyDao.java
License:Open Source License
public List<State> getStates(Country country) { if (country == null) { country = getCountry(Constants.DEFAULT_COUNTRY_CODE); }// ww w .jav a 2 s . co m Criteria criteria = getSession().createCriteria(State.class); criteria.add(Restrictions.eq("country", country)); criteria.addOrder(Order.asc("name")); return criteria.list(); }
From source file:au.org.theark.core.dao.StudyDao.java
License:Open Source License
/** * Gets a list of all Address Types/* w w w . j a v a2 s.c o m*/ * * @return */ public List<AddressType> getAddressTypes() { List<AddressType> AddressTypeLstNew = new ArrayList<AddressType>(); Criteria criteria = getSession().createCriteria(AddressType.class); criteria.addOrder(Order.asc("name")); List<AddressType> AddressTypeLst = criteria.list(); for (AddressType addressType : AddressTypeLst) { String name = addressType.getName().toLowerCase(); addressType.setName(WordUtils.capitalize(name)); AddressTypeLstNew.add(addressType); } return AddressTypeLstNew; }
From source file:au.org.theark.core.dao.StudyDao.java
License:Open Source License
/** * Gets a list of all Phone Types//from w w w. j a v a2s. c o m * * @return */ public List<PhoneType> getPhoneTypes() { Criteria criteria = getSession().createCriteria(PhoneType.class); criteria.addOrder(Order.asc("name")); return criteria.list(); }
From source file:au.org.theark.core.dao.StudyDao.java
License:Open Source License
public String getPreviousLastname(Person person) { Criteria criteria = getSession().createCriteria(PersonLastnameHistory.class); if (person.getId() != null) { criteria.add(Restrictions.eq(Constants.PERSON_SURNAME_HISTORY_PERSON, person)); }/* w w w . j a v a2 s . c om*/ criteria.addOrder(Order.asc("id")); PersonLastnameHistory personLastameHistory = new PersonLastnameHistory(); List<PersonLastnameHistory> results = criteria.list(); if (results.size() > 0) { // what this is saying is get the second-last last-name to display // as "previous lastname" personLastameHistory = (PersonLastnameHistory) results.get(results.size() - 1); } // else it doesnt have a previous...only a current return personLastameHistory.getLastName(); }
From source file:au.org.theark.core.dao.StudyDao.java
License:Open Source License
private Criteria buildGeneralSubjectCriteria(SubjectVO subjectVO) { Criteria criteria = getSession().createCriteria(LinkSubjectStudy.class); criteria.createAlias("person", "p"); if (subjectVO.getLinkSubjectStudy().getStudy() != null) { criteria.add(Restrictions.eq("study.id", subjectVO.getLinkSubjectStudy().getStudy().getId())); } else {// www . ja va2 s. c om criteria.add(Restrictions.in("study", subjectVO.getStudyList())); criteria.createAlias("study", "st"); criteria.addOrder(Order.asc("st.name")); } if (subjectVO.getLinkSubjectStudy().getPerson() != null) { if (subjectVO.getLinkSubjectStudy().getPerson().getId() != null) { criteria.add(Restrictions.eq("p.id", subjectVO.getLinkSubjectStudy().getPerson().getId())); } if (subjectVO.getLinkSubjectStudy().getPerson().getFirstName() != null) { criteria.add(Restrictions.ilike("p.firstName", subjectVO.getLinkSubjectStudy().getPerson().getFirstName(), MatchMode.ANYWHERE)); } if (subjectVO.getLinkSubjectStudy().getPerson().getMiddleName() != null) { criteria.add(Restrictions.ilike("p.middleName", subjectVO.getLinkSubjectStudy().getPerson().getMiddleName(), MatchMode.ANYWHERE)); } if (subjectVO.getLinkSubjectStudy().getPerson().getLastName() != null) { /* old code pre George adding personlastname lookup criteria.add(Restrictions.ilike("p.lastName", subjectVO.getLinkSubjectStudy().getPerson().getLastName(), MatchMode.ANYWHERE));*/ //log.info("Lastname: " + subjectVO.getLinkSubjectStudy().getPerson().getLastName()); DetachedCriteria previousLastNames = DetachedCriteria.forClass(PersonLastnameHistory.class, "l") .setProjection(Projections.property("l.lastName")) .add(Restrictions.ilike("l.lastName", subjectVO.getLinkSubjectStudy().getPerson().getLastName(), MatchMode.ANYWHERE)) .add(Restrictions.eqProperty("p.id", "l.person.id")); criteria.add(Restrictions.or(Restrictions.ilike("p.lastName", subjectVO.getLinkSubjectStudy().getPerson().getLastName(), MatchMode.ANYWHERE), Subqueries.exists(previousLastNames))); } if (subjectVO.getLinkSubjectStudy().getPerson().getDateOfBirth() != null) { criteria.add(Restrictions.eq("p.dateOfBirth", subjectVO.getLinkSubjectStudy().getPerson().getDateOfBirth())); } if (subjectVO.getLinkSubjectStudy().getPerson().getGenderType() != null) { criteria.add(Restrictions.eq("p.genderType.id", subjectVO.getLinkSubjectStudy().getPerson().getGenderType().getId())); } if (subjectVO.getLinkSubjectStudy().getPerson().getVitalStatus() != null) { criteria.add(Restrictions.eq("p.vitalStatus.id", subjectVO.getLinkSubjectStudy().getPerson().getVitalStatus().getId())); } if (!subjectVO.getLinkSubjectStudy().getPerson().getOtherIDs().isEmpty()) { OtherID o = (OtherID) subjectVO.getLinkSubjectStudy().getPerson().getOtherIDs().toArray()[0]; if (o != null && o.getOtherID() != null && !o.getOtherID().isEmpty()) { log.info("OtherID search"); // DetachedCriteria otherID = DetachedCriteria.forClass(OtherID.class, "O") // .setProjection(Projections.projectionList().add(Projections.property("O.otherID"))) // .add(Restrictions.ilike("O.otherID", ((OtherID) subjectVO.getLinkSubjectStudy().getPerson().getOtherIDs().toArray()[0]).getOtherID(), MatchMode.EXACT)) // .add(Restrictions.eqProperty("p.id", "O.person.id")); // criteria.add(Subqueries.exists(otherID)); criteria.createAlias("p.otherIDs", "o"); criteria.add(Restrictions.ilike("o.otherID", ((OtherID) subjectVO.getLinkSubjectStudy().getPerson().getOtherIDs().toArray()[0]) .getOtherID(), MatchMode.ANYWHERE)); criteria.setProjection(Projections.distinct( Projections.projectionList().add(Projections.property("o.personid"), "lss.person.id"))); } } } if (subjectVO.getLinkSubjectStudy().getSubjectUID() != null && subjectVO.getLinkSubjectStudy().getSubjectUID().length() > 0) { criteria.add(Restrictions.ilike("subjectUID", subjectVO.getLinkSubjectStudy().getSubjectUID(), MatchMode.ANYWHERE)); } if (subjectVO.getLinkSubjectStudy().getSubjectStatus() != null) { criteria.add(Restrictions.eq("subjectStatus", subjectVO.getLinkSubjectStudy().getSubjectStatus())); SubjectStatus subjectStatus = getSubjectStatus("Archive"); if (subjectStatus != null) { criteria.add(Restrictions.ne("subjectStatus", subjectStatus)); } } else { SubjectStatus subjectStatus = getSubjectStatus("Archive"); if (subjectStatus != null) { criteria.add(Restrictions.ne("subjectStatus", subjectStatus)); } } if (subjectVO.getRelativeUIDs().size() > 0) { criteria.add(Restrictions.not(Restrictions.in("subjectUID", subjectVO.getRelativeUIDs().toArray()))); } criteria.setProjection(Projections.distinct(Projections.projectionList().add(Projections.id()))); criteria.addOrder(Order.asc("subjectUID")); return criteria; }
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 va2 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<Upload> searchUploads(Upload uploadCriteria) { Criteria criteria = getSession().createCriteria(Upload.class); // Must be constrained on the arkFunction criteria.add(Restrictions.eq("arkFunction", uploadCriteria.getArkFunction())); if (uploadCriteria.getId() != null) { criteria.add(Restrictions.eq("id", uploadCriteria.getId())); }/*ww w. j a v a2 s. co m*/ if (uploadCriteria.getStudy() != null) { criteria.add(Restrictions.eq("study", uploadCriteria.getStudy())); } if (uploadCriteria.getFileFormat() != null) { criteria.add(Restrictions.ilike("fileFormat", uploadCriteria.getFileFormat())); } if (uploadCriteria.getDelimiterType() != null) { criteria.add(Restrictions.ilike("delimiterType", uploadCriteria.getDelimiterType())); } if (uploadCriteria.getFilename() != null) { criteria.add(Restrictions.ilike("filename", uploadCriteria.getFilename())); } criteria.addOrder(Order.desc("id")); List<Upload> resultsList = criteria.list(); return resultsList; }
From source file:au.org.theark.core.dao.StudyDao.java
License:Open Source License
public List<Upload> searchUploadsForBio(Upload uploadCriteria) { Criteria criteria = getSession().createCriteria(Upload.class); // - due to nature of table design...we need to specify it like this // ideally we might want to just have arkmodule in the upload table? // criteria.add(Restrictions.eq("arkFunction", // uploadCriteria.getArkFunction())); ArkFunction biospecArkFunction = getArkFunctionByName(Constants.FUNCTION_KEY_VALUE_BIOSPECIMEN); //ArkFunction biocollArkFunction = getArkFunctionByName(Constants.FUNCTION_KEY_VALUE_LIMS_COLLECTION); ArkFunction biocollArkFunction = getArkFunctionByName(Constants.FUNCTION_KEY_VALUE_LIMS_CUSTOM_FIELD); List<ArkFunction> arkFunctionsForBio = new ArrayList<ArkFunction>(); arkFunctionsForBio.add(biospecArkFunction); arkFunctionsForBio.add(biocollArkFunction); criteria.add(Restrictions.in("arkFunction", arkFunctionsForBio)); if (uploadCriteria.getId() != null) { criteria.add(Restrictions.eq("id", uploadCriteria.getId())); }/*w w w. j a va 2 s . co m*/ if (uploadCriteria.getStudy() != null) { criteria.add(Restrictions.eq("study", uploadCriteria.getStudy())); } if (uploadCriteria.getFileFormat() != null) { criteria.add(Restrictions.ilike("fileFormat", uploadCriteria.getFileFormat())); } if (uploadCriteria.getDelimiterType() != null) { criteria.add(Restrictions.ilike("delimiterType", uploadCriteria.getDelimiterType())); } if (uploadCriteria.getFilename() != null) { criteria.add(Restrictions.ilike("filename", uploadCriteria.getFilename())); } criteria.addOrder(Order.desc("id")); List<Upload> resultsList = criteria.list(); return resultsList; }
From source file:au.org.theark.core.dao.StudyDao.java
License:Open Source License
public List<Upload> searchUploadsForBiospecimen(Upload uploadCriteria, List studyListForUser) { Criteria criteria = getSession().createCriteria(Upload.class); // - due to nature of table design...we need to specify it like this // ideally we might want to just have arkmodule in the upload table? // criteria.add(Restrictions.eq("arkFunction", // uploadCriteria.getArkFunction())); ArkFunction biospecArkFunction = getArkFunctionByName(Constants.FUNCTION_KEY_VALUE_BIOSPECIMEN); List<ArkFunction> arkFunctionsForBio = new ArrayList<ArkFunction>(); arkFunctionsForBio.add(biospecArkFunction); criteria.add(Restrictions.eq("arkFunction", uploadCriteria.getArkFunction())); if (uploadCriteria.getId() != null) { criteria.add(Restrictions.eq("id", uploadCriteria.getId())); }/*w w w.ja v a2s. co m*/ if (!studyListForUser.isEmpty()) { criteria.add(Restrictions.in("study", studyListForUser)); } if (uploadCriteria.getFileFormat() != null) { criteria.add(Restrictions.ilike("fileFormat", uploadCriteria.getFileFormat())); } if (uploadCriteria.getDelimiterType() != null) { criteria.add(Restrictions.ilike("delimiterType", uploadCriteria.getDelimiterType())); } if (uploadCriteria.getFilename() != null) { criteria.add(Restrictions.ilike("filename", uploadCriteria.getFilename())); } criteria.addOrder(Order.desc("id")); List<Upload> resultsList = criteria.list(); return resultsList; }