List of usage examples for java.util SortedMap keySet
Set<K> keySet();
From source file:org.web4thejob.studio.controller.impl.PropertyEditorController.java
private void refreshComponentEvents(SortedMap<String, SortedSet<Element>> propsMap) { Grid grid = new Grid(); grid.setParent(events);/* ww w . java 2 s .c om*/ grid.setVflex("true"); grid.setSpan(true); new Columns().setParent(grid); grid.getColumns().setSizable(true); new Column("Name").setParent(grid.getColumns()); Column colServer = new Column("Server"); colServer.setParent(grid.getColumns()); colServer.setAlign("center"); colServer.setWidth("60px"); Column colClient = new Column("Client"); colClient.setParent(grid.getColumns()); colClient.setAlign("center"); colClient.setWidth("60px"); new Rows().setParent(grid); for (String group : propsMap.keySet()) { for (Element property : propsMap.get(group)) { String propertyName = property.getAttributeValue("name"); if (isEvent(propertyName)) { Row row = new Row(); row.setParent(grid.getRows()); Label name = new Label(propertyName); name.setParent(row); Button btn = new Button(); // btn.setMold("bs"); btn.setParent(row); btn.setIconSclass("z-icon-bolt"); btn.setAttribute("mode", "text/x-java"); btn.setAttribute("event", propertyName); btn.setAttribute("element", selection); btn.addEventListener(Events.ON_CLICK, CODE_EDITOR_HANDLER); if (getEventCodeNode(selection, propertyName, true) != null) { btn.setZclass("btn btn-xs btn-primary"); } else { btn.setZclass("btn btn-xs btn-default"); } btn.setWidth("32px"); btn.setHeight("25px"); btn = new Button(); // btn.setMold("bs"); btn.setParent(row); btn.setIconSclass("z-icon-bolt"); btn.setAttribute("mode", "javascript"); btn.setAttribute("event", propertyName); btn.setAttribute("element", selection); btn.addEventListener(Events.ON_CLICK, CODE_EDITOR_HANDLER); if (getEventCodeNode(selection, propertyName, false) != null) { btn.setZclass("btn btn-xs btn-primary"); } else { btn.setZclass("btn btn-xs btn-default"); } btn.setWidth("32px"); btn.setHeight("25px"); } } } }
From source file:org.wso2.carbon.ml.core.impl.MLModelHandler.java
private List<Integer> getNewToOldIndicesList(SortedMap<Integer, String> includedFeatures) { List<Integer> indicesList = new ArrayList<Integer>(); for (int featureIdx : includedFeatures.keySet()) { indicesList.add(featureIdx);/*from w ww. ja v a 2s . c o m*/ } return indicesList; }
From source file:com.aurel.track.report.dashboard.StatusOverTimeGraph.java
/** * Computes the hierarchical data for status changes * * @return//from ww w . ja v a2s . c o m */ public static SortedMap<Integer, SortedMap<Integer, Map<Integer, Integer>>> calculateTotalInStatus( int[] workItemIDs, Date dateFrom, Date dateTo, List<Integer> statusIDs, int selectedTimeInterval, Locale locale) { SortedMap<Integer, SortedMap<Integer, Map<Integer, Integer>>> yearToPeriodToStatusIDToStatusNumbersMap = new TreeMap<Integer, SortedMap<Integer, Map<Integer, Integer>>>(); if (statusIDs != null && statusIDs.isEmpty()) { LOGGER.warn("No status specified"); return yearToPeriodToStatusIDToStatusNumbersMap; } Set<Integer> statusIDsSet = GeneralUtils.createIntegerSetFromIntegerList(statusIDs); if (workItemIDs == null || workItemIDs.length == 0) { // LOGGER.warn("No issues satisfy the filtering condition (read right revoked, project/release deleted?)"); return yearToPeriodToStatusIDToStatusNumbersMap; } Map<Integer, Integer> statusForWorkItems = new HashMap<Integer, Integer>(); List<HistorySelectValues> historySelectValuesBefore = null; if (dateFrom != null) { //get all status changes till the beginning of the reporting period //include all statuses (not just the selected ones) //because we are interested only in the status at the end of each period historySelectValuesBefore = HistoryTransactionBL.getByWorkItemsFieldNewValuesDates(workItemIDs, SystemFields.INTEGER_STATE, null, null, dateFrom); } //get all status changes for the reporting period //include all statuses (not just the selected ones) //because we are interested only in the status at the end of each period List<HistorySelectValues> historySelectValuesReportingPeriod = HistoryTransactionBL .getByWorkItemsFieldNewValuesDates(workItemIDs, SystemFields.INTEGER_STATE, null, dateFrom, dateTo); SortedMap<Integer, SortedMap<Integer, List<HistorySelectValues>>> periodStatusChangesReportingPeriod = getStatusChangesMap( historySelectValuesReportingPeriod, selectedTimeInterval, true/*, statusIDs*/); Integer year = null; Integer period = null; Iterator yearIterator; //calculate the values for the beginning of the first reporting period if (historySelectValuesBefore != null) { //get the first year and period if (dateFrom != null) { //explicit dateFrom specified by user Calendar calendar = Calendar.getInstance(); calendar.setTime(dateFrom); year = Integer.valueOf(calendar.get(Calendar.YEAR)); int calendarInterval = getCalendarInterval(selectedTimeInterval); period = Integer.valueOf(calendar.get(calendarInterval)); } else { //no explicit dateFrom specified by the user, get the first found entry in the history yearIterator = periodStatusChangesReportingPeriod.keySet().iterator(); if (yearIterator.hasNext()) { year = (Integer) yearIterator.next(); SortedMap<Integer, List<HistorySelectValues>> intervalToStatusChangeBeans = periodStatusChangesReportingPeriod .get(year); Iterator<Integer> periodIterator = intervalToStatusChangeBeans.keySet().iterator(); period = periodIterator.next(); } } if (year == null || period == null) { //nothing found return yearToPeriodToStatusIDToStatusNumbersMap; } Iterator<HistorySelectValues> iterator = historySelectValuesBefore.iterator(); while (iterator.hasNext()) { //count the workItems in status till the beginning of the reporting period HistorySelectValues historySelectValues = iterator.next(); Integer workItemID = historySelectValues.getWorkItemID(); Integer statusID = historySelectValues.getNewValue(); if (statusForWorkItems.get(workItemID) == null) { //take into account only the last stateChange for the workItem statusForWorkItems.put(workItemID, statusID); if (statusIDsSet.contains(statusID)) { //count only if selected status setCount(yearToPeriodToStatusIDToStatusNumbersMap, year, period, statusID, 1); } } } } yearIterator = periodStatusChangesReportingPeriod.keySet().iterator(); while (yearIterator.hasNext()) { year = (Integer) yearIterator.next(); SortedMap intervalToStatusChangeBeans = periodStatusChangesReportingPeriod.get(year); Iterator<Integer> periodIterator = intervalToStatusChangeBeans.keySet().iterator(); while (periodIterator.hasNext()) { period = periodIterator.next(); List statusChangeBeansForInterval = (List) intervalToStatusChangeBeans.get(period); if (statusChangeBeansForInterval != null) { Iterator statusChangeBeansIterator = statusChangeBeansForInterval.iterator(); while (statusChangeBeansIterator.hasNext()) { HistorySelectValues historySelectValues = (HistorySelectValues) statusChangeBeansIterator .next(); Integer workItemID = historySelectValues.getWorkItemID(); Integer nextStatusID = historySelectValues.getNewValue(); Integer previousStatus = statusForWorkItems.get(workItemID); if (previousStatus == null) { //probably the item was created in the actual period statusForWorkItems.put(workItemID, nextStatusID); if (statusIDsSet.contains(nextStatusID)) { setCount(yearToPeriodToStatusIDToStatusNumbersMap, year, period, nextStatusID, 1); } } else { if (!previousStatus.equals(nextStatusID)) { statusForWorkItems.put(workItemID, nextStatusID); //add as new status if (statusIDsSet.contains(nextStatusID)) { setCount(yearToPeriodToStatusIDToStatusNumbersMap, year, period, nextStatusID, 1); } //decrement the count for the previous status if (statusIDsSet.contains(previousStatus)) { setCount(yearToPeriodToStatusIDToStatusNumbersMap, year, period, previousStatus, -1); } } } } } } } addZerosForEmptyIntervals(dateFrom, dateTo, selectedTimeInterval, yearToPeriodToStatusIDToStatusNumbersMap, statusIDs); //addTimeSeries(timeSeriesCollection, yearToPeriodToStatusIDToStatusNumbersMap, statusMap, selectedTimeInterval, true); return yearToPeriodToStatusIDToStatusNumbersMap; }
From source file:org.wso2.carbon.identity.oauth2.authcontext.JWTTokenGenerator.java
/** * Method that generates the JWT./*from w w w .j ava 2 s. c o m*/ * * @return signed JWT token * @throws IdentityOAuth2Exception */ @Override public void generateToken(OAuth2TokenValidationMessageContext messageContext) throws IdentityOAuth2Exception { String clientId = ((AccessTokenDO) messageContext.getProperty("AccessTokenDO")).getConsumerKey(); long issuedTime = ((AccessTokenDO) messageContext.getProperty("AccessTokenDO")).getIssuedTime().getTime(); String authzUser = messageContext.getResponseDTO().getAuthorizedUser(); int tenantID = ((AccessTokenDO) messageContext.getProperty("AccessTokenDO")).getTenantID(); String tenantDomain = OAuth2Util.getTenantDomain(tenantID); boolean isExistingUser = false; RealmService realmService = OAuthComponentServiceHolder.getRealmService(); // TODO : Need to handle situation where federated user name is similar to a one we have in our user store if (realmService != null && tenantID != MultitenantConstants.INVALID_TENANT_ID && tenantID == OAuth2Util.getTenantIdFromUserName(authzUser)) { try { UserRealm userRealm = realmService.getTenantUserRealm(tenantID); if (userRealm != null) { UserStoreManager userStoreManager = (UserStoreManager) userRealm.getUserStoreManager(); isExistingUser = userStoreManager .isExistingUser(MultitenantUtils.getTenantAwareUsername(authzUser)); } } catch (UserStoreException e) { log.error("Error occurred while loading the realm service", e); } } OAuthAppDAO appDAO = new OAuthAppDAO(); OAuthAppDO appDO; try { appDO = appDAO.getAppInformation(clientId); // Adding the OAuthAppDO as a context property for further use messageContext.addProperty("OAuthAppDO", appDO); } catch (IdentityOAuth2Exception e) { log.debug(e.getMessage(), e); throw new IdentityOAuth2Exception(e.getMessage()); } catch (InvalidOAuthClientException e) { log.debug(e.getMessage(), e); throw new IdentityOAuth2Exception(e.getMessage()); } String subscriber = appDO.getUserName(); String applicationName = appDO.getApplicationName(); //generating expiring timestamp long currentTime = Calendar.getInstance().getTimeInMillis(); long expireIn = currentTime + 1000 * 60 * getTTL(); // Prepare JWT with claims set JWTClaimsSet claimsSet = new JWTClaimsSet(); claimsSet.setIssuer(API_GATEWAY_ID); claimsSet.setSubject(authzUser); claimsSet.setIssueTime(new Date(issuedTime)); claimsSet.setExpirationTime(new Date(expireIn)); claimsSet.setClaim(API_GATEWAY_ID + "/subscriber", subscriber); claimsSet.setClaim(API_GATEWAY_ID + "/applicationname", applicationName); claimsSet.setClaim(API_GATEWAY_ID + "/enduser", authzUser); if (claimsRetriever != null) { //check in local cache String[] requestedClaims = messageContext.getRequestDTO().getRequiredClaimURIs(); if (requestedClaims == null && isExistingUser) { // if no claims were requested, return all requestedClaims = claimsRetriever.getDefaultClaims(authzUser); } CacheKey cacheKey = null; Object result = null; if (requestedClaims != null) { cacheKey = new ClaimCacheKey(authzUser, requestedClaims); result = claimsLocalCache.getValueFromCache(cacheKey); } SortedMap<String, String> claimValues = null; if (result != null) { claimValues = ((UserClaims) result).getClaimValues(); } else if (isExistingUser) { claimValues = claimsRetriever.getClaims(authzUser, requestedClaims); UserClaims userClaims = new UserClaims(claimValues); claimsLocalCache.addToCache(cacheKey, userClaims); } if (isExistingUser) { String claimSeparator = getMultiAttributeSeparator(authzUser, tenantID); if (StringUtils.isBlank(claimSeparator)) { userAttributeSeparator = claimSeparator; } } if (claimValues != null) { Iterator<String> it = new TreeSet(claimValues.keySet()).iterator(); while (it.hasNext()) { String claimURI = it.next(); String claimVal = claimValues.get(claimURI); List<String> claimList = new ArrayList<String>(); if (userAttributeSeparator != null && claimVal.contains(userAttributeSeparator)) { StringTokenizer st = new StringTokenizer(claimVal, userAttributeSeparator); while (st.hasMoreElements()) { String attValue = st.nextElement().toString(); if (StringUtils.isNotBlank(attValue)) { claimList.add(attValue); } } claimsSet.setClaim(claimURI, claimList.toArray(new String[claimList.size()])); } else { claimsSet.setClaim(claimURI, claimVal); } } } } JWT jwt = null; if (!JWSAlgorithm.NONE.equals(signatureAlgorithm)) { JWSHeader header = new JWSHeader(JWSAlgorithm.RS256); header.setX509CertThumbprint(new Base64URL(getThumbPrint(tenantDomain, tenantID))); jwt = new SignedJWT(header, claimsSet); jwt = signJWT((SignedJWT) jwt, tenantDomain, tenantID); } else { jwt = new PlainJWT(claimsSet); } if (log.isDebugEnabled()) { log.debug("JWT Assertion Value : " + jwt.serialize()); } OAuth2TokenValidationResponseDTO.AuthorizationContextToken token; token = messageContext.getResponseDTO().new AuthorizationContextToken("JWT", jwt.serialize()); messageContext.getResponseDTO().setAuthorizationContextToken(token); }
From source file:annis.visualizers.htmlvis.HTMLVis.java
private String createHTML(SDocumentGraph graph, VisualizationDefinition[] definitions) { SortedMap<Long, SortedSet<OutputItem>> outputStartTags = new TreeMap<Long, SortedSet<OutputItem>>(); SortedMap<Long, SortedSet<OutputItem>> outputEndTags = new TreeMap<Long, SortedSet<OutputItem>>(); StringBuilder sb = new StringBuilder(); EList<SToken> token = graph.getSortedSTokenByText(); for (SToken t : token) { for (VisualizationDefinition vis : definitions) { String matched = vis.getMatcher().matchedAnnotation(t); if (matched != null) { vis.getOutputter().outputHTML(t, matched, outputStartTags, outputEndTags); }/* w ww . jav a 2 s.c o m*/ } } List<SSpan> spans = graph.getSSpans(); for (VisualizationDefinition vis : definitions) { for (SSpan span : spans) { String matched = vis.getMatcher().matchedAnnotation(span); if (matched != null) { vis.getOutputter().outputHTML(span, matched, outputStartTags, outputEndTags); } } } // get all used indexes Set<Long> indexes = new TreeSet<Long>(); indexes.addAll(outputStartTags.keySet()); indexes.addAll(outputEndTags.keySet()); for (Long i : indexes) { // output all strings belonging to this token position // first the start tags for this position SortedSet<OutputItem> itemsStart = outputStartTags.get(i); if (itemsStart != null) { Iterator<OutputItem> it = itemsStart.iterator(); boolean first = true; while (it.hasNext()) { OutputItem s = it.next(); if (!first) { sb.append("-->"); } first = false; sb.append(s.getOutputString()); if (it.hasNext()) { sb.append("<!--\n"); } } } // then the end tags for this position, but inverse their order SortedSet<OutputItem> itemsEnd = outputEndTags.get(i); if (itemsEnd != null) { List<OutputItem> itemsEndReverse = new LinkedList<OutputItem>(itemsEnd); Collections.reverse(itemsEndReverse); for (OutputItem s : itemsEndReverse) { sb.append(s.getOutputString()); } } } return sb.toString(); }
From source file:org.apache.cayenne.map.ObjEntity.java
/** * Recursively appends all attributes in the entity inheritance hierarchy. *///from ww w . j ava 2s. c o m final void appendAttributes(Map<String, ObjAttribute> map) { map.putAll(getAttributeMapInternal()); ObjEntity superEntity = getSuperEntity(); if (superEntity != null) { SortedMap<String, ObjAttribute> attributeMap = new TreeMap<>(); superEntity.appendAttributes(attributeMap); for (String attributeName : attributeMap.keySet()) { String overridedDbPath = attributeOverrides.get(attributeName); ObjAttribute attribute = new ObjAttribute(attributeMap.get(attributeName)); attribute.setEntity(this); if (overridedDbPath != null) { attribute.setDbAttributePath(overridedDbPath); } map.put(attributeName, attribute); } } }
From source file:org.archive.crawler.admin.StatisticsTracker.java
protected void writeHostsReportTo(final PrintWriter writer) { // TODO: use CrawlHosts for all stats; only perform sorting on // manageable number of hosts SortedMap<String, AtomicLong> hd = getReverseSortedHostsDistribution(); // header/* ww w.ja va2 s . c om*/ writer.print( "[#urls] [#bytes] [host] [#robots] [#remaining] [#novel-urls] [#novel-bytes] [#dup-by-hash-urls] [#dup-by-hash-bytes] [#not-modified-urls] [#not-modified-bytes]\n"); for (String key : hd.keySet()) { // Key is 'host'. CrawlHost host = controller.getServerCache().getHostFor(key); AtomicLong val = hd.get(key); writeReportLine(writer, val == null ? "-" : val.get(), getBytesPerHost(key), key, host.getSubstats().getRobotsDenials(), host.getSubstats().getRemaining(), host.getSubstats().getNovelUrls(), host.getSubstats().getNovelBytes(), host.getSubstats().getDupByHashUrls(), host.getSubstats().getDupByHashBytes(), host.getSubstats().getNotModifiedUrls(), host.getSubstats().getNotModifiedBytes()); } // StatisticsTracker doesn't know of zero-completion hosts; // so supplement report with those entries from host cache Closure logZeros = new Closure() { public void execute(Object obj) { CrawlHost host = (CrawlHost) obj; if (host.getSubstats().getRecordedFinishes() == 0) { writeReportLine(writer, host.getSubstats().getRecordedFinishes(), host.getSubstats().getTotalBytes(), host.getHostName(), host.getSubstats().getRobotsDenials(), host.getSubstats().getRemaining(), host.getSubstats().getNovelUrls(), host.getSubstats().getNovelBytes(), host.getSubstats().getDupByHashUrls(), host.getSubstats().getDupByHashBytes(), host.getSubstats().getNotModifiedUrls(), host.getSubstats().getNotModifiedBytes()); } } }; controller.getServerCache().forAllHostsDo(logZeros); }
From source file:pt.ist.expenditureTrackingSystem.presentationTier.actions.statistics.StatisticsAction.java
private Spreadsheet generateSpreadSheet(final SortedMap<Object, BigDecimal> sumMap, final SortedMap<Object, BigDecimal> medianMap, final SortedMap<Object, BigDecimal> averageMap, final SortedMap<Object, BigDecimal> minsMap, final SortedMap<Object, BigDecimal> maxsMap) { final Spreadsheet spreadsheet = new Spreadsheet("Estatsticas"); spreadsheet.setHeader("Estado"); spreadsheet.setHeader("Soma"); spreadsheet.setHeader("Mediana Tempo (em dias)"); spreadsheet.setHeader("Mdia Tempo (em dias)"); spreadsheet.setHeader("Tempo Mnimo (em dias)"); spreadsheet.setHeader("Tempo Mximo (em dias)"); final SortedSet<Object> types = new TreeSet<Object>(); types.addAll(sumMap.keySet()); types.addAll(medianMap.keySet());/*from w w w .j a va 2 s. co m*/ types.addAll(averageMap.keySet()); BigDecimal DAYS_CONST = new BigDecimal(1000 * 3600 * 24); for (final Object type : types) { final BigDecimal sum = sumMap.get(type); final BigDecimal median = medianMap.get(type); final BigDecimal average = averageMap.get(type); final BigDecimal min = minsMap.get(type); final BigDecimal max = maxsMap.get(type); final Row row = spreadsheet.addRow(); row.setCell(((IPresentableEnum) type).getLocalizedName()); row.setCell(sum == null ? "0" : sum.toString()); row.setCell(median == null ? "" : median.divide(DAYS_CONST, 2, BigDecimal.ROUND_HALF_UP).toString()); row.setCell(average == null ? "" : average.divide(DAYS_CONST, 2, BigDecimal.ROUND_HALF_UP).toString()); row.setCell(min == null ? "" : min.divide(DAYS_CONST, 2, BigDecimal.ROUND_HALF_UP).toString()); row.setCell(max == null ? "" : max.divide(DAYS_CONST, 2, BigDecimal.ROUND_HALF_UP).toString()); } return spreadsheet; }
From source file:org.kuali.kra.budget.calculator.BudgetCalculationServiceImpl.java
protected SortedMap<BudgetCategoryType, List<CostElement>> categorizeObjectCodesByCategory(Budget budget) { SortedMap<CostElement, List<BudgetDecimal>> objectCodeTotals = budget.getObjectCodeTotals(); SortedMap<BudgetCategoryType, List<CostElement>> objectCodeListByBudgetCategoryType = new TreeMap<BudgetCategoryType, List<CostElement>>(); for (CostElement objectCode : objectCodeTotals.keySet()) { objectCode.refreshReferenceObject("budgetCategory"); if (objectCode.getBudgetCategory() != null) { objectCode.getBudgetCategory().refreshReferenceObject("budgetCategoryType"); objectCode.setBudgetCategoryTypeCode(objectCode.getBudgetCategory().getBudgetCategoryTypeCode()); }/*from w w w. ja va 2s. co m*/ if (!objectCodeListByBudgetCategoryType .containsKey(objectCode.getBudgetCategory().getBudgetCategoryType())) { List<CostElement> filteredObjectCodes = filterObjectCodesByBudgetCategoryType( objectCodeTotals.keySet(), objectCode.getBudgetCategoryTypeCode()); objectCodeListByBudgetCategoryType.put(objectCode.getBudgetCategory().getBudgetCategoryType(), filteredObjectCodes); } } return objectCodeListByBudgetCategoryType; }
From source file:edu.usc.pgroup.louvain.hadoop.ReduceCommunity.java
private Graph reconstructGraph(Iterable<BytesWritable> values) throws Exception { Iterator<BytesWritable> it = values.iterator(); SortedMap<Integer, GraphMessage> map = new TreeMap<Integer, GraphMessage>(); //Load data//from w w w . j av a 2s. c o m while (it.hasNext()) { BytesWritable bytesWritable = it.next(); ByteArrayInputStream inputStream = new ByteArrayInputStream(bytesWritable.getBytes()); try { ObjectInputStream objectInputStream = new ObjectInputStream(inputStream); GraphMessage msg = (GraphMessage) objectInputStream.readObject(); map.put(msg.getCurrentPartition(), msg); } catch (IOException e) { e.printStackTrace(); throw new Exception(e); } } // Renumber int gap = 0; int degreeGap = 0; Path pt = new Path(outpath + File.separator + "Map-Partition-Sizes"); FileSystem fs = FileSystem.get(new Configuration()); if (fs.exists(pt)) { fs.delete(pt, true); } BufferedWriter br = new BufferedWriter(new OutputStreamWriter(fs.create(pt, true))); PrintWriter out = new PrintWriter(br); for (int i = 0; i < map.keySet().size(); i++) { GraphMessage msg = map.get(i); long currentDegreelen = msg.getDegrees()[msg.getDegrees().length - 1]; if (i != 0) { for (int j = 0; j < msg.getLinks().length; j++) { msg.getLinks()[j] += gap; } for (int j = 0; j < msg.getRemoteMap().length; j++) { msg.getRemoteMap()[j].source += gap; } for (int j = 0; j < msg.getN2c().length; j++) { msg.getN2c()[j] += gap; } for (int j = 0; j < msg.getDegrees().length; j++) { msg.getDegrees()[j] += degreeGap; } } out.println("" + i + "," + msg.getNb_nodes()); gap += msg.getNb_nodes(); degreeGap += currentDegreelen; } out.flush(); out.close(); //Integrate Graph graph = new Graph(); for (int i = 0; i < map.keySet().size(); i++) { GraphMessage msg = map.get(i); Collections.addAll(graph.getDegrees().getList(), msg.getDegrees()); Collections.addAll(graph.getLinks().getList(), msg.getLinks()); Collections.addAll(graph.getWeights().getList(), msg.getWeights()); graph.setNb_links(graph.getNb_links() + msg.getNb_links()); graph.setNb_nodes((int) (graph.getNb_nodes() + msg.getNb_nodes())); graph.setTotal_weight(graph.getTotal_weight() + msg.getTotal_weight()); } //Merge local done. Map<Integer, Vector<Integer>> remoteEdges = new HashMap<Integer, Vector<Integer>>(); Map<Integer, Vector<Float>> remoteWeighs = new HashMap<Integer, Vector<Float>>(); for (int i = 0; i < map.keySet().size(); i++) { Map<HashMap.SimpleEntry<Integer, Integer>, Float> m = new HashMap<AbstractMap.SimpleEntry<Integer, Integer>, Float>(); GraphMessage msg = map.get(i); for (int j = 0; j < msg.getRemoteMap().length; j++) { RemoteMap remoteMap = msg.getRemoteMap()[j]; int sink = remoteMap.sink; int sinkPart = remoteMap.sinkPart; int target = map.get(sinkPart).getN2c()[sink]; HashMap.SimpleEntry<Integer, Integer> key = new HashMap.SimpleEntry<Integer, Integer>( remoteMap.source, target); if (m.containsKey(key)) { m.put(key, m.get(key) + 1.0f); } else { m.put(key, 1.0f); } } graph.setNb_links(graph.getNb_links() + m.size()); Iterator<HashMap.SimpleEntry<Integer, Integer>> itr = m.keySet().iterator(); while (itr.hasNext()) { HashMap.SimpleEntry<Integer, Integer> key = itr.next(); float w = m.get(key); if (remoteEdges.containsKey(key.getKey())) { remoteEdges.get(key.getKey()).getList().add(key.getValue()); if (remoteWeighs.containsKey(key.getKey())) { remoteWeighs.get(key.getKey()).getList().add(w); } } else { Vector<Integer> list = new Vector<Integer>(); list.getList().add(key.getValue()); remoteEdges.put(key.getKey(), list); Vector<Float> wList = new Vector<Float>(); wList.getList().add(w); remoteWeighs.put(key.getKey(), wList); } } } graph.addRemoteEdges(remoteEdges, remoteWeighs); //Merge Remote Done return graph; }