private void tagFrontLoadLargeTopics() { List<Topic> sortedTopicList = new ArrayList<Topic>(examination.getTopicList()); Collections.sort( sortedTopicList, new Comparator<Topic>() { public int compare(Topic a, Topic b) { return new CompareToBuilder() .append(a.getStudentSize(), b.getStudentSize()) // Ascending .append(b.getId(), a.getId()) // Descending (according to spec) .toComparison(); } }); int frontLoadLargeTopicSize = examination.getInstitutionParametrization().getFrontLoadLargeTopicSize(); if (frontLoadLargeTopicSize == 0) { return; } int minimumTopicId = sortedTopicList.size() - frontLoadLargeTopicSize; if (minimumTopicId < 0) { logger.warn( "The frontLoadLargeTopicSize (" + frontLoadLargeTopicSize + ") is bigger than topicListSize (" + sortedTopicList.size() + "). Tagging all topic as frontLoadLarge..."); minimumTopicId = 0; } for (Topic topic : sortedTopicList.subList(minimumTopicId, sortedTopicList.size())) { topic.setFrontLoadLarge(true); } }
private void readTopicListAndStudentList() throws IOException { coincidenceMap = new LinkedHashMap<Topic, Set<Topic>>(); exclusionMap = new LinkedHashMap<Topic, Set<Topic>>(); afterMap = new LinkedHashMap<Topic, Set<Topic>>(); Map<Integer, Student> studentMap = new HashMap<Integer, Student>(); int examSize = readHeaderWithNumber("Exams"); List<Topic> topicList = new ArrayList<Topic>(examSize); for (int i = 0; i < examSize; i++) { Topic topic = new Topic(); topic.setId((long) i); String line = bufferedReader.readLine(); String[] lineTokens = line.split(SPLIT_REGEX); topic.setDuration(Integer.parseInt(lineTokens[0])); List<Student> topicStudentList = new ArrayList<Student>(lineTokens.length - 1); for (int j = 1; j < lineTokens.length; j++) { topicStudentList.add(findOrCreateStudent(studentMap, Integer.parseInt(lineTokens[j]))); } topic.setStudentList(topicStudentList); topic.setFrontLoadLarge(false); topicList.add(topic); coincidenceMap.put(topic, new HashSet<Topic>()); exclusionMap.put(topic, new HashSet<Topic>()); afterMap.put(topic, new HashSet<Topic>()); } examination.setTopicList(topicList); List<Student> studentList = new ArrayList<Student>(studentMap.values()); examination.setStudentList(studentList); }