mirror of
https://github.com/st-tu-dresden-praktikum/swt23w23
synced 2024-07-04 20:29:39 +02:00
50 lines
1.8 KiB
Java
50 lines
1.8 KiB
Java
|
/*
|
||
|
* Copyright (C) 2023 Simon Bruder
|
||
|
*
|
||
|
* This program is free software: you can redistribute it and/or modify
|
||
|
* it under the terms of the GNU Affero General Public License as published by
|
||
|
* the Free Software Foundation, either version 3 of the License, or
|
||
|
* (at your option) any later version.
|
||
|
*
|
||
|
* This program is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU Affero General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU Affero General Public License
|
||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||
|
*/
|
||
|
package catering.catalog;
|
||
|
|
||
|
import static org.salespointframework.core.Currencies.EURO;
|
||
|
|
||
|
import org.javamoney.moneta.Money;
|
||
|
import org.salespointframework.core.DataInitializer;
|
||
|
import org.springframework.core.annotation.Order;
|
||
|
import org.springframework.stereotype.Component;
|
||
|
import org.springframework.util.Assert;
|
||
|
|
||
|
@Component
|
||
|
@Order(20)
|
||
|
class CatalogDataInitializer implements DataInitializer {
|
||
|
|
||
|
private final CateringCatalog cateringCatalog;
|
||
|
|
||
|
CatalogDataInitializer(CateringCatalog cateringCatalog) {
|
||
|
Assert.notNull(cateringCatalog, "CateringCatalog must not be null!");
|
||
|
this.cateringCatalog = cateringCatalog;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void initialize() {
|
||
|
if (cateringCatalog.findAll().iterator().hasNext()) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
cateringCatalog.save(new CatalogDummy("Brötchen Vollkorn", CatalogDummyType.CONSUMABLE, Money.of(1, EURO), Money.of(0.5, EURO),
|
||
|
Money.of(0.75, EURO)));
|
||
|
cateringCatalog.save(new CatalogDummy("Kerze Rot", CatalogDummyType.CONSUMABLE, Money.of(2, EURO), Money.of(1.5, EURO)));
|
||
|
cateringCatalog.save(new CatalogDummy("Brotschneidemaschine Power X 3000", CatalogDummyType.RENTABLE, Money.of(25, EURO), Money.of(10000, EURO)));
|
||
|
}
|
||
|
}
|