List of usage examples for org.hibernate StatelessSession createQuery
@Override org.hibernate.query.Query createQuery(String queryString);
From source file:edu.psu.iam.cpr.core.database.postprocess.AddressPostProcessor.java
License:Creative Commons License
/** * This method will generate the campus mappings of codes to keys */// w ww . j a va 2 s. c om private final void generateCampusMap() { campusMap = new HashMap<String, Long>(); final StatelessSession db = getStatelessSession(); if (db != null) { final Query query = db.createQuery("from CampusCs where activeFlag = :active_flag"); query.setParameter(ACTIVE_FLAG, YES); for (final Iterator<?> it = query.list().iterator(); it.hasNext();) { final CampusCs bean = (CampusCs) it.next(); campusMap.put(bean.getCampusCode(), bean.getCampusCodeKey()); } } }
From source file:edu.psu.iam.cpr.core.database.postprocess.AddressPostProcessor.java
License:Creative Commons License
/** * The method will generate the country mappings of codes to keys *///from w ww. j av a 2s . c om private final void generateCountryMaps() { countryThreeMap = new HashMap<String, Long>(); countryTwoMap = new HashMap<String, Long>(); final StatelessSession db = getStatelessSession(); if (db != null) { final Query query = db.createQuery("from Country where endDate is NULL"); for (final Iterator<?> it = query.list().iterator(); it.hasNext();) { final Country bean = (Country) it.next(); countryTwoMap.put(bean.getCountryCodeTwo(), bean.getCountryKey()); countryThreeMap.put(bean.getCountryCodeThree(), bean.getCountryKey()); } } }
From source file:edu.psu.iam.cpr.core.database.postprocess.NamesPostProcessor.java
License:Creative Commons License
/** * This is the method that set's the final legal name. * @param personId contains the person identifier whose name is to be set. * @param namesStagingBean contains the name to be set. */// w w w .ja v a2 s . c om public void setLegalName(final long personId, final NamesStaging namesStagingBean) { final StatelessSession db = getStatelessSession(); final Query query = db.createQuery( "from Names where personId = :person_id AND dataTypeKey = :data_type_key AND endDate is NULL"); query.setParameter(PERSON_ID, personId); query.setParameter(DATA_TYPE_KEY, NameType.LEGAL_NAME.index()); boolean matchFound = false; for (final Iterator<?> it = query.list().iterator(); it.hasNext();) { final Names bean = (Names) it.next(); // If the incoming name is from ISIS, we need to do an exact match on the components of name. if (namesStagingBean.getImportFrom().equals(BatchDataSource.ISIS.toString())) { // Did we find a match? if (Utility.areStringFieldsEqualIgnoreCase(namesStagingBean.getFirstName(), bean.getFirstName()) && Utility.areStringFieldsEqualIgnoreCase(namesStagingBean.getMiddleNames(), bean.getMiddleNames()) && Utility.areStringFieldsEqualIgnoreCase(namesStagingBean.getLastName(), bean.getLastName()) && Utility.areStringFieldsEqualIgnoreCase(namesStagingBean.getSuffix(), bean.getSuffix())) { matchFound = true; } // No match, so expire existing name, because we are going to add a new one. else { expireName(db, bean, namesStagingBean.getImportFrom()); } } // Non-ISIS names can use match codes. else { // Did we find a match using a match code? if (namesStagingBean.getNameMatchCode().equals(bean.getNameMatchCode())) { matchFound = true; } // No match, so expire existing name, because we are going to add a new one. else { expireName(db, bean, namesStagingBean.getImportFrom()); } } } // We did not find a match, so its time to add a new name. if (!matchFound) { addName(db, namesStagingBean); } }
From source file:edu.psu.iam.cpr.core.database.postprocess.NamesPostProcessor.java
License:Creative Commons License
/** * This method is used to obtain all of the names for a person from the names staging table. * @param personId contains the person to do the search for. *//* w w w . j a v a 2s . c om*/ public void getAllStagedNamesForPerson(final long personId) { setIsisName(null); setIbisName(null); setHmcName(null); setUpdatedName(null); final StatelessSession db = getStatelessSession(); final Query query = db.createQuery("from NamesStaging where personId = :person_id order by importDate"); query.setParameter(PERSON_ID, personId); // Most recently updated name setUpdatedName((NamesStaging) query.list().get(0)); for (final Iterator<?> it = query.list().iterator(); it.hasNext();) { final NamesStaging bean = (NamesStaging) it.next(); final String importFrom = bean.getImportFrom(); // IBIS Name. if (importFrom.equalsIgnoreCase(BatchDataSource.IBIS.toString())) { setIbisName(bean); } // ISIS Name. else if (importFrom.equalsIgnoreCase(BatchDataSource.ISIS.toString())) { setIsisName(bean); } // HMC Name. else if (importFrom.equalsIgnoreCase(BatchDataSource.HMC.toString())) { setHmcName(bean); } } }
From source file:edu.psu.iam.cpr.core.database.postprocess.NamesPostProcessor.java
License:Creative Commons License
/** * This method is used to obtain the current semester code. * @return will return the semester code. *///w w w.j av a 2 s .c o m public String getCurrentSemesterCode() { final StatelessSession db = getStatelessSession(); final Date d = new Date(); final Query query = db.createQuery("from Semesters where :now >= semStartDate AND :now < semEndDate"); query.setParameter(NOW, d); for (final Iterator<?> it = query.list().iterator(); it.hasNext();) { Semesters bean = (Semesters) it.next(); return bean.getSemesterCode(); } return null; }
From source file:edu.psu.iam.cpr.core.database.postprocess.NamesPostProcessor.java
License:Creative Commons License
/** * This method is used to obtain the value of the Student Aid flag. * @param personId contains the person to be search for. */// w ww .ja v a 2 s . com public void getStudentAidFlag(final long personId) { setStudentAid(false); final String semesterCode = getCurrentSemesterCode(); final StatelessSession db = getStatelessSession(); // Obtain the student record for the current semester. final Query query = db .createQuery("from Student where personId = :person_id AND semesterCode = :semester_code"); query.setParameter(PERSON_ID, personId); query.setParameter(SEMESTER_CODE, semesterCode); for (final Iterator<?> it = query.list().iterator(); it.hasNext();) { final Student bean = (Student) it.next(); // Call Validate to ensure the student aid flag is a Y/N value. final String flag = Validate.isValidYesNo(bean.getStudentAidFlag()); if (Utility.isOptionYes(flag)) { setStudentAid(true); } else { setStudentAid(false); } } }
From source file:edu.psu.iam.cpr.core.database.postprocess.NamesPostProcessor.java
License:Creative Commons License
/** * This helper method is used to obtains all of the affiliations for a person and determine whether they are * either an employee or a student or both. * @param personId contains the person identifier parameter. *///from ww w . j av a 2 s .c om public void getAndEvaluateAffiliations(final long personId) { setStudent(false); setEmployee(false); final StatelessSession db = getStatelessSession(); final Query query = db .createQuery("from PersonAffiliation where personId = :person_id and endDate is null"); query.setParameter(PERSON_ID, personId); for (final Iterator<?> it = query.list().iterator(); it.hasNext();) { final PersonAffiliation bean = (PersonAffiliation) it.next(); final AffiliationsType affiliationsType = AffiliationsType.get(bean.getAffiliationKey()); if (affiliationsType == AffiliationsType.STUDENT) { setStudent(true); } else if (affiliationsType == AffiliationsType.STAFF || affiliationsType == AffiliationsType.FACULTY || affiliationsType == AffiliationsType.EMPLOYEE || affiliationsType == AffiliationsType.EMERITUS || affiliationsType == AffiliationsType.RETIREE) { setEmployee(true); // Check is a Hershey employee affiliation is active if (bean.getLastUpdateBy().equals(BatchDataSource.HMC.toString())) { setEmployeeHMC(true); } } } }
From source file:edu.psu.iam.cpr.core.messaging.ChangeNotification.java
License:Creative Commons License
/** * This method is used to obtain a campus code using the campus key value. * @param campusCodeKey contains the campus key value to be used as part of the query. * @return will return the campus code if found. *///from w ww . jav a2 s . c o m private String getCampusCodeUsingKey(Long campusCodeKey) { String campusCode = null; if (campusCodeKey == null) { return campusCode; } final StatelessSession session = getStatelessSession(); final Query query = session.createQuery("from CampusCs where campusCodeKey = :campus_code_key"); query.setParameter("campus_code_key", campusCodeKey); for (final Iterator<?> it = query.list().iterator(); it.hasNext();) { CampusCs bean = (CampusCs) it.next(); campusCode = bean.getCampusCode(); } return campusCode; }
From source file:edu.psu.iam.cpr.core.messaging.ChangeNotification.java
License:Creative Commons License
/** * This method is used to obtain a country code using the campus key value. * @param countryCodeKey contains the country code to be obtained. * @return will return a country code if successful. *//* ww w .j av a2 s . c o m*/ private String getCountryCodeUsingKey(Long countryCodeKey) { String countryCode = null; if (countryCodeKey == null) { return countryCode; } final StatelessSession session = getStatelessSession(); final Query query = session.createQuery("from Country where countryKey = :country_key"); query.setParameter("country_key", countryCodeKey); for (final Iterator<?> it = query.list().iterator(); it.hasNext();) { Country bean = (Country) it.next(); countryCode = bean.getCountryCodeThree(); } return countryCode; }
From source file:edu.psu.iam.cpr.core.messaging.MessagingCore.java
License:Apache License
/** * This helper method is used to obtain a message consumer key for a specific message consumer. Right now its only used for * batch processing./* w w w . j a v a 2 s. c om*/ * @param session contains the stateless database session. * @param consumer contains the consumer to be searched for. */ private final void getMessageConsumerKey(StatelessSession session, String consumer) { Query query = session.createQuery("from MessageConsumer where consumer = :consumer AND endDate is NULL"); query.setParameter("consumer", consumer); for (Iterator<?> it = query.list().iterator(); it.hasNext();) { edu.psu.iam.cpr.core.database.beans.MessageConsumer messageConsumer = (edu.psu.iam.cpr.core.database.beans.MessageConsumer) it .next(); setBatchMessageConsumerKey(messageConsumer.getMessageConsumerKey()); } }