/**
  * ********************************************************************
  *
  * @param the object that will remove an old association
  * @param the object that will be removed as the old association (neighbor)
  *     ********************************************************************
  */
 public synchronized void deleteAssociation(
     Address address, Object neighbor, String AssociationID) {
   try {
     Address object = Database.get(Address.class, address.ID());
     if (object != null) {
       int oldID = address.ID();
       if (neighbor instanceof Station) {
         ((Station) neighbor).deleteAssociation(object, AssociationID);
         Transactions.AddCommand(
             new Command(
                 getAccess(),
                 CommandType.DELETE_ASSOCIATION,
                 CommandTargetLayer.VIEW,
                 oldID,
                 address,
                 object,
                 Station.class,
                 ((Station) neighbor).ID(),
                 neighbor,
                 null));
       }
       object.checkModelRestrictions();
       object.checkRestrictions();
       Transactions.getSession().store(object);
     } else {
       Transactions.CancelTransaction(
           "Failed in DeleteAssociation", "the Address does not exists");
     }
   } catch (Exception e) {
     Transactions.CancelTransaction(
         "Failed in DeleteAssociation",
         "Error ocurred while trying to delete the association of Address");
   }
 }
  /**
   * ********************************************************************
   *
   * @param the object that will be updated
   *     ********************************************************************
   */
  public synchronized void update(Address address) {
    try {
      Address object = Database.get(Address.class, address.ID());
      int oldID = address.ID();
      object.setID();
      if (Database.get(Address.class, object.ID()) == null) {
        object.checkModelRestrictions();
        object.checkRestrictions();

        Transactions.getSession().store(object);
        Transactions.AddCommand(
            new Command(
                getAccess(),
                CommandType.UPDATE,
                CommandTargetLayer.DATABASE,
                oldID,
                address,
                object,
                null,
                0,
                null,
                null));
        Transactions.AddCommand(
            new Command(
                getAccess(),
                CommandType.UPDATE,
                CommandTargetLayer.VIEW,
                oldID,
                address,
                object,
                null,
                0,
                null,
                null));
      } else {
        Transactions.CancelTransaction("Failed in Edit", "this Address already exists");
      }
    } catch (Exception e) {
      Transactions.CancelTransaction(
          "Failed in Edit", "Error ocurred while trying to save the Address");
    }
  }
  /**
   * ********************************************************************
   *
   * @param the object that will be deleted
   *     ********************************************************************
   */
  public synchronized void delete(Address address) {
    try {
      Address object = Database.get(Address.class, address.ID());
      if (object != null) {
        int oldID = address.ID();
        notifyDeletion(object);
        Transactions.getSession().delete(object);

        Transactions.AddCommand(
            new Command(
                getAccess(),
                CommandType.DELETE,
                CommandTargetLayer.DATABASE,
                oldID,
                object,
                null,
                null,
                0,
                null,
                null));
        Transactions.AddCommand(
            new Command(
                getAccess(),
                CommandType.DELETE,
                CommandTargetLayer.VIEW,
                oldID,
                object,
                null,
                null,
                0,
                null,
                null));
      } else {
        Transactions.CancelTransaction("Failed in Delete", "this Address does not exists");
      }
    } catch (Exception e) {
      Transactions.CancelTransaction(
          "Failed in Delete", "Error ocurred while trying to delete the Address");
    }
  }
  /**
   * ********************************************************************
   *
   * @param the object that will be inserted
   *     ********************************************************************
   */
  public synchronized void insert(Address object) {
    try {
      if (Database.get(Address.class, object.ID()) == null) {
        object.checkModelRestrictions();
        object.checkRestrictions();

        Transactions.getSession().store(object);
        Transactions.AddCommand(
            new Command(
                getAccess(),
                CommandType.INSERT,
                CommandTargetLayer.DATABASE,
                0,
                null,
                object,
                null,
                0,
                null,
                null));
        Transactions.AddCommand(
            new Command(
                getAccess(),
                CommandType.INSERT,
                CommandTargetLayer.VIEW,
                0,
                null,
                object,
                null,
                0,
                null,
                null));
      } else {
        Transactions.CancelTransaction("Failed in Insert", "this Address already exists");
      }
    } catch (Exception e) {
      Transactions.CancelTransaction(
          "Failed in Insert", "Error ocurred while trying to save the Address");
    }
  }