Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.50 KB | None | 0 0
  1. package com.mlpt.bvnextgen.generatePDLGD.generateLGD.CallProcedure;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.HashMap;
  5. import java.util.List;
  6. import java.util.Map;
  7.  
  8. import org.hibernate.Query;
  9. import org.json.simple.JSONObject;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.stereotype.Service;
  12.  
  13. import com.mlpt.bvnextgen.MasterGeneralConstants;
  14. import com.mlpt.bvnextgen.annotation.Info;
  15. import com.mlpt.bvnextgen.annotation.InfoIn;
  16. import com.mlpt.bvnextgen.annotation.InfoOut;
  17. import com.mlpt.bvnextgen.dao.ConfigurationDao;
  18. import com.mlpt.bvnextgen.generatePDLGD.LoggingConfiguration;
  19. import com.mlpt.bvnextgen.procedureSQL.CallProcedure;
  20.  
  21. @InfoIn(value = {
  22.  
  23. })
  24. @InfoOut(value = {
  25. @Info(name = "status", description = "status", type = "String.class"),
  26. @Info(name = "errorMessage", description = "error Message", type = "String.class") })
  27. @Service
  28. public class CallLWOBAL {
  29. @Autowired
  30. ConfigurationDao configureDao;
  31.  
  32. @Autowired
  33. LoggingConfiguration logConfig;
  34.  
  35. @Autowired
  36. CallProcedure procedureCall;
  37.  
  38.  
  39. @SuppressWarnings("unchecked")
  40. public JSONObject processBo(JSONObject serviceInput) {
  41.  
  42. JSONObject resultOutput = new JSONObject();
  43.  
  44. String errorMessage = "";
  45. String result = "";
  46.  
  47. List<Map<String, String>> parameter = new ArrayList<Map<String, String>>();
  48. Map<String, String> configure = new HashMap<String, String>();
  49.  
  50. try {
  51.  
  52. /*
  53. * --------------------------- START
  54. * --------------------------------------
  55. */
  56.  
  57. // get break type
  58. List<String> queryResultFindBreak = new ArrayList<String>();
  59. Query findBreak = configureDao.createQuery("Select subconfig "
  60. + "from com.mlpt.bvnextgen.entity.Configuration "
  61. + "where configMenu = :configMenu and active = :active");
  62. findBreak.setParameter("configMenu", MasterGeneralConstants.BREAK);
  63. findBreak.setParameter("active", MasterGeneralConstants.ACTIVATE);
  64.  
  65. queryResultFindBreak = findBreak.list();
  66. configureDao.closeSessionCreateQuery();
  67.  
  68. System.out.println("BREAK TYPE : " + queryResultFindBreak.get(0));
  69. String breakType = String.valueOf(queryResultFindBreak.get(0));
  70. /*
  71. * ---------------------------- END
  72. * ---------------------------------------
  73. */
  74.  
  75. String lwobalType = "";
  76.  
  77. if (breakType.equals(MasterGeneralConstants.BRANCH)) {
  78. lwobalType = MasterGeneralConstants.LWOBAL_BRANCH;
  79. } else if (breakType.equals(MasterGeneralConstants.REGION)) {
  80. lwobalType = MasterGeneralConstants.LWOBAL_REGION;
  81. } else if (breakType.equals(MasterGeneralConstants.SEGMENT)) {
  82. lwobalType = MasterGeneralConstants.LWOBAL_SEGMENT;
  83. } else if (breakType.equals(MasterGeneralConstants.PLAN)) {
  84. lwobalType = MasterGeneralConstants.LWOBAL_PLAN;
  85. } else {
  86. lwobalType = MasterGeneralConstants.LWOBAL;
  87. }
  88.  
  89. // 2. LWOBAL
  90. procedureCall.callProcedure(lwobalType, parameter);
  91.  
  92. //LOG LGD
  93. procedureCall.callProcedure(MasterGeneralConstants.LOG_LWOBAL,parameter);
  94.  
  95. //LOG m_config
  96. logConfig.processWriteToLogMConfigLGD();
  97.  
  98. resultOutput.put("status", "S");
  99.  
  100. } catch (Exception e) {
  101. e.printStackTrace();
  102.  
  103. errorMessage = e.getCause().toString();
  104. errorMessage = errorMessage.substring(
  105. (errorMessage.indexOf(':') + 1), errorMessage.length());
  106. errorMessage = errorMessage.trim();
  107.  
  108. resultOutput.put("status", "F");
  109. resultOutput.put("errorMessage", errorMessage);
  110.  
  111. return resultOutput;
  112. }
  113.  
  114. return resultOutput;
  115.  
  116. }
  117.  
  118.  
  119. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement