/**
   * Saves the given RegimenCategory entity if possible.
   *
   * @param regimenCategory the RegimenCategory to save.
   * @throws java.lang.NullPointerException if regimenCategory is null.
   * @throws org.openlmis.core.exception.DataException if unable to save.
   */
  public void save(RegimenCategory regimenCategory) {
    if (regimenCategory == null) throw new NullPointerException("RegimenCategory argument is null");

    try {
      if (regimenCategory.hasId()) mapper.update(regimenCategory);
      else mapper.insert(regimenCategory);
    } catch (DuplicateKeyException dke) {
      throw new DataException("error.duplicate.regimen.category", dke);
    } catch (DataIntegrityViolationException dive) {
      throw new DataException("error.incorrect.length", dive);
    }
  }
 /**
  * Finds a stored RegimenCategory with the given code.
  *
  * @param code the code to find by, case insensitive
  * @return the RegimenCategory with the given code, or null if no such code exists.
  */
 public RegimenCategory getByCode(String code) {
   if (code == null) return null;
   return mapper.getByCode(code);
 }
 /**
  * Gets a list of all stored RegimenCategory entities.
  *
  * @return an sorted list by display order and then name, ascending.
  */
 public List<RegimenCategory> getAll() {
   return mapper.getAll();
 }