List of usage examples for java.util LinkedHashMap put
V put(K key, V value);
From source file:org.jutge.joc.porra.controller.base.BetController.java
@EntityStashManaged(entities = EntityStashEntityModule.ALL, views = EntityStashViewModule.NONE) @SuppressWarnings({ "rawtypes", "unchecked" }) @RequestMapping(value = "/usuari/aposta-guanyador", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody LinkedHashMap makeWinnerBet(@RequestBody final LinkedHashMap map, final EntityStash entityStash, final HttpServletRequest request, final Locale locale) { this.logger.info("BetController.makeWinnerBet"); final LinkedHashMap response = new LinkedHashMap(); try {/*from w ww .j a v a 2 s . c om*/ final WinnerBet bet = (WinnerBet) this.createBetInstance(map, entityStash, locale); this.betService.newWinnerBet(bet, entityStash); this.createResponse(response, entityStash, locale); } catch (final BetException exception) { response.put("errors", exception.getErrorMessages()); } return response; }
From source file:com.itemanalysis.psychometrics.irt.equating.MeanSigmaMethodTest.java
/** * Tests the calculations needed for mean/mean and mean/sigma scale linking. * Item parameters and true values obtained from example 2 from the STUIRT * program by Michael Kolen and colleagues. Note that the original example * used teh PARSCALE version of item parameters. These were converted to * ICL type parameters by subtracting a step from the item difficulty. * *//*w w w . j ava2s .c o m*/ @Test public void mixedFormatMeanSigmaTest() { System.out.println("Mixed format mean/sigma test"); LinkedHashMap<String, ItemResponseModel> itemFormX = new LinkedHashMap<String, ItemResponseModel>(); LinkedHashMap<String, ItemResponseModel> itemFormY = new LinkedHashMap<String, ItemResponseModel>(); itemFormX.put("Item1", new Irm3PL(0.751335, -0.897391, 0.244001, 1.7)); itemFormX.put("Item2", new Irm3PL(0.955947, -0.811477, 0.242883, 1.7)); itemFormX.put("Item3", new Irm3PL(0.497206, -0.858681, 0.260893, 1.7)); itemFormX.put("Item4", new Irm3PL(0.724000, -0.123911, 0.243497, 1.7)); itemFormX.put("Item5", new Irm3PL(0.865200, 0.205889, 0.319135, 1.7)); itemFormX.put("Item6", new Irm3PL(0.658129, 0.555228, 0.277826, 1.7)); itemFormX.put("Item7", new Irm3PL(1.082118, 0.950549, 0.157979, 1.7)); itemFormX.put("Item8", new Irm3PL(0.988294, 1.377501, 0.084828, 1.7)); itemFormX.put("Item9", new Irm3PL(1.248923, 1.614355, 0.181874, 1.7)); itemFormX.put("Item10", new Irm3PL(1.116682, 2.353932, 0.246856, 1.7)); itemFormX.put("Item11", new Irm3PL(0.438171, 3.217965, 0.309243, 1.7)); itemFormX.put("Item12", new Irm3PL(1.082206, 4.441864, 0.192339, 1.7)); double[] step1 = { 0, -1.09327, 1.101266 }; itemFormX.put("Item13", new IrmGPCM(0.269994, step1, 1.7)); double[] step2 = { 0, 1.526148, 1.739176 }; itemFormX.put("Item14", new IrmGPCM(0.972506, step2, 1.7)); double[] step3 = { 0, 1.362356, 5.566958 }; itemFormX.put("Item15", new IrmGPCM(0.378812, step3, 1.7)); double[] step4 = { 0, 1.486566, -0.071229, 1.614823 }; itemFormX.put("Item16", new IrmGPCM(0.537706, step4, 1.7)); double[] step5 = { 0, 1.425413, 2.630705, 3.242696 }; itemFormX.put("Item17", new IrmGPCM(0.554506, step5, 1.7)); itemFormY.put("Item1", new Irm3PL(0.887276, -1.334798, 0.134406, 1.7)); itemFormY.put("Item2", new Irm3PL(1.184412, -1.129004, 0.237765, 1.7)); itemFormY.put("Item3", new Irm3PL(0.609412, -1.464546, 0.15139, 1.7)); itemFormY.put("Item4", new Irm3PL(0.923812, -0.576435, 0.240097, 1.7)); itemFormY.put("Item5", new Irm3PL(0.822776, -0.476357, 0.192369, 1.7)); itemFormY.put("Item6", new Irm3PL(0.707818, -0.235189, 0.189557, 1.7)); itemFormY.put("Item7", new Irm3PL(1.306976, 0.242986, 0.165553, 1.7)); itemFormY.put("Item8", new Irm3PL(1.295471, 0.598029, 0.090557, 1.7)); itemFormY.put("Item9", new Irm3PL(1.366841, 0.923206, 0.172993, 1.7)); itemFormY.put("Item10", new Irm3PL(1.389624, 1.380666, 0.238008, 1.7)); itemFormY.put("Item11", new Irm3PL(0.293806, 2.02807, 0.203448, 1.7)); itemFormY.put("Item12", new Irm3PL(0.885347, 3.152928, 0.195473, 1.7)); double[] step1y = { 0, -1.387347, 0.399117 }; itemFormY.put("Item13", new IrmGPCM(0.346324, step1y, 1.7)); double[] step2y = { 0, 0.756514, 0.956014 }; itemFormY.put("Item14", new IrmGPCM(1.252012, step2y, 1.7)); double[] step3y = { 0, 0.975303, 4.676299 }; itemFormY.put("Item15", new IrmGPCM(0.392282, step3y, 1.7)); double[] step4y = { 0, 0.643405, -0.418869, 0.804394 }; itemFormY.put("Item16", new IrmGPCM(0.660841, step4y, 1.7)); double[] step5y = { 0, 0.641293, 1.750488, 2.53802 }; itemFormY.put("Item17", new IrmGPCM(0.669612, step5y, 1.7)); MeanSigmaMethod meanSigmaMethod = new MeanSigmaMethod(itemFormX, itemFormY, true); meanSigmaMethod.setPrecision(6); double B = meanSigmaMethod.getIntercept(); double A = meanSigmaMethod.getScale(); // System.out.println("Slope: " + A); // System.out.println("Intercept: " + B); assertEquals("Mean/sigma slope test", 0.887294, A, 1e-6); assertEquals("Mean/sigma intercept test", -0.560159, B, 1e-6); }
From source file:org.jutge.joc.porra.controller.base.BetController.java
@EntityStashManaged(entities = EntityStashEntityModule.ALL, views = EntityStashViewModule.NONE) @SuppressWarnings({ "rawtypes", "unchecked" }) @RequestMapping(value = "/usuari/aposta/tipus/rondes/kudos/{kudos}/jugador/{jugador}/rondes/{rondes}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody LinkedHashMap getRoundsBetRate(@PathVariable final Integer kudos, @PathVariable final String jugador, @PathVariable final Integer rondes, final EntityStash entityStash, final HttpServletRequest request) { this.logger.info("BetController.getRoundsBetRate"); final LinkedHashMap response = new LinkedHashMap(); try {//from w ww . j ava 2 s.c o m final RoundsBet roundsBet = this.createRoundsBetInstance(kudos, jugador, rondes, entityStash); final double betRate = this.betService.getBetRate(roundsBet, entityStash); final String formattedeRate = BetUtils.formatDouble(betRate); response.put("rate", formattedeRate); } catch (final BetException exception) { response.put("errors", exception.getErrorMessages()); } return response; }
From source file:com.amsoftgroup.geospatial.dc.business.EntityResolver.java
private LinkedHashMap<String, String> ParseHotels(int gid) { LinkedHashMap<String, String> hm = new LinkedHashMap<String, String>(); try {/*w ww . ja v a2s . com*/ if (json.isNull("hotels")) { Log.e(TAG, "ParseHotels(" + gid + ") failed to return results."); hm.put("Could not retrieve results:", " unexpected value returned."); } else if (json.get("hotels").getClass().equals(JSONObject.class)) { JSONObject jsonLineItem = json.getJSONObject("hotels"); if (!jsonLineItem.isNull("name")) { hm.put("Title: ", jsonLineItem.getString("name")); } if (!jsonLineItem.isNull("numrooms")) { hm.put("Number of Rooms: ", jsonLineItem.getString("numrooms")); } if (!jsonLineItem.isNull("phone")) { hm.put("Phone: ", jsonLineItem.getString("phone")); } if (!jsonLineItem.isNull("address")) { hm.put("Address: ", jsonLineItem.getString("address")); } if (!jsonLineItem.isNull("zip")) { hm.put("Zip Code: ", jsonLineItem.getString("zip")); } if (!jsonLineItem.isNull("webUrl")) { hm.put("Website: ", jsonLineItem.getString("webUrl")); } } else { Log.e(TAG, "ParseHotels(" + gid + ") returned unexpected results."); } } catch (Exception e) { Log.e(TAG, e.getMessage()); } return hm; }
From source file:com.amsoftgroup.geospatial.dc.business.EntityResolver.java
private LinkedHashMap<String, String> ParseLibraries(int gid) { LinkedHashMap<String, String> hm = new LinkedHashMap<String, String>(); try {/*www . j av a 2 s. c o m*/ if (json.isNull("libraries")) { Log.e(TAG, "ParseLibraries(" + gid + ") failed to return results."); hm.put("Could not retrieve results:", " unexpected value returned."); } else if (json.get("libraries").getClass().equals(JSONObject.class)) { JSONObject jsonLineItem = json.getJSONObject("libraries"); if (!jsonLineItem.isNull("name")) { hm.put("Title: ", jsonLineItem.getString("name")); } if (!jsonLineItem.isNull("phone")) { hm.put("Phone: ", jsonLineItem.getString("phone")); } if (!jsonLineItem.isNull("address")) { hm.put("Address: ", jsonLineItem.getString("address")); } if (!jsonLineItem.isNull("webUrl")) { hm.put("Website: ", jsonLineItem.getString("webUrl")); } } else { Log.e(TAG, "ParseLibraries(" + gid + ") returned unexpected results."); } } catch (Exception e) { Log.e(TAG, e.getMessage()); } return hm; }
From source file:com.base2.kagura.core.report.connectors.FreemarkerSQLDataReportConnector.java
/** * Returns a preparedStatement result into a List of Maps. Not the most efficient way of storing the values, however * the results should be limited at this stage. * @param rows The result set./*www . j av a2 s. c o m*/ * @return Mapped results. * @throws RuntimeException upon any error, adds values to "errors" */ public List<Map<String, Object>> resultSetToMap(ResultSet rows) { try { List<Map<String, Object>> beans = new ArrayList<Map<String, Object>>(); int columnCount = rows.getMetaData().getColumnCount(); while (rows.next()) { LinkedHashMap<String, Object> bean = new LinkedHashMap<String, Object>(); beans.add(bean); for (int i = 0; i < columnCount; i++) { Object object = rows.getObject(i + 1); String columnLabel = rows.getMetaData().getColumnLabel(i + 1); String columnName = rows.getMetaData().getColumnName(i + 1); bean.put(StringUtils.defaultIfEmpty(columnLabel, columnName), object != null ? object.toString() : ""); } } return beans; } catch (Exception ex) { errors.add(ex.getMessage()); throw new RuntimeException(ex); } }
From source file:com.amsoftgroup.geospatial.dc.business.EntityResolver.java
private LinkedHashMap<String, String> ParseHospitals(int gid) { LinkedHashMap<String, String> hm = new LinkedHashMap<String, String>(); try {// ww w. j a v a 2s. c o m if (json.isNull("hospitals")) { Log.e(TAG, "ParseHospitals(" + gid + ") failed to return results."); hm.put("Could not retrieve results", "unexpected value returned."); } else if (json.get("hospitals").getClass().equals(JSONObject.class)) { JSONObject jsonLineItem = json.getJSONObject("hospitals"); hm.put("DATA MAY BE INCORRECT ", "PLEASE EXIT THIS APP AND CALL 911 FOR EMERGENCIES!"); hm.put("", ""); if (!jsonLineItem.isNull("name")) { hm.put("Title: ", jsonLineItem.getString("name")); } if (!jsonLineItem.isNull("address")) { hm.put("Address: ", jsonLineItem.getString("address")); } if (!jsonLineItem.isNull("webUrl")) { hm.put("Website: ", jsonLineItem.getString("webUrl")); } if (!jsonLineItem.isNull("type")) { hm.put("Type: ", jsonLineItem.getString("type")); } } else { Log.e(TAG, "ParseHospitals(" + gid + ") returned unexpected results."); } } catch (Exception e) { Log.e(TAG, e.getMessage()); } return hm; }
From source file:com.amsoftgroup.geospatial.dc.business.EntityResolver.java
private LinkedHashMap<String, String> ParsePostoffice(int gid) { LinkedHashMap<String, String> hm = new LinkedHashMap<String, String>(); try {//from www . j a v a 2 s. com if (json.isNull("postoffice")) { Log.e(TAG, "ParsePostoffice(" + gid + ") failed to return results."); hm.put("Could not retrieve results:", " unexpected value returned."); } else if (json.get("postoffice").getClass().equals(JSONObject.class)) { JSONObject jsonLineItem = json.getJSONObject("postoffice"); if (!jsonLineItem.isNull("name")) { hm.put("Title: ", jsonLineItem.getString("name")); } if (!jsonLineItem.isNull("phone")) { hm.put("Phone: ", jsonLineItem.getString("phone")); } if (!jsonLineItem.isNull("address")) { hm.put("Address: ", jsonLineItem.getString("address")); } if (!jsonLineItem.isNull("webUrl")) { hm.put("Website: ", jsonLineItem.getString("webUrl")); } } else { Log.e(TAG, "ParsePostoffice(" + gid + ") returned unexpected results."); } } catch (Exception e) { Log.e(TAG, e.getMessage()); } return hm; }
From source file:com.dianping.wed.cache.redis.biz.WeddingRedisMonitorServiceImpl.java
@Override public LinkedHashMap<String, String> info(String ipPort) { Jedis jedis = jedisFactory.getByIPPort(ipPort); if (jedis == null) { return null; }/*from w w w . ja v a 2s . c om*/ try { Object redisMacheInfo = jedis.eval("return redis.call(\"info\")"); LinkedHashMap<String, String> infoMap = new LinkedHashMap<String, String>(); if (redisMacheInfo != null) { String[] infoArray = redisMacheInfo.toString().split("\n"); for (String inf : infoArray) { if (StringUtils.isEmpty(inf)) { continue; } String[] kv = inf.split(":"); if (kv.length != 2) { continue; } //??? infoMap.put(kv[0].replace("\r", "").replace("\n", ""), kv[1].replace("\r", "").replace("\n", "")); } } return infoMap; } finally { jedis.close(); } }