コード例 #1
0
  /**
   * @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);
    }
  }
コード例 #2
0
  /**
   * @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);
    }
  }
コード例 #3
0
  /**
   * @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();
  }
コード例 #4
0
 /**
  * @ejb.interface-method
  * @ejb.transaction type="Supports"
  */
 public Collection findAll() throws LocalException {
   try {
     SpecialRateLocalHome home = SpecialRateUtil.getLocalHome();
     Collection col = home.findAll();
     List list = new CompressedSerializedList();
     for (Iterator iter = col.iterator(); iter.hasNext(); ) {
       SpecialRateLocal element = (SpecialRateLocal) iter.next();
       list.add(fill(element.getSpecialRateValue()));
     }
     return list;
   } catch (Exception e) {
     log.warn(StackTraceUtil.getStackTrace(e));
     throw new LocalException("An Error occured while findAll()!", e);
   }
 }
コード例 #5
0
 /**
  * @see net.metaship.generic.Manager#add(ValueObject)
  * @ejb.interface-method
  * @ejb.transaction type="Required"
  */
 public ValueObject add(ValueObject valueObject) throws LocalException {
   checkValueObjectInstance(valueObject);
   if (isDuplicate(
       "SpecialRate",
       ((SpecialRateValue) valueObject).getIsImport() ? Boolean.TRUE : Boolean.FALSE,
       new Long(((SpecialRateValue) valueObject).getFacilityId()),
       new Long(((SpecialRateValue) valueObject).getVendorId()),
       ((SpecialRateValue) valueObject).getDurationFrom(),
       ((SpecialRateValue) valueObject).getDurationTo())) {
     throw new LocalException("<USER>A tariff with these setting does exist already</USER>");
   }
   try {
     SpecialRateLocalHome home = SpecialRateUtil.getLocalHome();
     return home.create((SpecialRateValue) valueObject).getSpecialRateValue();
   } catch (Exception e) {
     throw new LocalException(
         "An Error occured while adding valueObject: " + valueObject + "!!", e);
   }
 }
コード例 #6
0
  /**
   * @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);
    }
  }