Example usage for java.util LinkedHashMap values

List of usage examples for java.util LinkedHashMap values

Introduction

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

Prototype

public Collection<V> values() 

Source Link

Document

Returns a Collection view of the values contained in this map.

Usage

From source file:controller.ViewPackageController.java

@RequestMapping(value = "/createOrder", method = RequestMethod.GET)
public String createOrder(HttpServletRequest req, ModelMap mm, Authentication authen) {
    try {/*from   w  w w. ja v a  2s. c o m*/
        LinkedHashMap<OderDetail, Requirement> orderSession = null;
        orderSession = (LinkedHashMap<OderDetail, Requirement>) req.getSession().getAttribute("orderSession");
        if (orderSession == null) {
            mm.put("msg", "No Package choosed");
            return "createOrder";
        } else {
            Set<OderDetail> listOrderDetail = new HashSet<>();
            Set<Requirement> listRequirement = new HashSet<>();
            listOrderDetail = orderSession.keySet();
            for (Requirement rq : orderSession.values()) {
                if (rq != null) {
                    listRequirement.add(rq);
                }
            }
            Customer customer = cusModel.find(authen.getName(), "username", false).get(0);
            customer.setRequirements(listRequirement);
            Calendar c = Calendar.getInstance();
            c.add(Calendar.MONTH, 1);
            Order order = null;
            int orderID = orderModel.getOrderIDByCustomerNonActive(customer.getCustomerId());
            if (orderID == 0) {
                order = new Order(customer, new Date(), c.getTime(), Byte.valueOf("0"), null);
                orderModel.addOrUpdate(order);
            } else {
                order = orderModel.getByID(orderID);
            }
            Set<OderDetail> listDetailTmp = order.getOderDetails();
            for (OderDetail od : listOrderDetail) {
                od.setId(new OderDetailId(order.getOderId(), od.getPackages().getPackageId()));
                for (OderDetail tmp : listDetailTmp) {
                    if (od.getPackages().getPackageId() == tmp.getPackages().getPackageId()) {
                        od.setQuantity(od.getQuantity() + 1);
                        break;
                    }
                }
            }
            order.setOderDetails(listOrderDetail);

            orderModel.addOrUpdate(order);
            cusModel.addOrUpdate(customer);

            req.getSession().setAttribute("orderSession", null);
            mm.put("msg", "Order Created");
        }
    } catch (Exception ex) {
        mm.put("msg", ex.getMessage());
    }
    return "createOrder";
}

From source file:com.att.aro.ui.view.diagnostictab.plot.DLPacketPlot.java

@Override
public void populate(XYPlot plot, AROTraceData analysis) {

    LinkedHashMap<Color, PacketSeries> dlDatasets = new LinkedHashMap<Color, PacketSeries>();

    AnalysisFilter filter = null;//  w  w  w  .  j  a v a  2 s  .  co  m
    //      logger.info("isDownloadPacket(): "+ isDownloadPacket());
    if (analysis != null) {
        filter = analysis.getAnalyzerResult().getFilter();
        for (Session session : analysis.getAnalyzerResult().getSessionlist()) {
            addSeries(session, dlDatasets, filter);
        }
    }
    // Create the XY data set
    YIntervalSeriesCollection coll = new YIntervalSeriesCollection();
    XYItemRenderer renderer = plot.getRenderer();
    for (PacketSeries series : dlDatasets.values()) {
        coll.addSeries(series);
        renderer.setSeriesPaint(coll.indexOf(series.getKey()), series.getColor());
    }

    // Create tooltip generator
    renderer.setBaseToolTipGenerator(new PacketToolTipGenerator());

    plot.setDataset(coll);

    //      return plot;
}

From source file:be.ugent.maf.cellmissy.gui.controller.analysis.doseresponse.area.AreaDRInputController.java

/**
 * Table model for bottom table: starts from analysis group.
 *
 * @param analysisGroup/*from w  w w  . j  a  v  a  2  s  .c  om*/
 * @return
 */
private NonEditableTableModel createTableModel(AreaDoseResponseAnalysisGroup analysisGroup) {
    LinkedHashMap<Double, String> concentrationsMap = analysisGroup.getConcentrationsMap()
            .get(analysisGroup.getTreatmentToAnalyse());
    LinkedHashMap<PlateCondition, List<Double>> velocitiesMap = analysisGroup.getVelocitiesMap();
    //when removing all conditions
    if (velocitiesMap.isEmpty()) {
        return new NonEditableTableModel();
    }

    int maxReplicates = 0;
    for (List<Double> value : velocitiesMap.values()) {
        int replicates = value.size();
        if (replicates > maxReplicates) {
            maxReplicates = replicates;
        }
    }

    Object[][] data = new Object[velocitiesMap.size()][maxReplicates + 2];
    int i = 0;
    int controlIndex = 100;
    int rowIndex = 0;

    for (Map.Entry<PlateCondition, List<Double>> entry : velocitiesMap.entrySet()) {
        //check if this platecondition is the control, save index for table
        for (Treatment treatment : entry.getKey().getTreatmentList()) {
            if (treatment.getTreatmentType().getName().contains("ontrol")) {
                controlIndex = i;
            }
        }
        i++;

        int columnIndex = 2;
        for (Double velocity : entry.getValue()) {

            if (velocity != null && !velocity.isNaN()) {
                // round to three decimals slopes and coefficients
                Double slope = AnalysisUtils.roundThreeDecimals(velocity);
                // show in table slope + (coefficient)
                data[rowIndex][columnIndex] = slope;
            } else if (velocity == null) {
                data[rowIndex][columnIndex] = "excluded";
            } else if (velocity.isNaN()) {
                data[rowIndex][columnIndex] = "NaN";
            }

            columnIndex++;
        }
        rowIndex++;
    }

    if (controlIndex != 100) {
        data[controlIndex][0] = 0.0;
        data[controlIndex][1] = "--";
    }
    rowIndex = 0;
    //if user only selects control, the concentrationsmap is null
    if (concentrationsMap != null) {
        for (Map.Entry<Double, String> entry : concentrationsMap.entrySet()) {
            if (rowIndex >= controlIndex) {
                data[rowIndex + 1][0] = entry.getKey();
                data[rowIndex + 1][1] = entry.getValue();
            } else {
                data[rowIndex][0] = entry.getKey();
                data[rowIndex][1] = entry.getValue();
            }

            rowIndex++;
        }
    }
    // array of column names for table model
    String[] columnNames = new String[data[0].length];
    columnNames[0] = "Conc of " + analysisGroup.getTreatmentToAnalyse();
    columnNames[1] = "Unit";
    for (int x = 2; x < columnNames.length; x++) {
        columnNames[x] = "Repl " + (x - 1);
    }

    NonEditableTableModel nonEditableTableModel = new NonEditableTableModel();
    nonEditableTableModel.setDataVector(data, columnNames);
    return nonEditableTableModel;

}

From source file:org.eclipse.recommenders.utils.rcp.JdtUtils.java

/**
 * Returns a list of all public instance methods and fields declared in the given type or any of its super-types
 *//* ww  w. ja v  a 2  s  .c om*/
public static Collection<IMember> findAllPublicInstanceFieldsAndNonVoidNonPrimitiveInstanceMethods(
        final IType type) {
    final LinkedHashMap<String, IMember> tmp = new LinkedHashMap<String, IMember>();

    try {
        final IType[] returnTypeAndSupertypes = findAllSupertypesIncludeingArgument(type);
        for (final IType cur : returnTypeAndSupertypes) {
            for (final IMethod m : cur.getMethods()) {
                if (isVoid(m) || !isPublic(m) || m.isConstructor() || isStatic(m)
                        || hasPrimitiveReturnType(m)) {
                    continue;
                }
                final String key = createMethodKey(m);
                if (!tmp.containsKey(key)) {
                    tmp.put(key, m);
                }
            }
            for (final IField field : cur.getFields()) {
                if (!isPublic(field) || isStatic(field)) {
                    continue;
                }
                final String key = createFieldKey(field);
                if (!tmp.containsKey(key)) {
                    tmp.put(key, field);
                }
            }
        }
    } catch (final Exception e) {
        log(e);
    }
    return tmp.values();
}

From source file:com.perceptive.epm.perkolcentral.action.ajax.EmployeeDetailsAction.java

public String executeGetAllEmployees() throws ExceptionWrapper {
    try {// www  .j a v  a 2 s  .co  m
        Soundex sndx = new Soundex();
        DoubleMetaphone doubleMetaphone = new DoubleMetaphone();
        final StringEncoderComparator comparator1 = new StringEncoderComparator(doubleMetaphone);

        LoggingHelpUtil.printDebug("Page " + getPage() + " Rows " + getRows() + " Sorting Order " + getSord()
                + " Index Row :" + getSidx());
        LoggingHelpUtil.printDebug("Search :" + searchField + " " + searchOper + " " + searchString);

        // Calcalate until rows ware selected
        int to = (rows * page);

        // Calculate the first row to read
        int from = to - rows;
        LinkedHashMap<Long, EmployeeBO> employeeLinkedHashMap = new LinkedHashMap<Long, EmployeeBO>();

        employeeLinkedHashMap = employeeBL.getAllEmployees();
        ArrayList<EmployeeBO> allEmployees = new ArrayList<EmployeeBO>(employeeLinkedHashMap.values());
        //Handle search
        if (searchOper != null && !searchOper.trim().equalsIgnoreCase("") && searchString != null
                && !searchString.trim().equalsIgnoreCase("")) {
            if (searchOper.trim().equalsIgnoreCase("eq")) {
                CollectionUtils.filter(allEmployees, new Predicate() {
                    @Override
                    public boolean evaluate(Object o) {
                        return ((EmployeeBO) o).getEmployeeName().equalsIgnoreCase(searchString.trim()); //To change body of implemented methods use File | Settings | File Templates.
                    }
                });
            } else if (searchOper.trim().equalsIgnoreCase("slk")) {
                CollectionUtils.filter(allEmployees, new Predicate() {
                    @Override
                    public boolean evaluate(Object o) {
                        return (new StringEncoderComparator(new Soundex()).compare(
                                ((EmployeeBO) o).getEmployeeName().toLowerCase(),
                                searchString.trim().toLowerCase()) == 0
                                || new StringEncoderComparator(new DoubleMetaphone()).compare(
                                        ((EmployeeBO) o).getEmployeeName().toLowerCase(),
                                        searchString.trim().toLowerCase()) == 0
                                || new StringEncoderComparator(new Metaphone()).compare(
                                        ((EmployeeBO) o).getEmployeeName().toLowerCase(),
                                        searchString.trim().toLowerCase()) == 0
                                || new StringEncoderComparator(new RefinedSoundex()).compare(
                                        ((EmployeeBO) o).getEmployeeName().toLowerCase(),
                                        searchString.trim().toLowerCase()) == 0); //To change body of implemented methods use File | Settings | File Templates.
                    }
                });
            } else {
                //First check whether there is an exact match
                if (CollectionUtils.exists(allEmployees, new Predicate() {
                    @Override
                    public boolean evaluate(Object o) {
                        return (((EmployeeBO) o).getEmployeeName().toLowerCase()
                                .contains(searchString.trim().toLowerCase())); //To change body of implemented methods use File | Settings | File Templates.
                    }
                })) {
                    CollectionUtils.filter(allEmployees, new Predicate() {
                        @Override
                        public boolean evaluate(Object o) {
                            return (((EmployeeBO) o).getEmployeeName().toLowerCase()
                                    .contains(searchString.trim().toLowerCase()));
                        }
                    });
                } else {
                    ArrayList<String> matchedEmployeeIds = employeeBL.getLuceneUtil()
                            .getBestMatchEmployeeName(searchString.trim().toLowerCase());
                    allEmployees = new ArrayList<EmployeeBO>();
                    for (String id : matchedEmployeeIds) {
                        allEmployees.add(employeeBL.getAllEmployees().get(Long.valueOf(id)));
                    }
                }
            }

            /*{
            CollectionUtils.filter(allEmployees, new Predicate() {
                @Override
                public boolean evaluate(Object o) {
                    if (((EmployeeBO) o).getEmployeeName().toLowerCase().contains(searchString.trim().toLowerCase()))
                        return true;
                    else if(new StringEncoderComparator(new Soundex()).compare(((EmployeeBO) o).getEmployeeName().toLowerCase(), searchString.trim().toLowerCase()) == 0
                            || new StringEncoderComparator(new DoubleMetaphone()).compare(((EmployeeBO) o).getEmployeeName().toLowerCase(), searchString.trim().toLowerCase()) == 0)
                    {
                        return true;
                    }
                    else {
                        for (String empNameParts : ((EmployeeBO) o).getEmployeeName().trim().split(" ")) {
                            if (new StringEncoderComparator(new Soundex()).compare(empNameParts.toLowerCase(), searchString.trim().toLowerCase()) == 0
                                    || new StringEncoderComparator(new DoubleMetaphone()).compare(empNameParts.toLowerCase(), searchString.trim().toLowerCase()) == 0
                                //    || new StringEncoderComparator(new Metaphone()).compare(empNameParts.toLowerCase(), searchString.trim().toLowerCase()) == 0
                                //    || new StringEncoderComparator(new RefinedSoundex()).compare(empNameParts.toLowerCase(), searchString.trim().toLowerCase()) == 0
                                    ) {
                                return true;
                            }
                        }
                        return false;
                    }
                    
                    
                }
            });
            } */
        }
        //// Handle Order By
        if (sidx != null && !sidx.equals("")) {

            Collections.sort(allEmployees, new Comparator<EmployeeBO>() {
                public int compare(EmployeeBO e1, EmployeeBO e2) {
                    if (sidx.equalsIgnoreCase("employeeName"))
                        return sord.equalsIgnoreCase("asc")
                                ? e1.getEmployeeName().compareTo(e2.getEmployeeName())
                                : e2.getEmployeeName().compareTo(e1.getEmployeeName());
                    else if (sidx.equalsIgnoreCase("jobTitle"))
                        return sord.equalsIgnoreCase("asc") ? e1.getJobTitle().compareTo(e2.getJobTitle())
                                : e2.getJobTitle().compareTo(e1.getJobTitle());
                    else if (sidx.equalsIgnoreCase("manager"))
                        return sord.equalsIgnoreCase("asc") ? e1.getManager().compareTo(e2.getManager())
                                : e2.getManager().compareTo(e1.getManager());
                    else
                        return sord.equalsIgnoreCase("asc")
                                ? e1.getEmployeeName().compareTo(e2.getEmployeeName())
                                : e2.getEmployeeName().compareTo(e1.getEmployeeName());
                }
            });

        }
        //

        records = allEmployees.size();
        total = (int) Math.ceil((double) records / (double) rows);

        gridModel = new ArrayList<EmployeeBO>();
        to = to > records ? records : to;
        for (int iCounter = from; iCounter < to; iCounter++) {
            EmployeeBO employeeBO = allEmployees.get(iCounter);
            //new EmployeeBO((Employee) employeeLinkedHashMap.values().toArray()[iCounter]);
            gridModel.add(employeeBO);
        }

    } catch (Exception ex) {
        throw new ExceptionWrapper(ex);

    }
    return SUCCESS;
}

From source file:org.apache.hadoop.hive.ql.hooks.LineageLogger.java

/**
 * Based on the final select operator, find out all the target columns.
 * For each target column, find out its sources based on the dependency index.
 *///  w w  w.java2 s  .  com
private List<Edge> getEdges(QueryPlan plan, Index index) {
    LinkedHashMap<String, ObjectPair<SelectOperator, org.apache.hadoop.hive.ql.metadata.Table>> finalSelOps = index
            .getFinalSelectOps();
    Map<String, Vertex> vertexCache = new LinkedHashMap<String, Vertex>();
    List<Edge> edges = new ArrayList<Edge>();
    for (ObjectPair<SelectOperator, org.apache.hadoop.hive.ql.metadata.Table> pair : finalSelOps.values()) {
        List<FieldSchema> fieldSchemas = plan.getResultSchema().getFieldSchemas();
        SelectOperator finalSelOp = pair.getFirst();
        org.apache.hadoop.hive.ql.metadata.Table t = pair.getSecond();
        String destTableName = null;
        List<String> colNames = null;
        if (t != null) {
            destTableName = t.getDbName() + "." + t.getTableName();
            fieldSchemas = t.getCols();
        } else {
            // Based on the plan outputs, find out the target table name and column names.
            for (WriteEntity output : plan.getOutputs()) {
                Entity.Type entityType = output.getType();
                if (entityType == Entity.Type.TABLE || entityType == Entity.Type.PARTITION) {
                    t = output.getTable();
                    destTableName = t.getDbName() + "." + t.getTableName();
                    List<FieldSchema> cols = t.getCols();
                    if (cols != null && !cols.isEmpty()) {
                        colNames = Utilities.getColumnNamesFromFieldSchema(cols);
                    }
                    break;
                }
            }
        }
        Map<ColumnInfo, Dependency> colMap = index.getDependencies(finalSelOp);
        List<Dependency> dependencies = colMap != null ? Lists.newArrayList(colMap.values()) : null;
        int fields = fieldSchemas.size();
        if (t != null && colMap != null && fields < colMap.size()) {
            // Dynamic partition keys should be added to field schemas.
            List<FieldSchema> partitionKeys = t.getPartitionKeys();
            int dynamicKeyCount = colMap.size() - fields;
            int keyOffset = partitionKeys.size() - dynamicKeyCount;
            if (keyOffset >= 0) {
                fields += dynamicKeyCount;
                for (int i = 0; i < dynamicKeyCount; i++) {
                    FieldSchema field = partitionKeys.get(keyOffset + i);
                    fieldSchemas.add(field);
                    if (colNames != null) {
                        colNames.add(field.getName());
                    }
                }
            }
        }
        if (dependencies == null || dependencies.size() != fields) {
            log("Result schema has " + fields + " fields, but we don't get as many dependencies");
        } else {
            // Go through each target column, generate the lineage edges.
            Set<Vertex> targets = new LinkedHashSet<Vertex>();
            for (int i = 0; i < fields; i++) {
                Vertex target = getOrCreateVertex(vertexCache,
                        getTargetFieldName(i, destTableName, colNames, fieldSchemas), Vertex.Type.COLUMN);
                targets.add(target);
                Dependency dep = dependencies.get(i);
                addEdge(vertexCache, edges, dep.getBaseCols(), target, dep.getExpr(), Edge.Type.PROJECTION);
            }
            Set<Predicate> conds = index.getPredicates(finalSelOp);
            if (conds != null && !conds.isEmpty()) {
                for (Predicate cond : conds) {
                    addEdge(vertexCache, edges, cond.getBaseCols(), new LinkedHashSet<Vertex>(targets),
                            cond.getExpr(), Edge.Type.PREDICATE);
                }
            }
        }
    }
    return edges;
}

From source file:com.grarak.kerneladiutor.fragments.tools.BackupFragment.java

private void showBackupFlashingDialog(final File file) {
    final LinkedHashMap<String, Backup.PARTITION> menu = getPartitionMenu();
    mBackupFlashingDialog = new Dialog(getActivity())
            .setItems(menu.keySet().toArray(new String[menu.size()]), new DialogInterface.OnClickListener() {
                @Override// w  ww  .  j  av  a 2s. c  o m
                public void onClick(DialogInterface dialogInterface, int i) {
                    Backup.PARTITION partition = menu.values().toArray(new Backup.PARTITION[menu.size()])[i];
                    if (file != null) {
                        restore(partition, file, true);
                    } else {
                        backup(partition);
                    }
                }
            }).setOnDismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public void onDismiss(DialogInterface dialogInterface) {
                    mBackupFlashingDialog = null;
                }
            });
    mBackupFlashingDialog.show();
}

From source file:com.johan.vertretungsplan.parser.UntisMonitorParser.java

public Vertretungsplan getVertretungsplan() throws IOException, JSONException {
    new LoginHandler(schule).handleLogin(executor, cookieStore, username, password); //

    JSONArray urls = schule.getData().getJSONArray("urls");
    String encoding = schule.getData().getString("encoding");
    List<Document> docs = new ArrayList<Document>();

    for (int i = 0; i < urls.length(); i++) {
        JSONObject url = urls.getJSONObject(i);
        loadUrl(url.getString("url"), encoding, url.getBoolean("following"), docs);
    }/*from w  ww  . j ava2 s . com*/

    LinkedHashMap<String, VertretungsplanTag> tage = new LinkedHashMap<String, VertretungsplanTag>();
    for (Document doc : docs) {
        if (doc.title().contains("Untis")) {
            VertretungsplanTag tag = parseMonitorVertretungsplanTag(doc, schule.getData());
            if (!tage.containsKey(tag.getDatum())) {
                tage.put(tag.getDatum(), tag);
            } else {
                VertretungsplanTag tagToMerge = tage.get(tag.getDatum());
                tagToMerge.merge(tag);
                tage.put(tag.getDatum(), tagToMerge);
            }
        } else {
            //Fehler
        }
    }
    Vertretungsplan v = new Vertretungsplan();
    v.setTage(new ArrayList<VertretungsplanTag>(tage.values()));

    return v;
}

From source file:com.google.gwt.emultest.java.util.LinkedHashMapTest.java

/**
 * Test method for 'java.util.AbstractMap.values()'.
 *//*from  w  w  w  .  j av a2 s. com*/
public void testValues() {
    LinkedHashMap<String, String> hashMap = new LinkedHashMap<String, String>();
    checkEmptyLinkedHashMapAssumptions(hashMap);

    assertNotNull(hashMap.values());

    hashMap.put(KEY_KEY, VALUE_VAL);

    Collection<String> valColl = hashMap.values();
    assertNotNull(valColl);
    assertEquals(valColl.size(), SIZE_ONE);

    Iterator<String> itVal = valColl.iterator();
    String val = itVal.next();
    assertEquals(val, VALUE_VAL);
}

From source file:com.jaspersoft.studio.data.xml.XMLDataAdapterDescriptor.java

/**
 * Returns the list of fields provided by an XML document and the related
 * query.//from w  w w  . j  a v a 2s. c  o  m
 * 
 * @param doc
 *            the W3C XML document
 * @param jConfig
 *            the JasperReports configuration instance
 * @param jDataset
 *            the current dataset
 * @return the list of fields
 * @throws JRException
 */
protected List<JRDesignField> getFieldsFromDocument(Document doc, JasperReportsConfiguration jConfig,
        JRDataset jDataset) throws JRException {
    JRXPathExecuterFactory xPathExecuterFactory = JRXPathExecuterUtils.getXPathExecuterFactory(jConfig);
    JRXPathExecuter xPathExecuter = xPathExecuterFactory.getXPathExecuter();
    NodeList nodes = xPathExecuter.selectNodeList(doc, jDataset.getQuery().getText());
    LinkedHashMap<String, JRDesignField> fieldsMap = new LinkedHashMap<String, JRDesignField>();
    for (int nIdx = 0; nIdx < nodes.getLength(); nIdx++) {
        Node currNode = nodes.item(nIdx);
        if (considerEmptyNodes || StringUtils.isNotBlank(DOMUtil.getChildText(currNode))) {
            addMainNodeField(fieldsMap, currNode);
        }
        findDirectChildrenAttributes(currNode, fieldsMap, "");
        if (currNode.getNodeType() == Node.ELEMENT_NODE) {
            NodeList childNodes = currNode.getChildNodes();
            findChildFields(childNodes, fieldsMap, "");
        }
    }
    return new ArrayList<JRDesignField>(fieldsMap.values());
}