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.MovilidadDao.java
public List<PojoMapaMovilidad> getBecastListToCharts(Integer tipoMovilidad, List<String> paisSelected, List<String> categoriaSelected, String desde, String hasta) { String campoUnion = ""; if (tipoMovilidad == 1) { campoUnion = campoUnion + "m.ID_PAIS_ORIGEN"; } else {//from w ww. ja v a2 s .c o m campoUnion = campoUnion + "m.ID_PAIS_DESTINO"; } String query = "SELECT\n" + " p.ID_PAIS idPais,\n" + " p.CODIGO_PAIS codigoPais," + " p.NOMBRE_PAIS nombrePais," + " count(*) cantidadMovilidades," + " SUM(m.VIATICOS+m.PAGO_DE_CURSO+m.VOLETO_AEREO) montoMovilidades " + " FROM MOVILIDAD m INNER JOIN PAIS p ON " + campoUnion + " = p.ID_PAIS" + " WHERE m.ID_TIPO_MOVILIDAD = " + tipoMovilidad + " and m.ID_ETAPA_MOVILIDAD=3 " + " and YEAR(m.FECHA_INICIO) BETWEEN " + Integer.parseInt(desde) + " and " + Integer.parseInt(hasta) + " and " + campoUnion + " IN " + "(" + String.join(",", paisSelected) + ")" + " and m.ID_CATEGORIA IN " + "(" + String.join(",", categoriaSelected) + ")" + "GROUP BY " + campoUnion; Query q = getSessionFactory().getCurrentSession().createSQLQuery(query) .addScalar("idPais", new IntegerType()).addScalar("codigoPais", new StringType()) .addScalar("nombrePais", new StringType()).addScalar("cantidadMovilidades", new IntegerType()) .addScalar("montoMovilidades", new DoubleType()) .setResultTransformer(Transformers.aliasToBean(PojoMapaMovilidad.class)); return q.list(); }
From source file:com.networknt.client.oauth.OauthHelper.java
public static String getEncodedString(TokenRequest request) throws UnsupportedEncodingException { Map<String, String> params = new HashMap<>(); params.put(GRANT_TYPE, request.getGrantType()); if (TokenRequest.AUTHORIZATION_CODE.equals(request.getGrantType())) { params.put(CODE, ((AuthorizationCodeRequest) request).getAuthCode()); params.put(REDIRECT_URI, ((AuthorizationCodeRequest) request).getRedirectUri()); String csrf = request.getCsrf(); if (csrf != null) { params.put(CSRF, csrf);/*from w ww. ja v a 2 s. c o m*/ } } if (TokenRequest.REFRESH_TOKEN.equals(request.getGrantType())) { params.put(REFRESH_TOKEN, ((RefreshTokenRequest) request).getRefreshToken()); String csrf = request.getCsrf(); if (csrf != null) { params.put(CSRF, csrf); } } if (request.getScope() != null) { params.put(SCOPE, String.join(" ", request.getScope())); } return Http2Client.getFormDataString(params); }
From source file:configuration.Cluster.java
public static boolean clusterPbs(workflow_properties properties) { // Server name String serverName = getClusterServerName(clusterAccessAddress(properties)); String clusterDir = properties.get("ClusterDirPath"); String c = updateCommandProgramForCluster(properties, clusterDir); Util.dm("Cluster CLI >" + c); String stdOut = getClusterFilePath(properties, "stdOutFile", ""); String stdErr = getClusterFilePath(properties, "stdErrFile", ""); String hours = "00"; String minutes = "05"; String seconds = "00"; String nodesV = "1"; String ppn = "1"; String emailV = "email@email.com"; if (properties.isSet("WalltimeHours_box")) hours = properties.get("WalltimeHours_box"); if (properties.isSet("WalltimeMinutes_box")) minutes = properties.get("WalltimeMinutes_box"); if (properties.isSet("WalltimeSeconds_box")) seconds = properties.get("WalltimeSeconds_box"); if (properties.isSet("BasicNodes_box")) nodesV = properties.get("BasicNodes_box"); if (properties.isSet("BasicPPN_box")) ppn = properties.get("BasicPPN_box"); if (properties.isSet("ContactEmail_box")) emailV = properties.get("ContactEmail_box"); if (properties.isSet("ContactEmail_box")) seconds = properties.get("ContactEmail_box"); String walltime = "#PBS -l walltime=" + hours + ":" + minutes + ":" + seconds + ""; String nodes = "#PBS -l nodes=" + nodesV + ":ppn=" + ppn + ""; // Need to be setted depending on cluster choosed String qwork = "#PBS -q qwork@mp2"; String r = "#PBS -r n"; String stdDoc = "#PBS -o " + stdOut + ""; String stdDec = "#PBS -e " + stdErr + ""; String email = "#PBS -M " + emailV + ""; String exitValue = "a=\"ExitStatus>\"$?\"<\"\necho $a"; /*/*from w w w. j a v a2 s .c om*/ WARNINGS ITS ONLY FOR ONE MODULE not if there is dependencies */ String module = "module load " + properties.get("ClusterModuleIs") + ""; // Prepare lines List<String> lines = new ArrayList<String>(); lines.add("#!/bin/bash"); lines.add(walltime); lines.add(nodes); lines.add(qwork); if (!serverName.contains("mp2")) { lines.add(r); lines.add(email); } lines.add(stdDoc); lines.add(stdDec); lines.add(module); lines.add(c); lines.add(exitValue); // Prepare bash file String fBash = Util.currentPath() + File.separator + "tmp" + File.separator + "clusterPbs.sh"; Util.CreateFile(fBash); Path file = Paths.get(fBash); try { Files.write(file, lines); } catch (IOException ex) { Logger.getLogger(Docker.class.getName()).log(Level.SEVERE, null, ex); return false; } if (isP2RsaHere()) { boolean b = runUploadFile(properties, fBash, clusterDir); if (!b) { return false; } properties.put("ClusterCommandLineRunning", c); properties.put("ClusterPBSInfo", String.join("\n", lines)); Util.deleteFile(fBash); String tasksNum = executePbsOnCluster(properties, clusterDir + "/clusterPbs.sh"); if (tasksNum != "") { properties.put("ClusterTasksNumber", tasksNum); return true; } } return false; }
From source file:com.flipkart.poseidon.serviceclients.generator.ServiceGenerator.java
private void addMetaAnnotations(ServiceIDL serviceIdl, JCodeModel jCodeModel, JDefinedClass serviceImpl) { String serviceName = canonicalName(getInterfaceName(serviceIdl), "ServiceClient", "SC"); addNameAnnotations(serviceImpl, serviceName); addVersionAnnotations(serviceImpl, serviceIdl.getVersion().getMajor(), serviceIdl.getVersion().getMinor(), serviceIdl.getVersion().getPatch()); String[] description = serviceIdl.getService().getDescription(); String shortDescription = description.length > 0 ? description[0] : getInterfaceName(serviceIdl); String fullDescription = description.length > 0 ? String.join(" ", description) : getInterfaceName(serviceIdl); addDescriptionAnnotations(serviceImpl, shortDescription, fullDescription); }
From source file:com.cdd.bao.editor.EditSchema.java
public void actionFileMerge() { FileChooser chooser = new FileChooser(); chooser.setTitle("Merge Schema"); if (schemaFile != null) chooser.setInitialDirectory(schemaFile.getParentFile()); File file = chooser.showOpenDialog(stage); if (file == null) return;/* w ww .ja v a 2 s .co m*/ Schema addSchema = null; try { addSchema = ModelSchema.deserialise(file); } catch (IOException ex) { ex.printStackTrace(); Util.informWarning("Merge", "Failed to parse file: is it a valid schema?"); return; } List<String> log = new ArrayList<>(); Schema merged = SchemaUtil.mergeSchema(stack.getSchema(), addSchema, log); if (log.size() == 0) { Util.informMessage("Merge", "The merge file is the same: no action."); return; } String text = String.join("\n", log); Dialog<Boolean> confirm = new Dialog<>(); confirm.setTitle("Confirm Merge Modifications"); TextArea area = new TextArea(text); area.setWrapText(true); area.setPrefWidth(700); area.setPrefHeight(500); confirm.getDialogPane().setContent(area); ButtonType btnApply = new ButtonType("Apply", ButtonBar.ButtonData.OK_DONE); confirm.getDialogPane().getButtonTypes().addAll(new ButtonType("Cancel", ButtonBar.ButtonData.CANCEL_CLOSE), btnApply); confirm.setResultConverter(buttonType -> { if (buttonType == btnApply) return true; return null; }); Optional<Boolean> result = confirm.showAndWait(); if (!result.isPresent() || result.get() != true) return; stack.changeSchema(merged, true); rebuildTree(); }
From source file:de.hska.ld.content.service.impl.DocumentServiceImpl.java
@Override public void fillAttachedEntitiesCounters(Document document) { String[] imageMimeType = { "image/cis-cod", "image/cmu-raster", "image/fif", "image/gif", "image/ief", "image/jpeg", "image/png", "image/tiff", "image/vasa", "image/vnd.wap.wbmp", "image/x-freehand", "image/x-icon", "image/x-portable-anymap", "image/x-portable-bitmap", "image/x-portable-graymap", "image/x-portable-pixmap", "image/x-rgb", "image/x-windowdump", "image/x-xbitmap", "image/x-xpixmap" }; String concatImageMimeType = String.join(";", imageMimeType); long fileAttachmentCount = getAttachmentCount(document, "all", concatImageMimeType); // exclude image types document.setFileAttachmentCount((int) fileAttachmentCount); long mediaAttachmentCount = getAttachmentCount(document, concatImageMimeType, ""); // include image types document.setMediaAttachmentCount((int) mediaAttachmentCount); }
From source file:com.ga.forms.DailyLogUI.java
private void exportButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportButtonActionPerformed System.out.print(// w w w . j a v a 2s. com "REGEX: " + monthCombo.getSelectedItem().toString() + "-" + yearCombo.getSelectedItem().toString()); JFrame fileChooserFrame = new JFrame(); JFileChooser saveFileDialog = new JFileChooser(); FileNameExtensionFilter fileExtentionFilter = new FileNameExtensionFilter("Comma Seperated Values (*.csv)", "csv"); saveFileDialog.setFileFilter(fileExtentionFilter); int saveFileDialogStatus = saveFileDialog.showSaveDialog(fileChooserFrame); if (saveFileDialogStatus == JFileChooser.APPROVE_OPTION) { String fileSaveDetails = saveFileDialog.getSelectedFile().toString(); args = new HashMap(); HashMap regex = new HashMap(); regex.put("$regex", monthCombo.getSelectedItem().toString() + "-" + yearCombo.getSelectedItem().toString()); args.put("date", regex); DailyLogRecord record = new DailyLogRecord(); ArrayList logs = record.retrieveRecord(args); String[] columnNames = new String[] { "Date", "Day", "In", "Out", "Break", "Duration", "Under-Time", "Over-Time" }; ArrayList data = null; if (!logs.isEmpty()) { data = new ArrayList(); data.add(String.join(",", columnNames)); for (int logIndex = 0; logIndex < logs.size(); logIndex++) { JSONObject logJSONOBject = new JSONObject((Map) logs.get(logIndex)); String csvRecord = logJSONOBject.get("date").toString() + "," + logJSONOBject.get("day").toString() + "," + logJSONOBject.get("check-in").toString() + "," + logJSONOBject.get("check-out").toString() + "," + logJSONOBject.get("break").toString() + "," + logJSONOBject.get("duration").toString() + "," + logJSONOBject.get("under-time").toString() + "," + logJSONOBject.get("over-time").toString(); data.add(csvRecord); } } DailyLogCSVExport csvExporter = new DailyLogCSVExport(); csvExporter.save(data, fileSaveDetails); } }
From source file:com.sisrni.dao.MovilidadDao.java
public List<PojoMovilidadMapaCategoria> getBecastListToChartsCate(Integer tipoMovilidad, List<String> paisSelected, List<String> categoriaSelected, String desde, String hasta) { String campoUnion = ""; if (tipoMovilidad == 1) { campoUnion = campoUnion + "m.ID_PAIS_ORIGEN"; } else {/*from www . j ava 2 s. com*/ campoUnion = campoUnion + "m.ID_PAIS_DESTINO"; } String query = "SELECT \n" + " cm.NOMBRE_CATEGORIA categoria,\n" + " count(*) cantidad" + " FROM MOVILIDAD m INNER JOIN PAIS p ON " + campoUnion + " = p.ID_PAIS" + " INNER JOIN CATEGORIA_MOVILIDAD cm on cm.ID_CATEGORIA_MOVILIDAD=m.ID_CATEGORIA" + " WHERE m.ID_TIPO_MOVILIDAD = " + tipoMovilidad + " and m.ID_ETAPA_MOVILIDAD=3 " + " and YEAR(m.FECHA_INICIO) BETWEEN " + Integer.parseInt(desde) + " and " + Integer.parseInt(hasta) + " and " + campoUnion + " IN " + "(" + String.join(",", paisSelected) + ")" + " and m.ID_CATEGORIA IN " + "(" + String.join(",", categoriaSelected) + ")" + " GROUP BY cm.ID_CATEGORIA_MOVILIDAD"; Query q = getSessionFactory().getCurrentSession().createSQLQuery(query) .addScalar("categoria", new StringType()).addScalar("cantidad", new IntegerType()) .setResultTransformer(Transformers.aliasToBean(PojoMovilidadMapaCategoria.class)); return q.list(); }
From source file:edu.cmu.cs.lti.discoursedb.api.browsing.controller.BrowsingRestController.java
@RequestMapping(value = "/action/downloadQueryCsv/discoursedb_data.csv", method = RequestMethod.GET) @ResponseBody/*from w w w.j a v a 2 s .c o m*/ String downloadQueryCsv(HttpServletResponse response, @RequestParam("query") String query, HttpServletRequest hsr, HttpSession session) throws IOException { securityUtils.authenticate(hsr, session); response.setContentType("application/csv; charset=utf-8"); response.setHeader("Content-Disposition", "attachment"); try { logger.info("Got query for csv: " + query); DdbQuery q = new DdbQuery(selector, discoursePartService, query); Page<BrowsingContributionResource> lbcr = q.retrieveAllContributions() .map(c -> new BrowsingContributionResource(c, annoService)); StringBuilder output = new StringBuilder(); ArrayList<String> headers = new ArrayList<String>(); for (PropertyDescriptor pd : BeanUtils.getPropertyDescriptors(BrowsingContributionResource.class)) { String name = pd.getName(); if (!name.equals("class") && !name.equals("id") && !name.equals("links")) { headers.add(name); } } output.append(String.join(",", headers)); output.append("\n"); for (BrowsingContributionResource bcr : lbcr.getContent()) { String comma = ""; BeanWrapper wrap = PropertyAccessorFactory.forBeanPropertyAccess(bcr); for (String hdr : headers) { String item = ""; try { item = wrap.getPropertyValue(hdr).toString(); item = item.replaceAll("\"", "\"\""); item = item.replaceAll("^\\[(.*)\\]$", "$1"); } catch (Exception e) { logger.info(e.toString() + " For header " + hdr + " item " + item); item = ""; } if (hdr.equals("annotations") && item.length() > 0) { logger.info("Annotation is " + item); } output.append(comma + "\"" + item + "\""); comma = ","; } output.append("\n"); } return output.toString(); } catch (Exception e) { return "ERROR:" + e.getMessage(); } }
From source file:com.orange.clara.cloud.servicedbdumper.integrations.AbstractIntegrationTest.java
protected Process runCommandLine(String[] commandLine) throws IOException, InterruptedException { logger.info("Running command line: " + String.join(" ", commandLine)); ProcessBuilder pb = new ProcessBuilder(commandLine); pb.redirectOutput(ProcessBuilder.Redirect.PIPE); Process process = pb.start(); return process; }