List of usage examples for java.lang String join
public static String join(CharSequence delimiter, Iterable<? extends CharSequence> elements)
From source file:com.sisrni.dao.ProyectoDao.java
public List<PojoMapaInteractivo> getProjectListToCharts(List<String> paisSelected, List<String> tipoProyectoSelected, String desde, String hasta) { String wherePais = ""; String whereTipoProyecto = ""; String groupBy = " GROUP BY pr.ID_PAIS_COOPERANTE"; String limite = ""; List<String> paisesFinales = new ArrayList<String>(); if (paisSelected.size() > 0) { wherePais = wherePais + " AND pa.ID_PAIS IN (" + String.join(",", paisSelected) + ")"; } else {/*w ww. j av a 2 s . c om*/ limite += " LIMIT 5"; } if (tipoProyectoSelected.size() > 0) { whereTipoProyecto += " AND pr.ID_TIPO_PROYECTO IN (" + String.join(",", tipoProyectoSelected) + ")"; } String query = "SELECT pa.ID_PAIS as idPais,pa.CODIGO_PAIS as codigoPais, pa.NOMBRE_PAIS as nombrePais, SUM(pr.MONTO_PROYECTO) as montoCooperacion,COUNT(pr.ID_PROYECTO) as cantidadProyectos\n" + " FROM PROYECTO pr INNER JOIN PAIS pa ON pr.ID_PAIS_COOPERANTE = pa.ID_PAIS\n" + " WHERE pr.ANIO_GESTION BETWEEN " + Integer.parseInt(desde) + " AND " + Integer.parseInt(hasta) + "\n" + wherePais + whereTipoProyecto + groupBy + limite; try { Query q = getSessionFactory().getCurrentSession().createSQLQuery(query) .addScalar("idPais", new IntegerType()).addScalar("codigoPais", new StringType()) .addScalar("nombrePais", new StringType()).addScalar("montoCooperacion", new DoubleType()) .addScalar("cantidadProyectos", new IntegerType()) .setResultTransformer(Transformers.aliasToBean(PojoMapaInteractivo.class)); List<PojoMapaInteractivo> listPojos = q.list(); if (listPojos.size() > 0) { for (PojoMapaInteractivo pj : listPojos) { paisesFinales.add(pj.idPais.toString().trim()); } String qt = "SELECT tp.ID_TIPO_PROYECTO as idTipoProyecto,tp.NOMBRE_TIPO_PROYECTO as nombreTipoProyecto,count(pr.ID_PROYECTO) as cantidadProyectos FROM PROYECTO pr INNER JOIN TIPO_PROYECTO tp ON pr.ID_TIPO_PROYECTO = tp.ID_TIPO_PROYECTO\n" + " WHERE pr.ANIO_GESTION BETWEEN " + Integer.parseInt(desde) + " AND " + Integer.parseInt(hasta) + "\n" + "AND pr.ID_PAIS_COOPERANTE IN(" + String.join(",", paisesFinales) + ")" + whereTipoProyecto + " GROUP BY tp.ID_TIPO_PROYECTO"; Query rtp = getSessionFactory().getCurrentSession().createSQLQuery(qt) .addScalar("idTipoProyecto", new IntegerType()) .addScalar("nombreTipoProyecto", new StringType()) .addScalar("cantidadProyectos", new IntegerType()) .setResultTransformer(Transformers.aliasToBean(PojoProyectosByTipo.class)); List<PojoProyectosByTipo> listTipos = rtp.list(); for (PojoMapaInteractivo pj : listPojos) { String qp = "SELECT * FROM PROYECTO pr \n" + " WHERE pr.ANIO_GESTION BETWEEN " + Integer.parseInt(desde) + " AND " + Integer.parseInt(hasta) + "\n" + "AND pr.ID_PAIS_COOPERANTE=" + pj.getIdPais() + whereTipoProyecto; //String qp = "from Proyect pr Where pr.idPaisCooperante='" + pj.getCodigoPais() + "' and pr.idTipoProyecto in (" + String.join(",", tipoProyectoSelected) + ") and pr.anioGestion between " + Integer.parseInt(desde) + " AND " + Integer.parseInt(hasta); Query r = getSessionFactory().getCurrentSession().createSQLQuery(qp).addEntity(Proyecto.class); pj.setProjectList(r.list()); pj.setSeries(listTipos); } } return listPojos; } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:com.netflix.spinnaker.clouddriver.jobs.local.JobExecutorLocal.java
private <T> JobResult<T> executeWrapper(final JobRequest jobRequest, RequestExecutor<T> requestExecutor) { log.debug(String.format("Starting job: '%s'...", String.join(" ", jobRequest.getTokenizedCommand()))); final String jobId = UUID.randomUUID().toString(); JobResult<T> jobResult;// www. j a va 2 s. c om try { jobResult = requestExecutor.execute(jobRequest); } catch (IOException e) { throw new RuntimeException("Failed to execute job", e); } if (jobResult.isKilled()) { log.warn(String.format("Job %s timed out (after %d minutes)", jobId, timeoutMinutes)); } return jobResult; }
From source file:co.runrightfast.vertx.core.eventbus.EventBusAddress.java
/** * Address format follows a URI path convention, but prefixes the path with 'runrightfast'. * * e.g., eventBusAddress("path1","path2","path3") returns "/runrightfast/path1/path2/path3" * * * @param path REQUIRED/* w w w. jav a2s . com*/ * @param paths OPTIONAL * @return eventbus address */ public static String runrightfastEventBusAddress(final String path, final String... paths) { checkArgument(isNotBlank(path)); final StringBuilder sb = new StringBuilder(128).append('/').append(RUNRIGHTFAST).append('/').append(path); if (ArrayUtils.isNotEmpty(paths)) { checkArgument(!Arrays.stream(paths).filter(StringUtils::isBlank).findFirst().isPresent()); sb.append('/').append(String.join("/", paths)); } return sb.toString(); }
From source file:com.hp.octane.integrations.testhelpers.OctaneSecuritySimulationUtils.java
static private Cookie createSecurityCookie(String client, String secret) { Cookie result = new Cookie(SECURITY_COOKIE_NAME, String.join(SECURITY_TOKEN_SEPARATOR, Stream .of(client, secret, String.valueOf(System.currentTimeMillis())).collect(Collectors.toList()))); result.setHttpOnly(true);//from w ww . ja v a2 s . c om result.setDomain(".localhost"); return result; }
From source file:com.blackducksoftware.integration.hub.detect.help.print.HelpTextWriter.java
public void write(final PrintStream printStream) { printStream.println(String.join(System.lineSeparator(), pieces)); }
From source file:com.jayway.restassured.module.mockmvc.http.MultiValueController.java
@RequestMapping(value = "/threeMultiValueParam", method = POST, produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody String threeMultiValueParam(@RequestParam("list") List<String> list1Values, @RequestParam("list2") List<String> list2Values, @RequestParam("list3") List<String> list3Values) { return "{ \"list\" : \"" + String.join(",", list1Values) + "\"," + " \"list2\" : \"" + String.join(",", list2Values) + "\", " + " \"list3\" : \"" + String.join(",", list3Values) + "\" }"; }
From source file:edu.harvard.iq.dataverse.BibtexCitation.java
@Override public String toString() { StringBuilder citation = new StringBuilder("@data{"); citation.append(persistentId.getIdentifier() + "_" + year + "," + "\r\n"); citation.append("author = {").append(String.join(" and ", authors)).append("},\r\n"); citation.append("publisher = {").append(publisher).append("},\r\n"); citation.append("title = {").append(title).append("},\r\n"); citation.append("year = {").append(year).append("},\r\n"); citation.append("doi = {").append(persistentId.getAuthority()).append("/") .append(persistentId.getIdentifier()).append("},\r\n"); citation.append("url = {").append(persistentId.toURL().toString()).append("}\r\n"); citation.append("}"); return citation.toString(); }
From source file:rc.championship.platform.decoder.lap.publisher.JaxRSLapPublisher.java
public void setTargets(List<String> targets) { String str = String.join(";", targets); NbPreferences.forModule(getClass()).put("targets", str); reloadTargetsFromProperties();/*from w w w . j a va 2s.c o m*/ }
From source file:de.jackwhite20.japs.server.command.impl.SetCommand.java
@Override public boolean execute(String[] args) { if (args.length < 2) { JaPS.getLogger().info("Usage: set <Key> [Expire] <Value>"); return false; }/* w w w . ja v a 2 s . co m*/ int expire = -1; String value = args[1]; if (args.length >= 3) { try { expire = Integer.parseInt(args[1]); } catch (NumberFormatException e) { JaPS.getLogger().info("'" + args[1] + "' is not a number"); return false; } String[] values = new String[args.length - 2]; System.arraycopy(args, 2, values, 0, args.length - 2); value = String.join(" ", values); } JaPS.getServer().cache().put(args[0], value); JaPS.getServer().clusterBroadcast(null, new JSONObject().put("op", OpCode.OP_CACHE_ADD.getCode()) .put("key", args[0]).put("value", value).put("expire", expire)); return true; }
From source file:org.travis4j.rest.Request.java
private <T> String join(CharSequence delimiter, Collection<T> values) { return String.join(delimiter, toStringList(values)); }