Guest User

Untitled

a guest
Aug 11th, 2014
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.47 KB | None | 0 0
  1. public void refresh(String usr) {
  2. logger.log(Level.INFO, "Enter Dynamics Pull");
  3. logger.log(Level.INFO, "\tEnter refresh");
  4. Query qry = em.createNamedQuery("Authuser.findByUsr");
  5.  
  6. qry.setParameter("usr", usr);
  7. Authuser au = (Authuser) qry.getSingleResult();
  8.  
  9. Integer count = 0;
  10.  
  11. Dynamicspulllog pullLog = new Dynamicspulllog();
  12. pullLog.setUsr(au);
  13. pullLog.setPullstart(new Date());
  14. pullLog.setPullminutes(0);
  15. pullLog.setPullrecords(count);
  16. pullLog.setPullresult("running");
  17. em.persist(pullLog);
  18. em.flush();
  19.  
  20. try {
  21. clearOldData();
  22. resetSequences();
  23. count = count + fetchProjectData();
  24. pullLog.setPullrecords(count);
  25. em.merge(pullLog);
  26. em.flush();
  27. count = count + fetchRelatedProjectData();
  28. pullLog.setPullrecords(count);
  29. em.merge(pullLog);
  30. em.flush();
  31.  
  32. findMissingAuthCodes();
  33. associateRelatedData();
  34.  
  35. } catch (Exception e) {
  36.  
  37. pullLog.setPullstop(new Date());
  38. pullLog.setPullminutes(new Long((pullLog.getPullstop().getTime() - pullLog.getPullstart().getTime()) / (60 * 1000)).intValue());
  39. pullLog.setPullrecords(count);
  40. pullLog.setPullresult("fail");
  41. pullLog.setCreated(pullLog.getPullstop());
  42. em.merge(pullLog);
  43. em.flush();
  44.  
  45. }
  46.  
  47. pullLog.setPullstop(new Date());
  48. pullLog.setPullminutes(new Long((pullLog.getPullstop().getTime() - pullLog.getPullstart().getTime()) / (60 * 1000)).intValue());
  49. pullLog.setPullrecords(count);
  50. pullLog.setPullresult("success");
  51. pullLog.setCreated(pullLog.getPullstop());
  52. em.merge(pullLog);
  53. em.flush();
  54.  
  55. logger.log(Level.INFO, "\tExit refresh");
  56. logger.log(Level.INFO, "Exit Dynamics Pull");
  57.  
  58. }
  59.  
  60.  
  61. @SuppressWarnings("unchecked")
  62. private Integer fetchRelatedProjectData() {
  63. logger.log(Level.INFO, "\tEnter fetchRelatedProjectData");
  64.  
  65. Integer count = 0;
  66.  
  67. Future futureBudgetEZLNE = pullProjectBudget.pullData(Constant.COMPANY_EZLNE);
  68. Future futureBudgetMONKL = pullProjectBudget.pullData(Constant.COMPANY_MONKL);
  69. Future futureBudgetALAMN = pullProjectBudget.pullData(Constant.COMPANY_ALAMN);
  70. Future futurePerformanceDailyEZLNE = pullProjectPerformanceDaily.pullData(Constant.COMPANY_EZLNE);
  71. Future futurePerformanceDailyMONKL = pullProjectPerformanceDaily.pullData(Constant.COMPANY_MONKL);
  72. Future futurePerformanceDailyALAMN = pullProjectPerformanceDaily.pullData(Constant.COMPANY_ALAMN);
  73. Future futurePerformanceWeeklyEZLNE = pullProjectPerformanceWeekly.pullData(Constant.COMPANY_EZLNE);
  74. Future futurePerformanceWeeklyMONKL = pullProjectPerformanceWeekly.pullData(Constant.COMPANY_MONKL);
  75. Future futurePerformanceWeeklyALAMN = pullProjectPerformanceWeekly.pullData(Constant.COMPANY_ALAMN);
  76. Future futureRevenueEZLNE = pullProjectRevenue.pullData(Constant.COMPANY_EZLNE);
  77. Future futureRevenueMONKL = pullProjectRevenue.pullData(Constant.COMPANY_MONKL);
  78. Future futureRevenueALAMN = pullProjectRevenue.pullData(Constant.COMPANY_ALAMN);
  79. Future futureTimesheetHistoryEZLNE = pullProjectTimesheetHistory.pullData(Constant.COMPANY_EZLNE);
  80. Future futureTimesheetHistoryMONKL = pullProjectTimesheetHistory.pullData(Constant.COMPANY_MONKL);
  81. Future futureTimesheetHistoryALAMN = pullProjectTimesheetHistory.pullData(Constant.COMPANY_ALAMN);
  82. Future futureTransactionEZLNE = pullProjectTransaction.pullData(Constant.COMPANY_EZLNE);
  83. Future futureTransactionMONKL = pullProjectTransaction.pullData(Constant.COMPANY_MONKL);
  84. Future futureTransactionALAMN = pullProjectTransaction.pullData(Constant.COMPANY_ALAMN);
  85.  
  86.  
  87.  
  88. try {
  89. count = count + (Integer) futureBudgetEZLNE.get();
  90. count = count + (Integer) futureBudgetMONKL.get();
  91. count = count + (Integer) futureBudgetALAMN.get();
  92. count = count + (Integer) futurePerformanceDailyEZLNE.get();
  93. count = count + (Integer) futurePerformanceDailyMONKL.get();
  94. count = count + (Integer) futurePerformanceDailyALAMN.get();
  95. count = count + (Integer) futurePerformanceWeeklyEZLNE.get();
  96. count = count + (Integer) futurePerformanceWeeklyMONKL.get();
  97. count = count + (Integer) futurePerformanceWeeklyALAMN.get();
  98. count = count + (Integer) futureRevenueEZLNE.get();
  99. count = count + (Integer) futureRevenueMONKL.get();
  100. count = count + (Integer) futureRevenueALAMN.get();
  101. count = count + (Integer) futureTimesheetHistoryEZLNE.get();
  102. count = count + (Integer) futureTimesheetHistoryMONKL.get();
  103. count = count + (Integer) futureTimesheetHistoryALAMN.get();
  104. count = count + (Integer) futureTransactionEZLNE.get();
  105. count = count + (Integer) futureTransactionMONKL.get();
  106. count = count + (Integer) futureTransactionALAMN.get();
  107.  
  108. } catch (InterruptedException | ExecutionException | CancellationException ex) {
  109. throw new IllegalStateException("Cannot get the answer", ex);
  110. }
  111.  
  112. logger.log(Level.INFO, "\tExit fetchRelatedProjectData " + count);
  113. return count;
  114. }
Advertisement
Add Comment
Please, Sign In to add comment