List of usage examples for java.util ArrayList toString
public String toString()
From source file:org.venice.piazza.servicecontroller.messaging.handlers.DeleteServiceHandler.java
/** * Handler for the DeleteServiceJob that was submitted. Stores the metadata * in MongoDB (non-Javadoc)// w w w .j a v a 2 s. co m * * @see org.venice.piazza.servicecontroller.messaging.handlers.Handler#handle( * model.job.PiazzaJobType) */ @Override public ResponseEntity<String> handle(PiazzaJobType jobRequest) { ResponseEntity<String> responseEntity; if (jobRequest != null) { coreLogger.log("Deleting a service", Severity.DEBUG); DeleteServiceJob job = (DeleteServiceJob) jobRequest; // Get the ResourceMetadata String resourceId = job.serviceID; coreLogger.log("deleteService serviceId=" + resourceId, Severity.INFORMATIONAL); String result = handle(resourceId, false); if ((result != null) && (result.length() > 0)) { String jobId = job.getJobId(); ArrayList<String> resultList = new ArrayList<>(); resultList.add(jobId); resultList.add(resourceId); responseEntity = new ResponseEntity<>(resultList.toString(), HttpStatus.OK); } else { coreLogger.log("No result response from the handler, something went wrong", Severity.ERROR); responseEntity = new ResponseEntity<>("DeleteServiceHandler handle didn't work", HttpStatus.NOT_FOUND); } } else { coreLogger.log("A null PiazzaJobRequest was passed in. Returning null", Severity.ERROR); responseEntity = new ResponseEntity<>("A Null PiazzaJobRequest was received", HttpStatus.BAD_REQUEST); } return responseEntity; }
From source file:org.quackbot.hooks.core.ServerCommand.java
public String onCommand(CommandEvent event, String action, String target, @Optional String[] arg2) throws Exception { Bot bot = event.getBot();/*from w w w . j a v a2 s .co m*/ Controller controller = bot.getController(); if (action.equalsIgnoreCase("list")) { ArrayList<String> serverNames = new ArrayList(controller.getBots().size()); for (Bot curBot : controller.getBots()) serverNames.add(curBot.getServer()); return "Connected to servers: " + serverNames.toString().substring(0, serverNames.toString().length()); } else if (action.equalsIgnoreCase("add")) { controller.addServer(target); return "Attempting to join server: " + target; } else if (action.equalsIgnoreCase("quit")) { String quitMessage = "Bot killed by user " + event.getUser().getNick(); if (StringUtils.isBlank(target)) //Assume quitting this server bot.quitServer(quitMessage); else { //Trying to quit another server for (Bot curBot : controller.getBots()) if (curBot.getServer().equalsIgnoreCase(target)) { curBot.quitServer(quitMessage); return "Quit server " + target; } //Getting here means the server wasn't found throw new RuntimeException("Can't find server " + target); } } else if (action.equalsIgnoreCase("lock")) { bot.setBotLocked(true); return "Bot locked on this server"; } else if (action.equalsIgnoreCase("unlock")) { bot.setBotLocked(false); return "Bot unlocked on this server"; } else if (action.equalsIgnoreCase("lockStatus")) return "Bot locked status: " + ((bot.isBotLocked()) ? "Locked" : "Unlocked"); else return "Unknown operation: " + action; return null; }
From source file:controllers.OldSensorReadingController.java
public static Result add(Boolean publish) throws Exception { JsonNode json = request().body().asJson(); if (json == null) { return badRequest("Expecting Json data"); }//from w ww .j av a2s. c o m if (!checkDao()) { return internalServerError("database conf file not found"); } // Parse JSON FIle String deviceId = json.findPath("id").getTextValue(); Long timeStamp = json.findPath("timestamp").getLongValue(); Iterator<String> it = json.getFieldNames(); ArrayList<String> error = new ArrayList<String>(); while (it.hasNext()) { String sensorType = it.next(); if (sensorType == "id" || sensorType == "timestamp") continue; double value = json.findPath(sensorType).getDoubleValue(); if (!sensorReadingDao.addReading(deviceId, timeStamp, sensorType, value)) { error.add(sensorType + ", " + deviceId + ", " + timeStamp.toString() + ", " + value + "\n"); } if (publish) { MessageBusHandler mb = new MessageBusHandler(); if (!mb.publish(new models.OldSensorReading(deviceId, timeStamp, sensorType, value))) { error.add("publish failed"); } } } if (error.size() == 0) { System.out.println("saved"); return ok("saved"); } else { System.out.println("some not saved: " + error.toString()); return ok("some not saved: " + error.toString()); } }
From source file:jsentvar.DataMapperTest.java
/** * Test of getUris method, of class DataMapper. *//*from www. j a v a 2s . c o m*/ @Test public void testGetUris() throws IOException { System.out.println("getUris Test"); String term_value0 = "intelligent_systems"; String term_value = term_value0.substring(0, 1).toUpperCase() + term_value0.substring(1); Surrogate sur = new Surrogate(term_value, this.model); String mode = "wide"; String term_id = term_value.replace(" ", "_"); String queryString = sur.preQuery(mode, term_id); DataMapper instance = new DataMapper(); instance.setModel(this.model); ArrayList<String> result0 = instance.getUris(queryString, mode); String expResult; expResult = FileUtils.readFileToString(new File("resources/test/getUrisResult.txt"), "utf8"); String result = result0.toString(); assertEquals(expResult, result); // TODO review the generated test code and remove the default call to fail. // fail("getUris error."); }
From source file:io.github.tonyguyot.acronym.ui.HistoryFragment.java
private void onResultSuccess(Intent intent) { ArrayList<Acronym> results = AcronymService.ListIntent.getResultList(intent); if (results != null) { Log.d(TAG, results.toString()); // display the number of results in the status text view if (results.isEmpty()) { // no result found mAdapter.clear(); // in case there was something in the list previously setMessageText(R.string.history_empty); } else {/*from w w w. ja v a 2 s .co m*/ // one or more results found setResultList(results); } } else { // this should not happen here and will be treated as an error onResultFailed(); } }
From source file:nl.hnogames.domoticz.Fragments.Temperature.java
private void processTemperature() { final TemperatureClickListener listener = this; mDomoticz.getTemperatures(new TemperatureReceiver() { @Override// w w w .j av a 2s . c om public void onReceiveTemperatures(ArrayList<TemperatureInfo> mTemperatureInfos) { successHandling(mTemperatureInfos.toString(), false); if (getView() != null) { mSwipeRefreshLayout = (SwipeRefreshLayout) getView().findViewById(R.id.swipe_refresh_layout); coordinatorLayout = (CoordinatorLayout) getView().findViewById(R.id.coordinatorLayout); adapter = new TemperatureAdapter(mContext, mTemperatureInfos, listener); listView = (ListView) getView().findViewById(R.id.listView); listView.setAdapter(adapter); listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> adapterView, View view, int index, long id) { showInfoDialog(adapter.filteredData.get(index)); return true; } }); mSwipeRefreshLayout.setRefreshing(false); mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { processTemperature(); } }); hideProgressDialog(); } } @Override public void onError(Exception error) { errorHandling(error); } }); }
From source file:org.venice.piazza.servicecontroller.messaging.handlers.UpdateServiceHandler.java
/** * Handler for the RegisterServiceJob that was submitted. Stores the metadata in MongoDB * @see org.venice.piazza.servicecontroller.messaging.handlers.Handler#handle(model.job.PiazzaJobType) *///from w w w .ja v a 2 s . co m public ResponseEntity<String> handle(PiazzaJobType jobRequest) { LOGGER.debug("Updating a service"); UpdateServiceJob job = (UpdateServiceJob) jobRequest; if (job != null) { // Get the ResourceMetadata Service sMetadata = job.data; LOGGER.info("serviceMetadata received is " + sMetadata); coreLogger.log("serviceMetadata received is " + sMetadata, Severity.INFORMATIONAL); String result = handle(sMetadata); if (result.length() > 0) { String jobId = job.getJobId(); // TODO Use the result, send a message with the resource Id and jobId ArrayList<String> resultList = new ArrayList<>(); resultList.add(jobId); resultList.add(sMetadata.getServiceId()); return new ResponseEntity<String>(resultList.toString(), HttpStatus.OK); } else { coreLogger.log("No result response from the handler, something went wrong", Severity.ERROR); return new ResponseEntity<String>("UpdateServiceHandler handle didn't work", HttpStatus.UNPROCESSABLE_ENTITY); } } else { coreLogger.log("A null PiazzaJobRequest was passed in. Returning null", Severity.ERROR); return new ResponseEntity<String>("A Null PiazzaJobRequest was received", HttpStatus.BAD_REQUEST); } }
From source file:com.javacodegags.waterflooding.controller.AdminController.java
@RequestMapping(value = "/admin/updateCriteria", method = RequestMethod.POST, produces = "application/json;charset=UTF-8") public @ResponseBody String updateCriterias(@RequestBody String postBody) throws JSONException { JSONObject jsono = new JSONObject(postBody); Criteria criteria = new CustomJSONParser().jsonToCriteria(jsono); criteriaInterface.updateCriteria(criteria); ArrayList<Parameters> alp = new CustomJSONParser().jsonToListParams(jsono.getJSONArray("params"), criteria.getId());//w w w .jav a 2s. c om LOG.info(alp.toString()); parameterInterface.deleteParams(criteria.getId()); for (Parameters p : alp) { parameterInterface.insertParams(p); } return jsono.toString(); }
From source file:pt.webdetails.cpk.sitemap.LinkGenerator.java
public JsonNode getLinksJson() { ObjectMapper mapper = new ObjectMapper(); JsonNode jnode = null;//w w w . ja v a2 s.c o m ArrayList<String> json = new ArrayList<String>(); for (Link l : dashboardLinks) { json.add(l.getLinkJson()); } try { jnode = mapper.readTree(json.toString()); } catch (IOException ex) { logger.error(ex); } return jnode; }
From source file:com.github.lynxdb.server.api.http.handlers.EpPut.java
@RequestMapping(path = "", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity put(Authentication _authentication, @RequestBody @Valid List<Metric> _request, BindingResult _bindingResult) {/*from www . ja v a 2s . co m*/ User user = (User) _authentication.getPrincipal(); if (_bindingResult.hasErrors()) { ArrayList<String> errors = new ArrayList(); _bindingResult.getFieldErrors().forEach((FieldError t) -> { errors.add(t.getField() + ": " + t.getDefaultMessage()); }); return new ErrorResponse(mapper, HttpStatus.BAD_REQUEST, errors.toString(), null).response(); } List<com.github.lynxdb.server.core.Metric> metricList = new ArrayList<>(); _request.stream().forEach((m) -> { metricList.add(new com.github.lynxdb.server.core.Metric(m)); }); try { entries.insertBulk(vhosts.byId(user.getVhost()), metricList); } catch (Exception ex) { throw ex; } return ResponseEntity.status(HttpStatus.NO_CONTENT).build(); }