Commit d8992aa4 authored by Michael Menzel's avatar Michael Menzel

Perf. imp. for track matrix in wizard

parent c7426656
......@@ -29,9 +29,9 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpSession;
import java.net.SocketTimeoutException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.stream.Collectors;
import static de.thm.spring.controller.ControllerHelper.setModel;
......@@ -210,9 +210,15 @@ public class WizardController {
if(collector != null) {
List<String> trackNames = DataTableCache.getInstance(collector).getTrackNames();
Map<String, List<Integer>> ids = new TreeMap<>();
Collections.sort(trackNames);
for(TrackPackage pack: collector.getPackages()){
// Map<String, List<Integer>> ids = new TreeMap<>();
List<List<Integer>> ids = new ArrayList<>();
List<TrackPackage> packages = collector.getPackages();
packages.sort(Comparator.comparing(TrackPackage::getCellLine));
for (TrackPackage pack : packages) {
List<Integer> linkIds = new ArrayList<>();
List<String> packNames = pack.getTrackList().stream().map(Track::getName).map(String::toLowerCase).collect(Collectors.toList());
......@@ -226,7 +232,7 @@ public class WizardController {
linkIds.add(-1);
}
ids.put(pack.getCellLine(), linkIds);
ids.add(linkIds);
}
model.addAttribute("ids", ids);
......@@ -234,7 +240,14 @@ public class WizardController {
model.addAttribute("trackNames", trackNames);
model.addAttribute("packages", collector.getPackages());
model.addAttribute("assembly", collector.getAssembly());
model.addAttribute("celllines", DataTableCache.getInstance(collector).getCellLines());
model.addAttribute("celllines", new ArrayList<>(collector.getCellLines().keySet()).parallelStream()
.filter(cl -> collector.getPackages()
.stream()
.map(TrackPackage::getCellLine)
.anyMatch(cl::equals))
.sorted()
.collect(Collectors.toList()));
} else {
logger.warn("ApplicationController: Collector for data is null");
......
......@@ -88,3 +88,7 @@ h4{
font-size:10px;
float: right;
}
#maintable {
display: none;
}
......@@ -99,7 +99,7 @@
<div class="div2">
<div id="datatable" class="table-responsive">
<table class="table table-hover">
<table id="maintable" class="table table-hover">
<col width="200"/>
<th:block th:each="track: ${trackNames}">
......@@ -124,56 +124,23 @@
</th:block>
<tbody>
<th:block th:each="cl: ${celllines}">
<th:block th:if="${#lists.isEmpty(cl.value)}">
<th:block th:each="cl, iter: ${celllines}">
<tr class="clrow">
<td class="rowheader" th:text="${cl.key}"></td>
<td class="rowheader" th:text="${cl}"></td>
<th:block th:each="pack: ${ids}">
<th:block th:if="${cl.key == pack.key}">
<th:block th:each="value,iter: ${pack.value}">
<th:block th:each="value, trackiter: ${ids[iter.index]}">
<td class="row" th:if="${value != -1}"><input class="check" type="checkbox" th:field="${interfaceCommand.tracks}" th:value="${value}" th:title="${'Track '+ trackNames[iter.index] + ' for ' + cl.key}"/></td>
<td class="row" th:if="${value == -1}"></td>
</th:block>
</th:block>
<td class="row" th:if="${value != -1}"><input class="check"
type="checkbox"
th:field="${interfaceCommand.tracks}"
th:value="${value}"
th:title="${'Track '+ trackNames[trackiter.index] + ' for ' + cl}"/>
</td>
<td class="row" th:if="${value == -1}"></td>
</th:block>
</tr>
</th:block>
<th:block th:if="${not #lists.isEmpty(cl.value)}">
<tr class="clrow">
<td class="rowheader" th:title="${cl.key}" th:text="${cl.key}"></td>
</tr>
<th:block th:each="inner: ${cl.value}">
<tr class="clrow">
<td class="subrowheader rowheader" th:title="${inner}"
th:text="${inner}"></td>
<th:block th:each="pack: ${ids}">
<th:block th:if="${inner == pack.key}">
<th:block th:each="value: ${pack.value}">
<td class="row" th:title="${value}"
th:if="${value != -1}"><input class="check"
type="checkbox"
th:field="${interfaceCommand.tracks}"
th:value="${value}"/>
</td>
<td class="row" th:if="${value == -1}"></td>
</th:block>
</th:block>
</th:block>
</tr>
</th:block>
</th:block>
</th:block>
</tbody>
......@@ -253,20 +220,6 @@
}
</script>
<script>
$(".acidjs-css3-treeview").delegate("label input:checkbox", "change", function () {
var
checkbox = $(this),
nestedList = checkbox.parent().next().next(),
selectNestedListCheckbox = nestedList.find("label:not([for]) input:checkbox");
if (checkbox.is(":checked")) {
return selectNestedListCheckbox.prop("checked", true);
}
selectNestedListCheckbox.prop("checked", false);
});
</script>
<script src="/js/celltable.js" th:href="@{/js/celltable.js}" ></script>
<script>
......@@ -298,6 +251,9 @@
</script>
<script>
document.getElementById("maintable").setAttribute("style", "display: table")
</script>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment