List of usage examples for java.util SortedMap put
V put(K key, V value);
From source file:eu.domibus.submission.webService.impl.BackendWebServiceImpl.java
private void enrichMessageWithSMPData(Messaging ebMSHeaderInfo) { String endpointAddress = ""; final SortedMap<String, Object> metadata = new TreeMap<String, Object>(); //Service@Type is ignored because as of now it is not supported by the SMP datamodel metadata.put(Metadata.PROCESS_ID, ebMSHeaderInfo.getUserMessage().getCollaborationInfo().getService().getValue()); metadata.put(Metadata.DOCUMENT_OR_ACTION_ID, ebMSHeaderInfo.getUserMessage().getCollaborationInfo().getAction()); for (Property property : ebMSHeaderInfo.getUserMessage().getMessageProperties().getProperty()) { switch (property.getName()) { case "originalSender": metadata.put(Metadata.SENDING_END_ENTITY_ID, property.getValue()); break; case "finalRecipient": metadata.put(Metadata.RECEIVING_END_ENTITY_ID, property.getValue()); break; }/* www . j a va 2s . c o m*/ } //should be configurable metadata.put(Metadata.COMMUNITY, "civil-law"); metadata.put(Metadata.ENVIRONMENT, "test"); metadata.put(Metadata.TRANSPORT_PROFILE_ID, "ebms3-as4"); metadata.put(Metadata.SUFFIX, "community.eu"); //!!! metadata.put(Metadata.COUNTRY_CODE_OR_EU, "*"); metadata.put(Metadata.NAMING_SCHEME, new ECodexNamingScheme()); try { discoveryClient.resolveMetadata(metadata); endpointAddress = (String) metadata.get(Metadata.ENDPOINT_ADDRESS); } catch (DiscoveryException e) { LOG.error("", e); } Collection<Identifier> identifiers = partyIndentifierResolverService.resolveByEndpoint(endpointAddress); PartyId partyId = new PartyId(); for (Identifier identifier : identifiers) { partyId.setType(identifier.getPartyIdType().getValue()); partyId.setValue(identifier.getPartyId()); ebMSHeaderInfo.getUserMessage().getPartyInfo().getTo().getPartyId().add(partyId); } }
From source file:com.tripit.auth.OAuthCredential.java
@SuppressWarnings("unchecked") private SortedMap<String, String> generateOAuthParameters(String url, SortedMap<String, String> params) throws UnsupportedEncodingException, InvalidKeyException, NoSuchAlgorithmException { TreeMap<String, String> oauthParameters = new TreeMap<String, String>(); oauthParameters.put("oauth_consumer_key", consumerKey); oauthParameters.put("oauth_nonce", generateNonce()); oauthParameters.put("oauth_timestamp", generateTimestamp()); oauthParameters.put("oauth_signature_method", OAUTH_SIGNATURE_METHOD); oauthParameters.put("oauth_version", OAUTH_VERSION); if (userKey != null) { oauthParameters.put("oauth_token", userKey); }//w w w . j a v a 2 s . c o m if (requestorId != null) { oauthParameters.put("xoauth_requestor_id", requestorId); } SortedMap<String, String> oauthParametersForBaseString = (SortedMap<String, String>) oauthParameters .clone(); if (params != null) { for (Map.Entry<String, String> param : params.entrySet()) { oauthParametersForBaseString.put(param.getKey(), param.getValue()); } } oauthParameters.put("oauth_signature", generateSignature(url, oauthParametersForBaseString)); return oauthParameters; }
From source file:edu.northwestern.bioinformatics.studycalendar.restlets.SchedulePreviewResource.java
public SortedMap<Date, List<ScheduledActivity>> createActivitiesByDate( List<ScheduledActivity> scheduledActivities) { SortedMap<Date, List<ScheduledActivity>> byDate = new TreeMap<Date, List<ScheduledActivity>>(); Collections.sort(scheduledActivities); for (ScheduledActivity scheduledActivity : scheduledActivities) { Date key = scheduledActivity.getActualDate(); if (!byDate.containsKey(key)) { byDate.put(key, new ArrayList<ScheduledActivity>()); }/*from ww w . j a v a2 s . co m*/ byDate.get(key).add(scheduledActivity); } return byDate; }
From source file:de.faustedition.tei.TeiValidator.java
@Override public void run() { try {/* w ww. j a v a 2 s . c om*/ final SortedSet<FaustURI> xmlErrors = new TreeSet<FaustURI>(); final SortedMap<FaustURI, String> teiErrors = new TreeMap<FaustURI, String>(); for (FaustURI source : xml.iterate(new FaustURI(FaustAuthority.XML, "/transcript"))) { try { final List<String> errors = validate(source); if (!errors.isEmpty()) { teiErrors.put(source, Joiner.on("\n").join(errors)); } } catch (SAXException e) { logger.debug("XML error while validating transcript: " + source, e); xmlErrors.add(source); } catch (IOException e) { logger.warn("I/O error while validating transcript: " + source, e); } } if (xmlErrors.isEmpty() && teiErrors.isEmpty()) { return; } reporter.send("TEI validation report", new ReportCreator() { public void create(PrintWriter body) { if (!xmlErrors.isEmpty()) { body.println(Strings.padStart(" XML errors", 79, '=')); body.println(); body.println(Joiner.on("\n").join(xmlErrors)); body.println(); } if (!teiErrors.isEmpty()) { body.println(Strings.padStart(" TEI errors", 79, '=')); body.println(); for (Map.Entry<FaustURI, String> teiError : teiErrors.entrySet()) { body.println(Strings.padStart(" " + teiError.getKey(), 79, '-')); body.println(); body.println(teiError.getValue()); body.println(); body.println(); } } } }); } catch (EmailException e) { e.printStackTrace(); } }
From source file:com.aurel.track.report.dashboard.AverageTimeToCloseItem.java
/** * Add the time series to the timeSeriesCollection * SortedMap at first and second level (year and period) * (Sorted because the accumulated should be calculated in the right order) * @param timeSeriesCollection//from w w w. j ava 2 s . c o m * @param yearToPeriodToOpenedWorkItemCountMap * @param selectedTimeInterval */ public static SortedMap<Date, Object> transformPeriodsToDates( SortedMap/*<Integer, SortedMap<Integer, Object>>*/ yearToPeriodToValuesMap, int selectedTimeInterval) { SortedMap<Date, Object> dateToValue = new TreeMap<Date, Object>(); for (Iterator iterator = yearToPeriodToValuesMap.keySet().iterator(); iterator.hasNext();) { Integer year = (Integer) iterator.next(); SortedMap<Integer, Object> intervalToStatusChangeBeans = (SortedMap<Integer, Object>) yearToPeriodToValuesMap .get(year); Iterator<Integer> periodIterator = intervalToStatusChangeBeans.keySet().iterator(); while (periodIterator.hasNext()) { Integer period = periodIterator.next(); Object periodValue = intervalToStatusChangeBeans.get(period); if (periodValue != null) { dateToValue.put(createDate(period.intValue(), year.intValue(), selectedTimeInterval), periodValue); } } } return dateToValue; }
From source file:net.openj21.mih.protocol.codec.AnnotationUtils.java
/** * Returns a Collection containing all fields of the given SEQUENCE class * that are annotated with the SEQUENCE_ELEMENT annotation. The collection * is sorted on the order of the sequence elements. * * @param sequenceClass a class//w w w. j a v a 2s . co m * @return a Collection containing all fields of the given SEQUENCE class */ public Collection<Field> getSequenceFields(Class<?> sequenceClass) { final SortedMap<Integer, Field> toEncodeFields = new TreeMap<Integer, Field>(); ReflectionUtils.doWithFields(sequenceClass, new ReflectionUtils.FieldCallback() { public void doWith(Field field) throws IllegalArgumentException, IllegalAccessException { SEQUENCE_ELEMENT encodedAnnotation = field.getAnnotation(SEQUENCE_ELEMENT.class); if (encodedAnnotation != null) { if (toEncodeFields.put(encodedAnnotation.order(), field) != null) { throw new IllegalStateException( "Duplicate " + SEQUENCE_ELEMENT.class.getSimpleName() + " order: " + field); } } } }); return toEncodeFields.values(); }
From source file:com.michelin.cio.hudson.plugins.rolestrategy.RoleMap.java
/** * Create a sub-map of the current {@link RoleMap} containing only the * {@link Role}s matching the given pattern. * @param namePattern The pattern to match * @return A {@link RoleMap} containing only {@link Role}s matching the given name */// ww w .ja va2s . co m public RoleMap newMatchingRoleMap(String namePattern) { Set<Role> roles = getMatchingRoles(namePattern); SortedMap<Role, Set<String>> roleMap = new TreeMap<Role, Set<String>>(); for (Role role : roles) { roleMap.put(role, this.grantedRoles.get(role)); } return new RoleMap(roleMap); }
From source file:cz.muni.fi.mir.controllers.StatisticsController.java
private ModelMap prepareStatisticsModelMap(Statistics stat, Map<Long, DateTime> dropdownMap) { Map<Pair<Configuration, Revision>, SortedMap<String, Integer>> map = new HashMap<>(); Map<String, Integer> graph = new HashMap<>(); SortedSet<String> columns = new TreeSet<>(); for (StatisticsHolder sh : stat.getStatisticsHolders()) { Pair<Configuration, Revision> key = new Pair<>(sh.getConfiguration(), sh.getRevision()); SortedMap<String, Integer> keyValues = null; if (map.containsKey(key)) { keyValues = map.get(key);/*from w w w .j av a2 s .c o m*/ addOrIncrement(sh.getAnnotation(), sh.getCount(), keyValues); addOrIncrement(sh.getAnnotation(), sh.getCount(), graph); } else { keyValues = new TreeMap<>(); keyValues.put(sh.getAnnotation(), sh.getCount()); addOrIncrement(sh.getAnnotation(), sh.getCount(), graph); } map.put(key, keyValues); columns.add(sh.getAnnotation()); } //postprocessing to fill empty columns for (Pair<Configuration, Revision> pair : map.keySet()) { SortedMap<String, Integer> values = map.get(pair); for (String s : columns) { if (!values.containsKey(s)) { values.put(s, 0); } } map.put(pair, values); } ModelMap mm = new ModelMap(); mm.addAttribute("statisticsMap", map); mm.addAttribute("statisticsColumns", columns); mm.addAttribute("statisticsDate", stat.getCalculationDate()); mm.addAttribute("formulaCount", stat.getTotalFormulas()); mm.addAttribute("coCount", stat.getTotalCanonicOutputs()); mm.addAttribute("graph", graph); mm.addAttribute("statisticsDropdown", dropdownMap); return mm; }
From source file:com.aqnote.app.wifianalyzer.vendor.model.VendorService.java
public SortedMap<String, List<String>> findAll() { SortedMap<String, List<String>> results = new TreeMap<>(); Database database = MainContext.INSTANCE.getDatabase(); List<VendorData> vendorDatas = database.findAll(); for (VendorData vendorData : vendorDatas) { String key = VendorNameUtils.cleanVendorName(vendorData.getName()); List<String> macs = results.get(key); if (macs == null) { macs = new ArrayList<>(); results.put(key, macs); }//from w w w . jav a 2 s .co m macs.add(vendorData.getMac()); Collections.sort(macs); } return results; }
From source file:de.micromata.genome.gwiki.controls.GWikiUserRightsPropsDescriptorValue.java
@Override public String render(GWikiPropsEditorArtefakt<?> editor, PropsEditContext pct) { GWikiAuthorization auth = pct.getWikiContext().getWikiWeb().getAuthorization(); if ((auth instanceof GWikiAuthorizationExt) == false) { return super.render(editor, pct); }/*from w w w . jav a 2 s.c om*/ GWikiAuthorizationExt authx = (GWikiAuthorizationExt) auth; SortedMap<String, GWikiRight> systemRights = authx.getSystemRights(pct.getWikiContext()); String pval = pct.getPropsValue(); SortedMap<String, GWikiRight> usr = authx.getUserRight(pct.getWikiContext(), systemRights, pval); for (Map.Entry<String, GWikiRight> me : usr.entrySet()) { if (systemRights.containsKey(me.getKey()) == false) { systemRights.put(me.getKey(), me.getValue()); } } Map<String, List<GWikiRight>> groups = new TreeMap<String, List<GWikiRight>>(); for (Map.Entry<String, GWikiRight> me : systemRights.entrySet()) { List<GWikiRight> gr = groups.get(me.getValue().getCategory()); if (gr == null) { gr = new ArrayList<GWikiRight>(); groups.put(me.getValue().getCategory(), gr); } gr.add(me.getValue()); } StringBuilder sb = new StringBuilder(); sb.append("<ul>\n"); for (Map.Entry<String, List<GWikiRight>> ge : groups.entrySet()) { sb.append("<li>").append(ge.getKey()).append("<br/><ul>"); for (GWikiRight r : ge.getValue()) { if (r.isPrivateRight() == true) { continue; } sb.append("<li><input type=\"checkbox\" name=\"right.").append(r.getName()).append("\""); if (usr.containsKey(r.getName()) == true) { sb.append(" checked=\"checked\""); } sb.append(">"); if (StringUtils.isNotBlank(r.getDescription()) == true) { sb.append("<a href=\"#\" title=\"") // .append(StringEscapeUtils.escapeXml(r.getDescription())).append("\">") .append(StringEscapeUtils.escapeXml(r.getName())).append("</a>"); } else { sb.append(StringEscapeUtils.escapeXml(r.getName())); } sb.append("</li>\n"); } sb.append("</ul></li>\n"); } // for (Map.Entry<String, GWikiRight> me : systemRights.entrySet()) { // // } sb.append("</ul>\n"); return sb.toString();// + super.render(editor, pct); }