/**
   * @see net.metaship.generic.Manager#deleteSpecialRate(PrimaryKey)
   * @ejb.interface-method
   * @ejb.transaction type="Required"
   */
  public void delete(PrimaryKey primaryKey) throws LocalException {
    checkPrimaryKeyInstance(primaryKey);

    try {
      Collection col =
          SpecialRateLineUtil.getLocalHome()
              .findBySpecialRateId(((SpecialRatePK) primaryKey).getId().longValue());
      for (Iterator iter = col.iterator(); iter.hasNext(); ) {
        SpecialRateLineLocal element = (SpecialRateLineLocal) iter.next();

        Collection col2 =
            RateServiceAreaUtil.getLocalHome().findBySpecialRateLineId(element.getId().longValue());
        for (Iterator iterator = col2.iterator(); iterator.hasNext(); ) {
          RateServiceAreaLocal element2 = (RateServiceAreaLocal) iterator.next();
          element2.remove();
        }

        element.remove();
      }

      SpecialRateLocalHome home = SpecialRateUtil.getLocalHome();
      SpecialRateLocal local = home.findByPrimaryKey((SpecialRatePK) primaryKey);
      local.remove();
    } catch (Exception e) {
      throw new LocalException(
          "An Error occured while deleting object with primary key: " + primaryKey + "!!", e);
    }
  }
  /**
   * @see net.metaship.generic.Manager#update(ValueObject)
   * @ejb.interface-method
   * @ejb.transaction type="Required"
   */
  public void update(ValueObject valueObject) throws LocalException {
    checkValueObjectInstance(valueObject);

    SpecialRateValue value = (SpecialRateValue) valueObject;
    SpecialRateLocal local = null;
    try {
      SpecialRateLocalHome home = SpecialRateUtil.getLocalHome();
      local = home.findByPrimaryKey(value.getPrimaryKey());
      local.setSpecialRateValue(value);

    } catch (Exception e) {
      throw new LocalException("An Error occured while updating object: " + valueObject + "!!", e);
    }
  }
  /**
   * @see net.metaship.generic.Manager#findByPrimaryKey(PrimaryKey)
   * @ejb.interface-method
   * @ejb.transaction type="Required"
   */
  public ValueObject findByPrimaryKey(PrimaryKey primaryKey) throws LocalException {
    checkPrimaryKeyInstance(primaryKey);

    SpecialRateLocal local = null;
    try {
      SpecialRateLocalHome home = SpecialRateUtil.getLocalHome();
      local = home.findByPrimaryKey((SpecialRatePK) primaryKey);
    } catch (Exception e) {
      throw new LocalException(
          "An Error occured while finding object with primary key: " + primaryKey + "!!", e);
    }

    return local.getSpecialRateValue();
  }
  /**
   * @ejb.interface-method
   * @ejb.transaction type="Required"
   */
  public void modifyValidity(
      java.util.List tariffPKs, java.util.Date durationFrom, java.util.Date durationTo)
      throws LocalException, FinderException, NamingException {
    if (log.isInfoEnabled())
      log.info(
          ">modifyValidity "
              + " List"
              + tariffPKs
              + " Date "
              + durationFrom
              + " Date "
              + durationTo);

    if (tariffPKs.size() < 1) return;

    SpecialRateLocalHome ttlh = SpecialRateUtil.getLocalHome();
    for (int i = 0, n = tariffPKs.size(); i < n; i++) {
      SpecialRateLocal ttl = ttlh.findByPrimaryKey((SpecialRatePK) tariffPKs.get(i));
      if (durationFrom != null) ttl.setDurationFrom(durationFrom);
      if (durationTo != null) ttl.setDurationTo(durationTo);
    }
  }