List of usage examples for java.util HashMap keySet
public Set<K> keySet()
From source file:com.jci.supp.repo.SuppRepoImpl.java
@Override public ResultSet getSegmentedResultSet(ScrollingParam param, DataHelper request) throws InvalidKeyException, URISyntaxException, StorageException { ResultContinuation continuationToken = DataUtil.getContinuationToken(param); PaginationParam pagination = new PaginationParam(); if (continuationToken != null) { pagination.setLastPartition(param.getPartition()); pagination.setLastRow(param.getRow()); }/*from ww w .j a v a 2 s. c o m*/ // Create the query String whereCondition = QueryBuilder.partitionWhereCondition(request.getPartitionValue()); if (StringUtils.isBlank(whereCondition)) { return null; } TableQuery<DynamicTableEntity> query = TableQuery.from(DynamicTableEntity.class).where(whereCondition) .take(param.getSize()); CloudTable table = azureStorage.getTable(request.getTableName()); ResultSegment<DynamicTableEntity> response = table.executeSegmented(query, continuationToken); // next continuation token continuationToken = response.getContinuationToken(); if (continuationToken != null) { pagination.setNextPartition(continuationToken.getNextPartitionKey()); pagination.setNextRow(continuationToken.getNextRowKey()); } HashMap<String, Object> hashmap; ObjectMapper mapper = new ObjectMapper(); List<HashMap<String, Object>> series = new ArrayList<>(); DynamicTableEntity row; EntityProperty ep; TypeReference<HashMap<String, Object>> typeRef = new TypeReference<HashMap<String, Object>>() { }; Iterator<DynamicTableEntity> rows = response.getResults().iterator(); LOG.error("hasNext--->" + rows.hasNext()); while (rows.hasNext()) { row = rows.next(); HashMap<String, EntityProperty> map = row.getProperties(); hashmap = new HashMap<>(); for (String key : map.keySet()) { ep = map.get(key); if (Constants.JSON_STRING.equalsIgnoreCase(key)) { try { hashmap = mapper.readValue(ep.getValueAsString(), typeRef); hashmap.put("id", row.getRowKey()); series.add(hashmap); } catch (IOException e) { LOG.error("### Exception in ####", e); } } } } LOG.error("hasNext--->" + series); return new ResultSet(series, pagination); }
From source file:com.openerp.addons.note.NoteDBHelper.java
public JSONArray getSelectedTagId(HashMap<String, TagsItems> selectedTags) { JSONArray list = new JSONArray(); for (String key : selectedTags.keySet()) { list.put(selectedTags.get(key).getId()); }/*from ww w . j ava 2s . com*/ return list; }
From source file:edu.isi.wings.util.oodt.CurationServiceAPI.java
public HashMap<String, String> getParentTypeMap() { String result = this.query("GET", "parentmap"); HashMap<?, ?> map = gson.fromJson(result, HashMap.class); HashMap<String, String> ptypeMap = new HashMap<String, String>(); for (Object key : map.keySet()) { ptypeMap.put((String) key, (String) map.get(key)); }//w w w . jav a 2 s .c om return ptypeMap; }
From source file:Data.c_PriceDB.java
public c_Price getPrice(c_Deck deck, WhichHalf part) { c_Price price = new c_Price(); if (part == WhichHalf.DECK || part == WhichHalf.BOTH) { HashMap<Integer, Integer> cards = deck.getCards(); for (int mid : cards.keySet()) { Integer amount = cards.get(mid); c_Card card = m_db.getCard(mid); c_Price cardprice = getPrice(card.Name, card.Expansion); price.addPriceTimesAmount(cardprice, amount); amount = null;/*from w w w . j a v a2s. c om*/ card = null; cardprice = null; } } if (part == WhichHalf.SB || part == WhichHalf.BOTH) { HashMap<Integer, Integer> cards = deck.getSBCards(); for (int mid : cards.keySet()) { Integer amount = cards.get(mid); c_Card card = m_db.getCard(mid); c_Price cardprice = getPrice(card.Name, card.Expansion); price.addPriceTimesAmount(cardprice, amount); amount = null; card = null; cardprice = null; } } return price; }
From source file:com.eTilbudsavis.etasdk.network.impl.HttpURLNetwork.java
private void setHeaders(Request<?> request, HttpURLConnection connection) { HashMap<String, String> headers = new HashMap<String, String>(request.getHeaders().size()); headers.putAll(request.getHeaders()); for (String key : headers.keySet()) connection.setRequestProperty(key, headers.get(key)); }
From source file:edu.illinois.cs.cogcomp.transliteration.WikiTransliteration.java
/** * This normalizes the raw counts by the counts of the source strings in each production. * Example://w ww. ja va 2 s . c om * Raw counts={ Prod("John", "Yon")=>4, Prod("John","Jon")=>1 } * Normalized={ Prod("John", "Yon")=>4/5, Prod("John","Jon")=>1/5} * * If source strings only ever show up for one target string, then this does nothing. * * @param counts raw counts * @param internTable * @return */ public static HashMap<Production, Double> NormalizeBySourceSubstring(HashMap<Production, Double> counts, InternDictionary<String> internTable) { // gets counts by source strings HashMap<String, Double> totals = GetAlignmentTotals1(counts); HashMap<Production, Double> result = new HashMap<>(counts.size()); for (Production key : counts.keySet()) { Double value = counts.get(key); result.put(new Production(internTable.Intern(key.getFirst()), internTable.Intern(key.getSecond())), value / totals.get(key.getFirst())); } return result; }
From source file:com.eTilbudsavis.etasdk.network.impl.DefaultHttpNetwork.java
private void setHeaders(Request<?> request, HttpRequestBase http) { HashMap<String, String> headers = new HashMap<String, String>(request.getHeaders().size()); headers.putAll(request.getHeaders()); for (String key : headers.keySet()) http.setHeader(key, headers.get(key)); }
From source file:com.vina.hlexchang.ClientRequestHelper.java
public String sendGet(String url, HashMap<String, String> hmHeader) { String response = ""; HttpGet httpGet = new HttpGet(url); Set<String> setKey = hmHeader.keySet(); //Add request Header for (String key : setKey) { String value = hmHeader.get(key); if (value != null) { httpGet.addHeader(key, value); }//from ww w . ja v a2 s. co m } // HttpResponse httpResponse; try { httpResponse = mClient.execute(httpGet); BufferedReader rd = new BufferedReader(new InputStreamReader(httpResponse.getEntity().getContent())); System.out.println("Status Code:" + httpResponse.getStatusLine().getStatusCode()); StringBuffer result = new StringBuffer(); String line = ""; while ((line = rd.readLine()) != null) { result.append(line); } response = result.toString(); } catch (IOException ex) { Logger.getLogger(ClientRequestHelper.class.getName()).log(Level.SEVERE, null, ex); } return response; }
From source file:eu.optimis.infrastructureproviderriskassessmenttool.core.holisticriskassessment.ProactiveRiskAssessor.java
private void ProactiveRiskAssessmentForVMs() throws Exception { log.info("Start: ProactiveRiskAssessmentForVMs"); Set<String> serviceIDs = VMsRiskLevelThresholds.keySet(); Iterator<String> itr = serviceIDs.iterator(); while (itr.hasNext()) { String serviceID = itr.next(); HashMap<String, String> VMs = VMsRiskLevelThresholds.get(serviceID); Set<String> serviceIDs2 = VMs.keySet(); Iterator<String> itrVMs = serviceIDs2.iterator(); while (itrVMs.hasNext()) { String VMID = itrVMs.next(); int VMRiskLevelThreshold = Integer.valueOf(VMs.get(VMID)); double currentVMRiskLevel = re.getVm(VMID); if (currentVMRiskLevel >= VMRiskLevelThreshold) { // notify HM; HMClient.notifyVMRiskLevel(VMID, (int) currentVMRiskLevel); }//from ww w . j a va 2 s . c om } } log.info("End: ProactiveRiskAssessmentForVMs"); }
From source file:com.jci.item.repo.ItemRepoImpl.java
@Override public ResultSet getSegmentedResultSet(ScrollingParam param, DataHelper request) throws InvalidKeyException, URISyntaxException, StorageException { ResultContinuation continuationToken = DataUtil.getContinuationToken(param); PaginationParam pagination = new PaginationParam(); if (continuationToken != null) { pagination.setLastPartition(param.getPartition()); pagination.setLastRow(param.getRow()); }//w w w . j a va 2s .c o m // Create the query String whereCondition = QueryBuilder.partitionWhereCondition(request.getPartitionValue()); if (StringUtils.isBlank(whereCondition)) { return null; } TableQuery<DynamicTableEntity> query = TableQuery.from(DynamicTableEntity.class).where(whereCondition) .take(param.getSize()); CloudTable table = azureStorage.getTable(request.getTableName()); // segmented query ResultSegment<DynamicTableEntity> response = table.executeSegmented(query, continuationToken); // next continuation token continuationToken = response.getContinuationToken(); if (continuationToken != null) { pagination.setNextPartition(continuationToken.getNextPartitionKey()); pagination.setNextRow(continuationToken.getNextRowKey()); } HashMap<String, Object> hashmap; List<HashMap<String, Object>> series = new ArrayList<>(); DynamicTableEntity row; EntityProperty ep; ObjectMapper mapper = new ObjectMapper(); TypeReference<HashMap<String, Object>> typeRef = new TypeReference<HashMap<String, Object>>() { }; Iterator<DynamicTableEntity> rows = response.getResults().iterator(); while (rows.hasNext()) { row = rows.next(); HashMap<String, EntityProperty> map = row.getProperties(); hashmap = new HashMap<>(); for (String key : map.keySet()) { ep = map.get(key); if ("ItemJsonString".equalsIgnoreCase(key)) { try { hashmap = mapper.readValue(ep.getValueAsString(), typeRef); hashmap.put("id", row.getRowKey()); series.add(hashmap); } catch (IOException e) { LOG.error("### Exception in ####", e); } } } } return new ResultSet(series, pagination); }