Created
September 28, 2015 15:54
-
-
Save jkneal/94655668779478e0665d to your computer and use it in GitHub Desktop.
Inv Query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public List<ClassDeptDescriptionSearchResult> searchDepartmentDescriptions( | |
String inst, String car, String strm, String subj, String catalogNumber, String subjectLetter) { | |
List<String> classCriteria = new ArrayList<String>(); | |
List<String> args = new ArrayList<String>(); | |
classCriteria.add("a.institution = :1"); | |
args.add(inst); | |
classCriteria.add("a.acad_career = :2"); | |
args.add(car); | |
String matchSubj = subj; | |
if (StringUtil.hasValue(subjectLetter)) { | |
classCriteria.add("a.subject = :3"); | |
matchSubj += "-" + subjectLetter; | |
} else { | |
classCriteria.add("a.subject LIKE :3"); | |
matchSubj += "%"; | |
} | |
args.add(matchSubj); | |
if (StringUtil.hasValue(strm)) { | |
classCriteria.add("a.strm = :4"); | |
args.add(strm); | |
} | |
if (StringUtil.hasValue(catalogNumber)) { | |
classCriteria.add("TRIM(a.catalog_nbr) = :" + (StringUtil.hasValue(strm) ? "5" : "4")); | |
args.add(catalogNumber); | |
} | |
String[] qCrit = new String[classCriteria.size()]; | |
List<SisSrClass> cl = sis.getBeanQuery(SisSrClass.class, classCriteria.toArray(qCrit), args.toArray()).getResults(); | |
Map<CldCoKey, SisSrClass> coks = new HashMap<>(); | |
for (SisSrClass src : cl) | |
coks.put(new CldCoKey(src), src); | |
Map<CldCoKey, SisCourseOffering> cos = new HashMap<>(); | |
for (SisCourseOffering co : courseOfferingService.search(coks.keySet())) | |
cos.put(new CldCoKey(co), co); | |
List<ClassDeptDescriptionSearchResult> results = new ArrayList<>(); | |
coks.keySet().stream().filter(k -> cos.containsKey(k)).forEach(cldCoKey -> { | |
SisSrClass srClass = coks.get(cldCoKey); | |
SisCourseOffering courseOffering = cos.get(cldCoKey); | |
Map<String, Object> dc = new HashMap<>(); | |
dc.put("courseId", srClass.getCourseId()); | |
dc.put("courseOfferNumber", courseOffering.getCourseOfferNumber()); | |
dc.put("strm", srClass.getStrm()); | |
ClassDescription<?> description = findDepartmentDescription(srClass); | |
if (description != null && StringUtil.hasValue(description.getClassDescription())) { | |
results.add(new ClassDeptDescriptionSearchResult(srClass, courseOffering, description)); | |
} | |
}); | |
return results; | |
} | |
private ClassDescription<?> findDepartmentDescription(SisSrClass srClass) { | |
String strm = srClass.getStrm(); | |
String courseId = srClass.getCourseId(); | |
int courseOfferNumber = srClass.getCourseOfferNumber(); | |
String sessionCode = srClass.getSessionCode(); | |
Map<CldKey, ClassDescriptionDeptEntity> dd = getDeptIndex(strm); | |
if (dd != null) { | |
ClassDescriptionDeptEntity rv = dd.get(new CldKey(courseId, | |
courseOfferNumber, strm, sessionCode)); | |
if (rv != null) | |
return rv; | |
} | |
Map<String, Object> pd = new HashMap<>(); | |
pd.put("courseId", courseId); | |
pd.put("courseOfferNumber", courseOfferNumber); | |
pd.put("strm", strm); | |
pd.put("sessionCode", DEPARTMENT_DESCRIPTION_SESSION_CODE_VALUE); | |
List<ClassDescriptionDeptEntity> descriptions = Sr.EJB.getBean("sis", SisDao.class).searchBeans(ClassDescriptionDeptEntity.class, pd); | |
if (!descriptions.isEmpty()) { | |
return descriptions.get(0); | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment