Exemple #1
0
  /**
   * Taking Survey - Update Survey Status
   *
   * @param record
   * @return
   * @throws Exception
   */
  @SuppressWarnings({"rawtypes", "unchecked"})
  public Map takeSurvey(Map record) throws Exception {
    EntityManager oracleManager = null;
    Object transaction = null;
    try {
      String log = "Method:CommonDMI.takeSurvey.";
      oracleManager = EMF.getEntityManager();
      transaction = EMF.getTransaction(oracleManager);

      Timestamp recDate = new Timestamp(System.currentTimeMillis());
      Long survey_id = new Long(record.get("survey_id").toString());
      String loggedUserName = record.get("loggedUserName").toString();
      RCNGenerator.getInstance().initRcn(oracleManager, recDate, loggedUserName, log);
      ArrayList<Survey> surveyList =
          (ArrayList<Survey>)
              oracleManager
                  .createNamedQuery("Survey.getLocked")
                  .setParameter("survId", survey_id)
                  .getResultList();
      if (surveyList == null || surveyList.isEmpty()) {
        throw new CallCenterException(
            "გარკვევის ეს ჩანაწერი უკვე გადაწყვეტილია. გთხოვთ სცადოთ სხვა !");
      }
      Survey survey = surveyList.get(0);
      oracleManager.lock(survey, LockModeType.OPTIMISTIC);
      if (survey.getBblocked() != null
          && survey.getBblocked().equals(1L)
          && !loggedUserName.equals(survey.getLoked_user())) {
        throw new CallCenterException(
            "გარკვევის ეს ჩანაწერი უკვე აღებულია სხვის მიერ. გთხოვთ სცადოთ სხვა !");
      }
      survey.setBblocked(1L);
      survey.setLoked_user(loggedUserName);
      oracleManager.merge(survey);

      oracleManager.flush();
      EMF.commitTransaction(transaction);

      Map result = DMIUtils.findRecordById("SurveyDS", "searchAllSurvey", survey_id, "mysurvey_id");
      log += ". Status Updating Finished SuccessFully. ";
      logger.info(log);
      return result;
    } catch (Exception e) {
      EMF.rollbackTransaction(transaction);
      if (e instanceof CallCenterException) {
        throw (CallCenterException) e;
      }
      logger.error("Error While Update Status for Survey Into Database : ", e);
      throw new CallCenterException("შეცდომა მონაცემების განახლებისას : " + e.toString());
    } finally {
      if (oracleManager != null) {
        EMF.returnEntityManager(oracleManager);
      }
    }
  }
Exemple #2
0
  /**
   * Updating Survey
   *
   * @param record
   * @return
   * @throws Exception
   */
  @SuppressWarnings({"rawtypes"})
  public Map updateSurveyItem(Map record) throws Exception {
    EntityManager oracleManager = null;
    Object transaction = null;
    try {
      String log = "Method:CommonDMI.updateSurveyItem.";
      oracleManager = EMF.getEntityManager();
      transaction = EMF.getTransaction(oracleManager);

      Date recDate = new Date(System.currentTimeMillis());
      Long survey_id = new Long(record.get("survey_id").toString());
      Long survey_reply_type_id = new Long(record.get("survey_reply_type_id").toString());
      String loggedUserName = record.get("loggedUserName").toString();
      RCNGenerator.getInstance()
          .initRcn(oracleManager, new Timestamp(recDate.getTime()), loggedUserName, log);
      Survey survey = oracleManager.find(Survey.class, survey_id);

      survey.setsurvey_reply_type_id(survey_reply_type_id);
      survey.setLoked_user(loggedUserName);

      survey.setBblocked(0L);
      survey.setSurvery_responce_status(1L);

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