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

Merge commit. #6

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
40 changes: 40 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.
# compiled output
/dist
/tmp
/out-tsc
/.dist
# dependencies
/node_modules
node_modules
/src/node_modules
# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
testem.log
/typings
# e2e
/e2e/*.js
/e2e/*.map
# System Files
.DS_Store
Thumbs.db
#Webstorm
.idea
40 changes: 40 additions & 0 deletions API/code/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
*#
*.iml
*.ipr
*.iws
*.jar
*.sw?
*~
.#*
.*.md.html
.DS_Store
.classpath
.factorypath
.gradle
.idea
.metadata
.project
.recommenders
.settings
.springBeans
/build
MANIFEST.MF
_site/
activemq-data
bin
build
build.log
dependency-reduced-pom.xml
dump.rdb
interpolated*.xml
lib/
manifest.yml
overridedb.*
settings.xml
target
transaction-logs
.flattened-pom.xml
secrets.yml
.gradletasknamecache
.sts4-cache
/node_modules
61 changes: 61 additions & 0 deletions API/code/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Panalpina Build-a-Backend Challenge

## Requirements
- Java SDK 1.8
- Maven 3.3.9

The developed source code uses maven for dependency management and build execution. For ease of use you may want to ensure that 'mvn' is available on your PATH.

## Executing the submission

To execute the code:

$cd submission/code

$mvn clean install

$cd restapi/

$mvn spring-boot:run


## Workflow

The developed code reads csv files located in src/main/resources folder and loads data into JPA repositories. The H2 in-memory database has been used for the scope of this challenge. The application.properties file located in src/main/resources folder allow to configure it for another database by properties:

spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=


## MarineTraffic Keys

Specify your key in application.properties as the values of following properties:

marinetraffic.vessel.historical.track.PS01.key=<YOUR_KEY>
marinetraffic.single.vessel.position.PS07.key=<YOUR_KEY>
marinetraffic.voyage.forecasts.VI01.key=<YOUR_KEY>
marinetraffic.search.vessel.VD03.key=<YOUR_KEY>


## Points to note

- The swagger document has been updated for FlightShipmentResponse and FreightShipmentResponse.
- The data provided by the client in the csv files is not recent. So test files `Air_freight_test.csv` and `Ocean_freight_test.csv` have been created and placed with original data at `src/main/resources` folder. The structure of the files are exactly similar as given by the client but the data value is recent for ships and flights(at the time of writing and testing the code).
- MarineTraffic API needs MMSI for making API calls which is not included in the client data. So the code takes value from property `marinetraffic.api.test.mmsi.value` in application.properties and makes calls.
- Username and password of FlightAware API works for `FlightXML version 3` and NOT for FlightXML 2.0. The two versions are not interchangeable.
- FlightAware API calls uses ICAO airline number but client data has provided IATA airline values in `CARRIER_PREFIX`. `Air_freight_test.csv` uses ICAO airline value in carrier preifx to make flightXML API calls.
- The code allows POST requests but only properties in the csv files given by the client are allowed to be updated. Other properties of FlightShipmentResponse and FrieghtShipmentResponse are not in the database and hence can't be updated.



## H2-console
You can watch the data loaded into database by using H2-console. Type the url `http://localhost:8080/h2-console/` in the browser and specify `jdbc:h2:mem:testdb` as JDBC URL.

![H2-Console](./images/h2-console.png)





18 changes: 18 additions & 0 deletions API/code/restapi/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
Expand All @@ -27,5 +28,22 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="target/generated-sources/annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
4 changes: 2 additions & 2 deletions API/code/restapi/.project
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
Expand Down
3 changes: 3 additions & 0 deletions API/code/restapi/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.methodParameters=generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.processAnnotations=enabled
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
* Application class.
Expand All @@ -17,4 +20,14 @@ public class Application {
public static void main(String... args) {
SpringApplication.run(Application.class, args);
}

@Bean
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurer() {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**").allowedMethods("*");
}
};
}
}
Loading