Package com.darkhonor.rage.libs.dataaccess

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


                        {
                            LOGGER.debug("Question not in database.  Inserting "
                                    + "new question");

                            // Need to persist each of the test cases before the question
                            TestCaseDAO testCaseDAO = new TestCaseDAO(emf.createEntityManager());
                            for (TestCase tc : question.getTestCases())
                            {
                                if (tc.getId() != null)
                                {
                                    try
                                    {
                                        TestCase dbTestCase = testCaseDAO.find(tc.getId());
                                        // TestCase exists in the database, update
                                        tc = testCaseDAO.update(tc);
                                    } catch (IllegalArgumentException exTestCase)
                                    {
                                        // TestCase not in data source, just save
                                        Long newId = testCaseDAO.create(tc);
                                    }
                                } else
                                {
                                    // New TestCase with no Id
                                    Long newId = testCaseDAO.create(tc);
                                    tc.setId(newId);
                                }
//                                tx.begin();
//                                tc.setId(null); // Reset the TestCase Id for persisting
//                                LOGGER.debug("Inputs / Outputs: " + tc.getInputs().size()
//                                        + " / " + tc.getOutputs().size());
//                                em.persist(tc);
//                                tx.commit();
                            }
                            testCaseDAO.closeConnection();
                            // Can persist the question now that all components are saved
                            // TODO: RAGE-24 - Migrate to the QuestionDAO class
                            tx.begin();
                            em.persist(question);
                            tx.commit();
View Full Code Here

TOP

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

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.