use of org.apache.commons.lang3.StringUtils.replace in project Gargoyle by callakrsos.
the class CommonsSqllPan method menuExportInsertScriptOnAction.
@Override
public void menuExportInsertScriptOnAction(ActionEvent e) {
Optional<Pair<String, String[]>> showTableInputDialog = showTableInputDialog(f -> f.getName());
// Optional<Pair<String, String>> showInputDialog = DialogUtil.showInputDialog("table Name", "테이블명을 입력하세요.");
if (showTableInputDialog == null)
return;
showTableInputDialog.ifPresent(op -> {
if (op == null || op.getValue() == null)
return;
String schemaName = op.getValue()[0];
String _tableName = op.getValue()[1];
String tableName = "";
if (ValueUtil.isNotEmpty(schemaName)) {
tableName = String.format("%s.%s", schemaName, _tableName);
} else {
tableName = _tableName;
}
List<Map<String, Object>> items = getSelectedTabResultItems();
Map<String, Object> map = items.get(0);
final Set<String> keySet = map.keySet();
StringBuilder clip = new StringBuilder();
String insertPreffix = "insert into " + tableName;
String collect = keySet.stream().collect(Collectors.joining(",", "(", ")"));
String insertMiddle = " values ";
List<String> valueList = items.stream().map(v -> {
return ValueUtil.toJSONObject(v);
}).map(v -> {
Iterator<String> iterator = keySet.iterator();
List<Object> values = new ArrayList<>();
while (iterator.hasNext()) {
String columnName = iterator.next();
Object value = v.get(columnName);
values.add(value);
}
return values;
}).map(list -> {
return list.stream().map(str -> {
if (str == null)
return null;
else {
String convert = str.toString();
convert = convert.substring(1, convert.length() - 1);
if (convert.indexOf("'") >= 0) {
try {
convert = StringUtils.replace(convert, "'", "''");
} catch (Exception e1) {
e1.printStackTrace();
}
}
return "'".concat(convert).concat("'");
}
}).collect(Collectors.joining(",", "(", ")"));
}).map(str -> {
return new StringBuilder().append(insertPreffix).append(collect).append(insertMiddle).append(str).append(";\n").toString();
}).collect(Collectors.toList());
valueList.forEach(str -> {
clip.append(str);
});
SimpleTextView parent = new SimpleTextView(clip.toString());
parent.setWrapText(false);
FxUtil.createStageAndShow(String.format("[InsertScript] Table : %s", tableName), parent, stage -> {
});
});
}
use of org.apache.commons.lang3.StringUtils.replace in project eol-globi-data by jhpoelen.
the class CitationUtil method getDOI.
public static String getDOI(Dataset dataset) {
String doi = dataset.getOrDefault("doi", "");
URI archiveURI = dataset.getArchiveURI();
if (StringUtils.isBlank(doi)) {
String recordZenodo = StringUtils.replace(archiveURI.toString(), ZENODO_URL_PREFIX, "");
String[] split = recordZenodo.split("/");
if (split.length > 0) {
doi = "https://doi.org/10.5281/zenodo." + split[0];
}
}
return doi;
}
use of org.apache.commons.lang3.StringUtils.replace in project symja_android_library by axkr.
the class F method showGraphic.
public static String showGraphic(IExpr expr) {
try {
if (expr.isSameHeadSizeGE(Graphics, 2)) {
return openSVGOnDesktop((IAST) expr);
} else if (expr.isSameHeadSizeGE(Graphics3D, 2)) {
StringBuilder buf = new StringBuilder();
if (GraphicsFunctions.renderGraphics3D(buf, (IAST) expr, EvalEngine.get())) {
try {
String manipulateStr = buf.toString();
String html = JSBuilder.buildGraphics3D(JSBuilder.GRAPHICS3D_TEMPLATE, manipulateStr);
return openHTMLOnDesktop(html);
} catch (Exception ex) {
LOGGER.debug("JSBuilder.buildGraphics3D() failed", ex);
}
}
} else if (expr instanceof GraphExpr) {
String javaScriptStr = GraphFunctions.graphToJSForm((GraphExpr) expr);
if (javaScriptStr != null) {
String html = Config.VISJS_PAGE;
html = StringUtils.replace(html, "`1`", javaScriptStr);
html = StringUtils.replace(html, "`2`", "var options = {};");
return openHTMLOnDesktop(html);
}
} else if (expr.isAST(JSFormData, 3)) {
return printJSFormData(expr);
} else if (expr.isString()) {
IStringX str = (IStringX) expr;
if (str.getMimeType() == IStringX.TEXT_HTML) {
String htmlSnippet = str.toString();
String htmlPage = Config.HTML_PAGE;
htmlPage = StringUtils.replace(htmlPage, "`1`", htmlSnippet);
EvalEngine.get().getOutPrintStream().println(htmlPage);
return openHTMLOnDesktop(htmlPage);
}
} else if (expr.isList(x -> x.isAST(JSFormData, 3))) {
StringBuilder buf = new StringBuilder();
((IAST) expr).forEach(x -> buf.append(printJSFormData(x)));
return buf.toString();
}
} catch (Exception ex) {
LOGGER.debug("F.showGraphic() failed", ex);
}
return null;
}
use of org.apache.commons.lang3.StringUtils.replace in project cas by apereo.
the class Log4jInitialization method setMainArguments.
@Override
public void setMainArguments(final String[] mainArguments) {
val args = Arrays.stream(mainArguments).filter(arg -> arg.startsWith("--logging.level")).map(arg -> StringUtils.replace(arg, "=", " ")).toArray(String[]::new);
MainMapLookup.setMainArguments(args);
}
Aggregations