/** * <p> * Synchronize entity (that just read) with entity in database. * It just check if it's new. * </p> * @param pAddParam additional params * @param pEntity object * @return isNew if entity exist in database (need update) * @throws Exception - an exception **/ @Override public final boolean sync(final Map<String, Object> pAddParam, final Object pEntity) throws Exception { Object entityPbDb = getSrvOrm().retrieveEntity(pAddParam, pEntity); return entityPbDb == null; }
/** * <p>Process entity request.</p> * @param pReqVars 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 SalesReturnLine process(final Map<String, Object> pReqVars, final SalesReturnLine pEntityPb, final IRequestData pRequestData) throws Exception { SalesReturnLine entity = this.prcEntityCreate .process(pReqVars, pEntityPb, pRequestData); pReqVars.put("DebtorCreditortaxDestinationdeepLevel", 2); Set<String> ndFlDc = new HashSet<String>(); ndFlDc.add("itsId"); ndFlDc.add("isForeigner"); ndFlDc.add("taxDestination"); pReqVars.put("DebtorCreditorneededFields", ndFlDc); entity.setItsOwner(this.prcEntityCreate.getSrvOrm() .retrieveEntity(pReqVars, entity.getItsOwner())); pReqVars.remove("DebtorCreditorneededFields"); pReqVars.remove("DebtorCreditortaxDestinationdeepLevel"); return entity; }
/** * <p> * Synchronize IHasVersion. * </p> * @param pAddParam additional params * @param pEntity object * @return isNew if entity exist in database (need update) * @throws Exception - an exception **/ @Override public final boolean sync(final Map<String, Object> pAddParam, final Object pEntity) throws Exception { IHasVersion entityPb = (IHasVersion) pEntity; IHasVersion entityPbDb = getSrvOrm().retrieveEntity(pAddParam, entityPb); boolean isNew = true; if (entityPbDb != null) { entityPb.setItsVersion(entityPbDb.getItsVersion()); isNew = false; } return isNew; }
/** * <p>Lazy getter for balanceAtAllDirtyCheck.</p> * @param pAddParam additional param * @return BalanceAtAllDirtyCheck * @throws Exception - an exception **/ public final synchronized BalanceAtAllDirtyCheck lazyGetBalanceAtAllDirtyCheck( final Map<String, Object> pAddParam) throws Exception { if (this.balanceAtAllDirtyCheck == null) { BalanceAtAllDirtyCheck balLoc = new BalanceAtAllDirtyCheck(); balLoc.setItsId(1L); this.balanceAtAllDirtyCheck = getSrvOrm() .retrieveEntity(pAddParam, balLoc); if (this.balanceAtAllDirtyCheck == null) { getSrvOrm().insertEntity(pAddParam, balLoc); balLoc.setIsNew(false); this.balanceAtAllDirtyCheck = getSrvOrm() .retrieveEntity(pAddParam, balLoc); } } return this.balanceAtAllDirtyCheck; }
/** * <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 MatchForeignLine process( final Map<String, Object> pAddParam, final MatchForeignLine pEntityPb, final IRequestData pRequestData) throws Exception { MatchForeignLine entity = this.prcEntityCreate .process(pAddParam, pEntityPb, pRequestData); entity.setItsOwner(this.prcEntityCreate.getSrvOrm() .retrieveEntity(pAddParam, entity.getItsOwner())); 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 CsvColumn process( final Map<String, Object> pAddParam, final CsvColumn pEntityPb, final IRequestData pRequestData) throws Exception { CsvColumn entity = this.prcEntityCreate .process(pAddParam, pEntityPb, pRequestData); entity.setItsOwner(this.prcEntityCreate.getSrvOrm() .retrieveEntity(pAddParam, entity.getItsOwner())); return entity; }
.retrieveEntity(pReqVars, pEntity.getItsOwner())); pReqVars.remove("DebtorCreditortaxDestinationdeepLevel");
.retrieveEntity(pReqVars, pEntity.getItsOwner())); pReqVars.remove("DebtorCreditortaxDestinationdeepLevel");
/** * <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 InvItemTaxCategoryLine process( final Map<String, Object> pAddParam, final InvItemTaxCategoryLine pEntity, final IRequestData pRequestData) throws Exception { // Beige-Orm refresh: pEntity.setItsOwner(getSrvOrm() .retrieveEntity(pAddParam, pEntity.getItsOwner())); // optimistic locking (dirty check): Long ownerVersion = Long.valueOf(pRequestData .getParameter(InvItemTaxCategory.class.getSimpleName() + ".ownerVersion")); pEntity.getItsOwner().setItsVersion(ownerVersion); getSrvOrm().deleteEntity(pAddParam, pEntity); updateInvItemTaxCategory(pAddParam, pEntity.getItsOwner()); pAddParam.put("nextEntity", pEntity.getItsOwner()); pAddParam.put("nameOwnerEntity", InvItemTaxCategory.class.getSimpleName()); return null; }
.equals(pEntity.getCustomer().getItsId())) { pEntity.setCustomer(getSrvOrm() .retrieveEntity(pReqVars, pEntity.getCustomer())); if (pOldEntity.getCustomer().getTaxDestination() != null || pEntity.getCustomer().getTaxDestination() != null) {
.equals(pEntity.getVendor().getItsId())) { pEntity.setVendor(getSrvOrm() .retrieveEntity(pReqVars, pEntity.getVendor())); if (pOldEntity.getVendor().getTaxDestination() != null || pEntity.getVendor().getTaxDestination() != null) {
final AccountingEntries pEntity, final IRequestData pRequestData) throws Exception { AccountingEntries entity = this.srvOrm.retrieveEntity(pAddParam, pEntity); entity.setIsNew(false); pRequestData.setAttribute("entity", entity);
/** * <p>Make save preparations before insert/update block if it's need.</p> * @param pAddParam additional param * @param pEntity entity * @param pRequestData Request Data * @throws Exception - an exception **/ @Override public final void makeFirstPrepareForSave(final Map<String, Object> pAddParam, final PrepaymentFrom pEntity, final IRequestData pRequestData) throws Exception { //BeigeORM refresh: pEntity.setAccCash(getSrvOrm() .retrieveEntity(pAddParam, pEntity.getAccCash())); if (pEntity.getAccCash().getSubaccType() != null && pEntity.getSubaccCashId() == null) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "select_subaccount"); } }
/** * <p>Make save preparations before insert/update block if it's need.</p> * @param pAddParam additional param * @param pEntity entity * @param pRequestData Request Data * @throws Exception - an exception **/ @Override public final void makeFirstPrepareForSave(final Map<String, Object> pAddParam, final PrepaymentTo pEntity, final IRequestData pRequestData) throws Exception { //BeigeORM refresh: pEntity.setAccCash(getSrvOrm() .retrieveEntity(pAddParam, pEntity.getAccCash())); if (pEntity.getAccCash().getSubaccType() != null && pEntity.getSubaccCashId() == null) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "select_subaccount"); } }
"Attempt to double reverse! " + pAddParam.get("user")); T entityReversed = getSrvOrm().retrieveEntity(pAddParam, pEntity); entityReversed.setIsNew(false); Long docId = entityReversed.getItsId();
/** * <p>Make save preparations before insert/update block if it's need.</p> * @param pAddParam additional param * @param pEntity entity * @param pRequestData Request Data * @throws Exception - an exception **/ @Override public final void makeFirstPrepareForSave(final Map<String, Object> pAddParam, final PaymentFrom pEntity, final IRequestData pRequestData) throws Exception { //BeigeORM refresh: pEntity.setAccCash(getSrvOrm() .retrieveEntity(pAddParam, pEntity.getAccCash())); if (pEntity.getAccCash().getSubaccType() != null && pEntity.getSubaccCashId() == null) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "select_subaccount"); } if (pEntity.getSalesInvoice() != null) { SalesInvoice salesInvoice = getSrvOrm() .retrieveEntity(pAddParam, pEntity.getSalesInvoice()); if (!salesInvoice.getHasMadeAccEntries() || salesInvoice.getReversedId() != null) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "sales_invoice_must_be_accounted"); } pEntity.setSalesInvoice(salesInvoice); } }
/** * <p>Make save preparations before insert/update block if it's need.</p> * @param pAddParam additional param * @param pEntity entity * @param pRequestData Request Data * @throws Exception - an exception **/ @Override public final void makeFirstPrepareForSave(final Map<String, Object> pAddParam, final PaymentTo pEntity, final IRequestData pRequestData) throws Exception { //BeigeORM refresh: pEntity.setAccCash(getSrvOrm() .retrieveEntity(pAddParam, pEntity.getAccCash())); if (pEntity.getAccCash().getSubaccType() != null && pEntity.getSubaccCashId() == null) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "select_subaccount"); } if (pEntity.getPurchaseInvoice() != null) { PurchaseInvoice purchaseInvoice = getSrvOrm() .retrieveEntity(pAddParam, pEntity.getPurchaseInvoice()); if (!purchaseInvoice.getHasMadeAccEntries() || purchaseInvoice.getReversedId() != null) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "purchase_invoice_must_be_accounted"); } pEntity.setPurchaseInvoice(purchaseInvoice); } }
/** * <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>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 AccountingEntry process( final Map<String, Object> pAddParam, final AccountingEntry pEntity, final IRequestData pRequestData) throws Exception { if (pEntity.getIsNew()) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "forbidden_operation"); } else { if (pEntity.getIdDatabaseBirth() != getSrvOrm().getIdDatabase()) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "can_not_change_foreign_src"); } AccountingEntry entity = this.srvOrm.retrieveEntity(pAddParam, pEntity); entity.setDescription(pEntity.getDescription()); this.srvOrm.updateEntity(pAddParam, entity); pRequestData.setAttribute("accSettings", this.srvAccSettings.lazyGetAccSettings(pAddParam)); return entity; } }
/** * <p>Retrieve Accounting settings from database.</p> * @param pAddParam additional param * @throws Exception - an exception **/ public final synchronized void retrieveAccSettings( final Map<String, Object> pAddParam) throws Exception { this.accSettings = new AccSettings(); this.accSettings.setItsId(1L); this.accSettings = getSrvOrm().retrieveEntity(pAddParam, this.accSettings); if (this.accSettings == null) { throw new ExceptionWithCode(ExceptionWithCode.CONFIGURATION_MISTAKE, "There is no accounting settings!!!"); } DrawMaterialSourcesLine dmsl = new DrawMaterialSourcesLine(); dmsl.setItsOwner(this.accSettings); List<DrawMaterialSourcesLine> drawMaterialSources = getSrvOrm() .retrieveListForField(pAddParam, dmsl, "itsOwner"); this.accSettings.setDrawMaterialSources(drawMaterialSources); CogsItemSourcesLine cisl = new CogsItemSourcesLine(); cisl.setItsOwner(this.accSettings); List<CogsItemSourcesLine> cogsItemSources = getSrvOrm() .retrieveListForField(pAddParam, cisl, "itsOwner"); this.accSettings.setCogsItemSources(cogsItemSources); AccEntriesSourcesLine aesl = new AccEntriesSourcesLine(); aesl.setItsOwner(this.accSettings); List<AccEntriesSourcesLine> accEntriesSources = getSrvOrm() .retrieveListForField(pAddParam, aesl, "itsOwner"); this.accSettings.setAccEntriesSources(accEntriesSources); }