List of usage examples for java.util LinkedHashMap keySet
public Set<K> keySet()
From source file:org.openmeetings.app.installation.ImportInitvalues.java
/** * Loading initial Language from xml Files into database *//*from w ww . jav a 2 s. com*/ // ------------------------------------------------------------------------------ public void loadInitLanguages(String filePath) throws Exception { loadCountriesFiles(filePath); loadTimeZoneFiles(filePath); LinkedHashMap<Integer, LinkedHashMap<String, Object>> listlanguages = this.getLanguageFiles(filePath); boolean langFieldIdIsInited = false; /** Read all languages files */ for (Iterator<Integer> itLang = listlanguages.keySet().iterator(); itLang.hasNext();) { Integer langId = itLang.next(); LinkedHashMap<String, Object> lang = listlanguages.get(langId); log.debug("loadInitLanguages lang: " + lang); String langName = (String) lang.get("name"); String rtl = (String) lang.get("rtl"); String code = (String) lang.get("code"); log.debug("loadInitLanguages rtl from xml: " + rtl); Boolean langRtl = false; if (rtl != null && rtl.equals("true")) langRtl = true; Long languages_id = fieldLanguageDaoImpl.addLanguage(langName, langRtl, code); SAXReader reader = new SAXReader(); Document document = reader.read(new File(filePath, langName + ".xml")); Element root = document.getRootElement(); for (@SuppressWarnings("rawtypes") Iterator it = root.elementIterator("string"); it.hasNext();) { Element item = (Element) it.next(); // log.error(item.getName()); Long id = Long.valueOf(item.attributeValue("id")).longValue(); String name = item.attributeValue("name"); String value = ""; for (@SuppressWarnings("rawtypes") Iterator t2 = item.elementIterator("value"); t2.hasNext();) { Element val = (Element) t2.next(); value = val.getText(); } // log.error("result: "+langFieldIdIsInited+" "+id+" "+name+" "+value); Fieldvalues fv = null; // Only do that for the first field-set if (!langFieldIdIsInited) { fv = fieldmanagment.addFieldById(name, id); } else { fv = fieldmanagment.getFieldvaluesById(id); } fieldmanagment.addFieldValueByFieldAndLanguage(fv, languages_id, value); } log.debug("Lang ADDED: " + lang); if (!langFieldIdIsInited) langFieldIdIsInited = true; } }
From source file:org.eclipse.scanning.test.scan.nexus.MandelbrotRemoteTest.java
private void checkNexusFile(IRunnableDevice<ScanModel> scanner, int... sizes) throws NexusException, ScanningException, DatasetException { final ScanModel mod = ((AbstractRunnableDevice<ScanModel>) scanner).getModel(); assertEquals(DeviceState.READY, scanner.getDeviceState()); String filePath = ((AbstractRunnableDevice<ScanModel>) scanner).getModel().getFilePath(); NexusFile nf = fileFactory.newNexusFile(filePath); nf.openToRead();//from w ww .j a v a2 s. c om TreeFile nexusTree = NexusUtils.loadNexusTree(nf); NXroot rootNode = (NXroot) nexusTree.getGroupNode(); NXentry entry = rootNode.getEntry(); NXinstrument instrument = entry.getInstrument(); // check that the scan points have been written correctly assertSolsticeScanGroup(entry, false, false, sizes); LinkedHashMap<String, List<String>> detectorDataFields = new LinkedHashMap<>(); // axis for additional dimensions of a datafield, e.g. image detectorDataFields.put(NXdetector.NX_DATA, Arrays.asList("real", "imaginary")); detectorDataFields.put("spectrum", Arrays.asList("spectrum_axis")); detectorDataFields.put("value", Collections.emptyList()); String detectorName = mod.getDetectors().get(0).getName(); NXdetector detector = instrument.getDetector(detectorName); // map of detector data field to name of nxData group where that field is the @signal field Map<String, String> expectedDataGroupNames = detectorDataFields.keySet().stream().collect(Collectors .toMap(Function.identity(), x -> detectorName + (x.equals(NXdetector.NX_DATA) ? "" : "_" + x))); // validate the NXdata generated by the NexusDataBuilder Map<String, NXdata> nxDataGroups = entry.getChildren(NXdata.class); assertEquals(detectorDataFields.size(), nxDataGroups.size()); assertTrue(nxDataGroups.keySet().containsAll(expectedDataGroupNames.values())); for (String nxDataGroupName : nxDataGroups.keySet()) { NXdata nxData = entry.getData(nxDataGroupName); String sourceFieldName = nxDataGroupName.equals(detectorName) ? NXdetector.NX_DATA : nxDataGroupName.substring(nxDataGroupName.indexOf('_') + 1); assertSignal(nxData, sourceFieldName); // check the nxData's signal field is a link to the data node of the detector DataNode dataNode = detector.getDataNode(sourceFieldName); IDataset dataset = dataNode.getDataset().getSlice(); assertSame(dataNode, nxData.getDataNode(sourceFieldName)); int[] shape = dataset.getShape(); for (int i = 0; i < sizes.length; i++) assertEquals(sizes[i], shape[i]); // Make sure none of the numbers are NaNs. The detector // is expected to fill this scan with non-nulls. final PositionIterator it = new PositionIterator(shape); while (it.hasNext()) { int[] next = it.getPos(); assertFalse(Double.isNaN(dataset.getDouble(next))); } // Check axes final IPosition pos = mod.getPositionIterable().iterator().next(); final Collection<String> names = pos.getNames(); // Append _value_demand to each name in list, then add detector axis fields to result List<String> expectedAxesNames = Stream.concat(names.stream().map(x -> x + "_value_set"), detectorDataFields.get(sourceFieldName).stream()).collect(Collectors.toList()); assertAxes(nxData, expectedAxesNames.toArray(new String[expectedAxesNames.size()])); int[] defaultDimensionMappings = IntStream.range(0, sizes.length).toArray(); int i = -1; for (String positionerName : names) { i++; NXpositioner positioner = instrument.getPositioner(positionerName); assertNotNull(positioner); dataNode = positioner.getDataNode("value_set"); dataset = dataNode.getDataset().getSlice(); shape = dataset.getShape(); assertEquals(1, shape.length); assertEquals(sizes[i], shape[0]); String nxDataFieldName = positionerName + "_value_set"; assertSame(dataNode, nxData.getDataNode(nxDataFieldName)); assertIndices(nxData, nxDataFieldName, i); assertTarget(nxData, nxDataFieldName, rootNode, "/entry/instrument/" + positionerName + "/value_set"); // Actual values should be scanD dataNode = positioner.getDataNode(NXpositioner.NX_VALUE); dataset = dataNode.getDataset().getSlice(); shape = dataset.getShape(); assertArrayEquals(sizes, shape); nxDataFieldName = positionerName + "_" + NXpositioner.NX_VALUE; assertSame(dataNode, nxData.getDataNode(nxDataFieldName)); assertIndices(nxData, nxDataFieldName, defaultDimensionMappings); assertTarget(nxData, nxDataFieldName, rootNode, "/entry/instrument/" + positionerName + "/" + NXpositioner.NX_VALUE); } } }
From source file:com.google.gwt.emultest.java.util.LinkedHashMapTest.java
public void testLinkedHashMapMap() { LinkedHashMap<Integer, Integer> srcMap = new LinkedHashMap<Integer, Integer>(); assertNotNull(srcMap);/*from ww w. j av a 2s . c om*/ checkEmptyLinkedHashMapAssumptions(srcMap); srcMap.put(INTEGER_1, INTEGER_11); srcMap.put(INTEGER_2, INTEGER_22); srcMap.put(INTEGER_3, INTEGER_33); LinkedHashMap<Integer, Integer> hashMap = cloneLinkedHashMap(srcMap); assertFalse(hashMap.isEmpty()); assertTrue(hashMap.size() == SIZE_THREE); Collection<Integer> valColl = hashMap.values(); assertTrue(valColl.contains(INTEGER_11)); assertTrue(valColl.contains(INTEGER_22)); assertTrue(valColl.contains(INTEGER_33)); Collection<Integer> keyColl = hashMap.keySet(); assertTrue(keyColl.contains(INTEGER_1)); assertTrue(keyColl.contains(INTEGER_2)); assertTrue(keyColl.contains(INTEGER_3)); }
From source file:org.polymap.core.data.imex.csv.CsvImporter.java
/** * Convert a csv file to a FeatureCollection. <b>This for now supports only * point geometries</b>.<br> * For different crs it also performs coor transformation. * <p>//from w ww . j a v a2 s .com * <b>NOTE: this doesn't support date attributes</b> * </p> * <p> * This code was initially taken from * {@link eu.hydrologis.jgrass.libs.utils.features.FeatureUtilities}. * * @param crs the crs to use. * @param fieldsAndTypes the {@link Map} of filed names and * {@link JGrassConstants#CSVTYPESARRAY types}. * @param monitor progress monitor. * @return the created {@link FeatureCollection} * @throws Exception */ @SuppressWarnings("nls") public FeatureCollection<SimpleFeatureType, SimpleFeature> createFeatureCollection(String name, CoordinateReferenceSystem crs, LinkedHashMap<String, Integer> fieldsAndTypesIndex, IProgressMonitorJGrass monitor) throws Exception { checkReadLines(); GeometryFactory gf = new GeometryFactory(); Map<String, Class> typesMap = JGrassConstants.CSVTYPESCLASSESMAP; String[] typesArray = JGrassConstants.CSVTYPESARRAY; SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder(); b.setName(name); b.setCRS(crs); b.add("the_geom", Point.class); int xIndex = -1; int yIndex = -1; // the bbox of all imported points Envelope bbox = null; Set<String> fieldNames = fieldsAndTypesIndex.keySet(); String[] fieldNamesArray = fieldNames.toArray(new String[fieldNames.size()]); for (int i = 0; i < fieldNamesArray.length; i++) { String fieldName = fieldNamesArray[i]; Integer typeIndex = fieldsAndTypesIndex.get(fieldName); if (typeIndex == 0) { xIndex = i; } else if (typeIndex == 1) { yIndex = i; } else { Class class1 = typesMap.get(typesArray[typeIndex]); b.add(fieldName, class1); log.debug(" field: name=" + fieldName + ", type=" + class1 + ", index=" + i); } } SimpleFeatureType featureType = b.buildFeatureType(); // FeatureCollection FeatureCollection<SimpleFeatureType, SimpleFeature> newCollection = new DefaultFeatureCollection(null, featureType); try { Collection<Integer> orderedTypeIndexes = fieldsAndTypesIndex.values(); Integer[] orderedTypeIndexesArray = orderedTypeIndexes.toArray(new Integer[orderedTypeIndexes.size()]); featureErrors.clear(); int featureId = 0; monitor.beginTask("Reading CSV Data", lines.size()); int count = 0; for (String[] line : lines) { monitor.worked(1); if (monitor.isCanceled()) { return newCollection; } try { SimpleFeatureBuilder builder = new SimpleFeatureBuilder(featureType); Object[] values = new Object[fieldNames.size() - 1]; try { double x = line[xIndex].length() > 0 ? nf.parse(line[xIndex]).doubleValue() : -1; //bbox.centre().x; double y = line[yIndex].length() > 0 ? nf.parse(line[yIndex]).doubleValue() : -1; //bbox.centre().y; if (x <= 0 || y <= 0) { log.info(" Missing geom. skipping this object!"); continue; } Point point = gf.createPoint(new Coordinate(x, y)); values[0] = point; if (bbox != null) { bbox.expandToInclude(point.getCoordinate()); } else { bbox = point.getEnvelope().getEnvelopeInternal(); } } catch (Exception e) { // don't break the entire run log.warn("Error while parsing ccordinates." + " index=" + count + " | xIndex=" + xIndex + ", value=" + line[xIndex] + " | yIndex=" + yIndex + ", value=" + line[yIndex] + " (" + e.toString() + ")"); } int objIndex = 1; for (int i = 0; i < orderedTypeIndexesArray.length; i++) { if (i == xIndex || i == yIndex) { continue; } String value = line[i]; int typeIndex = orderedTypeIndexesArray[i]; String typeName = typesArray[typeIndex]; if (typeName.equals(typesArray[3])) { values[objIndex] = value; } else if (typeName.equals(typesArray[4])) { //values[objIndex] = new Double( value ); values[objIndex] = nf.parse(value); } else if (typeName.equals(typesArray[5])) { values[objIndex] = new Integer(value); } else { throw new IllegalArgumentException("An undefined value type was found"); } objIndex++; } builder.addAll(values); SimpleFeature feature = builder.buildFeature(featureType.getTypeName() + "." + featureId); newCollection.add(feature); count++; } catch (Exception e) { featureErrors.add(featureId); log.warn("Error while creating FeatureCollection.", e); } featureId++; } monitor.done(); } catch (Exception e) { //JGrassLibsPlugin.log( "JGrassLibsPlugin problem", e ); //$NON-NLS-1$ e.printStackTrace(); throw e; } return newCollection; }
From source file:br.ufrgs.inf.dsmoura.repository.model.loadData.LoadLists.java
private static void loadSystemProperties() { LinkedHashMap<String, String> values = new LinkedHashMap<String, String>(); values.put(SystemPropertyEnum.FEEDBACK_EMAIL.getKey(), "lavoi@mydomain.com"); values.put(SystemPropertyEnum.REPOSITORY_SUBTITLE.getKey(), "Lavoi Reuse Repository"); values.put(SystemPropertyEnum.REPOSITORY_URL.getKey(), "http://localhost:8080/lavoi"); values.put(SystemPropertyEnum.HOME_PAGE_URL.getKey(), "https://github.com/dsmoura/lavoi"); values.put(SystemPropertyEnum.SMTP_HOSTNAME.getKey(), "smtp.mydomain.com"); values.put(SystemPropertyEnum.SMTP_SSL.getKey(), "true"); values.put(SystemPropertyEnum.EMAIL_DOMAIN_RESTRICTION.getKey(), "@mydomain.com"); values.put(SystemPropertyEnum.REPOSITORY_EMAIL.getKey(), "lavoi@mydomain.com"); values.put(SystemPropertyEnum.REPOSITORY_EMAIL_PASSWORD.getKey(), "password"); values.put(SystemPropertyEnum.REPOSITORY_EMAIL_USER.getKey(), "lavoi@mydomain.com"); values.put(SystemPropertyEnum.REPOSITORY_EMAIL_PASSWORD.getKey(), "password"); values.put(SystemPropertyEnum.SOLR_SERVER_URL.getKey(), "http://localhost:8080/solr/"); values.put(SystemPropertyEnum.USER_AUTHENTICATION_MODE.getKey(), "DATABASE"); values.put(SystemPropertyEnum.USER_AUTHENTICATION_DOMAIN_PREFIX.getKey(), "mydomain-"); for (String key : values.keySet()) { SystemPropertyDTO systemPropertyDTO = new SystemPropertyDTO(); systemPropertyDTO.setKey(key);//from w w w .j ava2s .c o m systemPropertyDTO.setValue(values.get(key)); GenericDAO.getInstance().insert(systemPropertyDTO); logger.info("Property inserted: " + systemPropertyDTO.getKey() + " -> " + systemPropertyDTO.getValue()); } }
From source file:gate.util.reporting.PRTimeReporter.java
/** * Sorts the processing element entries inside tree like structure made up of * LinkedHashMap. Entries will be sorted in descending order of time taken. * * @param gStore/*from www . j a va2 s. c o m*/ * An Object of type LinkedHashMap<String, Object> containing the * processing elements (with time in milliseconds) in hierarchical * structure. * * @return An Object of type LinkedHashMap<String, Object> containing the * processing elements sorted in descending order of processing time * taken. */ @SuppressWarnings("unchecked") private LinkedHashMap<String, Object> sortReport(LinkedHashMap<String, Object> gStore) { Iterator<String> i = gStore.keySet().iterator(); LinkedHashMap<String, Object> sortedReport = new LinkedHashMap<String, Object>(); LinkedHashMap<String, Object> mapperReport = new LinkedHashMap<String, Object>(); LinkedHashMap<String, String> unsortedReport = new LinkedHashMap<String, String>(); while (i.hasNext()) { Object key = i.next(); if (gStore.get(key) instanceof LinkedHashMap) { int systotal = 0; if (((LinkedHashMap<String, Object>) (gStore.get(key))).get("systotal") != null) { systotal = Integer .parseInt((String) ((LinkedHashMap<String, Object>) (gStore.get(key))).get("systotal")); } if (systotal >= 0) { unsortedReport.put((String) key, Integer.toString(systotal)); } mapperReport.put((String) key, sortReport((LinkedHashMap<String, Object>) (gStore.get(key)))); } else { if (!(key.equals("total") || key.equals("systotal"))) { if (Integer.parseInt((String) (gStore.get(key))) >= 0) { unsortedReport.put((String) key, new Integer((String) gStore.get(key)).toString()); } } } } LinkedHashMap<String, String> tempOutLHM = sortHashMapByValues(unsortedReport); Iterator<String> itr = tempOutLHM.keySet().iterator(); while (itr.hasNext()) { Object tempKey = itr.next(); sortedReport.put((String) tempKey, tempOutLHM.get(tempKey)); if (mapperReport.containsKey(tempKey)) { sortedReport.put((String) tempKey, mapperReport.get(tempKey)); } } sortedReport.put("total", gStore.get("total")); if (gStore.get("systotal") != null) { sortedReport.put("systotal", gStore.get("systotal")); } return sortedReport; }
From source file:com.amalto.workbench.utils.XSDAnnotationsStructure.java
public TreeMap<String, String> getHiddenAccesses() { TreeMap<String, String> hiddenAccesses = new TreeMap<String, String>(); LinkedHashMap<String, String> appInfos = getAppInfos("X_Hide");//$NON-NLS-1$ Set<String> keys = appInfos.keySet(); for (Iterator<String> iter = keys.iterator(); iter.hasNext();) { String key = iter.next(); hiddenAccesses.put(key, appInfos.get(key)); }//from ww w .j ava 2 s. c o m return hiddenAccesses; }
From source file:com.amalto.workbench.utils.XSDAnnotationsStructure.java
public TreeMap<String, String> getWriteAccesses() { TreeMap<String, String> writeAccesses = new TreeMap<String, String>(); LinkedHashMap<String, String> appInfos = getAppInfos("X_Write");//$NON-NLS-1$ Set<String> keys = appInfos.keySet(); for (Iterator<String> iter = keys.iterator(); iter.hasNext();) { String key = iter.next(); writeAccesses.put(key, appInfos.get(key)); }/* w w w . j a v a2 s. c o m*/ return writeAccesses; }
From source file:com.amalto.workbench.utils.XSDAnnotationsStructure.java
public LinkedHashMap<String, String> getLabels() { LinkedHashMap<String, String> labels = new LinkedHashMap<String, String>(); LinkedHashMap<String, String> appInfos = getAppInfos("X_Label_.*");//$NON-NLS-1$ Set<String> keys = appInfos.keySet(); for (Iterator<String> iter = keys.iterator(); iter.hasNext();) { String key = iter.next(); labels.put(key.substring(8).toLowerCase(), appInfos.get(key)); }/*from ww w . j a v a 2s.co m*/ return labels; }
From source file:com.amalto.workbench.utils.XSDAnnotationsStructure.java
/**************************************************************************** * X_Deny_Create//from w w w . jav a 2s . c om ****************************************************************************/ public TreeMap<String, String> getDenyCreate() { TreeMap<String, String> writeAccesses = new TreeMap<String, String>(); LinkedHashMap<String, String> appInfos = getAppInfos("X_Deny_Create");//$NON-NLS-1$ Set<String> keys = appInfos.keySet(); for (Iterator<String> iter = keys.iterator(); iter.hasNext();) { String key = iter.next(); writeAccesses.put(key, appInfos.get(key)); } return writeAccesses; }