Skip to content

Commit

Permalink
Prettify
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoLaval committed Jul 8, 2024
1 parent c73a525 commit 239af7b
Show file tree
Hide file tree
Showing 3 changed files with 392 additions and 392 deletions.
138 changes: 69 additions & 69 deletions src/main/java/fr/insee/trevas/jupyter/DatasetUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,75 +10,75 @@

public class DatasetUtils {

public static String datasetToDisplay(Dataset dataset) {
Map<String, Dataset.Role> roles = dataset.getDataStructure().getRoles();
Dataset reducedDataset = new SparkDataset(
((SparkDataset) ((PersistentDataset) dataset).getDelegate())
.getSparkDataset()
.limit(50), roles);
var b = new StringBuilder();
b.append("<table id='dataset_").append(reducedDataset.hashCode()).append("' class='display'>");
b.append("<thead>");
b.append("<tr>");
reducedDataset.getDataStructure()
.forEach(
(name, component) -> {
b.append("<th>").append(name).append("</th>");
});
b.append("</tr>");
b.append("</thead>");
b.append("<tbody>");
reducedDataset.getDataPoints()
.forEach(
row -> {
b.append("<tr>");
reducedDataset.getDataStructure()
.keySet()
.forEach(
name -> {
b.append("<td>")
.append(row.get(name))
.append("</td>");
});
b.append("</tr>");
});
b.append("</tbody>");
b.append("</table>");
b.append(
"<script\n"
+ " src=\"https://code.jquery.com/jquery-3.6.0.slim.min.js\"\n"
+ " integrity=\"sha256-u7e5khyithlIdTpu22PHhENmPcRdFiHRjhAuHcs05RI=\"\n"
+ " crossorigin=\"anonymous\"></script>");
b.append(
"<link rel=\"stylesheet\" type=\"text/css\""
+ " href=\"https://cdn.datatables.net/1.12.1/css/jquery.dataTables.css\">\n"
+ " \n"
+ "<script type=\"text/javascript\" charset=\"utf8\""
+ " src=\"https://cdn.datatables.net/1.12.1/js/jquery.dataTables.js\"></script>\n");
b.append("<script type=\"text/javascript\">" + "$(document).ready( function () {\n" + " $('#dataset_").append(reducedDataset.hashCode()).append("').DataTable();\n").append("} );").append("</script>");
public static String datasetToDisplay(Dataset dataset) {
Map<String, Dataset.Role> roles = dataset.getDataStructure().getRoles();
Dataset reducedDataset = new SparkDataset(
((SparkDataset) ((PersistentDataset) dataset).getDelegate())
.getSparkDataset()
.limit(50), roles);
var b = new StringBuilder();
b.append("<table id='dataset_").append(reducedDataset.hashCode()).append("' class='display'>");
b.append("<thead>");
b.append("<tr>");
reducedDataset.getDataStructure()
.forEach(
(name, component) -> {
b.append("<th>").append(name).append("</th>");
});
b.append("</tr>");
b.append("</thead>");
b.append("<tbody>");
reducedDataset.getDataPoints()
.forEach(
row -> {
b.append("<tr>");
reducedDataset.getDataStructure()
.keySet()
.forEach(
name -> {
b.append("<td>")
.append(row.get(name))
.append("</td>");
});
b.append("</tr>");
});
b.append("</tbody>");
b.append("</table>");
b.append(
"<script\n"
+ " src=\"https://code.jquery.com/jquery-3.6.0.slim.min.js\"\n"
+ " integrity=\"sha256-u7e5khyithlIdTpu22PHhENmPcRdFiHRjhAuHcs05RI=\"\n"
+ " crossorigin=\"anonymous\"></script>");
b.append(
"<link rel=\"stylesheet\" type=\"text/css\""
+ " href=\"https://cdn.datatables.net/1.12.1/css/jquery.dataTables.css\">\n"
+ " \n"
+ "<script type=\"text/javascript\" charset=\"utf8\""
+ " src=\"https://cdn.datatables.net/1.12.1/js/jquery.dataTables.js\"></script>\n");
b.append("<script type=\"text/javascript\">" + "$(document).ready( function () {\n" + " $('#dataset_").append(reducedDataset.hashCode()).append("').DataTable();\n").append("} );").append("</script>");

return b.toString();
}
return b.toString();
}

public static String datasetMetadataToDisplay(Dataset dataset) {
StringBuilder sb = new StringBuilder();
sb.append("<ul>");
Structured.DataStructure dataStructure = dataset.getDataStructure();
dataStructure.forEach(
(key, value) -> {
sb.append("<li>")
.append(key)
.append(" (")
.append(value.getRole().name())
.append(" - ")
.append(value.getType().getSimpleName());
String valuedomain = value.getValuedomain();
if (null != valuedomain) {
sb.append(" - ").append(valuedomain);
}
sb.append(")").append("</li>").append("\n");
});
sb.append("</ul>");
return sb.toString();
}
public static String datasetMetadataToDisplay(Dataset dataset) {
StringBuilder sb = new StringBuilder();
sb.append("<ul>");
Structured.DataStructure dataStructure = dataset.getDataStructure();
dataStructure.forEach(
(key, value) -> {
sb.append("<li>")
.append(key)
.append(" (")
.append(value.getRole().name())
.append(" - ")
.append(value.getType().getSimpleName());
String valuedomain = value.getValuedomain();
if (null != valuedomain) {
sb.append(" - ").append(valuedomain);
}
sb.append(")").append("</li>").append("\n");
});
sb.append("</ul>");
return sb.toString();
}
}
Loading

0 comments on commit 239af7b

Please sign in to comment.