List of usage examples for java.util LinkedHashMap get
public V get(Object key)
From source file:jp.primecloud.auto.ui.mock.service.MockInstanceService.java
@Override public List<PlatformDto> getPlatforms(Long userNo) { // ?//from ww w . j a v a2 s. c om List<PlatformDto> dtos = new ArrayList<PlatformDto>(); List<Platform> platforms = XmlDataLoader.getData("platform.xml", Platform.class); LinkedHashMap<Long, ComponentType> componentTypeMap = getComponentTypeMap(); LinkedHashMap<Long, PlatformAws> platformAwsMap = getPlatformAwsMap(); LinkedHashMap<Long, PlatformVmware> platformVmwareMap = getPlatformVmwareMap(); LinkedHashMap<Long, PlatformNifty> platformNiftyMap = getPlatformNiftyMap(); LinkedHashMap<Long, PlatformCloudstack> platformCloudstackMap = getPlatformCloudstackMap(); for (Platform platform : platforms) { List<ImageDto> imageDtos = getImages(platform, componentTypeMap); PlatformDto dto = new PlatformDto(); dto.setPlatform(platform); dto.setPlatformAws(platformAwsMap.get(platform.getPlatformNo())); dto.setPlatformVmware(platformVmwareMap.get(platform.getPlatformNo())); dto.setPlatformNifty(platformNiftyMap.get(platform.getPlatformNo())); dto.setPlatformCloudstack(platformCloudstackMap.get(platform.getPlatformNo())); dto.setImages(imageDtos); dtos.add(dto); } return dtos; }
From source file:org.jutge.joc.porra.controller.base.BetController.java
@SuppressWarnings({ "rawtypes", "unchecked" }) private Bet createBetInstance(final LinkedHashMap map, final EntityStash entityStash, final Locale locale) throws BetException { // Find parameter format errors first final List errorMessages = new ArrayList(); final Bet bet = this.createBetInstanceByType(map, errorMessages, locale); if (bet == null) { final String message = this.messageSource.getMessage("exception.betTypeUnavailable", null, locale); final MessageBox messageBox = new MessageBox("betTypeUnavailable", message, new ArrayList<String>()); errorMessages.add(messageBox);// w ww . j av a 2s .com } // Parameter format validated: fire exception if any errors were found if (!errorMessages.isEmpty()) { throw new BetException(errorMessages); } // proceed with remaining required fields final String playerName = (String) map.get("jugador"); final Player player = entityStash.getPlayer(playerName); if (player != null && bet != null) { bet.setPlayer(playerName); bet.setLeague(player.getLeague()); } if (bet != null) { final Account account = entityStash.getAccount(); bet.setAccount(account.getName()); } return bet; }
From source file:com.chiorichan.database.DatabaseEngine.java
@SuppressWarnings("unchecked") public LinkedHashMap<String, Object> selectOne(String table, Object where) throws SQLException { LinkedHashMap<String, Object> result = select(table, where); if (result == null || result.size() < 1) return null; return (LinkedHashMap<String, Object>) result.get("0"); }
From source file:com.google.gwt.emultest.java.util.LinkedHashMapTest.java
public void testEntrySetRemove() { LinkedHashMap<String, String> hashMap = new LinkedHashMap<String, String>(); hashMap.put("A", "B"); LinkedHashMap<String, String> dummy = new LinkedHashMap<String, String>(); dummy.put("A", "b"); Entry<String, String> bogus = dummy.entrySet().iterator().next(); Set<Entry<String, String>> entrySet = hashMap.entrySet(); boolean removed = entrySet.remove(bogus); assertEquals(removed, false);/*from w w w. j a va 2 s. c o m*/ assertEquals(hashMap.get("A"), "B"); }
From source file:com.evolveum.midpoint.wf.impl.processors.primary.policy.ProcessSpecifications.java
static ProcessSpecifications createFromRules(List<EvaluatedPolicyRule> rules, PrismContext prismContext) throws ObjectNotFoundException { // Step 1: plain list of approval actions -> map: process-spec -> list of related actions/rules ("collected") LinkedHashMap<WfProcessSpecificationType, List<Pair<ApprovalPolicyActionType, EvaluatedPolicyRule>>> collectedSpecifications = new LinkedHashMap<>(); for (EvaluatedPolicyRule rule : rules) { for (ApprovalPolicyActionType approvalAction : rule.getEnabledActions(ApprovalPolicyActionType.class)) { WfProcessSpecificationType spec = approvalAction.getProcessSpecification(); collectedSpecifications.computeIfAbsent(spec, s -> new ArrayList<>()) .add(new ImmutablePair<>(approvalAction, rule)); }/*w w w . ja v a 2 s . c o m*/ } // Step 2: resolve references for (WfProcessSpecificationType spec : new HashSet<>(collectedSpecifications.keySet())) { // cloned to avoid concurrent modification exception if (spec != null && spec.getRef() != null) { List<Map.Entry<WfProcessSpecificationType, List<Pair<ApprovalPolicyActionType, EvaluatedPolicyRule>>>> matching = collectedSpecifications .entrySet().stream() .filter(e -> e.getKey() != null && spec.getRef().equals(e.getKey().getName())) .collect(Collectors.toList()); if (matching.isEmpty()) { throw new IllegalStateException("Process specification named '" + spec.getRef() + "' referenced from an approval action couldn't be found"); } else if (matching.size() > 1) { throw new IllegalStateException("More than one process specification named '" + spec.getRef() + "' referenced from an approval action: " + matching); } else { // move all actions/rules to the referenced process specification List<Pair<ApprovalPolicyActionType, EvaluatedPolicyRule>> referencedSpecActions = matching .get(0).getValue(); referencedSpecActions.addAll(collectedSpecifications.get(spec)); collectedSpecifications.remove(spec); } } } Map<String, Pair<ApprovalPolicyActionType, EvaluatedPolicyRule>> actionsMap = null; // Step 3: include other actions for (Map.Entry<WfProcessSpecificationType, List<Pair<ApprovalPolicyActionType, EvaluatedPolicyRule>>> processSpecificationEntry : collectedSpecifications .entrySet()) { WfProcessSpecificationType spec = processSpecificationEntry.getKey(); if (spec == null || spec.getIncludeAction().isEmpty() && spec.getIncludeActionIfPresent().isEmpty()) { continue; } if (actionsMap == null) { actionsMap = createActionsMap(collectedSpecifications.values()); } for (String actionToInclude : spec.getIncludeAction()) { processActionToInclude(actionToInclude, actionsMap, processSpecificationEntry, true); } for (String actionToInclude : spec.getIncludeActionIfPresent()) { processActionToInclude(actionToInclude, actionsMap, processSpecificationEntry, false); } } // Step 4: sorts process specifications and wraps into ProcessSpecification objects ProcessSpecifications rv = new ProcessSpecifications(prismContext); collectedSpecifications.entrySet().stream().sorted((ps1, ps2) -> { WfProcessSpecificationType key1 = ps1.getKey(); WfProcessSpecificationType key2 = ps2.getKey(); if (key1 == null) { return key2 == null ? 0 : 1; // non-empty (key2) records first } else if (key2 == null) { return -1; // non-empty (key1) record first } int order1 = defaultIfNull(key1.getOrder(), Integer.MAX_VALUE); int order2 = defaultIfNull(key2.getOrder(), Integer.MAX_VALUE); return Integer.compare(order1, order2); }).forEach(e -> rv.specifications.add(rv.new ProcessSpecification(e))); return rv; }
From source file:com.thingsee.tracker.MainActivity.java
private void loadUserInfo(final String accessToken) { Log.d("Tracker", "loadUserInfo(), accessToken:" + accessToken); new KiiGetUserInfoAsyncTask(new KiiGetUserInfoAsyncTask.AsyncResponseUserInfo() { @Override/* w w w .j a v a2s. com*/ public void processFinish(LinkedHashMap<String, String> info) { String[] splitStr = info.get("displayName").split("\\s+"); String firstName = info.get("displayName"); String lastName = info.get("displayName"); if ((splitStr[0] != null) && (!splitStr[0].isEmpty())) { firstName = splitStr[0]; } if ((splitStr[1] != null) && (!splitStr[1].isEmpty())) { lastName = splitStr[1]; } userAccountModel = new AccountModel(info.get("emailAddress"), firstName, lastName, info.get("phoneNumber"), info.get("emailAddress")); userAccountModel.setAccessToken(accessToken); progress.dismiss(); loginScreen.setVisibility(View.GONE); mHandler.postDelayed(startupSetupDelay, CommonConstants.STARTUP_SETUP_DELAY); progressReadingTrackers = new ProgressDialog(mContext); progressReadingTrackers.setTitle(mResources.getString(R.string.fetching_trackers_title)); progressReadingTrackers.setMessage(mResources.getString(R.string.fetching_trackers_message)); progressReadingTrackers.setCancelable(false); progressReadingTrackers.show(); loadTrackers(); } }, CommonConstants.KII_CLOUD_APP_ID, CommonConstants.KII_CLOUD_APP_KEY, accessToken).execute(); }
From source file:com.google.gwt.emultest.java.util.LinkedHashMapTest.java
public void testLRU() { LinkedHashMap<String, String> m = new LinkedHashMap<String, String>(10, .5f, true); m.put("A", "A"); m.put("B", "B"); m.put("C", "C"); m.put("D", "D"); Iterator<Entry<String, String>> entry = m.entrySet().iterator(); assertEquals("A", entry.next().getValue()); assertEquals("B", entry.next().getValue()); assertEquals("C", entry.next().getValue()); assertEquals("D", entry.next().getValue()); m.get("B"); m.get("D");/*from ww w .jav a 2 s. c o m*/ entry = m.entrySet().iterator(); assertEquals("A", entry.next().getValue()); assertEquals("C", entry.next().getValue()); assertEquals("B", entry.next().getValue()); assertEquals("D", entry.next().getValue()); }
From source file:AndroidUninstallStock.java
public static LinkedHashMap<String, String> getLibFromPackage(String adb, LinkedList<String> liblist, LinkedHashMap<String, String> apklist) throws IOException { LinkedHashMap<String, String> libinclude = new LinkedHashMap<String, String>(); File libget = File.createTempFile("AndroidUninstallStockLibs", null); for (Map.Entry<String, String> info : sortByValues(apklist).entrySet()) { System.out.print("* Libs in " + info.getKey() + " (" + info.getValue() + ")"); LinkedList<String> pull = run(adb, "-s", lastdevice, "pull", "\"" + info.getKey() + "\"", "\"" + libget.getCanonicalPath() + "\""); if (pull.size() > 0 && pull.get(0).indexOf("does not exist") > 0) { System.out.println(" - file not exist"); continue; }/*from www . ja va 2 s . c om*/ LinkedList<String> libinapk = getLibsInApk(libget.toPath()); if (libinapk.size() == 0) { System.out.println(" - empty"); } else { System.out.println(":"); for (String libpath : libinapk) { String libname = libpath.substring(libpath.lastIndexOf('/') + 1); boolean libfound = false; for (String lb : liblist) { if (lb.indexOf(libname) > -1) { System.out.println(libpath + " = " + lb); libinclude.put(lb, (libinclude.containsKey(libname) ? libinclude.get(libname) + ", " : "") + info.getKey()); libfound = true; } } if (!libfound) { System.out.println(libpath + " = not found"); } } } } try { libget.delete(); } catch (Exception e) { } return libinclude; }
From source file:com.ephesoft.dcma.tabbed.TabbedPdfExporter.java
/** * This API merges all the documents as per priority list into first document. Also, updates the multi page pdf file name to tabbed * pdf file name.//w w w . j a va 2 s . co m * * @param batchSchemaService{@link BatchSchemaService} * @param batch{@link Batch} * @param documentNames {@link Set<String>} * @param documentPDFMap {@link LinkedHashMap<String, List<String>>} * @param tabbedPDFName {@link String} */ private void mergeBatchXmlDocs(BatchSchemaService batchSchemaService, Batch batch, Set<String> documentNames, LinkedHashMap<String, List<String>> documentPDFMap, String tabbedPDFName) { boolean isFirstDocInXML = true; String documentIdInt; Documents documents = new Documents(); List<Document> docList = new ArrayList<Document>(); Iterator<String> iterator = documentNames.iterator(); while (iterator.hasNext()) { documentIdInt = iterator.next(); List<String> docDetails = documentPDFMap.get(documentIdInt); String documentTypeAfterSorting = docDetails.get(0); // fetch the document from batch xml and merge with first document as per priority. documents = batch.getDocuments(); docList = documents.getDocument(); Iterator<Document> docListIter = docList.iterator(); while (docListIter.hasNext()) { Document document = (Document) docListIter.next(); String docTypeFromXML = document.getType(); if (docTypeFromXML.equalsIgnoreCase(documentTypeAfterSorting)) { if (isFirstDocInXML) { // put this document as first document docList.add(0, document); isFirstDocInXML = false; } else { // merge the document with first document Pages docPages = document.getPages(); docList.get(0).getPages().getPage().addAll(docPages.getPage()); } docList.remove(document); break; } } } // update the multipage pdf file name docList.get(0).setMultiPagePdfFile(tabbedPDFName); batchSchemaService.updateBatch(batch); }
From source file:org.openmeetings.app.data.user.Organisationmanagement.java
/** * TODO//w w w . j a va 2 s . co m * * @param org * @param users * @return */ @SuppressWarnings({ "unused", "rawtypes" }) private Long updateOrganisationUsersByHashMap(Organisation org, LinkedHashMap users, long insertedby) { try { LinkedList<Long> usersToAdd = new LinkedList<Long>(); LinkedList<Long> usersToDel = new LinkedList<Long>(); List usersStored = this.getUsersByOrganisationId(org.getOrganisation_id()); for (Iterator it = users.keySet().iterator(); it.hasNext();) { Integer key = (Integer) it.next(); Long userIdToAdd = Long.valueOf(users.get(key).toString()).longValue(); log.error("userIdToAdd: " + userIdToAdd); if (!this.checkUserAlreadyStored(userIdToAdd, usersStored)) usersToAdd.add(userIdToAdd); } for (Iterator it = usersStored.iterator(); it.hasNext();) { Users us = (Users) it.next(); Long userIdStored = us.getUser_id(); log.error("userIdStored: " + userIdStored); if (!this.checkUserShouldBeStored(userIdStored, users)) usersToDel.add(userIdStored); } log.debug("usersToAdd.size " + usersToAdd.size()); log.debug("usersToDel.size " + usersToDel.size()); for (Iterator<Long> it = usersToAdd.iterator(); it.hasNext();) { Long user_id = it.next(); this.addUserToOrganisation(user_id, org.getOrganisation_id(), insertedby); } for (Iterator<Long> it = usersToDel.iterator(); it.hasNext();) { Long user_id = it.next(); this.deleteUserFromOrganisation(new Long(3), user_id, org.getOrganisation_id()); } } catch (Exception err) { log.error("updateOrganisationUsersByHashMap", err); } return null; }