Skip to content

Commit

Permalink
Merge pull request #128 from dcsaorg/APVCV-567-TNT-Overhaul
Browse files Browse the repository at this point in the history
APVCV-567 - TNT Overhaul
  • Loading branch information
FinnNielsen authored Apr 25, 2023
2 parents 70a9909 + 3226972 commit 381872e
Show file tree
Hide file tree
Showing 137 changed files with 1,175 additions and 2,883 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@ jobs:
- name: Fetch Backend Status
run: |
sleep 10
status=$(curl -s http://localhost:9090/v3/actuator/health | jq -r '.status')
status=$(curl -s http://localhost:9090/actuator/health | jq -r '.status')
retries=12
while [[ "$status" != "UP" ]] && [[ $retries -gt 0 ]]; do
echo "Status is '$status' - waiting 5 secs ($retries retries left)"
sleep 5
retries=$((retries - 1))
status=$(curl -s http://localhost:9090/v3/actuator/health | jq -r '.status')
status=$(curl -s http://localhost:9090/actuator/health | jq -r '.status')
done
echo "Final status is '$status'"
if [[ "$status" != "UP" ]]; then
curl -v http://localhost:9090/v3/actuator/health || :
curl -v http://localhost:9090/actuator/health || :
docker ps || :
docker logs dcsa-tnt_dcsa-tnt_1 || :
exit 1
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "DCSA-Sample-Data"]
path = DCSA-Sample-Data
url = https://github.com/dcsaorg/DCSA-Sample-Data.git
1 change: 0 additions & 1 deletion DCSA-Sample-Data
Submodule DCSA-Sample-Data deleted from 8fe2f8
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ services:
environment:
POSTGRES_PASSWORD: "change_this_password"
volumes:
- ./tnt-persistence/src/main/init.db:/docker-entrypoint-initdb.d:ro
- ./tnt-domain/src/main/init.db:/docker-entrypoint-initdb.d:ro
ports:
- 5432:5432

Expand Down
62 changes: 6 additions & 56 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.dcsa</groupId>
<artifactId>dcsa-bom</artifactId>
<version>1.3-SNAPSHOT</version>
<version>1.5-SNAPSHOT</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>org.dcsa.tnt</groupId>
Expand All @@ -23,22 +23,19 @@
<!-- End: Define DCSA-TNT version -->

<!-- Define Shared Kernel version -->
<dcsa.shared-kernel.version>0.2.0</dcsa.shared-kernel.version>
<dcsa.shared-kernel.version>0.4.0</dcsa.shared-kernel.version>
<dcsa.shared-kernel.tag/>
<dcsa.shared-kernel.artifacttype>-SNAPSHOT</dcsa.shared-kernel.artifacttype>
<shared-kernel.version>${dcsa.shared-kernel.version}${dcsa.shared-kernel.tag}${dcsa.shared-kernel.artifacttype}</shared-kernel.version>
<dcsa.shared-kernel-dataloader.version>0.4.0-SNAPSHOT</dcsa.shared-kernel-dataloader.version>
<!-- End: Define Shared kernel version -->

<hibernate-types.version>2.20.0</hibernate-types.version>
<camel.version>3.18.1</camel.version>
<testcontainers.version>1.17.5</testcontainers.version>
<hibernate-types.version>2.21.1</hibernate-types.version>

</properties>

<modules>
<module>tnt-transfer-obj</module>
<module>tnt-persistence</module>
<module>tnt-domain</module>
<module>tnt-service</module>
<module>tnt-application</module>
</modules>
Expand All @@ -55,34 +52,9 @@
<dependencies>
<dependency><!-- TODO: Move this to super-pom -->
<groupId>com.vladmihalcea</groupId><!-- Support for json and jsonb data types in hibernate/JPA -->
<artifactId>hibernate-types-55</artifactId>
<artifactId>hibernate-types-60</artifactId>
<version>${hibernate-types.version}</version>
</dependency>
<dependency><!-- TODO: Move this to super-pom -->
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-spring-boot-bom</artifactId>
<version>${camel.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>postgresql</artifactId>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.dcsa.tnt</groupId>
Expand All @@ -91,7 +63,7 @@
</dependency>
<dependency>
<groupId>org.dcsa.tnt</groupId>
<artifactId>dcsa-tnt-persistence</artifactId>
<artifactId>dcsa-tnt-domain</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
Expand All @@ -106,29 +78,7 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency><!-- Remove this if OVS is updated to newer shared-kernel (spring boot 3) -->
<groupId>org.dcsa.shared-kernel</groupId>
<artifactId>dcsa-shared-kernel-dataloader</artifactId>
<version>${dcsa.shared-kernel-dataloader.version}</version>
</dependency>

<!-- Solve convergence errors -->
<dependency>
<groupId>com.sun.istack</groupId>
<artifactId>istack-commons-runtime</artifactId>
<version>3.0.12</version>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>4.3.1</version>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>21.0.1</version>
</dependency>
<!-- /Solve convergence errors -->
</dependencies>
</dependencyManagement>

Expand Down
36 changes: 13 additions & 23 deletions postman_collection.json

Large diffs are not rendered by default.

43 changes: 1 addition & 42 deletions tnt-application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</dependency>
<dependency>
<groupId>org.dcsa.tnt</groupId>
<artifactId>dcsa-tnt-persistence</artifactId>
<artifactId>dcsa-tnt-domain</artifactId>
</dependency>
<dependency>
<groupId>org.dcsa.tnt</groupId>
Expand Down Expand Up @@ -52,22 +52,6 @@
<groupId>org.dcsa.shared-kernel</groupId>
<artifactId>dcsa-shared-kernel-all</artifactId>
</dependency>
<dependency>
<groupId>org.dcsa.shared-kernel</groupId>
<artifactId>dcsa-shared-kernel-dataloader</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-servlet-starter</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-jackson-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand All @@ -86,26 +70,6 @@
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>postgresql</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test-spring-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured-all</artifactId>
Expand All @@ -116,11 +80,6 @@
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-mock-starter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,66 +6,65 @@
import org.dcsa.skernel.infrastructure.sorting.Sorter.SortableFields;
import org.dcsa.skernel.infrastructure.validation.EnumSubset;
import org.dcsa.skernel.infrastructure.validation.UniversalServiceReference;
import org.dcsa.tnt.persistence.entity.EventCache_;
import org.dcsa.tnt.persistence.entity.enums.DocumentTypeCode;
import org.dcsa.tnt.persistence.entity.enums.EquipmentEventTypeCode;
import org.dcsa.tnt.persistence.entity.enums.EventType;
import org.dcsa.tnt.persistence.entity.enums.ShipmentEventTypeCode;
import org.dcsa.tnt.persistence.entity.enums.TransportEventTypeCode;
import org.dcsa.tnt.persistence.repository.specification.EventCacheSpecification.EventCacheFilters;
import org.dcsa.tnt.domain.persistence.entity.Event_;
import org.dcsa.tnt.domain.persistence.repository.specification.EventSpecification.EventFilters;
import org.dcsa.tnt.domain.valueobjects.enums.DocumentTypeCode;
import org.dcsa.tnt.domain.valueobjects.enums.EquipmentEventTypeCode;
import org.dcsa.tnt.domain.valueobjects.enums.EventType;
import org.dcsa.tnt.domain.valueobjects.enums.ShipmentEventTypeCode;
import org.dcsa.tnt.domain.valueobjects.enums.TransportEventTypeCode;
import org.dcsa.tnt.service.EventService;
import org.dcsa.tnt.service.mapping.transferobject.EventMapper;
import org.dcsa.tnt.transferobjects.EventTO;
import org.springframework.data.domain.Sort;
import org.springframework.http.HttpStatus;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.Min;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;
import java.time.OffsetDateTime;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;

import static org.dcsa.skernel.infrastructure.util.EnumUtil.toEnumList;


@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("${spring.application.context-path}")
public class EventController {
private static final String TNT_EVENT_TYPES = "EQUIPMENT,TRANSPORT,SHIPMENT";
private static final List<EventType> TNT_EVENT_TYPE_ENUMS = Arrays.stream(TNT_EVENT_TYPES.split(","))
.map(EventType::valueOf)
.toList();

private final List<Sort.Order> defaultSort = List.of(new Sort.Order(Sort.Direction.ASC, EventCache_.EVENT_CREATED_DATE_TIME));
private final SortableFields sortableFields = SortableFields.of(EventCache_.EVENT_CREATED_DATE_TIME, EventCache_.EVENT_DATE_TIME);
private final List<Sort.Order> defaultSort = List.of(new Sort.Order(Sort.Direction.ASC, Event_.EVENT_CREATED_DATE_TIME));
private final SortableFields sortableFields = SortableFields.of(Event_.EVENT_CREATED_DATE_TIME, Event_.EVENT_DATE_TIME);

private final EventService eventService;
private final EventMapper eventMapper;
private final DCSAQueryParameterParser queryParameterParser;

@GetMapping(path = "/events/{eventID}")
@ResponseStatus(HttpStatus.OK)
public EventTO findEvent(@PathVariable("eventID") UUID eventID) {
return eventService.findEvent(eventID, TNT_EVENT_TYPE_ENUMS, eventMapper::toDTO);
public EventTO findEvent(@PathVariable("eventID") String eventID) {
return eventService.findEvent(eventID);
}

@GetMapping(path = "/events")
@ResponseStatus(HttpStatus.OK)
public List<EventTO> findEvents(
@RequestParam(value = "eventType", required = false, defaultValue = TNT_EVENT_TYPES)
@RequestParam(value = "eventType", required = false)
@EnumSubset(anyOf = TNT_EVENT_TYPES)
String eventType,

Expand Down Expand Up @@ -128,14 +127,14 @@ public List<EventTO> findEvents(
.with(request, response, page, pageSize)
.sortBy(sort, defaultSort, sortableFields)
.paginate(pageRequest ->
eventService.findAll(pageRequest, EventCacheFilters.builder()
eventService.findAll(pageRequest, EventFilters.builder()
.eventCreatedDateTime(queryParameterParser.parseCustomQueryParameter(queryParams, "eventCreatedDateTime", OffsetDateTime::parse))
.eventDateTime(queryParameterParser.parseCustomQueryParameter(queryParams, "eventDateTime", OffsetDateTime::parse))
.eventType(toEnumList(eventType, EventType.class))
.shipmentEventTypeCode(toEnumList(shipmentEventTypeCode, ShipmentEventTypeCode.class))
.transportEventTypeCode(toEnumList(transportEventTypeCode, TransportEventTypeCode.class))
.equipmentEventTypeCode(toEnumList(equipmentEventTypeCode, EquipmentEventTypeCode.class))
.documentTypeCode(toEnumList(documentTypeCode, DocumentTypeCode.class))
.eventType(toEnumSet(eventType, EventType.class))
.shipmentEventTypeCode(toEnumSet(shipmentEventTypeCode, ShipmentEventTypeCode.class))
.transportEventTypeCode(toEnumSet(transportEventTypeCode, TransportEventTypeCode.class))
.equipmentEventTypeCode(toEnumSet(equipmentEventTypeCode, EquipmentEventTypeCode.class))
.documentTypeCode(toEnumSet(documentTypeCode, DocumentTypeCode.class))
.documentReference(documentReference)
.transportCallReference(transportCallReference)
.carrierExportVoyageNumber(carrierExportVoyageNumber)
Expand All @@ -145,8 +144,11 @@ public List<EventTO> findEvents(
.vesselIMONumber(vesselIMONumber)
.carrierServiceCode(carrierServiceCode)
.equipmentReference(equipmentReference)
.build(),
eventMapper::toDTO)
.build())
);
}

private <T extends Enum<T>> Set<T> toEnumSet(String values, Class<T> enumClass) {
return values == null ? null : Set.copyOf(toEnumList(values, enumClass));
}
}
Loading

0 comments on commit 381872e

Please sign in to comment.