/** * <p>Retrieve a page of entities.</p> * @param pAddParam additional param * @param pFirst number of the first record * @param pPageSize page size (max records) * @return list of business objects * @throws Exception - an exception */ @Override public final List<T> retrievePage(final Map<String, Object> pAddParam, final Integer pFirst, final Integer pPageSize) throws Exception { addAccSettingsIntoAttrs(pAddParam); return getSrvOrm().retrievePage(this.entityClass, pFirst, pPageSize); }
/** * <p>Delete entity from DB by given ID.</p> * @param pAddParam additional param * @param pId ID * @throws Exception - an exception **/ @Override public final void deleteEntity(final Map<String, Object> pAddParam, final Object pId) throws Exception { T entity = retrieveEntityById(pAddParam, pId); deleteEntity(pAddParam, entity); }
/** * <p>Retrieve a list of all entities.</p> * @param pAddParam additional param * @return list of all business objects * @throws Exception - an exception */ @Override public final List<T> retrieveList( final Map<String, Object> pAddParam) throws Exception { return getSrvOrm().retrieveList(this.entityClass); }
/** * <p>Create SrvEmployee service.</p> * @param pSrvName Service Name * @return SrvEmployee Employee service * @throws Exception - an exception */ public final synchronized SrvAccEntitySimple createSrvEmployee(final String pSrvName) throws Exception { SrvAccEntitySimple srvEntity = new SrvAccEntitySimple(Employee.class, factoryAppBeans.lazyGetSrvOrm(), lazyGetSrvAccSettings()); factoryAppBeans.getBeansMap().put(pSrvName, srvEntity); SrvEmployeeYearWage srvEntityOwned = new SrvEmployeeYearWage( factoryAppBeans.lazyGetSrvOrm(), lazyGetSrvAccSettings()); this.factoryAppBeans.getBeansMap().put("srv" + EmployeeYearWage.class .getSimpleName(), srvEntityOwned); return srvEntity; }
/** * <p>Calculate total rows for pagination.</p> * @param pAddParam additional param * @param pWhere not null e.g. "ITSID > 33" * @return Integer row count * @throws Exception - an exception */ @Override public final Integer evalRowCountWhere(final Map<String, Object> pAddParam, final String pWhere) throws Exception { return getSrvOrm().evalRowCountWhere(this.entityClass, pWhere); }
/** * <p>Create InvItem Tax Category service.</p> * @param pSrvName Service Name * @return SrvAccEntitySimple<InvItemTaxCategory> InvItem Tax Category service * @throws Exception - an exception */ public final synchronized SrvAccEntitySimple<InvItemTaxCategory> createSrvInvItemTaxCat(final String pSrvName) throws Exception { SrvAccEntitySimple<InvItemTaxCategory> srvEntity = new SrvAccEntitySimple<InvItemTaxCategory>(InvItemTaxCategory.class, factoryAppBeans.lazyGetSrvOrm(), lazyGetSrvAccSettings()); factoryAppBeans.getBeansMap().put(pSrvName, srvEntity); Object srvInvItemTaxCatLine = new SrvInvItemTaxCategoryLine<RS>(factoryAppBeans.lazyGetSrvOrm(), lazyGetSrvAccSettings()); factoryAppBeans.getBeansMap().put("srv" + InvItemTaxCategoryLine .class.getSimpleName(), srvInvItemTaxCatLine); return srvEntity; }
/** * <p>Retrieve entity from DB by given ID.</p> * @param pAddParam additional param * @param pId ID * @return entity or null * @throws Exception - an exception **/ @Override public final T retrieveEntityById(final Map<String, Object> pAddParam, final Object pId) throws Exception { addAccSettingsIntoAttrs(pAddParam); return getSrvOrm().retrieveEntityById(this.entityClass, pId); }
/** * <p>Calculate total rows for pagination.</p> * @param pAddParam additional param * @param pWhere not null e.g. "ITSID > 33" * @return Integer row count * @throws Exception - an exception */ @Override public final Integer evalRowCount( final Map<String, Object> pAddParam) throws Exception { return getSrvOrm().evalRowCount(this.entityClass); } /**
/** * <p>Create MoveItems service.</p> * @param pSrvName Service Name * @return SrvAccEntitySimple<MoveItems> MoveItems service * @throws Exception - an exception */ public final synchronized SrvAccEntitySimple<MoveItems> createSrvMoveItems(final String pSrvName) throws Exception { SrvAccEntitySimple<MoveItems> srvEntity = new SrvAccEntitySimple<MoveItems>(MoveItems.class, factoryAppBeans.lazyGetSrvOrm(), lazyGetSrvAccSettings()); factoryAppBeans.getBeansMap().put(pSrvName, srvEntity); Object srvMoveItemsLine = new SrvMoveItemsLine<RS>(factoryAppBeans.lazyGetSrvOrm(), lazyGetSrvAccSettings(), lazyGetSrvWarehouseEntry()); factoryAppBeans.getBeansMap().put("srv" + MoveItemsLine .class.getSimpleName(), srvMoveItemsLine); return srvEntity; }
/** * <p>Retrieve a page of entities.</p> * @param pAddParam additional param * @param pQueryConditions Not NULL e.g. "where name='U1' ORDER BY id" * @param pFirst number of the first record * @param pPageSize page size (max records) * @return list of business objects * @throws Exception - an exception */ @Override public final List<T> retrievePageWithConditions( final Map<String, Object> pAddParam, final String pQueryConditions, final Integer pFirst, final Integer pPageSize) throws Exception { addAccSettingsIntoAttrs(pAddParam); return getSrvOrm().retrievePageWithConditions(this.entityClass, pQueryConditions, pFirst, pPageSize); }
/** * <p>Retrieve a list of entities.</p> * @param pAddParam additional param * @param pQueryConditions Not NULL e.g. "where name='U1' ORDER BY id" * @return list of business objects * @throws Exception - an exception */ @Override public final List<T> retrieveListWithConditions( final Map<String, Object> pAddParam, final String pQueryConditions) throws Exception { return getSrvOrm().retrieveListWithConditions(this.entityClass, pQueryConditions); }
createSrvAccount(pSrvName); } else { srvEntity = new SrvAccEntitySimple(entityClass, factoryAppBeans.lazyGetSrvOrm(), lazyGetSrvAccSettings()); factoryAppBeans.getBeansMap().put(pSrvName, srvEntity);
/** * <p>Refresh entity from DB by given entity with ID.</p> * @param pEntity entity * @return entity or null * @throws Exception - an exception **/ @Override public final T retrieveEntity(final Map<String, Object> pAddParam, final T pEntity) throws Exception { addAccSettingsIntoAttrs(pAddParam); return getSrvOrm().retrieveEntityById(this.entityClass, pEntity.getItsId()); }
/** * <p>Delete entity from DB.</p> * @param pAddParam additional param * @param pEntity entity * @throws Exception - an exception **/ @Override public final void deleteEntity(final Map<String, Object> pAddParam, final T pEntity) throws Exception { if (APersistableBase.class.isAssignableFrom(pEntity.getClass()) && !((APersistableBase) pEntity).getIdDatabaseBirth() .equals(getSrvOrm().getIdDatabase())) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "can_not_delete_foreign_src"); } getSrvOrm().deleteEntity(this.entityClass, pEntity.getItsId()); }
/** * <p>Create entity.</p> * @param pAddParam additional param * @return entity instance * @throws Exception - an exception **/ @Override public final T createEntity( final Map<String, Object> pAddParam) throws Exception { T entity = getSrvOrm().createEntity(this.entityClass); entity.setIsNew(true); addAccSettingsIntoAttrs(pAddParam); return entity; }
/** * <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 T pEntity, final boolean isEntityDetached) throws Exception { if (pEntity.getIsNew()) { getSrvOrm().insertEntity(pEntity); } else { if (APersistableBase.class.isAssignableFrom(pEntity.getClass()) && !((APersistableBase) pEntity).getIdDatabaseBirth() .equals(getSrvOrm().getIdDatabase())) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "can_not_change_foreign_src"); } getSrvOrm().updateEntity(pEntity); } }
/** * <p>Retrieve copy of entity from DB by given ID.</p> * @param pAddParam additional param * @param pId ID * @return entity or null * @throws Exception - an exception **/ @Override public final T retrieveCopyEntity(final Map<String, Object> pAddParam, final Object pId) throws Exception { T entity = getSrvOrm().retrieveCopyEntity(this.entityClass, pId); entity.setIsNew(true); addAccSettingsIntoAttrs(pAddParam); return entity; }