/** * <p>Retrieve copy of entity from DB by given ID.</p> * @param pAddParam additional param * @param pId ID * @return entity or null * @throws Exception - an exception **/ @Override public final MoveItemsLine retrieveCopyEntity( final Map<String, Object> pAddParam, final Object pId) throws Exception { MoveItemsLine entity = getSrvOrm().retrieveCopyEntity( MoveItemsLine.class, pId); @SuppressWarnings("unchecked") Map<String, String[]> parameterMap = (Map<String, String[]>) pAddParam. get("parameterMap"); if (parameterMap.get("actionAdd") != null && "reverse".equals(parameterMap.get("actionAdd")[0])) { throw new ExceptionWithCode(ExceptionWithCode.FORBIDDEN, "reverse_not_supported"); } entity.setItsQuantity(BigDecimal.ZERO); entity.setIsNew(true); addAccSettingsIntoAttrs(pAddParam); return entity; }
pEntity.setItsQuantity(pEntity.getItsQuantity().setScale( accSettings.getQuantityPrecision(), accSettings.getRoundingMode()));
/** * <p>Insert immutable line into DB.</p> * @param pAddParam additional param * @param pEntity entity * @param isEntityDetached ignored * @throws Exception - an exception **/ @Override public final void saveEntity(final Map<String, Object> pAddParam, final MoveItemsLine pEntity, final boolean isEntityDetached) throws Exception { if (pEntity.getIsNew()) { if (pEntity.getItsQuantity().doubleValue() <= 0) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "quantity_less_or_equal_zero"); } pEntity.setItsQuantity(pEntity.getItsQuantity().setScale( getSrvAccSettings().lazyGetAccSettings().getQuantityPrecision(), getSrvAccSettings().lazyGetAccSettings().getRoundingMode())); getSrvOrm().insertEntity(pEntity); MoveItems itsOwner = getSrvOrm().retrieveEntityById( MoveItems.class, pEntity.getItsOwner().getItsId()); pEntity.setItsOwner(itsOwner); srvWarehouseEntry.move(pAddParam, pEntity, pEntity .getWarehouseSiteFrom(), pEntity.getWarehouseSiteTo()); } else { throw new ExceptionWithCode(ExceptionWithCode.FORBIDDEN, "edit_not_allowed"); } }