/** * <p>Get SrvWarehouseEntry in lazy mode.</p> * @return SrvWarehouseEntry - SrvWarehouseEntry * @throws Exception - an exception */ public final synchronized SrvWarehouseEntry<RS> lazyGetSrvWarehouseEntry() throws Exception { if (this.srvWarehouseEntry == null) { this.srvWarehouseEntry = new SrvWarehouseEntry<RS>(factoryAppBeans.lazyGetSrvOrm(), lazyGetSrvTypeCodeAccSources(), factoryAppBeans.lazyGetSrvI18n(), lazyGetEntryDateFormatter()); } return this.srvWarehouseEntry; }
/** * <p>Make description for warehouse entry.</p> * @param pEntity movement * @return description **/ public final String makeDescription(final IMakingWarehouseEntry pEntity) { String strWho = getSrvI18n().getMsg(pEntity.getClass().getSimpleName() + "short") + " #" + getSrvOrm().getIdDatabase() + "-" + pEntity.getItsId(); //only local if (pEntity.getOwnerId() == null) { strWho += ", " + getDateFormatter().format(pEntity .getDocumentDate()); } else { strWho += " " + getSrvI18n().getMsg("in") + " " + getSrvI18n() .getMsg(getSrvTypeCodeDocuments().getTypeCodeMap().get(pEntity .getOwnerType()).getSimpleName() + "short") + " #" + getSrvOrm() .getIdDatabase() + "-" + pEntity.getOwnerId() + ", " + getDateFormatter().format(pEntity.getDocumentDate()); } return getSrvI18n().getMsg("made_at") + " " + getDateFormatter().format( new Date()) + " " + getSrvI18n().getMsg("by") + " " + strWho; }
+ " and " + tblNm + ".IDDATABASEBIRTH=" + getSrvOrm().getIdDatabase() + " and SOURCEID=" + pEntity.getItsId(); result = getSrvOrm().retrieveListWithConditions(pAddParam, WarehouseEntry.class, where); result = retrieveEntriesForOwner(pAddParam, pEntity.constTypeCode(), pEntity.getItsId()); } else { result.addAll(retrieveEntriesForOwner(pAddParam, pEntity.constTypeCode(), pEntity.getItsId()));
/** * <p>Make description for warehouse entry.</p> * @param pEntity movement * @param pLangDef Lang Default * @param pDateFormat DateFormat * @return description **/ public final String makeDescription(final IMakingWarehouseEntry pEntity, final String pLangDef, final DateFormat pDateFormat) { String strWho = getSrvI18n().getMsg(pEntity.getClass().getSimpleName() + "short", pLangDef) + " #" + getSrvOrm().getIdDatabase() + "-" + pEntity.getItsId(); //only local if (pEntity.getOwnerId() == null) { strWho += ", " + pDateFormat.format(pEntity .getDocumentDate()); } else { strWho += " " + getSrvI18n().getMsg("in", pLangDef) + " " + getSrvI18n() .getMsg(getSrvTypeCodeDocuments().getTypeCodeMap().get(pEntity .getOwnerType()).getSimpleName() + "short", pLangDef) + " #" + getSrvOrm() .getIdDatabase() + "-" + pEntity.getOwnerId() + ", " + pDateFormat.format(pEntity.getDocumentDate()); } return getSrvI18n().getMsg("made_at", pLangDef) + " " + pDateFormat.format( new Date()) + " " + getSrvI18n().getMsg("by", pLangDef) + " " + strWho; }
final WarehouseSite pWhSiteTo) throws Exception { if (!pEntity.getIdDatabaseBirth() .equals(getSrvOrm().getIdDatabase())) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "can_not_make_ws_entry_for_foreign_src"); if (pEntity.getReversedId() != null) { String tblNm = WarehouseEntry.class.getSimpleName().toUpperCase(); wms = getSrvOrm().retrieveEntityWithConditions(pAddParam, WarehouseEntry.class, " where SOURCETYPE=" + pEntity.constTypeCode() + " and SOURCEID=" + pEntity.getReversedId() + " and " + tblNm + ".IDDATABASEBIRTH=" + getSrvOrm() .getIdDatabase() + " and WAREHOUSESITETO=" + pWhSiteTo.getItsId() + " and INVITEM=" + pEntity.getInvItem() DateFormat.MEDIUM, DateFormat.SHORT, new Locale(langDef)); WarehouseEntry wm = new WarehouseEntry(); wm.setIdDatabaseBirth(getSrvOrm().getIdDatabase()); wm.setSourceId(pEntity.getItsId()); wm.setSourceType(pEntity.constTypeCode()); if (wms != null) { wm.setReversedId(wms.getItsId()); wm.setDescription(makeDescription(pEntity, langDef, dateFormat) + " " + getSrvI18n().getMsg("reversed_entry_n", langDef) + getSrvOrm() .getIdDatabase() + "-" + wms.getItsId()); //only local } else { wm.setDescription(makeDescription(pEntity, langDef, dateFormat));
final WarehouseSite pWhSiteFrom) throws Exception { if (!pEntity.getIdDatabaseBirth() .equals(getSrvOrm().getIdDatabase())) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "can_not_make_ws_entry_for_foreign_src"); DateFormat.MEDIUM, DateFormat.SHORT, new Locale(langDef)); if (pWhSiteFrom != null) { WarehouseRest wr = getSrvOrm().retrieveEntityWithConditions(pAddParam, WarehouseRest.class, "where THEREST>0 and INVITEM=" + pEntity.getInvItem().getItsId() + " and UNITOFMEASURE=" getSrvOrm().updateEntity(pAddParam, wr); WarehouseEntry wm = new WarehouseEntry(); wm.setIdDatabaseBirth(getSrvOrm().getIdDatabase()); wm.setSourceId(pEntity.getItsId()); wm.setSourceType(pEntity.constTypeCode()); wm.setSourceOwnerId(pEntity.getOwnerId()); wm.setSourceOwnerType(pEntity.getOwnerType()); wm.setDescription(makeDescription(pEntity, langDef, dateFormat)); getSrvOrm().insertEntity(pAddParam, wm); wm.setIsNew(false); } else { List<WarehouseRest> wrl = getSrvOrm().retrieveListWithConditions( pAddParam, WarehouseRest.class, "where THEREST>0 and INVITEM=" + pEntity.getInvItem().getItsId() + " and UNITOFMEASURE=" getSrvOrm().updateEntity(pAddParam, wr);
/** * <p>Retrieve entries for lines owner id/type.</p> * @param pAddParam additional param * @param pOwnerTypeCode Owner Type code * @param pOwnerId Owner ID * @return warehouse entries made by this document * @throws Exception - an exception **/ @Override public final List<WarehouseEntry> retrieveEntriesForOwner( final Map<String, Object> pAddParam, final Integer pOwnerTypeCode, final Long pOwnerId) throws Exception { String tblNm = WarehouseEntry.class.getSimpleName().toUpperCase(); String where = " where SOURCEOWNERTYPE=" + pOwnerTypeCode + " and " + tblNm + ".IDDATABASEBIRTH=" + getSrvOrm().getIdDatabase() + " and SOURCEOWNERID=" + pOwnerId; return getSrvOrm() .retrieveListWithConditions(pAddParam, WarehouseEntry.class, where); }
WarehouseEntry wms = null; if (!pEntity.getIdDatabaseBirth() .equals(getSrvOrm().getIdDatabase())) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "can_not_make_ws_entry_for_foreign_src"); wms = getSrvOrm().retrieveEntityWithConditions(pAddParam, WarehouseEntry.class, " where SOURCETYPE=" + pEntity.constTypeCode() + " and " + tblNm + ".IDDATABASEBIRTH=" + getSrvOrm().getIdDatabase() + " and SOURCEID=" + pEntity.getReversedId()); if (wms == null) { DateFormat.MEDIUM, DateFormat.SHORT, new Locale(langDef)); WarehouseEntry wm = new WarehouseEntry(); wm.setIdDatabaseBirth(getSrvOrm().getIdDatabase()); wm.setSourceId(pEntity.getItsId()); wm.setSourceType(pEntity.constTypeCode()); if (wms != null) { wm.setReversedId(wms.getItsId()); wm.setDescription(makeDescription(pEntity, langDef, dateFormat) + " " + getSrvI18n().getMsg("reversed_entry_n", langDef) + getSrvOrm() .getIdDatabase() + "-" + wms.getItsId()); //only local } else { wm.setDescription(makeDescription(pEntity, langDef, dateFormat)); getSrvOrm().insertEntity(pAddParam, wm); wm.setIsNew(false); makeWarehouseRest(pAddParam, pEntity, pWhSiteFrom,
final WarehouseSite pWhSiteFrom) throws Exception { if (!pEntity.getIdDatabaseBirth() .equals(getSrvOrm().getIdDatabase())) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "can_not_make_ws_entry_for_foreign_src"); WarehouseRest wr = getSrvOrm().retrieveEntityWithConditions( WarehouseRest.class, "where THEREST>0 and INVITEM=" + pEntity.getInvItem().getItsId() + " and UNITOFMEASURE=" + " and UNITOFMEASURE=" + wr.getUnitOfMeasure().getItsId() + " and WAREHOUSESITE=" + pWhSiteFrom.getItsId(); getSrvOrm().updateEntityWhere(wr, where); WarehouseEntry wm = new WarehouseEntry(); wm.setIdDatabaseBirth(getSrvOrm().getIdDatabase()); wm.setSourceId(pEntity.getItsId()); wm.setSourceType(pEntity.constTypeCode()); wm.setSourceOwnerId(pEntity.getOwnerId()); wm.setSourceOwnerType(pEntity.getOwnerType()); wm.setDescription(makeDescription(pEntity)); getSrvOrm().insertEntity(wm); } else { List<WarehouseRest> wrl = getSrvOrm().retrieveListWithConditions( WarehouseRest.class, "where THEREST>0 and INVITEM=" + pEntity.getInvItem().getItsId() + " and UNITOFMEASURE=" + " and WAREHOUSESITE=" + wr.getWarehouseSite().getItsId() + " and UNITOFMEASURE=" + wr.getUnitOfMeasure().getItsId();
+ " and " + tblNm + ".IDDATABASEBIRTH=" + getSrvOrm().getIdDatabase() + " and SOURCEID=" + pEntity.getItsId(); result = getSrvOrm().retrieveListWithConditions(WarehouseEntry.class, where); + " and " + tblNm + ".IDDATABASEBIRTH=" + getSrvOrm().getIdDatabase() + " and SOURCEOWNERID=" + pEntity.getItsId(); if (result == null) { result = getSrvOrm().retrieveListWithConditions(WarehouseEntry.class, where); } else { result.addAll(getSrvOrm().retrieveListWithConditions( WarehouseEntry.class, where));
WarehouseEntry wms = null; if (!pEntity.getIdDatabaseBirth() .equals(getSrvOrm().getIdDatabase())) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "can_not_make_ws_entry_for_foreign_src"); wms = getSrvOrm().retrieveEntityWithConditions(WarehouseEntry.class, " where SOURCETYPE=" + pEntity.constTypeCode() + " and " + tblNm + ".IDDATABASEBIRTH=" + getSrvOrm().getIdDatabase() + " and SOURCEID=" + pEntity.getReversedId()); if (wms == null) { wm.setIdDatabaseBirth(getSrvOrm().getIdDatabase()); wm.setSourceId(pEntity.getItsId()); wm.setSourceType(pEntity.constTypeCode()); if (wms != null) { wm.setReversedId(wms.getItsId()); wm.setDescription(makeDescription(pEntity) + " " + getSrvI18n() .getMsg("reversed_entry_n") + getSrvOrm().getIdDatabase() + "-" + wms.getItsId()); //only local } else { wm.setDescription(makeDescription(pEntity)); getSrvOrm().insertEntity(wm); makeWarehouseRest(pAddParam, pEntity, pWhSiteFrom, pEntity.getItsQuantity().negate()); makeWarehouseRest(pAddParam, pEntity, pWhSiteTo, pEntity.getItsQuantity()); if (wms != null) {
final BigDecimal pQuantity) throws Exception { if (!pEntity.getIdDatabaseBirth() .equals(getSrvOrm().getIdDatabase())) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "can_not_make_ws_entry_for_foreign_src"); WarehouseRest wr = getSrvOrm().retrieveEntityWithConditions(pAddParam, WarehouseRest.class, "where WAREHOUSESITE=" + pWhSite.getItsId() + " and INVITEM=" getSrvOrm().insertEntity(pAddParam, wr); wr.setIsNew(false); } else { getSrvOrm().updateEntity(pAddParam, wr);
/** * <p>Get SrvWarehouseEntry in lazy mode.</p> * @return SrvWarehouseEntry - SrvWarehouseEntry * @throws Exception - an exception */ public final SrvWarehouseEntry<RS> lazyGetSrvWarehouseEntry() throws Exception { String beanName = getSrvWarehouseEntryName(); @SuppressWarnings("unchecked") SrvWarehouseEntry<RS> srvWarehouseEntry = (SrvWarehouseEntry<RS>) this.factoryAppBeans.getBeansMap().get(beanName); if (srvWarehouseEntry == null) { srvWarehouseEntry = new SrvWarehouseEntry<RS>(this.factoryAppBeans.lazyGetSrvOrm(), lazyGetSrvTypeCodeAccSources(), this.factoryAppBeans.lazyGetSrvI18n()); this.factoryAppBeans.getBeansMap().put(beanName, srvWarehouseEntry); this.factoryAppBeans.lazyGetLogger().info(null, FactoryAccServices.class, beanName + " has been created."); } return srvWarehouseEntry; }
final IMakingWarehouseEntry pEntity) throws Exception { if (!pEntity.getIdDatabaseBirth() .equals(getSrvOrm().getIdDatabase())) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "can_not_make_ws_entry_for_foreign_src"); List<WarehouseEntry> wml = getSrvOrm().retrieveListWithConditions( pAddParam, WarehouseEntry.class, "where SOURCETYPE=" + pEntity .constTypeCode() + " and " + tblNm + ".IDDATABASEBIRTH=" + getSrvOrm() .getIdDatabase() + " and SOURCEID=" + pEntity.getReversedId() + " and INVITEM=" + pEntity.getInvItem().getItsId() wm.setIdDatabaseBirth(getSrvOrm().getIdDatabase()); wm.setSourceId(pEntity.getItsId()); wm.setSourceType(pEntity.constTypeCode()); wm.setSourceOwnerType(pEntity.getOwnerType()); wm.setReversedId(wms.getItsId()); wm.setDescription(makeDescription(pEntity, langDef, dateFormat) + " " + getSrvI18n().getMsg("reversed_entry_n", langDef) + getSrvOrm() .getIdDatabase() + "-" + wms.getItsId()); getSrvOrm().insertEntity(pAddParam, wm); wm.setIsNew(false); makeWarehouseRest(pAddParam, pEntity, wm.getWarehouseSiteFrom(), wms.getItsQuantity()); wms.setReversedId(wm.getItsId()); wms.setDescription(wms.getDescription() + " " + getSrvI18n() .getMsg("reversing_entry_n", langDef) + getSrvOrm().getIdDatabase() + "-" + wm.getItsId());
final BigDecimal pQuantity) throws Exception { if (!pEntity.getIdDatabaseBirth() .equals(getSrvOrm().getIdDatabase())) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "can_not_make_ws_entry_for_foreign_src"); WarehouseRest wr = getSrvOrm().retrieveEntityWithConditions( WarehouseRest.class, "where WAREHOUSESITE=" + pWhSite.getItsId() + " and INVITEM=" getSrvOrm().insertEntity(wr); } else { String where = "INVITEM=" + wr.getInvItem().getItsId() + " and WAREHOUSESITE=" + wr.getWarehouseSite().getItsId() + " and UNITOFMEASURE=" + wr.getUnitOfMeasure().getItsId(); getSrvOrm().updateEntityWhere(wr, where);
final IMakingWarehouseEntry pEntity) throws Exception { if (!pEntity.getIdDatabaseBirth() .equals(getSrvOrm().getIdDatabase())) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "can_not_make_ws_entry_for_foreign_src"); List<WarehouseEntry> wml = getSrvOrm().retrieveListWithConditions( WarehouseEntry.class, "where SOURCETYPE=" + pEntity.constTypeCode() + " and " + tblNm + ".IDDATABASEBIRTH=" + getSrvOrm().getIdDatabase() + " and SOURCEID=" + pEntity.getReversedId() + " and INVITEM=" + pEntity.getInvItem().getItsId() wm.setIdDatabaseBirth(getSrvOrm().getIdDatabase()); wm.setSourceId(pEntity.getItsId()); wm.setSourceType(pEntity.constTypeCode()); wm.setSourceOwnerType(pEntity.getOwnerType()); wm.setReversedId(wms.getItsId()); wm.setDescription(makeDescription(pEntity) + " " + getSrvI18n() .getMsg("reversed_entry_n") + getSrvOrm().getIdDatabase() + "-" + wms.getItsId()); getSrvOrm().insertEntity(wm); makeWarehouseRest(pAddParam, pEntity, wm.getWarehouseSiteFrom(), wms.getItsQuantity()); wms.setReversedId(wm.getItsId()); wms.setDescription(wms.getDescription() + " " + getSrvI18n() .getMsg("reversing_entry_n") + getSrvOrm().getIdDatabase() + "-" + wm.getItsId()); getSrvOrm().updateEntity(wms);
final WarehouseSite pWhSiteTo) throws Exception { if (!pEntity.getIdDatabaseBirth() .equals(getSrvOrm().getIdDatabase())) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "can_not_make_ws_entry_for_foreign_src"); if (pEntity.getReversedId() != null) { String tblNm = WarehouseEntry.class.getSimpleName().toUpperCase(); wms = getSrvOrm().retrieveEntityWithConditions(WarehouseEntry.class, " where SOURCETYPE=" + pEntity.constTypeCode() + " and SOURCEID=" + pEntity.getReversedId() + " and " + tblNm + ".IDDATABASEBIRTH=" + getSrvOrm().getIdDatabase() + " and WAREHOUSESITETO=" + pWhSiteTo.getItsId() + " and INVITEM=" + pEntity.getInvItem() wm.setIdDatabaseBirth(getSrvOrm().getIdDatabase()); wm.setSourceId(pEntity.getItsId()); wm.setSourceType(pEntity.constTypeCode()); if (wms != null) { wm.setReversedId(wms.getItsId()); wm.setDescription(makeDescription(pEntity) + " " + getSrvI18n() .getMsg("reversed_entry_n") + getSrvOrm().getIdDatabase() + "-" + wms.getItsId()); //only local } else { wm.setDescription(makeDescription(pEntity)); getSrvOrm().insertEntity(wm); makeWarehouseRest(pAddParam, pEntity, pWhSiteTo, pEntity.getItsQuantity());