Startup: Ensure each Accession has its system Inventory
In InventoryServiceImpl
add a ensureSystemInventories()
method that we can run in ApplicationStartup and in AdminController.
@Transactional
int ensureSystemInventories() {
var accessionsWithoutSystemInv = jpa.select(/* Convert to DSL*/"select a.id from accession a left join a.inventories i where i.formTypeCode='**' group by a having count(i) = 0");
// TODO add them
return accessionsWithoutSystemInv.size();
}