Package com.darkhonor.rage.model

Examples of com.darkhonor.rage.model.GradedEvent


            selectQuestionDialog.setModalityType(ModalityType.APPLICATION_MODAL);
            selectQuestionDialog.setVisible(true);
            if (selectQuestionDialog.getReturnStatus() == SelectQuestionDialog.RET_OK)
            {
                LOGGER.debug("Updating list of questions for the GradedEvent");
                GradedEvent gradedEvent = (GradedEvent) lstGradedEvents.getSelectedValue();
                //EntityManager em = emf.createEntityManager();
                //EntityTransaction tx = em.getTransaction();
                LOGGER.debug("Merging GradedEvent with Persistence Context");
                GradedEventDAO gradedEventDAO = new GradedEventDAO(emf.createEntityManager());
                //tx.begin();
                //gradedEvent = em.find(GradedEvent.class, gradedEvent.getId());
                //tx.commit();
                gradedEvent = gradedEventDAO.find(gradedEvent.getId());
                LOGGER.debug("Adding " + gradedEvent.getQuestions().size()
                        + " Questions to GradedEvent Question List Model");
                int actual = 0;
                modGradedEventQuestions.removeAll();
                for (int i = 0; i < gradedEvent.getQuestions().size(); i++)
                {
                    modGradedEventQuestions.add(gradedEvent.getQuestions().get(i));
                    actual++;
                }
                LOGGER.debug("Added " + actual + " Questions to List Model");
                // Update the Graded Event List Model
                modGradedEvents.update(gradedEvent);
View Full Code Here


    private void btnRemoveGradedEventActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoveGradedEventActionPerformed
        // Remove GradedEvent from the database
        if (emf != null && emf.isOpen() && lstGradedEvents.getSelectedIndex() >= 0)
        {
            //EntityManager em = emf.createEntityManager();
            GradedEvent selectedEvent = (GradedEvent) lstGradedEvents.getSelectedValue();
            GradedEventDAO gradedEventDAO = new GradedEventDAO(emf.createEntityManager());
            //GradedEvent gradedEvent = em.find(GradedEvent.class, selectedEvent.getId());
            GradedEvent gradedEvent = gradedEventDAO.find(selectedEvent.getId());
            gradedEvent.clearQuestions();
            //EntityTransaction tx = em.getTransaction();
            //tx.begin();
            gradedEvent = gradedEventDAO.update(gradedEvent);
            //gradedEvent = em.merge(gradedEvent);
            gradedEventDAO.delete(gradedEvent.getId());
            //em.remove(gradedEvent);
            //tx.commit();
            //em.close();
            gradedEventDAO.closeConnection();
        }
View Full Code Here

            LOGGER.error("Not all required fields completed.  Please verify all fields"
                    + " have been completed.");
        } else
        {
            LOGGER.debug("All fields complete");
            GradedEvent gradedEvent = null;
            EntityManager em = emf.createEntityManager();
            LOGGER.debug("Getting selected Course");
            CourseDAO courseDAO = new CourseDAO(emf.createEntityManager());
            Course selectedCourse = (Course) cboCourse.getSelectedItem();
            Course course = courseDAO.find(selectedCourse.getId());
            //Course course = em.find(Course.class, selectedCourse.getId());
            LOGGER.debug("Course Name: " + course.getName());

            LOGGER.debug("Querying the data source to see if a GradedEvent "
                    + "already exists");
            GradedEventDAO gradedEventDAO =
                    new GradedEventDAO(emf.createEntityManager());
//            CriteriaBuilder cb = em.getCriteriaBuilder();
//            CriteriaQuery cq = cb.createQuery(GradedEvent.class);
//            Root<GradedEvent> gradedEventRoot = cq.from(GradedEvent.class);
//            cq.where(cb.and(cb.equal(gradedEventRoot.get("assignment"), txtAssignment.getText().trim()),
//                    cb.equal(gradedEventRoot.get("term"), txtTerm.getText().trim()),
//                    cb.equal(gradedEventRoot.get("course"), course),
//                    cb.equal(gradedEventRoot.get("version"), txtVersion.getText().trim())));
//
//            TypedQuery<GradedEvent> gradedEventQuery = em.createQuery(cq);
//            LOGGER.debug("Query built");
            try
            {
                //gradedEvent = gradedEventQuery.getSingleResult();
                gradedEvent = gradedEventDAO.find(course,
                        txtAssignment.getText().trim(), txtTerm.getText().trim(),
                        txtVersion.getText().trim());
            } catch (IllegalArgumentException ex)
            {
                // Because of the check at the beginning of this method, we should
                // never reach this point.  But just in case...
                LOGGER.warn("Invalid value provided.  Ensure Course, Term, "
                        + "Assignment, and Version are not blank.");
            }
            if (gradedEvent != null)
            {
                JOptionPane.showMessageDialog(this, "ERROR: This Graded "
                        + "Event already exists in the system.", "ERROR",
                        JOptionPane.ERROR_MESSAGE);
                LOGGER.error("This GradedEvent already exists in the database");
                doClose(RET_CANCEL);
            } else
            {
                LOGGER.debug("Creating a new GradedEvent");
                EntityTransaction tx = em.getTransaction();
                gradedEvent = new GradedEvent();
                gradedEvent.setCourse(course);
                gradedEvent.setAssignment(txtAssignment.getText().trim());
                gradedEvent.setTerm(txtTerm.getText().trim());
                gradedEvent.setVersion(txtVersion.getText().trim());
                gradedEvent.setPartialCredit(chkPartialCredit.isSelected());
                try
                {
                    gradedEvent.setDueDate(txtDueDate.getText().trim());
                } catch (IllegalArgumentException ex)
                {
                    LOGGER.warn("Invalid Date Specified.  No Due Date Set");
                }
                LOGGER.debug("Graded Event: " + gradedEvent.toString());
                List<Question> objects = lstQuestions.getSelectedValuesList();
                LOGGER.debug("Adding " + objects.size() + " Questions to GradedEvent");
                int count = 0;
                for (int i = 0; i < objects.size(); i++)
                {
                    // TODO: RAGE-24 - Migrate to the QuestionDAO class. 
                    // Action: Update the Question in the current Persistence Context
                    Question question = objects.get(i);
                    try
                    {
                        question = em.merge(question);
                    } catch (Exception ex)
                    {
                        LOGGER.error("Exception: " + ex.getLocalizedMessage());
                        tx.rollback();
                    }
                    gradedEvent.addQuestion(question);
                    count++;
                }
                LOGGER.debug(count + " Questions added.  Saving to database");
                Long newId;
                try
View Full Code Here

        Course course = courseDAO.find(2L);

        CategoryDAO categoryDAO = new CategoryDAO(testDb.getConnection());
        Category category = categoryDAO.find(2L);

        GradedEvent gradedEvent = instance.find(new Long(3L));
        GradedEvent event = new GradedEvent();
        event.setId(gradedEvent.getId());
        event.setCourse(course);
        event.setAssignment("PEX3");
        event.setDueDate("19 May 2010");
        event.setPartialCredit(false);
        event.setTerm("Fall 2010");

        Question newQuestion = new Question(42L, "TestQ", category,
                "This is a new test question");

        for (int i = 0; i < gradedEvent.getQuestions().size(); i++)
        {
            event.addQuestion(gradedEvent.getQuestions().get(i));
        }

        event.addQuestion(newQuestion);

        // Make sure the updated GradedEvent is returned from the method
        GradedEvent result = instance.update(event);
    }
View Full Code Here

        Course course = courseDAO.find(2L);

        CategoryDAO categoryDAO = new CategoryDAO(testDb.getConnection());
        Category category = categoryDAO.find(2L);

        GradedEvent gradedEvent = instance.find(new Long(3L));
        GradedEvent event = new GradedEvent();
        event.setId(new Long(42L));
        event.setCourse(course);
        event.setAssignment("PEX3");
        event.setDueDate("19 May 2010");
        event.setPartialCredit(false);
        event.setTerm("Fall 2010");
        event.setVersion("ALL");

        Question newQuestion = new Question(42L, "TestQ", category,
                "This is a new test question");

        for (int i = 0; i < gradedEvent.getQuestions().size(); i++)
        {
            event.addQuestion(gradedEvent.getQuestions().get(i));
        }

        event.addQuestion(newQuestion);

        // Make sure the updated GradedEvent is returned from the method
        GradedEvent result = instance.update(event);
    }
View Full Code Here

        Course course = courseDAO.find(2L);

        CategoryDAO categoryDAO = new CategoryDAO(testDb.getConnection());
        Category category = categoryDAO.find(2L);

        GradedEvent gradedEvent = instance.find(new Long(3L));
        GradedEvent event = new GradedEvent();
        event.setCourse(course);
        event.setAssignment("PEX3");
        event.setDueDate("19 May 2010");
        event.setPartialCredit(false);
        event.setTerm("Fall 2010");
        event.setVersion("ALL");

        Question newQuestion = new Question(42L, "TestQ", category,
                "This is a new test question");

        for (int i = 0; i < gradedEvent.getQuestions().size(); i++)
        {
            event.addQuestion(gradedEvent.getQuestions().get(i));
        }

        event.addQuestion(newQuestion);

        // Make sure the updated GradedEvent is returned from the method
        GradedEvent result = instance.update(event);
    }
View Full Code Here

    public void testRemoveQuestionFromGradedEvent()
    {
        System.out.println("removeQuestionFromGradedEvent");
        assertTrue(instance.isOpen());
       
        GradedEvent gradedEvent = instance.find(new Long(5L));
        assertEquals(2, gradedEvent.getQuestions().size());
       
        Question question = new Question();
        question.setId(new Long(1L));
        question.setName("Sequencer");
       
        instance.removeQuestionFromGradedEvent(gradedEvent, question);
       
        gradedEvent = instance.find(new Long(5L));
        assertEquals(1, gradedEvent.getQuestions().size());
       
        EntityManager em = testDb.getConnection();
       
        Question testQuestion = em.find(Question.class, new Long(1L));
        assertNotNull(testQuestion);
View Full Code Here

    public void testRemoveQuestionFromGradedEventNotFound()
    {
        System.out.println("removeQuestionFromGradedEvent - Question Not in DB");
        assertTrue(instance.isOpen());
       
        GradedEvent gradedEvent = instance.find(new Long(5L));
        assertEquals(2, gradedEvent.getQuestions().size());
       
        Question question = new Question();
        question.setId(new Long(123L));
        question.setName("Sequencer 2");
       
View Full Code Here

    public void testRemoveQuestionFromGradedEventNotInQuestion()
    {
        System.out.println("removeQuestionFromGradedEvent - Question Not in GE");
        assertTrue(instance.isOpen());
       
        GradedEvent gradedEvent = instance.find(new Long(5L));
        assertEquals(2, gradedEvent.getQuestions().size());
       
        Question question = new Question();
        question.setId(new Long(3L));
        question.setName("Jumper");
       
View Full Code Here

    public void testRemoveQuestionFromGradedEventNotIn()
    {
        System.out.println("removeQuestionFromGradedEvent - GradedEvent not in DB");
        assertTrue(instance.isOpen());
       
        GradedEvent gradedEvent = new GradedEvent();
        gradedEvent.setId(new Long(333L));
        gradedEvent.setAssignment("PEX Something");
        gradedEvent.setTerm("Summer 2011");
        gradedEvent.setVersion("ALL");
       
        Course course = new Course("CS110");
        course.setId(new Long(1L));
        gradedEvent.setCourse(course);
       
        Question question = new Question();
        question.setId(new Long(1L));
        question.setName("Sequencer");
       
View Full Code Here

TOP

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

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.