/** * <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 SubaccountLine createEntityWithOwner( final Map<String, Object> pAddParam, final Account pEntityItsOwner) throws Exception { SubaccountLine entity = new SubaccountLine(); entity.setIsNew(true); entity.setItsOwner(pEntityItsOwner); addAccSettingsIntoAttrs(pAddParam); addTypeCodeIntoAttrs(pAddParam); return entity; }
/** * <p>Create entity.</p> * @param pAddParam additional param * @return entity instance * @throws Exception - an exception **/ @Override public final SubaccountLine createEntity( final Map<String, Object> pAddParam) throws Exception { SubaccountLine entity = new SubaccountLine(); entity.setIsNew(true); Account itsOwner = new Account(); entity.setItsOwner(itsOwner); addTypeCodeIntoAttrs(pAddParam); addAccSettingsIntoAttrs(pAddParam); return entity; }
} else { SubaccountLine sal = new SubaccountLine(); sal.setItsOwner(acc); List<SubaccountLine> subaccounts = srvOrm .retrieveListForField(addParam, sal, "itsOwner");
/** * <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 SubaccountLine createEntityWithOwnerById( final Map<String, Object> pAddParam, final Object pIdOwner) throws Exception { SubaccountLine entity = new SubaccountLine(); entity.setIsNew(true); Account itsOwner = getSrvOrm().retrieveEntityById( Account.class, pIdOwner); entity.setSubaccType(itsOwner.getSubaccType()); entity.setItsOwner(itsOwner); addAccSettingsIntoAttrs(pAddParam); addTypeCodeIntoAttrs(pAddParam); return entity; }
/** * <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 pEntity Entity to process * @return Entity processed for farther process or null * @throws Exception - an exception **/ @Override public final SubaccountLine process( final Map<String, Object> pAddParam, final SubaccountLine pEntity, final IRequestData pRequestData) throws Exception { SubaccountLine entity = this.prcAccEntityCreate .process(pAddParam, pEntity, pRequestData); entity.setItsOwner(getSrvOrm() .retrieveEntity(pAddParam, entity.getItsOwner())); pEntity.setSubaccType(entity.getItsOwner().getSubaccType()); pRequestData.setAttribute("typeCodeSubaccMap", this.srvTypeCode.getTypeCodeMap()); return entity; }
/** * <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 SubaccountLine pEntity, final boolean isEntityDetached) throws Exception { Account itsOwner = getSrvOrm().retrieveEntityById( Account.class, pEntity.getItsOwner().getItsId()); pEntity.setItsOwner(itsOwner); if (!pEntity.getSubaccType().equals(pEntity .getItsOwner().getSubaccType())) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "wrong_paramaters"); } if (pEntity.getIsNew()) { getSrvOrm().insertEntity(pEntity); registerSubaccountUsedIfExist(pEntity.getSubaccType(), pEntity.getSubaccId()); } else { getSrvOrm().updateEntity(pEntity); } }