@Test public void testGetCounterMerticValue() throws Exception{ CounterDetailVO counterDetails = new CounterDetailVO(); counterDetails.setEnvironmentCounterId(6); counterDetails.setEnvironmentId(1); counterDetails.setCounterId(1); counterDetails.setCounterMetricTypeId(1); counterDetails.setParameter1("4,6"); counterDetails.setParameter2("AVG"); List<CounterDetailVO> counterList = new ArrayList<CounterDetailVO>(); counterList.add(counterDetails); GlobalCounterHandler gcHandler = new GlobalCounterHandler(); gcHandler.getCounterMerticValue(counterDetails, counterList); }
@Override public float getCounterMerticValue(CounterDetailVO counterDetails, List<CounterDetailVO> listCounterDetails) throws Exception { String[] environmentCounterIDs = counterDetails.getParameter1().split(","); float matchingCounters = 0f; float sumMatchingCounters = 0f; for(String environmentCounterID: environmentCounterIDs){ int envCountId = Integer.parseInt(environmentCounterID); for(CounterDetailVO couDet: listCounterDetails){ if(couDet.getEnvironmentCounterId() == envCountId){ float metricValue = couDet.getMetricValue(); if(metricValue<0){ metricValue= DBQueryUtil.getTotalTransaction(envCountId); } matchingCounters++; sumMatchingCounters += metricValue; } } } logger.debug("EnvironmentCounterId=" + counterDetails.getEnvironmentCounterId() + "; matchingCounters = " + matchingCounters + "; sumMatchingCounters = " + sumMatchingCounters); if(counterDetails.getParameter2() != null && counterDetails.getParameter2().equalsIgnoreCase("AVG") && matchingCounters > 0){ return sumMatchingCounters/matchingCounters; } return sumMatchingCounters; }
GlobalCounterHandler extends CounterMetricHandler { @Override public float getCounterMerticValue(CounterDetailVO counterDetails, List<CounterDetailVO> listCounterDetails) throws Exception { String[] environmentCounterIDs = counterDetails.getParameter1().split(","); float matchingCounters = 0f; float sumMatchingCounters = 0f; for(String environmentCounterID: environmentCounterIDs){ int envCountId = Integer.parseInt(environmentCounterID); for(CounterDetailVO couDet: listCounterDetails){ if(couDet.getEnvironmentCounterId() == envCountId){ float metricValue = couDet.getMetricValue(); if(metricValue<0){ metricValue= DBQueryUtil.getTotalTransaction(envCountId); } matchingCounters++; sumMatchingCounters += metricValue; } } } logger.debug("EnvironmentCounterId=" + counterDetails.getEnvironmentCounterId() + "; matchingCounters = " + matchingCounters + "; sumMatchingCounters = " + sumMatchingCounters); if(counterDetails.getParameter2() != null && counterDetails.getParameter2().equalsIgnoreCase("AVG") && matchingCounters > 0){ return sumMatchingCounters/matchingCounters; } return sumMatchingCounters; } }
GlobalCounterHandler extends CounterMetricHandler { @Override public float getCounterMerticValue(CounterDetailVO counterDetails, List<CounterDetailVO> listCounterDetails) throws Exception { String[] environmentCounterIDs = counterDetails.getParameter1().split(","); float matchingCounters = 0f; float sumMatchingCounters = 0f; for(String environmentCounterID: environmentCounterIDs){ int envCountId = Integer.parseInt(environmentCounterID); for(CounterDetailVO couDet: listCounterDetails){ if(couDet.getEnvironmentCounterId() == envCountId){ float metricValue = couDet.getMetricValue(); if(metricValue<0){ metricValue= DBQueryUtil.getTotalTransaction(envCountId); } matchingCounters++; sumMatchingCounters += metricValue; } } } logger.debug("EnvironmentCounterId=" + counterDetails.getEnvironmentCounterId() + "; matchingCounters = " + matchingCounters + "; sumMatchingCounters = " + sumMatchingCounters); if(counterDetails.getParameter2() != null && counterDetails.getParameter2().equalsIgnoreCase("AVG") && matchingCounters > 0){ return sumMatchingCounters/matchingCounters; } return sumMatchingCounters; }  }
GlobalCounterHandler extends CounterMetricHandler { @Override public float getCounterMerticValue(CounterDetailVO counterDetails, List<CounterDetailVO> listCounterDetails) throws Exception { String[] environmentCounterIDs = counterDetails.getParameter1().split(","); float matchingCounters = 0f; float sumMatchingCounters = 0f; for(String environmentCounterID: environmentCounterIDs){ int envCountId = Integer.parseInt(environmentCounterID); for(CounterDetailVO couDet: listCounterDetails){ if(couDet.getEnvironmentCounterId() == envCountId){ float metricValue = couDet.getMetricValue(); if(metricValue<0){ metricValue= DBQueryUtil.getTotalTransaction(envCountId); } matchingCounters++; sumMatchingCounters += metricValue; } } } logger.debug("EnvironmentCounterId=" + counterDetails.getEnvironmentCounterId() + "; matchingCounters = " + matchingCounters + "; sumMatchingCounters = " + sumMatchingCounters); if(counterDetails.getParameter2() != null && counterDetails.getParameter2().equalsIgnoreCase("AVG") && matchingCounters > 0){ return sumMatchingCounters/matchingCounters; } return sumMatchingCounters; }  @Override float getCounterMerticValue(CounterDetailVO counterDetails, List<CounterDetailVO> listCounterDetails); @Override Logger getLogger(); }
GlobalCounterHandler extends CounterMetricHandler { @Override public float getCounterMerticValue(CounterDetailVO counterDetails, List<CounterDetailVO> listCounterDetails) throws Exception { String[] environmentCounterIDs = counterDetails.getParameter1().split(","); float matchingCounters = 0f; float sumMatchingCounters = 0f; for(String environmentCounterID: environmentCounterIDs){ int envCountId = Integer.parseInt(environmentCounterID); for(CounterDetailVO couDet: listCounterDetails){ if(couDet.getEnvironmentCounterId() == envCountId){ float metricValue = couDet.getMetricValue(); if(metricValue<0){ metricValue= DBQueryUtil.getTotalTransaction(envCountId); } matchingCounters++; sumMatchingCounters += metricValue; } } } logger.debug("EnvironmentCounterId=" + counterDetails.getEnvironmentCounterId() + "; matchingCounters = " + matchingCounters + "; sumMatchingCounters = " + sumMatchingCounters); if(counterDetails.getParameter2() != null && counterDetails.getParameter2().equalsIgnoreCase("AVG") && matchingCounters > 0){ return sumMatchingCounters/matchingCounters; } return sumMatchingCounters; }  @Override float getCounterMerticValue(CounterDetailVO counterDetails, List<CounterDetailVO> listCounterDetails); @Override Logger getLogger();  }