/**
  * Creates a reward type
  *
  * @param rt the type of the reward, e.g. 'Beer'
  * @return the reward type, created
  */
 @Override
 public RewardType addRewardType(RewardType rt) {
   try {
     long id = delegator.getNextSeqId(ENTITY);
     rt.setId(id);
     delegator.create(toGenericValue(rt));
     return rt;
   } catch (GenericEntityException e) {
     String msg =
         String.format(
             "Could not create reward type ('%s', '%s') ?!?", rt.getName(), rt.getDescription());
     LOG.error(msg);
     throw new OfbizDataException(msg, e);
   }
 }
 private GenericValue toGenericValue(RewardType rt) {
   Map<String, Object> map = new HashMap<String, Object>();
   map.put(ID_FIELD, rt.getId());
   map.put(NAME_FIELD, rt.getName());
   map.put(NAMEPL_FIELD, rt.getNamePluralForm());
   map.put(DESC_FIELD, rt.getDescription());
   map.put(ICON_FIELD, rt.getIconURL());
   return delegator.makeValue(ENTITY, map);
 }
 /**
  * Gets all the reward types
  *
  * @return the reward
  */
 @Override
 public List<RewardType> getRewardTypes() {
   try {
     List<GenericValue> list = delegator.findAll(ENTITY);
     return fromGenericValue(list);
   } catch (GenericEntityException e) {
     String msg = "Could not load all rewards types ?!?";
     LOG.error(msg);
     throw new OfbizDataException(msg, e);
   }
 }
 /**
  * Gets the types
  *
  * @param id the id
  * @return the RewardType
  */
 @Override
 public RewardType getRewardType(long id) {
   try {
     GenericValue ret = delegator.findByPrimaryKey(ENTITY, makePk(id));
     return (ret != null ? fromGenericValue(ret) : null);
   } catch (GenericEntityException e) {
     String msg = String.format("Could not load reward type (id=%d) ?!?", id);
     LOG.error(msg);
     throw new OfbizDataException(msg, e);
   }
 }
 private GenericPK makePk(long id) {
   Map<String, Object> map = new HashMap<String, Object>();
   map.put(ID_FIELD, id);
   return delegator.makePK(ENTITY, map);
 }
 /** Constructor */
 public RewardTypeDataServiceImpl() {
   this.delegator = GenericDelegator.getGenericDelegator("default");
 }