Package com.darkhonor.rage.model

Examples of com.darkhonor.rage.model.Section


    }

    private Section createPersistedSection(Long id, Course course, String name)
    {
        EntityManager em = emf.createEntityManager();
        Section section = null;

        try
        {
            section = findSectionById(id);
            LOGGER.warn("Section already in database: " + section);
        } catch (NoResultException ex)
        {
            section = new Section(name);
            section.setId(id);
            Course dbCourse = em.find(Course.class, course.getId());
            section.setCourse(dbCourse);
            dbCourse.addSection(section);
            EntityTransaction tx = em.getTransaction();
            tx.begin();
            em.persist(section);
            em.merge(dbCourse);
View Full Code Here


    }

    private Section findSectionById(Long id) throws NoResultException
    {
        EntityManager em = emf.createEntityManager();
        Section section = em.find(Section.class, id);
        if (section == null)
            throw new NoResultException();
        em.close();
        return section;
    }
View Full Code Here

    private void persistSectionInstructor(Section section, Instructor instructor)
    {
        EntityManager em = emf.createEntityManager();
        EntityTransaction tx = em.getTransaction();
        Section dbSection = em.find(Section.class, section.getId());
        Course dbCourse = em.find(Course.class, section.getCourse().getId());
        Instructor dbInstructor = em.find(Instructor.class, instructor.getId());
        dbSection.setInstructor(dbInstructor);
        dbInstructor.addSection(dbSection);
        if (dbCourse.getInstructors().contains(dbInstructor))
        {
            LOGGER.warn("Instructor already in the course");
        } else
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();
View Full Code Here

        assertEquals("Sarah.OReilly", ins2.getDomainAccount());
        assertNotNull(result.getSections());
        assertEquals(2, result.getSections().size());
        for (int i = 0; i < result.getSections().size(); i++)
        {
            Section section = result.getSection(i);
            System.out.println("- Section: " + section + ", Id: " + section.getId());
        }
        assertTrue(result.getSection(0).getName().equals("M1A") ||
                result.getSection(0).getName().equals("M2B"));
        assertTrue(result.getSection(1).getName().equals("M1A") ||
                result.getSection(1).getName().equals("M2B"));
View Full Code Here

        assertEquals("Sarah.OReilly", ins2.getDomainAccount());
        assertNotNull(result.getSections());
        assertEquals(2, result.getSections().size());
        for (int i = 0; i < result.getSections().size(); i++)
        {
            Section section = result.getSection(i);
            System.out.println("- Section: " + section + ", Id: " + section.getId());
        }
        assertTrue(result.getSection(0).getName().equals("M1A") ||
                result.getSection(0).getName().equals("M2B"));
        assertTrue(result.getSection(1).getName().equals("M1A") ||
                result.getSection(1).getName().equals("M2B"));
View Full Code Here

        assertEquals("Sarah.OReilly", ins2.getDomainAccount());
        assertNotNull(result.getSections());
        assertEquals(2, result.getSections().size());
        for (int i = 0; i < result.getSections().size(); i++)
        {
            Section section = result.getSection(i);
            System.out.println("- Section: " + section + ", Id: " + section.getId());
        }
        assertTrue(result.getSection(0).getName().equals("M1A") ||
                result.getSection(0).getName().equals("M2B"));
        assertTrue(result.getSection(1).getName().equals("M1A") ||
                result.getSection(1).getName().equals("M2B"));
View Full Code Here

        assertEquals("David.Roberts", ins1.getDomainAccount());
        assertNotNull(result.getSections());
        assertEquals(2, result.getSections().size());
        for (int i = 0; i < result.getSections().size(); i++)
        {
            Section section = result.getSection(i);
            System.out.println("- Section: " + section + ", Id: " + section.getId());
        }
        assertTrue(result.getSection(0).getName().equals("M1A") ||
                result.getSection(0).getName().equals("M2B"));
        assertTrue(result.getSection(1).getName().equals("M1A") ||
                result.getSection(1).getName().equals("M2B"));
View Full Code Here

        assertEquals("John.Smith", ins3.getDomainAccount());
        assertNotNull(result.getSections());
        assertEquals(2, result.getSections().size());
        for (int i = 0; i < result.getSections().size(); i++)
        {
            Section section = result.getSection(i);
            System.out.println("- Section: " + section + ", Id: " + section.getId());
        }
        assertTrue(result.getSection(0).getName().equals("M1A") ||
                result.getSection(0).getName().equals("M2B"));
        assertTrue(result.getSection(1).getName().equals("M1A") ||
                result.getSection(1).getName().equals("M2B"));
View Full Code Here

        assertEquals(0, result.getInstructors().size());
        assertNotNull(result.getSections());
        assertEquals(2, result.getSections().size());
        for (int i = 0; i < result.getSections().size(); i++)
        {
            Section section = result.getSection(i);
            System.out.println("- Section: " + section + ", Id: " + section.getId());
        }
        assertTrue(result.getSection(0).getName().equals("M1A") ||
                result.getSection(0).getName().equals("M2B"));
        assertTrue(result.getSection(1).getName().equals("M1A") ||
                result.getSection(1).getName().equals("M2B"));
View Full Code Here

TOP

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

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.