Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void refresh(String usr) {
- logger.log(Level.INFO, "Enter Dynamics Pull");
- logger.log(Level.INFO, "\tEnter refresh");
- Query qry = em.createNamedQuery("Authuser.findByUsr");
- qry.setParameter("usr", usr);
- Authuser au = (Authuser) qry.getSingleResult();
- Integer count = 0;
- Dynamicspulllog pullLog = new Dynamicspulllog();
- pullLog.setUsr(au);
- pullLog.setPullstart(new Date());
- pullLog.setPullminutes(0);
- pullLog.setPullrecords(count);
- pullLog.setPullresult("running");
- em.persist(pullLog);
- em.flush();
- try {
- clearOldData();
- resetSequences();
- count = count + fetchProjectData();
- pullLog.setPullrecords(count);
- em.merge(pullLog);
- em.flush();
- count = count + fetchRelatedProjectData();
- pullLog.setPullrecords(count);
- em.merge(pullLog);
- em.flush();
- findMissingAuthCodes();
- associateRelatedData();
- } catch (Exception e) {
- pullLog.setPullstop(new Date());
- pullLog.setPullminutes(new Long((pullLog.getPullstop().getTime() - pullLog.getPullstart().getTime()) / (60 * 1000)).intValue());
- pullLog.setPullrecords(count);
- pullLog.setPullresult("fail");
- pullLog.setCreated(pullLog.getPullstop());
- em.merge(pullLog);
- em.flush();
- }
- pullLog.setPullstop(new Date());
- pullLog.setPullminutes(new Long((pullLog.getPullstop().getTime() - pullLog.getPullstart().getTime()) / (60 * 1000)).intValue());
- pullLog.setPullrecords(count);
- pullLog.setPullresult("success");
- pullLog.setCreated(pullLog.getPullstop());
- em.merge(pullLog);
- em.flush();
- logger.log(Level.INFO, "\tExit refresh");
- logger.log(Level.INFO, "Exit Dynamics Pull");
- }
- @SuppressWarnings("unchecked")
- private Integer fetchRelatedProjectData() {
- logger.log(Level.INFO, "\tEnter fetchRelatedProjectData");
- Integer count = 0;
- Future futureBudgetEZLNE = pullProjectBudget.pullData(Constant.COMPANY_EZLNE);
- Future futureBudgetMONKL = pullProjectBudget.pullData(Constant.COMPANY_MONKL);
- Future futureBudgetALAMN = pullProjectBudget.pullData(Constant.COMPANY_ALAMN);
- Future futurePerformanceDailyEZLNE = pullProjectPerformanceDaily.pullData(Constant.COMPANY_EZLNE);
- Future futurePerformanceDailyMONKL = pullProjectPerformanceDaily.pullData(Constant.COMPANY_MONKL);
- Future futurePerformanceDailyALAMN = pullProjectPerformanceDaily.pullData(Constant.COMPANY_ALAMN);
- Future futurePerformanceWeeklyEZLNE = pullProjectPerformanceWeekly.pullData(Constant.COMPANY_EZLNE);
- Future futurePerformanceWeeklyMONKL = pullProjectPerformanceWeekly.pullData(Constant.COMPANY_MONKL);
- Future futurePerformanceWeeklyALAMN = pullProjectPerformanceWeekly.pullData(Constant.COMPANY_ALAMN);
- Future futureRevenueEZLNE = pullProjectRevenue.pullData(Constant.COMPANY_EZLNE);
- Future futureRevenueMONKL = pullProjectRevenue.pullData(Constant.COMPANY_MONKL);
- Future futureRevenueALAMN = pullProjectRevenue.pullData(Constant.COMPANY_ALAMN);
- Future futureTimesheetHistoryEZLNE = pullProjectTimesheetHistory.pullData(Constant.COMPANY_EZLNE);
- Future futureTimesheetHistoryMONKL = pullProjectTimesheetHistory.pullData(Constant.COMPANY_MONKL);
- Future futureTimesheetHistoryALAMN = pullProjectTimesheetHistory.pullData(Constant.COMPANY_ALAMN);
- Future futureTransactionEZLNE = pullProjectTransaction.pullData(Constant.COMPANY_EZLNE);
- Future futureTransactionMONKL = pullProjectTransaction.pullData(Constant.COMPANY_MONKL);
- Future futureTransactionALAMN = pullProjectTransaction.pullData(Constant.COMPANY_ALAMN);
- try {
- count = count + (Integer) futureBudgetEZLNE.get();
- count = count + (Integer) futureBudgetMONKL.get();
- count = count + (Integer) futureBudgetALAMN.get();
- count = count + (Integer) futurePerformanceDailyEZLNE.get();
- count = count + (Integer) futurePerformanceDailyMONKL.get();
- count = count + (Integer) futurePerformanceDailyALAMN.get();
- count = count + (Integer) futurePerformanceWeeklyEZLNE.get();
- count = count + (Integer) futurePerformanceWeeklyMONKL.get();
- count = count + (Integer) futurePerformanceWeeklyALAMN.get();
- count = count + (Integer) futureRevenueEZLNE.get();
- count = count + (Integer) futureRevenueMONKL.get();
- count = count + (Integer) futureRevenueALAMN.get();
- count = count + (Integer) futureTimesheetHistoryEZLNE.get();
- count = count + (Integer) futureTimesheetHistoryMONKL.get();
- count = count + (Integer) futureTimesheetHistoryALAMN.get();
- count = count + (Integer) futureTransactionEZLNE.get();
- count = count + (Integer) futureTransactionMONKL.get();
- count = count + (Integer) futureTransactionALAMN.get();
- } catch (InterruptedException | ExecutionException | CancellationException ex) {
- throw new IllegalStateException("Cannot get the answer", ex);
- }
- logger.log(Level.INFO, "\tExit fetchRelatedProjectData " + count);
- return count;
- }
Advertisement
Add Comment
Please, Sign In to add comment