public boolean preloadStudent() { // this.student = analyticsService.getStudenById(39); this.student = analyticsController.getStudent(); this.oLSubjects = new ListDataModel(analyticsService.getOLSubjects(student)); this.oLSubjectsEleven = new ListDataModel(analyticsService.getOLSubjectsEleven(student)); List<OLSubjectPrediction> olSubjectPredictions = new ArrayList<>(); double termMark = 0.0; Iterator<ClassroomSubject> olsubjectIterator = oLSubjects.iterator(); Iterator<ClassroomSubject> olsubjectElevenIterator = oLSubjectsEleven.iterator(); OLSubjectPrediction olSubjectPrediction = null; while (true) { List<Double> termMarks = new ArrayList<Double>(); ClassroomSubject olSubject = null; ClassroomSubject olsubjectEleven = null; if (olsubjectIterator.hasNext() && olsubjectElevenIterator.hasNext()) { olSubject = olsubjectIterator.next(); olsubjectEleven = olsubjectElevenIterator.next(); } else { break; } ArrayList<Integer> previousTermMarks = new ArrayList<>(); ArrayList<Integer> predictedTermMarksLower = new ArrayList<>(); ArrayList<Integer> predictedTermMarksUpper = new ArrayList<>(); ArrayList<Integer> range = new ArrayList<>(); olSubjectPrediction = new OLSubjectPrediction(); boolean check = true; for (int term = 1; term <= 3; term++) { termMark = analyticsService.getTermMarksForOLSub(this.student, olSubject, term); if (termMark >= 0 && termMark <= 100) { termMarks.add(termMark); int mark = (int) termMark; if (check) { previousTermMarks.add(mark); try { // range = predictNextTerm(null, 2008, 10, term, // olSubject.getSubjectIdsubject().getName(), student.getId(), previousTermMarks); if (term < 3) { range = predictNextTerm( null, 2008, 10, term + 1, olSubject.getSubjectIdsubject().getName(), student.getId(), previousTermMarks); } if (term == 3) { range = predictNextTerm( null, 2009, 11, 1, olSubject.getSubjectIdsubject().getName(), student.getId(), previousTermMarks); } } catch (Exception e) { } } } // else if (termMark == -1) { // termMarks.add(-0.1); // } else if (termMark == -2) { // termMarks.add(-0.2); // } else if (termMark == -3) { // termMarks.add(-0.3); // } else { check = false; termMark = -1.0; termMarks.add(termMark); range.add(-1); range.add(-1); olSubjectPrediction.setCheck(true); // break; } predictedTermMarksLower.add(range.get(0)); predictedTermMarksUpper.add(range.get(1)); } for (int term = 1; term <= 3; term++) { termMark = analyticsService.getTermMarksForOLSub(this.student, olsubjectEleven, term); if (termMark >= 0 && termMark <= 100) { termMarks.add(termMark); olSubjectPrediction.setCheckTermMarks(false); int mark = (int) termMark; if (check) { previousTermMarks.add(mark); try { if (term < 3) { range = predictNextTerm( null, 2008, 11, term + 1, olSubject.getSubjectIdsubject().getName(), student.getId(), previousTermMarks); } if (term == 3) { // range = predictNextTerm(null, 2008, 11, 1, // olSubject.getSubjectIdsubject().getName(), student.getId(), previousTermMarks); } } catch (Exception e) { } } } // else if (termMark == -1) { // termMarks.add(-0.1); // } else if (termMark == -2) { // termMarks.add(-0.2); // } else if (termMark == -3) { // termMarks.add(-0.3); // } else { check = false; termMark = -1.0; termMarks.add(termMark); range.add(-1); range.add(-1); olSubjectPrediction.setCheck(true); // break; } if (term < 3) { predictedTermMarksLower.add(range.get(0)); predictedTermMarksUpper.add(range.get(1)); } } olSubjectPrediction.setOlSubject(olSubject); olSubjectPrediction.setTermMarks(termMarks); olSubjectPrediction.setTermMarksUpper(predictedTermMarksUpper); olSubjectPrediction.setTermMarksLower(predictedTermMarksLower); // createLinearModelTermMarks(olSubjectPrediction); // olSubjectPrediction.setLinearModelTermMarks(linearModelTermMarks); olSubjectPredictions.add(olSubjectPrediction); } this.olSubjectPredictions = new ListDataModel<OLSubjectPrediction>(olSubjectPredictions); Iterator<OLSubjectPrediction> iterator = olSubjectPredictions.iterator(); while (iterator.hasNext()) { OLSubjectPrediction olSubjectPrediction_tmp = iterator.next(); olSubjectPrediction_tmp.setLinearModelTermMarks( createLinearModelTermMarksForOlSub(olSubjectPrediction_tmp)); } Iterator<OLSubjectPrediction> iterator1 = olSubjectPredictions.iterator(); while (iterator1.hasNext()) { OLSubjectPrediction olSubjectPrediction_tmp = iterator1.next(); // List<String> msgs = new ArrayList<>(); // String msg = olSubjectPrediction_tmp.getMsg(); if (olSubjectPrediction_tmp.isCheck()) { olSubjectPrediction_tmp.setMsg(null); olSubjectPrediction_tmp.setMsgWarning(null); olSubjectPrediction_tmp.setMsgValidation(null); continue; } // int index = 0; // while (index < olSubjectPrediction_tmp.getTermMarksLower().size()-1) { // msgs = new ArrayList<>(); int recentIndex = olSubjectPrediction_tmp.getTermMarks().size() - 1; double termMarks1; termMarks1 = olSubjectPrediction_tmp.getTermMarks().get(recentIndex - 1); double lower = olSubjectPrediction_tmp.getTermMarksLower().get(recentIndex - 2); double upper = olSubjectPrediction_tmp.getTermMarksUpper().get(recentIndex - 2); double upper_prediction = olSubjectPrediction_tmp.getTermMarksUpper().get(recentIndex - 1); double lower_prediction = olSubjectPrediction_tmp.getTermMarksUpper().get(recentIndex - 1); if (upper < upper_prediction) { olSubjectPrediction_tmp.setPrediction_msgValidation(MessageStudentHome.future_positive); olSubjectPrediction_tmp.setPrediction_msgValidation_available(true); } else if (lower > lower_prediction) { olSubjectPrediction_tmp.setPrediction_msgWarning(MessageStudentHome.future_negative); olSubjectPrediction_tmp.setPrediction_msgWarning_available(true); } else if (lower <= lower_prediction || upper_prediction <= upper) { olSubjectPrediction_tmp.setPrediction_msg(MessageStudentHome.future_information); olSubjectPrediction_tmp.setPrediction_msg_available(true); } if (upper >= termMarks1 && termMarks1 >= lower) { // index++; olSubjectPrediction_tmp.setMsg(MessageStudentHome.info_consis); olSubjectPrediction_tmp.setMsg_available(true); continue; } if (upper < termMarks1) { // msgs.add(MessageStudentHome.appreciation); olSubjectPrediction_tmp.setMsgValidation(MessageStudentHome.appreciation); olSubjectPrediction_tmp.setMsgValidation_available(true); olSubjectPrediction_tmp.setMsg(null); olSubjectPrediction_tmp.setMsgWarning(null); continue; } if (lower > termMarks1) { olSubjectPrediction_tmp.setMsgWarning(MessageStudentHome.warning); olSubjectPrediction_tmp.setMsgWarning_available(true); olSubjectPrediction_tmp.setMsg(null); olSubjectPrediction_tmp.setMsgValidation(null); continue; } else { olSubjectPrediction_tmp.setMsg_available(true); } // index++; } // olSubjectPrediction_tmp.setMsgs(msg); // } return true; }
public boolean preloadProfiles() { YAnalyzer yAnalyzer = new YAnalyzer(); List<Integer> admissionNoList = new ArrayList<>(); admissionNoList = yAnalyzer.getNeighbours(); this.matchingStudentProfiles = new ListDataModel(analyticsService.getStudentByAdmissionNumber(admissionNoList)); // this.matchingStudentGeneralExamProfiles = new // ListDataModel(analyticsService.getStudentGeneralExamProfileByStudentList(matchingStudentProfiles)); // matchingStudentProfile.setAlSubjects(new // ListDataModel<ClassroomSubject>(analyticsService.getALSubjects(this.getStudent()))); List<SubjectResult> subjectResultListAL = null; List<SubjectResult> subjectResultListOL = null; List<MatchingStudentProfile> matchingStudentProfileClass = new ArrayList<>(); List<MatchingStudentProfile> matchingStudentProfileClassArts = new ArrayList<>(); List<MatchingStudentProfile> matchingStudentProfileClassCommerce = new ArrayList<>(); List<MatchingStudentProfile> matchingStudentProfileClassMaths = new ArrayList<>(); List<MatchingStudentProfile> matchingStudentProfileClassScience = new ArrayList<>(); List<ClassroomSubject> classroomALSubjectList = new ArrayList<>(); List<ClassroomSubject> classroomOLSubjectList = new ArrayList<>(); Student student = new Student(); MatchingStudentProfile matchingStudentProfile; Iterator<Student> matchingStudentProfileIterator = this.matchingStudentProfiles.iterator(); while (matchingStudentProfileIterator.hasNext()) { subjectResultListAL = new ArrayList<>(); subjectResultListOL = new ArrayList<>(); student = matchingStudentProfileIterator.next(); // student=analyticsService.getStudent(); matchingStudentProfile = new MatchingStudentProfile(student); int islarank = analyticsService.getStudentIslandRank(student); double zsocre = analyticsService.getStudentzScore(student); matchingStudentProfile.setIslandRank(islarank); matchingStudentProfile.setzScore(zsocre); classroomALSubjectList = analyticsService.getALSubjects(student); if (classroomALSubjectList != null) { Iterator<ClassroomSubject> classroomALSubjectIterator = classroomALSubjectList.iterator(); while (classroomALSubjectIterator.hasNext()) { ClassroomSubject classroomALSubject = classroomALSubjectIterator.next(); String result = analyticsService.getALSubjectsResult(student, classroomALSubject); SubjectResult subjectResult = new SubjectResult(classroomALSubject, result); subjectResultListAL.add(subjectResult); } classroomOLSubjectList = analyticsService.getOLSubjects(student); if (classroomOLSubjectList != null) { Iterator<ClassroomSubject> classroomOLSubjectIterator = classroomOLSubjectList.iterator(); while (classroomOLSubjectIterator.hasNext()) { ClassroomSubject classroomOLSubject = classroomOLSubjectIterator.next(); String result = analyticsService.getOLSubjectsResult(student, classroomOLSubject); SubjectResult subjectResult = new SubjectResult(classroomOLSubject, result); subjectResultListOL.add(subjectResult); } } matchingStudentProfile.setAlSubjects(new ListDataModel<SubjectResult>(subjectResultListAL)); matchingStudentProfile.setOlSubjects(new ListDataModel<SubjectResult>(subjectResultListOL)); matchingStudentProfileClass.add(matchingStudentProfile); /*check stream*/ String stream = analyticsService.checkStream(student); if (stream.contentEquals("Arts")) { matchingStudentProfileClassArts.add(matchingStudentProfile); } else if (stream.contentEquals("Commerce")) { matchingStudentProfileClassCommerce.add(matchingStudentProfile); } else if (stream.contentEquals("Physical Science")) { matchingStudentProfileClassMaths.add(matchingStudentProfile); } else if (stream.contentEquals("Biological Science")) { matchingStudentProfileClassScience.add(matchingStudentProfile); } } } matchingProfilesWithSubRes = new ListDataModel<MatchingStudentProfile>(matchingStudentProfileClass); matchingStudentProfileArts = new ListDataModel<MatchingStudentProfile>(matchingStudentProfileClassArts); matchingStudentProfileCommerce = new ListDataModel<MatchingStudentProfile>(matchingStudentProfileClassCommerce); matchingStudentProfileMaths = new ListDataModel<MatchingStudentProfile>(matchingStudentProfileClassMaths); matchingStudentProfileScience = new ListDataModel<MatchingStudentProfile>(matchingStudentProfileClassScience); if (analyticsController.getProfileStream().contentEquals("Arts")) { this.currentStream = "Arts"; matchingStudentProfileStream = matchingStudentProfileArts; } else if (analyticsController.getProfileStream().contentEquals("Commerce")) { this.currentStream = "Commerce"; matchingStudentProfileStream = matchingStudentProfileCommerce; } else if (analyticsController.getProfileStream().contentEquals("Maths")) { this.currentStream = "Physical Science"; matchingStudentProfileStream = matchingStudentProfileMaths; } else if (analyticsController.getProfileStream().contentEquals("Science")) { this.currentStream = "Biological Science"; matchingStudentProfileStream = matchingStudentProfileScience; } return true; }