public static OfferInfoDbType getOfferInfoDbEntry( int companyId, int branchId, int offerId, OffersInfo offersInfo) { OfferInfoDbType dbEntry = new OfferInfoDbType(); dbEntry.setId(getOfferInfoPrimaryKey(companyId, offerId)); dbEntry.setType(offersInfo.getType()); dbEntry.setDetails(offersInfo.getDetails()); dbEntry.setBranchId(branchId); dbEntry.setStartTS(offersInfo.getStart()); dbEntry.setEndTS(offersInfo.getEnd()); dbEntry.setRecurrenceDay(offersInfo.getRecurrenceDay()); dbEntry.setRecurrence(offersInfo.isRecurrence()); dbEntry.setHourlyPush(offersInfo.isHourlyPush()); dbEntry.setClientAppVisibility(offersInfo.isClientAppVisibility()); return dbEntry; }
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); } }