Package com.darkhonor.rage.model

Examples of com.darkhonor.rage.model.Student


                                                    //stu.setSection(res);
                                                }
                                                // TODO: RAGE-34 - Migrate to StudentDAO
                                                query = em.createQuery("select p FROM Person p WHERE p.webID = :webid");
                                                query.setParameter("webid", stu.getWebID());
                                                Student stuRes;
                                                try
                                                {
                                                    stuRes = (Student)query.getSingleResult();
                                                }
                                                catch (NoResultException ex)
View Full Code Here


        course.setId(1L);
        tx.begin();
        em.persist(course);
        tx.commit();
        // Create 2 Sections, 2 Students per Section, and 2 Instructors
        Student student1 = createPersistedStudent(1L, "John", "Doe", "C13John.Doe",
                new Integer(2013));
        Student student2 = createPersistedStudent(2L, "Mary", "Johnson", "C13Mary.Johnson",
                new Integer(2013));
        Student student3 = createPersistedStudent(3L, "Bob", "Reimer", "C13Robert.Reimer",
                new Integer(2013));
        Student student4 = createPersistedStudent(4L, "Andrew", "Callow",
                "C13Andrew.Callow", new Integer(2013));

        Section section1 = new Section("M1A");
        section1.setId(new Long(1L));
        Section section2 = new Section("M2B");
        section2.setId(new Long(2L));
        section1.setCourse(course);
        section2.setCourse(course);
       
        Instructor instructor1 = createPersistedInstructor(5L, "David", "Roberts",
                "David.Roberts");
        Instructor instructor2 = createPersistedInstructor(6L, "Sarah", "O'Reilly",
                "Sarah.OReilly");

        // Set the Instructors for Sections 1 & 2
        section1.setInstructor(instructor1);
        section2.setInstructor(instructor2);

        // Add Instructors to Course
        course.addInstructor(instructor1);
        course.addInstructor(instructor2);

        // Add Students 1 & 2 to Section 1
        section1.addStudent(student1);
        student1.addSection(section1);
        section1.addStudent(student2);
        student2.addSection(section1);

        course.addSection(section1);
        course.addSection(section2);

        // Add Students 3 & 4 to Section 2
        section2.addStudent(student3);
        student3.addSection(section2);
        section2.addStudent(student4);
        student4.addSection(section2);

        tx.begin();
        em.persist(section1);
        em.persist(section2);
        em.merge(instructor1);
View Full Code Here

        course.setId(2L);
        tx.begin();
        em.persist(course);
        tx.commit();
        // Create 2 Sections, 2 Students per Section, and 2 Instructors
        Student student1 = createPersistedStudent(7L, "John", "Doe", "C11John.Doe",
                new Integer(2011));
        Student student2 = createPersistedStudent(8L, "Mary", "Johnson",
                "C11Mary.Johnson", new Integer(2011));
        Student student3 = createPersistedStudent(3L, "Bob", "Reimer",
                "C13Robert.Reimer", new Integer(2013));
        Student student4 = createPersistedStudent(4L, "Andrew", "Callow",
                "C13Andrew.Callow", new Integer(2013));
        Student student5 = createPersistedStudent(9L, "Kerry", "Beevers",
                "C11Kerry.Beevers", new Integer(2011));

        Instructor instructor1 = createPersistedInstructor(5L, "David", "Roberts",
                "David.Roberts");

        Section section1 = new Section("T5A");
        section1.setId(new Long(3L));
        Section section2 = new Section("T6A");
        section2.setId(new Long(4L));
        section1.setCourse(course);
        section2.setCourse(course);

        // Set the Instructors for Sections 1 & 2
        section1.setInstructor(instructor1);
        section2.setInstructor(instructor1);

        // Add Instructors to Course
        course.addInstructor(instructor1);

        // Add Students 1 & 2 to Section 1
        section1.addStudent(student1);
        student1.addSection(section1);
        section1.addStudent(student2);
        student2.addSection(section1);

        course.addSection(section1);
        course.addSection(section2);

        // Add Students 3 & 4 to Section 2
        section2.addStudent(student3);
        student3.addSection(section2);
        section2.addStudent(student4);
        student4.addSection(section2);
        section2.addStudent(student5);
        student5.addSection(section2);

        tx.begin();
        em.persist(section1);
        em.persist(section2);
        em.merge(instructor1);
View Full Code Here

    private Student createPersistedStudent(Long id, String firstName, String lastName,
            String webId, Integer classYear) throws IllegalArgumentException
    {
        EntityManager em = emf.createEntityManager();
        Student student = null;

        try
        {
            student = findStudentByWebId(webId);
            LOGGER.warn("Student already exists: " + student.getWebID());
        } catch (NoResultException ex)
        {
            student = new Student (firstName, lastName, webId, classYear);
            student.setId(id);
            EntityTransaction tx = em.getTransaction();
            tx.begin();
            em.persist(student);
            tx.commit();
            LOGGER.debug("Student ID (post-persist): " + student.getId());
        }
        em.close();
        return student;
    }
View Full Code Here

    private void persistSectionStudent(Section section, Student student)
    {
        EntityManager em = emf.createEntityManager();
        EntityTransaction tx = em.getTransaction();
        Section dbSection = em.find(Section.class, section.getId());
        Student dbStudent = em.find(Student.class, student.getId());
        dbSection.addStudent(dbStudent);
        dbStudent.addSection(dbSection);
        tx.begin();
        em.merge(dbSection);
        em.merge(dbStudent);
        tx.commit();
        em.close();
View Full Code Here

    {
        Course course = new Course("CS256");
        course.setId(new Long(15L));
       
        // Create 2 Sections, 2 Students per Section, and 2 Instructors
        Student student1 = new Student("Jerry", "Baker", "C14Jerry.Baker",
                new Integer(2013));
        student1.setId(new Long(10L));
        Student student2 = new Student("Lisa", "Thompson", "C14Lisa.Thompson",
                new Integer(2013));
        student2.setId(new Long(11L));
        Student student3 = new Student("Kelly", "Rogers", "C14Kelly.Rogers",
                new Integer(2013));
        student3.setId(new Long(12L));
        Student student4 = new Student("Jason", "Borough", "C14Jason.Borough",
                new Integer(2013));
        student4.setId(new Long(13L));
        Section section1 = new Section("M3A");
        section1.setId(new Long(10L));
        Section section2 = new Section("T2B");
        section2.setId(new Long(11L));
        Instructor instructor1 = new Instructor("Sam", "Pierce", "Sam.Pierce");
        instructor1.setDomainAccount(instructor1.getWebID());
        instructor1.setId(new Long(14L));
        Instructor instructor2 = new Instructor("Jenny", "Conners", "Jenny.Conners");
        instructor2.setDomainAccount(instructor2.getWebID());
        instructor2.setId(new Long(15L));

        // Set the Instructors for Sections 1 & 2
        section1.setInstructor(instructor1);
        section2.setInstructor(instructor2);
        section1.setCourse(course);
        section2.setCourse(course);

        // Add Instructors to Course
        course.addInstructor(instructor1);
        course.addInstructor(instructor2);

        // Add Students 1 & 2 to Section 1
        section1.addStudent(student1);
        student1.addSection(section1);
        section1.addStudent(student2);
        student2.addSection(section1);

        // Add Students 3 & 4 to Section 2
        section2.addStudent(student3);
        student3.addSection(section2);
        section2.addStudent(student4);
        student4.addSection(section2);

        // Add Sections 1 & 2 to Course
        course.addSection(section1);
        course.addSection(section2);
View Full Code Here

    private Course createTestCourseNullId()
    {
        Course course = new Course("CS256");
       
        // Create 2 Sections, 2 Students per Section, and 2 Instructors
        Student student1 = new Student("Jerry", "Baker", "C14Jerry.Baker",
                new Integer(2013));
        student1.setId(new Long(10L));
        Student student2 = new Student("Lisa", "Thompson", "C14Lisa.Thompson",
                new Integer(2013));
        student2.setId(new Long(11L));
        Student student3 = new Student("Kelly", "Rogers", "C14Kelly.Rogers",
                new Integer(2013));
        student3.setId(new Long(12L));
        Student student4 = new Student("Jason", "Borough", "C14Jason.Borough",
                new Integer(2013));
        student4.setId(new Long(13L));
        Section section1 = new Section("M3A");
        section1.setId(new Long(10L));
        Section section2 = new Section("T2B");
        section2.setId(new Long(11L));
        Instructor instructor1 = new Instructor("Sam", "Pierce", "Sam.Pierce");
        instructor1.setDomainAccount(instructor1.getWebID());
        instructor1.setId(new Long(14L));
        Instructor instructor2 = new Instructor("Jenny", "Conners", "Jenny.Conners");
        instructor2.setDomainAccount(instructor2.getWebID());
        instructor2.setId(new Long(15L));

        // Set the Instructors for Sections 1 & 2
        section1.setInstructor(instructor1);
        section2.setInstructor(instructor2);
        section1.setCourse(course);
        section2.setCourse(course);

        // Add Instructors to Course
        course.addInstructor(instructor1);
        course.addInstructor(instructor2);

        // Add Students 1 & 2 to Section 1
        section1.addStudent(student1);
        student1.addSection(section1);
        section1.addStudent(student2);
        student2.addSection(section1);

        // Add Students 3 & 4 to Section 2
        section2.addStudent(student3);
        student3.addSection(section2);
        section2.addStudent(student4);
        student4.addSection(section2);

        // Add Sections 1 & 2 to Course
        course.addSection(section1);
        course.addSection(section2);
View Full Code Here

    {
        Course course = new Course("CS110");
        course.setId(1L);

        // Create 2 Sections, 2 Students per Section, and 2 Instructors
        Student student1 = new Student("John", "Doe", "C13John.Doe",
                new Integer(2013));
        student1.setId(new Long(1L));
        Student student2 = new Student("Mary", "Johnson", "C13Mary.Johnson",
                new Integer(2013));
        student2.setId(new Long(2L));
        Student student3 = new Student("Bob", "Reimer", "C13Robert.Reimer",
                new Integer(2013));
        student3.setId(new Long(3L));
        Student student4 = new Student("Andrew", "Callow", "C13Andrew.Callow",
                new Integer(2013));
        student4.setId(new Long(4L));

        Section section1 = new Section("M1A");
        section1.setId(new Long(1L));
        Section section2 = new Section("M2B");
        section2.setId(new Long(2L));
        section1.setCourse(course);
        section2.setCourse(course);

        Instructor instructor1 = new Instructor("David", "Roberts", "David.Roberts");
        instructor1.setId(new Long(5L));
        Instructor instructor2 = new Instructor("Sarah", "O'Reilly", "Sarah.OReilly");
        instructor2.setId(new Long(6L));

        // Set the Instructors for Sections 1 & 2
        section1.setInstructor(instructor1);
        section2.setInstructor(instructor2);

        // Add Instructors to Course
        course.addInstructor(instructor1);
        course.addInstructor(instructor2);

        // Add Students 1 & 2 to Section 1
        section1.addStudent(student1);
        student1.addSection(section1);
        section1.addStudent(student2);
        student2.addSection(section1);

        course.addSection(section1);
        course.addSection(section2);

        // Add Students 3 & 4 to Section 2
        section2.addStudent(student3);
        student3.addSection(section2);
        section2.addStudent(student4);
        student4.addSection(section2);

        return course;
    }
View Full Code Here

                Section section = em.find(Section.class, selectSectionDialog.getSection().getId());
                LOGGER.debug("New Section: " + section.getName());
                Section selectedSection = (Section) lstSections.getSelectedValue();
                Section oldSection = em.find(Section.class, selectedSection.getId());
                LOGGER.debug("Old Section: " + oldSection.getName());
                Student selectedStudent = (Student) lstStudents.getSelectedValue();
                Student student = em.find(Student.class, selectedStudent.getId());
                LOGGER.debug("Removing from old Section: " + oldSection);
                try
                {
                    student.removeFromSection(oldSection);
                } catch (NullPointerException ex)
                {
                    LOGGER.error("NullPointException: " + ex.getLocalizedMessage());
                } catch (IllegalArgumentException ex)
                {
                    LOGGER.error("IllegalArgumentException: " + ex.getLocalizedMessage());
                }

                LOGGER.debug("Adding to new Section: " + section);
                student.addSection(section);
                oldSection.removeStudent(student);
                section.addStudent(student);
                EntityTransaction tx = em.getTransaction();
                try
                {
View Full Code Here

    public void removeStudentFromCourse()
    {
        if (lstStudents.getSelectedIndex() >= 0)
        {
            LOGGER.info("Removing selected Student from Course");
            Student selectedStudent = (Student) lstStudents.getSelectedValue();
            Section selectedSection = (Section) lstSections.getSelectedValue();
            EntityManager em = emf.createEntityManager();
            Student student = em.find(Student.class, selectedStudent.getId());
            Section section = em.find(Section.class, selectedSection.getId());
            LOGGER.info("Removing " + student.getLastName() + ", "
                    + student.getFirstName() + " (" + student.getClassYear()
                    + ") from Section " + section.getName());
            student.removeFromSection(section);
            section.removeStudent(student);
            EntityTransaction tx = em.getTransaction();
            tx.begin();
            em.merge(section);
            em.merge(student);
View Full Code Here

TOP

Related Classes of com.darkhonor.rage.model.Student

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.