/** * 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); } } }
/** * 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); } } }
/** * Updating SurveyReplyType * * @param record * @return * @throws Exception */ @SuppressWarnings("rawtypes") public SurveyReplyType updateSurveyReplyType(Map record) throws Exception { EntityManager oracleManager = null; Object transaction = null; try { String log = "Method:CommonDMI.updateSurveyReplyType."; oracleManager = EMF.getEntityManager(); transaction = EMF.getTransaction(oracleManager); Timestamp recDate = new Timestamp(System.currentTimeMillis()); Long survey_reply_type_id = new Long(record.get("survey_reply_type_id").toString()); String survey_reply_type_name = record.get("survey_reply_type_name") == null ? null : record.get("survey_reply_type_name").toString(); String loggedUserName = record.get("loggedUserName").toString(); RCNGenerator.getInstance().initRcn(oracleManager, recDate, loggedUserName, log); SurveyReplyType SurveyReplyType = oracleManager.find(SurveyReplyType.class, survey_reply_type_id); SurveyReplyType.setSurvey_reply_type_name(survey_reply_type_name); oracleManager.merge(SurveyReplyType); oracleManager.flush(); SurveyReplyType = oracleManager.find(SurveyReplyType.class, survey_reply_type_id); EMF.commitTransaction(transaction); log += ". Updating Finished SuccessFully. "; logger.info(log); return SurveyReplyType; } catch (Exception e) { EMF.rollbackTransaction(transaction); if (e instanceof CallCenterException) { throw (CallCenterException) e; } logger.error("Error While Update SurveyReplyType Into Database : ", e); throw new CallCenterException("შეცდომა მონაცემების შენახვისას : " + e.toString()); } finally { if (oracleManager != null) { EMF.returnEntityManager(oracleManager); } } }
/** * სატელეფონო კომპანიის და მისი ინდექსების ინფორმაციის გაუქმების ფუნქცია. * * @param record პარამეტრი რომელშიც მოდის თუ რომელი სატელეფონო კომპანა და მისი ინდექსების * ინფორმაცა უნდა წაიშალოს მონაცემთა ბაზიდან * @return Contract აბრუნებს ცარიელი კონტრაქტის ობიექს რადგან ინფორმაცია უკვე წაშლილია * @throws Exception */ @SuppressWarnings("rawtypes") public BillingCompany removeBillingComp(DSRequest dsRequest) throws Exception { EntityManager oracleManager = null; Object transaction = null; try { Map oldValue = dsRequest.getOldValues(); Long billing_company_id = new Long(dsRequest.getFieldValue("billing_company_id").toString()); String loggedUserName = oldValue.get("loggedUserName").toString(); String log = "Method:BillingCompsDMI.removeBillingComp."; oracleManager = EMF.getEntityManager(); transaction = EMF.getTransaction(oracleManager); Timestamp updDate = new Timestamp(System.currentTimeMillis()); BillingCompany billingComp = oracleManager.find(BillingCompany.class, billing_company_id); RCNGenerator.getInstance() .initRcn(oracleManager, updDate, loggedUserName, "Remove BillingComp."); oracleManager .createNativeQuery(QueryConstants.Q_DELETE_BILLINGCOMP_IND) .setParameter(1, billingComp.getbilling_company_id()) .executeUpdate(); oracleManager.remove(billingComp); oracleManager.flush(); EMF.commitTransaction(transaction); log += ". Status Updating Finished SuccessFully. "; logger.info(log); return null; } catch (Exception e) { EMF.rollbackTransaction(transaction); if (e instanceof CallCenterException) { throw (CallCenterException) e; } logger.error("Error While Remove BillingComps From Database : ", e); throw new CallCenterException("შეცდომა მონაცემების წაშლისას : " + e.toString()); } finally { if (oracleManager != null) { EMF.returnEntityManager(oracleManager); } } }
/** * 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); } } }
/** * Updating SurveyKind Status * * @param record * @return * @throws Exception */ @SuppressWarnings("rawtypes") public SurveyKind removeSurveyKind(Map record, DSRequest req) throws Exception { EntityManager oracleManager = null; Object transaction = null; try { String log = "Method:CommonDMI.removeSurveyKind."; oracleManager = EMF.getEntityManager(); transaction = EMF.getTransaction(oracleManager); Timestamp recDate = new Timestamp(System.currentTimeMillis()); Long survey_kind_id = new Long(req.getOldValues().get("survey_kind_id").toString()); String loggedUserName = req.getOldValues().get("loggedUserName").toString(); RCNGenerator.getInstance().initRcn(oracleManager, recDate, loggedUserName, log); SurveyKind surveyKind = oracleManager.find(SurveyKind.class, survey_kind_id); oracleManager.remove(surveyKind); oracleManager.flush(); surveyKind = oracleManager.find(SurveyKind.class, survey_kind_id); EMF.commitTransaction(transaction); log += ". Status 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 Status for SurveyKind Into Database : ", e); throw new CallCenterException("შეცდომა მონაცემების შენახვისას : " + e.toString()); } finally { if (oracleManager != null) { EMF.returnEntityManager(oracleManager); } } }
/** * Remove OrganizationActivity * * @param record * @return * @throws Exception */ public void deleteSessionCharge(DSRequest dsRequest) throws Exception { EntityManager oracleManager = null; Object transaction = null; try { String log = "Method:SurveyDMI.deleteSessionCharge."; oracleManager = EMF.getEntityManager(); transaction = EMF.getTransaction(oracleManager); Long cse_id = new Long(dsRequest.getOldValues().get("cse_id").toString()); String loggedUserName = dsRequest.getOldValues().get("loggedUserName").toString(); Timestamp updDate = new Timestamp(System.currentTimeMillis()); RCNGenerator.getInstance() .initRcn(oracleManager, updDate, loggedUserName, "Removing EventCategory."); CallSessionExpense callSessionExpense = oracleManager.find(CallSessionExpense.class, cse_id); oracleManager.remove(callSessionExpense); oracleManager.flush(); EMF.commitTransaction(transaction); log += ". Removing Finished SuccessFully. "; logger.info(log); } catch (Exception e) { EMF.rollbackTransaction(transaction); if (e instanceof CallCenterException) { throw (CallCenterException) e; } logger.error("Error While remove organizationActivity from Database : ", e); throw new CallCenterException("შეცდომა მონაცემების შენახვისას : " + e.toString()); } finally { if (oracleManager != null) { EMF.returnEntityManager(oracleManager); } } }
/** * ახალი სატელეფონო კომპანიის და მისი ინდექსების დამატების ფუნქციონალი. * * @param dsRequest ამ პარამეტრში მოდის თუ რა ინფორმაცია უნდა შეინახოს სატელეფონო კომპანიის * შესახებ * @return BillingComp ფუნქცია აბრუნებს ჰიბერნეიტის კლასს რომელიც უკვე შენახულია მონაცმთა ბაზაში. * ეს კლასი ბრუნდება კლიენტის მხარეს რათა კლიენტმა დაინახოს მის მიერ ახალ დამატებული * სატელეფონო კომპანია * @throws Exception შეცდომის დამუშავება. */ @SuppressWarnings("rawtypes") public BillingCompany addBillingComp(DSRequest dsRequest) throws Exception { EntityManager oracleManager = null; Object transaction = null; try { String log = "Method:BillingCompsDMI.addBillingComp."; String loggedUserName = dsRequest.getFieldValue("loggedUserName").toString(); // sysdate Timestamp rec_date = new Timestamp(System.currentTimeMillis()); BillingCompany billingComp = new BillingCompany(); billingComp.setLoggedUserName(loggedUserName); Object obilling_company_name = dsRequest.getFieldValue("billing_company_name"); String billing_company_name = (obilling_company_name == null ? null : obilling_company_name.toString()); billingComp.setBilling_company_name(billing_company_name); Object oour_percent = dsRequest.getFieldValue("our_percent"); Double our_percent = (oour_percent == null ? 1L : new Double(oour_percent.toString())); billingComp.setOur_percent(our_percent); Object ocall_price = dsRequest.getFieldValue("call_price"); Double call_price = (ocall_price == null ? 1L : new Double(ocall_price.toString())); billingComp.setCall_price(call_price); Object ohas_calculation = dsRequest.getFieldValue("has_calculation"); Long has_calculation = (ohas_calculation == null ? -1L : new Long(ohas_calculation.toString())); billingComp.setHas_calculation(has_calculation); Long operator_src = Long.parseLong(dsRequest.getFieldValue("operator_src").toString()); Long mobile_company = Long.parseLong(dsRequest.getFieldValue("mobile_company").toString()); Object mobile_company_name_o = dsRequest.getFieldValue("mobile_company_name"); String mobile_company_name = (mobile_company_name_o == null ? null : mobile_company_name_o.toString()); billingComp.setOperator_src(operator_src); billingComp.setMobile_company(mobile_company); billingComp.setMobile_company_name(mobile_company_name); oracleManager = EMF.getEntityManager(); transaction = EMF.getTransaction(oracleManager); RCNGenerator.getInstance() .initRcn(oracleManager, rec_date, loggedUserName, "Adding BillingComp."); oracleManager.persist(billingComp); oracleManager.flush(); Object oMap = dsRequest.getFieldValue("billingCompIdexes"); if (oMap != null) { LinkedMap indexed = (LinkedMap) oMap; if (!indexed.isEmpty()) { Set keys1 = indexed.keySet(); checkBillingCompIndexes(null, operator_src, indexed); for (Object okey1 : keys1) { String str_bill_index_start = okey1.toString(); LinkedMap value1 = (LinkedMap) indexed.get(str_bill_index_start); String str_bill_index_end = value1.get("str_bill_index_end").toString(); String str_applied_wholly = value1.get("str_applied_wholly").toString(); String str_calcul_type = value1.get("str_calcul_type").toString(); BillingCompanyInd item = new BillingCompanyInd(); item.setApplied_wholly(new Long(str_applied_wholly)); item.setBill_index_end(new Long(str_bill_index_end)); item.setBill_index_start(new Long(str_bill_index_start)); item.setCalcul_type(new Long(str_calcul_type)); item.setBilling_company_id(billingComp.getbilling_company_id()); oracleManager.persist(item); } } } billingComp = oracleManager.find(BillingCompany.class, billingComp.getbilling_company_id()); billingComp.setLoggedUserName(loggedUserName); if (has_calculation.equals(1L)) { billingComp.setHas_calculation_descr("დიახ"); } else if (has_calculation.equals(0L)) { billingComp.setHas_calculation_descr("არა"); } else { billingComp.setHas_calculation_descr("ყველა"); } EMF.commitTransaction(transaction); log += ". Inserting Finished SuccessFully. "; logger.info(log); return billingComp; } catch (Exception e) { EMF.rollbackTransaction(transaction); if (e instanceof CallCenterException) { throw (CallCenterException) e; } logger.error("Error While Insert BillingComp Into Database : ", e); throw new CallCenterException("შეცდომა მონაცემების შენახვისას : " + e.toString()); } finally { if (oracleManager != null) { EMF.returnEntityManager(oracleManager); } } }