Package com.darkhonor.rage.libs.dataaccess

Examples of com.darkhonor.rage.libs.dataaccess.InstructorDAO


                LOGGER.debug("Grading all sections for Instructor "
                        + selectedInstructor.getLastName() + ", "
                        + selectedInstructor.getFirstName());

                // Pull the Instructor from the Data Source to be able to grab Sections
                InstructorDAO instructorDAO = new InstructorDAO(emf.createEntityManager());
                Instructor instructor = instructorDAO.find(selectedInstructor.getId());
                for (Section sectionIter : instructor.getSections())
                {
                    sectionReport = new SectionReport(course.getName(),
                            instructor, sectionIter.getName(),
                            selectedAssignment.getAssignment());
                    try
                    {
                        outputFile = new File(path + File.separator
                                + sectionIter.getName() + File.separator
                                + sectionIter.getName() + dateStampString + ".html");
                        LOGGER.debug("Output File: " + outputFile.getCanonicalPath());
                        outputFile.createNewFile();
                    } catch (IOException ex)
                    {
                        LOGGER.error("IOException caught: "
                                + ex.getLocalizedMessage());
                    }
                    /**
                     * If a section is selected and there are multiple versions,
                     * pull the right one for the gevent variable...can we
                     * search the list and return the right one?
                     */
                    if (multVersions)
                    {
                        /**
                         * If there are multiple versions of the GradedEvent,
                         * pull only the one for this section
                         */
                        gevent = RageLib.getGradedEventFromSectionName(gevents,
                                sectionIter.getName());
                    }
                    // No else needed since if there are no multiple versions,
                    // gevent is already set above

                    for (Student studentIter : sectionIter.getStudents())
                    {
//                        StudentReport studentReport = new StudentReport(studentIter);
                        StudentReport studentReport = new StudentReport(studentIter,
                                sectionIter);
                        String newPath = new String();
                        newPath = path.concat(File.separator);
                        newPath = newPath.concat(sectionIter.getName());
                        newPath = newPath.concat(File.separator);
                        newPath = newPath.concat(studentIter.getWebID());
                        LOGGER.debug("Path to grade: " + newPath);
                        statusMessageLabel.setText("Grading: " + studentIter.getLastName()
                                + ", " + studentIter.getFirstName());
                        LOGGER.info("Grading: " + studentIter.getLastName()
                                + ", " + studentIter.getFirstName());
                        File directory = new File(newPath);
                        launcher.directory(directory);
                        Runnable r = new GraderThread(node, launcher, directory,
                                gevent, studentReport, type);
                        grader_thread = new Thread(r);
                        grader_thread.start();
                        while (grader_thread.isAlive())
                        {
                        }
                        sectionReport.addStudentReport(studentReport);
                    }
                    sectionReport.sortStudentReports();
                    RageLib.printSectionReport(outputFile, sectionReport);
                }
                // Close the connection to the Data Source
                instructorDAO.closeConnection();
            } /**
             * Grade all students in a single section
             */
            else if ((cboStudent.getSelectedIndex() == 0)
                    && (cboSection.getSelectedIndex() > 0))
View Full Code Here


                //query.setParameter("fname", name[1].trim());
                //query.setParameter("lname", name[0].trim());
                // Don't need to check for non-existent since cboInstructor was populated
                // from the database...have bigger problems if instructor is not there now
                //ins = (Instructor)query.getSingleResult();
                InstructorDAO instructorDAO = new InstructorDAO(emf.createEntityManager());
                instructor = instructorDAO.find(selectedInstructor.getId());
                //instructor = em.find(Instructor.class, selectedInstructor.getId());
                path = path.concat(instructor.getWebID());

                // Add the section if one is selected
                if (cboSection.getSelectedIndex() > 0)
                {
                    SectionDAO sectionDAO = new SectionDAO(emf.createEntityManager());
                    section = sectionDAO.find(selectedSection.getId());
                    //section = em.find(Section.class, selectedSection.getId());
                    //for (Section s : instructor.getSections())
                    //{
                    //    if (s.getName().equals(cboSection.getSelectedItem()))
                    //    {
                    //        sect = s;
                    //    }
                    //}
                    path = path.concat(File.separator);
                    path = path.concat(section.getName());

                    // Add the Student if one is selected
                    if (cboStudent.getSelectedIndex() > 0)
                    {
                        path = path.concat(File.separator);
                        name = cboStudent.getSelectedItem().toString().split(",");
                        query = em.createQuery("SELECT p FROM Person p WHERE "
                                + "p.firstName = :fname AND p.lastName = :lname");
                        query.setParameter("fname", name[1].trim());
                        query.setParameter("lname", name[0].trim());
                        student = (Student) query.getSingleResult();
                        path = path.concat(student.getWebID());
                    }
                    sectionDAO.closeConnection();
                }
                instructorDAO.closeConnection();
            }
            // Figure out what is selected based on the path info above
            if ((cboInstructor.getSelectedIndex() == 0) && (cboSection.getSelectedIndex() < 0))
            {  // Assignment and All Instructors is selected, no section or student
                // selected
View Full Code Here

            LOGGER.debug("(connectAction) Validating connection authorization");
            String userName = System.getProperty("user.name");
            LOGGER.debug("(connectAction) Finding Instructor from userid: "
                    + userName);
            InstructorDAO instructorDAO = null;
            try
            {
                instructorDAO = new InstructorDAO(emf.createEntityManager());
                Instructor instructor =
                        instructorDAO.findInstructorByDomainAccount(userName);
                LOGGER.debug("(connectAction) Instructor found.");
                if (node.getBoolean("UsePassword", true))
                {
                    // TODO: Add Password option
                    // Prompt the user for a password and check the response with what
                    // is now stored in appUser.password.  If it's ok, move on.  Otherwise
                    // exit the program with an error message stating the user is not
                    // authorized.  Perhaps give them a couple of tries.
                }
                statusMessageLabel.setText("Welcome " + instructor.getFirstName()
                        + " " + instructor.getLastName());
                LOGGER.debug("(connectAction) Closing InstructorDAO connection");
                instructorDAO.closeConnection();
            } catch (NoResultException ex)
            {
                LOGGER.error("(connectAction) Instructor not found in the data "
                        + "source");
                JOptionPane.showMessageDialog(CourseGraderApp.getApplication()
                        .getMainFrame(), "Instructor " + userName + " not found "
                        + "in the database.  Exiting CourseGrader.", "Error",
                        JOptionPane.ERROR_MESSAGE);
                instructorDAO.closeConnection();
                this.exitApplication();
            } catch (IllegalStateException ex)
            {
                LOGGER.warn("(connectAction) Problem connecting to the database "
                        + "with the InstructorDAO object");
View Full Code Here

TOP

Related Classes of com.darkhonor.rage.libs.dataaccess.InstructorDAO

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.