List of usage examples for java.util LinkedHashMap keySet
public Set<K> keySet()
From source file:org.kutkaitis.timetable2.timetable.OptimizationResultsBean.java
private int calculateMoreThanSevenLecturesPerDay() { int penaltyPoints = 0; List<LinkedHashMap> teachersAllDay = getAllDaysTeacherTimeTable(); days: for (LinkedHashMap<String, LinkedHashMap> daysTimeTable : teachersAllDay) { Collection<String> teacherNames = daysTimeTable.keySet(); for (String teacherName : teacherNames) { LinkedHashMap<String, String> teachersTimeTableForTheDay = daysTimeTable.get(teacherName); Collection<String> lectureNumbers = teachersTimeTableForTheDay.keySet(); int lectureNumbersSize = lectureNumbers.size(); if (lectureNumbersSize > 7) { penaltyPoints += PenaltyPoints.MORE_THAN_SEVEN_LECTURES_PER_DAY.penaltyPoints(); continue days; }/* w ww.j a v a2s.c o m*/ } } return penaltyPoints; }
From source file:com.fortify.processrunner.common.processor.AbstractProcessorUpdateIssueStateForVulnerabilities.java
/** * Process the current group of vulnerabilities (grouped by bug tracker deep link) to update the corresponding * previously submitted issue. This includes updating issue fields, re-opening issues if they have been closed * but there are open vulnerabilities, and closing issues if they are open but no open vulnerabilities are remaining. *///from w w w .j a v a2 s . c om @Override protected boolean processMap(Context context, List<Object> vulnerabilities, LinkedHashMap<String, Object> map) { SubmittedIssue submittedIssue = getSubmittedIssue(vulnerabilities.get(0)); String fieldNames = map.keySet().toString(); if (map != null && !map.isEmpty() && updateIssueFields(context, submittedIssue, map)) { LOG.info(String.format("[%s] Updated field(s) %s for issue %s", getBugTrackerName(), fieldNames, submittedIssue.getDeepLink())); } if (hasOpenVulnerabilities(vulnerabilities)) { if (openIssueIfClosed(context, submittedIssue)) { LOG.info(String.format("[%s] Re-opened issue %s", getBugTrackerName(), submittedIssue.getDeepLink())); } } else { if (closeIssueIfOpen(context, submittedIssue)) { LOG.info(String.format("[%s] Closed issue %s", getBugTrackerName(), submittedIssue.getDeepLink())); } } if (vulnerabilityUpdater != null) { vulnerabilityUpdater.updateVulnerabilityStateForExistingIssue(context, getBugTrackerName(), submittedIssue, getIssueStateDetailsRetriever(), vulnerabilities); } return true; }
From source file:com.allinfinance.dwr.system.SelectOptionsDWR.java
/** *@ ? /*from w w w . j a v a2s.c o m*/ **/ public String loadSecMchtdataData(String mchtNoId) { String jsonData = "{data:[{'mchtNm':'','mchtMCC':'','mchtFeeRate':''}]}"; try { log.info("mchtNoId=" + mchtNoId); Object[] params = new Object[1]; params[0] = mchtNoId; LinkedHashMap<String, String> dataMap = SelectMethod.getMchtData(params); Iterator<String> iter = dataMap.keySet().iterator(); if (iter.hasNext()) { Map<String, Object> jsonDataMap = new HashMap<String, Object>(); LinkedList<Object> jsonDataList = new LinkedList<Object>(); Map<String, String> tmpMap = null; String key = null; while (iter.hasNext()) { tmpMap = new LinkedHashMap<String, String>(); key = iter.next(); if (key.equals("mchtNm")) { tmpMap.put("mchtNm", dataMap.get(key)); } else if (key == "mchtMCC") { tmpMap.put("mchtMCC", dataMap.get(key)); } else if (key == "mchtFeeRate") { tmpMap.put("mchtFeeRate", dataMap.get(key)); } jsonDataList.add(tmpMap); } jsonDataMap.put("data", jsonDataList); jsonData = JSONBean.genMapToJSON(jsonDataMap); // System.out.println(jsonData); } } catch (Exception e) { e.printStackTrace(); log.error(e.getMessage()); } return jsonData; }
From source file:org.kutkaitis.timetable2.timetable.OptimizationResultsBean.java
private int calculateLectureDidacticsPenalties() { int penaltyPoints = 0; List<LinkedHashMap> teachersAllDay = getAllDaysTeacherTimeTable(); for (LinkedHashMap<String, LinkedHashMap> daysTimeTable : teachersAllDay) { Collection<String> teacherNames = daysTimeTable.keySet(); for (String teacherName : teacherNames) { LinkedHashMap<String, String> teachersTimeTableForTheDay = daysTimeTable.get(teacherName); Collection<String> lectureNumbers = teachersTimeTableForTheDay.keySet(); List<String> groupsListforCheck = new ArrayList<>(); for (String lectureNumber : lectureNumbers) { String groupName = teachersTimeTableForTheDay.get(lectureNumber).split(":")[1].trim(); if (!StringUtils.equals(groupName, EMPTY_GROUP)) { if (groupsListforCheck.contains(groupName)) { penaltyPoints += PenaltyPoints.BAD_LECTURES_DIDACTICS.penaltyPoints(); }//from www .j a v a2 s .com groupsListforCheck.add(groupName); } } } } return penaltyPoints; }
From source file:com.allinfinance.dwr.system.SelectOptionsDWR.java
/** *@ ? /*from w w w . j a va2 s.c om*/ **/ public String loadFirMchtdataData(String firMchtNoId) { String jsonData = "{data:[{'firMchtNm':'','firstTermNomber':'','firstMccNo':'','firstMchtFeeRate':''}]}"; try { log.info("firMchtNoId=" + firMchtNoId); Object[] params = new Object[1]; params[0] = firMchtNoId; LinkedHashMap<String, String> dataMap = SelectMethod.getFirMchtData(params); Iterator<String> iter = dataMap.keySet().iterator(); if (iter.hasNext()) { Map<String, Object> jsonDataMap = new HashMap<String, Object>(); LinkedList<Object> jsonDataList = new LinkedList<Object>(); Map<String, String> tmpMap = null; String key = null; while (iter.hasNext()) { tmpMap = new LinkedHashMap<String, String>(); key = iter.next(); if (key.equals("firMchtNm")) { tmpMap.put("firMchtNm", dataMap.get(key)); } else if (key == "firstTermNomber") { tmpMap.put("firstTermNomber", dataMap.get(key)); } else if (key == "firstMccNo") { tmpMap.put("firstMccNo", dataMap.get(key)); } else if (key == "firstMchtFeeRate") { tmpMap.put("firstMchtFeeRate", dataMap.get(key)); } jsonDataList.add(tmpMap); } jsonDataMap.put("data", jsonDataList); jsonData = JSONBean.genMapToJSON(jsonDataMap); // System.out.println(jsonData); } } catch (Exception e) { e.printStackTrace(); log.error(e.getMessage()); } return jsonData; }
From source file:com.sapito.db.dao.AbstractDao.java
/** * Obtiene todos los registros para una entidad dada ordenados con los * criterios establecidos a traves de la lista <code>ordering</code> * /*w w w .j ava2s.co m*/ * @param ordering : ["fieldName", "ASC" | "DESC"] <br> * (if != "ASC" se utiliza "DESC" por default) * * @return Registros recuperados ordenados mediante los criterios dados */ public List<T> findAll(LinkedHashMap<String, String> ordering) { CriteriaQuery cq = entityManager.getCriteriaBuilder().createQuery(); Root<T> root = cq.from(entityClass); cq.select(root); if (ordering != null) { CriteriaBuilder cb = entityManager.getCriteriaBuilder(); Set<String> set = ordering.keySet(); List<Order> orders = new ArrayList<>(); for (String orderingField : set) { Order order = (ordering.get(orderingField).equals("ASC")) ? cb.asc(root.get(orderingField)) : cb.desc(root.get(orderingField)); orders.add(order); } cq.orderBy(orders); } return entityManager.createQuery(cq).setMaxResults(MAX_RECORDS_RETURNED).getResultList(); }
From source file:com.allinfinance.dwr.system.SelectOptionsDWR.java
/** * ??/*from w ww . j av a2 s . co m*/ * @param txnId * @return */ public String getComboData(String txnId, HttpServletRequest request, HttpServletResponse response) { String jsonData = "{data:[{'valueField':'','displayField':'?'}]}"; try { //?? Operator operator = (Operator) request.getSession().getAttribute(Constants.OPERATOR_INFO); LinkedHashMap<String, String> dataMap = SelectOption.getSelectView(txnId, new Object[] { operator }); Iterator<String> iter = dataMap.keySet().iterator(); if (iter.hasNext()) { Map<String, Object> jsonDataMap = new HashMap<String, Object>(); LinkedList<Object> jsonDataList = new LinkedList<Object>(); Map<String, String> tmpMap = null; String key = null; while (iter.hasNext()) { tmpMap = new LinkedHashMap<String, String>(); key = iter.next(); tmpMap.put("valueField", key); tmpMap.put("displayField", dataMap.get(key)); jsonDataList.add(tmpMap); } jsonDataMap.put("data", jsonDataList); jsonData = JSONBean.genMapToJSON(jsonDataMap); } } catch (Exception e) { e.printStackTrace(); log.error(e.getMessage()); } return jsonData; }
From source file:com.allinfinance.dwr.system.SelectOptionsDWR.java
/** * ??// w w w.j a v a 2 s . c o m * @param txnId * @param request * @param response * @return * 2010-8-18?11:36:58 */ public String getFuncAllData(String txnId, HttpServletRequest request, HttpServletResponse response) { String jsonData = "{data:[{'valueField':'','displayField':'?'}]}"; try { //?? Operator operator = (Operator) request.getSession().getAttribute(Constants.OPERATOR_INFO); LinkedHashMap<String, String> dataMap = SelectOption.getSelectView(txnId, new Object[] { operator }); Iterator<String> iter = dataMap.keySet().iterator(); if (iter.hasNext()) { Map<String, Object> jsonDataMap = new HashMap<String, Object>(); LinkedList<Object> jsonDataList = new LinkedList<Object>(); Map<String, String> tmpMap = null; String key = null; while (iter.hasNext()) { tmpMap = new LinkedHashMap<String, String>(); key = iter.next(); tmpMap.put("valueField", key); tmpMap.put("displayField", dataMap.get(key)); jsonDataList.add(tmpMap); } jsonDataMap.put("data", jsonDataList); jsonData = JSONBean.genMapToJSON(jsonDataMap); } } catch (Exception e) { e.printStackTrace(); log.error(e.getMessage()); } return jsonData; }
From source file:eu.supersede.gr.utility.PointsLogic.java
private void computePoints() { List<HAHPGamePlayerPoint> gamesPlayersPoints = gamesPlayersPointsRepository.findAll(); // cycle on every gamesPlayersPoints for (int i = 0; i < gamesPlayersPoints.size(); i++) { HAHPGame g = gamesRepository.findOne(gamesPlayersPoints.get(i).getGame().getGameId()); // set currentPlayer that is used for other methods g.setCurrentPlayer(gamesPlayersPoints.get(i).getUser()); List<HAHPCriteriasMatrixData> criteriasMatrixDataList = criteriaMatricesRepository.findByGame(g); // calculate the agreementIndex for every gamesPlayersPoints of a game and a specific user Map<String, Double> resultTotal = AHPRest.CalculateAHP(g.getCriterias(), g.getRequirements(), criteriasMatrixDataList, g.getRequirementsMatrixData()); Map<String, Double> resultPersonal = AHPRest.CalculatePersonalAHP( gamesPlayersPoints.get(i).getUser().getUserId(), g.getCriterias(), g.getRequirements(), criteriasMatrixDataList, g.getRequirementsMatrixData()); List<Requirement> gameRequirements = g.getRequirements(); Double sum = 0.0;//from ww w .j a va 2 s . c om for (int j = 0; j < resultTotal.size(); j++) { Double requirementValueTotal = resultTotal .get(gameRequirements.get(j).getRequirementId().toString()); Double requirementValuePersonal = resultPersonal .get(gameRequirements.get(j).getRequirementId().toString()); sum = sum + (Math.abs(requirementValueTotal - requirementValuePersonal) * (1.0 - requirementValueTotal)); } Double agreementIndex = M - (M * sum); gamesPlayersPoints.get(i).setAgreementIndex(agreementIndex.longValue()); // calculate the positionInVoting for every gamesPlayersPoints of a game and a specific user List<User> players = g.getPlayers(); List<HAHPRequirementsMatrixData> lrmd = requirementsMatricesRepository.findByGame(g); Map<User, Float> gamePlayerVotes = new HashMap<>(); for (User player : players) { Integer total = 0; Integer voted = 0; if (lrmd != null) { for (HAHPRequirementsMatrixData data : lrmd) { for (HAHPPlayerMove pm : data.getPlayerMoves()) { if (pm.getPlayer().getUserId().equals(player.getUserId())) { total++; if (pm.getPlayed() == true && pm.getValue() != null && !pm.getValue().equals(-1l)) { voted++; } } } } } gamePlayerVotes.put(player, total.equals(0) ? 0f : ((new Float(voted) / new Float(total)) * 100)); } LinkedHashMap<User, Float> orderedList = sortHashMapByValues(gamePlayerVotes); List<User> indexes = new ArrayList<>(orderedList.keySet()); Integer index = indexes.indexOf(gamesPlayersPoints.get(i).getUser()); Double positionInVoting = (orderedList.size() - (new Double(index) + 1.0)) + 1.0; gamesPlayersPoints.get(i).setPositionInVoting(positionInVoting.longValue()); // calculate the virtualPosition of a user base on his/her points in a particular game HAHPGamePlayerPoint gpp = gamesPlayersPointsRepository .findByUserAndGame(gamesPlayersPoints.get(i).getUser(), g); List<HAHPGamePlayerPoint> specificGamePlayersPoints = gamesPlayersPointsRepository.findByGame(g); Collections.sort(specificGamePlayersPoints, new CustomComparator()); Long virtualPosition = specificGamePlayersPoints.indexOf(gpp) + 1l; gamesPlayersPoints.get(i).setVirtualPosition(virtualPosition); Long movesPoints = 0l; Long gameProgressPoints = 0l; Long positionInVotingPoints = 0l; Long gameStatusPoints = 0l; Long agreementIndexPoints = 0l; Long totalPoints = 0l; // set the movesPoints movesPoints = g.getMovesDone().longValue(); // setGameProgressPoints gameProgressPoints = (long) Math.floor(g.getPlayerProgress() / 10); // setPositionInVotingPoints if (positionInVoting == 1) { positionInVotingPoints = 5l; } else if (positionInVoting == 2) { positionInVotingPoints = 3l; } else if (positionInVoting == 3) { positionInVotingPoints = 2l; } // setGameStatusPoints if (g.getPlayerProgress() != 100) { gameStatusPoints = -20l; } else { gameStatusPoints = 0l; } // set AgreementIndexPoints agreementIndexPoints = agreementIndex.longValue(); totalPoints = movesPoints.longValue() + gameProgressPoints + positionInVotingPoints + gameStatusPoints + agreementIndexPoints; // set totalPoints 0 if the totalPoints are negative if (totalPoints < 0) { totalPoints = 0l; } gamesPlayersPoints.get(i).setPoints(totalPoints); gamesPlayersPointsRepository.save(gamesPlayersPoints.get(i)); } System.out.println("Finished computing votes"); }
From source file:com.grarak.kerneladiutor.utils.database.ProfileDB.java
public void putProfile(String name, LinkedHashMap<String, String> commands) { try {/*from w w w . j av a 2 s.c om*/ JSONObject items = new JSONObject(); items.put("name", name); JSONArray commandArray = new JSONArray(); for (int i = 0; i < commands.size(); i++) { JSONObject item = new JSONObject(); item.put("path", commands.keySet().toArray()[i]); item.put("command", commands.values().toArray()[i]); commandArray.put(item); } items.put("commands", commandArray); items.put("id", UUID.randomUUID()); putItem(items); } catch (JSONException e) { e.printStackTrace(); } }