mirror of
https://github.com/st-tu-dresden-praktikum/swt23w23
synced 2024-06-23 20:43:41 +02:00
This finally makes the licensing under AGPL-3.0-or-later explicit after I got the okay from the kickstart source owners. This also checks the REUSE compliance in a pre commit hook, and therefore also in CI.
36 lines
1.2 KiB
Java
36 lines
1.2 KiB
Java
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
// SPDX-FileCopyrightText: 2023 swt23w23
|
|
package catering.inventory;
|
|
|
|
import org.salespointframework.core.DataInitializer;
|
|
import org.salespointframework.inventory.UniqueInventory;
|
|
import org.salespointframework.inventory.UniqueInventoryItem;
|
|
import org.salespointframework.quantity.Quantity;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.util.Assert;
|
|
|
|
import catering.catalog.CateringCatalog;
|
|
|
|
@Component
|
|
class InventoryInitializer implements DataInitializer {
|
|
private final UniqueInventory<UniqueInventoryItem> inventory;
|
|
private final CateringCatalog cateringCatalog;
|
|
|
|
InventoryInitializer(UniqueInventory<UniqueInventoryItem> inventory, CateringCatalog cateringCatalog) {
|
|
Assert.notNull(inventory, "Inventory must not be null!");
|
|
Assert.notNull(cateringCatalog, "CateringCatalog must not be null!");
|
|
|
|
this.inventory = inventory;
|
|
this.cateringCatalog = cateringCatalog;
|
|
}
|
|
|
|
@Override
|
|
public void initialize() {
|
|
cateringCatalog.findAll().forEach(product -> {
|
|
if (inventory.findByProduct(product).isEmpty()) {
|
|
inventory.save(new UniqueInventoryItem(product, Quantity.of(10)));
|
|
}
|
|
});
|
|
}
|
|
}
|