List of usage examples for java.util LinkedHashMap LinkedHashMap
public LinkedHashMap()
From source file:com.benasmussen.maven.plugin.i18n.io.JsonResourceWriter.java
@Override protected void before(ResourceEntry resourceEntry) { super.before(resourceEntry); List<String> locales = resourceEntry.getLocales(); for (String locale : locales) { output.put(locale, new LinkedHashMap<String, String>()); }/*www . j ava2 s .c o m*/ }
From source file:net.i2cat.netconf.messageQueue.MessageQueue.java
public MessageQueue() { listeners = new Vector<MessageQueueListener>(); queue = new LinkedHashMap<String, RPCElement>(); }
From source file:com.sugaronrest.restapicalls.methodcalls.DeleteEntry.java
/** * Deletes entry [SugarCRM REST method -set_entry (sets deleted to 1]. * * @param url REST API Url./* www. j a v a2s .c o m*/ * @param sessionId Session identifier. * @param moduleName SugarCRM module name. * @param id The entity identifier. * @return DeleteEntryResponse object. */ public static DeleteEntryResponse run(String url, String sessionId, String moduleName, String id) { DeleteEntryResponse deleteEntryResponse = null; ErrorResponse errorResponse = null; String jsonRequest = new String(); String jsonResponse = new String(); ObjectMapper mapper = JsonObjectMapper.getMapper(); try { Map<String, Object> requestData = new LinkedHashMap<String, Object>(); requestData.put("session", sessionId); requestData.put("module_name", moduleName); requestData.put("name_value_list", DeleteDataToNameValueList(id)); String jsonRequestData = mapper.writeValueAsString(requestData); Map<String, Object> request = new LinkedHashMap<String, Object>(); request.put("method", "set_entry"); request.put("input_type", "json"); request.put("response_type", "json"); request.put("rest_data", requestData); jsonRequest = mapper.writeValueAsString(request); request.put("rest_data", jsonRequestData); HttpResponse response = Unirest.post(url).fields(request).asString(); if (response == null) { deleteEntryResponse = new DeleteEntryResponse(); errorResponse = ErrorResponse.format("An error has occurred!", "No data returned."); deleteEntryResponse.setStatusCode(HttpStatus.SC_BAD_REQUEST); deleteEntryResponse.setError(errorResponse); } else { jsonResponse = response.getBody().toString(); if (StringUtils.isNotBlank(jsonResponse)) { // First check if we have an error errorResponse = ErrorResponse.fromJson(jsonResponse); if (errorResponse == null) { deleteEntryResponse = mapper.readValue(jsonResponse, DeleteEntryResponse.class); } } if (deleteEntryResponse == null) { deleteEntryResponse = new DeleteEntryResponse(); deleteEntryResponse.setError(errorResponse); deleteEntryResponse.setStatusCode(HttpStatus.SC_OK); if (errorResponse != null) { deleteEntryResponse.setStatusCode(errorResponse.getStatusCode()); } } else { deleteEntryResponse.setStatusCode(HttpStatus.SC_OK); } } } catch (Exception exception) { deleteEntryResponse = new DeleteEntryResponse(); errorResponse = ErrorResponse.format(exception, exception.getMessage()); deleteEntryResponse.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR); errorResponse.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR); deleteEntryResponse.setError(errorResponse); } deleteEntryResponse.setJsonRawRequest(jsonRequest); deleteEntryResponse.setJsonRawResponse(jsonResponse); return deleteEntryResponse; }
From source file:controllers.TREEProxy.java
public static F.Promise<Result> index(String query) { if (StringUtils.isEmpty(query)) { F.Promise.promise(new F.Function0<Object>() { @Override// w w w . j a v a 2s . co m public Object apply() throws Throwable { return ok(Json.toJson("Query parameter (q) not provided ")); } }); } String basicUrl = "https://www.googleapis.com/customsearch/v1element"; // Additional query parameters String key = "AIzaSyCVAXiUzRYsML1Pv6RwSG1gunmMikTzQqY"; String rsz = "filtered_cse"; final int num = 10; String hl = "el"; String cx = "017401606067716418337:btpggki1yw8"; F.Promise<WSResponse> wsResponsePromise = WS.url(basicUrl).setQueryParameter("key", key) .setQueryParameter("rsz", rsz).setQueryParameter("num", Integer.toString(num)) .setQueryParameter("hl", hl).setQueryParameter("cx", cx).setQueryParameter("q", query).get(); return wsResponsePromise.map(new F.Function<WSResponse, Result>() { @Override public Result apply(WSResponse wsResponse) throws Throwable { String body = wsResponse.getBody(); List<Map<String, String>> results = new ArrayList<Map<String, String>>(); try { JSONObject initialBody = new JSONObject(body); JSONArray resultArray = (JSONArray) initialBody.get("results"); for (int i = 0; i < resultArray.length(); i++) { Map<String, String> keyValue = new LinkedHashMap<String, String>(); JSONObject innerObj = new JSONObject(resultArray.get(i).toString()); JSONObject metaTags = (JSONObject) innerObj.get("richSnippet"); JSONObject ogTags = (JSONObject) metaTags.get("metatags"); keyValue.put("image", ogTags.get("ogImage").toString()); keyValue.put("title", ogTags.get("ogTitle").toString()); keyValue.put("content", ogTags.get("ogDescription").toString()); keyValue.put("date", innerObj.get("contentNoFormatting").toString().substring(0, innerObj.get("contentNoFormatting").toString().indexOf(".."))); keyValue.put("url", ogTags.get("ogUrl").toString()); results.add(keyValue); } } catch (DOMException e) { e.printStackTrace(); } return ok(Json.toJson(results)); } }); }
From source file:com.yahoo.sql4d.BaseStatementMeta.java
public Map<String, Object> getDataMap() { Map<String, Object> map = new LinkedHashMap<>(); JSONObject dataSourceJson = new JSONObject(); if (dataSource != null) { dataSourceJson.put("type", "table"); dataSourceJson.put("name", dataSource); } else if (queryDataSource != null) { dataSourceJson.put("type", "query"); dataSourceJson.put("query", queryDataSource.getDataMap()); }/*from w w w . ja v a 2 s. c o m*/ map.put("dataSource", dataSourceJson); return map; }
From source file:com.sugaronrest.restapicalls.methodcalls.GetEntry.java
/** * Gets entry [SugarCRM REST method - get_entry]. * * @param url REST API Url./* ww w . j av a2 s.c om*/ * @param sessionId Session identifier. * @param moduleName SugarCRM module name. * @param identifier The entity identifier. * @param selectFields Selected field list. * @return */ public static ReadEntryResponse run(String url, String sessionId, String moduleName, String identifier, List<String> selectFields) { ReadEntryResponse readEntryResponse = null; ErrorResponse errorResponse = null; String jsonRequest = new String(); String jsonResponse = new String(); ObjectMapper mapper = JsonObjectMapper.getMapper(); try { Map<String, Object> requestData = new LinkedHashMap<String, Object>(); requestData.put("session", sessionId); requestData.put("module_name", moduleName); requestData.put("id", identifier); requestData.put("select_fields", selectFields); requestData.put("link_name_to_fields_array", StringUtils.EMPTY); requestData.put("track_view", false); String jsonRequestData = mapper.writeValueAsString(requestData); Map<String, Object> request = new LinkedHashMap<String, Object>(); request.put("method", "get_entry"); request.put("input_type", "json"); request.put("response_type", "json"); request.put("rest_data", requestData); jsonRequest = mapper.writeValueAsString(request); request.put("rest_data", jsonRequestData); HttpResponse response = Unirest.post(url).fields(request).asString(); if (response == null) { readEntryResponse = new ReadEntryResponse(); errorResponse = ErrorResponse.format("An error has occurred!", "No data returned."); readEntryResponse.setStatusCode(HttpStatus.SC_BAD_REQUEST); readEntryResponse.setError(errorResponse); } else { jsonResponse = response.getBody().toString(); if (StringUtils.isNotBlank(jsonResponse)) { // First check if we have an error errorResponse = ErrorResponse.fromJson(jsonResponse); if (errorResponse == null) { readEntryResponse = mapper.readValue(jsonResponse, ReadEntryResponse.class); } } if (readEntryResponse == null) { readEntryResponse = new ReadEntryResponse(); readEntryResponse.setError(errorResponse); readEntryResponse.setStatusCode(HttpStatus.SC_OK); if (errorResponse == null) { errorResponse.setStatusCode(errorResponse.getStatusCode()); } } else { readEntryResponse.setStatusCode(HttpStatus.SC_OK); } } } catch (Exception exception) { readEntryResponse = new ReadEntryResponse(); errorResponse = ErrorResponse.format(exception, exception.getMessage()); readEntryResponse.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR); errorResponse.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR); readEntryResponse.setError(errorResponse); } readEntryResponse.setJsonRawRequest(jsonRequest); readEntryResponse.setJsonRawResponse(jsonResponse); return readEntryResponse; }
From source file:com.xylocore.cassandra.query.TableScanQueryBuilder.java
private TableScanQueryBuilder() { session = null; keyspace = null; tableName = null; columnsOfInterest = new LinkedHashMap<>(); executor(null); }
From source file:de.alpharogroup.io.annotations.ImportResourcesExtensions.java
/** * Gets a {@link Map} with {@link ImportResource} objects and the corresponding to the found * class from the given package Name. The search is made recursive. The key from an entry of the * map is the class where the {@link ImportResource} objects found and the value is an Array of * the {@link ImportResource} objects that contains in the class. * * @param packageName/*from w w w . jav a 2s . c om*/ * the package name * @return the import resources * @throws ClassNotFoundException * occurs if a given class cannot be located by the specified class loader * @throws IOException * Signals that an I/O exception has occurred. */ public static Map<Class<?>, ImportResource[]> getImportResources(final String packageName) throws ClassNotFoundException, IOException { final Map<Class<?>, ImportResource[]> resourcesMap = new LinkedHashMap<>(); final Class<ImportResources> importResourcesClass = ImportResources.class; final Class<ImportResource> importResourceClass = ImportResource.class; final Set<Class<?>> importResourcesClasses = AnnotationExtensions.getAllAnnotatedClasses(packageName, importResourcesClass); final Set<Class<?>> importResourceClasses = AnnotationExtensions.getAllAnnotatedClasses(packageName, importResourceClass); importResourcesClasses.addAll(importResourceClasses); for (final Class<?> annotatedClass : importResourcesClasses) { final ImportResources importResources = annotatedClass.getAnnotation(ImportResources.class); ImportResource[] importResourcesArray = null; ImportResource[] importResourceArray = null; if (importResources != null) { importResourcesArray = importResources.resources(); } final ImportResource importResource = annotatedClass.getAnnotation(ImportResource.class); if (importResource != null) { importResourceArray = new ImportResource[1]; importResourceArray[0] = importResource; } final ImportResource[] array = (ImportResource[]) ArrayUtils.addAll(importResourceArray, importResourcesArray); Arrays.sort(array, new ImportResourceComparator()); resourcesMap.put(annotatedClass, array); } return resourcesMap; }
From source file:com.yahoo.sql4d.query.groupby.Having.java
public Map<String, Object> getJsonMap() { Map<String, Object> map = new LinkedHashMap<>(); map.put("type", getTypeForSymbol(type)); map.put("aggregation", aggregation); map.put("value", value); if (havingSpecs != null) { if (type.equals("not")) { map.put("havingSpecs", havingSpecs.get(0).getJson()); } else {/*from ww w . j a v a 2 s . c o m*/ JSONArray havingSpecsArray = new JSONArray(); for (Having item : havingSpecs) { havingSpecsArray.put(item.getJson()); } map.put("havingSpecs", havingSpecsArray); } } return map; }
From source file:gov.nih.nci.cabig.caaers.web.ae.SubmitReportAjaxFacade.java
/** * This method fetches the ReportStatus of the report. Its used in the SubmitReportController page. * @param String aeReportId/* w ww. j a v a 2s . c om*/ * @param String reportId * @return */ public AjaxOutput fetchReportSubmissionStatus(String aeReportId, String reportId) { AjaxOutput output = new AjaxOutput(); Report report = reportDao.getById(Integer.parseInt(reportId)); Map<String, String> params = new LinkedHashMap<String, String>(); params.put("reportId", reportId); if (report.getLastVersion().getReportStatus().equals(ReportStatus.FAILED)) { output.setHtmlContent(renderAjaxView("reportSubmissionStatus", Integer.parseInt(aeReportId), params)); output.setObjectContent("FAILED"); } else if (report.getLastVersion().getReportStatus().equals(ReportStatus.COMPLETED)) { output.setHtmlContent(renderAjaxView("reportSubmissionStatus", Integer.parseInt(aeReportId), params)); output.setObjectContent("COMPLETED"); } return output; }