List of usage examples for java.util SortedMap get
V get(Object key);
From source file:org.orekit.time.UTCTAIBulletinAFilesLoader.java
/** {@inheritDoc} */ @Override/* w w w . ja v a2 s .c o m*/ public List<OffsetModel> loadOffsets() throws OrekitException { final Parser parser = new Parser(); DataProvidersManager.getInstance().feed(supportedNames, parser); final SortedMap<Integer, Integer> taiUtc = parser.getTaiUtc(); final SortedMap<Integer, Double> ut1Utc = parser.getUt1Utc(); // identify UT1-UTC discontinuities final List<Integer> leapDays = new ArrayList<Integer>(); Map.Entry<Integer, Double> previous = null; for (final Map.Entry<Integer, Double> entry : ut1Utc.entrySet()) { if (previous != null) { final double delta = entry.getValue() - previous.getValue(); if (FastMath.abs(delta) > 0.5) { // discontinuity found between previous and current entry, a leap second has occurred leapDays.add(entry.getKey()); } } previous = entry; } final List<OffsetModel> offsets = new ArrayList<OffsetModel>(); if (!taiUtc.isEmpty()) { // find the start offset, before the first UT1-UTC entry final Map.Entry<Integer, Integer> firstTaiMUtc = taiUtc.entrySet().iterator().next(); int offset = firstTaiMUtc.getValue(); final int refMJD = firstTaiMUtc.getKey(); for (final int leapMJD : leapDays) { if (leapMJD > refMJD) { break; } --offset; } // set all known time steps for (final int leapMJD : leapDays) { offsets.add(new OffsetModel(new DateComponents(DateComponents.MODIFIED_JULIAN_EPOCH, leapMJD), ++offset)); } // check for missing time steps for (final Map.Entry<Integer, Integer> refTaiMUtc : taiUtc.entrySet()) { final DateComponents refDC = new DateComponents(DateComponents.MODIFIED_JULIAN_EPOCH, refTaiMUtc.getKey() + 1); OffsetModel before = null; for (final OffsetModel o : offsets) { if (o.getStart().compareTo(refDC) < 0) { before = o; } } if (before != null) { if (refTaiMUtc.getValue() != (int) FastMath.rint(before.getOffset())) { throw new OrekitException(OrekitMessages.MISSING_EARTH_ORIENTATION_PARAMETERS_BETWEEN_DATES, before.getStart(), refDC); } } } // make sure we stop the linear drift that was used before 1972 if (offsets.isEmpty()) { offsets.add(0, new OffsetModel(new DateComponents(1972, 1, 1), taiUtc.get(taiUtc.firstKey()))); } else { if (offsets.get(0).getStart().getYear() > 1972) { offsets.add(0, new OffsetModel(new DateComponents(1972, 1, 1), ((int) FastMath.rint(offsets.get(0).getOffset())) - 1)); } } } return offsets; }
From source file:org.kuali.kra.budget.calculator.BudgetCalculationServiceImpl.java
/** * //w ww .j a v a2s . c o m * @see org.kuali.kra.budget.calculator.BudgetCalculationService#calculateBudgetTotals(org.kuali.kra.budget.core.Budget) */ @SuppressWarnings("unchecked") public void calculateBudgetTotals(Budget budget) { // do we need to cache the totals ? SortedMap<CostElement, List<BudgetDecimal>> objectCodeTotals = new TreeMap<CostElement, List<BudgetDecimal>>(); SortedMap<RateType, List<BudgetDecimal>> calculatedExpenseTotals = new TreeMap<RateType, List<BudgetDecimal>>(); for (BudgetPeriod budgetPeriod : budget.getBudgetPeriods()) { List<CostElement> objectCodes = new ArrayList<CostElement>(); QueryList lineItemQueryList = new QueryList(); lineItemQueryList.addAll(budgetPeriod.getBudgetLineItems()); budgetPeriod.setExpenseTotal(BudgetDecimal.ZERO); // probably need to add '0' to the period that has no such object code or ratetype ? for (BudgetLineItem budgetLineItem : budgetPeriod.getBudgetLineItems()) { if (budgetLineItem.getCostElementBO() == null) { budgetLineItem.refreshReferenceObject("costElementBO"); } CostElement costElement = budgetLineItem.getCostElementBO(); if (!objectCodes.contains(costElement)) { objectCodes.add(costElement); Equals equalsCostElement = new Equals("costElement", budgetLineItem.getCostElement()); BudgetDecimal objectCodeTotalInThisPeriod = lineItemQueryList.sumObjects("lineItemCost", equalsCostElement); if (!objectCodeTotals.containsKey(costElement)) { // set up for all periods and put into map List<BudgetDecimal> periodTotals = new ArrayList<BudgetDecimal>(); for (int i = 0; i < budget.getBudgetPeriods().size(); i++) { periodTotals.add(i, BudgetDecimal.ZERO); } objectCodeTotals.put(costElement, periodTotals); } objectCodeTotals.get(costElement).set(budgetPeriod.getBudgetPeriod() - 1, objectCodeTotalInThisPeriod); budgetPeriod.setExpenseTotal(budgetPeriod.getExpenseTotal().add(objectCodeTotalInThisPeriod)); } // get calculated expenses QueryList lineItemCalcAmtQueryList = new QueryList(); lineItemCalcAmtQueryList.addAll(budgetLineItem.getBudgetLineItemCalculatedAmounts()); List<RateType> rateTypes = new ArrayList<RateType>(); for (Object item : budgetLineItem.getBudgetLineItemCalculatedAmounts()) { BudgetLineItemCalculatedAmount budgetLineItemCalculatedAmount = (BudgetLineItemCalculatedAmount) item; // if (budgetLineItemCalculatedAmount.getRateType() == null) { // budgetLineItemCalculatedAmount.refreshReferenceObject("rateType"); // } RateType rateType = createRateType(budgetLineItemCalculatedAmount); if (!rateTypes.contains(rateType)) { rateTypes.add(rateType); Equals equalsRC = new Equals("rateClassCode", budgetLineItemCalculatedAmount.getRateClassCode()); Equals equalsRT = new Equals("rateTypeCode", budgetLineItemCalculatedAmount.getRateTypeCode()); And RCandRT = new And(equalsRC, equalsRT); BudgetDecimal rateTypeTotalInThisPeriod = lineItemCalcAmtQueryList .sumObjects("calculatedCost", RCandRT); if (!calculatedExpenseTotals.containsKey(rateType)) { List<BudgetDecimal> rateTypePeriodTotals = new ArrayList<BudgetDecimal>(); for (int i = 0; i < budget.getBudgetPeriods().size(); i++) { rateTypePeriodTotals.add(i, BudgetDecimal.ZERO); } calculatedExpenseTotals.put(rateType, rateTypePeriodTotals); } calculatedExpenseTotals.get(rateType) .set(budgetPeriod.getBudgetPeriod() - 1, ((BudgetDecimal) calculatedExpenseTotals.get(rateType) .get(budgetPeriod.getBudgetPeriod() - 1)) .add(rateTypeTotalInThisPeriod)); budgetPeriod.setExpenseTotal(budgetPeriod.getExpenseTotal().add(rateTypeTotalInThisPeriod)); } } } } budget.setObjectCodeTotals(objectCodeTotals); budget.setCalculatedExpenseTotals(calculatedExpenseTotals); }
From source file:org.apache.accumulo.server.tabletserver.ScanRunState.java
public static Pair<Text, KeyExtent> verifyTabletInformation(KeyExtent extent, TServerInstance instance, SortedMap<Key, Value> tabletsKeyValues, String clientAddress, ZooLock lock) throws AccumuloSecurityException, DistributedStoreException, AccumuloException { log.debug("verifying extent " + extent); if (extent.isRootTablet()) { return verifyRootTablet(extent, instance); }/*from w w w. ja v a 2 s .com*/ String tableToVerify = MetadataTable.ID; if (extent.isMeta()) tableToVerify = RootTable.ID; List<ColumnFQ> columnsToFetch = Arrays .asList(new ColumnFQ[] { TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN, TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN, TabletsSection.TabletColumnFamily.SPLIT_RATIO_COLUMN, TabletsSection.TabletColumnFamily.OLD_PREV_ROW_COLUMN, TabletsSection.ServerColumnFamily.TIME_COLUMN }); ScannerImpl scanner = new ScannerImpl(HdfsZooInstance.getInstance(), SystemCredentials.get(), tableToVerify, Authorizations.EMPTY); scanner.setRange(extent.toMetadataRange()); TreeMap<Key, Value> tkv = new TreeMap<Key, Value>(); for (Entry<Key, Value> entry : scanner) tkv.put(entry.getKey(), entry.getValue()); // only populate map after success if (tabletsKeyValues == null) { tabletsKeyValues = tkv; } else { tabletsKeyValues.clear(); tabletsKeyValues.putAll(tkv); } Text metadataEntry = extent.getMetadataEntry(); Value dir = checkTabletMetadata(extent, instance, tabletsKeyValues, metadataEntry); if (dir == null) return null; Value oldPrevEndRow = null; for (Entry<Key, Value> entry : tabletsKeyValues.entrySet()) { if (TabletsSection.TabletColumnFamily.OLD_PREV_ROW_COLUMN.hasColumns(entry.getKey())) { oldPrevEndRow = entry.getValue(); } } if (oldPrevEndRow != null) { SortedMap<Text, SortedMap<ColumnFQ, Value>> tabletEntries; tabletEntries = MetadataTableUtil.getTabletEntries(tabletsKeyValues, columnsToFetch); KeyExtent fke; try { fke = MetadataTableUtil.fixSplit(metadataEntry, tabletEntries.get(metadataEntry), instance, SystemCredentials.get(), lock); } catch (IOException e) { log.error("Error fixing split " + metadataEntry); throw new AccumuloException(e.toString()); } if (!fke.equals(extent)) { return new Pair<Text, KeyExtent>(null, fke); } // reread and reverify metadata entries now that metadata entries were fixed tabletsKeyValues.clear(); return verifyTabletInformation(fke, instance, tabletsKeyValues, clientAddress, lock); } return new Pair<Text, KeyExtent>(new Text(dir.get()), null); }
From source file:com.aurel.track.report.dashboard.AverageTimeToCloseItem.java
private SortedMap<Integer, SortedMap<Integer, Double>> createYearToIntervalToAvgTimeMap(Integer timeInterval, Set<Integer> finalStates, int selectedTimeFormat) { SortedMap<Integer, SortedMap<Integer, ArrayList<ReportBeanWithHistory>>> yearToIntervalToReportBeanList = createYearToIntervalToReportBeanListMap( timeInterval, finalStates);//from w w w. jav a 2 s .co m SortedMap<Integer, SortedMap<Integer, Double>> yearToIntervalToAverageValue = new TreeMap<Integer, SortedMap<Integer, Double>>(); for (Map.Entry<Integer, SortedMap<Integer, ArrayList<ReportBeanWithHistory>>> yearToIntervalEntry : yearToIntervalToReportBeanList .entrySet()) { Integer year = yearToIntervalEntry.getKey(); SortedMap<Integer, ArrayList<ReportBeanWithHistory>> intervalToReportBeanList = yearToIntervalEntry .getValue(); yearToIntervalToAverageValue.put(year, new TreeMap<Integer, Double>()); for (Entry<Integer, ArrayList<ReportBeanWithHistory>> intervalToWorkItemsListEntry : intervalToReportBeanList .entrySet()) { Integer interval = intervalToWorkItemsListEntry.getKey(); ArrayList<ReportBeanWithHistory> reportBeanLists = intervalToWorkItemsListEntry.getValue(); int count = 0; int sumOfDaysOrWorkingHours = 0; for (ReportBeanWithHistory reportBean : reportBeanLists) { Integer stateID = getReportBeanStateID(reportBean); Date lastStateChangeDate = getReportBeanLastStateChange(reportBean); if (stateID == null || lastStateChangeDate == null) { continue; } count++; int valueToAdd = getNumberOfDaysBetweenDates(reportBean.getWorkItemBean().getCreated(), lastStateChangeDate); //It was closed on same day when it was created => 1 day if (valueToAdd == 0) { valueToAdd = 1; } if (selectedTimeFormat == TIME_FORMAT.WORKING_HOURS) { Double workingDaysHourse = hoursPerWorkingDayMap .get(reportBean.getWorkItemBean().getProjectID()); if (workingDaysHourse == null) { workingDaysHourse = 8.0; } valueToAdd *= workingDaysHourse; } sumOfDaysOrWorkingHours += valueToAdd; } Double avg = 0.0; if (count > 0) { avg = (double) sumOfDaysOrWorkingHours / count; } yearToIntervalToAverageValue.get(year).put(interval, avg); } } return yearToIntervalToAverageValue; }
From source file:org.apache.hadoop.hive.ql.QTestUtil.java
public static void setupMetaStoreTableColumnStatsFor30TBTPCDSWorkload(HiveConf conf) { Connection conn = null;/*w ww . j a v a 2s .co m*/ ArrayList<Statement> statements = new ArrayList<Statement>(); // list of Statements, PreparedStatements try { Properties props = new Properties(); // connection properties props.put("user", conf.get("javax.jdo.option.ConnectionUserName")); props.put("password", conf.get("javax.jdo.option.ConnectionPassword")); conn = DriverManager.getConnection(conf.get("javax.jdo.option.ConnectionURL"), props); ResultSet rs = null; Statement s = conn.createStatement(); if (LOG.isDebugEnabled()) { LOG.debug("Connected to metastore database "); } String mdbPath = AbstractCliConfig.HIVE_ROOT + "/data/files/tpcds-perf/metastore_export/"; // Setup the table column stats BufferedReader br = new BufferedReader(new FileReader(new File( AbstractCliConfig.HIVE_ROOT + "/metastore/scripts/upgrade/derby/022-HIVE-11107.derby.sql"))); String command; s.execute("DROP TABLE APP.TABLE_PARAMS"); s.execute("DROP TABLE APP.TAB_COL_STATS"); // Create the column stats table while ((command = br.readLine()) != null) { if (!command.endsWith(";")) { continue; } if (LOG.isDebugEnabled()) { LOG.debug("Going to run command : " + command); } try { PreparedStatement psCommand = conn.prepareStatement(command.substring(0, command.length() - 1)); statements.add(psCommand); psCommand.execute(); if (LOG.isDebugEnabled()) { LOG.debug("successfully completed " + command); } } catch (SQLException e) { LOG.info("Got SQL Exception " + e.getMessage()); } } br.close(); java.nio.file.Path tabColStatsCsv = FileSystems.getDefault().getPath(mdbPath, "csv", "TAB_COL_STATS.txt.bz2"); java.nio.file.Path tabParamsCsv = FileSystems.getDefault().getPath(mdbPath, "csv", "TABLE_PARAMS.txt.bz2"); // Set up the foreign key constraints properly in the TAB_COL_STATS data String tmpBaseDir = System.getProperty(TEST_TMP_DIR_PROPERTY); java.nio.file.Path tmpFileLoc1 = FileSystems.getDefault().getPath(tmpBaseDir, "TAB_COL_STATS.txt"); java.nio.file.Path tmpFileLoc2 = FileSystems.getDefault().getPath(tmpBaseDir, "TABLE_PARAMS.txt"); class MyComp implements Comparator<String> { @Override public int compare(String str1, String str2) { if (str2.length() != str1.length()) { return str2.length() - str1.length(); } return str1.compareTo(str2); } } final SortedMap<String, Integer> tableNameToID = new TreeMap<String, Integer>(new MyComp()); rs = s.executeQuery("SELECT * FROM APP.TBLS"); while (rs.next()) { String tblName = rs.getString("TBL_NAME"); Integer tblId = rs.getInt("TBL_ID"); tableNameToID.put(tblName, tblId); if (LOG.isDebugEnabled()) { LOG.debug("Resultset : " + tblName + " | " + tblId); } } final Map<String, Map<String, String>> data = new HashMap<>(); rs = s.executeQuery("select TBLS.TBL_NAME, a.COLUMN_NAME, a.TYPE_NAME from " + "(select COLUMN_NAME, TYPE_NAME, SDS.SD_ID from APP.COLUMNS_V2 join APP.SDS on SDS.CD_ID = COLUMNS_V2.CD_ID) a" + " join APP.TBLS on TBLS.SD_ID = a.SD_ID"); while (rs.next()) { String tblName = rs.getString(1); String colName = rs.getString(2); String typeName = rs.getString(3); Map<String, String> cols = data.get(tblName); if (null == cols) { cols = new HashMap<>(); } cols.put(colName, typeName); data.put(tblName, cols); } BufferedReader reader = new BufferedReader(new InputStreamReader( new BZip2CompressorInputStream(Files.newInputStream(tabColStatsCsv, StandardOpenOption.READ)))); Stream<String> replaced = reader.lines().parallel().map(str -> { String[] splits = str.split(","); String tblName = splits[0]; String colName = splits[1]; Integer tblID = tableNameToID.get(tblName); StringBuilder sb = new StringBuilder( "default@" + tblName + "@" + colName + "@" + data.get(tblName).get(colName) + "@"); for (int i = 2; i < splits.length; i++) { sb.append(splits[i] + "@"); } // Add tbl_id and empty bitvector return sb.append(tblID).append("@").toString(); }); Files.write(tmpFileLoc1, (Iterable<String>) replaced::iterator); replaced.close(); reader.close(); BufferedReader reader2 = new BufferedReader(new InputStreamReader( new BZip2CompressorInputStream(Files.newInputStream(tabParamsCsv, StandardOpenOption.READ)))); final Map<String, String> colStats = new ConcurrentHashMap<>(); Stream<String> replacedStream = reader2.lines().parallel().map(str -> { String[] splits = str.split("_@"); String tblName = splits[0]; Integer tblId = tableNameToID.get(tblName); Map<String, String> cols = data.get(tblName); StringBuilder sb = new StringBuilder(); sb.append("{\"COLUMN_STATS\":{"); for (String colName : cols.keySet()) { sb.append("\"" + colName + "\":\"true\","); } sb.append("},\"BASIC_STATS\":\"true\"}"); colStats.put(tblId.toString(), sb.toString()); return tblId.toString() + "@" + splits[1]; }); Files.write(tmpFileLoc2, (Iterable<String>) replacedStream::iterator); Files.write(tmpFileLoc2, (Iterable<String>) colStats.entrySet().stream() .map(map -> map.getKey() + "@COLUMN_STATS_ACCURATE@" + map.getValue())::iterator, StandardOpenOption.APPEND); replacedStream.close(); reader2.close(); // Load the column stats and table params with 30 TB scale String importStatement1 = "CALL SYSCS_UTIL.SYSCS_IMPORT_TABLE(null, '" + "TAB_COL_STATS" + "', '" + tmpFileLoc1.toAbsolutePath().toString() + "', '@', null, 'UTF-8', 1)"; String importStatement2 = "CALL SYSCS_UTIL.SYSCS_IMPORT_TABLE(null, '" + "TABLE_PARAMS" + "', '" + tmpFileLoc2.toAbsolutePath().toString() + "', '@', null, 'UTF-8', 1)"; try { PreparedStatement psImport1 = conn.prepareStatement(importStatement1); if (LOG.isDebugEnabled()) { LOG.debug("Going to execute : " + importStatement1); } statements.add(psImport1); psImport1.execute(); if (LOG.isDebugEnabled()) { LOG.debug("successfully completed " + importStatement1); } PreparedStatement psImport2 = conn.prepareStatement(importStatement2); if (LOG.isDebugEnabled()) { LOG.debug("Going to execute : " + importStatement2); } statements.add(psImport2); psImport2.execute(); if (LOG.isDebugEnabled()) { LOG.debug("successfully completed " + importStatement2); } } catch (SQLException e) { LOG.info("Got SQL Exception " + e.getMessage()); } } catch (FileNotFoundException e1) { LOG.info("Got File not found Exception " + e1.getMessage()); } catch (IOException e1) { LOG.info("Got IOException " + e1.getMessage()); } catch (SQLException e1) { LOG.info("Got SQLException " + e1.getMessage()); } finally { // Statements and PreparedStatements int i = 0; while (!statements.isEmpty()) { // PreparedStatement extend Statement Statement st = statements.remove(i); try { if (st != null) { st.close(); st = null; } } catch (SQLException sqle) { } } //Connection try { if (conn != null) { conn.close(); conn = null; } } catch (SQLException sqle) { } } }
From source file:org.wso2.carbon.ml.database.internal.MLDatabaseService.java
/** * Create the JSON string with summary statistics for a column. * * @param type Data-type of the column//w ww. j av a 2s.c o m * @param graphFrequencies Bin frequencies of the column * @param missing Number of missing values in the column * @param unique Number of unique values in the column * @param descriptiveStats DescriptiveStats object of the column * @return JSON representation of the summary statistics of the column */ private JSONArray createJson(String type, SortedMap<?, Integer> graphFrequencies, int missing, int unique, DescriptiveStatistics descriptiveStats) throws JSONException { JSONObject json = new JSONObject(); JSONArray freqs = new JSONArray(); Object[] categoryNames = graphFrequencies.keySet().toArray(); // Create an array with intervals/categories and their frequencies. for (int i = 0; i < graphFrequencies.size(); i++) { JSONArray temp = new JSONArray(); temp.put(categoryNames[i].toString()); temp.put(graphFrequencies.get(categoryNames[i])); freqs.put(temp); } // Put the statistics to a json object json.put("unique", unique); json.put("missing", missing); DecimalFormat decimalFormat = new DecimalFormat("#.###"); if (descriptiveStats.getN() != 0) { json.put("mean", decimalFormat.format(descriptiveStats.getMean())); json.put("min", decimalFormat.format(descriptiveStats.getMin())); json.put("max", decimalFormat.format(descriptiveStats.getMax())); json.put("median", decimalFormat.format(descriptiveStats.getPercentile(50))); json.put("std", decimalFormat.format(descriptiveStats.getStandardDeviation())); if (type.equalsIgnoreCase(FeatureType.NUMERICAL)) { json.put("skewness", decimalFormat.format(descriptiveStats.getSkewness())); } } json.put("values", freqs); json.put("bar", true); json.put("key", "Frequency"); JSONArray summaryStatArray = new JSONArray(); summaryStatArray.put(json); return summaryStatArray; }
From source file:org.kuali.coeus.common.budget.impl.calculator.BudgetCalculationServiceImpl.java
@Deprecated protected void calculateBudgetTotals(Budget budget) { // do we need to cache the totals ? SortedMap<CostElement, List<ScaleTwoDecimal>> objectCodeTotals = new TreeMap<>(); SortedMap<RateType, List<ScaleTwoDecimal>> calculatedExpenseTotals = new TreeMap<>(); for (BudgetPeriod budgetPeriod : budget.getBudgetPeriods()) { List<CostElement> objectCodes = new ArrayList<>(); QueryList<BudgetLineItem> lineItemQueryList = new QueryList<>(); lineItemQueryList.addAll(budgetPeriod.getBudgetLineItems()); budgetPeriod.setExpenseTotal(ScaleTwoDecimal.ZERO); // probably need to add '0' to the period that has no such object code or ratetype ? for (BudgetLineItem budgetLineItem : budgetPeriod.getBudgetLineItems()) { if (budgetLineItem.getCostElementBO() == null) { budgetLineItem.refreshReferenceObject("costElementBO"); }//from www . ja v a 2 s .co m CostElement costElement = budgetLineItem.getCostElementBO(); if (!objectCodes.contains(costElement)) { objectCodes.add(costElement); Equals equalsCostElement = new Equals("costElement", budgetLineItem.getCostElement()); ScaleTwoDecimal objectCodeTotalInThisPeriod = lineItemQueryList.sumObjects("lineItemCost", equalsCostElement); if (!objectCodeTotals.containsKey(costElement)) { // set up for all periods and put into map List<ScaleTwoDecimal> periodTotals = new ArrayList<>(); for (int i = 0; i < budget.getBudgetPeriods().size(); i++) { periodTotals.add(i, ScaleTwoDecimal.ZERO); } objectCodeTotals.put(costElement, periodTotals); } objectCodeTotals.get(costElement).set(budgetPeriod.getBudgetPeriod() - 1, objectCodeTotalInThisPeriod); budgetPeriod.setExpenseTotal(budgetPeriod.getExpenseTotal().add(objectCodeTotalInThisPeriod)); } // get calculated expenses QueryList<BudgetLineItemCalculatedAmount> lineItemCalcAmtQueryList = new QueryList<>(); lineItemCalcAmtQueryList.addAll(budgetLineItem.getBudgetLineItemCalculatedAmounts()); List<RateType> rateTypes = new ArrayList<>(); for (Object item : budgetLineItem.getBudgetLineItemCalculatedAmounts()) { BudgetLineItemCalculatedAmount budgetLineItemCalculatedAmount = (BudgetLineItemCalculatedAmount) item; RateType rateType = createRateType(budgetLineItemCalculatedAmount); if (!rateTypes.contains(rateType)) { rateTypes.add(rateType); Equals equalsRC = new Equals("rateClassCode", budgetLineItemCalculatedAmount.getRateClassCode()); Equals equalsRT = new Equals("rateTypeCode", budgetLineItemCalculatedAmount.getRateTypeCode()); And RCandRT = new And(equalsRC, equalsRT); ScaleTwoDecimal rateTypeTotalInThisPeriod = lineItemCalcAmtQueryList .sumObjects(CALCULATED_COST, RCandRT); if (!calculatedExpenseTotals.containsKey(rateType)) { List<ScaleTwoDecimal> rateTypePeriodTotals = new ArrayList<>(); for (int i = 0; i < budget.getBudgetPeriods().size(); i++) { rateTypePeriodTotals.add(i, ScaleTwoDecimal.ZERO); } calculatedExpenseTotals.put(rateType, rateTypePeriodTotals); } calculatedExpenseTotals.get(rateType).set(budgetPeriod.getBudgetPeriod() - 1, (calculatedExpenseTotals.get(rateType).get(budgetPeriod.getBudgetPeriod() - 1)) .add(rateTypeTotalInThisPeriod)); budgetPeriod.setExpenseTotal(budgetPeriod.getExpenseTotal().add(rateTypeTotalInThisPeriod)); } } } } budget.setObjectCodeTotals(objectCodeTotals); budget.setCalculatedExpenseTotals(calculatedExpenseTotals); }
From source file:org.jahia.admin.sites.ManageSites.java
private Locale determineDefaultLocale(ProcessingContext jParams, Map<Object, Object> infos) { Locale defaultLocale = jParams.getLocale(); SortedMap<Integer, String> activeLanguageCodesByRank = new TreeMap<Integer, String>(); for (Map.Entry<Object, Object> info : infos.entrySet()) { if (info.getKey() instanceof String) { Matcher m = LANGUAGE_RANK_PATTERN.matcher((String) info.getKey()); if (m.find()) { String languageCode = m.group(1); boolean activated = Boolean .parseBoolean((String) infos.get("language." + languageCode + ".activated")); if (activated) { if ("1".equals(info.getValue())) { return LanguageCodeConverters.languageCodeToLocale(languageCode); } else { activeLanguageCodesByRank.put(new Integer((String) info.getValue()), languageCode); }/*from w w w . jav a 2 s .co m*/ } } } } if (!activeLanguageCodesByRank.isEmpty()) { defaultLocale = LanguageCodeConverters .languageCodeToLocale(activeLanguageCodesByRank.get(activeLanguageCodesByRank.firstKey())); } return defaultLocale; }
From source file:org.kuali.kra.budget.calculator.BudgetCalculationServiceImpl.java
public void calculateBudgetSummaryTotals(Budget budget) { calculateBudgetTotals(budget);// w w w . j a v a2 s . c o m //Categorize all Object Codes per their Category Type SortedMap<BudgetCategoryType, List<CostElement>> objectCodeListByBudgetCategoryType = categorizeObjectCodesByCategory( budget); SortedMap<CostElement, List<BudgetPersonnelDetails>> objectCodeUniquePersonnelList = new TreeMap<CostElement, List<BudgetPersonnelDetails>>(); SortedMap<String, List<BudgetDecimal>> objectCodePersonnelSalaryTotals = new TreeMap<String, List<BudgetDecimal>>(); SortedMap<String, List<BudgetDecimal>> objectCodePersonnelFringeTotals = new TreeMap<String, List<BudgetDecimal>>(); //Temp collections for maintaining Sub Section Totals SortedSet<String> objectCodePersonnelSalaryTotalsByPeriod = new TreeSet<String>(); SortedSet<String> objectCodePersonnelFringeTotalsByPeriod = new TreeSet<String>(); SortedMap<RateType, List<BudgetDecimal>> personnelCalculatedExpenseTotals = new TreeMap<RateType, List<BudgetDecimal>>(); SortedMap<RateType, List<BudgetDecimal>> nonPersonnelCalculatedExpenseTotals = new TreeMap<RateType, List<BudgetDecimal>>(); List<BudgetDecimal> periodSummarySalaryTotals = new ArrayList<BudgetDecimal>(); for (int i = 0; i < budget.getBudgetPeriods().size(); i++) { periodSummarySalaryTotals.add(i, BudgetDecimal.ZERO); } List<BudgetDecimal> periodSummaryFringeTotals = new ArrayList<BudgetDecimal>(); for (int i = 0; i < budget.getBudgetPeriods().size(); i++) { periodSummaryFringeTotals.add(i, BudgetDecimal.ZERO); } SortedMap<String, List<BudgetDecimal>> subTotalsBySubSection = new TreeMap<String, List<BudgetDecimal>>(); subTotalsBySubSection.put("personnelSalaryTotals", periodSummarySalaryTotals); subTotalsBySubSection.put("personnelFringeTotals", periodSummaryFringeTotals); //Loop thru the Personnel Object Codes - to calculate Salary, Fringe Totals etc.. per person BudgetCategoryType personnelCategory = getPersonnelCategoryType(); List<CostElement> personnelObjectCodes = objectCodeListByBudgetCategoryType.get(personnelCategory); if (CollectionUtils.isNotEmpty(personnelObjectCodes)) { for (CostElement personnelCostElement : personnelObjectCodes) { if (!objectCodeUniquePersonnelList.containsKey(personnelCostElement)) { objectCodeUniquePersonnelList.put(personnelCostElement, new ArrayList<BudgetPersonnelDetails>()); } for (BudgetPeriod budgetPeriod : budget.getBudgetPeriods()) { budgetPeriod.setBudget(budget); QueryList lineItemQueryList = new QueryList(); lineItemQueryList.addAll(budgetPeriod.getBudgetLineItems()); Equals objectCodeEquals = new Equals("costElement", personnelCostElement.getCostElement()); QueryList<BudgetLineItem> filteredLineItems = lineItemQueryList.filter(objectCodeEquals); QueryList personnelQueryList = new QueryList(); //Loop thru the matching Line Items to gather personnel info for (BudgetLineItem matchingLineItem : filteredLineItems) { personnelQueryList.addAll(matchingLineItem.getBudgetPersonnelDetailsList()); } int matchingLineItemIndex = 0; for (BudgetLineItem matchingLineItem : filteredLineItems) { for (BudgetPersonnelDetails budgetPersonnelDetails : matchingLineItem .getBudgetPersonnelDetailsList()) { budgetPersonnelDetails.refreshReferenceObject("budgetPerson"); Equals personIdEquals = new Equals("personId", budgetPersonnelDetails.getPersonId()); QueryList personOccurrencesForSameObjectCode = personnelQueryList .filter(personIdEquals); //Calculate the Salary Totals for each Person BudgetDecimal personSalaryTotalsForCurrentPeriod = personOccurrencesForSameObjectCode .sumObjects("salaryRequested"); if (!objectCodePersonnelSalaryTotals.containsKey(matchingLineItem.getCostElement() + "," + budgetPersonnelDetails.getPersonId())) { objectCodeUniquePersonnelList.get(matchingLineItem.getCostElementBO()) .add(budgetPersonnelDetails); // set up for all periods and put into map List<BudgetDecimal> periodTotals = new ArrayList<BudgetDecimal>(); for (int i = 0; i < budget.getBudgetPeriods().size(); i++) { periodTotals.add(i, BudgetDecimal.ZERO); } objectCodePersonnelSalaryTotals.put(matchingLineItem.getCostElement() + "," + budgetPersonnelDetails.getPersonId(), periodTotals); } //Setting the total lines here - so that they'll be set just once for a unique person within an Object Code objectCodePersonnelSalaryTotals .get(matchingLineItem.getCostElement() + "," + budgetPersonnelDetails.getPersonId()) .set(budgetPeriod.getBudgetPeriod() - 1, personSalaryTotalsForCurrentPeriod); //subTotalsBySubSection.get("personnelSalaryTotals").set(budgetPeriod.getBudgetPeriod() - 1, ((BudgetDecimal) (subTotalsBySubSection.get("personnelSalaryTotals").get(budgetPeriod.getBudgetPeriod() - 1))).add(personSalaryTotalsForCurrentPeriod)); if (objectCodePersonnelSalaryTotalsByPeriod .add(budgetPeriod.getBudgetPeriod().toString() + "," + matchingLineItem.getCostElement() + "," + budgetPersonnelDetails.getPersonId())) { subTotalsBySubSection.get("personnelSalaryTotals").set( budgetPeriod.getBudgetPeriod() - 1, ((BudgetDecimal) (subTotalsBySubSection.get("personnelSalaryTotals") .get(budgetPeriod.getBudgetPeriod() - 1))) .add(personSalaryTotalsForCurrentPeriod)); } //Calculate the Fringe Totals for each Person if (!objectCodePersonnelFringeTotals.containsKey(matchingLineItem.getCostElement() + "," + budgetPersonnelDetails.getPersonId())) { // set up for all periods and put into map List<BudgetDecimal> periodFringeTotals = new ArrayList<BudgetDecimal>(); for (int i = 0; i < budget.getBudgetPeriods().size(); i++) { periodFringeTotals.add(i, BudgetDecimal.ZERO); } objectCodePersonnelFringeTotals.put(matchingLineItem.getCostElement() + "," + budgetPersonnelDetails.getPersonId(), periodFringeTotals); } BudgetDecimal personFringeTotalsForCurrentPeriod = BudgetDecimal.ZERO; // if(!isSummaryCalcAmountChanged(budget,budgetPeriod)){ //Calculate the Fringe Totals for that Person (cumulative fringe for all occurrences of the person) for (Object person : personOccurrencesForSameObjectCode) { BudgetPersonnelDetails personOccurrence = (BudgetPersonnelDetails) person; for (BudgetPersonnelCalculatedAmount calcExpenseAmount : personOccurrence .getBudgetPersonnelCalculatedAmounts()) { calcExpenseAmount.refreshReferenceObject("rateClass"); //Check for Employee Benefits RateClassType if (calcExpenseAmount.getRateClass().getRateClassType().equalsIgnoreCase("E")) { personFringeTotalsForCurrentPeriod = personFringeTotalsForCurrentPeriod .add(calcExpenseAmount.getCalculatedCost()); } } } objectCodePersonnelFringeTotals .get(matchingLineItem.getCostElement() + "," + budgetPersonnelDetails.getPersonId()) .set(budgetPeriod.getBudgetPeriod() - 1, personFringeTotalsForCurrentPeriod); //subTotalsBySubSection.get("personnelFringeTotals").set(budgetPeriod.getBudgetPeriod() - 1, ((BudgetDecimal) (subTotalsBySubSection.get("personnelFringeTotals").get(budgetPeriod.getBudgetPeriod() - 1))).add(personFringeTotalsForCurrentPeriod)); // } if (objectCodePersonnelFringeTotalsByPeriod .add(budgetPeriod.getBudgetPeriod().toString() + "," + matchingLineItem.getCostElement() + "," + budgetPersonnelDetails.getPersonId())) { subTotalsBySubSection.get("personnelFringeTotals").set( budgetPeriod.getBudgetPeriod() - 1, ((BudgetDecimal) (subTotalsBySubSection.get("personnelFringeTotals") .get(budgetPeriod.getBudgetPeriod() - 1))) .add(personFringeTotalsForCurrentPeriod)); } } //Need to handle the Summary Items - if any if (CollectionUtils.isEmpty(matchingLineItem.getBudgetPersonnelDetailsList())) { //Include Summary Item Salary (Line Item Cost) if (!objectCodePersonnelSalaryTotals.containsKey(matchingLineItem.getCostElement())) { // set up for all periods and put into map List<BudgetDecimal> periodTotals = new ArrayList<BudgetDecimal>(); for (int i = 0; i < budget.getBudgetPeriods().size(); i++) { periodTotals.add(i, BudgetDecimal.ZERO); } objectCodePersonnelSalaryTotals.put(matchingLineItem.getCostElement(), periodTotals); } objectCodePersonnelSalaryTotals.get(matchingLineItem.getCostElement()).set( budgetPeriod.getBudgetPeriod() - 1, ((BudgetDecimal) objectCodePersonnelSalaryTotals .get(matchingLineItem.getCostElement()) .get(budgetPeriod.getBudgetPeriod() - 1)) .add(matchingLineItem.getLineItemCost())); //Include Summary Item Fringe Amt BudgetDecimal summaryFringeTotalsForCurrentPeriod = BudgetDecimal.ZERO; if (!objectCodePersonnelFringeTotals.containsKey(matchingLineItem.getCostElement())) { // set up for all periods and put into map List<BudgetDecimal> periodFringeTotals = new ArrayList<BudgetDecimal>(); for (int i = 0; i < budget.getBudgetPeriods().size(); i++) { periodFringeTotals.add(i, BudgetDecimal.ZERO); } objectCodePersonnelFringeTotals.put(matchingLineItem.getCostElement(), periodFringeTotals); } for (BudgetLineItemCalculatedAmount lineItemCalculatedAmount : matchingLineItem .getBudgetLineItemCalculatedAmounts()) { lineItemCalculatedAmount.refreshReferenceObject("rateClass"); //Check for Employee Benefits RateClassType if (lineItemCalculatedAmount.getRateClass().getRateClassType() .equalsIgnoreCase("E")) { summaryFringeTotalsForCurrentPeriod = summaryFringeTotalsForCurrentPeriod .add(lineItemCalculatedAmount.getCalculatedCost()); } } objectCodePersonnelFringeTotals.get(matchingLineItem.getCostElement()).set( budgetPeriod.getBudgetPeriod() - 1, ((BudgetDecimal) objectCodePersonnelFringeTotals .get(matchingLineItem.getCostElement()) .get(budgetPeriod.getBudgetPeriod() - 1)) .add(summaryFringeTotalsForCurrentPeriod)); //if(matchingLineItemIndex == filteredLineItems.size()-1) { subTotalsBySubSection.get("personnelSalaryTotals").set( budgetPeriod.getBudgetPeriod() - 1, ((BudgetDecimal) (subTotalsBySubSection.get("personnelSalaryTotals") .get(budgetPeriod.getBudgetPeriod() - 1))) .add((BudgetDecimal) (objectCodePersonnelSalaryTotals .get(matchingLineItem.getCostElement()) .get(budgetPeriod.getBudgetPeriod() - 1)))); subTotalsBySubSection.get("personnelFringeTotals").set( budgetPeriod.getBudgetPeriod() - 1, ((BudgetDecimal) (subTotalsBySubSection.get("personnelFringeTotals") .get(budgetPeriod.getBudgetPeriod() - 1))) .add((BudgetDecimal) (objectCodePersonnelFringeTotals .get(matchingLineItem.getCostElement()) .get(budgetPeriod.getBudgetPeriod() - 1)))); //} } matchingLineItemIndex++; } } //Budget Period Looping Ends here } //Personnel Object Code Looping Ends here } budget.setBudgetSummaryTotals(subTotalsBySubSection); personnelCalculatedExpenseTotals = calculateExpenseTotals(budget, true); nonPersonnelCalculatedExpenseTotals = calculateExpenseTotals(budget, false); budget.setObjectCodeListByBudgetCategoryType(objectCodeListByBudgetCategoryType); //budget.setObjectCodePersonnelList(objectCodePersonnelList); budget.setObjectCodePersonnelList(objectCodeUniquePersonnelList); budget.setObjectCodePersonnelSalaryTotals(objectCodePersonnelSalaryTotals); budget.setObjectCodePersonnelFringeTotals(objectCodePersonnelFringeTotals); budget.setPersonnelCalculatedExpenseTotals(personnelCalculatedExpenseTotals); budget.setNonPersonnelCalculatedExpenseTotals(nonPersonnelCalculatedExpenseTotals); calculateNonPersonnelSummaryTotals(budget); populateBudgetPeriodSummaryCalcAmounts(budget); }
From source file:org.kuali.coeus.common.budget.impl.calculator.BudgetCalculationServiceImpl.java
@Deprecated @Override// ww w. j a va 2 s . c o m public void calculateBudgetSummaryTotals(Budget budget) { calculateBudgetTotals(budget); //Categorize all Object Codes per their Category Type SortedMap<BudgetCategoryType, List<CostElement>> objectCodeListByBudgetCategoryType = categorizeObjectCodesByCategory( budget); SortedMap<CostElement, List<BudgetPersonnelDetails>> objectCodeUniquePersonnelList = new TreeMap<>(); SortedMap<String, List<ScaleTwoDecimal>> objectCodePersonnelSalaryTotals = new TreeMap<>(); SortedMap<String, List<ScaleTwoDecimal>> objectCodePersonnelFringeTotals = new TreeMap<>(); //Temp collections for maintaining Sub Section Totals SortedSet<String> objectCodePersonnelSalaryTotalsByPeriod = new TreeSet<>(); SortedSet<String> objectCodePersonnelFringeTotalsByPeriod = new TreeSet<>(); SortedMap<RateType, List<ScaleTwoDecimal>> personnelCalculatedExpenseTotals = new TreeMap<>(); SortedMap<RateType, List<ScaleTwoDecimal>> nonPersonnelCalculatedExpenseTotals = new TreeMap<>(); List<ScaleTwoDecimal> periodSummarySalaryTotals = new ArrayList<>(); for (int i = 0; i < budget.getBudgetPeriods().size(); i++) { periodSummarySalaryTotals.add(i, ScaleTwoDecimal.ZERO); } List<ScaleTwoDecimal> periodSummaryFringeTotals = new ArrayList<>(); for (int i = 0; i < budget.getBudgetPeriods().size(); i++) { periodSummaryFringeTotals.add(i, ScaleTwoDecimal.ZERO); } SortedMap<String, List<ScaleTwoDecimal>> subTotalsBySubSection = new TreeMap<>(); subTotalsBySubSection.put("personnelSalaryTotals", periodSummarySalaryTotals); subTotalsBySubSection.put("personnelFringeTotals", periodSummaryFringeTotals); //Loop thru the Personnel Object Codes - to calculate Salary, Fringe Totals etc.. per person BudgetCategoryType personnelCategory = getPersonnelCategoryType(); List<CostElement> personnelObjectCodes = objectCodeListByBudgetCategoryType.get(personnelCategory); if (CollectionUtils.isNotEmpty(personnelObjectCodes)) { for (CostElement personnelCostElement : personnelObjectCodes) { if (!objectCodeUniquePersonnelList.containsKey(personnelCostElement)) { objectCodeUniquePersonnelList.put(personnelCostElement, new ArrayList<BudgetPersonnelDetails>()); } for (BudgetPeriod budgetPeriod : budget.getBudgetPeriods()) { budgetPeriod.setBudget(budget); QueryList<BudgetLineItem> lineItemQueryList = new QueryList<>(); lineItemQueryList.addAll(budgetPeriod.getBudgetLineItems()); Equals objectCodeEquals = new Equals("costElement", personnelCostElement.getCostElement()); QueryList<BudgetLineItem> filteredLineItems = lineItemQueryList.filter(objectCodeEquals); QueryList<BudgetPersonnelDetails> personnelQueryList = new QueryList<>(); //Loop thru the matching Line Items to gather personnel info for (BudgetLineItem matchingLineItem : filteredLineItems) { personnelQueryList.addAll(matchingLineItem.getBudgetPersonnelDetailsList()); } for (BudgetLineItem matchingLineItem : filteredLineItems) { for (BudgetPersonnelDetails budgetPersonnelDetails : matchingLineItem .getBudgetPersonnelDetailsList()) { Equals personIdEquals = new Equals("personId", budgetPersonnelDetails.getPersonId()); QueryList personOccurrencesForSameObjectCode = personnelQueryList .filter(personIdEquals); //Calculate the Salary Totals for each Person ScaleTwoDecimal personSalaryTotalsForCurrentPeriod = personOccurrencesForSameObjectCode .sumObjects("salaryRequested"); if (!objectCodePersonnelSalaryTotals.containsKey(matchingLineItem.getCostElement() + "," + budgetPersonnelDetails.getPersonId())) { objectCodeUniquePersonnelList.get(matchingLineItem.getCostElementBO()) .add(budgetPersonnelDetails); // set up for all periods and put into map List<ScaleTwoDecimal> periodTotals = new ArrayList<>(); for (int i = 0; i < budget.getBudgetPeriods().size(); i++) { periodTotals.add(i, ScaleTwoDecimal.ZERO); } objectCodePersonnelSalaryTotals.put(matchingLineItem.getCostElement() + "," + budgetPersonnelDetails.getPersonId(), periodTotals); } //Setting the total lines here - so that they'll be set just once for a unique person within an Object Code objectCodePersonnelSalaryTotals .get(matchingLineItem.getCostElement() + "," + budgetPersonnelDetails.getPersonId()) .set(budgetPeriod.getBudgetPeriod() - 1, personSalaryTotalsForCurrentPeriod); if (objectCodePersonnelSalaryTotalsByPeriod .add(budgetPeriod.getBudgetPeriod().toString() + "," + matchingLineItem.getCostElement() + "," + budgetPersonnelDetails.getPersonId())) { subTotalsBySubSection.get("personnelSalaryTotals").set( budgetPeriod.getBudgetPeriod() - 1, ((subTotalsBySubSection.get("personnelSalaryTotals") .get(budgetPeriod.getBudgetPeriod() - 1))) .add(personSalaryTotalsForCurrentPeriod)); } //Calculate the Fringe Totals for each Person if (!objectCodePersonnelFringeTotals.containsKey(matchingLineItem.getCostElement() + "," + budgetPersonnelDetails.getPersonId())) { // set up for all periods and put into map List<ScaleTwoDecimal> periodFringeTotals = new ArrayList<>(); for (int i = 0; i < budget.getBudgetPeriods().size(); i++) { periodFringeTotals.add(i, ScaleTwoDecimal.ZERO); } objectCodePersonnelFringeTotals.put(matchingLineItem.getCostElement() + "," + budgetPersonnelDetails.getPersonId(), periodFringeTotals); } ScaleTwoDecimal personFringeTotalsForCurrentPeriod = ScaleTwoDecimal.ZERO; //Calculate the Fringe Totals for that Person (cumulative fringe for all occurrences of the person) for (Object person : personOccurrencesForSameObjectCode) { BudgetPersonnelDetails personOccurrence = (BudgetPersonnelDetails) person; for (BudgetPersonnelCalculatedAmount calcExpenseAmount : personOccurrence .getBudgetPersonnelCalculatedAmounts()) { calcExpenseAmount.refreshReferenceObject("rateClass"); //Check for Employee Benefits RateClassType if (calcExpenseAmount.getRateClass().getRateClassTypeCode() .equalsIgnoreCase("E")) { personFringeTotalsForCurrentPeriod = personFringeTotalsForCurrentPeriod .add(calcExpenseAmount.getCalculatedCost()); } } } objectCodePersonnelFringeTotals .get(matchingLineItem.getCostElement() + "," + budgetPersonnelDetails.getPersonId()) .set(budgetPeriod.getBudgetPeriod() - 1, personFringeTotalsForCurrentPeriod); if (objectCodePersonnelFringeTotalsByPeriod .add(budgetPeriod.getBudgetPeriod().toString() + "," + matchingLineItem.getCostElement() + "," + budgetPersonnelDetails.getPersonId())) { subTotalsBySubSection.get("personnelFringeTotals").set( budgetPeriod.getBudgetPeriod() - 1, ((subTotalsBySubSection.get("personnelFringeTotals") .get(budgetPeriod.getBudgetPeriod() - 1))) .add(personFringeTotalsForCurrentPeriod)); } } //Need to handle the Summary Items - if any if (CollectionUtils.isEmpty(matchingLineItem.getBudgetPersonnelDetailsList())) { //Include Summary Item Salary (Line Item Cost) if (!objectCodePersonnelSalaryTotals.containsKey(matchingLineItem.getCostElement())) { // set up for all periods and put into map List<ScaleTwoDecimal> periodTotals = new ArrayList<>(); for (int i = 0; i < budget.getBudgetPeriods().size(); i++) { periodTotals.add(i, ScaleTwoDecimal.ZERO); } objectCodePersonnelSalaryTotals.put(matchingLineItem.getCostElement(), periodTotals); } objectCodePersonnelSalaryTotals.get(matchingLineItem.getCostElement()).set( budgetPeriod.getBudgetPeriod() - 1, (objectCodePersonnelSalaryTotals.get(matchingLineItem.getCostElement()) .get(budgetPeriod.getBudgetPeriod() - 1)) .add(matchingLineItem.getLineItemCost())); //Include Summary Item Fringe Amt ScaleTwoDecimal summaryFringeTotalsForCurrentPeriod = ScaleTwoDecimal.ZERO; if (!objectCodePersonnelFringeTotals.containsKey(matchingLineItem.getCostElement())) { // set up for all periods and put into map List<ScaleTwoDecimal> periodFringeTotals = new ArrayList<>(); for (int i = 0; i < budget.getBudgetPeriods().size(); i++) { periodFringeTotals.add(i, ScaleTwoDecimal.ZERO); } objectCodePersonnelFringeTotals.put(matchingLineItem.getCostElement(), periodFringeTotals); } for (BudgetLineItemCalculatedAmount lineItemCalculatedAmount : matchingLineItem .getBudgetLineItemCalculatedAmounts()) { lineItemCalculatedAmount.refreshReferenceObject("rateClass"); //Check for Employee Benefits RateClassType if (lineItemCalculatedAmount.getRateClass().getRateClassTypeCode() .equalsIgnoreCase("E")) { summaryFringeTotalsForCurrentPeriod = summaryFringeTotalsForCurrentPeriod .add(lineItemCalculatedAmount.getCalculatedCost()); } } objectCodePersonnelFringeTotals.get(matchingLineItem.getCostElement()).set( budgetPeriod.getBudgetPeriod() - 1, (objectCodePersonnelFringeTotals.get(matchingLineItem.getCostElement()) .get(budgetPeriod.getBudgetPeriod() - 1)) .add(summaryFringeTotalsForCurrentPeriod)); subTotalsBySubSection.get("personnelSalaryTotals").set( budgetPeriod.getBudgetPeriod() - 1, ((subTotalsBySubSection.get("personnelSalaryTotals") .get(budgetPeriod.getBudgetPeriod() - 1))) .add((objectCodePersonnelSalaryTotals .get(matchingLineItem.getCostElement()) .get(budgetPeriod.getBudgetPeriod() - 1)))); subTotalsBySubSection.get("personnelFringeTotals").set( budgetPeriod.getBudgetPeriod() - 1, ((subTotalsBySubSection.get("personnelFringeTotals") .get(budgetPeriod.getBudgetPeriod() - 1))) .add((objectCodePersonnelFringeTotals .get(matchingLineItem.getCostElement()) .get(budgetPeriod.getBudgetPeriod() - 1)))); } } } //Budget Period Looping Ends here } //Personnel Object Code Looping Ends here } budget.setBudgetSummaryTotals(subTotalsBySubSection); personnelCalculatedExpenseTotals = calculateExpenseTotals(budget, true); nonPersonnelCalculatedExpenseTotals = calculateExpenseTotals(budget, false); budget.setObjectCodeListByBudgetCategoryType(objectCodeListByBudgetCategoryType); budget.setObjectCodePersonnelList(objectCodeUniquePersonnelList); budget.setObjectCodePersonnelSalaryTotals(objectCodePersonnelSalaryTotals); budget.setObjectCodePersonnelFringeTotals(objectCodePersonnelFringeTotals); budget.setPersonnelCalculatedExpenseTotals(personnelCalculatedExpenseTotals); budget.setNonPersonnelCalculatedExpenseTotals(nonPersonnelCalculatedExpenseTotals); calculateNonPersonnelSummaryTotals(budget); populateBudgetPeriodSummaryCalcAmounts(budget); }