Example usage for java.util LinkedHashMap put

List of usage examples for java.util LinkedHashMap put

Introduction

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

Prototype

V put(K key, V value);

Source Link

Document

Associates the specified value with the specified key in this map (optional operation).

Usage

From source file:com.msopentech.odatajclient.proxy.api.impl.EntitySetInvocationHandler.java

private LinkedHashMap<String, Object> getCompoundKey(final Object key) {
    final Set<CompoundKeyElementWrapper> elements = new TreeSet<CompoundKeyElementWrapper>();

    for (Method method : key.getClass().getMethods()) {
        final Annotation annotation = method.getAnnotation(CompoundKeyElement.class);
        if (annotation instanceof CompoundKeyElement) {
            elements.add(new CompoundKeyElementWrapper(((CompoundKeyElement) annotation).name(), method,
                    ((CompoundKeyElement) annotation).position()));
        }/*  w  w  w.j  ava  2s  .c  o  m*/
    }

    final LinkedHashMap<String, Object> map = new LinkedHashMap<String, Object>();

    for (CompoundKeyElementWrapper element : elements) {
        try {
            map.put(element.getName(), element.getMethod().invoke(key));
        } catch (Exception e) {
            LOG.warn("Error retrieving compound key element '{}' value", element.getName(), e);
        }
    }

    return map;
}

From source file:de.helmholtz_muenchen.ibis.ngs.mats.MatsNodeModel.java

@Override
protected LinkedHashMap<String, String> getGUIParameters(final BufferedDataTable[] inData) {
    LinkedHashMap<String, String> pars = new LinkedHashMap<String, String>();

    /********************* SIMPLE PARAMETER ***************************/
    if (SET_ANALYSIS_TYPE.getBooleanValue())
        pars.put(NAME_OF_PAIRED_ANALYSIS, "P");
    else//from w w w.j  av  a2  s.  c o  m
        pars.put(NAME_OF_PAIRED_ANALYSIS, "U");
    if (SET_READ_LENGTH.getIntValue() > 1)
        pars.put(NAME_OF_READ_LENGTH, Integer.toString(SET_READ_LENGTH.getIntValue()));

    pars.put(NAME_OF_ANNOTATION_FILE, SET_ANNOTATION_FILE.getStringValue());
    pars.put(NAME_OF_CUTOFF_DIFFERENCE,
            Double.toString(Math.min(SET_CUTOFF_DIFFERENCE.getDoubleValue(), VALID_FOLDCHANGE_CUTOFF)));
    pars.put(NAME_OF_EXPRESSION_CHANGE, Double.toString(SET_EXPRESSION_CHANGE.getDoubleValue()));

    /********************* OUTPUT ****************************/
    String outputFolderArgument = SET_OUTPUT_FOLDER.getStringValue();
    File outDir = new File(outputFolderArgument).getParentFile();
    // create folder, if not already there
    if (!outDir.isDirectory())
        outDir.mkdir();

    pars.put(NAME_OF_OUTPUT_FOLDER, outputFolderArgument);

    /********************** INPUT BAM SETTINGS OF CONDITION 1 ****************************/
    ArrayList<String> bamArgument = new ArrayList<String>();
    ArrayList<String> insertArgument = new ArrayList<String>();
    ArrayList<String> standardDevArgument = new ArrayList<String>();

    // get input parameter from BAM/SAM selector
    for (Iterator<DataRow> it = inData[0].iterator(); it.hasNext();) {
        DataRow row = it.next();
        bamArgument.add(row.getCell(0).toString());
        insertArgument.add(row.getCell(1).toString());
        standardDevArgument.add(row.getCell(2).toString());
    }

    // add the input parameter
    pars.put(NAME_OF_BAM1, StringUtils.join(bamArgument, ","));
    pars.put(NAME_OF_INSERT_SIZE1, StringUtils.join(insertArgument, ","));
    pars.put(NAME_OF_STANDARD_DEV1, StringUtils.join(standardDevArgument, ","));

    /********************** INPUT BAM SETTINGS OF CONDITION 1 ****************************/
    bamArgument.clear();
    insertArgument.clear();
    standardDevArgument.clear();

    // get input parameter from BAM/SAM selector
    for (Iterator<DataRow> it = inData[1].iterator(); it.hasNext();) {
        DataRow row = it.next();
        bamArgument.add(row.getCell(0).toString());
        insertArgument.add(row.getCell(1).toString());
        standardDevArgument.add(row.getCell(2).toString());
    }

    // add the input parameter
    pars.put(NAME_OF_BAM2, StringUtils.join(bamArgument, ","));
    pars.put(NAME_OF_INSERT_SIZE2, StringUtils.join(insertArgument, ","));
    pars.put(NAME_OF_STANDARD_DEV2, StringUtils.join(standardDevArgument, ","));

    // return the GUI parameter
    return pars;
}

From source file:com.liferay.portal.editor.fckeditor.receiver.impl.BaseCommandReceiver.java

protected void getRootFolders(CommandArgument commandArgument, Document document, Element foldersElement)
        throws Exception {

    LinkedHashMap<String, Object> groupParams = new LinkedHashMap<String, Object>();

    groupParams.put("usersGroups", new Long(commandArgument.getUserId()));

    List<Group> groups = GroupLocalServiceUtil.search(commandArgument.getCompanyId(), null, null, groupParams,
            QueryUtil.ALL_POS, QueryUtil.ALL_POS);

    List<Organization> userOrgs = OrganizationLocalServiceUtil
            .getUserOrganizations(commandArgument.getUserId());

    for (Organization organization : userOrgs) {
        groups.add(0, organization.getGroup());
    }/*from ww w  . j  av a2  s. c  om*/

    if (PropsValues.LAYOUT_USER_PRIVATE_LAYOUTS_ENABLED || PropsValues.LAYOUT_USER_PUBLIC_LAYOUTS_ENABLED) {

        Group userGroup = GroupLocalServiceUtil.getUserGroup(commandArgument.getCompanyId(),
                commandArgument.getUserId());

        groups.add(0, userGroup);
    }

    Group companyGroup = GroupLocalServiceUtil.getCompanyGroup(commandArgument.getCompanyId());

    groups.add(0, companyGroup);

    ThemeDisplay themeDisplay = commandArgument.getThemeDisplay();

    long scopeGroupId = themeDisplay.getScopeGroupId();

    HttpServletRequest request = commandArgument.getHttpServletRequest();

    String portletId = ParamUtil.getString(request, "p_p_id");

    for (Group group : groups) {
        Element folderElement = document.createElement("Folder");

        foldersElement.appendChild(folderElement);

        boolean setNameAttribute = false;

        if (group.hasStagingGroup()) {
            Group stagingGroup = group.getStagingGroup();

            if ((stagingGroup.getGroupId() == scopeGroupId) && group.isStagedPortlet(portletId)
                    && !group.isStagedRemotely() && isStagedData(group)) {

                folderElement.setAttribute("name",
                        stagingGroup.getGroupId() + " - " + HtmlUtil.escape(stagingGroup.getDescriptiveName()));

                setNameAttribute = true;
            }
        }

        if (!setNameAttribute) {
            folderElement.setAttribute("name",
                    group.getGroupId() + " - " + HtmlUtil.escape(group.getDescriptiveName()));
        }
    }
}

From source file:com.act.lcms.db.analysis.ChemicalToMapOfMetlinIonsToIntensityTimeValues.java

/**
 * This function plots the positive ion and negative control ions for a given metlin ion mass per plot.
 * @param searchMz - The mz value which is used for finding spectra.
 * @param plottingDirectory - The directory where the plots will live.
 * @param positiveChemical - The positive chemical is used to make sure it is placed at the top of the spectra plot.
 * @return This function returns a map of ion to absolute paths where the plot lives.
 * @throws IOException//from   w w  w  .  j  a v  a2  s .com
 */
public Map<String, String> plotPositiveAndNegativeControlsForEachMetlinIon(Pair<String, Double> searchMz,
        String plottingDirectory, String positiveChemical, List<StandardWell> standardWells)
        throws IOException {
    Map<String, String> ionToPlottingFilePath = new HashMap<>();
    Map<String, Double> individualMaxIntensities = new HashMap<>();
    WriteAndPlotMS1Results plottingUtil = new WriteAndPlotMS1Results();

    //rearrange the order of plotting
    ArrayList<String> orderedPlotChemicalTitles = new ArrayList<>(this.peakData.keySet().size());
    for (String chemical : peakData.keySet()) {
        if (chemical.equals(positiveChemical)) {
            orderedPlotChemicalTitles.add(0, chemical);
        } else {
            orderedPlotChemicalTitles.add(chemical);
        }
    }

    // This variable is used as a part of the file path dir to uniquely identify the pos/neg wells for the chemical.
    StringBuilder indexedPath = new StringBuilder();
    for (StandardWell well : standardWells) {
        indexedPath.append(Integer.toString(well.getId()) + "-");
    }

    for (String ion : this.peakData.get(searchMz.getLeft()).keySet()) {
        LinkedHashMap<String, List<XZ>> ms1s = new LinkedHashMap<>();
        Map<String, Double> metlinMasses = new HashMap<>();
        Double maxIntensity = 0.0d;

        for (String chemical : orderedPlotChemicalTitles) {
            List<XZ> ionValues = this.peakData.get(chemical).get(ion);
            ms1s.put(chemical, ionValues);
            Double localMaxIntensity = findPeakMaxIntensity(ionValues);
            maxIntensity = Math.max(maxIntensity, localMaxIntensity);
            individualMaxIntensities.put(chemical, localMaxIntensity);
            metlinMasses.put(chemical, searchMz.getValue());
        }

        String relativePath = searchMz.getLeft() + "_" + indexedPath.toString() + "_" + ion;

        File absolutePathFileWithoutExtension = new File(plottingDirectory, relativePath);
        String absolutePathWithoutExtension = absolutePathFileWithoutExtension.getAbsolutePath();

        plottingUtil.plotSpectra(ms1s, maxIntensity, individualMaxIntensities, metlinMasses,
                absolutePathWithoutExtension, this.FMT, false, false);
        ionToPlottingFilePath.put(ion, relativePath + "." + this.FMT);
    }

    return ionToPlottingFilePath;
}

From source file:com.seajas.search.profiler.service.task.TaskService.java

/**
 * Retrieve the list of scheduled jobs./*from  ww w . j ava2s  .c om*/
 * 
 * @return Map<String, Map<String, TreeString>>
 */
public Map<String, LinkedHashMap<String, String>> getSchedulerJobs() {
    Map<String, LinkedHashMap<String, String>> schedulerJobs = new LinkedHashMap<String, LinkedHashMap<String, String>>();

    // Make sure these are added in order

    schedulerJobs.put(JOB_FEED_INJECTION, new LinkedHashMap<String, String>());
    schedulerJobs.put(JOB_ARCHIVE_INJECTION, new LinkedHashMap<String, String>());

    for (Entry<String, String> feedInjectionTrigger : feedInjectionTriggers.entrySet()) {
        schedulerJobs.get(JOB_FEED_INJECTION).put(feedInjectionTrigger.getKey(), "inactive");
    }

    for (Entry<String, String> archiveInjectionTrigger : archiveInjectionTriggers.entrySet()) {
        schedulerJobs.get(JOB_ARCHIVE_INJECTION).put(archiveInjectionTrigger.getKey(), "inactive");
    }

    // Add all others in whichever order, and update those triggers that are not inactive

    try {
        for (String groupName : taskScheduler.getJobGroupNames()) {
            if (!groupName.equals(GROUP_FEED) && !groupName.equals(GROUP_ARCHIVE))
                for (JobKey jobKey : taskScheduler.getJobKeys(GroupMatcher.jobGroupEquals(groupName))) {
                    LinkedHashMap<String, String> triggers = new LinkedHashMap<String, String>();

                    for (Trigger trigger : taskScheduler.getTriggersOfJob(jobKey))
                        triggers.put(trigger.getKey().getName(), "inactive");

                    schedulerJobs.put(jobKey.getName(), triggers);
                }

            for (JobExecutionContext jobContext : taskScheduler.getCurrentlyExecutingJobs())
                schedulerJobs.get(jobContext.getJobDetail().getKey().getName())
                        .put(jobContext.getTrigger().getKey().getName(), "active");
        }
    } catch (SchedulerException e) {
        logger.error("Could not retrieve the list of currently running jobs");
    }

    return schedulerJobs;
}

From source file:com.workday.autoparse.json.demo.InstanceUpdaterTest.java

@Test
public void testMapsFromJsonObjects() throws Exception {
    TestObject testObject = new TestObject();
    testObject.myInterfaceMap = new LinkedHashMap<>();
    testObject.myInterfaceMap.put("value", new TestObject.InnerTestObject("inside"));

    Map<String, Object> updates = getUpdateMapFromFile("update-maps.json");

    TestObject$$JsonObjectParser.INSTANCE.updateInstanceFromMap(testObject, updates, CONTEXT);

    LinkedHashMap<String, TestObject.InnerTestObject> expected = new LinkedHashMap<>();
    expected.put("value", new TestObject.InnerTestObject("out"));
    assertEquals("myInterfaceMap", expected, testObject.myInterfaceMap);
}

From source file:marytts.modules.ModuleRegistry.java

/**
 * Lookup a list of modules for the given combination of type, locale and voice.
 * A given lookup will return a list of modules accepting the datatype as input,
 * ordered by specificity so that the most specific modules come first.
 * For each output type produced by modules, there will be only one module
 * producing that type, namely the most specific one found.
 * Specificity is ordered as follows://www  .java 2 s. com
 * 1. most specific is the full combination of datatype, locale and voice;
 * 2. the combination of datatype, language-only locale and voice (i.e., for requested locale "en-US" will find modules with locale "en");
 * 3. the combination of datatype and locale, ignoring voice;
 * 4. the combination of datatype and language-only locale, ignoring voice;
 * 5. least specific is the datatype, ignoring locale and voice.
 * @param type the type of input data
 * @param locale the locale
 * @param voice the voice to use.
 * @return a list of mary modules accepting the datatype and suitable for
 * the given locale and voice, ordered by their specificity,
 * or an empty list if there is no suitable module.
 * @throws IllegalStateException if called when registration is not yet complete. 
 */
@SuppressWarnings("unchecked")
private static List<MaryModule> get(MaryDataType type, Locale locale, Voice voice)
        throws IllegalStateException {
    if (!registrationComplete)
        throw new IllegalStateException("Cannot inquire about modules while registration is ongoing");
    LinkedHashMap<MaryDataType, MaryModule> results = new LinkedHashMap<MaryDataType, MaryModule>();
    // First, get all results:
    List<List<MaryModule>> listOfLists = new LinkedList<List<MaryModule>>();
    listOfLists.add((List<MaryModule>) mkm.get(type, locale, voice));
    Locale langOnly = locale != null ? new Locale(locale.getLanguage()) : null;
    boolean haveCountry = langOnly == null ? false : !langOnly.equals(locale);
    if (haveCountry) {
        listOfLists.add((List<MaryModule>) mkm.get(type, langOnly, voice));
    }
    listOfLists.add((List<MaryModule>) mkm.get(type, locale, null));
    if (haveCountry) {
        listOfLists.add((List<MaryModule>) mkm.get(type, langOnly, null));
    }
    listOfLists.add((List<MaryModule>) mkm.get(type, null, null));
    // Now, for each mary output type, keep only the most specific module,
    // and return the list ordered by the specificity of modules (most specific first):
    for (List<MaryModule> list : listOfLists) {
        if (list != null) {
            for (MaryModule m : list) {
                if (!results.containsKey(m.outputType()))
                    results.put(m.outputType(), m);
            }
        }
    }
    List<MaryModule> returnList = new LinkedList<MaryModule>();
    for (MaryDataType t : results.keySet()) {
        returnList.add(results.get(t));
    }
    return returnList;
}

From source file:com.openerp.addons.note.NoteDBHelper.java

public LinkedHashMap<String, String> writeNoteTags(String tagname) {

    LinkedHashMap<String, String> noteTags = new LinkedHashMap<String, String>();
    ContentValues values = new ContentValues();

    values.put("name", tagname);
    NoteDBHelper.NoteTags notetagObj = new NoteTags(mContext);
    int newId = notetagObj.createRecordOnserver(notetagObj, values);
    values.put("id", newId);
    notetagObj.create(notetagObj, values);
    noteTags.put("newID", String.valueOf(newId));
    noteTags.put("tagName", tagname);
    return noteTags;
}

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

@NotNull
@Override/*from  w w  w  .  j a v a  2 s  .c o  m*/
public var $set(@NotNull var key, Object value) {
    LinkedHashMap<var, var> copyMap = copyMap();
    copyMap.put(key, DollarFactory.fromValue(value, errors()));
    return DollarFactory.wrap(new DollarMap(errors(), copyMap));
}

From source file:com.espertech.esper.regression.pattern.TestCronParameter.java

private EventCollection getEventSet(long baseTime, long numMSecBetweenEvents) {
    LinkedHashMap<String, Object> testData = new LinkedHashMap<String, Object>();
    testData.put("A1", new SupportBean_A("A1"));
    LinkedHashMap<String, Long> times = makeExternalClockTimes(testData, baseTime, numMSecBetweenEvents);
    return new EventCollection(testData, times);
}