Commit 8b2305a7 authored by Luna Riegel's avatar Luna Riegel
Browse files

Refactor: Simplify error filtering

parent dbc4750b
......@@ -1391,7 +1391,6 @@ public class CityDoctorController {
List<GmlId> idList = model.getBuildingIds();
foundBuildings.removeIf(gmlId -> (!idList.contains(gmlId)));
// model.getBuildings().filter(Checkable::containsAnyError).forEach(co -> foundBuildings.add(co.getGmlId()));
Supplier<Stream<Building>> supply = () -> model.getCache().getStream(foundBuildings).map(co -> (Building) co);
buildBuildingTreeFromList(supply, root);
updateTree(root);
......@@ -1414,7 +1413,6 @@ public class CityDoctorController {
List<GmlId> idList = model.getVegetationIds();
foundVegetation.removeIf(gmlId -> (!idList.contains(gmlId)));
// model.getVegetation().filter(Checkable::containsAnyError).forEach(co -> foundVegetation.add(co.getGmlId()));
Supplier<Stream<Vegetation>> supply = () -> model.getCache().getStream(foundVegetation).map(co -> (Vegetation) co);
buildVegetationTreeFromList(supply, root);
updateTree(root);
......@@ -1437,7 +1435,6 @@ public class CityDoctorController {
List<GmlId> idList = model.getBridgeIds();
foundBridge.removeIf(gmlId -> (!idList.contains(gmlId)));
// model.getBridges().filter(Checkable::containsAnyError).forEach(co -> foundBridge.add(co.getGmlId()));
Supplier<Stream<BridgeObject>> supply = () -> model.getCache().getStream(foundBridge).map(co -> (BridgeObject) co);
buildBridgeTreeFromList(supply, root);
updateTree(root);
......@@ -1460,7 +1457,6 @@ public class CityDoctorController {
List<GmlId> idList = model.getLandIds();
foundLand.removeIf(gmlId -> (!idList.contains(gmlId)));
// model.getLand().filter(Checkable::containsAnyError).forEach(co -> foundLand.add(co.getGmlId()));
Supplier<Stream<CityObject>> supply = () -> model.getCache().getStream(foundLand).map(co -> (CityObject) co);
buildLandTreeFromList(supply, root);
updateTree(root);
......@@ -1483,7 +1479,6 @@ public class CityDoctorController {
List<GmlId> idList = model.getCityFurnitureIds();
foundCityFurniture.removeIf(gmlId -> (!idList.contains(gmlId)));
// model.getCityFurniture().filter(Checkable::containsAnyError).forEach(co -> foundCityFurniture.add(co.getGmlId()));
Supplier<Stream<CityFurniture>> supply = () -> model.getCache().getStream(foundCityFurniture).map(co -> (CityFurniture) co);
buildCityFurnitureTreeFromList(supply, root);
updateTree(root);
......@@ -1506,7 +1501,6 @@ public class CityDoctorController {
List<GmlId> idList = model.getGenericCityObjectIds();
foundGenericCityObjects.removeIf(gmlId -> (!idList.contains(gmlId)));
// model.getGenericCityObjects().filter(Checkable::containsAnyError).forEach(co -> foundGenericCityObjects.add(co.getGmlId()));
Supplier<Stream<GenericCityObject>> supply = () -> model.getCache().getStream(foundGenericCityObjects).map(co -> (GenericCityObject) co);
buildGenericCityObjectTreeFromList(supply, root);
updateTree(root);
......@@ -1529,7 +1523,6 @@ public class CityDoctorController {
List<GmlId> idList = model.getTransportationIds();
foundTransportation.removeIf(gmlId -> (!idList.contains(gmlId)));
// model.getTransportation().filter(Checkable::containsAnyError).forEach(co -> foundTransportation.add(co.getGmlId()));
Supplier<Stream<TransportationObject>> supply = () -> model.getCache().getStream(foundTransportation).map(co -> (TransportationObject) co);
buildTransportationTreeFromList(supply, root);
updateTree(root);
......@@ -1552,7 +1545,6 @@ public class CityDoctorController {
List<GmlId> idList = model.getTunnelIds();
foundTunnel.removeIf(gmlId -> (!idList.contains(gmlId)));
// model.getTunnels().filter(Checkable::containsAnyError).forEach(co -> foundTunnel.add(co.getGmlId()));
Supplier<Stream<Tunnel>> supply = () -> model.getCache().getStream(foundTunnel).map(co -> (Tunnel) co);
buildTunnelTreeFromList(supply, root);
updateTree(root);
......@@ -1576,60 +1568,12 @@ public class CityDoctorController {
List<GmlId> idList = model.getWaterIds();
foundWater.removeIf(gmlId -> (!idList.contains(gmlId)));
// model.getWater().filter(Checkable::containsAnyError).forEach(co -> foundWater.add(co.getGmlId()));
Supplier<Stream<WaterObject>> supply = () -> model.getCache().getStream(foundWater).map(co -> (WaterObject) co);
buildWaterTreeFromList(supply, root);
updateTree(root);
addMoreButtonForWater(waterView, root, tunnelChunkNr, supply, foundWater.size());
}
public void fillTreeViewFromFeatures(FeatureType selectedTab) {
if (model == null) {
return;
}
mainWindow.resetSearchBar();
switch (selectedTab) {
case BUILDING:
buildBuildings(model);
updateTree(mainWindow.getBuildingsView().getRoot());
break;
case VEGETATION:
buildVegetation(model);
updateTree(mainWindow.getVegetationView().getRoot());
break;
case BRIDGE:
buildBridges(model);
updateTree(mainWindow.getBridgeView().getRoot());
break;
case LAND:
buildLand(model);
updateTree(mainWindow.getTerrainView().getRoot());
break;
case TRANSPORTATION:
buildTransportation(model);
updateTree(mainWindow.getTransportationView().getRoot());
break;
case TUNNEL:
buildTunnel(model);
updateTree(mainWindow.getTunnelView().getRoot());
break;
case WATER:
buildWater(model);
updateTree(mainWindow.getWaterView().getRoot());
break;
case CITY_FURNITURE:
buildCityFurniture(model);
updateTree(mainWindow.getCityFurnitureView().getRoot());
break;
case GENERIC_CITY_OBJECT:
buildGenericCityObjects(model);
updateTree(mainWindow.getGenericCityObjectView().getRoot());
break;
default:
throw new IllegalStateException();
}
}
public CityDoctorModel getModel() {
return model;
}
......@@ -1692,40 +1636,19 @@ public class CityDoctorController {
public void errorFilterIndexChanged(Number newV) {
mainWindow.getMeshGroup().getChildren().clear();
mainWindow.unselectEverything();
if (newV.intValue() == 0) {
fillTreeViewFromFeatures(mainWindow.getSelectedTab());
} else if (newV.intValue() == 1) {
switch (mainWindow.getSelectedTab()) {
case BUILDING:
fillTreeViewWithErrorBuildings();
break;
case VEGETATION:
fillTreeViewWithErrorVegetation();
break;
case BRIDGE:
fillTreeViewWithErrorBridges();
break;
case LAND:
fillTreeViewWithErrorLand();
break;
case TRANSPORTATION:
fillTreeViewWithErrorTransportation();
break;
case TUNNEL:
fillTreeViewWithErrorTunnel();
break;
case WATER:
fillTreeViewWithErrorWater();
break;
case CITY_FURNITURE:
fillTreeViewWithErrorCityFurniture();
break;
case GENERIC_CITY_OBJECT:
fillTreeViewWithErrorGenericCityObjects();
break;
default:
throw new IllegalStateException("Unknown selected feature tab: " + mainWindow.getSelectedTab());
}
if (newV.intValue() == 0) { // Error filter was set to "All"
buildTrees();
updateFeatureTrees();
} else if (newV.intValue() == 1) { // Error filter was set to "With errors"
fillTreeViewWithErrorBuildings();
fillTreeViewWithErrorVegetation();
fillTreeViewWithErrorBridges();
fillTreeViewWithErrorLand();
fillTreeViewWithErrorTransportation();
fillTreeViewWithErrorTunnel();
fillTreeViewWithErrorWater();
fillTreeViewWithErrorCityFurniture();
fillTreeViewWithErrorGenericCityObjects();
} else {
throw new IllegalStateException("Unknown filter index selected: " + newV);
}
......
Supports Markdown
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