Package com.darkhonor.rage.libs.dataaccess

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


                        //cq = cb.createQuery(Category.class);
                        //Root<Category> categoryRoot = cq.from(Category.class);
                        //cq.where(cb.equal(categoryRoot.get("name"),
                        //      txtCategory.getText().trim()));
                        //TypedQuery<Category> categoryQuery = em.createQuery(cq);
                        CategoryDAO catDAO = new CategoryDAO(emf.createEntityManager());
                        Category queryCat;
                        try
                        {
                            //queryCat = categoryQuery.getSingleResult();
                            queryCat = catDAO.find(txtCategory.getText().trim());
                            LOGGER.info("Category already exists in database: "
                                    + queryCat.getName());
                        } catch (NoResultException ex)
                        {
                            queryCat = new Category(txtCategory.getText().trim());
                            //tx.begin();
                            //em.persist(queryCat);
                            //tx.commit();
                            Long newCatId = catDAO.create(queryCat);
                            queryCat.setId(newCatId);
                            LOGGER.info("Added Category: " + queryCat.getName());
                        }
                        question.setCategory(queryCat);
                        if (catDAO.isOpen())
                        {
                            catDAO.closeConnection();
                        }
                       
                        // TODO: RAGE-24 - Migrate to the QuestionDAO class
                        cq = cb.createQuery(Question.class);
                        questionRoot = cq.from(Question.class);
View Full Code Here


                    Node q = nodes.item(i);
                    String qname = xpath.evaluate("./Name/@name", q);
                    String qcategory = xpath.evaluate("./@category", q);
                   
                    // Swap for CategoryDAO interface
                    CategoryDAO catDAO = new CategoryDAO(em);
                   
                    //query = em.createQuery("SELECT c FROM Category c WHERE "
                    //        + "c.name = :cname");
                    //query.setParameter("cname", qcategory);
                    Category qcat;
                    try
                    {
                        //qcat = (Category) query.getSingleResult();
                        qcat = catDAO.find(qcategory);
                    } catch (NoResultException e)
                    {
                        qcat = new Category(qcategory);
                        Long newCatId = catDAO.create(qcat);
                        qcat.setId(newCatId);
                    }
                    //tx.begin();
                    //em.persist(qcat);
                    //tx.commit();
                    qcat = catDAO.update(qcat);
                   
                    query = em.createQuery("SELECT q FROM Question q WHERE "
                            + "q.name = :name AND q.category = :cat");
                    query.setParameter("name", qname);
                    query.setParameter("cat", qcat);
View Full Code Here

                Node q = nodes.item(i);
                String qname = xpath.evaluate("./Name/@name", q);
                String qcategory = xpath.evaluate("./@category", q);
               
                // Switch to the CategoryDAO class
                CategoryDAO catDAO = new CategoryDAO(em);
                //query = em.createQuery("SELECT c FROM Category c WHERE c.name = :cname");
                //query.setParameter("cname", qcategory);
                Category qcat;
                try
                {
                    //qcat = (Category) query.getSingleResult();
                    qcat = catDAO.find(qcategory);
                } catch (NoResultException e)
                {
                    qcat = new Category(qcategory);
                    Long newCatId = catDAO.create(qcat);
                    qcat.setId(newCatId);
                }
                //tx.begin();
                //em.persist(qcat);
                //tx.commit();
                qcat = catDAO.update(qcat);
                query = em.createQuery("SELECT q FROM Question q WHERE "
                        + "q.name = :name AND q.category = :cat");
                query.setParameter("name", qname);
                query.setParameter("cat", qcat);
                try
View Full Code Here

TOP

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

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.