Package org.dmlite.exception

Examples of org.dmlite.exception.ActionException


   */
  public boolean execute() throws ActionException {
    boolean executed = false;
    if (getSession() == null && getTransaction() == null) {
      String error = "Action must be within a session or within a transaction";
      throw new ActionException(error, this);
    }
    try {
      if (getName().equals("add")) {
        executed = getEntities().add(updateEntity);
      } else if (getName().equals("remove")) {
        executed = getEntities().remove(entity);
      } else if (getName().equals("update")) {
        executed = getEntities().update(entity, updateEntity);
      }
    } catch (ActionException e) {
      log.error("Error in EntitiesAction.execute: " + e.getMessage());
      throw new ActionException(e.getMessage(), this);
    }
    if (executed) {
      setStatus("executed");
      if (getTransaction() == null) {
        DomainModel domainModel = (DomainModel) getSession()
View Full Code Here


   */
  public boolean undo() throws ActionException {
    boolean undone = false;
    if (!isExecuted()) {
      String error = "An action must be executed first.";
      throw new ActionException(error, this);
    }
    try {
      if (getName().equals("add")) {
        undone = getEntities().remove(updateEntity);
      } else if (getName().equals("remove")) {
        undone = getEntities().add(entity);
      } else if (getName().equals("update")) {
        undone = getEntities().update(updateEntity, entity);
      }
    } catch (ActionException e) {
      log.error("Error in EntitiesAction.undo: " + e.getMessage());
      throw new ActionException(e.getMessage(), this);
    }
    if (undone) {
      setStatus("undone");
      if (getTransaction() == null) {
        DomainModel domainModel = (DomainModel) getSession()
View Full Code Here

          return false;
        }
      }
    } catch (Exception e) {
      log.error("Error in Entities.add: " + e.getMessage());
      throw new ActionException(e.getMessage(), entitiesAddAction);
    }
    return false;
  }
View Full Code Here

          return false;
        }
      }
    } catch (Exception e) {
      log.error("Error in Entities.remove: " + e.getMessage());
      throw new ActionException(e.getMessage(), entitiesRemoveAction);
    }
    return false;
  }
View Full Code Here

    entitiesUpdateAction.setEntity(entity);
    entitiesUpdateAction.setUpdateEntity(updateEntity);
    try {
      if (entity == updateEntity) {
        String error = "The before update entity and the after update entity cannot be the same object.";
        throw new ActionException(error, entitiesUpdateAction);
      }

      T retrievedEntity = this.retrieveByOid(entity.getOid());
      if (retrievedEntity == null) {
        String error = "No before update entity.";
        throw new ActionException(error, entitiesUpdateAction);
      } else {
        if (retrievedEntity != entity) {
          String error = "Wrong before update entity.";
          throw new ActionException(error, entitiesUpdateAction);
        }
      }

      if (!preUpdate(entity, updateEntity)) {
        return false;
      }

      boolean updated = false;
      T backupBeforeEntity = (T) entity.copy();

      updated = entity.update(updateEntity);
      if (updated) {
        if (postUpdate(backupBeforeEntity, entity)) {
          IDomainModel domainModel = getDomainModel();
          if (domainModel != null && !domainModel.isSession()
              && domainModel.isInitialized()) {
            ModelMeta modelMeta = domainModel.getModelMeta();
            modelMeta.setParents(updateEntity, this);
            domainModel.notifyObservers(entitiesUpdateAction);
          }
          return true;
        } else {
          if (entity.update(backupBeforeEntity)) {
            return false;
          } else {
            String error = "Cannot undo an update that has a not valid postcondition.";
            throw new ActionException(error, entitiesUpdateAction);
          }
        }
      }
    } catch (Exception e) {
      log.error("Error in Entities.update: " + e.getMessage());
      throw new ActionException(e.getMessage(), entitiesUpdateAction);
    }
    return false;
  }
View Full Code Here

   * @throws dmLite
   *             action exception if there is a problem
   */
  public boolean execute() throws ActionException {
    String error = "Execute is not supported on an entity.";
    throw new ActionException(error, this);
  }
View Full Code Here

   * @throws dmLite
   *             action exception if there is a problem
   */
  public boolean undo() throws ActionException {
    String error = "Undo is not supported on an entity.";
    throw new ActionException(error, this);
  }
View Full Code Here

   */
  public boolean execute() throws ActionException {
    DomainModel domainModel = (DomainModel) getSession().getDomainModel();
    if (!domainModel.isSession()) {
      String error = "The domain model is not configured for transactions.";
      throw new ActionException(error, this);
    } else if (getSession() == null) {
      String error = "Transaction must be within a session.";
      throw new ActionException(error, this);
    }
    boolean executed = actions.executeAll();
    if (executed) {
      setStatus("executed");
      domainModel.notifyObservers(this);
View Full Code Here

   * @return <code>true</code> if undone
   */
  public boolean undo() throws ActionException {
    if (!isExecuted()) {
      String error = "A transaction must be executed first.";
      throw new ActionException(error, this);
    }
    boolean undone = actions.undoAll();
    if (undone) {
      setStatus("undone");
      DomainModel domainModel = (DomainModel) getSession()
View Full Code Here

    entityAction.setEntity(this);
    entityAction.setParameter(entity);
    try {
      if (this == entity) {
        String error = "Two update entities cannot be the same object.";
        throw new ActionException(error, entityAction);
      }

      IDomainModel domainModel = getDomainModel();
      if (domainModel != null) {
        ModelMeta modelMeta = domainModel.getModelMeta();
        updated = modelMeta.update(this, entity);
      }
    } catch (Exception e) {
      log.error("Error in Entity.update: " + e.getMessage());
      throw new ActionException(e.getMessage(), entityAction);
    }
    return updated;
  }
View Full Code Here

TOP

Related Classes of org.dmlite.exception.ActionException

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.