예제 #1
0
  /**
   * Adding New SurveyKind
   *
   * @param record
   * @return
   * @throws Exception
   */
  public SurveyKind addSurveyKind(SurveyKind SurveyKind) throws Exception {
    EntityManager oracleManager = null;
    Object transaction = null;
    try {
      String log = "Method:CommonDMI.addSurveyKind.";
      oracleManager = EMF.getEntityManager();
      transaction = EMF.getTransaction(oracleManager);

      // sysdate
      Timestamp recDate = new Timestamp(System.currentTimeMillis());
      String loggedUserName = SurveyKind.getLoggedUserName();
      RCNGenerator.getInstance().initRcn(oracleManager, recDate, loggedUserName, log);
      oracleManager.persist(SurveyKind);
      oracleManager.flush();

      SurveyKind = oracleManager.find(SurveyKind.class, SurveyKind.getSurvey_kind_id());
      SurveyKind.setLoggedUserName(loggedUserName);

      EMF.commitTransaction(transaction);
      log += ". Inserting Finished SuccessFully. ";
      logger.info(log);
      return SurveyKind;
    } catch (Exception e) {
      EMF.rollbackTransaction(transaction);
      if (e instanceof CallCenterException) {
        throw (CallCenterException) e;
      }
      logger.error("Error While Insert SurveyKind Into Database : ", e);
      throw new CallCenterException("შეცდომა მონაცემების შენახვისას : " + e.toString());
    } finally {
      if (oracleManager != null) {
        EMF.returnEntityManager(oracleManager);
      }
    }
  }
예제 #2
0
  /**
   * Updating SurveyKind
   *
   * @param record
   * @return
   * @throws Exception
   */
  @SuppressWarnings("rawtypes")
  public SurveyKind updateSurveyKind(Map record) throws Exception {
    EntityManager oracleManager = null;
    Object transaction = null;
    try {
      String log = "Method:CommonDMI.updateSurveyKind.";
      oracleManager = EMF.getEntityManager();
      transaction = EMF.getTransaction(oracleManager);

      Timestamp recDate = new Timestamp(System.currentTimeMillis());
      Long survey_kind_id = new Long(record.get("survey_kind_id").toString());
      String survey_kind_name =
          record.get("survey_kind_name") == null ? null : record.get("survey_kind_name").toString();
      String loggedUserName = record.get("loggedUserName").toString();

      RCNGenerator.getInstance().initRcn(oracleManager, recDate, loggedUserName, log);
      SurveyKind SurveyKind = oracleManager.find(SurveyKind.class, survey_kind_id);

      SurveyKind.setSurvey_kind_name(survey_kind_name);

      oracleManager.merge(SurveyKind);
      oracleManager.flush();

      SurveyKind = oracleManager.find(SurveyKind.class, survey_kind_id);

      EMF.commitTransaction(transaction);
      log += ". Updating Finished SuccessFully. ";
      logger.info(log);
      return SurveyKind;
    } catch (Exception e) {
      EMF.rollbackTransaction(transaction);
      if (e instanceof CallCenterException) {
        throw (CallCenterException) e;
      }
      logger.error("Error While Update SurveyKind Into Database : ", e);
      throw new CallCenterException("შეცდომა მონაცემების შენახვისას : " + e.toString());
    } finally {
      if (oracleManager != null) {
        EMF.returnEntityManager(oracleManager);
      }
    }
  }