Example usage for java.util LinkedHashMap entrySet

List of usage examples for java.util LinkedHashMap entrySet

Introduction

In this page you can find the example usage for java.util LinkedHashMap entrySet.

Prototype

public Set<Map.Entry<K, V>> entrySet() 

Source Link

Document

Returns a Set view of the mappings contained in this map.

Usage

From source file:com.fortify.bugtracker.common.tgt.processor.AbstractTargetProcessorUpdateIssues.java

private LinkedHashMap<String, Object> removeUnmodifiedFields(
        TargetIssueLocatorAndFields targetIssueLocatorAndFields,
        LinkedHashMap<String, Object> issueFieldsForUpdate) {
    LinkedHashMap<String, Object> result = new LinkedHashMap<>();
    JSONMap currentIssueFields = targetIssueLocatorAndFields.getFields();
    for (Map.Entry<String, Object> entry : issueFieldsForUpdate.entrySet()) {
        Object currentValue = currentIssueFields.get(entry.getKey());
        if (currentValue == null || areFieldValuesDifferent(currentValue, entry.getValue())) {
            result.put(entry.getKey(), entry.getValue());
        }/* w  ww.  j a v  a  2s.c  o  m*/
    }
    return result;
}

From source file:com.fortify.bugtracker.tgt.archer.connection.ArcherAuthenticatingRestConnection.java

public TargetIssueLocator submitIssue(LinkedHashMap<String, Object> issueData) {
    JSONMap data = new JSONMap();
    JSONMap fieldContents = new JSONMap();
    data.putPath("Content.LevelId", this.levelId);
    data.putPath("Content.FieldContents", fieldContents);
    for (Map.Entry<String, Object> entry : issueData.entrySet()) {
        String key = entry.getKey();
        Object value = entry.getValue();
        FieldContentAdder adder = fieldNamesToFieldContentAdderMap.get(key);
        if (adder == null) {
            LOG.error("[Archer] Field " + key + " not found in application, skipping");
        } else {//from w  w w  .ja va  2 s  .  c  o  m
            adder.addFieldContent(fieldContents, key, value);
        }
    }
    JSONMap result = executeRequest(HttpMethod.POST, getBaseResource().path("api/core/content"),
            Entity.entity(data, "application/json"), JSONMap.class);
    String id = SpringExpressionUtil.evaluateExpression(result, "RequestedObject.Id", String.class);
    return new TargetIssueLocator(id, getDeepLink(id));
}

From source file:com.fortify.processrunner.archer.connection.ArcherAuthenticatingRestConnection.java

public SubmittedIssue submitIssue(LinkedHashMap<String, Object> issueData) {
    JSONMap data = new JSONMap();
    JSONMap fieldContents = new JSONMap();
    data.putPath("Content.LevelId", this.levelId);
    data.putPath("Content.FieldContents", fieldContents);
    for (Map.Entry<String, Object> entry : issueData.entrySet()) {
        String key = entry.getKey();
        Object value = entry.getValue();
        FieldContentAdder adder = fieldNamesToFieldContentAdderMap.get(key);
        if (adder == null) {
            LOG.error("[Archer] Field " + key + " not found in application, skipping");
        } else {//from   www  .j a  v a2  s.  co m
            adder.addFieldContent(fieldContents, key, value);
        }
    }
    JSONMap result = executeRequest(HttpMethod.POST, getBaseResource().path("api/core/content"),
            Entity.entity(data, "application/json"), JSONMap.class);
    String id = SpringExpressionUtil.evaluateExpression(result, "RequestedObject.Id", String.class);
    return new SubmittedIssue(id, getDeepLink(id));
}

From source file:org.apache.hadoop.hive.ql.parse.RowResolver.java

/**
 * Gets the column Info to tab_alias.col_alias type of a column reference. I
 * the tab_alias is not provided as can be the case with an non aliased
 * column, this function looks up the column in all the table aliases in this
 * row resolver and returns the match. It also throws an exception if the
 * column is found in multiple table aliases. If no match is found a null
 * values is returned./*from   ww  w .  jav  a 2s.c o  m*/
 *
 * This allows us to interpret both select t.c1 type of references and select
 * c1 kind of references. The later kind are what we call non aliased column
 * references in the query.
 *
 * @param tab_alias
 *          The table alias to match (this is null if the column reference is
 *          non aliased)
 * @param col_alias
 *          The column name that is being searched for
 * @return ColumnInfo
 * @throws SemanticException
 */
public ColumnInfo get(String tab_alias, String col_alias) throws SemanticException {
    col_alias = col_alias.toLowerCase();
    ColumnInfo ret = null;

    if (tab_alias != null) {
        tab_alias = tab_alias.toLowerCase();
        HashMap<String, ColumnInfo> f_map = rslvMap.get(tab_alias);
        if (f_map == null) {
            return null;
        }
        ret = f_map.get(col_alias);
    } else {
        boolean found = false;
        String foundTbl = null;
        for (Map.Entry<String, LinkedHashMap<String, ColumnInfo>> rslvEntry : rslvMap.entrySet()) {
            String rslvKey = rslvEntry.getKey();
            LinkedHashMap<String, ColumnInfo> cmap = rslvEntry.getValue();
            for (Map.Entry<String, ColumnInfo> cmapEnt : cmap.entrySet()) {
                if (col_alias.equalsIgnoreCase(cmapEnt.getKey())) {
                    /*
                     * We can have an unaliased and one aliased mapping to a Column.
                     */
                    if (found && foundTbl != null && rslvKey != null) {
                        throw new SemanticException(
                                "Column " + col_alias + " Found in more than One Tables/Subqueries");
                    }
                    found = true;
                    foundTbl = rslvKey == null ? foundTbl : rslvKey;
                    ret = cmapEnt.getValue();
                }
            }
        }
    }

    return ret;
}

From source file:fingerprint.MyStructureFingerprint.java

private List<Integer> computeHistogramD2(LinkedHashMap<PhiThetaInterval, List<PointIfc>> groupedResidues) {

    List<Integer> histogramD2 = new ArrayList<>();

    List<PointIfc> onePointPerGroup = new ArrayList<>();
    for (Entry<PhiThetaInterval, List<PointIfc>> entry : groupedResidues.entrySet()) {
        if (entry.getValue().size() > 0) {
            onePointPerGroup.add(entry.getValue().get(0));
        }//from   w w  w .  ja v  a  2s . co m
    }

    List<Float> computelListDistanceBetweenTwoLists = SimilarityTools
            .computelListDistanceBetweenTwoLists(onePointPerGroup, onePointPerGroup, 1.0);
    int sizeList = 10;
    float distanceStep = (float) 20.0f / sizeList;
    float startAt = (float) 2.0;
    List<Integer> distributionDistance = SimilarityTools.binValues(computelListDistanceBetweenTwoLists,
            sizeList, distanceStep, startAt);
    histogramD2.addAll(distributionDistance);

    return histogramD2;
}

From source file:org.apache.hadoop.hive.ql.optimizer.physical.NullScanTaskDispatcher.java

private void processAlias(MapWork work, HashSet<TableScanOperator> tableScans) {
    ArrayList<String> aliases = new ArrayList<String>();
    for (TableScanOperator tso : tableScans) {
        // use LinkedHashMap<String, Operator<? extends OperatorDesc>>
        // getAliasToWork()
        String alias = getAliasForTableScanOperator(work, tso);
        aliases.add(alias);/*from   w  w  w .j a va 2 s  . co  m*/
        tso.getConf().setIsMetadataOnly(true);
    }
    // group path alias according to work
    LinkedHashMap<String, ArrayList<String>> candidates = new LinkedHashMap<String, ArrayList<String>>();
    for (String path : work.getPaths()) {
        ArrayList<String> aliasesAffected = work.getPathToAliases().get(path);
        if (aliasesAffected != null && aliasesAffected.size() > 0) {
            candidates.put(path, aliasesAffected);
        }
    }
    for (Entry<String, ArrayList<String>> entry : candidates.entrySet()) {
        processAlias(work, entry.getKey(), entry.getValue(), aliases);
    }
}

From source file:com.mozilla.telemetry.pig.eval.json.ValidateTelemetrySubmission.java

@SuppressWarnings("unchecked")
protected String validateTelemetryJson(String json) {
    try {//from  www. j  a  v a  2s.  c om
        Map<String, Object> jsonMap = jsonMapper.readValue(json, new TypeReference<Map<String, Object>>() {
        });
        String appVersion = getAppVersionFromTelemetryDoc(jsonMap);
        Map<String, Object> info = (Map<String, Object>) jsonMap.get(TelemetryConstants.INFO);
        if (info == null) {
            info = new LinkedHashMap<String, Object>();
            jsonMap.put(TelemetryConstants.INFO, info);
        }

        if (appVersion == null) {
            LOG.info("appVersion is null");
            info.put(TelemetryConstants.VALID_FOR_SCHEMA, "false");
            return jsonMapper.writeValueAsString(jsonMap);
        }

        Map<String, Map<String, Object>> referenceValues = getJsonSpec(appVersion);
        if (referenceValues == null) {
            LOG.info("referenceValues is null " + appVersion);
        }
        pigCounterHelper.incrCounter(ReportStats.SUBMISSIONS_EVALUATED, 1L);

        Map<String, Object> histograms = (Map<String, Object>) jsonMap.get(TelemetryConstants.HISTOGRAMS);
        if (histograms == null) {
            info.put(TelemetryConstants.VALID_FOR_SCHEMA, "false");
            return jsonMapper.writeValueAsString(jsonMap);
        }
        boolean validForSchema = true;
        for (Map.Entry<String, Object> entry : histograms.entrySet()) {
            String jKey = entry.getKey();
            String min = new String();
            String max = new String();
            String histogramType = new String();
            String bucketCount = new String();
            boolean validHistogram = true;
            Map<String, Object> bucketValues = new LinkedHashMap<String, Object>();
            LinkedHashMap<String, Object> histogramValues = (LinkedHashMap<String, Object>) entry.getValue();

            for (Map.Entry<String, Object> histogramValue : histogramValues.entrySet()) {
                try {
                    if (StringUtils.equals(histogramValue.getKey(), TelemetryConstants.RANGE)) {
                        List<Integer> range = (List<Integer>) histogramValue.getValue();
                        min = String.valueOf(range.get(0));
                        max = String.valueOf(range.get(1));
                    } else if (StringUtils.equals(histogramValue.getKey(), TelemetryConstants.HISTOGRAM_TYPE)) {
                        histogramType = String.valueOf(histogramValue.getValue());
                    } else if (StringUtils.equals(histogramValue.getKey(), TelemetryConstants.BUCKET_COUNT)) {
                        bucketCount = String.valueOf(histogramValue.getValue());
                    } else if (StringUtils.equals(histogramValue.getKey(), TelemetryConstants.VALUES)) {
                        bucketValues = (Map<String, Object>) histogramValue.getValue();
                    }
                } catch (Exception e) {
                    LOG.error(histogramValue, e);
                }
            }

            if (referenceValues.containsKey(jKey)) {
                pigCounterHelper.incrCounter(ReportStats.KNOWN_HISTOGRAMS, 1L);
                Map<String, Object> referenceHistograms = referenceValues.get(jKey);
                String referenceHistogramType = (String) referenceHistograms
                        .get(TelemetryConstants.HISTOGRAM_TYPE);

                if (!StringUtils.equals(referenceHistogramType, histogramType)) {
                    validHistogram = false;
                    pigCounterHelper.incrCounter(ReportStats.INVALID_HISTOGRAM_TYPE, 1L);
                }
                if (!StringUtils.equals((String) referenceHistograms.get(TelemetryConstants.MIN), min)) {
                    validHistogram = false;
                    pigCounterHelper.incrCounter(ReportStats.INVALID_HISTOGRAM_MIN, 1L);
                }
                if (!StringUtils.equals((String) referenceHistograms.get(TelemetryConstants.MAX), max)) {
                    validHistogram = false;
                    pigCounterHelper.incrCounter(ReportStats.INVALID_HISTOGRAM_MAX, 1L);
                }
                if (!StringUtils.equals((String) referenceHistograms.get(TelemetryConstants.BUCKET_COUNT),
                        bucketCount)) {
                    validHistogram = false;
                    pigCounterHelper.incrCounter(ReportStats.INVALID_HISTOGRAM_BUCKET_COUNT, 1L);
                }
                if (bucketValues == null || bucketValues.size() <= 0) {
                    pigCounterHelper.incrCounter(ReportStats.NO_HISTOGRAM_BUCKET_VALUES, 1L);
                    validHistogram = false;
                } else {
                    LinkedHashMap<String, Integer> invalidValues = new LinkedHashMap<String, Integer>();
                    List<Integer> referenceBucketValues = (List<Integer>) referenceHistograms
                            .get(TelemetryConstants.BUCKETS);
                    for (Map.Entry<String, Object> bucketValue : bucketValues.entrySet()) {
                        int bucketKey = -1;
                        try {
                            bucketKey = Integer.parseInt(bucketValue.getKey());
                        } catch (Exception e) {
                            bucketKey = -1;
                        }
                        if (!referenceBucketValues.contains(bucketKey)) {
                            invalidValues.put(TelemetryConstants.VALUES, bucketKey);
                        }
                    }

                    if (invalidValues.size() > 0) {
                        pigCounterHelper.incrCounter(ReportStats.INVALID_HISTOGRAM_BUCKET_VALUE, 1L);
                        validHistogram = false;
                    }
                    invalidValues = null;
                }

                if (validHistogram) {
                    histogramValues.put(TelemetryConstants.VALID, "true");
                    pigCounterHelper.incrCounter(ReportStats.VALID_HISTOGRAM, 1L);
                } else {
                    validForSchema = false;
                    histogramValues.put(TelemetryConstants.VALID, "false");
                    pigCounterHelper.incrCounter(ReportStats.INVALID_HISTOGRAM, 1L);
                }

            } else {
                pigCounterHelper.incrCounter(ReportStats.UNKNOWN_HISTOGRAMS, 1L);
            }
        }
        if (validForSchema) {
            info.put(TelemetryConstants.VALID_FOR_SCHEMA, "true");
        } else {
            info.put(TelemetryConstants.VALID_FOR_SCHEMA, "false");
        }
        return jsonMapper.writeValueAsString(jsonMap);
    } catch (JsonParseException e) {
        LOG.info("ERROR: failed to process telemetry spec jsons " + e.getMessage());
        pigCounterHelper.incrCounter(ReportStats.INVALID_JSON_STRUCTURE, 1L);
    } catch (JsonMappingException e) {
        LOG.info("ERROR: failed to process telemetry spec jsons " + e.getMessage());
        pigCounterHelper.incrCounter(ReportStats.INVALID_JSON_STRUCTURE, 1L);
    } catch (IOException e) {
        LOG.info("ERROR: failed to process telemetry spec jsons " + e.getMessage());
    }
    return null;
}

From source file:rb.app.RBnSCMCSystem.java

private List<Integer> getSorted_CJ_Indices(Vector<Parameter> C_J) {

    int J = C_J.size();

    LinkedHashMap<Double, Integer> dist_from_mu = new LinkedHashMap<Double, Integer>(J);

    for (int j = 0; j < J; j++) {
        double dist = param_dist(get_current_parameters(), C_J.get(j));
        dist_from_mu.put(dist, j);/* ww w  . ja v a 2  s.  c  om*/
    }

    List<Map.Entry<Double, Integer>> list = new LinkedList<Map.Entry<Double, Integer>>(dist_from_mu.entrySet());
    Collections.sort(list, new Comparator() {
        public int compare(Object o1, Object o2) {
            return ((Comparable) ((Map.Entry) (o1)).getKey()).compareTo(((Map.Entry) (o2)).getKey());
        }
    });

    // Create a sorted list of values to return
    List<Integer> result = new LinkedList<Integer>();
    for (Iterator it = list.iterator(); it.hasNext();) {
        Map.Entry<Double, Integer> entry = (Map.Entry<Double, Integer>) it.next();
        result.add(entry.getValue());
    }

    return result;
}

From source file:com.sillelien.dollar.api.types.DollarMap.java

@NotNull
@Override/*from   w ww .j a va2s . c  o m*/
public var $insert(@NotNull var value, int position) {
    final LinkedHashMap<var, var> newMap = new LinkedHashMap<>();
    int count = 0;
    for (Map.Entry<var, var> entry : newMap.entrySet()) {
        if (count == position) {
            newMap.put(value.$pairKey(), value.$pairValue());
        }
        newMap.put(entry.getKey(), entry.getValue());

    }
    newMap.putAll(toVarMap().mutable());
    return DollarFactory.fromValue(newMap, errors(), value.errors());
}

From source file:org.apache.jmeter.protocol.http.visualizers.RequestViewHTTP.java

@Override
public void setSamplerResult(Object objectResult) {

    this.searchTextExtension.resetTextToFind();
    if (objectResult instanceof HTTPSampleResult) {
        HTTPSampleResult sampleResult = (HTTPSampleResult) objectResult;

        // Display with same order HTTP protocol
        requestModel.addRow(new RowResult(JMeterUtils.getResString("view_results_table_request_http_method"), //$NON-NLS-1$
                sampleResult.getHTTPMethod()));

        // Parsed request headers
        LinkedHashMap<String, String> lhm = JMeterUtils.parseHeaders(sampleResult.getRequestHeaders());
        for (Entry<String, String> entry : lhm.entrySet()) {
            headersModel.addRow(new RowResult(entry.getKey(), entry.getValue()));
        }//from w  w  w.  java 2s  .  c o  m

        URL hUrl = sampleResult.getURL();
        if (hUrl != null) { // can be null - e.g. if URL was invalid
            requestModel
                    .addRow(new RowResult(JMeterUtils.getResString("view_results_table_request_http_protocol"), //$NON-NLS-1$
                            hUrl.getProtocol()));
            requestModel.addRow(new RowResult(JMeterUtils.getResString("view_results_table_request_http_host"), //$NON-NLS-1$
                    hUrl.getHost()));
            int port = hUrl.getPort() == -1 ? hUrl.getDefaultPort() : hUrl.getPort();
            requestModel.addRow(new RowResult(JMeterUtils.getResString("view_results_table_request_http_port"), //$NON-NLS-1$
                    Integer.valueOf(port)));
            requestModel.addRow(new RowResult(JMeterUtils.getResString("view_results_table_request_http_path"), //$NON-NLS-1$
                    hUrl.getPath()));

            String queryGet = hUrl.getQuery() == null ? "" : hUrl.getQuery(); //$NON-NLS-1$
            boolean isMultipart = isMultipart(lhm);

            // Concatenate query post if exists
            String queryPost = sampleResult.getQueryString();
            if (!isMultipart && StringUtils.isNotBlank(queryPost)) {
                if (queryGet.length() > 0) {
                    queryGet += PARAM_CONCATENATE;
                }
                queryGet += queryPost;
            }

            if (StringUtils.isNotBlank(queryGet)) {
                Set<Entry<String, String[]>> keys = RequestViewHTTP.getQueryMap(queryGet).entrySet();
                for (Entry<String, String[]> entry : keys) {
                    for (String value : entry.getValue()) {
                        paramsModel.addRow(new RowResult(entry.getKey(), value));
                    }
                }
            }

            if (isMultipart && StringUtils.isNotBlank(queryPost)) {
                String contentType = lhm.get(HTTPConstants.HEADER_CONTENT_TYPE);
                String boundaryString = extractBoundary(contentType);
                MultipartUrlConfig urlconfig = new MultipartUrlConfig(boundaryString);
                urlconfig.parseArguments(queryPost);

                for (JMeterProperty prop : urlconfig.getArguments()) {
                    Argument arg = (Argument) prop.getObjectValue();
                    paramsModel.addRow(new RowResult(arg.getName(), arg.getValue()));
                }
            }
        }

        // Display cookie in headers table (same location on http protocol)
        String cookie = sampleResult.getCookies();
        if (cookie != null && cookie.length() > 0) {
            headersModel
                    .addRow(new RowResult(JMeterUtils.getParsedLabel("view_results_table_request_http_cookie"), //$NON-NLS-1$
                            sampleResult.getCookies()));
        }

    } else {
        // add a message when no http sample
        requestModel.addRow(new RowResult("", //$NON-NLS-1$
                JMeterUtils.getResString("view_results_table_request_http_nohttp"))); //$NON-NLS-1$
    }
}