List of usage examples for java.util LinkedHashMap put
V put(K key, V value);
From source file:eionet.cr.dto.FactsheetDTO.java
/** * * @return//from w w w . ja v a 2 s .co m */ public LinkedHashMap<String, Collection<ObjectDTO>> getSortedPredicates() { ArrayList<String> predicateUris = new ArrayList<String>(getPredicates().keySet()); Collections.sort(predicateUris, new PredicateComparator()); LinkedHashMap<String, Collection<ObjectDTO>> result = new LinkedHashMap<String, Collection<ObjectDTO>>(); for (String predicateUri : predicateUris) { result.put(predicateUri, getObjects(predicateUri)); } return result; }
From source file:hydrograph.ui.propertywindow.widgets.customwidgets.ELTFilePathWidget.java
@Override public LinkedHashMap<String, Object> getProperties() { LinkedHashMap<String, Object> property = new LinkedHashMap<>(); property.put(propertyName, textBox.getText()); setToolTipErrorMessage();/*from w w w . j a v a 2 s .co m*/ return property; }
From source file:com.thoughtworks.go.server.service.support.ThreadInformationProvider.java
private LinkedHashMap<String, Object> asJSON(LockInfo lockInfo) { LinkedHashMap<String, Object> lockedOn = new LinkedHashMap<>(); if (lockInfo != null) { lockedOn.put("Class", lockInfo.getClassName()); lockedOn.put("IdentityHashCode", lockInfo.getIdentityHashCode()); }/*from w ww . j av a 2 s . c om*/ return lockedOn; }
From source file:com.opengamma.analytics.financial.provider.sensitivity.multicurve.SimpleParameterSensitivity.java
/** * Create a copy of the sensitivity and add a given named sensitivity to it. If the name / currency pair is in the map, the two sensitivity matrices are added. * Otherwise, a new entry is put into the map * @param name The name. Not null.//from w w w. j av a 2 s. c o m * @param sensitivity The sensitivity to add, not null * @return The total sensitivity. */ public SimpleParameterSensitivity plus(final String name, final DoubleMatrix1D sensitivity) { ArgumentChecker.notNull(name, "Name"); ArgumentChecker.notNull(sensitivity, "Matrix"); final MatrixAlgebra algebra = MatrixAlgebraFactory.COMMONS_ALGEBRA; final LinkedHashMap<String, DoubleMatrix1D> result = new LinkedHashMap<>(); result.putAll(_sensitivity); if (result.containsKey(name)) { result.put(name, (DoubleMatrix1D) algebra.add(result.get(name), sensitivity)); } else { result.put(name, sensitivity); } return new SimpleParameterSensitivity(result); }
From source file:org.mitre.dsmiley.httpproxy.URITemplateProxyServlet.java
@Override protected void service(HttpServletRequest servletRequest, HttpServletResponse servletResponse) throws ServletException, IOException { //First collect params /*/*from w w w . ja v a 2 s. c om*/ * Do not use servletRequest.getParameter(arg) because that will * typically read and consume the servlet InputStream (where our * form data is stored for POST). We need the InputStream later on. * So we'll parse the query string ourselves. A side benefit is * we can keep the proxy parameters in the query string and not * have to add them to a URL encoded form attachment. */ String queryString = "?" + servletRequest.getQueryString();//no "?" but might have "#" int hash = queryString.indexOf('#'); if (hash >= 0) { queryString = queryString.substring(0, hash); } List<NameValuePair> pairs; try { //note: HttpClient 4.2 lets you parse the string without building the URI pairs = URLEncodedUtils.parse(new URI(queryString), "UTF-8"); } catch (URISyntaxException e) { throw new ServletException("Unexpected URI parsing error on " + queryString, e); } LinkedHashMap<String, String> params = new LinkedHashMap<String, String>(); for (NameValuePair pair : pairs) { params.put(pair.getName(), pair.getValue()); } //Now rewrite the URL StringBuffer urlBuf = new StringBuffer();//note: StringBuilder isn't supported by Matcher Matcher matcher = TEMPLATE_PATTERN.matcher(targetUriTemplate); while (matcher.find()) { String arg = matcher.group(1); String replacement = params.remove(arg);//note we remove if (replacement == null) { throw new ServletException("Missing HTTP parameter " + arg + " to fill the template"); } matcher.appendReplacement(urlBuf, replacement); } matcher.appendTail(urlBuf); String newTargetUri = urlBuf.toString(); servletRequest.setAttribute(ATTR_TARGET_URI, newTargetUri); URI targetUriObj; try { targetUriObj = new URI(newTargetUri); } catch (Exception e) { throw new ServletException("Rewritten targetUri is invalid: " + newTargetUri, e); } servletRequest.setAttribute(ATTR_TARGET_HOST, URIUtils.extractHost(targetUriObj)); //Determine the new query string based on removing the used names StringBuilder newQueryBuf = new StringBuilder(queryString.length()); for (Map.Entry<String, String> nameVal : params.entrySet()) { if (newQueryBuf.length() > 0) newQueryBuf.append('&'); newQueryBuf.append(nameVal.getKey()).append('='); if (nameVal.getValue() != null) newQueryBuf.append(nameVal.getValue()); } servletRequest.setAttribute(ATTR_QUERY_STRING, newQueryBuf.toString()); super.service(servletRequest, servletResponse); }
From source file:com.predic8.membrane.servlet.embedded.RStudioMembraneServlet.java
@Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String queryString = req.getQueryString() == null ? "" : "?" + req.getQueryString(); Router router;// ww w . j ava 2 s .c o m // For websockets, the following paths are used by JupyterHub: // /(user/[^/]*)/(api/kernels/[^/]+/channels|terminals/websocket)/? // forward to ws(s)://servername:port_number //<LocationMatch "/mypath/(user/[^/]*)/(api/kernels/[^/]+/channels|terminals/websocket)(.*)"> // ProxyPassMatch ws://localhost:8999/mypath/$1/$2$3 // ProxyPassReverse ws://localhost:8999 # this may be superfluous //</LocationMatch> // ProxyPass /api/kernels/ ws://192.168.254.23:8888/api/kernels/ // ProxyPassReverse /api/kernels/ http://192.168.254.23:8888/api/kernels/ List<NameValuePair> pairs; try { //note: HttpClient 4.2 lets you parse the string without building the URI pairs = URLEncodedUtils.parse(new URI(queryString), "UTF-8"); } catch (URISyntaxException e) { throw new ServletException("Unexpected URI parsing error on " + queryString, e); } LinkedHashMap<String, String> params = new LinkedHashMap<>(); for (NameValuePair pair : pairs) { params.put(pair.getName(), pair.getValue()); } String externalIp = Ip.getHost(req.getRequestURL().toString()); StringBuffer urlBuf = new StringBuffer("http://localhost:"); String ctxPath = req.getRequestURI(); int x = ctxPath.indexOf("/rstudio"); int firstSlash = ctxPath.indexOf('/', x + 1); int secondSlash = ctxPath.indexOf('/', firstSlash + 1); String portString = ctxPath.substring(firstSlash + 1, secondSlash); Integer targetPort; try { targetPort = Integer.parseInt(portString); } catch (NumberFormatException ex) { logger.error("Invalid target port in the URL: " + portString); return; } urlBuf.append(portString); String newTargetUri = urlBuf.toString() + req.getRequestURI(); StringBuilder newQueryBuf = new StringBuilder(); newQueryBuf.append(newTargetUri); newQueryBuf.append(queryString); URI targetUriObj = null; try { targetUriObj = new URI(newQueryBuf.toString()); } catch (Exception e) { throw new ServletException("Rewritten targetUri is invalid: " + newTargetUri, e); } ServiceProxy sp = new ServiceProxy(new ServiceProxyKey(externalIp, "*", "*", -1), "localhost", targetPort); // ServiceProxy sp = new ServiceProxy( // new ServiceProxyKey( // externalIp, "*", "*", -1), // "localhost", targetPort); sp.setTargetURL(newQueryBuf.toString()); // only set external hostname in case admin console is used try { router = new HopsRouter(targetUriObj); router.add(sp); router.init(); ProxyRule proxy = new ProxyRule(new ProxyRuleKey(-1)); router.getRuleManager().addProxy(proxy, RuleManager.RuleDefinitionSource.MANUAL); router.getRuleManager().addProxy(sp, RuleManager.RuleDefinitionSource.MANUAL); new HopsServletHandler(req, resp, router.getTransport(), targetUriObj).run(); } catch (Exception ex) { Logger.getLogger(RStudioMembraneServlet.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.concursive.connect.web.modules.communications.utils.EmailUpdatesUtils.java
public static String getEmailHTMLMessage(Connection db, ApplicationPrefs prefs, Configuration configuration, EmailUpdatesQueue queue, Timestamp min, Timestamp max) throws Exception { // User who needs to be sent an email User user = UserUtils.loadUser(queue.getEnteredBy()); Project website = ProjectUtils.loadProject("main-profile"); int emailUpdatesSchedule = -1; String title = ""; if (queue.getScheduleOften()) { emailUpdatesSchedule = TeamMember.EMAIL_OFTEN; title = website.getTitle() + " recent updates"; } else if (queue.getScheduleDaily()) { emailUpdatesSchedule = TeamMember.EMAIL_DAILY; title = website.getTitle() + " daily update"; } else if (queue.getScheduleWeekly()) { emailUpdatesSchedule = TeamMember.EMAIL_WEEKLY; title = website.getTitle() + " weekly update"; } else if (queue.getScheduleMonthly()) { emailUpdatesSchedule = TeamMember.EMAIL_MONTHLY; title = website.getTitle() + " monthly update"; }/*ww w .j a v a 2 s .co m*/ if (emailUpdatesSchedule == -1) { //unexpected case; throw exception throw new Exception("The queue does not have a valid schedule type!"); } if (URLFactory.createURL(prefs.getPrefs()) == null) { throw new Exception( "The server URL is not specified. Please contact the system administrator to configure the remote server's URL!"); } // Populate the message template freemarker.template.Template template = configuration .getTemplate("scheduled_activity_updates_email_body-html.ftl"); Map bodyMappings = new HashMap(); bodyMappings.put("title", title); bodyMappings.put("link", new HashMap()); ((Map) bodyMappings.get("link")).put("settings", URLFactory.createURL(prefs.getPrefs()) + "/show/" + user.getProfileUniqueId()); // Load the RSS config file to determine the objects for display String fileName = "scheduled_emails_en_US.xml"; URL resource = EmailUpdatesUtils.class.getResource("/" + fileName); LOG.debug("Schedule emails config file: " + resource.toString()); XMLUtils library = new XMLUtils(resource); String purpose = prefs.get(ApplicationPrefs.PURPOSE); LOG.debug("Purpose: " + purpose); Element emailElement = XMLUtils.getElement(library.getDocumentElement(), "email", "events", "site," + purpose); if (emailElement == null) { emailElement = XMLUtils.getElement(library.getDocumentElement(), "email", "events", "site"); } if (emailElement != null) { LinkedHashMap categories = new LinkedHashMap(); PagedListInfo info = new PagedListInfo(); String limit = emailElement.getAttribute("limit"); info.setItemsPerPage(limit); int activityCount = 0; //Determine the website's site-chatter data to email for this user (if any) ProjectHistoryList chatter = new ProjectHistoryList(); chatter.setProjectId(website.getId()); chatter.setLinkObject(ProjectHistoryList.SITE_CHATTER_OBJECT); chatter.setRangeStart(min); chatter.setRangeEnd(max); chatter.setPagedListInfo(info); chatter.setForMemberEmailUpdates(user.getId(), emailUpdatesSchedule); LinkedHashMap map = chatter.getList(db, user.getId(), URLFactory.createURL(prefs.getPrefs())); activityCount += map.size(); if (map.size() != 0) { categories.put("Chatter", map); } // Determine the types of events to display based on the config file ArrayList<Element> eventElements = new ArrayList<Element>(); XMLUtils.getAllChildren(emailElement, "event", eventElements); // set all the requested types based on the types we allow for the query.. ArrayList<String> types = new ArrayList<String>(); for (Element eventElement : eventElements) { String type = XMLUtils.getNodeText(eventElement); types.add(type); } LOG.debug("Event Types: " + types); // Load the categories ProjectCategoryList categoryList = new ProjectCategoryList(); categoryList.setTopLevelOnly(true); categoryList.setEnabled(Constants.TRUE); categoryList.buildList(db); for (ProjectCategory category : categoryList) { ProjectHistoryList activities = new ProjectHistoryList(); activities.setProjectCategoryId(category.getId()); activities.setRangeStart(min); activities.setRangeEnd(max); activities.setObjectPreferences(types); activities.setPagedListInfo(info); activities.setForMemberEmailUpdates(user.getId(), emailUpdatesSchedule); LinkedHashMap activityMap = activities.getList(db, user.getId(), URLFactory.createURL(prefs.getPrefs())); activityCount += activityMap.size(); if (activityMap.size() != 0) { categories.put(category.getLabel(), activityMap); } } if (activityCount == 0) { //Don't send an email update return null; } bodyMappings.put("categories", categories); } // Parse and return StringWriter emailBodyTextWriter = new StringWriter(); template.process(bodyMappings, emailBodyTextWriter); return emailBodyTextWriter.toString(); }
From source file:com.quancheng.saluki.gateway.zuul.extend.StoreProxyRouteLocator.java
@Override protected LinkedHashMap<String, ZuulRoute> locateRoutes() { LinkedHashMap<String, ZuulRoute> routesMap = new LinkedHashMap<String, ZuulRoute>(); routesMap.putAll(super.locateRoutes()); for (ZuulProperties.ZuulRoute route : findAll()) { routesMap.put(route.getPath(), route); }/* ww w . j a v a2s .c o m*/ return routesMap; }
From source file:com.espertech.esper.epl.spec.PatternStreamSpecRaw.java
private static MatchEventSpec analyzeMatchEvent(EvalFactoryNode relativeNode) { LinkedHashMap<String, Pair<EventType, String>> taggedEventTypes = new LinkedHashMap<String, Pair<EventType, String>>(); LinkedHashMap<String, Pair<EventType, String>> arrayEventTypes = new LinkedHashMap<String, Pair<EventType, String>>(); // Determine all the filter nodes used in the pattern EvalNodeAnalysisResult evalNodeAnalysisResult = EvalNodeUtil.recursiveAnalyzeChildNodes(relativeNode); // collect all filters underneath for (EvalFilterFactoryNode filterNode : evalNodeAnalysisResult.getFilterNodes()) { String optionalTag = filterNode.getEventAsName(); if (optionalTag != null) { taggedEventTypes.put(optionalTag, new Pair<EventType, String>(filterNode.getFilterSpec().getFilterForEventType(), filterNode.getFilterSpec().getFilterForEventTypeName())); }//from w w w .ja va 2 s . c om } // collect those filters under a repeat since they are arrays Set<String> arrayTags = new HashSet<String>(); for (EvalMatchUntilFactoryNode matchUntilNode : evalNodeAnalysisResult.getRepeatNodes()) { EvalNodeAnalysisResult matchUntilAnalysisResult = EvalNodeUtil .recursiveAnalyzeChildNodes(matchUntilNode.getChildNodes().get(0)); for (EvalFilterFactoryNode filterNode : matchUntilAnalysisResult.getFilterNodes()) { String optionalTag = filterNode.getEventAsName(); if (optionalTag != null) { arrayTags.add(optionalTag); } } } // for each array tag change collection for (String arrayTag : arrayTags) { if (taggedEventTypes.get(arrayTag) != null) { arrayEventTypes.put(arrayTag, taggedEventTypes.get(arrayTag)); taggedEventTypes.remove(arrayTag); } } return new MatchEventSpec(taggedEventTypes, arrayEventTypes); }
From source file:hydrograph.ui.propertywindow.widgets.customwidgets.joinproperty.ELTJoinPortCount.java
@Override public LinkedHashMap<String, Object> getProperties() { LinkedHashMap<String, Object> property = new LinkedHashMap<>(); try {/* ww w .jav a 2s. c om*/ if (Integer.parseInt(textBox.getText()) < minimunPortCount || Integer.parseInt(textBox.getText()) > 25) { property.put(propertyName, textBox.getText()); property.put(firstPortPropertyName, textBox.getText()); if (StringUtils.isNotEmpty(unusedPortPropertyName)) property.put(unusedPortPropertyName, textBox.getText()); setToolTipErrorMessage(); } else { property.put(propertyName, textBox.getText()); property.put(firstPortPropertyName, textBox.getText()); if (StringUtils.isNotEmpty(unusedPortPropertyName)) property.put(unusedPortPropertyName, textBox.getText()); } } catch (NumberFormatException nfe) { logger.error("Error while saving port Count. Numerical value expected", nfe); } return property; }