コード例 #1
0
  @Transactional
  public OffersInfo addOffersInfo(int companyId, OffersInfo offersInfo) throws Exception {
    try {
      int offerId = offersInfoDao.getMaxIdValue(companyId) + 1;
      OfferInfoDbType offerInfoDbType =
          Conversions.getOfferInfoDbEntry(companyId, offersInfo.getBranchId(), offerId, offersInfo);
      offersInfoDao.add(offerInfoDbType);

      offersInfo.setOfferId(offerId);
      return offersInfo;
    } catch (Exception e) {
      logger.error(
          "error adding offers for : "
              + companyId
              + " and : "
              + offersInfo.getBranchId()
              + " : "
              + e.getMessage());
      throw new Exception(
          "error adding offers for : "
              + companyId
              + " and : "
              + offersInfo.getBranchId()
              + " : "
              + e.getMessage());
    }
  }
コード例 #2
0
  @Transactional
  public OffersInfo updateOffersInfo(int companyId, int offerId, OffersInfo offersInfo)
      throws Exception {
    try {
      OfferInfoPrimaryKey id = Conversions.getOfferInfoPrimaryKey(companyId, offerId);
      OfferInfoDbType dbEntry = offersInfoDao.find(id);

      updateOfferInfoDbEntry(dbEntry, offersInfo);

      return offersInfo;
    } catch (Exception e) {
      logger.error(
          "error updating offers for : "
              + companyId
              + " and : "
              + offersInfo.getBranchId()
              + " : "
              + e.getMessage());
      throw new Exception(
          "error updating offers for : "
              + companyId
              + " and : "
              + offersInfo.getBranchId()
              + " : "
              + e.getMessage());
    }
  }
コード例 #3
0
  public List<OffersInfo> getOffersInfo() throws Exception {
    try {
      List<OfferInfoDbType> listDbEntries = offersInfoDao.findAll();
      List<OffersInfo> out = new ArrayList<OffersInfo>(listDbEntries.size());

      for (OfferInfoDbType dbEntry : listDbEntries) {
        out.add(Conversions.getOffersInfo(dbEntry));
      }
      return out;
    } catch (Exception e) {
      logger.error("error getting all offers for : " + e.getMessage());
      throw new Exception("error getting all offers for : " + e.getMessage());
    }
  }
コード例 #4
0
  public List<OffersInfo> getOffersInfo(int companyId) throws Exception {
    try {
      List<OfferInfoDbType> listDbEntries = offersInfoDao.getOffersAndInfo(companyId);
      List<OffersInfo> out = new ArrayList<OffersInfo>(listDbEntries.size());

      for (OfferInfoDbType dbEntry : listDbEntries) {
        out.add(Conversions.getOffersInfo(dbEntry));
      }
      return out;
    } catch (Exception e) {
      logger.error("error getting offers for : " + companyId + " and : " + " : " + e.getMessage());
      throw new Exception(
          "error getting offers for : " + companyId + " and : " + " : " + e.getMessage());
    }
  }
コード例 #5
0
  private void updateOfferInfoDbEntry(OfferInfoDbType dbEntry, OffersInfo offersInfo) {
    boolean updated = false;
    if (!dbEntry.getType().equals(offersInfo.getType())) {
      dbEntry.setType(offersInfo.getType());
      updated = true;
    }
    if (!dbEntry.getDetails().equals(offersInfo.getDetails())) {
      dbEntry.setDetails(offersInfo.getDetails());
      updated = true;
    }
    if (!dbEntry.getStartTS().equals(offersInfo.getStart())) {
      dbEntry.setStartTS(offersInfo.getStart());
      updated = true;
    }
    if (!dbEntry.getEndTS().equals(offersInfo.getEnd())) {
      dbEntry.setEndTS(offersInfo.getEnd());
      updated = true;
    }
    if (dbEntry.getRecurrenceDay() != offersInfo.getRecurrenceDay()) {
      dbEntry.setRecurrenceDay(offersInfo.getRecurrenceDay());
      updated = true;
    }
    if (dbEntry.isRecurrence() != offersInfo.isRecurrence()) {
      dbEntry.setRecurrence(offersInfo.isRecurrence());
      updated = true;
    }
    if (dbEntry.isHourlyPush() != offersInfo.isHourlyPush()) {
      dbEntry.setHourlyPush(offersInfo.isHourlyPush());
      updated = true;
    }
    if (dbEntry.isClientAppVisibility() != offersInfo.isClientAppVisibility()) {
      dbEntry.setClientAppVisibility(offersInfo.isClientAppVisibility());
      updated = true;
    }

    if (updated == true) {
      offersInfoDao.update(dbEntry);
    }
  }
コード例 #6
0
 public OffersInfo getOfferOrInfo(int companyId, int offerId) throws Exception {
   try {
     OfferInfoDbType dbEntry =
         offersInfoDao.find(Conversions.getOfferInfoPrimaryKey(companyId, offerId));
     OffersInfo out = Conversions.getOffersInfo(dbEntry);
     return out;
   } catch (Exception e) {
     logger.error(
         "error getting offer for : "
             + companyId
             + " and : offer id"
             + offerId
             + " : "
             + e.getMessage());
     throw new Exception(
         "error getting offers for : "
             + companyId
             + " and : offer id"
             + offerId
             + " : "
             + e.getMessage());
   }
 }