/** * <p>Create entity with its itsOwner e.g. invoice line * for invoice.</p> * @param pAddParam additional param * @param pEntityItsOwner itsOwner * @return entity instance * @throws Exception - an exception **/ @Override public final AdditionCostLine createEntityWithOwner( final Map<String, Object> pAddParam, final ManufacturingProcess pEntityItsOwner) throws Exception { AdditionCostLine entity = new AdditionCostLine(); entity.setIsNew(true); entity.setIdDatabaseBirth(getSrvOrm().getIdDatabase()); entity.setItsOwner(pEntityItsOwner); addAccSettingsIntoAttrs(pAddParam); addTypeCodeIntoAttrs(pAddParam); return entity; }
final IRequestData pRequestData) throws Exception { pEntity.setItsOwner(getSrvOrm() .retrieveEntity(pAddParam, pEntity.getItsOwner())); pEntity.getItsOwner().setItsVersion(ownerVersion); if (pEntity.getItsOwner().getHasMadeAccEntries()) { throw new ExceptionWithCode(ExceptionWithCode.FORBIDDEN, "attempt_to_change_accounted_document"); if (pEntity.getItsOwner().getIsComplete()) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "attempt_to_change_completed_manufacturing_process"); if (pEntity.getIsNew()) { getSrvOrm().insertEntity(pAddParam, pEntity); pEntity.setIsNew(false); } else { getSrvOrm().updateEntity(pAddParam, pEntity); pAddParam.put("nextEntity", pEntity.getItsOwner()); pAddParam.put("nameOwnerEntity", ManufacturingProcess.class.getSimpleName());
/** * <p>Delete entity from DB.</p> * @param pAddParam additional param * @param pEntity entity * @throws Exception - an exception **/ @Override public final void deleteEntity(final Map<String, Object> pAddParam, final AdditionCostLine pEntity) throws Exception { if (pEntity.getItsOwner().getInvItem() == null) { ManufacturingProcess itsOwner = getSrvOrm().retrieveEntityById( ManufacturingProcess.class, pEntity.getItsOwner().getItsId()); pEntity.setItsOwner(itsOwner); } if (pEntity.getItsOwner().getIsComplete()) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "attempt_to_change_completed_manufacturing_process"); } getSrvOrm().deleteEntity(AdditionCostLine.class, pEntity.getItsId()); updateOwner(pEntity); }
AdditionCostLine acl = new AdditionCostLine(); acl.setItsOwner(reversed); List<AdditionCostLine> reversedAcl = getSrvOrm(). retrieveListForField(pAddParam, acl, "itsOwner"); for (AdditionCostLine reversedLine : reversedAcl) { if (reversedLine.getReversedId() == null) { AdditionCostLine reversingLine = new AdditionCostLine(); reversingLine.setIdDatabaseBirth(getSrvOrm().getIdDatabase()); reversingLine.setReversedId(reversedLine.getItsId()); reversingLine.setSubaccExpense(reversedLine.getSubaccExpense()); reversingLine.setSubaccExpenseId(reversedLine.getSubaccExpenseId()); reversingLine.setSubaccExpenseType(reversedLine .getSubaccExpenseType()); reversingLine.setAccExpense(reversedLine.getAccExpense()); reversingLine.setItsTotal(reversedLine.getItsTotal().negate()); reversingLine.setIsNew(true); reversingLine.setItsOwner(pEntity); reversingLine.setDescription(getSrvI18n() .getMsg("reversed_n", langDef) + reversedLine.getIdDatabaseBirth() + "-" + reversedLine.getItsId()); //local getSrvOrm().insertEntity(pAddParam, reversingLine); reversingLine.setIsNew(false); String descr; if (reversedLine.getDescription() == null) { descr = ""; } else { descr = reversedLine.getDescription(); reversedLine.setDescription(descr
/** * <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 AdditionCostLine pEntity, final boolean isEntityDetached) throws Exception { if (pEntity.getItsTotal().doubleValue() == 0d) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "total_is_0"); } ManufacturingProcess itsOwner = getSrvOrm().retrieveEntityById( ManufacturingProcess.class, pEntity.getItsOwner().getItsId()); if (itsOwner.getIsComplete()) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "attempt_to_change_completed_manufacturing_process"); } pEntity.setItsOwner(itsOwner); if (pEntity.getIsNew()) { getSrvOrm().insertEntity(pEntity); } else { getSrvOrm().updateEntity(pEntity); } updateOwner(pEntity); }
final AdditionCostLine pEntity, final IRequestData pRequestData) throws Exception { if (!pEntity.getIdDatabaseBirth().equals(getSrvOrm().getIdDatabase())) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "can_not_change_foreign_src"); pEntity.setItsOwner(getSrvOrm() .retrieveEntity(pAddParam, pEntity.getItsOwner())); pEntity.getItsOwner().setItsVersion(ownerVersion); if (pEntity.getItsOwner().getIsComplete()) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "attempt_to_change_completed_manufacturing_process"); if (pEntity.getItsOwner().getHasMadeAccEntries()) { throw new ExceptionWithCode(ExceptionWithCode.FORBIDDEN, "attempt_to_change_accounted_document"); pAddParam.put("nextEntity", pEntity.getItsOwner()); pAddParam.put("nameOwnerEntity", ManufacturingProcess.class.getSimpleName());
/** * <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 AdditionCostLine retrieveCopyEntity( final Map<String, Object> pAddParam, final Object pId) throws Exception { AdditionCostLine entity = getSrvOrm().retrieveCopyEntity( AdditionCostLine.class, pId); entity.setIdDatabaseBirth(getSrvOrm().getIdDatabase()); entity.setIsNew(true); addTypeCodeIntoAttrs(pAddParam); addAccSettingsIntoAttrs(pAddParam); return entity; }
/** * <p>Delete entity from DB by given ID.</p> * @param pAddParam additional param * @param pId ID * @throws Exception - an exception **/ @Override public final void deleteEntity(final Map<String, Object> pAddParam, final Object pId) throws Exception { AdditionCostLine entity = getSrvOrm() .retrieveEntityById(AdditionCostLine.class, pId); if (entity.getItsOwner().getIsComplete()) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "attempt_to_change_completed_manufacturing_process"); } getSrvOrm().deleteEntity(AdditionCostLine.class, entity.getItsId()); updateOwner(entity); }
/** * <p>Insert immutable line into DB.</p> * @param pEntity entity * @throws Exception - an exception **/ public final void updateOwner( final AdditionCostLine pEntity) throws Exception { String query = "select sum(ITSTOTAL) as ITSTOTAL from" + " ADDITIONCOSTLINE where ITSOWNER=" + pEntity.getItsOwner().getItsId(); Double total = getSrvDatabase().evalDoubleResult(query, "ITSTOTAL"); pEntity.getItsOwner().setTotalAdditionCost(BigDecimal.valueOf(total)); pEntity.getItsOwner().setItsTotal(pEntity.getItsOwner() .getTotalMaterialsCost().add(pEntity.getItsOwner() .getTotalAdditionCost())); pEntity.getItsOwner().setItsCost(pEntity.getItsOwner().getItsTotal() .divide(pEntity.getItsOwner().getItsQuantity(), getSrvAccSettings().lazyGetAccSettings().getCostPrecision(), getSrvAccSettings().lazyGetAccSettings().getRoundingMode())); getSrvOrm().updateEntity(pEntity.getItsOwner()); }
/** * <p>Refresh entity from DB by given entity with ID.</p> * @param pEntity entity * @return entity or null * @throws Exception - an exception **/ @Override public final AdditionCostLine retrieveEntity( final Map<String, Object> pAddParam, final AdditionCostLine pEntity) throws Exception { addAccSettingsIntoAttrs(pAddParam); addTypeCodeIntoAttrs(pAddParam); return getSrvOrm().retrieveEntityById(getEntityClass(), pEntity.getItsId()); }
/** * <p>Insert immutable line into DB.</p> * @param pAddParam additional param * @param pEntity entity * @throws Exception - an exception **/ public final void updateOwner(final Map<String, Object> pAddParam, final AdditionCostLine pEntity) throws Exception { String query = "select sum(ITSTOTAL) as ITSTOTAL from" + " ADDITIONCOSTLINE where ITSOWNER=" + pEntity.getItsOwner().getItsId(); Double total = getSrvDatabase().evalDoubleResult(query, "ITSTOTAL"); pEntity.getItsOwner().setTotalAdditionCost(BigDecimal.valueOf(total) .setScale(getSrvAccSettings().lazyGetAccSettings(pAddParam).getCostPrecision(), getSrvAccSettings().lazyGetAccSettings(pAddParam).getRoundingMode())); pEntity.getItsOwner().setItsTotal(pEntity.getItsOwner() .getTotalMaterialsCost().add(pEntity.getItsOwner() .getTotalAdditionCost()).setScale(getSrvAccSettings() .lazyGetAccSettings(pAddParam).getCostPrecision(), getSrvAccSettings().lazyGetAccSettings(pAddParam).getRoundingMode())); pEntity.getItsOwner().setItsCost(pEntity.getItsOwner().getItsTotal() .divide(pEntity.getItsOwner().getItsQuantity(), getSrvAccSettings().lazyGetAccSettings(pAddParam).getCostPrecision(), getSrvAccSettings().lazyGetAccSettings(pAddParam).getRoundingMode())); getSrvOrm().updateEntity(pAddParam, pEntity.getItsOwner()); }
/** * <p>Create entity.</p> * @param pAddParam additional param * @return entity instance * @throws Exception - an exception **/ @Override public final AdditionCostLine createEntity( final Map<String, Object> pAddParam) throws Exception { AdditionCostLine entity = new AdditionCostLine(); entity.setIdDatabaseBirth(getSrvOrm().getIdDatabase()); entity.setIsNew(true); ManufacturingProcess itsOwner = new ManufacturingProcess(); entity.setItsOwner(itsOwner); addTypeCodeIntoAttrs(pAddParam); addAccSettingsIntoAttrs(pAddParam); return entity; }
/** * <p>Insert immutable line into DB.</p> * @param pAddParam additional param * @param pEntity entity * @throws Exception - an exception **/ public final void updateOwner(final Map<String, Object> pAddParam, final AdditionCostLine pEntity) throws Exception { String query = "select sum(ITSTOTAL) as ITSTOTAL from" + " ADDITIONCOSTLINE where ITSOWNER=" + pEntity.getItsOwner().getItsId(); Double total = getSrvDatabase().evalDoubleResult(query, "ITSTOTAL"); pEntity.getItsOwner().setTotalAdditionCost(BigDecimal.valueOf(total) .setScale(getSrvAccSettings().lazyGetAccSettings(pAddParam).getCostPrecision(), getSrvAccSettings().lazyGetAccSettings(pAddParam).getRoundingMode())); pEntity.getItsOwner().setItsTotal(pEntity.getItsOwner() .getTotalMaterialsCost().add(pEntity.getItsOwner() .getTotalAdditionCost()).setScale(getSrvAccSettings() .lazyGetAccSettings(pAddParam).getCostPrecision(), getSrvAccSettings().lazyGetAccSettings(pAddParam).getRoundingMode())); pEntity.getItsOwner().setItsCost(pEntity.getItsOwner().getItsTotal() .divide(pEntity.getItsOwner().getItsQuantity(), getSrvAccSettings().lazyGetAccSettings(pAddParam).getCostPrecision(), getSrvAccSettings().lazyGetAccSettings(pAddParam).getRoundingMode())); getSrvOrm().updateEntity(pAddParam, pEntity.getItsOwner()); }
/** * <p>Create entity with its itsOwner e.g. invoice line * for invoice.</p> * @param pAddParam additional param * @param pIdEntityItsOwner entity itsOwner ID * @return entity instance * @throws Exception - an exception **/ @Override public final AdditionCostLine createEntityWithOwnerById( final Map<String, Object> pAddParam, final Object pIdEntityItsOwner) throws Exception { AdditionCostLine entity = new AdditionCostLine(); entity.setIdDatabaseBirth(getSrvOrm().getIdDatabase()); entity.setIsNew(true); ManufacturingProcess itsOwner = new ManufacturingProcess(); itsOwner.setItsId(Long.valueOf(pIdEntityItsOwner.toString())); entity.setItsOwner(itsOwner); addAccSettingsIntoAttrs(pAddParam); addTypeCodeIntoAttrs(pAddParam); return entity; }