protected void readData() {
String line = null;
int lineCounter = 0;
int dataCounter = -1;
Person currentPerson = null;
int indexKind = -1;
int indexShortName = -1;
int indexHoursCourse = -1;
int indexHours11 = -1;
int indexHours12 = -1;
try {
while ((line = eventAssignmentReader.readLine()) != null) {
lineCounter++;
if (dataCounter >= 0)
dataCounter++;
if (line.contains("Schuljahr")) {
dataCounter = 0;
} else if (dataCounter == 3) {
currentPerson = new Person();
currentPerson.setName(line.trim());
addStudent(currentPerson);
} else if (dataCounter == 4) {
currentPerson.setDescription(line.trim());
} else if (dataCounter == 6 || line.contains("Angebot*")) {
dataCounter = 6;
indexKind = line.indexOf("Angebot*");
indexHoursCourse = line.indexOf("Std");
indexHours11 = line.indexOf("11/1");
indexHours12 = line.indexOf("12/1");
indexShortName = line.indexOf("Wahl");
} else if (dataCounter > 6 && dataCounter < 54) {
if (currentPerson == null)
logger.fatal("Person ist null!? " + lineCounter);
String courseLongName = null;
String shortName = null;
Integer courseHours = null;
Integer hours11 = null;
Integer hours12 = null;
if (indexKind >= 0 && indexKind < line.length()) {
courseLongName = line.substring(0, indexKind).trim();
if (courseLongName.startsWith("PRO"))
courseLongName = courseLongName.split(" ")[1];
if (courseLongName.length() < 1)
continue;
}
// TODO every seminar is different!
if (line.contains("Wissenschaftspropädeutisches")) {
indexHoursCourse += 4;
indexHours11 += 4;
}
if (indexHoursCourse >= 0 && indexHours11 >= 0
&& indexHours11 < line.length() && indexHoursCourse < indexHours11) {
String subStr = line.substring(indexHoursCourse, indexHours11).trim();
if (subStr.length() > 0)
courseHours = Integer.parseInt(subStr.split(" ")[0].trim());
}
if (indexHours11 >= 0 && indexHours12 >= 0
&& indexHours12 < line.length() && indexHours11 < indexHours12) {
String subStr = line.substring(indexHours11, indexHours12).trim();
if (subStr.length() > 0)
hours11 = Integer.parseInt(subStr.split(" ")[0].trim());
}
if (indexHours12 >= 0 && indexShortName >= 0
&& indexShortName < line.length() && indexHours12 < indexShortName) {
String subStr = line.substring(indexHours12, indexShortName).trim();
if (subStr.length() > 0)
hours12 = Integer.parseInt(subStr.split(" ")[0].trim());
}
if (indexShortName >= 0 && indexShortName < line.length()) {
String subStr = line.substring(indexShortName).trim();
if (subStr.length() > 0)
shortName = subStr.split(":")[0].trim();
}
if (shortName == null)
continue;
if ("Kunst PRO".equals(courseLongName)) {
// "Kunst PRO" und Kunst können als identisch angesehen werden
// wer Kunst PRO wählt, geht in den normalen Kunstunterricht
shortName = "KU";
} else if (courseLongName.startsWith("Projekt-Seminar")) {
// jeder Schüler hat zur gleichen Zeit ein Seminar
shortName = "P" + shortName;
} else if (courseLongName.startsWith("Wissenschaftspropädeutisches Seminar")) {
shortName = "W" + shortName;
}
WinQDCourse course = courses.get(shortName);
if (course == null) {
course = new WinQDCourse();
course.setShortName(shortName);
course.setName(courseLongName);
if (courseHours != null)
course.setHours(getHours(courseHours));
addCourse(course);
}
Integer hours = null;
if (semester == 11 && hours11 != null)
hours = hours11;
if (semester == 12 && hours12 != null)
hours = hours12;
if (hours != null)
course.getStudents().add(currentPerson);
}
} // while all lines of eventAssignmentFile
logger.info(courses.size() + " Kurse gefunden!");
} catch (Exception ex) {
throw new RuntimeException(eventAssignmentFile + " - Fehler in Zeile " + lineCounter
+ " (Datensatzzeile:" + dataCounter + ") : " + line, ex);
}
lineCounter = 0;
dataCounter = - 1;
try {
while ((line = courseInstancesReader.readLine()) != null) {
lineCounter++;
if (dataCounter >= 0)
dataCounter++;
if (line.contains("Kursleiter")) {
dataCounter = 0;
continue;
}
if (dataCounter < 2)
continue;
// TNZ = Teilnehmerzahl
//0 1 2 3 4 5 6 7 8
//Nr|Kurs |Art |Kursleiter |Fach 11|Fach 12|TNZ|TZ1|TZ2|..
String[] columns = line.split("\\|");
if (columns.length != 10)
continue;
int no = Integer.parseInt(columns[0].trim());
if (no == 0)
continue;
String instanceName = columns[1].trim();
String courseShortName = columns[4].trim();
if (instanceName.startsWith("1W") || instanceName.startsWith("1P")) {
int fromIndex = indexOfLower(1, instanceName);
int index = indexOfNumber(1, instanceName);
courseShortName = instanceName.substring(fromIndex, index).toUpperCase();
// geografie
if ("EK".equals(courseShortName))
courseShortName = "GEO";
// chemie
if ("CH".equals(courseShortName))
courseShortName = "C";
// sport
if ("SP".equals(courseShortName))
courseShortName = "SPO";
if (fromIndex > 1)
courseShortName = instanceName.charAt(fromIndex - 1) + courseShortName;
}
WinQDCourse course = courses.get(courseShortName);
if (course == null) {
logger.fatal("Missing course:" + courseShortName);
continue;
}
String name = columns[3].trim();
currentPerson = teachers.get(name);
if (currentPerson == null) {
currentPerson = new Person();
currentPerson.setName(name);
addTeacher(currentPerson);
}
course.addInstance(instanceName, currentPerson);