Package au.edu.qut.yawl.exceptions

Examples of au.edu.qut.yawl.exceptions.YPersistenceException


        */
        String query = "from HumanResourceRole as hresrole where hresrole.HumanResource = '" + resourceID + "'";
        doPersistAction(query, DELETE_OPERATION);

        if (resource == null) {
            throw new YPersistenceException(binaryRelationFKMissingMsg.format(new String[]{"resource", resourceID, "role"}));
        }
        /*
          We are adding multiple roles
        */
        StringTokenizer roles = new StringTokenizer(selectrole, "$");
        while (roles.hasMoreTokens()) {

            Role role = getRole(roles.nextToken());
            if (role == null) {
                throw new YPersistenceException(binaryRelationFKMissingMsg.format(new String[]{"role", selectrole, "resource"}));
            }
            HumanResourceRole hResRole = new HumanResourceRole();
            hResRole.setHumanResource(resource);
            hResRole.setRole(role);

View Full Code Here


            */
            String query = "from HumanResourceRole as hresrole where hresrole.Role = '" + roleID + "'";
            doPersistAction(query, DELETE_OPERATION);

            if (role == null) {
                throw new YPersistenceException(
                        binaryRelationFKMissingMsg.format(new String[]{"resource", roleID, "role"}));
            }
            /*
              We are adding multiple humans
            */
            StringTokenizer humans = new StringTokenizer(selecthuman, "$");
            while (humans.hasMoreTokens()) {

                Resource resource = getResource(humans.nextToken());
                if (humans == null) {
                    throw new YPersistenceException(
                            binaryRelationFKMissingMsg.format(new String[]{"role", selecthuman, "resource"}));
                }
                HumanResourceRole hResRole = new HumanResourceRole();
                hResRole.setHumanResource(resource);
                hResRole.setRole(role);
View Full Code Here

            session.flush();
            session.evict(obj);
            tx.commit();
            session.close();
        } catch (HibernateException e) {
            throw new YPersistenceException("Hibernate problem: " + e.getMessage(), e);
        }
    }
View Full Code Here

        try {
            session = getFactory().openSession();
            transaction = session.beginTransaction();
        } catch (HibernateException e) {
            logger.fatal("Failure to start transactional session", e);
            throw new YPersistenceException("Failure to start transactional session", e);
        }
    }
View Full Code Here

                Enumeration enumeration = objectsToDelete.keys();

                while (enumeration.hasMoreElements()) {
                    String key = (String) enumeration.nextElement();
                    if (objectsToStore.containsKey(key)) {
                        throw new YPersistenceException("Object with key [" + key + "] present in both Delete and Insert cache");
                    }
                    if (objectsToUpdate.containsKey(key)) {
                        throw new YPersistenceException("Object with key [" + key + "] present in both Delete and Update cache");
                    }
                }
            }

            // Check for insert and updates
            {
                Enumeration enumeration = objectsToUpdate.keys();

                while (enumeration.hasMoreElements()) {
                    String key = (String) enumeration.nextElement();
                    if (objectsToStore.containsKey(key)) {
                        objectsToStore.put(key, objectsToUpdate.get(key));
                        objectsToUpdate.remove(key);
                    }
                }
            }

            if (logger.isDebugEnabled()) {
                logger.debug("POST DUPLICATE CHECK");
                dump();
            }
        }

        try
        {
            if (LAZY_UPDATES)
            {
                // Action object deletions
                {
                    Enumeration enumeration = objectsToDelete.elements();
                    while (enumeration.hasMoreElements()) {
                        removeData(enumeration.nextElement());
                    }
                }

                // Action object insertions - Note that we MUST insert the identifers first to cater for database RI rules
                {
                    {
                        Enumeration enumeration = objectsToStore.elements();
                        while (enumeration.hasMoreElements()) {
                            Object obj = enumeration.nextElement();
                            if (obj instanceof P_YIdentifier) {
                                storeData(obj);
                            }
                        }
                    }
                    {
                        Enumeration enumeration = objectsToStore.elements();
                        while (enumeration.hasMoreElements()) {
                            Object obj = enumeration.nextElement();
                            if (obj instanceof P_YIdentifier) {
                                // Null action
                            } else {
                                storeData(obj);
                            }
                        }

                    }
                }

                // Action object updates
                {
                    Enumeration enumeration = objectsToUpdate.elements();
                    while (enumeration.hasMoreElements()) {
                        updateData(enumeration.nextElement());
                    }
                }
            }

            // Commit
            getTransaction().commit();
           
        } catch (Exception e1) {
            logger.fatal("Failure to commit transactional session - Rolling Back Transaction", e1);

            try {
                getTransaction().rollback();
            } catch (Exception e2) {
                throw new YPersistenceException("Failure to rollback transactional session", e2);
            }
            throw new YPersistenceException("Failure to commit transactional session", e1);
        } finally {
            transaction = null;
            if (getSession() != null) {
                try {
                    getSession().close();
View Full Code Here

            // Nothing to do ???
        } else {
            try {
                getTransaction().rollback();
            } catch (HibernateException e) {
                throw new YPersistenceException("Failure to rollback transaction", e);
            } finally {
                transaction = null;
                if (getSession() != null) {
                    try {
                        getSession().close();
View Full Code Here

        try {
            getSession().delete(obj);
        } catch (HibernateException e) {
            logger.error("Failure whilst removing persisted data", e);
            throw new YPersistenceException("Failure whilst removing persisted data", e);
        }
        logger.debug("<-- removeData");
    }
View Full Code Here

        Query query = null;

        try {
            query = getSession().createQuery(queryString);
        } catch (HibernateException e) {
            throw new YPersistenceException("Failure to create Hibernate query object", e);
        }

        return query;
    }
View Full Code Here

                try {
                    con = session.connection();
                } catch (Exception e) {
                    String msg = "Failure to establish connection to persistance database";
                    Logger.getLogger(loggerName).fatal(msg, e);
                    throw new YPersistenceException(msg, e);
                }

                //AJH: Validate database connection by Selecting some data
                //todo Need a better database validation mechanism here
                Statement st = null;
                ResultSet rs = null;
                try {
                    tx = session.beginTransaction();
                    st = session.connection().createStatement();
                    rs = st.executeQuery("select * from specs");
                    tx.commit();
                } catch (Exception e) {
                    if (tx != null) {
                        tx.rollback();
                    }
                    Logger.getLogger(loggerName).warn("Database does not appear to exist - Attempting to create new database ...");
                    new SchemaUpdate(cfg).execute(false, true);
                    HumanResourceRole.addIntegrityEnforcements(session);

                } finally {
                    session.close();
                }

            } catch (Exception e) {
                e.printStackTrace();
                Logger.getLogger(loggerName).fatal("Failure initialising persistence layer", e);
                throw new YPersistenceException("Failure initialising persistence layer", e);
            }
        }
        // Finally, return the session factory
        return factory;
    }
View Full Code Here

            objectType = PT_USER;
            User obj2 = (User) obj;
            key = obj2.getUserID();
        } else {
            logger.error("Unknown object type [" + obj.getClass().getName() + "]");
            throw new YPersistenceException("Unknown object type [" + obj.getClass().getName() + "]");
        }

        return key;
    }
View Full Code Here

TOP

Related Classes of au.edu.qut.yawl.exceptions.YPersistenceException

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.