List of usage examples for org.json.simple JSONArray iterator
public Iterator<E> iterator()
From source file:net.phyloviz.goeburst.GoeBurstItemFactory.java
private Map<Integer, GOeBurstClusterWithStats> createGroups(JSONArray groupsArray, Map<Integer, EdgeInfo> edges, Map<Integer, GOeBurstNodeExtended> nodes, AbstractDistance ad) { TreeMap<Integer, GOeBurstClusterWithStats> groups = new TreeMap<>(); for (Iterator<JSONObject> gIt = groupsArray.iterator(); gIt.hasNext();) { JSONObject group = gIt.next();//ww w . ja v a2 s. c o m Integer id = (int) (long) group.get("id"); JSONArray g_edges = (JSONArray) group.get("edges"); JSONArray g_nodes = (JSONArray) group.get("nodes"); JSONArray g_maxLVs = (JSONArray) group.get("maxLVs"); Integer maxStId = (int) (long) group.get("maxStId"); GOeBurstClusterWithStats g_cluster = new GOeBurstClusterWithStats(goeburstStats, ad); g_cluster.setID(id); for (Iterator<Long> geIt = g_edges.iterator(); geIt.hasNext();) { EdgeInfo ei = edges.get((int) (long) geIt.next()); Edge<GOeBurstNodeExtended> edge = ei.edge; g_cluster.setEdgeMaxTieLevel(edge, ei.maxTie); g_cluster.updateVisibleEdges(edge); g_cluster.addEdge(edge); } for (Iterator<Long> gnIt = g_nodes.iterator(); gnIt.hasNext();) { Integer nodeId = (int) (long) gnIt.next(); g_cluster.addNode(nodes.get(nodeId)); } int lv = 0; for (Iterator<Long> gLVsIt = g_maxLVs.iterator(); gLVsIt.hasNext();) { Integer lv_val = (int) (long) gLVsIt.next(); g_cluster.setMaxXLV(lv++, lv_val); } //g_cluster.computeStatistics(); g_cluster.setMaxStId(maxStId); groups.put(id, g_cluster); } return groups; }
From source file:it.uniud.ailab.dcore.annotation.annotators.SimpleNGramGeneratorAnnotator.java
/** * Loads the nGram database according to the path and language specified in * the constructor.//from w ww . j a v a2 s . com * * @param lang the language to search in the database * @throws IOException if the database file is nonexistent or non accessible * @throws ParseException if the database file is malformed * @throws NullPointerException if the language requested is not in the * database */ private void loadDatabase(Locale lang) throws IOException, ParseException { // Get the POS pattern file and parse it. InputStreamReader is = FileSystem.getInputStreamReaderFromPath(posDatabasePaths.get(lang)); BufferedReader reader = new BufferedReader(is); Object obj = (new JSONParser()).parse(reader); JSONObject fileblock = (JSONObject) obj; JSONArray pagesBlock = (JSONArray) fileblock.get("languages"); // Find the required language in the specified file Iterator<JSONObject> iterator = pagesBlock.iterator(); JSONObject languageBlock = null; while (iterator.hasNext()) { languageBlock = (iterator.next()); String currLanguage = (String) languageBlock.get("language"); if (currLanguage.equals(lang.getLanguage())) { break; } } // If the language is not supported by the database, stop the execution. if (languageBlock == null) { throw new NullPointerException( "Language " + lang.getLanguage() + " not found in file " + posDatabasePaths.get(lang)); } JSONArray patternBlock = (JSONArray) languageBlock.get("patterns"); try { maxGramSize = Integer.parseInt(languageBlock.get("maxGramSize").toString()); } catch (Exception e) { // the field is badly formatted or non-existent: set to default maxGramSize = DEFAULT_MAX_NGRAM_SIZE; ; } Iterator<JSONObject> patternIterator = patternBlock.iterator(); // put the patterns in the hashmap while (patternIterator.hasNext()) { JSONObject pattern = (patternIterator.next()); String POSpattern = (String) pattern.get("pattern"); Long nounCount = (Long) pattern.get("nounCount"); validPOSPatterns.put(POSpattern, nounCount.intValue()); } }
From source file:eumetsat.pn.elasticsearch.webapp.ElasticsearchApp.java
@Override protected Map<String, Object> search(String searchTerms, String filterString, int from, int size) { Map<String, Object> data = new HashMap<>(); // put "session" parameters here rightaway so it can be used in template even when empty result data.put("search_terms", searchTerms); data.put("filter_terms", filterString); URL url;//from w w w . java 2 s. c o m try { url = new URL(searchEndpointUrlString); } catch (MalformedURLException e) { log.error("Search enpoint URL malformed: {}", e.getMessage()); addMessage(data, MessageLevel.danger, "Search endpoint URL is malformed: " + e.getMessage()); return data; } List<Map<String, String>> resHits = new ArrayList<>(); Map<String, String> resHit = null; Multimap<String, String> filterTermsMap = parseFiltersTerms(filterString); Set<String> hiddenFacets = new HashSet<>(); // to create the list of filters to hide String filterConstruct = ""; if (filterTermsMap.size() > 0) { int i = 0; String filterTerms = ""; for (String key : filterTermsMap.keySet()) { for (String term : filterTermsMap.get(key)) { if (i == 0) { filterTerms += "{ \"term\" : { \"" + FACETS2HIERACHYNAMES.get(key) + "\":\"" + term + "\"}}"; } else { filterTerms += ",{ \"term\" : { \"" + FACETS2HIERACHYNAMES.get(key) + "\":\"" + term + "\"}}"; } // hide the facets that are used for filtering hiddenFacets.add(key + ":" + term); i++; } } filterConstruct = " \"bool\" : { \"must\" : [" + filterTerms + "] }"; } int lengthOfTitle = 300; int lengthOfAbstract = 5000; int boostFactorTitle = 10; String body = "{ " + // pagination information "\"from\" : " + from + ", \"size\" : " + size + "," + // request highlighted info "\"highlight\" : { \"pre_tags\" : [\"<em><strong>\"], \"post_tags\" : [\"</strong></em>\"], " + " \"fields\" : { \"identificationInfo.title\": {\"fragment_size\" : " + lengthOfTitle + ", \"number_of_fragments\" : 1}, " + " \"identificationInfo.abstract\": {\"fragment_size\" : " + lengthOfAbstract + ", \"number_of_fragments\" : 1} } } , " + // request facets to refine search (here the maximum number of facets can be configured) " \"facets\" : { \"satellites\": { \"terms\" : { \"field\" : \"hierarchyNames.satellite\", \"size\":5 } }, " + " \"instruments\": { \"terms\" : { \"field\" : \"hierarchyNames.instrument\", \"size\":5 } }, " + " \"categories\": { \"terms\" : { \"field\" : \"hierarchyNames.category\", \"size\": 5 } }, " + " \"societal Benefit Area\": { \"terms\" : { \"field\" : \"hierarchyNames.societalBenefitArea\", \"size\":5 } }, " + " \"distribution\": { \"terms\" : { \"field\" : \"hierarchyNames.distribution\", \"size\":5 } } " + " }," + // add query info "\"query\" : { \"filtered\": { \"query\": " + " { \"simple_query_string\" : { \"fields\" : [\"identificationInfo.title^" + boostFactorTitle + "\", \"identificationInfo.abstract\"], " + "\"query\" : \"" + searchTerms + "\" } " + "}" + ",\"filter\": {" + filterConstruct + "}" + " }}}"; log.trace("elastic-search request: {}", body); //measure elapsed time Stopwatch stopwatch = Stopwatch.createStarted(); WebResponse response = rClient.doGetRequest(url, new HashMap<String, String>(), new HashMap<String, String>(), body, log.isDebugEnabled()); if (response == null) { log.error("Response from {} is null!", this.name); data.put("total_hits", 0); data = addMessage(data, MessageLevel.danger, "Response is null from " + this.name); } else { log.trace("Got response: {}", response); if (response.status == 200) { JSONParser parser = new JSONParser(); JSONObject jsObj; try { jsObj = (JSONObject) parser.parse(response.body); } catch (ParseException e) { log.error("Could not parse search server response: {}", e); addMessage(data, MessageLevel.danger, "Could not parse server response: " + e.getMessage()); return data; } Long hitcount = (Long) ((Map<?, ?>) jsObj.get("hits")).get("total"); data.put("total_hits", hitcount); if (hitcount < 1) addMessage(data, MessageLevel.info, "No results found!"); // compute the pagination information to create the pagination bar Map<String, Object> pagination = computePaginationParams(hitcount.intValue(), from); data.put("pagination", pagination); @SuppressWarnings("unchecked") List<Map<String, Object>> hits = (List<Map<String, Object>>) ((Map<?, ?>) jsObj.get("hits")) .get("hits"); //to get the highlight Map<?, ?> highlight = null; for (Map<String, Object> hit : hits) { resHit = new HashMap<>(); resHit.put("id", (String) hit.get("_id")); resHit.put("score", String.format("%.4g%n", ((Double) hit.get("_score")))); // can have or not title or abstract // strategy. If it doesn't have an abstract or a title match then take it from the _source highlight = (Map<?, ?>) hit.get("highlight"); if (highlight.containsKey("identificationInfo.title")) { resHit.put("title", (String) ((JSONArray) highlight.get("identificationInfo.title")).get(0)); } else { resHit.put("title", ((String) (((Map<?, ?>) (((Map<?, ?>) hit.get("_source")) .get("identificationInfo"))).get("title")))); } if (highlight.containsKey("identificationInfo.abstract")) { resHit.put("abstract", (String) ((JSONArray) highlight.get("identificationInfo.abstract")).get(0)); } else { resHit.put("abstract", ((String) (((Map<?, ?>) (((Map<?, ?>) hit.get("_source")) .get("identificationInfo"))).get("abstract")))); } JSONObject info = (JSONObject) ((JSONObject) hit.get("_source")).get("identificationInfo"); JSONArray keywords = (JSONArray) info.get("keywords"); resHit.put("keywords", Joiner.on(", ").join(keywords.iterator())); resHit.put("thumbnail", info.get("thumbnail").toString()); resHit.put("status", info.get("status").toString()); resHits.add(resHit); } data.put("hits", resHits); data.put("facets", jsObj.get("facets")); data.put("tohide", hiddenFacets); } else { // non-200 resonse log.error("Received non-200 response: {}", response); data = addMessage(data, MessageLevel.danger, "Non 200 response: " + response.toString()); } } stopwatch.stop(); data.put("elapsed", (double) (stopwatch.elapsed(TimeUnit.MILLISECONDS)) / (double) 1000); return data; }
From source file:net.itransformers.toplogyviewer.gui.neo4j.Neo4jLoader.java
public void getVertexes(String NetworkId) throws ParseException { String query = "start network=node(" + NetworkId + ") match network-->device where device.objectType='Node' return device.name, device.DeviceType,device.DeviceModel,device.ManagementIPAddress,device.YCoordinate,device.XCoordinate,device.siteID,device.ipv6Forwarding,device.BGPLocalASInfo,device.DeviceState"; String params = ""; String output = executeCypherQuery(query, params); JSONObject json = (JSONObject) new JSONParser().parse(output); JSONArray data = (JSONArray) json.get("data"); JSONArray columns = (JSONArray) json.get("columns"); Iterator dataIter = data.iterator(); while (dataIter.hasNext()) { JSONArray temp = (JSONArray) dataIter.next(); Iterator tempIter = temp.iterator(); Iterator columnsIter = columns.iterator(); String nodeName = null;//ww w. j a v a 2s.co m HashMap<String, GraphMLMetadata<String>> nodePropertiesMap = new HashMap<String, GraphMLMetadata<String>>(); HashMap<String, GraphMLMetadata<String>> graphMLPropertiesMap = new HashMap<String, GraphMLMetadata<String>>(); while (tempIter.hasNext() & columnsIter.hasNext()) { String keyNodeProperty = tempIter.next().toString(); String columnsValue = StringUtils .replace(StringUtils.substringAfter(columnsIter.next().toString(), "device."), "%20", " "); if (columnsValue.equals("name")) { nodeName = keyNodeProperty; } else { if (keyNodeProperty == null) { keyNodeProperty = ""; } else if (keyNodeProperty.equals("emptyValue")) { keyNodeProperty = ""; } HashMap<String, String> transformerValue = new HashMap<String, String>(); transformerValue.put(nodeName, keyNodeProperty); MapSettableTransformer<String, String> transfrmer = new MapSettableTransformer<String, String>( transformerValue); GraphMLMetadata<String> t = new GraphMLMetadata<String>(null, null, transfrmer); nodePropertiesMap.put(columnsValue, t); } } if (nodeName != null) { entireGraph.addVertex(nodeName); vertexMetadatas.put(nodeName, nodePropertiesMap); graphMetadatas.put(nodeName, graphMLPropertiesMap); } } }
From source file:eu.seaclouds.platform.discoverer.crawler.CloudTypes.java
private void crawlComputeOfferings() { /* iaas section */ String computeQuery = "https://cloudharmony.com/api/services?" + "api-key=" + API_KEY + "&" + "serviceTypes=compute"; JSONObject resp = (JSONObject) query(computeQuery); if (resp == null) { return;// w ww .j av a 2 s . c o m } JSONArray computes = (JSONArray) resp.get("ids"); Iterator<String> it = computes.iterator(); while (it.hasNext()) { try { String serviceId = it.next(); CloudHarmonyService chService = getService(serviceId, CloudTypes.IAAS); if (chService != null) generateOfferings(chService); } catch (Exception ex) { log.warn(ex.getMessage()); } } }
From source file:net.phyloviz.nj.json.NJItemFactory.java
private Map<Integer, NJLeafNode> createLeafs(TypingData<? extends AbstractProfile> td, JSONArray leafsArr) { Map<Integer, NJLeafNode> leafs = new HashMap(leafsArr.size()); Map<String, Profile> profiles = new HashMap(td.size()); for (Iterator<? extends AbstractProfile> it = td.iterator(); it.hasNext();) { Profile p = it.next();//from w w w . ja va 2 s . c o m profiles.put(p.getID(), p); } for (Iterator<JSONObject> it = leafsArr.iterator(); it.hasNext();) { JSONObject l = it.next(); String p = (String) l.get("profile"); Integer uid = (int) (long) l.get("id"); leafs.put(uid, new NJLeafNode(profiles.get(p), td.size(), uid, null)); } return leafs; }
From source file:JSONParser.JSONToHTMLRenderer.java
private String renderContentRows(JSONArray content, String[] rowHeader) { String renderedRows = ""; if (content == null || content.size() == 0) { renderedRows = "<tr >\n" + "<td colspan=\"" + rowHeader.length + "\"><center style=\"color: rgb(255, 0, 0);\">" + "No pending tickets available" + "</center></td></tr> \n"; return renderedRows; } else {//from w ww . j av a2s.c o m for (Iterator rowItr = content.iterator(); rowItr.hasNext();) { JSONObject WOERow = (JSONObject) rowItr.next(); String colorCode = (String) WOERow.get("colourCode"); if (colorCode == null) { colorCode = "rgb(0,0,0)"; } renderedRows += "<tr style=\"color: " + colorCode + ";font-weight:bold\">\n"; for (String columnStr : rowHeader) { renderedRows += "<td valign=\"top\" ><b>" + WOERow.get(columnStr) + "</b></td>\n"; } renderedRows += "</tr>"; } return renderedRows; } }
From source file:net.phyloviz.upgma.json.UPGMAItemFactory.java
private Map<Integer, UPGMALeafNode> createLeafs(TypingData<? extends AbstractProfile> td, JSONArray leafsArr) { Map<Integer, UPGMALeafNode> leafs = new HashMap(leafsArr.size()); Map<String, Profile> profiles = new HashMap(td.size()); for (Iterator<? extends AbstractProfile> it = td.iterator(); it.hasNext();) { Profile p = it.next();//from w w w. ja va 2 s .c om profiles.put(p.getID(), p); } for (Iterator<JSONObject> it = leafsArr.iterator(); it.hasNext();) { JSONObject l = it.next(); String p = (String) l.get("profile"); Integer uid = (int) (long) l.get("uid"); leafs.put(uid, new UPGMALeafNode(uid, profiles.get(p), td.size(), uid)); } return leafs; }
From source file:com.unilever.audit.services2.SyncUp.java
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) public void saveVisit(JSONObject visitData) throws Exception { Map<String, Object> hm = new HashMap<String, Object>(); /***************Visit***********************/ Visit saveVisit = new Visit(); hm.put("id", visitData.get("visitId").toString()); if (visitFacadeREST.findOneByQuery("Visit.findById", hm) == null) { saveVisit.setId(visitData.get("visitId").toString()); Customers c = em.getReference(Customers.class, (Integer.parseInt(visitData.get("customerId").toString()))); saveVisit.setCustomerid(c);//from w w w .ja v a 2 s. c om Merchandisers m = em.getReference(Merchandisers.class, new BigDecimal(visitData.get("merchandiserId").toString())); saveVisit.setMerchandiserid(m); try { //Date date = new SimpleDateFormat("MM/dd/yyyy").parse(visitData.get("visitDate").toString()); Date date = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss") .parse(visitData.get("visitDate").toString()); saveVisit.setVisitdate(date); } catch (java.text.ParseException ex) { ex.printStackTrace(); } saveVisit.setSubmitteddate(new Date()); visitFacadeREST.create(saveVisit); /****************Product Result*********************/ JSONArray Productarray = (JSONArray) visitData.get("productResult"); for (Iterator<JSONObject> it1 = Productarray.iterator(); it1.hasNext();) { JSONObject ProductJson = it1.next(); ProductResult productResult = new ProductResult(); productResult.setQuantity(new BigInteger(ProductJson.get("quantity").toString())); productResult.setExsit(new BigInteger(ProductJson.get("exist").toString())); productResult.setVisitid(saveVisit); Productkpis ProductKPI = em.getReference(Productkpis.class, new BigDecimal(ProductJson.get("productKpiId").toString())); productResult.setProductid(ProductKPI); productResultFacadeREST.create(productResult); } /*********************Price Result*******************/ JSONArray Pricearray = (JSONArray) visitData.get("priceResult"); if (Pricearray.size() > 0) { for (Iterator<JSONObject> it2 = Pricearray.iterator(); it2.hasNext();) { JSONObject PriceJson = it2.next(); PriceResult priceResult = new PriceResult(); priceResult.setVisitid(saveVisit); priceResult.setPrice(new BigDecimal(PriceJson.get("pricevalue").toString())); priceResult.setPricetagexist(new BigInteger(PriceJson.get("pricetagcheck").toString())); Pricekpis PriceKPI = em.getReference(Pricekpis.class, new BigDecimal(PriceJson.get("priceKPIid").toString())); priceResult.setPriceid(PriceKPI); priceResultFacadeREST.create(priceResult); } } /*********************Question Result*****************/ JSONArray Questionarray = (JSONArray) visitData.get("questionResult"); for (Iterator<JSONObject> it3 = Questionarray.iterator(); it3.hasNext();) { JSONObject QuestionJson = it3.next(); QuestionResult questionResult = new QuestionResult(); questionResult.setVisitid(saveVisit); questionResult.setAnswertext(QuestionJson.get("answerText").toString()); Questionkpis questionKPI = em.getReference(Questionkpis.class, new BigDecimal(QuestionJson.get("questionId").toString())); questionResult.setQuestionid(questionKPI); questionResultFacadeREST.create(questionResult); } /*********************Promotion Result*********************/ JSONArray promotionarray = (JSONArray) visitData.get("promotionResult"); for (Iterator<JSONObject> it4 = promotionarray.iterator(); it4.hasNext();) { JSONObject PromotionJson = it4.next(); PromotionResult promotionResult = new PromotionResult(); promotionResult.setVisitid(saveVisit); promotionResult.setExist(new BigInteger(PromotionJson.get("exist").toString())); Promotionkpis promotionKPI = em.getReference(Promotionkpis.class, new BigDecimal(PromotionJson.get("promotionKPIid").toString())); promotionResult.setPromotionid(promotionKPI); promotionResultFacadeREST.create(promotionResult); } /***********************ShareOfFolder Result*********************/ JSONArray ShareOfFolderarray = (JSONArray) visitData.get("sofResult"); for (Iterator<JSONObject> it5 = ShareOfFolderarray.iterator(); it5.hasNext();) { JSONObject SofJson = it5.next(); ShareoffolderKpiResult SofResult = new ShareoffolderKpiResult(); SofResult.setVisitid(saveVisit); SofResult.setNoofpicture(new BigInteger(SofJson.get("noOfPicture").toString())); SofResult.setTotalofpicture(new BigInteger(SofJson.get("totalNoOfPicture").toString())); Shareoffolderkpis shareoffolderkpis = em.getReference(Shareoffolderkpis.class, new BigDecimal(SofJson.get("sofID").toString())); SofResult.setSofid(shareoffolderkpis); SofResult.setSofexist(new BigInteger(SofJson.get("sofExist").toString())); shareoffolderKpiResultFacadeREST.create(SofResult); } /***************************STOCK Result***********************/ JSONArray Stockarray = (JSONArray) visitData.get("stockResult"); for (Iterator<JSONObject> it8 = Stockarray.iterator(); it8.hasNext();) { JSONObject StockJson = it8.next(); StockResult stockResult = new StockResult(); stockResult.setQuantity(new BigInteger(StockJson.get("quantity").toString())); stockResult.setVisitid(saveVisit); stockResult.setStockquantity(new BigInteger(StockJson.get("stockQuantity").toString())); Stockkpis stockKPI = em.getReference(Stockkpis.class, new BigDecimal(StockJson.get("stockKpiId").toString())); stockResult.setStockid(stockKPI); stockResultFacadeREST.create(stockResult); } /********************NPD Result**************************/ JSONArray Npdarray = (JSONArray) visitData.get("npdResult"); for (Iterator<JSONObject> it6 = Npdarray.iterator(); it6.hasNext();) { JSONObject NpdJson = it6.next(); NpdResult npdResult = new NpdResult(); npdResult.setVisitid(saveVisit); npdResult.setExist(new BigInteger(NpdJson.get("exist").toString())); Npdkpis npdKPI = em.getReference(Npdkpis.class, new BigDecimal(NpdJson.get("npdid").toString())); npdResult.setNpdid(npdKPI); npdResultFacadeREST.create(npdResult); } /***********************share of shelf Result**********************/ JSONArray shareOfShelfarray = (JSONArray) visitData.get("shareOfShelfResult"); for (Iterator<JSONObject> it7 = shareOfShelfarray.iterator(); it7.hasNext();) { JSONObject ShareOfShelfJson = it7.next(); ShareofshelfKpiResult shareofshelfKpiResult = new ShareofshelfKpiResult(); shareofshelfKpiResult.setVisitid(saveVisit); shareofshelfKpiResult.setSosbrand(new BigInteger(ShareOfShelfJson.get("sosBrand").toString())); shareofshelfKpiResult.setSossegment(new BigInteger(ShareOfShelfJson.get("sosSegment").toString())); Shareofshelfkpi ShareOfShelfKPI = em.getReference(Shareofshelfkpi.class, new BigDecimal(ShareOfShelfJson.get("shareofShelfID").toString())); shareofshelfKpiResult.setShareofshelfid(ShareOfShelfKPI); shareofshelfKpiResultFacadeREST.create(shareofshelfKpiResult); } /***********************POS Result************************/ JSONArray Posarray = (JSONArray) visitData.get("posResult"); for (Iterator<JSONObject> it9 = Posarray.iterator(); it9.hasNext();) { JSONObject PosJson = it9.next(); PosmaterialResult posResult = new PosmaterialResult(); posResult.setVisitid(saveVisit); posResult.setExist(new BigInteger(PosJson.get("exist").toString())); Posmaterialkpi posmaterialKPI = em.getReference(Posmaterialkpi.class, new BigDecimal(PosJson.get("posid").toString())); posResult.setPosmaterialid(posmaterialKPI); posmaterialResultFacadeREST.create(posResult); } } }
From source file:eu.serco.dhus.plugin.slstr.SlstrPlugin.java
private JSONArray getLatestValidityClosestInput(String start, String stop, JSONArray input) { JSONArray response = new JSONArray(); ;//from www . j a v a2s. c o m Date middleDate; try { middleDate = computeMiddleDate(start, stop); Iterator<JSONObject> i = input.iterator(); JSONObject latestValidityClosest = new JSONObject(); long diffInMillis = -1; while (i.hasNext()) { JSONObject obj = i.next(); String title = (String) obj.get("identifier"); String startTime = title.substring(16, 31); String stopTime = title.substring(32, 47); Date inputMiddleDate = computeMiddleDate(startTime, stopTime); if (diffInMillis == -1) { diffInMillis = Math.abs(middleDate.getTime() - inputMiddleDate.getTime()); latestValidityClosest = obj; } else { if (Math.abs(middleDate.getTime() - inputMiddleDate.getTime()) < diffInMillis) { diffInMillis = Math.abs(middleDate.getTime() - inputMiddleDate.getTime()); latestValidityClosest = obj; } } } response.add(latestValidityClosest); } catch (Exception e) { logger.error("Error computing middle date " + e.getMessage()); e.printStackTrace(); } return response; }