/** * <p>Save entity 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 AccountingEntries pEntity, final boolean isEntityDetached) throws Exception { if (!pEntity.getIdDatabaseBirth() .equals(getSrvOrm().getIdDatabase())) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "can_not_change_foreign_src"); } if (pEntity.getIsNew()) { getSrvOrm().insertEntity(pEntity); } else { getSrvOrm().updateEntity(pEntity); } }
/** * <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 AccountingEntry createEntityWithOwner( final Map<String, Object> pAddParam, final AccountingEntries pEntityItsOwner) throws Exception { if (!pEntityItsOwner.getIdDatabaseBirth() .equals(getSrvOrm().getIdDatabase())) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "can_not_make_entry_for_foreign_src"); } AccountingEntry entity = new AccountingEntry(); entity.setIsNew(true); entity.setItsDate(new Date()); entity.setSourceId(pEntityItsOwner.getItsId()); entity.setSourceType(this.accountingEntriesTypeCode); addAccSettingsIntoAttrs(pAddParam); return entity; }
AccountingEntries doc = getSrvOrm().retrieveEntityById(pAddParam, AccountingEntries.class, pEntity.getSourceId()); if (!doc.getIdDatabaseBirth() .equals(getSrvOrm().getIdDatabase())) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, pEntity.setItsDate(new Date()); pEntity.setSourceType(this.accountingEntriesTypeCode); pEntity.setSourceDatabaseBirth(doc.getIdDatabaseBirth()); String docDescription; if (doc.getDescription() != null) { DateFormat.MEDIUM, DateFormat.SHORT, new Locale(langDef)); pEntity.setDescription(getSrvI18n().getMsg(AccountingEntries.class .getSimpleName() + "short", langDef) + " #" + doc.getIdDatabaseBirth() + "-" + doc.getItsId() + ", " + dateFormat.format(doc.getItsDate()) + ". " + docDescription); //only local allowed
AccountingEntries doc = getSrvOrm().retrieveEntityById( AccountingEntries.class, pIdOwner); if (!doc.getIdDatabaseBirth() .equals(getSrvOrm().getIdDatabase())) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, entity.setSourceType(this.accountingEntriesTypeCode); entity.setDescription(getSrvI18n().getMsg(AccountingEntries.class .getSimpleName() + "short") + " #" + doc.getIdDatabaseBirth() + "-" + doc.getItsId() + ", " + getDateFormatter().format(doc.getItsDate()) + ". " + doc.getDescription()); //only local allowed
AccountingEntries doc = getSrvOrm().retrieveEntityById(pAddParam, AccountingEntries.class, entity.getSourceId()); if (!doc.getIdDatabaseBirth() .equals(getSrvOrm().getIdDatabase())) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, DateFormat.MEDIUM, DateFormat.SHORT, new Locale(langDef)); entity.setDescription(getSrvI18n().getMsg(AccountingEntries.class .getSimpleName() + "short", langDef) + " #" + doc.getIdDatabaseBirth() + "-" + doc.getItsId() + ", " + dateFormat.format(doc.getItsDate()) + ". " + docDescription); //only local allowed