List of usage examples for java.util List toString
public String toString()
From source file:edu.harvard.i2b2.fhir.FetchInterceptor.java
@Override public boolean incomingRequestPostProcessed(RequestDetails theRequestDetails, HttpServletRequest theRequest, HttpServletResponse theResponse) throws AuthenticationException { ourLog.info("incomingRequestPostProcessed" + theRequest.getPathInfo() + theRequest.getMethod()); if (theRequest.getMethod() != "GET") { ourLog.debug("exiting fetch interceptor as its not a GET request"); return true; }/*w w w . jav a2 s .co m*/ try { //if patient id is not specified run a a population query FetchRequest req = new FetchRequest(theRequestDetails); String fsId = req.getPatientId() + "-" + req.getRequestDetails().getResourceName(); if (req.getPatientId() == null || req.getPatientId().equals("")) {// throw new // FetcherException("Pa ourLog.info("reqDet:" + theRequestDetails.getRequestPath()); //String path=theRequestDetails.getRequestPath(); String path = "Patient?gender=male"; alterResponse(theResponse, path); return false; } } catch (IOException e) { ourLog.error(e.getMessage(), e); } List<String> list = new ArrayList<String>(); list.add(theRequestDetails.getOperation()); list.add(theRequestDetails.getResourceName()); if (theRequestDetails.getId() != null && theRequestDetails.getId().getIdPart() != null) { list.add(theRequestDetails.getId().getIdPart()); } ourLog.info("incomingRequestPostProcessed" + list.toString()); try { String msg = LocalUtils.readFile("samples/PatientFhirBundlePut.xml"); ApplicationContext appContext = AppContext.getApplicationContext(); if (appContext == null) { ourLog.warn("appContextIsNull"); } else { //Cache cache = (Cache) appContext.getBean("cacheImpl"); //String res = cache.put(msg); //injectPOJO(null,null,null, theRequestDetails); // new MyDao().inject(); Fetcher fetcher = (Fetcher) appContext.getBean("fetcherImpl"); fetcher.getData(theRequestDetails); //ourLog.info(res); } } catch (IOException e) { e.printStackTrace(); } catch (FetcherException e) { e.printStackTrace(); } return true; }
From source file:net.sf.jtmt.clustering.GeneticClusterer.java
/** * Cluster./*from w w w.j av a 2 s . c o m*/ * * @param collection the collection * @return the list */ public List<Cluster> cluster(DocumentCollection collection) { // get initial clusters int k = (int) Math.floor(Math.sqrt(collection.size())); List<Cluster> clusters = new ArrayList<Cluster>(); for (int i = 0; i < k; i++) { Cluster cluster = new Cluster("C" + i); clusters.add(cluster); } if (randomizeData) { collection.shuffle(); } // load it up using mod partitioning, this is P(0) int docId = 0; for (String documentName : collection.getDocumentNames()) { int clusterId = docId % k; clusters.get(clusterId).addDocument(documentName, collection.getDocument(documentName)); docId++; } log.debug("Initial clusters = " + clusters.toString()); // holds previous cluster in the compute loop List<Cluster> prevClusters = new ArrayList<Cluster>(); double prevFitness = 0.0D; int generations = 0; for (;;) { // compute fitness for P(t) double fitness = computeFitness(clusters); // if termination condition achieved, break and return clusters if (prevFitness > fitness) { clusters.clear(); clusters.addAll(prevClusters); break; } // even if termination condition not met, terminate after the // maximum number of generations if (generations > maxGenerations) { break; } // do specified number of crossover operations for this generation for (int i = 0; i < numCrossoversPerMutation; i++) { crossover(clusters, collection, i); generations++; } // followed by a single mutation per generation mutate(clusters, collection); generations++; log.debug("..Intermediate clusters (" + generations + "): " + clusters.toString()); // hold on to previous solution prevClusters.clear(); prevClusters.addAll(clusters); prevFitness = computeFitness(prevClusters); } return clusters; }
From source file:org.apache.drill.exec.store.http.HttpGroupScan.java
/** * * @param incomingEndpoints// ww w . j a va 2s . co m */ @Override public void applyAssignments(List<DrillbitEndpoint> incomingEndpoints) { watch.reset(); watch.start(); final int numSlots = incomingEndpoints.size(); logger.info("incomingEndpoints size: " + numSlots); logger.info("incomingEndpoints: " + incomingEndpoints.toString()); Preconditions.checkArgument(numSlots <= httpWorks.size(), String.format( "Incoming endpoints %d is greater than number of scan regions %d", numSlots, httpWorks.size())); /* * Minimum/Maximum number of assignment per slot */ final int minPerEndpointSlot = (int) Math.floor((double) httpWorks.size() / numSlots); final int maxPerEndpointSlot = (int) Math.ceil((double) httpWorks.size() / numSlots); endpointFragmentMapping = Maps.newHashMapWithExpectedSize(numSlots); Boolean executeLimitFlg = calcExecuteLimitFlg(); List<String> orderByCols = httpScanSpec.generateOrderByCols(); for (int i = 0; i < httpWorks.size(); i++) { int slotIndex = i % numSlots; HttpWork work = httpWorks.get(i); List<HttpSubScanSpec> endpointSlotScanList = endpointFragmentMapping.get(slotIndex); if (endpointSlotScanList == null) { endpointSlotScanList = new ArrayList<HttpSubScanSpec>(maxPerEndpointSlot); } //TODO HttpSubScanSpec tmpScanSpec = new HttpSubScanSpec(work.getDbName(), httpScanSpec.getTableName(), storagePluginConfig.getConnection(), storagePluginConfig.getResultKey(), work.getPartitionKeyStart(), work.getPartitionKeyEnd(), httpScanSpec.getFilterArgs(), httpScanSpec.getGroupByCols(), orderByCols, executeLimitFlg ? httpScanSpec.getLimitValue() : null, this.columns); endpointSlotScanList.add(tmpScanSpec); endpointFragmentMapping.put(slotIndex, endpointSlotScanList); logger.info("endpointSlotScanList: " + endpointSlotScanList); } logger.info("applyAssignments endpointFragmentMapping: " + endpointFragmentMapping); logger.debug("Built assignment map in {} s.\nEndpoints: {}.\nAssignment Map: {}", watch.elapsed(TimeUnit.NANOSECONDS) / 1000, incomingEndpoints, endpointFragmentMapping.toString()); }
From source file:net.sourceforge.jaulp.lang.ObjectUtilsTest.java
@SuppressWarnings({ "rawtypes", "unchecked" }) @Test(enabled = false)// w w w . j a v a 2s. c o m public void testCompareTo() throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { List<Person> persons = new ArrayList<>(); Person obelix = new Person(); obelix.setGender(Gender.MALE); obelix.setName("obelix"); Person asterix = new Person(); asterix.setGender(Gender.MALE); asterix.setName("asterix"); Person miraculix = new Person(); miraculix.setGender(Gender.MALE); miraculix.setName("miraculix"); int i = ObjectUtils.compareTo(asterix, obelix, "name"); System.out.println(i); persons.add(obelix); persons.add(asterix); persons.add(miraculix); System.out.println("Unsorted Persons:"); System.out.println(persons.toString()); Comparator defaultComparator = new BeanComparator("name"); Collections.sort(persons, defaultComparator); System.out.println("Sorted Persons by name:"); System.out.println(persons.toString()); Collections.reverse(persons); System.out.println("Sorted Persons by name reversed:"); System.out.println(persons.toString()); }
From source file:com.smart.smartrestfulw.controller.FileDepotController.java
/** * ?/* w ww .j a v a 2 s .c o m*/ * * @param strParam * @param uploadFiles * @return */ @RequestMapping(value = "/UpLoadFileParam", method = RequestMethod.POST, consumes = { org.springframework.http.MediaType.MULTIPART_FORM_DATA_VALUE }, produces = { org.springframework.http.MediaType.APPLICATION_JSON_VALUE }) @ResponseBody public String UpLoadFileParam(@RequestParam("param") String strParam, @RequestParam("file") List<MultipartFile> uploadFiles) { FileDepotParamModel paramModel = null; try { paramModel = analyzeUpLoadFileJsonStr(strParam, false); System.out.println(uploadFiles.toString()); return SaveUpLoadFile(uploadFiles, paramModel, false); } catch (Exception ex) { RSLogger.ErrorLogInfo( String.format("UpLoadFileParamError:%s,param%s", ex.getLocalizedMessage(), strParam), ex); return responseFormat.formationResultToString(ResponseResultCode.Error, ex); //return formationResult.formationResult(ResponseResultCode.Error, new ExecuteResultParam(ex.getLocalizedMessage(), paramModel == null ? null : paramModel.toStringInformation())); } }
From source file:com.campusconnect.GoogleSignInActivity.java
private void firebaseAuthWithGoogle(final GoogleSignInAccount acct) { Log.d(TAG, "firebaseAuthWithGoogle:" + acct.getId()); // [START_EXCLUDE silent] showProgressDialog();// w w w. j a va 2 s. co m // [END_EXCLUDE] AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null); mAuth.signInWithCredential(credential).addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { Log.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful()); // If sign in fails, display a message to the user. If sign in succeeds // the auth state listener will be notified and logic to handle the // signed in user can be handled in the listener. if (!task.isSuccessful()) { Log.w(TAG, "signInWithCredential", task.getException()); Toast.makeText(GoogleSignInActivity.this, "Authentication failed.", Toast.LENGTH_SHORT).show(); } else { Bundle params = new Bundle(); params.putString("firebaseauth", "success"); firebaseAnalytics.logEvent("login_firebase", params); personName = acct.getDisplayName(); personEmail = acct.getEmail(); personId = acct.getId(); Log.i("sw32", personId + ": here"); if (acct.getPhotoUrl() != null) { personPhoto = acct.getPhotoUrl().toString() + ""; Log.d("photourl", personPhoto); } else personPhoto = "shit"; // mStatusTextView.setText(getString(R.string.signed_in_fmt, acct.getDisplayName())); SharedPreferences sharedpreferences = getSharedPreferences("CC", Context.MODE_PRIVATE); if (sharedpreferences.contains("profileId")) { Intent home = new Intent(GoogleSignInActivity.this, HomeActivity2.class); home.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(home); finish(); } else { //TODO: SIGN-IN Retrofit retrofit = new Retrofit.Builder().baseUrl(MyApi.BASE_URL) .addConverterFactory(GsonConverterFactory.create()).build(); MyApi myApi = retrofit.create(MyApi.class); Log.i("sw32", personEmail + " : " + personId + " : " + FirebaseInstanceId.getInstance().getToken()); MyApi.getProfileRequest body = new MyApi.getProfileRequest(personEmail, personId, FirebaseInstanceId.getInstance().getToken()); Call<ModelGetProfile> call = myApi.getProfile(body); call.enqueue(new Callback<ModelGetProfile>() { @Override public void onResponse(Call<ModelGetProfile> call, Response<ModelGetProfile> response) { ModelGetProfile profile = response.body(); if (profile != null) { if (profile.getResponse().equals("0")) { SharedPreferences sharedPreferences = getSharedPreferences("CC", MODE_PRIVATE); sharedPreferences.edit().putString("profileId", profile.getProfileId()) .putString("collegeId", profile.getCollegeId()) .putString("personId", personId) .putString("collegeName", profile.getCollegeName()) .putString("batchName", profile.getBatchName()) .putString("branchName", profile.getBranchName()) .putString("sectionName", profile.getSectionName()) .putString("profileName", personName) .putString("email", personEmail) .putString("photourl", profile.getPhotourl()).apply(); Log.d("profileId", profile.getProfileId()); Intent home = new Intent(GoogleSignInActivity.this, HomeActivity2.class); home.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(home); finish(); } else { try { String decider = Branch.getInstance().getLatestReferringParams() .getString("+clicked_branch_link"); Intent registration = new Intent(GoogleSignInActivity.this, RegistrationPageActivity.class); if (decider.equals("false")) { registration.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); registration.putExtra("personName", personName); registration.putExtra("personEmail", personEmail); registration.putExtra("personPhoto", personPhoto); registration.putExtra("personId", personId); startActivity(registration); finish(); Log.d("branch", "regester called"); } } catch (JSONException e) { e.printStackTrace(); } } } } @Override public void onFailure(Call<ModelGetProfile> call, Throwable t) { } }); } } // [START_EXCLUDE] //Branch login try { String decider = Branch.getInstance().getLatestReferringParams() .getString("+clicked_branch_link"); if (decider.equals("true")) { if (Branch.isAutoDeepLinkLaunch(GoogleSignInActivity.this)) { final String collegeId = Branch.getInstance().getLatestReferringParams() .getString("collegeId"); final String collegeName = Branch.getInstance().getLatestReferringParams() .getString("collegeName"); final String batchName = Branch.getInstance().getLatestReferringParams() .getString("batch"); final String branchName = Branch.getInstance().getLatestReferringParams() .getString("branch"); final String sectionName = Branch.getInstance().getLatestReferringParams() .getString("sectionName"); String brachCoursesId = Branch.getInstance().getLatestReferringParams() .getString("coursesId"); Log.d("brancS:", brachCoursesId); String replace = brachCoursesId.replace("[", ""); String replace1 = replace.replace("]", ""); final List<String> coursesId = new ArrayList<String>( Arrays.asList(replace1.split("\\s*,\\s*"))); Log.d("brancL:", coursesId.toString()); Retrofit branchRetrofit = new Retrofit.Builder().baseUrl(FragmentCourses.BASE_URL) .addConverterFactory(GsonConverterFactory.create()).build(); MyApi myApi = branchRetrofit.create(MyApi.class); final MyApi.getProfileIdRequest request; Log.d("firebase", FirebaseInstanceId.getInstance().getId()); request = new MyApi.getProfileIdRequest(personName, collegeId, batchName, branchName, sectionName, personPhoto, personEmail, FirebaseInstanceId.getInstance().getId(), personId); Call<ModelSignUp> modelSignUpCall = myApi.getProfileId(request); modelSignUpCall.enqueue(new Callback<ModelSignUp>() { @Override public void onResponse(Call<ModelSignUp> call, Response<ModelSignUp> response) { ModelSignUp signUp = response.body(); if (signUp != null) { profileId = signUp.getKey(); SharedPreferences sharedPreferences = getSharedPreferences("CC", MODE_PRIVATE); sharedPreferences.edit().putString("profileId", profileId) .putString("collegeId", collegeId).putString("personId", personId) .putString("collegeName", collegeName) .putString("batchName", batchName) .putString("branchName", branchName) .putString("sectionName", sectionName) .putString("profileName", personName) .putString("email", personEmail).putString("photourl", personPhoto) .apply(); Log.d("branch login sucess", profileId); Retrofit retrofit = new Retrofit.Builder().baseUrl(FragmentCourses.BASE_URL) .addConverterFactory(GsonConverterFactory.create()).build(); MyApi branchMyApi = retrofit.create(MyApi.class); MyApi.subscribeCourseRequest subscribeCourseRequest = new MyApi.subscribeCourseRequest( profileId, coursesId); Call<ModelSubscribe> courseSubscribeCall = branchMyApi .subscribeCourse(subscribeCourseRequest); courseSubscribeCall.enqueue(new Callback<ModelSubscribe>() { @Override public void onResponse(Call<ModelSubscribe> call, Response<ModelSubscribe> response) { ModelSubscribe subscribe = response.body(); if (subscribe != null) { Log.d("branch response:", subscribe.getResponse()); SharedPreferences sharedPreferences = getSharedPreferences("CC", MODE_PRIVATE); sharedPreferences.edit() .putString("coursesId", coursesId.toString()).apply(); } Intent intent_temp = new Intent(getApplicationContext(), HomeActivity2.class); intent_temp.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent_temp); Log.d("branch", "home activity"); Bundle params = new Bundle(); params.putString("course_subscribe", "success"); firebaseAnalytics.logEvent("course_subscribe", params); finish(); } @Override public void onFailure(Call<ModelSubscribe> call, Throwable t) { Log.d("couses", "failed"); } }); } } @Override public void onFailure(Call<ModelSignUp> call, Throwable t) { Log.d("branch login", "failed"); } }); } else { Log.e("BRanch", "Launched by normal application flow"); } } } catch (JSONException e) { e.printStackTrace(); } hideProgressDialog(); // [END_EXCLUDE] } }); }
From source file:delfos.rs.trustbased.WeightedGraph.java
@Override public int compareTo(WeightedGraph<Node> o) { List<Node> allNodes = this.allNodes().stream().sorted().collect(Collectors.toList()); List<Node> allNodesOther = o.allNodes().stream().sorted().collect(Collectors.toList()); int compareNatural = StringsOrderings.compareNatural(allNodes.toString(), allNodesOther.toString()); if (compareNatural != 0) { return compareNatural; } else {/*from ww w. j av a 2 s.c om*/ return Integer.compare(this.hashCode(), o.hashCode()); } }
From source file:com.pinterest.arcee.handler.GroupHandler.java
public void attachInstanceToAutoScalingGroup(List<String> instanceIds, String groupName) throws Exception { List<String> runningIds = hostInfoDAO.getRunningInstances(instanceIds); if (runningIds.isEmpty()) { LOG.info("Instances {} are not running. Cannot attach to group {}", instanceIds.toString(), groupName); return;//w ww. j a v a 2 s.c om } AutoScalingGroupBean asgInfo = asgDAO.getAutoScalingGroupInfoByName(groupName); Set<String> instanceIdsInAsg = new HashSet<>(asgInfo.getInstances()); for (Iterator<String> iterator = runningIds.iterator(); iterator.hasNext();) { if (instanceIdsInAsg.contains(iterator.next())) { // Remove the instance that has been attached iterator.remove(); } } if (!runningIds.isEmpty()) { jobPool.submit(new AttachInstanceToGroupJob(groupName, null, runningIds, 0, null)); } }
From source file:org.starfishrespect.myconsumption.android.tasks.StatValuesUpdater.java
public void refreshDB() { AsyncTask<Void, List, Void> task = new AsyncTask<Void, List, Void>() { @Override/*from www.ja va 2 s. c o m*/ protected Void doInBackground(Void... params) { DatabaseHelper db = SingleInstance.getDatabaseHelper(); RestTemplate template = new RestTemplate(); HttpHeaders httpHeaders = CryptoUtils.createHeadersCurrentUser(); ResponseEntity<StatDTO[]> responseEnt; template.getMessageConverters().add(new MappingJacksonHttpMessageConverter()); try { for (SensorData sensor : db.getSensorDao().queryForAll()) { // Stats String url = String.format(SingleInstance.getServerUrl() + "stats/sensor/%s", sensor.getSensorId()); responseEnt = template.exchange(url, HttpMethod.GET, new HttpEntity<>(httpHeaders), StatDTO[].class); StatDTO[] statsArray = responseEnt.getBody(); List<StatDTO> stats = new ArrayList<>(Arrays.asList(statsArray)); ObjectMapper mapper = new ObjectMapper(); try { String json = mapper.writeValueAsString(stats); String key = "stats_" + sensor.getSensorId(); int id = db.getIdForKey(key); KeyValueData valueData = new KeyValueData(key, json); valueData.setId(id); LOGD(TAG, "writing stat in local db: " + json); db.getKeyValueDao().createOrUpdate(valueData); } catch (IOException e) { LOGD(TAG, "Cannot create stats " + stats.toString(), e); } } } catch (SQLException e) { LOGD(TAG, "Cannot create stats ", e); } catch (ResourceAccessException | HttpClientErrorException e) { LOGE(TAG, "Cannot access server ", e); } return null; } @Override protected void onPostExecute(Void aVoid) { if (statUpdateFinishedCallback != null) { statUpdateFinishedCallback.onStatUpdateFinished(); } } }; task.execute(); }
From source file:de.hopmann.repositories.cran.service.CRANPackageListingService.java
@Transactional(TxType.REQUIRES_NEW) public void updatePackageListing() { // TODO make sure called only once // TODO handle multiple repos // for (String sourceRepository : cranRepositories) { log.info("Updating package listing"); String sourceRepository = cranRepositories[0]; HttpGet getListing = new HttpGet(sourceRepository + "src/contrib/PACKAGES"); try {/*from w ww .j ava 2 s.c o m*/ CloseableHttpResponse httpResponse = httpclient.execute(getListing); ControlFile<CRANPackageDescriptionRecord> controlFile = new ControlFile<CRANPackageDescriptionRecord>( CRANPackageDescriptionRecord.class, new InputStreamReader(httpResponse.getEntity().getContent())); log.info("clearing listing"); try { removeCurrentListing(); } catch (Exception e) { e.printStackTrace(); controlFile.close(); return; } log.info("adding packages"); List<String> failedRecords = new ArrayList<String>(); CRANPackageDescriptionRecord record = null; while ((record = controlFile.readRecord()) != null) { if (record.getPackageName() == null) continue; try { addPackage(record.buildEntity()); } catch (Exception e) { if (record.getPackageName() != null) { failedRecords.add(record.getPackageName()); } } } controlFile.close(); log.warning("Adding of following package entries failed: " + failedRecords.toString()); } catch (IOException e) { e.printStackTrace(); } // } log.info("Finished updating package listing"); }