Examples of TransactionGuard


Examples of org.openbp.server.persistence.TransactionGuard

      {
        printError("Source and target model manager classes may not be identical.");
      }

      PersistenceContext pc = processor.getProcessServer().getEngine().getPersistenceContextProvider().obtainPersistenceContext();
      TransactionGuard tg = new TransactionGuard(pc);
      try
      {
        processor.perform();
      }
      catch (PersistenceException e)
      {
        tg.doCatch();
        throw e;
      }
      finally
      {
        tg.doFinally();
      }

      System.exit(0);
    }
    catch (Exception e)
View Full Code Here

Examples of org.openbp.server.persistence.TransactionGuard

  {
    // Create reference names for persistent storage
    model.maintainReferences(ModelObject.SYNC_GLOBAL_REFNAMES | ModelObject.SYNC_LOCAL_REFNAMES);

    PersistenceContext pc = getPersistenceContextProvider().obtainPersistenceContext();
    TransactionGuard tg = new TransactionGuard(pc);
    try
    {
      DbModel dbModel = (DbModel) pc.createEntity(DbModel.class);

      modelToDbModel(model, dbModel);

      pc.saveObject(dbModel);
    }
    catch (PersistenceException e)
    {
      tg.doCatch();
      throw new ModelException("DatabaseOperation", "Error saving descriptor of model '" + model.getQualifier() + "' to the database: "
        + e.getMessage(), e);
    }
    finally
    {
      tg.doFinally();
    }
  }
View Full Code Here

Examples of org.openbp.server.persistence.TransactionGuard

  {
    // Create reference names for persistent storage
    model.maintainReferences(ModelObject.SYNC_GLOBAL_REFNAMES | ModelObject.SYNC_LOCAL_REFNAMES);

    PersistenceContext pc = getPersistenceContextProvider().obtainPersistenceContext();
    TransactionGuard tg = new TransactionGuard(pc);
    try
    {
      DbModel dbModel = findDbModel(pc, model.getName());

      modelToDbModel(model, dbModel);

      pc.saveObject(dbModel);
    }
    catch (PersistenceException e)
    {
      tg.doCatch();
      throw new ModelException("DatabaseOperation", "Error saving descriptor of model '" + model.getQualifier() + "' to the database: "
        + e.getMessage(), e);
    }
    finally
    {
      tg.doFinally();
    }
  }
View Full Code Here

Examples of org.openbp.server.persistence.TransactionGuard

  {
    // Create reference names for persistent storage
    item.maintainReferences(ModelObject.SYNC_GLOBAL_REFNAMES | ModelObject.SYNC_LOCAL_REFNAMES);

    PersistenceContext pc = getPersistenceContextProvider().obtainPersistenceContext();
    TransactionGuard tg = new TransactionGuard(pc);
    try
    {
      DbModelItem dbModelItem = (DbModelItem) pc.createEntity(DbModelItem.class);

      itemToDbModelItem(item, dbModelItem);

      pc.saveObject(dbModelItem);
    }
    catch (PersistenceException e)
    {
      tg.doCatch();
      throw new ModelException("DatabaseOperation", "Error saving descriptor of component '" + item.getQualifier() + "' to the database: "
        + e.getMessage(), e);
    }
    finally
    {
      tg.doFinally();
    }
  }
View Full Code Here

Examples of org.openbp.server.persistence.TransactionGuard

   * @throws PersistenceException On error
   */
  public Object merge(Object obj)
    throws PersistenceException
  {
    TransactionGuard tg = new TransactionGuard(this);
    try
    {
      obj = getHibernateSession().merge(obj);
      return obj;
    }
    catch (HibernateException e)
    {
      tg.doCatch();
      throw createLoggedException(e);
    }
    finally
    {
      tg.doFinally();
    }
  }
View Full Code Here

Examples of org.openbp.server.persistence.TransactionGuard

  {
    // Create reference names for persistent storage
    item.maintainReferences(ModelObject.SYNC_GLOBAL_REFNAMES | ModelObject.SYNC_LOCAL_REFNAMES);

    PersistenceContext pc = getPersistenceContextProvider().obtainPersistenceContext();
    TransactionGuard tg = new TransactionGuard(pc);
    try
    {
      DbModelItem dbModelItem = findDbModelItem(pc, item);

      itemToDbModelItem(item, dbModelItem);

      pc.saveObject(dbModelItem);
    }
    catch (PersistenceException e)
    {
      tg.doCatch();
      throw new ModelException("DatabaseOperation", "Error saving descriptor of component '" + item.getQualifier() + "' to the database: "
        + e.getMessage(), e);
    }
    finally
    {
      tg.doFinally();
    }
  }
View Full Code Here

Examples of org.openbp.server.persistence.TransactionGuard

  public Object refreshObject(final Object obj)
    throws PersistenceException
  {
    if (obj != null)
    {
      TransactionGuard tg = new TransactionGuard(this);
      try
      {
        if (obj instanceof PersistentObjectBase)
        {
          ((PersistentObjectBase) obj).flagAsUnloaded();
        }
        getHibernateSession().refresh(obj);
      }
      catch (UnresolvableObjectException e)
      {
        tg.doCatch();
        String msg = LogUtil.error(getClass(), "Persistence error.", e);
        throw new PersistentObjectNotFoundException(msg, e);
      }
      catch (HibernateException e)
      {
        tg.doCatch();
        throw createLoggedException(e);
      }
      finally
      {
        tg.doFinally();
      }
    }
    return obj;
  }
View Full Code Here

Examples of org.openbp.server.persistence.TransactionGuard

   * @throws OpenBPException On error
   */
  protected void removeModelFromStore(Model model)
  {
    PersistenceContext pc = getPersistenceContextProvider().obtainPersistenceContext();
    TransactionGuard tg = new TransactionGuard(pc);
    try
    {
      String sql = "DELETE FROM OPENBPMODELITEM WHERE MI_MODEL_NAME = '" + model.getName() + "'";
      pc.executeUpdateOrDelete(sql);

      sql = "DELETE FROM OPENBPMODEL WHERE MO_NAME = '" + model.getName() + "'";
      pc.executeUpdateOrDelete(sql);
    }
    catch (PersistenceException e)
    {
      tg.doCatch();
      throw new ModelException("DatabaseOperation", "Error removing model '" + model.getQualifier() + "' from the database: "
        + e.getMessage(), e);
    }
    finally
    {
      tg.doFinally();
    }
  }
View Full Code Here

Examples of org.openbp.server.persistence.TransactionGuard

   */
  public Object findById(final Object id, Class entityClass)
    throws PersistenceException
  {
    Class beanClass = determineEntityClass(entityClass);
    TransactionGuard tg = new TransactionGuard(this);
    try
    {
      Object ret = getHibernateSession().get(beanClass, (Serializable) id);
      return ret;
    }
    catch (HibernateException e)
    {
      tg.doCatch();
      throw createLoggedException(e);
    }
    finally
    {
      tg.doFinally();
    }
  }
View Full Code Here

Examples of org.openbp.server.persistence.TransactionGuard

   * @throws OpenBPException On error
   */
  protected void removeItemFromStore(Item item)
  {
    PersistenceContext pc = getPersistenceContextProvider().obtainPersistenceContext();
    TransactionGuard tg = new TransactionGuard(pc);
    try
    {
      DbModelItem dbModelItem = findDbModelItem(pc, item);

      pc.deleteObject(dbModelItem);
    }
    catch (PersistenceException e)
    {
      tg.doCatch();
      throw new ModelException("DatabaseOperation", "Error saving descriptor of component '" + item.getQualifier() + "' to the database: "
        + e.getMessage(), e);
    }
    finally
    {
      tg.doFinally();
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.