Package org.dmlite.model.action

Examples of org.dmlite.model.action.EntitiesAction


                    IPersistentEntities persistentEntities = getPersistentEntry(entryCode);
                    persistentEntities.save();
                  }
                }
              } else if (arg instanceof EntitiesAction) {
                EntitiesAction action = (EntitiesAction) arg;
                String actionName = action.getName();
                IEntities entities = action.getEntities();
                if (actionName.equals("add")
                    || actionName.equals("remove")
                    || actionName.equals("update")) {
                  IEntities entry = domainModel
                      .getModelMeta().getEntry(entities);
                  if (entry != null) {
                    String entryCode = entry
                        .getConceptConfig()
                        .getEntitiesCode();
                    IPersistentEntities persistentEntities = getPersistentEntry(entryCode);
                    persistentEntities.save();
                  }
                }
              }
            } else if (arg instanceof EntitiesAction) {
              EntitiesAction action = (EntitiesAction) arg;
              String actionName = action.getName();
              IEntities entities = action.getEntities();
              if (actionName.equals("add")
                  || actionName.equals("remove")
                  || actionName.equals("update")) {
                IEntities entry = domainModel.getModelMeta()
                    .getEntry(entities);
View Full Code Here


                  }
                  db.commit();
                }
              } else if (arg instanceof EntitiesAction) {
                // domain model session, but no transaction
                EntitiesAction action = (EntitiesAction) arg;
                IEntities entities = action.getEntities();
                String actionName = action.getName();
                IEntity entity = action.getEntity();
                ObjectContainer db = getDb();
                if (actionName.equals("add")) {
                  db.set(entity);
                  db.set(entities);
                } else if (actionName.equals("remove")) {
                  db.set(entities);
                  db.delete(entity);
                } else if (actionName.equals("update")) {
                  IEntity updateEntity = action.getEntity();
                  db.set(updateEntity);
                } else if (actionName.equals("attach")) {
                  db.set(entities);
                } else if (actionName.equals("detach")) {
                  db.set(entities);
                }
                db.commit();
              }
            } else if (arg instanceof EntitiesAction) {
              // no domain model session
              EntitiesAction action = (EntitiesAction) arg;
              IEntities entities = action.getEntities();
              String actionName = action.getName();
              IEntity entity = action.getEntity();
              ObjectContainer db = getDb();
              if (actionName.equals("add")) {
                db.set(entity);
                db.set(entities);
              } else if (actionName.equals("remove")) {
                db.set(entities);
                db.delete(entity);
              } else if (actionName.equals("update")) {
                IEntity updateEntity = action.getEntity();
                db.set(updateEntity);
              } else if (actionName.equals("attach")) {
                db.set(entities);
              } else if (actionName.equals("detach")) {
                db.set(entities);
View Full Code Here

  private void test09() {
    try {
      boolean done;
      Session session = getDomainModel().getSession();
      EntitiesAction action = new RemoveAction(session);
      Comments comments = getComments();
      Comment firstComment = (Comment) comments.first();
      action.setEntities(comments);
      action.setEntity(firstComment);
      done = action.execute();
      log.info("Successful Action: " + done);
    } catch (ActionException ae) {
      log.info("Action problem: " + ae.getMessage());
    }
  }
View Full Code Here

  private void test10() {
    try {
      boolean undone;
      Session session = getDomainModel().getSession();
      EntitiesAction action = new RemoveAction(session);
      Comments comments = getComments();
      Comment firstComment = (Comment) comments.first();
      action.setEntities(comments);
      action.setEntity(firstComment);
      action.execute();
      undone = action.undo();
      log.info("Undone Action: " + undone);
    } catch (ActionException ae) {
      log.info("Action problem: " + ae.getMessage());
    }
  }
View Full Code Here

      Session session = getDomainModel().getSession();
      Transaction transaction = new Transaction(session);
      Comments comments = getComments();
      Comment firstComment = (Comment) comments.first();
      Comment secondComment = (Comment) comments.next(firstComment);
      EntitiesAction action1 = new RemoveAction(transaction);
      action1.setEntities(comments);
      action1.setEntity(firstComment);
      EntitiesAction action2 = new RemoveAction(transaction);
      action2.setEntities(comments);
      action2.setEntity(secondComment);
      allActionsDone = transaction.execute();
      log.info("Successful Transaction: " + allActionsDone);
    } catch (ActionException ae) {
      log.info("Transaction problem: " + ae.getMessage());
    }
View Full Code Here

      Session session = getDomainModel().getSession();
      Transaction transaction = new Transaction(session);
      Comments comments = getComments();
      Comment firstComment = (Comment) comments.first();
      Comment secondComment = (Comment) comments.next(firstComment);
      EntitiesAction action1 = new RemoveAction(transaction);
      action1.setEntities(comments);
      action1.setEntity(firstComment);
      EntitiesAction action2 = new RemoveAction(transaction);
      action2.setEntities(comments);
      action2.setEntity(secondComment);
      transaction.execute();
      allActionsUndone = transaction.undo();
      log.info("Undone Transaction: " + allActionsUndone);
    } catch (ActionException ae) {
      log.info("Transaction problem: " + ae.getMessage());
View Full Code Here

   * @return <code>true</code> if the entity is added
   * @throws dmLite
   *             action exception if there is a problem
   */
  public boolean add(T entity) throws ActionException {
    EntitiesAction entitiesAddAction = new AddAction();
    entitiesAddAction.setEntities(this);
    entitiesAddAction.setEntity(entity);
    try {
      if (entity == null) {
        return false;
      }

View Full Code Here

   * @return <code>true</code> if the entity is removed
   * @throws dmLite
   *             action exception if there is a problem
   */
  public boolean remove(T entity) throws ActionException {
    EntitiesAction entitiesRemoveAction = new RemoveAction();
    entitiesRemoveAction.setEntities(this);
    entitiesRemoveAction.setEntity(entity);
    try {
      if (!preRemove(entity)) {
        return false;
      }

View Full Code Here

   * @throws dmLite
   *             action exception if there is a problem
   */
  public boolean update(T entity, T updateEntity)
      throws ActionException {
    EntitiesAction entitiesUpdateAction = new UpdateAction();
    entitiesUpdateAction.setEntities(this);
    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);
      }
View Full Code Here

TOP

Related Classes of org.dmlite.model.action.EntitiesAction

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.