List of usage examples for java.util HashMap values
public Collection<V> values()
From source file:org.messic.server.datamodel.jpaimpl.DAOJPASong.java
@Override @Transactional/*from w ww . jav a2 s.c o m*/ public List<MDOSong> genericFind(String username, List<String> searches) { HashMap<Long, MDOSong> finalResult = new HashMap<Long, MDOSong>(); for (int i = 0; i < searches.size(); i++) { String content = searches.get(i); String sql = "from MDOSong as a WHERE (a.owner.login = :userName) AND ("; sql = sql + "(UPPER(a.name) LIKE :what) OR "; sql = sql + "(UPPER(a.album.name) LIKE :what) OR "; sql = sql + "(UPPER(a.album.genre.name) LIKE :what) OR "; try { Integer.parseInt(content); sql = sql + "(a.album.year LIKE :what) OR "; } catch (NumberFormatException nfe) { } sql = sql + "(UPPER(a.album.comments) LIKE :what) OR "; sql = sql + "(UPPER(a.album.author.name) LIKE :what)"; sql = sql + ")"; Query query = entityManager.createQuery(sql); query.setParameter("userName", username); query.setParameter("what", "%" + content.toUpperCase() + "%"); @SuppressWarnings("unchecked") List<MDOSong> results = query.getResultList(); for (MDOSong mdoSong : results) { finalResult.put(mdoSong.getSid(), mdoSong); } } ArrayList<MDOSong> result = new ArrayList<MDOSong>(); Iterator<MDOSong> songsit = finalResult.values().iterator(); while (songsit.hasNext()) { result.add(songsit.next()); } return result; }
From source file:ddf.catalog.impl.operations.OperationsCrudSupport.java
void commitAndCleanup(StorageRequest storageRequest, Optional<String> historianTransactionKey, HashMap<String, Path> tmpContentPaths) { if (storageRequest != null) { try {//from w w w . j a va2 s. c o m sourceOperations.getStorage().commit(storageRequest); historianTransactionKey.ifPresent(historian::commit); } catch (StorageException e) { LOGGER.error("Unable to commit content changes for id: {}", storageRequest.getId(), e); try { sourceOperations.getStorage().rollback(storageRequest); } catch (StorageException e1) { LOGGER.error("Unable to remove temporary content for id: {}", storageRequest.getId(), e1); } finally { try { historianTransactionKey.ifPresent(historian::rollback); } catch (RuntimeException re) { LOGGER.error("Unable to commit versioned items for historian transaction: {}", historianTransactionKey.orElseGet(String::new), re); } } } } tmpContentPaths.values().forEach(path -> FileUtils.deleteQuietly(path.toFile())); tmpContentPaths.clear(); }
From source file:com.microsoft.projectoxford.emotionsample.RecognizeActivity.java
private List<RecognizeResult> processWithAutoFaceDetection() throws EmotionServiceException, IOException, JSONException { Log.d("emotion", "Start emotion detection with auto-face detection"); Gson gson = new Gson(); // Put the image into an input stream for detection. ByteArrayOutputStream output = new ByteArrayOutputStream(); mBitmap.compress(Bitmap.CompressFormat.JPEG, 100, output); ByteArrayInputStream inputStream = new ByteArrayInputStream(output.toByteArray()); long startTime = System.currentTimeMillis(); List<RecognizeResult> result = null; ////from w ww. j a v a 2s .com // Detect emotion by auto-detecting faces in the image. // result = this.client.recognizeImage(inputStream); String json = gson.toJson(result); Log.e("result", json); try { JSONArray jArray = new JSONArray(json); JSONObject jObj = jArray.getJSONObject(0); JSONObject scores = jObj.getJSONObject("scores"); HashMap<String, Double> emotionScores = new HashMap<>(); emotionScores.put("Anger", scores.getDouble("anger")); emotionScores.put("Contempt", scores.getDouble("contempt")); emotionScores.put("Disgust", scores.getDouble("disgust")); emotionScores.put("Fear", scores.getDouble("fear")); emotionScores.put("Happiness", scores.getDouble("happiness")); emotionScores.put("Neutral", scores.getDouble("neutral")); emotionScores.put("Sadness", scores.getDouble("sadness")); emotionScores.put("Surprise", scores.getDouble("surprise")); double maxScore = Collections.max(emotionScores.values()); for (Map.Entry<String, Double> entry : emotionScores.entrySet()) { if (entry.getValue() == maxScore) { Log.e("Max emotion score ", entry.getKey()); //String testS = entry.getKey(); mEmotion = entry.getKey(); } } } catch (Exception e) { e.printStackTrace(); } Log.e("emotion", String.format("Detection done. Elapsed time: %d ms", (System.currentTimeMillis() - startTime))); return result; }
From source file:com.griddynamics.jagger.engine.e1.reporting.WorkloadScalabilityPlotsReporter.java
private Collection<ScenarioPlotDTO> getScenarioPlots(List<WorkloadData> scenarios) { HashMap<String, ScenarioPlotDTO> throughputPlots = new HashMap<String, ScenarioPlotDTO>(); List<WorkloadTaskData> resultData; for (WorkloadData scenario : scenarios) { String scenarioName = scenario.getScenario().getName(); if (!throughputPlots.containsKey(scenarioName)) { resultData = getResultData(scenarioName); XYDataset latencyData = getLatencyData(resultData); XYDataset throughputData = getThroughputData(resultData); String clockForPlot = getClockForPlot(resultData); JFreeChart chartThroughput = ChartHelper.createXYChart(null, throughputData, clockForPlot, "Throughput (TPS)", 6, 3, ChartHelper.ColorTheme.LIGHT); JFreeChart chartLatency = ChartHelper.createXYChart(null, latencyData, clockForPlot, "Latency (sec)", 6, 3, ChartHelper.ColorTheme.LIGHT); ScenarioPlotDTO plotDTO = new ScenarioPlotDTO(); plotDTO.setScenarioName(scenarioName); plotDTO.setThroughputPlot(new JCommonDrawableRenderer(chartThroughput)); plotDTO.setLatencyPlot(new JCommonDrawableRenderer(chartLatency)); throughputPlots.put(scenarioName, plotDTO); resultData.clear();/* w w w. java 2 s . c om*/ } } return throughputPlots.values(); }
From source file:com.cburch.logisim.circuit.CircuitWires.java
private void connectTunnels(BundleMap ret) { // determine the sets of tunnels HashMap<String, ArrayList<Location>> tunnelSets = new HashMap<String, ArrayList<Location>>(); for (Component comp : tunnels) { String label = comp.getAttributeSet().getValue(StdAttr.LABEL); label = label.trim();/* w ww .j a v a 2s. c om*/ if (!label.equals("")) { ArrayList<Location> tunnelSet = tunnelSets.get(label); if (tunnelSet == null) { tunnelSet = new ArrayList<Location>(3); tunnelSets.put(label, tunnelSet); } tunnelSet.add(comp.getLocation()); } } // now connect the bundles that are tunnelled together for (ArrayList<Location> tunnelSet : tunnelSets.values()) { WireBundle foundBundle = null; Location foundLocation = null; for (Location loc : tunnelSet) { WireBundle b = ret.getBundleAt(loc); if (b != null) { foundBundle = b; foundLocation = loc; break; } } if (foundBundle == null) { foundLocation = tunnelSet.get(0); foundBundle = ret.createBundleAt(foundLocation); } for (Location loc : tunnelSet) { if (loc != foundLocation) { WireBundle b = ret.getBundleAt(loc); if (b == null) { foundBundle.points.add(loc); ret.setBundleAt(loc, foundBundle); } else { b.unite(foundBundle); } } } } }
From source file:im.vector.activity.HomeActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { if (CommonActivityUtils.shouldRestartApp()) { Log.e(LOG_TAG, "Restart the application."); CommonActivityUtils.restartApp(this); }/* www . jav a 2 s .c om*/ super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); mMyRoomList = (ExpandableListView) findViewById(R.id.listView_myRooms); // the chevron is managed in the header view mMyRoomList.setGroupIndicator(null); mAdapter = new ConsoleRoomSummaryAdapter(this, Matrix.getMXSessions(this), R.layout.adapter_item_my_rooms, R.layout.adapter_room_section_header); if (null != savedInstanceState) { if (savedInstanceState.containsKey(PUBLIC_ROOMS_LIST_LIST)) { Serializable map = savedInstanceState.getSerializable(PUBLIC_ROOMS_LIST_LIST); if (null != map) { HashMap<String, List<PublicRoom>> hash = (HashMap<String, List<PublicRoom>>) map; mPublicRoomsListList = new ArrayList<List<PublicRoom>>(hash.values()); mHomeServerNames = new ArrayList<>(hash.keySet()); } } } final Intent intent = getIntent(); if (intent.hasExtra(EXTRA_JUMP_TO_ROOM_ID)) { mAutomaticallyOpenedRoomId = intent.getStringExtra(EXTRA_JUMP_TO_ROOM_ID); } if (intent.hasExtra(EXTRA_JUMP_MATRIX_ID)) { mAutomaticallyOpenedMatrixId = intent.getStringExtra(EXTRA_JUMP_MATRIX_ID); } if (intent.hasExtra(EXTRA_ROOM_INTENT)) { mOpenedRoomIntent = intent.getParcelableExtra(EXTRA_ROOM_INTENT); } String action = intent.getAction(); String type = intent.getType(); // send files from external application if ((Intent.ACTION_SEND.equals(action) || Intent.ACTION_SEND_MULTIPLE.equals(action)) && type != null) { this.runOnUiThread(new Runnable() { @Override public void run() { CommonActivityUtils.sendFilesTo(HomeActivity.this, intent); } }); } mMyRoomList.setAdapter(mAdapter); Collection<MXSession> sessions = Matrix.getMXSessions(HomeActivity.this); // check if there is some valid session // the home activity could be relaunched after an application crash // so, reload the sessions before displaying the hidtory if (sessions.size() == 0) { Log.e(LOG_TAG, "Weird : onCreate : no session"); if (null != Matrix.getInstance(this).getDefaultSession()) { Log.e(LOG_TAG, "No loaded session : reload them"); startActivity(new Intent(HomeActivity.this, SplashActivity.class)); HomeActivity.this.finish(); return; } } for (MXSession session : sessions) { addSessionListener(session); } mMyRoomList.setOnChildClickListener(new ExpandableListView.OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { if (mAdapter.isRecentsGroupIndex(groupPosition)) { String roomId = null; MXSession session = null; RoomSummary roomSummary = mAdapter.getRoomSummaryAt(groupPosition, childPosition); session = Matrix.getInstance(HomeActivity.this).getSession(roomSummary.getMatrixId()); roomId = roomSummary.getRoomId(); Room room = session.getDataHandler().getRoom(roomId); // cannot join a leaving room if ((null == room) || room.isLeaving()) { roomId = null; } if (mAdapter.resetUnreadCount(groupPosition, roomId)) { session.getDataHandler().getStore().flushSummary(roomSummary); } if (null != roomId) { CommonActivityUtils.goToRoomPage(session, roomId, HomeActivity.this, null); } } else if (mAdapter.isPublicsGroupIndex(groupPosition)) { joinPublicRoom(mAdapter.getHomeServerURLAt(groupPosition), mAdapter.getPublicRoomAt(groupPosition, childPosition)); } return true; } }); mMyRoomList.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { if (ExpandableListView.getPackedPositionType(id) == ExpandableListView.PACKED_POSITION_TYPE_CHILD) { long packedPos = ((ExpandableListView) parent).getExpandableListPosition(position); final int groupPosition = ExpandableListView.getPackedPositionGroup(packedPos); if (mAdapter.isRecentsGroupIndex(groupPosition)) { final int childPosition = ExpandableListView.getPackedPositionChild(packedPos); FragmentManager fm = HomeActivity.this.getSupportFragmentManager(); IconAndTextDialogFragment fragment = (IconAndTextDialogFragment) fm .findFragmentByTag(TAG_FRAGMENT_ROOM_OPTIONS); if (fragment != null) { fragment.dismissAllowingStateLoss(); } final Integer[] lIcons = new Integer[] { R.drawable.ic_material_exit_to_app }; final Integer[] lTexts = new Integer[] { R.string.action_leave }; fragment = IconAndTextDialogFragment.newInstance(lIcons, lTexts, null, HomeActivity.this.getResources().getColor(R.color.vector_title_color)); fragment.setOnClickListener(new IconAndTextDialogFragment.OnItemClickListener() { @Override public void onItemClick(IconAndTextDialogFragment dialogFragment, int position) { Integer selectedVal = lTexts[position]; if (selectedVal == R.string.action_leave) { HomeActivity.this.runOnUiThread(new Runnable() { @Override public void run() { final RoomSummary roomSummary = mAdapter.getRoomSummaryAt(groupPosition, childPosition); final MXSession roomSession = Matrix.getInstance(HomeActivity.this) .getSession(roomSummary.getMatrixId()); String roomId = roomSummary.getRoomId(); Room room = roomSession.getDataHandler().getRoom(roomId); if (null != room) { room.leave(new SimpleApiCallback<Void>(HomeActivity.this) { @Override public void onSuccess(Void info) { mAdapter.removeRoomSummary(groupPosition, roomSummary); mAdapter.notifyDataSetChanged(); } }); } } }); } } }); fragment.show(fm, TAG_FRAGMENT_ROOM_OPTIONS); return true; } } return false; } }); mMyRoomList.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() { @Override public void onGroupExpand(int groupPosition) { if (mAdapter.isPublicsGroupIndex(groupPosition)) { refreshPublicRoomsList(); } } }); mMyRoomList.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() { @Override public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) { return mAdapter.getGroupCount() < 2; } }); mSearchRoomEditText = (EditText) this.findViewById(R.id.editText_search_room); mSearchRoomEditText.addTextChangedListener(new TextWatcher() { public void afterTextChanged(android.text.Editable s) { mAdapter.setSearchedPattern(s.toString()); mMyRoomList.smoothScrollToPosition(0); } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { } }); }
From source file:com.globalsight.everest.webapp.pagehandler.tasks.UpdateLeverageHandler.java
private void applyMTMatches(SourcePage p_sourcePage, GlobalSightLocale p_sourceLocale, GlobalSightLocale p_targetLocale, Collection<Tuv> untranslatedSrcTuvs) throws Exception { MachineTranslationProfile mtProfile = MTProfileHandlerHelper.getMtProfileBySourcePage(p_sourcePage, p_targetLocale);/*from ww w.j a v a2 s . co m*/ if (mtProfile == null || !(mtProfile.isActive())) { return; } HashMap<Tu, Tuv> sourceTuvMap = getSourceTuvMap(p_sourcePage); String mtEngine = mtProfile.getMtEngine(); machineTranslator = MTHelper.initMachineTranslator(mtEngine); HashMap paramMap = mtProfile.getParamHM(); paramMap.put(MachineTranslator.SOURCE_PAGE_ID, p_sourcePage.getId()); paramMap.put(MachineTranslator.TARGET_LOCALE_ID, p_targetLocale.getIdAsLong()); boolean isXlf = MTHelper2.isXlf(p_sourcePage.getId()); paramMap.put(MachineTranslator.NEED_SPECAIL_PROCESSING_XLF_SEGS, isXlf ? "true" : "false"); paramMap.put(MachineTranslator.DATA_TYPE, MTHelper2.getDataType(p_sourcePage.getId())); if (MachineTranslator.ENGINE_MSTRANSLATOR.equalsIgnoreCase(machineTranslator.getEngineName()) && p_targetLocale.getLanguage().equalsIgnoreCase("sr")) { String srLang = mtProfile.getPreferedLangForSr(p_targetLocale.toString()); paramMap.put(MachineTranslator.SR_LANGUAGE, srLang); } machineTranslator.setMtParameterMap(paramMap); List<TuvImpl> tuvsToBeUpdated = new ArrayList<TuvImpl>(); long jobId = p_sourcePage.getJobId(); TranslationMemoryProfile tmProfile = getTmProfile(p_sourcePage); long mtConfidenceScore = mtProfile.getMtConfidenceScore(); HashMap<Tu, Tuv> needHitMTTuTuvMap = new HashMap<Tu, Tuv>(); needHitMTTuTuvMap = formTuTuvMap(untranslatedSrcTuvs, sourceTuvMap, p_targetLocale, jobId); XmlEntities xe = new XmlEntities(); // put all TUs into array. Object[] key_tus = needHitMTTuTuvMap.keySet().toArray(); Tu[] tusInArray = new Tu[key_tus.length]; for (int key = 0; key < key_tus.length; key++) { tusInArray[key] = (Tu) key_tus[key]; } // put all target TUVs into array Object[] value_tuvs = needHitMTTuTuvMap.values().toArray(); Tuv[] targetTuvsInArray = new Tuv[value_tuvs.length]; for (int value = 0; value < value_tuvs.length; value++) { targetTuvsInArray[value] = (Tuv) value_tuvs[value]; } // put all GXML into array String[] p_segments = new String[targetTuvsInArray.length]; for (int index = 0; index < targetTuvsInArray.length; index++) { String segment = targetTuvsInArray[index].getGxml(); TuvImpl tuv = new TuvImpl(); if (p_sourcePage.getExternalPageId().endsWith(".idml")) { segment = IdmlHelper.formatForOfflineDownload(segment); } tuv.setSegmentString(segment); p_segments[index] = segment; } // Send all segments to MT engine for translation. logger.info("Begin to hit " + machineTranslator.getEngineName() + "(Segment number:" + p_segments.length + "; SourcePageID:" + p_sourcePage.getIdAsLong() + "; TargetLocale:" + p_targetLocale.getLocale().getLanguage() + ")."); String[] translatedSegments = machineTranslator.translateBatchSegments(p_sourceLocale.getLocale(), p_targetLocale.getLocale(), p_segments, LeverageMatchType.CONTAINTAGS, true); logger.info("End hit " + machineTranslator.getEngineName() + "(SourcePageID:" + p_sourcePage.getIdAsLong() + "; TargetLocale:" + p_targetLocale.getLocale().getLanguage() + ")."); // handle translate result one by one. Collection<LeverageMatch> lmCollection = new ArrayList<LeverageMatch>(); for (int tuvIndex = 0; tuvIndex < targetTuvsInArray.length; tuvIndex++) { Tu currentTu = tusInArray[tuvIndex]; Tuv sourceTuv = (Tuv) sourceTuvMap.get(currentTu); Tuv currentNewTuv = targetTuvsInArray[tuvIndex]; String machineTranslatedGxml = null; if (translatedSegments != null && translatedSegments.length == targetTuvsInArray.length) { machineTranslatedGxml = translatedSegments[tuvIndex]; } boolean isGetMTResult = isValidMachineTranslation(machineTranslatedGxml); boolean tagMatched = true; if (isGetMTResult && MTHelper.needCheckMTTranslationTag(machineTranslator.getEngineName())) { tagMatched = SegmentUtil2.canBeModified(currentNewTuv, machineTranslatedGxml, jobId); } // replace the content in target tuv with mt result if (mtConfidenceScore == 100 && isGetMTResult && tagMatched) { // GBS-3722 if (mtProfile.isIncludeMTIdentifiers()) { String leading = mtProfile.getMtIdentifierLeading(); String trailing = mtProfile.getMtIdentifierTrailing(); if (!StringUtil.isEmpty(leading) || !StringUtil.isEmpty(trailing)) { machineTranslatedGxml = MTHelper.tagMachineTranslatedContent(machineTranslatedGxml, leading, trailing); } } currentNewTuv.setGxml(MTHelper.fixMtTranslatedGxml(machineTranslatedGxml)); currentNewTuv.setMatchType(LeverageMatchType.UNKNOWN_NAME); currentNewTuv.setLastModifiedUser(machineTranslator.getEngineName() + "_MT"); // mark TUVs as localized so they get committed to the TM TuvImpl t = (TuvImpl) currentNewTuv; t.setState(com.globalsight.everest.tuv.TuvState.LOCALIZED); long trgTuvId = currentTu.getTuv(p_targetLocale.getId(), jobId).getId(); t.setId(trgTuvId); tuvsToBeUpdated.add(t); } // save MT match into "leverage_match" if (isGetMTResult == true) { LeverageMatch lm = new LeverageMatch(); lm.setSourcePageId(p_sourcePage.getIdAsLong()); lm.setOriginalSourceTuvId(sourceTuv.getIdAsLong()); lm.setSubId("0"); lm.setMatchedText(machineTranslatedGxml); lm.setMatchedClob(null); lm.setTargetLocale(currentNewTuv.getGlobalSightLocale()); // This is the first MT matches,its order number is 301. lm.setOrderNum((short) TmCoreManager.LM_ORDER_NUM_START_MT); lm.setScoreNum(mtConfidenceScore); if (mtConfidenceScore == 100) { lm.setMatchType(MatchState.MT_EXACT_MATCH.getName()); } else { lm.setMatchType(MatchState.FUZZY_MATCH.getName()); } lm.setMatchedTuvId(-1); lm.setProjectTmIndex(Leverager.MT_PRIORITY); lm.setTmId(0); lm.setTmProfileId(tmProfile.getIdAsLong()); lm.setMtName(machineTranslator.getEngineName() + "_MT"); lm.setMatchedOriginalSource(sourceTuv.getGxml()); // lm.setSid(sourceTuv.getSid()); lm.setCreationUser(machineTranslator.getEngineName()); lm.setCreationDate(sourceTuv.getLastModified()); lm.setModifyDate(sourceTuv.getLastModified()); lmCollection.add(lm); } } List<Long> originalSourceTuvIds = new ArrayList<Long>(); for (Tuv untranslatedSrcTuv : untranslatedSrcTuvs) { originalSourceTuvIds.add(untranslatedSrcTuv.getIdAsLong()); } LingServerProxy.getLeverageMatchLingManager().deleteLeverageMatches(originalSourceTuvIds, p_targetLocale, LeverageMatchLingManager.DEL_LEV_MATCHES_MT_ONLY, jobId); // Save the LMs into DB LingServerProxy.getLeverageMatchLingManager().saveLeveragedMatches(lmCollection, jobId); /****** END :: Hit MT to get matches if configured ******/ // Populate into target TUVs SegmentTuvUtil.updateTuvs(tuvsToBeUpdated, jobId); }
From source file:com.acentera.utils.ProjectsHelpers.java
public static JSONObject getProjectImagesAsJson(List<DropletImage> lstImages) throws JsonProcessingException { ObjectMapper mapper = new ObjectMapper(); mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false); mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); ObjectWriter ow = mapper.writer();/*from w w w . j a va 2 s .c om*/ JSONObject jso = new JSONObject(); HashMap<String, Distro> hmDistro = new HashMap<String, Distro>(); Iterator<DropletImage> itrImages = lstImages.iterator(); long distroId = 1; List<DropletImage> realListImages = new ArrayList<DropletImage>(); while (itrImages.hasNext()) { DropletImage img = itrImages.next(); if (img.getSlug() == null) { continue; } if (!(hmDistro.containsKey(img.getDistribution()))) { if (img.getDistribution().compareTo("Arch Linux") == 0) { continue; } Distro d = new Distro(); d.setId(distroId); d.setName(img.getDistribution()); distroId++; hmDistro.put(img.getDistribution(), d); } if (!(img.getSlug().toLowerCase().startsWith(img.getDistribution().toLowerCase()))) { continue; } realListImages.add(img); } jso.put("images", mapper.writeValueAsString(realListImages)); jso.put("distros", mapper.writeValueAsString(hmDistro.values())); return jso; }
From source file:com.microsoft.tfs.client.common.ui.wit.dialogs.WorkItemPickerDialog.java
/** * Iterate all projects and determine the union of work item types across * all projects./* w ww . j av a 2 s.com*/ * * @return Array of work-item types representing the union of all work item * types across all projects. */ private WorkItemType[] getAllProjectWorkItemTypes() { final HashMap map = new HashMap(); for (int i = 0; i < projects.length; i++) { final Project project = projects[i]; final WorkItemTypeCollection collection = project.getWorkItemTypes(); for (final Iterator it = collection.iterator(); it.hasNext();) { final WorkItemType type = (WorkItemType) it.next(); final String typeName = type.getName(); if (!map.containsKey(typeName)) { map.put(typeName, type); } } } return (WorkItemType[]) map.values().toArray(new WorkItemType[map.size()]); }
From source file:com.codesourcery.internal.installer.InstallManager.java
@Override public IInstalledProduct[] getInstalledProducts(IProductRange[] ranges, boolean uniqueLocations) { ArrayList<IInstalledProduct> products = new ArrayList<IInstalledProduct>(); HashMap<IPath, IInstalledProduct> locations = new HashMap<IPath, IInstalledProduct>(); for (IProductRange range : ranges) { IInstalledProduct product = getInstallRegistry().getProduct(range.getId()); if (product != null) { // Any product version or product version is in range if ((range.getVersionRange() == null) || range.getVersionRange().isIncluded(product.getVersion())) { if (uniqueLocations) locations.put(product.getInstallLocation(), product); else products.add(product); }/* w w w.ja v a2 s . c om*/ } } if (uniqueLocations) { Collection<IInstalledProduct> values = locations.values(); return values.toArray(new IInstalledProduct[values.size()]); } else { return products.toArray(new IInstalledProduct[products.size()]); } }