Package de.timefinder.data

Examples of de.timefinder.data.Person


            }

            updateStatus(30);
            double tmp = 10.0 / (noOfPersons + 1);
            // 3. 'noOfSubjects'-lines describes the choice of one person (student/event)
            Person currentPerson;
            for (int p = 0; p < noOfPersons; p++) {
                updateStatus(30 + (int) (p * tmp));

                currentPerson = createPerson();
                currentPerson.putConstraint(newRasterConstraint());

                for (Event event : getEventDao().getAll()) {
                    if ((Integer.parseInt(bReader.readLine()) > 0)) {
                        currentPerson.addEvent(event, true);
                    }
                }
            }

            updateStatus(40);
View Full Code Here


        event.setName("Event " + event.getId());
        return event;
    }

    public Person createPerson() {
        Person person = new Person();
        person.putConstraint(new PersonITCRasterConstraint(person, poolSettings));
        getPersonDao().attach(person);
        person.setName("Person " + person.getId());

        return person;
    }
View Full Code Here

        Map<Resource, Set<Assignment>> resources = newResources(Arrays.asList(d, b), Arrays.asList(d, a), Arrays.asList(c));
        matrix.initFromResources(resources);

        // add more visiors => force d into location with 10 seats
        for (int i = 0; i < LIMITING_CAPACITY + 1; i++) {
            b.getEvent().addPerson(new Person(), true);
            c.getEvent().addPerson(new Person(), true);
        }

        List locations = Arrays.asList(new Location(10), new Location(LIMITING_CAPACITY));

        periode = newPeriod(slotsPerWeek, locations, matrix);
View Full Code Here

    }

    @Test
    public void testCopyPropertiesOfEvent() throws Exception {
        Event source = new Event(4, 2);
        source.addPerson(new Person(), true);
        Event dest = new Event();
        Helper.copyProperties(source, dest);

        assertEquals(2, source.getDuration());
        assertEquals(2, dest.getDuration());
View Full Code Here

    @Test
    public void testPerson() {
        System.out.println("removePerson");

        Person p = new Person();
        p.setName("testName2");
        assertFalse(pDao.detach(p));

        pDao.attach(p);
        assertTrue(pDao.detach(p));

        Person andreas1 = new Person();
        andreas1.setName("Andy");
        assertEquals(0, pDao.getAll().size());
        pDao.attach(andreas1);
        assertEquals(1, pDao.getAll().size());
    }
View Full Code Here

    @Test
    public void testHasEqual() {
        System.out.println("hasEqual");

        String name = "Achim1";
        Person p2 = new Person();
        p2.setName(name);
        pDao.attach(p2);

        Person p3 = new Person();
        p3.setName(name + "false");

        assertTrue(pDao.getAll().contains(p2));
        assertFalse(pDao.getAll().contains(p3));
    }
View Full Code Here

        assertFalse(pDao.getAll().contains(p3));
    }

    @Test
    public void testRole() {
        Person p = new Person();
        Event ev1 = new Event();
        p.addEvent(ev1, Role.TEACHER, true);
        assertEquals(p.getRole(ev1), Role.TEACHER);

        Event ev2 = new Event();
        p.addEvent(ev2, true);
        assertEquals(p.getRole(ev2), Role.STUDENT);
    }
View Full Code Here

     */
    @Test
    public void testIdentical() {
        System.out.println("identival");
        String name = "Testachim";
        Person person = new Person();
        person.setName(name);
        pDao.attach(person);
        Person person1 = pDao.getAll().iterator().next();
        person1.setName("achim");

        Person person2 = pDao.getAll().iterator().next();

        pDao.commit();

        assertSame("Both persons should be identical", person2, person1);
    }
View Full Code Here

    }

    @Test
    public void testAttach() {
        PersonDaoSimpl dao = new PersonDaoSimpl();
        Person p = dao.create();
        assertFalse(dao.getMap().containsValue(p));
        assertNull(p.getId());

        dao.attach(p);
        assertTrue(dao.getMap().containsValue(p));
        assertNotNull(p.getId());
    }
View Full Code Here

    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);
View Full Code Here

TOP

Related Classes of de.timefinder.data.Person

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.