if (parameterMap.get("actionAdd") != null && "reverse".equals(parameterMap.get("actionAdd")[0])) { if (entity.getReversedId() != null) { throw new ExceptionWithCode(ExceptionWithCode.FORBIDDEN, "attempt_to_reverse_reversed::" + pAddParam.get("user"));
/** * <p>Process entity request.</p> * @param pAddParam additional param, e.g. return this line's * document in "nextEntity" for farther process * @param pRequestData Request Data * @param pEntityPb Entity to process * @return Entity processed for farther process or null * @throws Exception - an exception **/ @Override public final UsedMaterialLine process( final Map<String, Object> pAddParam, final UsedMaterialLine pEntityPb, final IRequestData pRequestData) throws Exception { UsedMaterialLine entity = this.prcAccEntityPbCopy .process(pAddParam, pEntityPb, pRequestData); if (entity.getReversedId() != null) { throw new ExceptionWithCode(ExceptionWithCode.FORBIDDEN, "attempt_to_reverse_reversed"); } entity.setReversedId(pEntityPb.getItsId()); entity.setItsQuantity(entity.getItsQuantity().negate()); entity.setItsTotal(entity.getItsTotal().negate()); return entity; }
if (pEntity.getIsNew()) { if (pEntity.getItsQuantity().doubleValue() <= 0 && pEntity.getReversedId() == null) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "quantity_less_or_equal_zero::" + pAddParam.get("user")); getSrvOrm().insertEntity(pEntity); pEntity.setItsOwner(itsOwner); if (pEntity.getReversedId() != null) { UsedMaterialLine reversed = getSrvOrm().retrieveEntityById( UsedMaterialLine.class, pEntity.getReversedId()); if (reversed.getReversedId() != null) { throw new ExceptionWithCode(ExceptionWithCode.FORBIDDEN, "attempt_to_reverse_reversed::" + pAddParam.get("user"));
&& pEntity.getReversedId() == null) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "quantity_less_or_equal_zero::" + pAddParam.get("user")); pEntity.setIsNew(false); pEntity.setItsOwner(pEntity.getItsOwner()); if (pEntity.getReversedId() != null) { UsedMaterialLine reversed = getSrvOrm().retrieveEntityById( pAddParam, UsedMaterialLine.class, pEntity.getReversedId()); if (reversed.getReversedId() != null) { throw new ExceptionWithCode(ExceptionWithCode.FORBIDDEN, "attempt_to_reverse_reversed::" + pAddParam.get("user"));
ManufacturingProcess.class, reversed.getItsId()); for (UsedMaterialLine reversedLine : reversedMaterials) { if (reversedLine.getReversedId() == null) { UsedMaterialLine reversingLine = new UsedMaterialLine(); reversingLine.setIdDatabaseBirth(getSrvOrm().getIdDatabase());
String langDef = (String) pAddParam.get("langDef"); for (UsedMaterialLine reversedLine : reversedMaterials) { if (reversedLine.getReversedId() == null) { UsedMaterialLine reversingLine = new UsedMaterialLine(); reversingLine.setIdDatabaseBirth(getSrvOrm().getIdDatabase());