List of usage examples for java.util HashMap containsValue
public boolean containsValue(Object value)
From source file:org.kuali.coeus.common.budget.impl.struts.BudgetPersonnelBudgetAction.java
public ActionForward deleteBudgetPersonnelDetails(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { BudgetForm budgetForm = (BudgetForm) form; Budget budget = budgetForm.getBudget(); int selectedBudgetPeriodIndex = budgetForm.getViewBudgetPeriod() - 1; int selectedBudgetLineItemIndex = budgetForm.getSelectedBudgetLineItemIndex(); BudgetPersonnelBudgetService budgetPersonnelBudgetService = KcServiceLocator .getService(BudgetPersonnelBudgetService.class); budgetPersonnelBudgetService.deleteBudgetPersonnelDetails(budget, selectedBudgetPeriodIndex, selectedBudgetLineItemIndex, getLineToDelete(request)); HashMap uniqueBudgetPersonnelCount = new HashMap(); int qty = 0;//from www .j ava 2s .c o m for (BudgetPersonnelDetails budgetPersonnelDetails : budget.getBudgetPeriod(selectedBudgetPeriodIndex) .getBudgetLineItem(selectedBudgetLineItemIndex).getBudgetPersonnelDetailsList()) { if (!uniqueBudgetPersonnelCount.containsValue(budgetPersonnelDetails.getPersonId())) { uniqueBudgetPersonnelCount.put(qty, budgetPersonnelDetails.getPersonId()); qty = qty + 1; } } budget.getBudgetPeriod(selectedBudgetPeriodIndex).getBudgetLineItem(selectedBudgetLineItemIndex) .setQuantity(new Integer(qty)); getCalculationService().calculateBudgetPeriod(budget, budget.getBudgetPeriod(selectedBudgetPeriodIndex)); return mapping.findForward(Constants.MAPPING_BASIC); }
From source file:org.kuali.kra.budget.web.struts.action.BudgetPersonnelBudgetAction.java
public ActionForward deleteBudgetPersonnelDetails(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { BudgetForm budgetForm = (BudgetForm) form; BudgetDocument budgetDocument = budgetForm.getDocument(); Budget budget = budgetDocument.getBudget(); int selectedBudgetPeriodIndex = budgetForm.getViewBudgetPeriod() - 1; int selectedBudgetLineItemIndex = budgetForm.getSelectedBudgetLineItemIndex(); BudgetPersonnelBudgetService budgetPersonnelBudgetService = KraServiceLocator .getService(BudgetPersonnelBudgetService.class); budgetPersonnelBudgetService.deleteBudgetPersonnelDetails(budget, selectedBudgetPeriodIndex, selectedBudgetLineItemIndex, getLineToDelete(request)); HashMap uniqueBudgetPersonnelCount = new HashMap(); int qty = 0;//from w ww . j a va 2 s. c om for (BudgetPersonnelDetails budgetPersonnelDetails : budget.getBudgetPeriod(selectedBudgetPeriodIndex) .getBudgetLineItem(selectedBudgetLineItemIndex).getBudgetPersonnelDetailsList()) { if (!uniqueBudgetPersonnelCount.containsValue(budgetPersonnelDetails.getPersonId())) { uniqueBudgetPersonnelCount.put(qty, budgetPersonnelDetails.getPersonId()); qty = qty + 1; } } budget.getBudgetPeriod(selectedBudgetPeriodIndex).getBudgetLineItem(selectedBudgetLineItemIndex) .setQuantity(new Integer(qty)); getCalculationService().calculateBudgetPeriod(budget, budget.getBudgetPeriod(selectedBudgetPeriodIndex)); return mapping.findForward(Constants.MAPPING_BASIC); }
From source file:org.kuali.coeus.common.budget.impl.struts.BudgetPersonnelBudgetAction.java
/** * This method is used to add a new Budget Line Item * @param mapping//from w w w .ja v a 2 s . c o m * @param form * @param request * @param response * @return mapping forward * @throws Exception */ public ActionForward addBudgetPersonnelDetails(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { BudgetForm budgetForm = (BudgetForm) form; Budget budget = budgetForm.getBudget(); int selectedBudgetPeriodIndex = budgetForm.getViewBudgetPeriod() - 1; int selectedBudgetLineItemIndex = budgetForm.getSelectedBudgetLineItemIndex(); BudgetPersonnelDetails newBudgetPersonnelDetails = budgetForm.getNewBudgetPersonnelDetails(); boolean errorFound = false; if (newBudgetPersonnelDetails.getPercentEffort().isGreaterThan(new ScaleTwoDecimal(100))) { GlobalVariables.getMessageMap().putError("newBudgetPersonnelDetails.percentEffort", KeyConstants.ERROR_PERCENTAGE, Constants.PERCENT_EFFORT_FIELD); errorFound = true; } if (newBudgetPersonnelDetails.getPercentCharged().isGreaterThan(new ScaleTwoDecimal(100))) { GlobalVariables.getMessageMap().putError("newBudgetPersonnelDetails.percentCharged", KeyConstants.ERROR_PERCENTAGE, Constants.PERCENT_CHARGED_FIELD); errorFound = true; } if (newBudgetPersonnelDetails.getPercentCharged() .isGreaterThan(newBudgetPersonnelDetails.getPercentEffort())) { GlobalVariables.getMessageMap().putError("newBudgetPersonnelDetails.percentCharged", KeyConstants.ERROR_PERCENT_EFFORT_LESS_THAN_PERCENT_CHARGED); errorFound = true; } if (StringUtils.isBlank((budgetForm.getNewBudgetPersonnelDetails().getPeriodTypeCode()))) { GlobalVariables.getMessageMap().putError("newBudgetPersonnelDetails.periodTypeCode", RiceKeyConstants.ERROR_REQUIRED, new String[] { "Period Type (Period Type)" }); errorFound = true; } if (budgetForm.getNewBudgetPersonnelDetails().getPersonSequenceNumber() == null) { GlobalVariables.getMessageMap().putError("newBudgetPersonnelDetails.personSequenceNumber", RiceKeyConstants.ERROR_REQUIRED, new String[] { "Person (Person)" }); errorFound = true; } HashMap uniqueBudgetPersonnelCount = new HashMap(); int qty = 0; if (!errorFound) { BudgetPersonnelBudgetService budgetPersonnelBudgetService = KcServiceLocator .getService(BudgetPersonnelBudgetService.class); for (BudgetPersonnelDetails budgetPersonnelDetails : budget.getBudgetPeriod(selectedBudgetPeriodIndex) .getBudgetLineItem(selectedBudgetLineItemIndex).getBudgetPersonnelDetailsList()) { if (!uniqueBudgetPersonnelCount.containsValue(budgetPersonnelDetails.getPersonId())) { uniqueBudgetPersonnelCount.put(qty, budgetPersonnelDetails.getPersonId()); qty = qty + 1; } } budget.getBudgetPeriod(selectedBudgetPeriodIndex).getBudgetLineItem(selectedBudgetLineItemIndex) .setQuantity(new Integer(qty)); updatePersonnelBudgetRate(budget.getBudgetPeriod(selectedBudgetPeriodIndex) .getBudgetLineItem(selectedBudgetLineItemIndex)); getCalculationService().calculateBudgetPeriod(budget, budget.getBudgetPeriod(selectedBudgetPeriodIndex)); } return mapping.findForward(Constants.MAPPING_BASIC); }
From source file:org.kuali.kra.budget.web.struts.action.BudgetPersonnelBudgetAction.java
/** * This method is used to add a new Budget Line Item * @param mapping/*from ww w .j a v a 2 s .c o m*/ * @param form * @param request * @param response * @return mapping forward * @throws Exception */ public ActionForward addBudgetPersonnelDetails(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { BudgetForm budgetForm = (BudgetForm) form; BudgetDocument budgetDocument = budgetForm.getDocument(); Budget budget = budgetDocument.getBudget(); int selectedBudgetPeriodIndex = budgetForm.getViewBudgetPeriod() - 1; int selectedBudgetLineItemIndex = budgetForm.getSelectedBudgetLineItemIndex(); BudgetPersonnelDetails newBudgetPersonnelDetails = budgetForm.getNewBudgetPersonnelDetails(); boolean errorFound = false; if (newBudgetPersonnelDetails.getPercentEffort().isGreaterThan(new BudgetDecimal(100))) { GlobalVariables.getErrorMap().putError("newBudgetPersonnelDetails.percentEffort", KeyConstants.ERROR_PERCENTAGE, Constants.PERCENT_EFFORT_FIELD); errorFound = true; } if (newBudgetPersonnelDetails.getPercentCharged().isGreaterThan(new BudgetDecimal(100))) { GlobalVariables.getErrorMap().putError("newBudgetPersonnelDetails.percentCharged", KeyConstants.ERROR_PERCENTAGE, Constants.PERCENT_CHARGED_FIELD); errorFound = true; } if (newBudgetPersonnelDetails.getPercentCharged() .isGreaterThan(newBudgetPersonnelDetails.getPercentEffort())) { GlobalVariables.getErrorMap().putError("newBudgetPersonnelDetails.percentCharged", KeyConstants.ERROR_PERCENT_EFFORT_LESS_THAN_PERCENT_CHARGED); errorFound = true; } if (StringUtils.isBlank((budgetForm.getNewBudgetPersonnelDetails().getPeriodTypeCode()))) { GlobalVariables.getErrorMap().putError("newBudgetPersonnelDetails.periodTypeCode", RiceKeyConstants.ERROR_REQUIRED, new String[] { "Period Type (Period Type)" }); errorFound = true; } if (budgetForm.getNewBudgetPersonnelDetails().getPersonSequenceNumber() == null) { GlobalVariables.getErrorMap().putError("newBudgetPersonnelDetails.personSequenceNumber", RiceKeyConstants.ERROR_REQUIRED, new String[] { "Person (Person)" }); errorFound = true; } HashMap uniqueBudgetPersonnelCount = new HashMap(); int qty = 0; if (!errorFound) { BudgetPersonnelBudgetService budgetPersonnelBudgetService = KraServiceLocator .getService(BudgetPersonnelBudgetService.class); for (BudgetPersonnelDetails budgetPersonnelDetails : budget.getBudgetPeriod(selectedBudgetPeriodIndex) .getBudgetLineItem(selectedBudgetLineItemIndex).getBudgetPersonnelDetailsList()) { if (!uniqueBudgetPersonnelCount.containsValue(budgetPersonnelDetails.getPersonId())) { uniqueBudgetPersonnelCount.put(qty, budgetPersonnelDetails.getPersonId()); qty = qty + 1; } } budget.getBudgetPeriod(selectedBudgetPeriodIndex).getBudgetLineItem(selectedBudgetLineItemIndex) .setQuantity(new Integer(qty)); updatePersonnelBudgetRate(budget.getBudgetPeriod(selectedBudgetPeriodIndex) .getBudgetLineItem(selectedBudgetLineItemIndex)); getCalculationService().calculateBudgetPeriod(budget, budget.getBudgetPeriod(selectedBudgetPeriodIndex)); } return mapping.findForward(Constants.MAPPING_BASIC); }
From source file:com.google.gwt.emultest.java.util.HashMapTest.java
public void testContainsValue() { HashMap<String, Integer> hashMap = new HashMap<String, Integer>(); checkEmptyHashMapAssumptions(hashMap); assertFalse("check contains of empty map", hashMap.containsValue(VALUE_TEST_CONTAINS_KEY)); hashMap.put(KEY_TEST_CONTAINS_VALUE, VALUE_TEST_CONTAINS_KEY); assertTrue("check contains of map with element", hashMap.containsValue(VALUE_TEST_CONTAINS_KEY)); assertFalse("check contains of map other element", hashMap.containsValue(VALUE_TEST_CONTAINS_DOES_NOT_EXIST)); assertFalse(hashMap.containsValue(null)); hashMap.put(KEY_TEST_CONTAINS_VALUE, null); assertTrue(hashMap.containsValue(null)); }
From source file:Util.PacketGenerator.java
public void GenerateGraphGnuplot() { try {/* w w w .j a v a 2 s . com*/ for (int j = 6; j <= 6; j++) { File real = new File("D:\\Mestrado\\SketchMatrix\\trunk\\Simulations\\Analise\\Scenario1\\Topology" + j + "\\Real.csv"); for (int k = 1; k <= 4; k++) { File simu = new File( "D:\\Mestrado\\SketchMatrix\\trunk\\Simulations\\Analise\\Scenario1\\Topology" + j + "\\SimulacaoInstancia" + k + ".csv"); File dat = new File( "D:\\Mestrado\\SketchMatrix\\trunk\\Simulations\\Analise\\Scenario1\\Topology" + j + "\\SimulacaoInstancia" + k + ".txt"); FileInputStream simuFIS = new FileInputStream(simu); DataInputStream simuDIS = new DataInputStream(simuFIS); BufferedReader simuBR = new BufferedReader(new InputStreamReader(simuDIS)); FileInputStream realFIS = new FileInputStream(real); DataInputStream realDIS = new DataInputStream(realFIS); BufferedReader realBR = new BufferedReader(new InputStreamReader(realDIS)); PrintWriter datPW = new PrintWriter(dat); String lineSimu = simuBR.readLine(); String lineReal = realBR.readLine(); double maxX = 0.0; double maxY = 0.0; HashMap<Double, Double> map = new HashMap<>(); while (lineSimu != null && lineReal != null) { lineSimu = lineSimu.replaceAll(",", "."); String[] simuMatriz = lineSimu.split(";"); String[] realMatriz = lineReal.split(";"); for (int i = 0; i < simuMatriz.length; i++) { try { Integer valorReal = Integer.parseInt(realMatriz[i]); Double valorSimu = Double.parseDouble(simuMatriz[i]); if (map.containsKey(valorReal) && map.containsValue(valorSimu)) { continue; } map.put(valorReal.doubleValue(), valorSimu); datPW.write(valorReal.doubleValue() + "\t"); datPW.write(valorReal.doubleValue() + "\t"); datPW.write(valorSimu.doubleValue() + "\t"); datPW.write(valorReal.doubleValue() * 1.2 + "\t"); datPW.write(valorReal.doubleValue() * 0.8 + "\n"); if (valorReal > maxX) { maxX = valorReal; } if (valorSimu > maxY) { maxY = valorSimu; } } catch (NumberFormatException ex) { } } lineSimu = simuBR.readLine(); lineReal = realBR.readLine(); } simuFIS.close(); simuDIS.close(); simuBR.close(); realFIS.close(); realDIS.close(); realBR.close(); datPW.close(); Double max = Math.max(maxX, maxY); max *= 1.05; Process p = Runtime.getRuntime().exec("cmd"); new Thread(new SyncPipe(p.getErrorStream(), System.err)).start(); new Thread(new SyncPipe(p.getInputStream(), System.out)).start(); PrintWriter stdin = new PrintWriter(p.getOutputStream()); stdin.println("gnuplot"); stdin.println("cd 'D:\\Mestrado\\SketchMatrix\\trunk\\Simulations\\Analise\\Scenario1\\Topology" + j + "'"); stdin.println("set terminal postscript eps enhanced \"Times\" 20"); stdin.println("set output \"SimulacaoInstancia" + k + ".eps\""); stdin.println("unset title"); stdin.println("unset style line"); stdin.println("set style line 1 pt 7 lc 7 lw 1"); stdin.println("set style line 2 lt 1 lc 7 lw 1"); stdin.println("set style line 3 lt 4 lc 7 lw 1"); stdin.println("set style line 4 lt 4 lc 7 lw 1"); stdin.println("set style line 5 lt 5 lc 5 lw 3"); stdin.println("set style line 6 lt 6 lc 6 lw 3"); stdin.println("set style line 7 pt 7 lc 7 lw 3"); if (k == 4) { stdin.println("set ylabel \"CMO-MT\""); stdin.println("set xlabel \"Real\""); } else { stdin.println("set ylabel \"Zhao\""); stdin.println("set xlabel \"CMO-MT\""); } stdin.println("set key top left"); stdin.println("set xrange [0:" + max.intValue() + "]"); stdin.println("set yrange [0:" + max.intValue() + "]"); stdin.println("set grid ytics lc rgb \"#bbbbbb\" lw 1 lt 0"); stdin.println("set grid xtics lc rgb \"#bbbbbb\" lw 1 lt 0"); stdin.println("plot " + "x title \"Referencia\" ls 2," + "\"SimulacaoInstancia" + k + ".txt\" using 1:3 title \"Matriz\" ls 7," + "1.2*x title \"Superior 20%\" ls 4," + "0.8*x title \"Inferior 20%\" ls 4"); stdin.println("exit"); stdin.println("exit"); // write any other commands you want here stdin.close(); int returnCode = p.waitFor(); System.out.println("Return code = " + returnCode); } } } catch (Exception e) { e.printStackTrace(); } }
From source file:org.apache.ranger.biz.AssetMgr.java
@SuppressWarnings("unchecked") private HashMap<String, Object> populatePermMap(VXResource xResource, HashMap<String, Object> resourceMap, int assetType) { List<VXPermMap> xPermMapList = xResource.getPermMapList(); Set<Long> groupList = new HashSet<Long>(); for (VXPermMap xPermMap : xPermMapList) { groupList.add(xPermMap.getId()); }// w w w.j ava 2s . co m List<HashMap<String, Object>> sortedPermMapGroupList = new ArrayList<HashMap<String, Object>>(); // Loop for adding group perms for (VXPermMap xPermMap : xPermMapList) { String groupKey = xPermMap.getPermGroup(); if (groupKey != null) { boolean found = false; for (HashMap<String, Object> sortedPermMap : sortedPermMapGroupList) { if (sortedPermMap.containsValue(groupKey)) { found = true; Long groupId = xPermMap.getGroupId(); Long userId = xPermMap.getUserId(); if (groupId != null) { Set<String> groups = (Set<String>) sortedPermMap.get("groups"); if (groups != null) { groups.add(xPermMap.getGroupName()); sortedPermMap.put("groups", groups); } } else if (userId != null) { Set<String> users = (Set<String>) sortedPermMap.get("users"); if (users != null) { users.add(xPermMap.getUserName()); sortedPermMap.put("users", users); } } Set<String> access = (Set<String>) sortedPermMap.get("access"); String perm = AppConstants.getLabelFor_XAPermType(xPermMap.getPermType()); access.add(perm); sortedPermMap.put("access", access); } } if (!found) { HashMap<String, Object> sortedPermMap = new HashMap<String, Object>(); sortedPermMap.put("groupKey", xPermMap.getPermGroup()); Set<String> permSet = new HashSet<String>(); String perm = AppConstants.getLabelFor_XAPermType(xPermMap.getPermType()); permSet.add(perm); sortedPermMap.put("access", permSet); if (assetType == AppConstants.ASSET_KNOX) { String[] ipAddrList = new String[0]; if (xPermMap.getIpAddress() != null) { ipAddrList = xPermMap.getIpAddress().split(","); sortedPermMap.put("ipAddress", ipAddrList); } else sortedPermMap.put("ipAddress", ipAddrList); } Long groupId = xPermMap.getGroupId(); Long userId = xPermMap.getUserId(); if (groupId != null) { Set<String> groupSet = new HashSet<String>(); String group = xPermMap.getGroupName(); groupSet.add(group); sortedPermMap.put("groups", groupSet); } else if (userId != null) { Set<String> userSet = new HashSet<String>(); String user = xPermMap.getUserName(); userSet.add(user); sortedPermMap.put("users", userSet); } sortedPermMapGroupList.add(sortedPermMap); } } } for (HashMap<String, Object> sortedPermMap : sortedPermMapGroupList) { sortedPermMap.remove("groupKey"); } for (HashMap<String, Object> sortedPermMap : sortedPermMapGroupList) { sortedPermMap.remove("groupKey"); } resourceMap.put("permission", sortedPermMapGroupList); return resourceMap; }
From source file:com.google.gwt.emultest.java.util.HashMapTest.java
/** * Test method for 'java.util.HashMap.putAll(Map)'. *///from w ww . j a v a2 s . c o m public void testPutAll() { HashMap<String, String> srcMap = new HashMap<String, String>(); checkEmptyHashMapAssumptions(srcMap); srcMap.put(KEY_1, VALUE_1); srcMap.put(KEY_2, VALUE_2); srcMap.put(KEY_3, VALUE_3); // Make sure that the data is copied correctly HashMap<String, String> dstMap = new HashMap<String, String>(); checkEmptyHashMapAssumptions(dstMap); dstMap.putAll(srcMap); assertEquals(srcMap.size(), dstMap.size()); assertTrue(dstMap.containsKey(KEY_1)); assertTrue(dstMap.containsValue(VALUE_1)); assertFalse(dstMap.containsKey(KEY_1.toUpperCase(Locale.ROOT))); assertFalse(dstMap.containsValue(VALUE_1.toUpperCase(Locale.ROOT))); assertTrue(dstMap.containsKey(KEY_2)); assertTrue(dstMap.containsValue(VALUE_2)); assertFalse(dstMap.containsKey(KEY_2.toUpperCase(Locale.ROOT))); assertFalse(dstMap.containsValue(VALUE_2.toUpperCase(Locale.ROOT))); assertTrue(dstMap.containsKey(KEY_3)); assertTrue(dstMap.containsValue(VALUE_3)); assertFalse(dstMap.containsKey(KEY_3.toUpperCase(Locale.ROOT))); assertFalse(dstMap.containsValue(VALUE_3.toUpperCase(Locale.ROOT))); // Check that an empty map does not blow away the contents of the // destination map HashMap<String, String> emptyMap = new HashMap<String, String>(); checkEmptyHashMapAssumptions(emptyMap); dstMap.putAll(emptyMap); assertTrue(dstMap.size() == srcMap.size()); // Check that put all overwrite any existing mapping in the destination map srcMap.put(KEY_1, VALUE_2); srcMap.put(KEY_2, VALUE_3); srcMap.put(KEY_3, VALUE_1); dstMap.putAll(srcMap); assertEquals(dstMap.size(), srcMap.size()); assertEquals(dstMap.get(KEY_1), VALUE_2); assertEquals(dstMap.get(KEY_2), VALUE_3); assertEquals(dstMap.get(KEY_3), VALUE_1); // Check that a putAll does adds data but does not remove it srcMap.put(KEY_4, VALUE_4); dstMap.putAll(srcMap); assertEquals(dstMap.size(), srcMap.size()); assertTrue(dstMap.containsKey(KEY_4)); assertTrue(dstMap.containsValue(VALUE_4)); assertEquals(dstMap.get(KEY_1), VALUE_2); assertEquals(dstMap.get(KEY_2), VALUE_3); assertEquals(dstMap.get(KEY_3), VALUE_1); assertEquals(dstMap.get(KEY_4), VALUE_4); dstMap.putAll(dstMap); }
From source file:org.kuali.coeus.common.budget.impl.struts.BudgetPersonnelAction.java
private void setLineItemQuantity(BudgetLineItem personnelLineItem) { HashMap uniqueBudgetPersonnelCount = new HashMap(); int qty = 0;/*from www .j a v a 2s . c o m*/ for (BudgetPersonnelDetails budgetPersonnelDetails : personnelLineItem.getBudgetPersonnelDetailsList()) { if (!uniqueBudgetPersonnelCount.containsValue(budgetPersonnelDetails.getPersonId())) { uniqueBudgetPersonnelCount.put(qty, budgetPersonnelDetails.getPersonId()); qty = qty + 1; } } personnelLineItem.setQuantity(new Integer(qty)); }
From source file:parsegui.Window.java
private void buyTicketActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buyTicketActionPerformed int ticketCount = 0; long phone = 0; //eventList.setSelectedItem(evt); String festSelection = (String) eventList.getSelectedItem(); String personName = (String) nameTextField.getText(); String email = (String) mailTextField.getText(); //ParseObject rel = new ParseObject("Attendee"); ParseObject aObj = new ParseObject("Attendee"); try {/*from w w w .j a v a 2 s. c om*/ int length = String.valueOf(phoneTextField.getText()).length(); if (length == 0 || length < 10 || length > 10) { JOptionPane.showConfirmDialog(null, "Please enter a valid 10 digit phone number", "Error", JOptionPane.CLOSED_OPTION); return; } else { phone = Long.parseLong(phoneTextField.getText()); } ticketCount = Integer.parseInt(ticketNoField.getText()); if (ticketCount <= 0) { JOptionPane.showConfirmDialog(null, "Number of tickets should be atleast 1", "Error", JOptionPane.CLOSED_OPTION); return; } } catch (NumberFormatException e) { System.out.println("Exception" + e); JOptionPane.showConfirmDialog(null, "Please fill all the fields", "Error", JOptionPane.CLOSED_OPTION); return; } int b = JOptionPane.showConfirmDialog(null, "Confirm " + ticketCount + " tickets", "Confirm", JOptionPane.OK_CANCEL_OPTION); if (b == 0) { System.out.println("Phone number: " + phone); System.out.println("number of tickets: " + ticketCount); System.out.println("name: " + personName); System.out.println("Email-ID: " + email); System.out.println("festival selected: " + festSelection); aObj.put("Name", personName); aObj.put("PhoneNo", phone); aObj.put("EmailID", email); aObj.put("Tickets_purchased", ticketCount); /* fest selection*/ ParseQuery festquery = new ParseQuery("Festival"); ParseObject festObj = new ParseObject("Festival"); // String id = festObj.getString("Rockathon");// id = null.. should be in loop nd use list/array System.out.println(eventList.getSelectedItem()); //festquery.whereEqualTo(festSelection, festObj.getString("Rockathon")); /* festquery.findInBackground(new FindCallback() { @Override public void done(List<ParseObject> objects, ParseException e) { if(e == null){ System.out.println("QUERRIED ATLAST!!!!"); } else{ System.out.println("NOOOOOOOOOO"); } } });*/ festquery.findInBackground(new FindCallback() { @Override public void done(List<ParseObject> objects, almonds.ParseException e) { if (e == null) { List<ParseObject> res = new ArrayList<>(objects); HashMap<String, String> hm = new HashMap<>(); System.out.println(res.size()); /*for (ParseObject re : res) { System.out.println("IDS: " + re.getString("Festival_name")); }*/ ParseObject re1 = new ParseObject("Festival"); for (ParseObject re : res) { System.out.println("festival name: " + re.getString("Festival_name") + " festivalID : " + re.getObjectId()); ; // n.add(re.getObjectId()); hm.put(re.getObjectId(), re.getString("Festival_name")); } if (hm.containsValue(festSelection)) { for (Map.Entry entry : hm.entrySet()) { if (festSelection.equals(entry.getValue())) { System.out.println("Selected festival key is " + entry.getKey()); } } } } else { System.out.println("error"); } } }); try { aObj.save(); } catch (ParseException ex) { Logger.getLogger(Window.class.getName()).log(Level.SEVERE, null, ex); JOptionPane.showConfirmDialog(null, "ERROR: " + ex, "Error", JOptionPane.OK_CANCEL_OPTION); } } else { return; } System.exit(0); }