List of usage examples for java.util TreeMap put
public V put(K key, V value)
From source file:com.zhm.config.MyAuthorizationCodeAccessTokenProvider.java
private UserRedirectRequiredException getRedirectForAuthorization(AuthorizationCodeResourceDetails resource, AccessTokenRequest request) {/*from w w w . ja v a2 s.co m*/ // we don't have an authorization code yet. So first get that. TreeMap<String, String> requestParameters = new TreeMap<String, String>(); requestParameters.put("response_type", "code"); // oauth2 spec, section 3 requestParameters.put("client_id", resource.getClientId()); // Client secret is not required in the initial authorization request String redirectUri = resource.getRedirectUri(request); if (redirectUri != null) { requestParameters.put("redirect_uri", redirectUri); } if (resource.isScoped()) { StringBuilder builder = new StringBuilder(); List<String> scope = resource.getScope(); if (scope != null) { Iterator<String> scopeIt = scope.iterator(); while (scopeIt.hasNext()) { builder.append(scopeIt.next()); if (scopeIt.hasNext()) { builder.append(' '); } } } requestParameters.put("scope", builder.toString()); } UserRedirectRequiredException redirectException = new UserRedirectRequiredException( resource.getUserAuthorizationUri(), requestParameters); String stateKey = stateKeyGenerator.generateKey(resource); redirectException.setStateKey(stateKey); request.setStateKey(stateKey); redirectException.setStateToPreserve(redirectUri); request.setPreservedState(redirectUri); return redirectException; }
From source file:hydrograph.ui.engine.ui.converter.impl.InputSparkRedshiftUiConverter.java
@Override protected Map<String, String> getRuntimeProperties() { LOGGER.debug("Generating Runtime Properties for -{}", componentName); TreeMap<String, String> runtimeMap = null; TypeProperties typeProperties = ((Sparkredshift) typeBaseComponent).getRuntimeProperties(); if (typeProperties != null) { runtimeMap = new TreeMap<>(); for (Property runtimeProperty : typeProperties.getProperty()) { runtimeMap.put(runtimeProperty.getName(), runtimeProperty.getValue()); }//www . j a v a 2 s . c o m } return runtimeMap; }
From source file:flex.messaging.services.http.proxy.RequestFilter.java
/** * Before calling the endpoint, set up the cookies found in the request. * @param context the context//from w ww. ja v a2 s . c o m */ public static void copyCookiesToEndpoint(ProxyContext context) { HttpServletRequest clientRequest = FlexContext.getHttpRequest(); context.clearRequestCookies(); if (clientRequest != null) { javax.servlet.http.Cookie[] cookies = clientRequest.getCookies(); HttpState initState = context.getHttpClient().getState(); if (cookies != null) { // Gather up the cookies keyed on the length of the path. // This is done so that if we have two cookies with the same name, // we pass the cookie with the longest path first to the endpoint TreeMap cookieMap = new TreeMap(); for (javax.servlet.http.Cookie cookie : cookies) { CookieInfo origCookie = new CookieInfo(cookie.getName(), cookie.getDomain(), cookie.getName(), cookie.getValue(), cookie.getPath(), cookie.getMaxAge(), null, cookie.getSecure()); CookieInfo newCookie = RequestUtil.createCookie(origCookie, context, context.getTarget().getUrl().getHost(), context.getTarget().getUrl().getPath()); if (newCookie != null) { Integer pathInt = Integer.valueOf(0 - newCookie.path.length()); ArrayList list = (ArrayList) cookieMap.get(pathInt); if (list == null) { list = new ArrayList(); cookieMap.put(pathInt, list); } list.add(newCookie); } } // loop through (in order) the cookies we've gathered for (Object mapValue : cookieMap.values()) { ArrayList list = (ArrayList) mapValue; for (Object aList : list) { CookieInfo cookieInfo = (CookieInfo) aList; if (Log.isInfo()) { String str = "-- Cookie in request: " + cookieInfo; Log.getLogger(HTTPProxyService.LOG_CATEGORY).debug(str); } Cookie cookie = new Cookie(cookieInfo.domain, cookieInfo.name, cookieInfo.value, cookieInfo.path, cookieInfo.maxAge, cookieInfo.secure); // If this is a session cookie and we're dealing with local domain, make sure the session // cookie has the latest session id. This check is needed when the session was invalidated // and then recreated in this request; we shouldn't be sending the old session id to the endpoint. if (context.isLocalDomain() && STRING_JSESSIONID.equalsIgnoreCase(cookieInfo.clientName)) { FlexSession flexSession = FlexContext.getFlexSession(); if (flexSession != null && flexSession.isValid()) { String sessionId = flexSession.getId(); String cookieValue = cookie.getValue(); if (!cookieValue.contains(sessionId)) { int colonIndex = cookieValue.indexOf(':'); if (colonIndex != -1) { // Websphere changes jsession id to the following format: // 4 digit cacheId + jsessionId + ":" + cloneId. ServletContext servletContext = FlexContext.getServletContext(); String serverInfo = servletContext != null ? servletContext.getServerInfo() : null; boolean isWebSphere = serverInfo != null && serverInfo.contains("WebSphere"); if (isWebSphere) { String cacheId = cookieValue.substring(0, 4); String cloneId = cookieValue.substring(colonIndex); String wsSessionId = cacheId + sessionId + cloneId; cookie.setValue(wsSessionId); } else { cookie.setValue(sessionId); } } else { cookie.setValue(sessionId); } } } } // finally add the cookie to the current request initState.addCookie(cookie); context.addRequestCookie(cookie); } } } } }
From source file:com.qpark.eip.core.spring.AbstractPlaceholderConfigurer.java
/** * @param properties//from w w w . ja va2 s. c om * The loaded properties * @return the {@link TreeMap} containing the translations. */ public static TreeMap<String, String> setupTranslationMap(final Map<String, String> properties) { TreeMap<String, String> translationMap = new TreeMap<String, String>(); String number; String source; String translated; for (String s0 : properties.keySet()) { if (s0.trim().length() > 0 && !s0.trim().startsWith("#") && s0.indexOf('.') > 0) { number = s0.substring(0, s0.indexOf('.')); for (String s1 : properties.keySet()) { source = null; translated = null; if (s1.trim().length() > 0 && !s1.trim().startsWith("#") && s1.startsWith(number) && !s1.equals(s0)) { if (s0.contains("source")) { source = s0; } else if (s1.contains("source")) { source = s1; } if (s0.contains("translated")) { translated = s0; } else if (s1.contains("translated")) { translated = s1; } if (source != null && translated != null) { translationMap.put(properties.get(source), properties.get(translated)); } } } } } return translationMap; }
From source file:hydrograph.ui.engine.ui.converter.impl.OutputSparkRedshiftUiConverter.java
@Override protected Map<String, String> getRuntimeProperties() { LOGGER.debug("Fetching runtime properties for -", componentName); TreeMap<String, String> runtimeMap = null; TypeProperties typeProperties = ((Sparkredshift) typeBaseComponent).getRuntimeProperties(); if (typeProperties != null) { runtimeMap = new TreeMap<>(); for (Property runtimeProperty : typeProperties.getProperty()) { runtimeMap.put(runtimeProperty.getName(), runtimeProperty.getValue()); }//from www. j a v a 2 s. c om } return runtimeMap; }
From source file:com.mycompany.task1.Chart.java
private void prepareRangeMap(TreeMap<Double, Integer> groupedMap, Map<Double, Integer> mapa) { //Object[] tab = null; // tab = mapa.keySet().toArray(); double min = 0; //(Double) tab[0]; double max = 6; //(Double) tab[tab.length - 1]; double range = (max - min) / 10; double newRange = range; for (int i = 0; i < 10; i++) { groupedMap.put(newRange, 0); newRange += range;// w w w . j av a 2s . c om } }
From source file:com.villemos.ispace.ktree.KtreeAccessor.java
public Map<String, List> getResults() { TreeMap<String, List> results = new TreeMap<String, List>(new StringComperatorIgnoreCase()); if (getKtreeEndpoint().isDocuments()) { results.put(getKtreeEndpoint().getDocumentTabName(), documents); }/*from w w w. j av a 2s . c o m*/ if (getKtreeEndpoint().isFolders()) { results.put(getKtreeEndpoint().getFolderTabName(), folders); } return results; }
From source file:com.act.lcms.db.analysis.AnalysisHelper.java
/** * This function scores the various metlin ions from different standard ion results, sorts them and picks the * best ion. This is done by adding up the indexed positions of the ion in each sorted entry of the list of * standard ion results. Since the entries in the standard ion results are sorted, the lower magnitude summation ions * are better than the larger magnitude summations. Then, we add another feature, in this case, the normalized SNR/maxSNR * but multiplying the positional score with the normalized SNR. The exact calculation is as follows: * score = positional_score * (1 - SNR(i)/maxSNR). We have to do the (1 - rel_snr) since we choose the lowest score, * so if the rel_snr is huge (ie a good signal), the overall magnitude of score will reduce, which makes that a better * ranking for the ion. We then do a post filtering on these scores based on if we have only positive/negative scans * from the scan files which exist in the context of the caller. * @param standardIonResults The list of standard ion results * @param curatedMetlinIons A map from standard ion result to the best curated ion that was manual inputted. * @param areOtherPositiveModeScansAvailable This boolean is used to post filter and pick a positive metlin ion if and * only if positive ion mode scans are available. * @param areOtherNegativeModeScansAvailable This boolean is used to post filter and pick a negative metlin ion if and * only if negative ion mode scans are available. * @return The best metlin ion or null if none can be found *//*from w ww .ja v a 2 s . co m*/ public static String scoreAndReturnBestMetlinIonFromStandardIonResults( List<StandardIonResult> standardIonResults, Map<StandardIonResult, String> curatedMetlinIons, boolean areOtherPositiveModeScansAvailable, boolean areOtherNegativeModeScansAvailable) { if (standardIonResults == null) { return null; } // We find the maximum SNR values for each standard ion result so that we can normalize individual SNR scores // during scoring. HashMap<StandardIonResult, Double> resultToMaxSNR = new HashMap<>(); for (StandardIonResult result : standardIonResults) { Double maxSNR = 0.0d; for (Map.Entry<String, XZ> resultoDoublePair : result.getAnalysisResults().entrySet()) { if (resultoDoublePair.getValue().getIntensity() > maxSNR) { maxSNR = resultoDoublePair.getValue().getIntensity(); } } resultToMaxSNR.put(result, maxSNR); } Map<String, Double> metlinScore = new HashMap<>(); Set<String> ions = standardIonResults.get(0).getAnalysisResults().keySet(); // For each ion, iterate through all the ion results to find the position of that ion in each result set (since the // ions are sorted) and then multiply that by a normalized value of the SNR. for (String ion : ions) { for (StandardIonResult result : standardIonResults) { Integer counter = 0; for (String localIon : result.getAnalysisResults().keySet()) { counter++; if (localIon.equals(ion)) { Double ionScore = metlinScore.get(ion); if (ionScore == null) { // Normalize the sample's SNR by dividing it by the maxSNR. Then we multiple a variant of it to the counter // score so that if the total magnitude of the score is lower, the ion is ranked higher. ionScore = (1.0 * counter) * (1 - (result.getAnalysisResults().get(ion).getIntensity() / resultToMaxSNR.get(result))); } else { ionScore += (1.0 * counter) * (1 - (result.getAnalysisResults().get(ion).getIntensity() / resultToMaxSNR.get(result))); } metlinScore.put(ion, ionScore); break; } } } } for (Map.Entry<StandardIonResult, String> resultToIon : curatedMetlinIons.entrySet()) { // Override all the scores of the manually curated standard ion result and set them to the highest rank. // Ideally, the user has been consistent for the best metlin ion across similar standard ion results, so // tie breakers will not happen. If a tie happen, it is broken arbitrarily. metlinScore.put(resultToIon.getValue(), MANUAL_OVERRIDE_BEST_SCORE); } TreeMap<Double, List<String>> sortedScores = new TreeMap<>(); for (String ion : metlinScore.keySet()) { if (MS1.getIonModeOfIon(ion) != null) { if ((MS1.getIonModeOfIon(ion).equals(MS1.IonMode.POS) && areOtherPositiveModeScansAvailable) || (MS1.getIonModeOfIon(ion).equals(MS1.IonMode.NEG) && areOtherNegativeModeScansAvailable)) { List<String> ionBucket = sortedScores.get(metlinScore.get(ion)); if (ionBucket == null) { ionBucket = new ArrayList<>(); } ionBucket.add(ion); sortedScores.put(metlinScore.get(ion), ionBucket); } } } if (sortedScores.size() == 0) { LOGGER.error( "Could not find any ions corresponding to the positive and negative scan mode conditionals"); return null; } else { List<String> topMetlinIons = sortedScores.get(sortedScores.keySet().iterator().next()); // In cases of a tie breaker, simply choose the first ion. return topMetlinIons.get(0); } }
From source file:hydrograph.ui.engine.ui.converter.impl.InputXmlUiConverter.java
@Override protected Map<String, String> getRuntimeProperties() { LOGGER.debug("Generating Runtime Properties for -{}", componentName); TreeMap<String, String> runtimeMap = null; TypeProperties typeProperties = ((XmlFile) typeBaseComponent).getRuntimeProperties(); if (typeProperties != null) { runtimeMap = new TreeMap<>(); for (Property runtimeProperty : typeProperties.getProperty()) { runtimeMap.put(runtimeProperty.getName(), runtimeProperty.getValue()); }/*w ww . j ava 2 s . co m*/ } return runtimeMap; }
From source file:hermes.ext.ems.TibcoEMSAdmin.java
public Map getStatistics(final DestinationConfig destination) throws JMSException { try {/* w w w.ja v a 2 s. co m*/ final DestinationInfo info = getDestinationInfo(destination); final TreeMap rval = new TreeMap(); rval.putAll(PropertyUtils.describe(info)); rval.remove("inboundStatistics"); rval.remove("outboundStatistics"); rval.put("inboundByteRate", new Long(info.getInboundStatistics().getByteRate())); rval.put("inboundMessageRate", new Long(info.getInboundStatistics().getMessageRate())); rval.put("inboundTotalBytes", new Long(info.getInboundStatistics().getTotalBytes())); rval.put("inboundTotalMessages", new Long(info.getInboundStatistics().getTotalMessages())); rval.put("outboundByteRate", new Long(info.getOutboundStatistics().getByteRate())); rval.put("outboundMessageRate", new Long(info.getOutboundStatistics().getMessageRate())); rval.put("outboundTotalBytes", new Long(info.getOutboundStatistics().getTotalBytes())); rval.put("outboundTotalMessages", new Long(info.getOutboundStatistics().getTotalMessages())); return rval; } catch (IllegalAccessException e) { throw new HermesException(e); } catch (InvocationTargetException e) { throw new HermesException(e); } catch (NoSuchMethodException e) { throw new HermesException(e); } }