Improve asset sorting by brand, model, and QR code with null handling
This commit is contained in:
@@ -96,7 +96,10 @@ public class WebController {
|
|||||||
model.addAttribute(DESCRIPTORS, tree);
|
model.addAttribute(DESCRIPTORS, tree);
|
||||||
model.addAttribute(PROPERTIES, tree.stream().flatMap(d -> d.getProperties().stream()).toList());
|
model.addAttribute(PROPERTIES, tree.stream().flatMap(d -> d.getProperties().stream()).toList());
|
||||||
var assets = assetService.getAssetsByType(type);
|
var assets = assetService.getAssetsByType(type);
|
||||||
assets.sort(Comparator.comparing(Asset::getQr));
|
assets.sort(Comparator
|
||||||
|
.comparing((Asset a) -> a.getAsset().getBrand(), Comparator.nullsFirst(Comparator.naturalOrder()))
|
||||||
|
.thenComparing((Asset a) -> a.getAsset().getModel(), Comparator.nullsFirst(Comparator.naturalOrder()))
|
||||||
|
.thenComparing(Asset::getQr));
|
||||||
model.addAttribute(ASSETS, assets);
|
model.addAttribute(ASSETS, assets);
|
||||||
return "browse_type";
|
return "browse_type";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user