List of usage examples for java.util SortedMap get
V get(Object key);
From source file:net.sourceforge.fenixedu.presentationTier.Action.scientificCouncil.credits.ViewTeacherCreditsReportDispatchAction.java
private void setTotals(HttpServletRequest request, ExecutionYear untilExecutionYear, SortedMap<Department, Map<ExecutionYear, PeriodCreditsReportDTO>> departmentTotalCredits) { int totalTeachersSize = 0, totalCareerTeachersSize = 0, totalNotCareerTeachersSize = 0; SortedMap<ExecutionYear, GenericPair<Double, GenericPair<Double, Double>>> executionYearTotals = new TreeMap<ExecutionYear, GenericPair<Double, GenericPair<Double, Double>>>( ExecutionYear.COMPARATOR_BY_YEAR); for (Department department : departmentTotalCredits.keySet()) { for (ExecutionYear executionYear : departmentTotalCredits.get(department).keySet()) { if (!executionYearTotals.containsKey(executionYear)) { executionYearTotals.put(executionYear, new GenericPair(0.0, new GenericPair(0.0, 0.0))); }//from w w w . java2 s. co m GenericPair genericPair = executionYearTotals.get(executionYear); genericPair.setLeft(round(departmentTotalCredits.get(department).get(executionYear).getCredits() + executionYearTotals.get(executionYear).getLeft())); ((GenericPair) genericPair.getRight()).setLeft(round( departmentTotalCredits.get(department).get(executionYear).getCareerCategoryTeacherCredits() + executionYearTotals.get(executionYear).getRight().getLeft())); ((GenericPair) genericPair.getRight()).setRight(round(departmentTotalCredits.get(department) .get(executionYear).getNotCareerCategoryTeacherCredits() + executionYearTotals.get(executionYear).getRight().getRight())); if (executionYear.equals(untilExecutionYear)) { totalTeachersSize += departmentTotalCredits.get(department).get(executionYear) .getTeachersSize(); totalCareerTeachersSize += departmentTotalCredits.get(department).get(executionYear) .getCareerTeachersSize(); totalNotCareerTeachersSize += departmentTotalCredits.get(department).get(executionYear) .getNotCareerTeachersSize(); } } } request.setAttribute("totalCareerTeachersSize", totalCareerTeachersSize); request.setAttribute("totalNotCareerTeachersSize", totalNotCareerTeachersSize); request.setAttribute("totalCareerTeachersBalance", round(executionYearTotals.get(untilExecutionYear).getRight().getLeft() / totalCareerTeachersSize)); request.setAttribute("totalNotCareerTeachersBalance", round( executionYearTotals.get(untilExecutionYear).getRight().getRight() / totalNotCareerTeachersSize)); request.setAttribute("totalBalance", round(executionYearTotals.get(untilExecutionYear).getLeft() / totalTeachersSize)); request.setAttribute("totalTeachersSize", totalTeachersSize); request.setAttribute("executionYearTotals", executionYearTotals); }
From source file:com.aurel.track.fieldType.runtime.matchers.run.CompositeSelectMatcherRT.java
/** * Add a match expression to the criteria *///from www . j a va2s . com @Override public void addCriteria(Criteria crit) { if (relation == MatchRelations.IS_NULL || relation == MatchRelations.NOT_IS_NULL) { String alias = addAliasAndJoin(crit); addNullExpressionToCriteria(crit, alias + "." + "CUSTOMOPTIONID"); return; } SortedMap<Integer, Object> matcherValueMap = null; try { matcherValueMap = (SortedMap<Integer, Object>) matchValue; } catch (Exception e) { LOGGER.warn("Converting the matcher value of type " + matchValue.getClass().getName() + " to SortedMap<Integer, Object> failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } if (matcherValueMap != null && matcherValueMap.size() != 0) { Iterator<Integer> iterator = matcherValueMap.keySet().iterator(); Criterion criterion = null; while (iterator.hasNext()) { Integer parameterCode = iterator.next(); Integer[] matcherValueCustomOption = null; try { matcherValueCustomOption = (Integer[]) matcherValueMap.get(parameterCode); } catch (Exception e) { LOGGER.error("Converting the matcher value for part " + parameterCode + " to Integer[] failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); return; } if (matcherValueCustomOption == null || matcherValueCustomOption.length == 0) { matcherValueCustomOption = new Integer[0]; } String alias = null; switch (relation) { case MatchRelations.EQUAL: alias = addAliasAndJoin(crit, parameterCode); crit.addIn(alias + "." + "CUSTOMOPTIONID", matcherValueCustomOption); break; case MatchRelations.NOT_EQUAL: alias = addAliasAndJoin(crit, parameterCode); if (criterion == null) { criterion = crit.getNewCriterion(alias + "." + "CUSTOMOPTIONID", matcherValueCustomOption, Criteria.NOT_IN); } else { criterion = criterion.or(crit.getNewCriterion(alias + "." + "CUSTOMOPTIONID", matcherValueCustomOption, Criteria.NOT_IN)); } break; case MatchRelations.PARTIAL_MATCH: if (matcherValueCustomOption[0].equals(ANY_FROM_LEVEL)) { return; } else { alias = addAliasAndJoin(crit, parameterCode); crit.addIn(alias + "." + "CUSTOMOPTIONID", matcherValueCustomOption); } break; case MatchRelations.PARTIAL_NOTMATCH: if (!matcherValueCustomOption[0].equals(NONE_FROM_LEVEL)) { alias = addAliasAndJoin(crit, parameterCode); if (criterion == null) { criterion = crit.getNewCriterion(alias + "." + "CUSTOMOPTIONID", matcherValueCustomOption, Criteria.NOT_IN); } else { criterion = criterion.or(crit.getNewCriterion(alias + "." + "CUSTOMOPTIONID", matcherValueCustomOption, Criteria.NOT_IN)); } } break; } } if (criterion != null) { crit.add(criterion); } } }
From source file:com.uber.jenkins.phabricator.coverage.CoberturaXMLParser.java
private Map<String, List<Integer>> parse(Map<NodeList, List<String>> coverageData) { Map<String, SortedMap<Integer, Integer>> internalCounts = new HashMap<String, SortedMap<Integer, Integer>>(); // Each entry in the map is an XML list of classes (files) mapped to its possible source roots for (Map.Entry<NodeList, List<String>> entry : coverageData.entrySet()) { NodeList classes = entry.getKey(); List<String> sourceDirs = entry.getValue(); // Loop over all files in the coverage report for (int i = 0; i < classes.getLength(); i++) { Node classNode = classes.item(i); String fileName = classNode.getAttributes().getNamedItem(NODE_FILENAME).getTextContent(); if (includeFileNames != null && !includeFileNames.contains(FilenameUtils.getName(fileName))) { continue; }/*from w w w. j ava2s. c o m*/ // Make a guess on which of the `sourceDirs` contains the file in question String detectedSourceRoot = new PathResolver(workspace, sourceDirs).choose(fileName); fileName = join(detectedSourceRoot, fileName); SortedMap<Integer, Integer> hitCounts = internalCounts.get(fileName); if (hitCounts == null) { hitCounts = new TreeMap<Integer, Integer>(); } NodeList children = classNode.getChildNodes(); for (int j = 0; j < children.getLength(); j++) { Node child = children.item(j); if (NODE_NAME_LINES.equals(child.getNodeName())) { NodeList lines = child.getChildNodes(); for (int k = 0; k < lines.getLength(); k++) { Node line = lines.item(k); if (!NODE_NAME_LINE.equals(line.getNodeName())) { continue; } Integer lineNumber = getIntValue(line, NODE_NUMBER); int existingHits = hitCounts.containsKey(lineNumber) ? hitCounts.get(lineNumber) : 0; hitCounts.put(lineNumber, Math.max(existingHits, getIntValue(line, NODE_HITS))); } internalCounts.put(fileName, hitCounts); } } } } return computeLineCoverage(internalCounts); }
From source file:org.kuali.kra.budget.external.budget.impl.BudgetAdjustmentClientBase.java
/** * This method sets the personnel salary accounting line. * @param accountingLines // www .j av a2 s . c om * @return * @throws Exception */ protected boolean setPersonnelSalaryAccountingLines(AwardBudgetDocument awardBudgetDocument, Map<String, ScaleTwoDecimal> accountingLines) throws Exception { Budget currentBudget = awardBudgetDocument.getBudget(); AwardBudgetExt previousBudget = getPrevBudget(awardBudgetDocument); boolean complete = true; SortedMap<String, ScaleTwoDecimal> netCost = getBudgetAdjustmentServiceHelper() .getPersonnelSalaryCost(currentBudget, previousBudget); for (String name : netCost.keySet()) { String financialObjectCode = getFinancialObjectCode(name); if (ObjectUtils.isNull(financialObjectCode)) { complete &= false; } else { if (!accountingLines.containsKey(financialObjectCode)) { accountingLines.put(financialObjectCode, netCost.get(name)); } else { accountingLines.put(financialObjectCode, accountingLines.get(financialObjectCode).add(netCost.get(name))); } } } return complete; }
From source file:org.kuali.kra.budget.external.budget.impl.BudgetAdjustmentServiceHelperImpl.java
/** * This method returns the personnel calculated direct cost. * @return//from w w w .java 2 s. c o m */ public Map<RateClassRateType, ScaleTwoDecimal> getPersonnelCalculatedDirectCost(Budget currentBudget, AwardBudgetExt previousBudget) { SortedMap<RateType, List<ScaleTwoDecimal>> currentTotals = currentBudget .getPersonnelCalculatedExpenseTotals(); int period = currentBudget.getBudgetPeriods().size() - 1; Map<RateClassRateType, ScaleTwoDecimal> currentCost = new HashMap<RateClassRateType, ScaleTwoDecimal>(); Map<RateClassRateType, ScaleTwoDecimal> netCost = new HashMap<RateClassRateType, ScaleTwoDecimal>(); for (RateType rate : currentTotals.keySet()) { // For some reason indirect cost shows up in this, remove it. if (!StringUtils.equalsIgnoreCase(rate.getRateClass().getRateClassTypeCode(), "O")) { LOG.info("Rate Class: " + rate.getRateClassCode() + "RateType: " + rate.getRateTypeCode() + ""); currentCost.put(new RateClassRateType(rate.getRateClassCode(), rate.getRateTypeCode()), currentTotals.get(rate).get(period)); } } for (RateClassRateType rate : currentCost.keySet()) { netCost.put(rate, currentCost.get(rate)); } return netCost; }
From source file:org.wso2.carbon.appmgt.impl.token.JWTGenerator.java
/** * Method that generates the JWT./*w ww . jav a 2 s . co m*/ * * @param keyValidationInfoDTO * @param apiContext * @param version * @param includeEndUserName * @return signed JWT token * @throws org.wso2.carbon.appmgt.api.AppManagementException */ public String generateToken(APIKeyValidationInfoDTO keyValidationInfoDTO, String apiContext, String version, boolean includeEndUserName) throws AppManagementException { //generating expiring timestamp long currentTime = Calendar.getInstance().getTimeInMillis(); long expireIn = currentTime + 1000 * 60 * getTTL(); String jwtBody; String dialect; if (claimsRetriever != null) { //jwtBody = JWT_INITIAL_BODY.replaceAll("\\[0\\]", claimsRetriever.getDialectURI(endUserName)); dialect = claimsRetriever.getDialectURI(keyValidationInfoDTO.getEndUserName()); } else { //jwtBody = JWT_INITIAL_BODY.replaceAll("\\[0\\]", dialectURI); dialect = dialectURI; } String subscriber = keyValidationInfoDTO.getSubscriber(); String applicationName = keyValidationInfoDTO.getApplicationName(); String applicationId = keyValidationInfoDTO.getApplicationId(); String tier = keyValidationInfoDTO.getTier(); String endUserName = includeEndUserName ? keyValidationInfoDTO.getEndUserName() : null; String keyType = keyValidationInfoDTO.getType(); String userType = keyValidationInfoDTO.getUserType(); String applicationTier = keyValidationInfoDTO.getApplicationTier(); String enduserTenantId = includeEndUserName ? String.valueOf(getTenantId(endUserName)) : null; //Sample JWT body //{"iss":"wso2.org/products/am","exp":1349267862304,"http://wso2.org/claims/subscriber":"nirodhasub", // "http://wso2.org/claims/applicationname":"App1","http://wso2.org/claims/apicontext":"/echo", // "http://wso2.org/claims/version":"1.2.0","http://wso2.org/claims/tier":"Gold", // "http://wso2.org/claims/enduser":"null"} StringBuilder jwtBuilder = new StringBuilder(); jwtBuilder.append("{"); jwtBuilder.append("\"iss\":\""); jwtBuilder.append(API_GATEWAY_ID); jwtBuilder.append("\","); jwtBuilder.append("\"exp\":"); jwtBuilder.append(String.valueOf(expireIn)); jwtBuilder.append(","); jwtBuilder.append("\""); jwtBuilder.append(dialect); jwtBuilder.append("/subscriber\":\""); jwtBuilder.append(subscriber); jwtBuilder.append("\","); jwtBuilder.append("\""); jwtBuilder.append(dialect); jwtBuilder.append("/applicationid\":\""); jwtBuilder.append(applicationId); jwtBuilder.append("\","); jwtBuilder.append("\""); jwtBuilder.append(dialect); jwtBuilder.append("/applicationname\":\""); jwtBuilder.append(applicationName); jwtBuilder.append("\","); jwtBuilder.append("\""); jwtBuilder.append(dialect); jwtBuilder.append("/applicationtier\":\""); jwtBuilder.append(applicationTier); jwtBuilder.append("\","); jwtBuilder.append("\""); jwtBuilder.append(dialect); jwtBuilder.append("/apicontext\":\""); jwtBuilder.append(apiContext); jwtBuilder.append("\","); jwtBuilder.append("\""); jwtBuilder.append(dialect); jwtBuilder.append("/version\":\""); jwtBuilder.append(version); jwtBuilder.append("\","); jwtBuilder.append("\""); jwtBuilder.append(dialect); jwtBuilder.append("/tier\":\""); jwtBuilder.append(tier); jwtBuilder.append("\","); jwtBuilder.append("\""); jwtBuilder.append(dialect); jwtBuilder.append("/keytype\":\""); jwtBuilder.append(keyType); jwtBuilder.append("\","); jwtBuilder.append("\""); jwtBuilder.append(dialect); jwtBuilder.append("/usertype\":\""); jwtBuilder.append(userType); jwtBuilder.append("\","); jwtBuilder.append("\""); jwtBuilder.append(dialect); jwtBuilder.append("/enduser\":\""); jwtBuilder.append(endUserName); jwtBuilder.append("\","); jwtBuilder.append("\""); jwtBuilder.append(dialect); jwtBuilder.append("/enduserTenantId\":\""); jwtBuilder.append(enduserTenantId); jwtBuilder.append("\""); if (claimsRetriever != null) { SortedMap<String, String> claimValues = claimsRetriever.getClaims(endUserName); Iterator<String> it = new TreeSet(claimValues.keySet()).iterator(); while (it.hasNext()) { String claimURI = it.next(); jwtBuilder.append(", \""); jwtBuilder.append(claimURI); jwtBuilder.append("\":\""); jwtBuilder.append(claimValues.get(claimURI)); jwtBuilder.append("\""); } } jwtBuilder.append("}"); jwtBody = jwtBuilder.toString(); String jwtHeader = null; //if signature algo==NONE, header without cert if (signatureAlgorithm.equals(NONE)) { jwtHeader = "{\"typ\":\"JWT\"}"; } else if (signatureAlgorithm.equals(SHA256_WITH_RSA)) { jwtHeader = addCertToHeader(endUserName); } /*//add cert thumbprint to header String headerWithCertThumb = addCertToHeader(endUserName);*/ String base64EncodedHeader = Base64Utils.encode(jwtHeader.getBytes()); String base64EncodedBody = Base64Utils.encode(jwtBody.getBytes()); if (signatureAlgorithm.equals(SHA256_WITH_RSA)) { String assertion = base64EncodedHeader + "." + base64EncodedBody; //get the assertion signed byte[] signedAssertion = signJWT(assertion, endUserName); if (log.isDebugEnabled()) { log.debug("signed assertion value : " + new String(signedAssertion)); } String base64EncodedAssertion = Base64Utils.encode(signedAssertion); return base64EncodedHeader + "." + base64EncodedBody + "." + base64EncodedAssertion; } else { return base64EncodedHeader + "." + base64EncodedBody + "."; } }
From source file:org.web4thejob.studio.controller.impl.PropertyEditorController.java
private void refreshComponentProperties(SortedMap<String, SortedSet<Element>> propsMap) { ComponentDefinition componentDefinition = getDefinitionByTag(selection.getLocalName()); List<Row> bindings = new ArrayList<>(1); for (String group : propsMap.keySet()) { Groupbox groupbox = findGroup(group); Row row;/* w ww . ja v a2 s.c o m*/ if (groupbox == null) { groupbox = buildGroupbox(group); } Grid grid = (Grid) groupbox.getLastChild(); int num = 0; for (Element property : propsMap.get(group)) { String propertyName = property.getAttributeValue("name"); if (isEvent(propertyName)) continue; Object val = null; Attribute attribute = selection.getAttribute(propertyName); if (attribute != null) { val = attribute.getValue(); } InputElement editor = findEditor(selection, propertyName); if (editor == null) { row = new Row(); row.setAttribute("property", propertyName); row.setWidgetAttribute("w4tjstudio-property", propertyName); row.setParent(grid.getRows()); Label name = new Label(propertyName); name.setParent(row); name.setValue(propertyName); editor = createEditor(componentDefinition, property, val); editor.setAttribute("property", propertyName); editor.setAttribute("element", selection); editor.addEventListener(Events.ON_OK, OK_HANDLER); editor.setParent(row); } else { editor.setAttribute("element", selection); editor.setRawValue(val); row = (Row) editor.getParent(); } if (val instanceof String) { String s = (String) val; if (s.contains("@bind(") || s.contains("@load(") || s.contains("@save(")) { Row brow = (Row) row.clone(); ((Label) brow.getFirstChild()).setSclass("label label-primary"); String bval = ((InputElement) brow.getLastChild()).getRawValue().toString(); brow.getLastChild().detach(); new Html("<span class=\"label label-success z-label\">" + bval + "</span>").setParent(brow); bindings.add(brow); } } num++; } if (num > 0) { groupbox.setParent(properties); } //else discard } if (!bindings.isEmpty()) { Groupbox groupbox = findGroup("bindings"); Grid grid; if (groupbox == null) { groupbox = buildGroupbox("bindings"); properties.insertBefore(groupbox, properties.getFirstChild()); groupbox.setOpen(true); } grid = (Grid) groupbox.getLastChild(); grid.getRows().getChildren().clear(); for (Row row : bindings) { row.setParent(grid.getRows()); } } else { Groupbox groupbox = findGroup("bindings"); if (groupbox != null) groupbox.detach(); } Clients.evalJavaScript("w4tjStudioDesigner.decoratePropertyCaptions();"); }
From source file:com.linkedin.pinot.core.segment.store.SingleFileIndexDirectory.java
private void mapAndSliceFile(SortedMap<Long, IndexEntry> startOffsets, List<Long> offsetAccum, long endOffset) throws IOException { Preconditions.checkNotNull(startOffsets); Preconditions.checkNotNull(offsetAccum); Preconditions.checkArgument(offsetAccum.size() >= 1); long fromFilePos = offsetAccum.get(0); long toFilePos = endOffset - fromFilePos; String context = allocationContext(indexFile, "single_file_index.rw." + "." + String.valueOf(fromFilePos) + "." + String.valueOf(toFilePos)); PinotDataBuffer buffer = PinotDataBuffer.fromFile(indexFile, fromFilePos, toFilePos, readMode, FileChannel.MapMode.READ_WRITE, context); allocBuffers.add(buffer);/* ww w .ja v a 2 s. c o m*/ int prevSlicePoint = 0; for (Long fileOffset : offsetAccum) { IndexEntry entry = startOffsets.get(fileOffset); int endSlicePoint = prevSlicePoint + (int) entry.size; validateMagicMarker(buffer, prevSlicePoint); PinotDataBuffer viewBuffer = buffer.view(prevSlicePoint + MAGIC_MARKER_SIZE_BYTES, endSlicePoint); entry.buffer = viewBuffer; prevSlicePoint = endSlicePoint; } }
From source file:de.ailis.xadrian.data.Sector.java
/** * Returns the yield map. This map has the yield as key and the number of * asteroids with this yield as value.// ww w. j av a 2 s .c om * * @param wareId * The id of the asteroid ware to search for * @return The yield map */ public SortedMap<Integer, Integer> getYieldsMap(final String wareId) { final SortedMap<Integer, Integer> yields = new TreeMap<Integer, Integer>(new ReverseIntegerComparator()); // Iterate over all asteroids for (final Asteroid asteroid : getAsteroids()) { // If this asteroid is not of the searched type then ignore it if (!wareId.equals(asteroid.getWare().getId())) continue; // Update the yield in the yields map final int yield = asteroid.getYield(); Integer oldQuantity = yields.get(yield); if (oldQuantity == null) oldQuantity = 0; yields.put(yield, oldQuantity + 1); } // Return the yields map return yields; }
From source file:org.jahia.modules.modulemanager.flow.ModuleManagementFlowHandler.java
/** * Returns a map, keyed by the module name, with all available module updates. * * @return a map, keyed by the module name, with all available module updates *//*from ww w. j a v a 2 s . c o m*/ public Map<String, Module> getAvailableUpdates() { Map<String, Module> availableUpdate = new HashMap<String, Module>(); Map<String, SortedMap<ModuleVersion, JahiaTemplatesPackage>> moduleStates = templateManagerService .getTemplatePackageRegistry().getAllModuleVersions(); for (String key : moduleStates.keySet()) { SortedMap<ModuleVersion, JahiaTemplatesPackage> moduleVersions = moduleStates.get(key); Module forgeModule = forgeService.findModule(key, moduleVersions.get(moduleVersions.firstKey()).getGroupId()); if (forgeModule != null) { ModuleVersion forgeVersion = new ModuleVersion(forgeModule.getVersion()); if (!isSameOrNewerVersionPresent(key, forgeVersion)) { availableUpdate.put(key, forgeModule); } } } return availableUpdate; }