コード例 #1
0
  /**
   * Insert a new {@link org.openlmis.core.domain.ProductForm}.
   *
   * @param pf {@link org.openlmis.core.domain.ProductForm} to insert.
   * @throws DataException if entity is invalid or already exists.
   */
  public void insert(ProductForm pf) {
    pf.isValid();
    if (getByCode(pf.getCode()) != null)
      throw new DataException("error.duplicate.dosage.unit.code");

    try {
      pfMapper.insert(pf);
    } catch (DataIntegrityViolationException dive) {
      throw new DataException("error.incorrect.length", dive);
    }
  }
コード例 #2
0
  /**
   * Updates an existing {@link org.openlmis.core.domain.ProductForm}.
   *
   * @param pf {@link org.openlmis.core.domain.ProductForm} to update.
   * @throws DataException if entity is invalid.
   */
  public void update(ProductForm pf) {
    pf.isValid();

    try {
      pfMapper.update(pf);
    } catch (DataIntegrityViolationException dive) {
      throw new DataException("error.incorrect.length", dive);
    }
  }