List of usage examples for java.util LinkedHashMap get
public V get(Object key)
From source file:com.amalto.workbench.actions.XSDSetAnnotationLabelAction.java
@Override public IStatus doAction() { try {/*from w ww . j a v a 2 s .c om*/ // IStructuredSelection selection = (IStructuredSelection)page.getTreeViewer().getSelection(); // // XSDAnnotationsStructure struc = new XSDAnnotationsStructure((XSDComponent)selection.getFirstElement()); IStructuredSelection selection = (TreeSelection) page.getTreeViewer().getSelection(); XSDComponent xSDCom = null; if (selection.getFirstElement() instanceof Element) { TreePath tPath = ((TreeSelection) selection).getPaths()[0]; for (int i = 0; i < tPath.getSegmentCount(); i++) { if (tPath.getSegment(i) instanceof XSDAnnotation) { xSDCom = (XSDAnnotation) (tPath.getSegment(i)); } } } else { xSDCom = (XSDComponent) selection.getFirstElement(); } XSDAnnotationsStructure struc = new XSDAnnotationsStructure(xSDCom); if (struc.getAnnotation() == null) { throw new RuntimeException(Messages.bind(Messages.XSDSetAnnotationLabelAction_ExceptioInfo, xSDCom.getClass().getName())); } AnnotationLanguageLabelsDialog dlg = new AnnotationLanguageLabelsDialog(struc.getLabels(), new AnnotationLabelDialogSelectionListener(page), page.getEditorSite().getShell(), Messages.XSDSetAnnotationLabelAction_DialogTitle); dlg.setBlockOnOpen(true); dlg.open(); if (dlg.getReturnCode() == Window.OK) { // remove existing annotations with labels struc.removeAllLabels(); // add the new ones LinkedHashMap<String, String> descriptions = dlg.getDescriptionsMap(); Set<String> isoCodes = descriptions.keySet(); for (Iterator iter = isoCodes.iterator(); iter.hasNext();) { String isoCode = (String) iter.next(); struc.setLabel(isoCode, descriptions.get(isoCode)); } } else { return Status.CANCEL_STATUS; } if (struc.hasChanged()) { page.markDirty(); page.refresh(); page.getTreeViewer().expandToLevel(xSDCom, 2); } } catch (Exception e) { log.error(e.getMessage(), e); MessageDialog.openError(page.getSite().getShell(), Messages._Error, Messages.bind(Messages.XSDSetAnnotationLabelAction_ErrorMsg, e.getLocalizedMessage())); return Status.CANCEL_STATUS; } return Status.OK_STATUS; }
From source file:net.big_oh.resourcestats.dao.ResourceDAOIntegrationTest.java
/** * Test method for/* www. j ava 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:com.grarak.kerneladiutor.database.tools.profiles.Profiles.java
public void putProfile(String name, LinkedHashMap<String, String> commands) { try {// w w w. j av a 2s. c om JSONObject items = new JSONObject(); items.put("name", name); ProfileItem profileItem = new ProfileItem(items); for (String id : commands.keySet()) { profileItem.putCommand(new ProfileItem.CommandItem(id, commands.get(id))); } putItem(items); } catch (JSONException e) { e.printStackTrace(); } }
From source file:org.envirocar.wps.util.EnviroCarFeatureParser.java
/** * parses envirocar track encoded as JSON into Geotools simple features; a feature is created for each measurement point * of track/*from w ww. j a va 2 s . c om*/ * * @param url * URL of track (e.g. https://envirocar.org/api/stable/tracks/53433169e4b09d7b34fa824a) * @return * Geotools simple features; a feature is created for each measurement point of track * @throws IOException * if opening of URL stream fails */ public SimpleFeatureCollection createFeaturesFromJSON(URL url) throws IOException { InputStream in = url.openStream(); ObjectMapper objMapper = new ObjectMapper(); Map<?, ?> map = objMapper.readValue(in, Map.class); ArrayList<?> features = null; for (Object o : map.keySet()) { Object entry = map.get(o); if (o.equals("features")) { features = (ArrayList<?>) entry; } } GeometryFactory geomFactory = new GeometryFactory(); List<SimpleFeature> simpleFeatureList = new ArrayList<SimpleFeature>(); String uuid = UUID.randomUUID().toString().substring(0, 5); String namespace = "http://www.52north.org/" + uuid; SimpleFeatureType sft = null; SimpleFeatureBuilder sfb = null; typeBuilder = new SimpleFeatureTypeBuilder(); try { typeBuilder.setCRS(CRS.decode("EPSG:4326")); } catch (NoSuchAuthorityCodeException e) { LOGGER.error("Could not decode EPSG:4326", e); } catch (FactoryException e) { LOGGER.error("Could not decode EPSG:4326", e); } typeBuilder.setNamespaceURI(namespace); Name nameType = new NameImpl(namespace, "Feature-" + uuid); typeBuilder.setName(nameType); typeBuilder.add(FeatureProperties.GEOMETRY, Point.class); typeBuilder.add(FeatureProperties.ID, String.class); typeBuilder.add(FeatureProperties.TIME, String.class); Set<String> distinctPhenomenonNames = gatherPropertiesForFeatureTypeBuilder(features); for (Object object : features) { if (object instanceof LinkedHashMap<?, ?>) { LinkedHashMap<?, ?> featureMap = (LinkedHashMap<?, ?>) object; Object geometryObject = featureMap.get("geometry"); Point point = null; if (geometryObject instanceof LinkedHashMap<?, ?>) { LinkedHashMap<?, ?> geometryMap = (LinkedHashMap<?, ?>) geometryObject; Object coordinatesObject = geometryMap.get("coordinates"); if (coordinatesObject instanceof ArrayList<?>) { ArrayList<?> coordinatesList = (ArrayList<?>) coordinatesObject; Object xObj = coordinatesList.get(0); Object yObj = coordinatesList.get(1); point = geomFactory.createPoint(new Coordinate(Double.parseDouble(xObj.toString()), Double.parseDouble(yObj.toString()))); } } Object propertiesObject = featureMap.get("properties"); if (propertiesObject instanceof LinkedHashMap<?, ?>) { LinkedHashMap<?, ?> propertiesMap = (LinkedHashMap<?, ?>) propertiesObject; /* * get id and time */ String id = propertiesMap.get("id").toString(); String time = propertiesMap.get("time").toString(); Object phenomenonsObject = propertiesMap.get("phenomenons"); if (phenomenonsObject instanceof LinkedHashMap<?, ?>) { LinkedHashMap<?, ?> phenomenonsMap = (LinkedHashMap<?, ?>) phenomenonsObject; /* * properties are id, time and phenomenons */ if (sft == null) { sft = buildFeatureType(distinctPhenomenonNames); sfb = new SimpleFeatureBuilder(sft); } sfb.set(FeatureProperties.ID, id); sfb.set(FeatureProperties.TIME, time); sfb.set(FeatureProperties.GEOMETRY, point); for (Object phenomenonKey : phenomenonsMap.keySet()) { Object phenomenonValue = phenomenonsMap.get(phenomenonKey); if (phenomenonValue instanceof LinkedHashMap<?, ?>) { LinkedHashMap<?, ?> phenomenonValueMap = (LinkedHashMap<?, ?>) phenomenonValue; String value = phenomenonValueMap.get("value").toString(); String unit = phenomenonValueMap.get("unit").toString(); /* * create property name */ String propertyName = phenomenonKey.toString() + " (" + unit + ")"; if (sfb != null) { sfb.set(propertyName, value); } } } if (sfb != null) { simpleFeatureList.add(sfb.buildFeature(id)); } } } } } return new ListFeatureCollection(sft, simpleFeatureList); }
From source file:org.eda.fpsrv.FPParams.java
public void setFromJSONString(String jsonString) throws IOException { LinkedHashMap<String, String> h_map; h_map = new ObjectMapper().readValue(jsonString, new TypeReference<LinkedHashMap<String, Object>>() { });/*w w w. ja va2 s.co m*/ FPProperty property; for (String key : properties.keySet()) { if (h_map.containsKey(key)) { property = properties.get(key); property.setValue(h_map.get(key)); } } }
From source file:com.opengamma.analytics.financial.provider.sensitivity.multicurve.SimpleParameterSensitivity.java
/** * Create a copy of the sensitivity and add a given sensitivity to it. * @param other The sensitivity to add.//w w w .j a va2s. c o m * @return The total sensitivity. */ public SimpleParameterSensitivity plus(final SimpleParameterSensitivity other) { ArgumentChecker.notNull(other, "Sensitivity to add"); final MatrixAlgebra algebra = MatrixAlgebraFactory.COMMONS_ALGEBRA; final LinkedHashMap<String, DoubleMatrix1D> result = new LinkedHashMap<>(); result.putAll(_sensitivity); for (final Map.Entry<String, DoubleMatrix1D> entry : other.getSensitivities().entrySet()) { final String name = entry.getKey(); if (result.containsKey(name)) { result.put(name, (DoubleMatrix1D) algebra.add(result.get(name), entry.getValue())); } else { result.put(name, entry.getValue()); } } return new SimpleParameterSensitivity(result); }
From source file:be.ugent.maf.cellmissy.gui.controller.analysis.doseresponse.area.AreaDRNormalizedController.java
/** * Prepare data for fitting starting from the analysis group. * * @param dRAnalysisGroup// www . java 2 s . com * @return LinkedHashMap That maps the concentration (log-transformed!) to * the normalized replicate velocites */ private List<DoseResponsePair> prepareFittingData(AreaDoseResponseAnalysisGroup dRAnalysisGroup) { List<DoseResponsePair> result = new ArrayList<>(); //!! control concentrations (10 * lower than lowest treatment conc) also need to be added 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()) { 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); //normalize each value List<Double> normalizedVelocities = new ArrayList<>(); for (Double value : replicateVelocities) { normalizedVelocities.add(normalize(value)); } //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(normalizedVelocities); x++; } for (int i = 0; i < allLogConcentrations.size(); i++) { result.add(new DoseResponsePair(allLogConcentrations.get(i), allVelocities.get(i))); } return result; }
From source file:net.sf.maltcms.chromaui.normalization.spi.charts.PeakGroupRtBoxPlot.java
protected String getPeakName(IPeakGroupDescriptor pgd) { String rt = "mean rt: " + String.format("%.2f", pgd.getMeanApexTime()) + "+/-" + String.format("%.2f", pgd.getApexTimeStdDev()) + "; median rt: " + String.format("%.2f", pgd.getMedianApexTime()) + ": "; LinkedHashMap<String, Integer> names = new LinkedHashMap<>(); if (!pgd.getDisplayName().equals(pgd.getName())) { return rt + pgd.getDisplayName(); }// ww w. java2s . co m for (IPeakAnnotationDescriptor ipad : pgd.getPeakAnnotationDescriptors()) { if (names.containsKey(ipad.getName())) { names.put(ipad.getName(), names.get(ipad.getName()) + 1); } else { names.put(ipad.getName(), 1); } } if (names.isEmpty()) { return rt + "<NA>"; } if (names.size() > 1) { StringBuilder sb = new StringBuilder(); for (String key : names.keySet()) { sb.append(key); sb.append(" (" + names.get(key) + ")"); sb.append(" | "); } return rt + sb.replace(sb.length() - 1, sb.length() - 1, "").toString(); } else { return rt + names.keySet().toArray(new String[0])[0]; } }
From source file:net.sf.maltcms.chromaui.normalization.spi.charts.PeakGroupBoxPlot.java
protected String getPeakName(IPeakGroupDescriptor pgd) { String rt = "mean area: " + String.format("%.2f", pgd.getMeanArea(normalizer)) + "+/-" + String.format("%.2f", pgd.getAreaStdDev(normalizer)) + "; median area: " + String.format("%.2f", pgd.getMedianArea(normalizer)) + ": "; LinkedHashMap<String, Integer> names = new LinkedHashMap<>(); if (!pgd.getDisplayName().equals(pgd.getName())) { return rt + pgd.getDisplayName(); }/* www . ja va 2s. c o m*/ for (IPeakAnnotationDescriptor ipad : pgd.getPeakAnnotationDescriptors()) { if (names.containsKey(ipad.getName())) { names.put(ipad.getName(), names.get(ipad.getName()) + 1); } else { names.put(ipad.getName(), 1); } } if (names.isEmpty()) { return rt + "<NA>"; } if (names.size() > 1) { StringBuilder sb = new StringBuilder(); for (String key : names.keySet()) { sb.append(key); sb.append(" (" + names.get(key) + ")"); sb.append(" | "); } return rt + sb.replace(sb.length() - 1, sb.length() - 1, "").toString(); } else { return rt + names.keySet().toArray(new String[0])[0]; } }
From source file:org.raxa.module.raxacore.web.v1_0.controller.RaxaDrugController.java
/** * Creates a drug info for the given drug *///from w w w . j av a 2 s . c om private void createNewDrugInfo(Drug drug, LinkedHashMap drugInfoMap) { String drugUuid = drug.getUuid(); // create drug info POJO and add required relationship with a Drug DrugInfo drugInfo = new DrugInfo(); drugInfo.setDrug(drug); if (drugInfoMap.get("name") != null) { drugInfo.setName(drugInfoMap.get("name").toString()); } if (drugInfoMap.get("description") != null) { drugInfo.setDescription(drugInfoMap.get("description").toString()); } if (drugInfoMap.get("price") != null) { drugInfo.setPrice(Double.parseDouble(drugInfoMap.get("price").toString())); } if (drugInfoMap.get("cost") != null) { drugInfo.setCost(Double.parseDouble(drugInfoMap.get("cost").toString())); } // save new object and prepare response DrugInfo drugInfoJustCreated = Context.getService(DrugInfoService.class).saveDrugInfo(drugInfo); }