Bug fix bei addAprioriToCalc()

This commit is contained in:
2025-08-28 09:53:31 +02:00
parent d7a8788209
commit 9462bb0b94

View File

@@ -166,20 +166,23 @@ public class TreeHelper {
public TreeItem<Object> addAprioriToCalc(TreeItem<Object> calcItem, TreeItem<Object> aprioriItem) public TreeItem<Object> addAprioriToCalc(TreeItem<Object> calcItem, TreeItem<Object> aprioriItem)
throws InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException { throws InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
for (TreeItem<Object> aprioriChild : aprioriItem.getChildren()) { for (TreeItem<Object> aprioriChild : aprioriItem.getChildren()) {
boolean isInCalc = false;
List<TreeItem<Object>> matchingChildren = calcItem.getChildren().stream() int i = 0;
.filter(c -> ((ProduktbausteinType) c.getValue()).getId() for (TreeItem<Object> calcChild : calcItem.getChildren()) {
.equals(((ProduktbausteinType) aprioriChild.getValue()).getId())) if (((ProduktbausteinType) calcChild.getValue()).getId().equals(((ProduktbausteinType) aprioriChild.getValue()).getId()) || isNotIncluded.contains(calcChild)) {
.toList(); isInCalc = true;
if (!aprioriChild.getChildren().isEmpty()) {
if (matchingChildren.isEmpty()) { calcChild = addAprioriToCalc(calcChild, aprioriChild);
TreeItem<Object> newChild = cloneTreeItem(aprioriChild); calcItem.getChildren().set(i, calcChild);
}
calcItem.getChildren().add(newChild); }
addAprioriToCalc(newChild, aprioriChild); i++;
} else { }
for (TreeItem<Object> matchingChild : matchingChildren) { if (!isInCalc) {
addAprioriToCalc(matchingChild, aprioriChild); TreeItem<Object> missingCalcItem = cloneTreeItem(aprioriChild);
calcItem.getChildren().add(missingCalcItem);
if (!isNotIncluded.contains(missingCalcItem)) {
isNotIncluded.add(missingCalcItem);
} }
} }
} }