Example usage for java.util LinkedHashMap keySet

List of usage examples for java.util LinkedHashMap keySet

Introduction

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

Prototype

public Set<K> keySet() 

Source Link

Document

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

Usage

From source file:net.big_oh.resourcestats.dao.ResourceDAOIntegrationTest.java

/**
 * Test method for/*w w  w.j av  a2  s.  co m*/
 * {@link net.big_oh.resourcestats.dao.ResourceDAO#getMostPopularResources(int, int)}
 * .
 */
@Test
public void testGetMostPopularResourcesIntInt() {
    try {
        sf.getCurrentSession().beginTransaction();

        LinkedHashMap<Resource, Number> resources = dao.getMostPopularResources(5, 7);

        assertNotNull(resources);

        for (Object key : resources.keySet()) {
            assertTrue(key instanceof Resource);
            Object value = resources.get(key);
            assertTrue(value instanceof Number);
        }

        // TODO DSW Provide improved assertions

        sf.getCurrentSession().getTransaction().commit();
    } catch (Throwable t) {
        HibernateUtil.rollback(t, sf, log);
        throw new RuntimeException(t);
    }
}

From source file:com.opengamma.analytics.math.interpolation.data.Interpolator1DDataBundleBuilderFunction.java

public Interpolator1DDataBundleBuilderFunction(final LinkedHashMap<String, double[]> knotPoints,
        final LinkedHashMap<String, Interpolator1D> interpolators) {
    Validate.notNull(knotPoints, "null knot points");
    Validate.notNull(interpolators, "null interpolators");
    int count = 0;
    final Set<String> names = knotPoints.keySet();
    for (final String name : names) {
        final int size = knotPoints.get(name).length;
        Validate.isTrue(size > 0, "no knot points for " + name);
        count += size;/*from   w ww  . ja  va2s  . c  o  m*/
    }
    _knotPoints = knotPoints;
    _interpolators = interpolators;
    _nNodes = count;
}

From source file:ubic.gemma.web.controller.visualization.FactorProfile.java

private List<Double> extractFactorPlotValues(ExperimentalFactor ef,
        LinkedHashMap<BioAssayValueObject, LinkedHashMap<ExperimentalFactor, Double>> profiles) {
    List<Double> values = new ArrayList<>();
    for (BioAssayValueObject ba : profiles.keySet()) {
        for (ExperimentalFactor bef : profiles.get(ba).keySet()) {
            if (bef.equals(ef)) {
                values.add(profiles.get(ba).get(ef));
            }/*from   w ww.java  2s .c  om*/
        }
    }
    return values;
}

From source file:net.big_oh.resourcestats.dao.RequestorDAOIntegrationTest.java

/**
 * Test method for/* ww w  .  ja v a2s. co  m*/
 * {@link net.big_oh.resourcestats.dao.RequestorDAO#getMostFrequentRequestors(int, java.util.Date)}
 * .
 */
@Test
public void testGetMostFrequentRequestorsIntDate() {
    try {
        sf.getCurrentSession().beginTransaction();

        LinkedHashMap<Requestor, Number> requestors = dao.getMostFrequentRequestors(5,
                DateUtils.addDays(new Date(), -3));

        assertNotNull(requestors);

        for (Object key : requestors.keySet()) {
            assertTrue(key instanceof Requestor);
            Object value = requestors.get(key);
            assertTrue(value instanceof Number);
        }

        // TODO DSW Provide improved assertions

        sf.getCurrentSession().getTransaction().commit();
    } catch (Throwable t) {
        HibernateUtil.rollback(t, sf, log);
        throw new RuntimeException(t);
    }
}

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

/**
 * Prepare data for fitting starting from the analysis group.
 *
 * @param dRAnalysisGroup/*  ww  w  . j  av a2  s.  c o m*/
 * @return LinkedHashMap That maps the concentration (log-transformed!) to
 * the replicate velocities
 */
private List<DoseResponsePair> prepareFittingData(AreaDoseResponseAnalysisGroup dRAnalysisGroup) {
    List<DoseResponsePair> result = new ArrayList<>();

    List<List<Double>> allVelocities = new ArrayList<>();
    List<Double> allLogConcentrations = new ArrayList<>();

    //put concentrations of treatment to analyze (control not included!) in list
    LinkedHashMap<Double, String> nestedMap = dRAnalysisGroup.getConcentrationsMap()
            .get(dRAnalysisGroup.getTreatmentToAnalyse());
    for (Double concentration : nestedMap.keySet()) {
        //key can only be linked with a single value, if one concentration is setup to have more than one associated concentration unit, only the last will remain
        String unit = nestedMap.get(concentration);

        Double logConcentration = AnalysisUtils.logTransform(concentration, unit);
        allLogConcentrations.add(logConcentration);
    }

    Double lowestLogConc = Collections.min(allLogConcentrations);
    //iterate through conditions
    int x = 0;
    for (PlateCondition plateCondition : dRAnalysisGroup.getVelocitiesMap().keySet()) {
        List<Double> replicateVelocities = dRAnalysisGroup.getVelocitiesMap().get(plateCondition);

        //check if this platecondition is the control
        for (Treatment treatment : plateCondition.getTreatmentList()) {
            if (treatment.getTreatmentType().getName().contains("ontrol")) {
                allLogConcentrations.add(x, lowestLogConc - 1.0);
            }
        }

        allVelocities.add(replicateVelocities);
        x++;
    }

    for (int i = 0; i < allVelocities.size(); i++) {
        result.add(new DoseResponsePair(allLogConcentrations.get(i), allVelocities.get(i)));
    }
    return result;
}

From source file:com.qwazr.graph.GraphServiceImpl.java

@Override
public Set<String> createUpdateNodes(String graphName, LinkedHashMap<String, GraphNode> nodes, Boolean upsert) {
    try {//from  ww w  .  j ava 2s  .co  m
        GraphManager.INSTANCE.getGraphInstance(graphName).createUpdateNodes(nodes, upsert);
        return nodes.keySet();
    } catch (URISyntaxException | IOException | ServerException | DatabaseException e) {
        logger.warn(e.getMessage(), e);
        throw ServerException.getJsonException(e);
    }
}

From source file:ubic.gemma.web.controller.visualization.VisualizationValueObject.java

/**
 * Initialize the factor profiles./*from   w w  w  .j a  va2  s .  co m*/
 */
public void setUpFactorProfiles(
        LinkedHashMap<BioAssayValueObject, LinkedHashMap<ExperimentalFactor, Double>> layout) {
    if (layout == null) {
        VisualizationValueObject.log.warn("Null layout, ignoring");
        return;
    }

    Collection<ExperimentalFactor> efs = new HashSet<>();
    for (LinkedHashMap<ExperimentalFactor, Double> maps : layout.values()) {
        efs.addAll(maps.keySet());
    }

    this.factorProfiles = new ArrayList<>();
    for (ExperimentalFactor experimentalFactor : efs) {
        this.factorProfiles.add(new FactorProfile(experimentalFactor, layout));
    }
}

From source file:net.big_oh.resourcestats.dao.ResourceDAOIntegrationTest.java

/**
 * Test method for// w ww. ja v a  2s .co  m
 * {@link net.big_oh.resourcestats.dao.ResourceDAO#getMostPopularResources(int, java.util.Date)}
 * .
 */
@Test
public void testGetMostPopularResourcesIntDate() {
    try {
        sf.getCurrentSession().beginTransaction();

        LinkedHashMap<Resource, Number> resources = dao.getMostPopularResources(5,
                DateUtils.addDays(new Date(), -3));

        assertNotNull(resources);

        for (Object key : resources.keySet()) {
            assertTrue(key instanceof Resource);
            Object value = resources.get(key);
            assertTrue(value instanceof Number);
        }

        // TODO DSW Provide improved assertions

        sf.getCurrentSession().getTransaction().commit();
    } catch (Throwable t) {
        HibernateUtil.rollback(t, sf, log);
        throw new RuntimeException(t);
    }
}

From source file:org.i3xx.step.uno.impl.service.builtin.ContextPropertiesService.java

/**
 * Reads the key value pairs from a JSON String, 
 * and adds the pairs to the map.//from   ww  w . jav a2  s.c o m
 * 
 * @param json
 * @throws Exception
 */
public void fromJSON(String json) throws Exception {

    Map<String, Object> values = context.getValues();

    GsonBuilder gsonBuilder = new GsonBuilder();
    gsonBuilder.registerTypeAdapter(LinkedHashMap.class, new GsonHashMapDeserializer());
    Gson gson = gsonBuilder.create();

    final Callable rev = new Callable() {
        public Object call(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) {
            //
            // sh, 12.12.2014
            // not really understood what happens, but
            // @see http://stackoverflow.com/questions/10856154/rhino-return-json-from-within-java
            // tested some toJSON/fromJSON sequences with success.
            //
            return args[1];
        }
    };

    Context jscx = Context.getCurrentContext();
    boolean jsf = jscx != null;
    if (!jsf)
        jscx = Context.enter();

    LinkedHashMap<?, ?> map = gson.fromJson(json, LinkedHashMap.class);
    Iterator<?> iter = map.keySet().iterator();
    while (iter.hasNext()) {
        String key = (String) iter.next();
        Object val = map.get(key);

        if (val == null) {
            //values.put(key, null);
        } else if (val instanceof Number) {
            values.put(key, val);
        } else if (val instanceof String) {
            values.put(key, val);
        } else if (val instanceof Map<?, ?>) {
            LinkedHashMap<?, ?> mo2 = (LinkedHashMap<?, ?>) val;
            if (mo2.containsKey("Object")) {
                String stmt = (String) mo2.get("Object");
                if (stmt != null) {
                    Object obj = writeValue(Base64.decodeBase64(stmt));
                    if (obj != null) {
                        values.put(key, obj);
                    } //fi
                } //fi
            } else if (mo2.containsKey("Scriptable")) {
                String stmt = (String) mo2.get("Scriptable");
                if (stmt != null) {
                    Scriptable scope = context.getScope();
                    Object obj = NativeJSON.parse(jscx, scope, stmt, rev);
                    if (obj != null) {
                        values.put(key, obj);
                    } //fi
                } //fi
            } else {
                continue;
            }
        } //fi
    } //while

    if (!jsf)
        Context.exit();
}

From source file:org.deri.iris.rules.compiler.RuleCompiler.java

/**
 * Compile a rule. No optimisations of any kind are attempted.
 * //from  w  w w.ja v a2  s .co m
 * @param rule The rule to be compiled
 * @return The compiled rule, ready to be evaluated
 * @throws EvaluationException If the query can not be compiled for any
 *             reason.
 */
public ICompiledRule compile(IRule rule) throws EvaluationException {
    LinkedHashMap<RuleElement, ILiteral> elementsToLiteral = compileBody(rule.getBody());
    List<RuleElement> elements = IteratorUtils.toList(elementsToLiteral.keySet().iterator());

    List<IVariable> variables;

    if (elements.size() == 0)
        variables = new ArrayList<IVariable>();
    else {
        RuleElement lastElement = elements.get(elements.size() - 1);
        variables = lastElement.getOutputVariables();
    }

    ILiteral headLiteral = rule.getHead().get(0);
    IAtom headAtom = headLiteral.getAtom();
    ITuple headTuple = headAtom.getTuple();

    HeadSubstituter substituter;

    // We create a special head substituter for rules with head
    // equality, that establishes equivalence relation between terms in the
    // equivalent terms data-structure.
    if (RuleHeadEquality.hasRuleHeadEquality(rule)) {
        substituter = new RuleHeadEqualitySubstituter(variables, headTuple, elementsToLiteral, mEquivalentTerms,
                mConfiguration);
    } else {
        substituter = new HeadSubstituter(variables, headTuple, elementsToLiteral, mConfiguration);
    }

    elements.add(substituter);

    //Amir added
    for (int e = 0; e < elements.size() - 2; e++) {
        RuleElement elt = elements.get(e);
        elt.FindIndices(elements);
    }

    return new CompiledRule(elements, headAtom.getPredicate(), headLiteral, mConfiguration);
}