private List copyTariffPK(
      java.util.List tariffPKs, java.util.Date durationFrom, java.util.Date durationTo)
      throws LocalException {
    if (log.isInfoEnabled())
      log.info(">copy " + " List" + tariffPKs + " Date " + durationFrom + " Date " + durationTo);
    //
    // iterate over all TariffPK's
    //
    List newTariffs = new ArrayList();
    for (int i = 0; i < tariffPKs.size(); i++) {
      SpecialRateValue ttv = (SpecialRateValue) findByPrimaryKey((PrimaryKey) tariffPKs.get(i));
      // copy tariff
      List value =
          copy(
              (SpecialRatePK) tariffPKs.get(i),
              !ttv.getIsImport(),
              ttv.getIsImport(),
              new Long[] {new Long(ttv.getFacilityId())},
              new Long[] {new Long(ttv.getVendorId())},
              durationFrom,
              durationTo);

      // add tariff to return list
      newTariffs.addAll(value);
    }
    return newTariffs;
  }
  /**
   * @ejb.interface-method
   * @ejb.transaction type="Required"
   */
  public ValueObject fill(ValueObject valueObject) throws LocalException {
    List list = new CompressedSerializedList();
    ValueObject returnValue = null;
    try {
      if (valueObject instanceof SpecialRateValue) {
        SpecialRateValue object = new SpecialRateValue((SpecialRateValue) valueObject);

        if (object.getId() == null) {
          throw new LocalException("Could not fill object, because primary key is null: " + object);
        }
        SpecialRateLineManagerLocal srlm =
            (SpecialRateLineManagerLocal) SpecialRateLineManagerUtil.getLocalHome().create();
        Collection col =
            SpecialRateLineUtil.getLocalHome().findBySpecialRateId(object.getId().longValue());
        for (Iterator iter = col.iterator(); iter.hasNext(); ) {
          SpecialRateLineLocal element = (SpecialRateLineLocal) iter.next();
          list.add(srlm.fill(element.getSpecialRateLineValue()));
        }
        object.fillSpecialRateLines(list);
        returnValue = object;

      } else {
        // others
        throw new LocalException(
            "Tried to fill an Unsupported valueObject-type: " + valueObject.getClass());
      }
    } catch (NamingException e) {
      throw new LocalException("NamingException while filling: " + valueObject, e);
    } catch (FinderException e) {
      throw new LocalException("FinderException while filling: " + valueObject, e);
    } catch (CreateException e) {
      throw new LocalException("FinderException while filling: " + valueObject, e);
    }
    return returnValue;
  }
  /**
   * @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);
    }
  }
  /**
   * Copy the specified tariffPK's with all line items to new tariffs with the given validity Can
   * handle Tariff PK's or TariffLine PK's if TariffLinePK's are handed over onlly the handed ones
   * are copied
   *
   * @param tariffPKs
   * @param newDurationFrom
   * @param newDurationTo
   * @return
   * @throws LocalException
   * @throws NamingException
   * @throws FinderException
   * @ejb.interface-method
   * @ejb.transaction type="Required"
   */
  public List copy(java.util.List tariffPKs, java.util.Date durationFrom, java.util.Date durationTo)
      throws LocalException, FinderException, NamingException {
    if (log.isInfoEnabled())
      log.info(">copy " + " List" + tariffPKs + " Date " + durationFrom + " Date " + durationTo);

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

    List pks = null;
    List copiedTariffs = new ArrayList();
    Hashtable pKs = new Hashtable();
    if (tariffPKs.get(0) instanceof SpecialRateLinePK) {
      for (int i = 0, n = tariffPKs.size(); i < n; i++) {
        SpecialRateLineLocal ttll =
            ((SpecialRateLineLocal)
                SpecialRateLineUtil.getLocalHome()
                    .findByPrimaryKey((SpecialRateLinePK) tariffPKs.get(i)));
        SpecialRatePK ttpk = new SpecialRatePK(new Long(ttll.getSpecialRateId()));
        SpecialRateValue ttl = null;
        if (!pKs.contains(ttpk)) {
          ttl =
              SpecialRateUtil.getLocalHome()
                  .findByPrimaryKey(ttpk)
                  .plainCopy(false, durationFrom, durationTo);
          pKs.put(ttpk, ttl);
          copiedTariffs.add(ttl);
        }
        ttl = (SpecialRateValue) pKs.get(ttpk);
        ttll.copyInto(ttl.getPrimaryKey());
      }

    } else {
      pks = tariffPKs;
      copiedTariffs = copyTariffPK(pks, durationFrom, durationTo);
    }
    return copiedTariffs;
  }