/** * <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); }
final boolean isEntityDetached) throws Exception { boolean isNew = pEntity.getIsNew(); makeFirstPrepareForSave(pAddParam, pEntity); @SuppressWarnings("unchecked") Map<String, String[]> parameterMap = (Map<String, String[]>) pAddParam. + " " + getSrvI18n().getMsg("reversed_n") + pEntity .getReversedIdDatabaseBirth() + "-" + pEntity.getReversedId()); getSrvOrm().insertEntity(pEntity); if (pEntity.getReversedId() != null) { T reversed; if (pEntity.getIdDatabaseBirth().equals(pEntity reversed = getSrvOrm().retrieveEntityById( getEntityClass(), pEntity.getReversedId()); } else { //reversing foreign doc String tblNm = getEntityClass().getSimpleName().toUpperCase(); String whereStr = " where " + tblNm + ".IDBIRTH=" + pEntity .getReversedId() + " and " + tblNm + ".IDDATABASEBIRTH=" + pEntity .getReversedIdDatabaseBirth(); reversed = getSrvOrm().retrieveEntityWithConditions( getEntityClass(), whereStr); + " " + getSrvI18n().getMsg("reversing_n") + pEntity .getIdDatabaseBirth() + "-" getSrvOrm().updateEntity(reversed);
/** * <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); T entity = getSrvOrm().retrieveEntityById(getEntityClass(), pId); @SuppressWarnings("unchecked") Map<String, String[]> parameterMap = (Map<String, String[]>) pAddParam. get("parameterMap"); if (parameterMap.get("actionAdd") != null && "full".equals(parameterMap.get("actionAdd")[0])) { IAttributes attributes = (IAttributes) pAddParam.get("attributes"); attributes.setAttribute("accEntries", srvAccEntry .retrieveAccEntriesFor(pAddParam, entity)); } retrieveOtherDataFor(pAddParam, entity); return entity; }
final Map<String, Object> pAddParam, final Object pId) throws Exception { T entity = getSrvOrm() .retrieveCopyEntity(getEntityClass(), pId); @SuppressWarnings("unchecked") Map<String, String[]> parameterMap = (Map<String, String[]>) pAddParam. "Attempt to double reverse! " + pAddParam.get("user")); T entityReversed = getSrvOrm() .retrieveEntityById(getEntityClass(), pId); Long docId = entityReversed.getItsId(); if (entityReversed.getIdBirth() != null) { entity.setItsDate(new Date()); entity.setIdDatabaseBirth(getSrvOrm().getIdDatabase()); entity.setIsNew(true); entity.setHasMadeAccEntries(false); makeAddPrepareForCopy(pAddParam, entity); addAccSettingsIntoAttrs(pAddParam); return entity;
/** * <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 (!pEntity.getIdDatabaseBirth().equals(getSrvOrm().getIdDatabase())) { throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER, "can_not_delete_foreign_src"); } deleteEntity(pAddParam, pEntity.getItsId()); }