Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rest frontend #102

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 61 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,65 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED</argLine>
<argLine>--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED
</argLine>
</configuration>
<version>2.22.2</version>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<workingDirectory>src/main/resources/frontend/</workingDirectory>
</configuration>
<executions>
<execution>
<id>npm install (initialize)</id>
<goals>
<goal>exec</goal>
</goals>
<phase>initialize</phase>
<configuration>
<executable>npm</executable>
<arguments>
<argument>install</argument>
</arguments>
</configuration>
</execution>

<execution>
<id>npm run build (compile)</id>
<goals>
<goal>exec</goal>
</goals>
<phase>compile</phase>
<configuration>
<executable>npm</executable>
<arguments>
<argument>run</argument>
<argument>build</argument>
</arguments>
</configuration>
</execution>

<execution>
<id>npm run clean (clean)</id>
<goals>
<goal>exec</goal>
</goals>
<phase>clean</phase>
<configuration>
<executable>npm</executable>
<arguments>
<argument>run</argument>
<argument>clean</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down Expand Up @@ -211,11 +266,11 @@
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>htmlunit-driver</artifactId>
</dependency>
<!-- <dependency>--> <!-- Used to generate OpenAPI docs -->
<!-- <groupId>org.springdoc</groupId>-->
<!-- <artifactId>springdoc-openapi-webmvc-core</artifactId>-->
<!-- <version>1.6.12</version>-->
<!-- </dependency>-->
<!-- <dependency>--> <!-- Used to generate OpenAPI docs -->
<!-- <groupId>org.springdoc</groupId>-->
<!-- <artifactId>springdoc-openapi-webmvc-core</artifactId>-->
<!-- <version>1.6.12</version>-->
<!-- </dependency>-->
</dependencies>

<repositories>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,32 +76,32 @@ protected void doInTransactionWithoutResult(TransactionStatus status) {
voyageRepository.store(HELSINKI_TO_HONGKONG);
voyageRepository.store(DALLAS_TO_HELSINKI_ALT);

RouteSpecification routeSpecification = new RouteSpecification(HONGKONG, HELSINKI, toDate("2009-03-15"));
RouteSpecification routeSpecification = new RouteSpecification(HONGKONG, HELSINKI, toDate("2024-03-15"));
TrackingId trackingId = new TrackingId("ABC123");
Cargo abc123 = new Cargo(trackingId, routeSpecification);

Itinerary itinerary = new Itinerary(List.of(
new Leg(HONGKONG_TO_NEW_YORK, HONGKONG, NEWYORK, toDate("2009-03-02"), toDate("2009-03-05")),
new Leg(NEW_YORK_TO_DALLAS, NEWYORK, DALLAS, toDate("2009-03-06"), toDate("2009-03-08")),
new Leg(DALLAS_TO_HELSINKI, DALLAS, HELSINKI, toDate("2009-03-09"), toDate("2009-03-12"))
new Leg(HONGKONG_TO_NEW_YORK, HONGKONG, NEWYORK, toDate("2024-03-02"), toDate("2024-03-05")),
new Leg(NEW_YORK_TO_DALLAS, NEWYORK, DALLAS, toDate("2024-03-06"), toDate("2024-03-08")),
new Leg(DALLAS_TO_HELSINKI, DALLAS, HELSINKI, toDate("2024-03-09"), toDate("2024-03-12"))
));
abc123.assignToRoute(itinerary);

cargoRepository.store(abc123);

try {
HandlingEvent event1 = handlingEventFactory.createHandlingEvent(
Instant.now(), toDate("2009-03-01"), trackingId, null, HONGKONG.unLocode(), HandlingEvent.Type.RECEIVE
Instant.now(), toDate("2024-03-01"), trackingId, null, HONGKONG.unLocode(), HandlingEvent.Type.RECEIVE
);
handlingEventRepository.store(event1);

HandlingEvent event2 = handlingEventFactory.createHandlingEvent(
Instant.now(), toDate("2009-03-02"), trackingId, HONGKONG_TO_NEW_YORK.voyageNumber(), HONGKONG.unLocode(), HandlingEvent.Type.LOAD
Instant.now(), toDate("2024-03-02"), trackingId, HONGKONG_TO_NEW_YORK.voyageNumber(), HONGKONG.unLocode(), HandlingEvent.Type.LOAD
);
handlingEventRepository.store(event2);

HandlingEvent event3 = handlingEventFactory.createHandlingEvent(
Instant.now(), toDate("2009-03-05"), trackingId, HONGKONG_TO_NEW_YORK.voyageNumber(), NEWYORK.unLocode(), HandlingEvent.Type.UNLOAD
Instant.now(), toDate("2024-03-05"), trackingId, HONGKONG_TO_NEW_YORK.voyageNumber(), NEWYORK.unLocode(), HandlingEvent.Type.UNLOAD
);
handlingEventRepository.store(event3);
} catch (CannotCreateHandlingEventException e) {
Expand All @@ -115,37 +115,37 @@ protected void doInTransactionWithoutResult(TransactionStatus status) {

// Cargo JKL567

RouteSpecification routeSpecification1 = new RouteSpecification(HANGZHOU, STOCKHOLM, toDate("2009-03-18"));
RouteSpecification routeSpecification1 = new RouteSpecification(HANGZHOU, STOCKHOLM, toDate("2024-03-18"));
TrackingId trackingId1 = new TrackingId("JKL567");
Cargo jkl567 = new Cargo(trackingId1, routeSpecification1);

Itinerary itinerary1 = new Itinerary(List.of(
new Leg(HONGKONG_TO_NEW_YORK, HANGZHOU, NEWYORK, toDate("2009-03-03"), toDate("2009-03-05")),
new Leg(NEW_YORK_TO_DALLAS, NEWYORK, DALLAS, toDate("2009-03-06"), toDate("2009-03-08")),
new Leg(DALLAS_TO_HELSINKI, DALLAS, STOCKHOLM, toDate("2009-03-09"), toDate("2009-03-11"))
new Leg(HONGKONG_TO_NEW_YORK, HANGZHOU, NEWYORK, toDate("2024-03-03"), toDate("2024-03-05")),
new Leg(NEW_YORK_TO_DALLAS, NEWYORK, DALLAS, toDate("2024-03-06"), toDate("2024-03-08")),
new Leg(DALLAS_TO_HELSINKI, DALLAS, STOCKHOLM, toDate("2024-03-09"), toDate("2024-03-11"))
));
jkl567.assignToRoute(itinerary1);

cargoRepository.store(jkl567);

try {
HandlingEvent event1 = handlingEventFactory.createHandlingEvent(
Instant.now(), toDate("2009-03-01"), trackingId1, null, HANGZHOU.unLocode(), HandlingEvent.Type.RECEIVE
Instant.now(), toDate("2024-03-01"), trackingId1, null, HANGZHOU.unLocode(), HandlingEvent.Type.RECEIVE
);
handlingEventRepository.store(event1);

HandlingEvent event2 = handlingEventFactory.createHandlingEvent(
Instant.now(), toDate("2009-03-03"), trackingId1, HONGKONG_TO_NEW_YORK.voyageNumber(), HANGZHOU.unLocode(), HandlingEvent.Type.LOAD
Instant.now(), toDate("2024-03-03"), trackingId1, HONGKONG_TO_NEW_YORK.voyageNumber(), HANGZHOU.unLocode(), HandlingEvent.Type.LOAD
);
handlingEventRepository.store(event2);

HandlingEvent event3 = handlingEventFactory.createHandlingEvent(
Instant.now(), toDate("2009-03-05"), trackingId1, HONGKONG_TO_NEW_YORK.voyageNumber(), NEWYORK.unLocode(), HandlingEvent.Type.UNLOAD
Instant.now(), toDate("2024-03-05"), trackingId1, HONGKONG_TO_NEW_YORK.voyageNumber(), NEWYORK.unLocode(), HandlingEvent.Type.UNLOAD
);
handlingEventRepository.store(event3);

HandlingEvent event4 = handlingEventFactory.createHandlingEvent(
Instant.now(), toDate("2009-03-06"), trackingId1, HONGKONG_TO_NEW_YORK.voyageNumber(), NEWYORK.unLocode(), HandlingEvent.Type.LOAD
Instant.now(), toDate("2024-03-06"), trackingId1, HONGKONG_TO_NEW_YORK.voyageNumber(), NEWYORK.unLocode(), HandlingEvent.Type.LOAD
);
handlingEventRepository.store(event4);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package se.citerus.dddsample.infrastructure.web;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class HomeController {

@RequestMapping(value = {"/", "/cargo/**", "/admin/**"})
public String index() {
return "/static/index";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
import se.citerus.dddsample.domain.model.voyage.VoyageRepository;
import se.citerus.dddsample.interfaces.booking.facade.BookingServiceFacade;
import se.citerus.dddsample.interfaces.booking.facade.internal.BookingServiceFacadeImpl;
import se.citerus.dddsample.interfaces.booking.web.CargoAdminController;
import se.citerus.dddsample.interfaces.handling.file.UploadDirectoryScanner;
import se.citerus.dddsample.interfaces.tracking.CargoTrackingController;
import se.citerus.dddsample.interfaces.tracking.TrackCommandValidator;
import se.citerus.dddsample.interfaces.tracking.ws.CargoTrackingRestService;

Expand Down Expand Up @@ -61,25 +59,15 @@ public FixedLocaleResolver localeResolver() {
}

@Bean
public CargoTrackingController cargoTrackingController(MessageSource messageSource, CargoRepository cargoRepository, HandlingEventRepository handlingEventRepository) {
return new CargoTrackingController(cargoRepository, handlingEventRepository, messageSource);
}

@Bean
public CargoTrackingRestService cargoTrackingRestService(CargoRepository cargoRepository, HandlingEventRepository handlingEventRepository, MessageSource messageSource) {
return new CargoTrackingRestService(cargoRepository, handlingEventRepository, messageSource);
public CargoTrackingRestService cargoTrackingRestService(CargoRepository cargoRepository, BookingServiceFacade bookingServiceFacade, HandlingEventRepository handlingEventRepository, MessageSource messageSource) {
return new CargoTrackingRestService(cargoRepository, bookingServiceFacade, handlingEventRepository, messageSource);
}

@Bean
public TrackCommandValidator trackCommandValidator() {
return new TrackCommandValidator();
}

@Bean
public CargoAdminController cargoAdminController(BookingServiceFacade bookingServiceFacade) {
return new CargoAdminController(bookingServiceFacade);
}

@Bean
public BookingServiceFacade bookingServiceFacade(BookingService bookingService, LocationRepository locationRepository, CargoRepository cargoRepository, VoyageRepository voyageRepository) {
return new BookingServiceFacadeImpl(bookingService, locationRepository, cargoRepository, voyageRepository);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ public String getUnLocode() {
public String getName() {
return name;
}

}

This file was deleted.

This file was deleted.

Loading