Skip to content

Commit 7037e1e

Browse files
committed
Minor refactoring on roach-data-jpa-orders
1 parent 4e9fdae commit 7037e1e

File tree

5 files changed

+41
-58
lines changed

5 files changed

+41
-58
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package io.roach.data.jpa;
2+
3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
5+
import org.springframework.beans.factory.annotation.Autowired;
6+
import org.springframework.boot.CommandLineRunner;
7+
import org.springframework.stereotype.Component;
8+
9+
@Component
10+
public class OrderClient implements CommandLineRunner {
11+
protected final Logger logger = LoggerFactory.getLogger(getClass());
12+
13+
@Autowired
14+
private OrderSystemFacade orderSystemFacade;
15+
16+
@Override
17+
public void run(String... args) {
18+
logger.info("Clear all...");
19+
orderSystemFacade.clearAll();
20+
21+
logger.info("Creating products...");
22+
orderSystemFacade.createProductInventory();
23+
24+
logger.info("Creating customers...");
25+
orderSystemFacade.createCustomers();
26+
27+
logger.info("Creating orders...");
28+
orderSystemFacade.createOrders();
29+
30+
logger.info("Listing orders...");
31+
orderSystemFacade.listOrders();
32+
33+
logger.info("Removing orders...");
34+
orderSystemFacade.removeOrders();
35+
}
36+
}

roach-data-jpa-orders/src/main/java/io/roach/data/jpa/ShoppingSystemFacade.java renamed to roach-data-jpa-orders/src/main/java/io/roach/data/jpa/OrderSystemFacade.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import io.roach.data.jpa.repository.ProductRepository;
2121

2222
@Service
23-
public class ShoppingSystemFacade {
23+
public class OrderSystemFacade {
2424
protected static final Logger logger = LoggerFactory.getLogger(JpaOrdersApplication.class);
2525

2626
@Autowired

roach-data-jpa-orders/src/main/java/io/roach/data/jpa/SchemaExporter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ public class SchemaExporter {
3232
Product.class
3333
};
3434

35-
public static void _main(String[] args) throws IOException {
36-
boolean drop = true;
35+
public static void main(String[] args) throws IOException {
36+
boolean drop = false;
3737
Path outFile = null;
3838
String delimiter = ";";
3939
Class dialect = CockroachDB201Dialect.class;
@@ -71,7 +71,7 @@ public static void _main(String[] args) throws IOException {
7171

7272
MetadataSources metadataSources = new MetadataSources(standardRegistry);
7373

74-
Arrays.stream(ENTITY_TYPES).sequential().forEach(clazz -> metadataSources.addAnnotatedClass(clazz));
74+
Arrays.stream(ENTITY_TYPES).sequential().forEach(metadataSources::addAnnotatedClass);
7575

7676
MetadataBuilder metadataBuilder = metadataSources.getMetadataBuilder();
7777
metadataBuilder.applyImplicitNamingStrategy(ImplicitNamingStrategyJpaCompliantImpl.INSTANCE);

roach-data-jpa-orders/src/main/java/io/roach/data/jpa/ShoppingClient.java

Lines changed: 0 additions & 53 deletions
This file was deleted.

roach-data-jpa-orders/src/main/java/io/roach/data/jpa/domain/Order.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public Builder withCustomer(Customer customer) {
3333
}
3434

3535
public OrderItem.Builder andOrderItem() {
36-
return new OrderItem.Builder(this, orderItem -> orderItems.add(orderItem));
36+
return new OrderItem.Builder(this, orderItems::add);
3737
}
3838

3939
public Order build() {

0 commit comments

Comments
 (0)