Skip to content

fcdl94/VehicleTracking

Repository files navigation

VehicleTracking

DP2 Project of 2017

The aim of this project is to design and implement a RESTful web service that can track the presence of vehicles in an area with restricted access and, based on the tracking information, can provide permission to new vehicles to enter the area and suggestions about the path to their destinations. The service uses a model of the area that is a graph, with nodes representing roads and parking areas, and arcs representing the possibility to go from one node to another one. When a new vehicle wants to enter the area, it has to ask the service for permission, specifying both the entry point (i.e. its current position) and the desired destination in the area. The service will check if it is possible to allow the entrance of the new vehicle, based on the area model (which can include a number of constraints, such as capacity of parking areas and of roads) and based on the current and expected future positions of the other vehicles in the area. If the service allows entrance, it responds by also indicating a suggested path that the new vehicle is expected to follow from the entry point to the destination, and a unique identifier assigned by the service to the new vehicle. While the vehicle is moving to its destination it will periodically send information about its current position to the service, which will update its tracking information. If the service realizes that a vehicle is not following the suggested path, it will compute an updated path that starts from the current vehicle position and will send it back to the vehicle in response to the position tracking message. The area model must be specified in an XML document, for which a schema has to be designed. The service must upload the area model from the XML file at startup and it must allow administrators to collect various kinds of information about the vehicles currently in the area and their expected routes.

IMPORTANT

You must import in /opt/dp2/shared/lib the libraries for JAX-RS downloadable from https://jersey.github.io/

Java and JUnit

In the project it is used the Java 8 OpenJDK. JUnit version is JUnit 5.

Ant

The project can be lauched by using ANT script. This project uses ANT version 1.10.1 (I use the Eclipse plugin version of ANT)

TomCat

The project was made using Tomcat (version 8.5.24) but it is not included in the files. You can download it from https://tomcat.apache.org/download-80.cgi You must configure the CATALINA_HOME variable in order to point the installation folder of TOMCAT application

Swagger

The project uses Swagger to build automatically the documentation of REST APIs. Swagger libraries are in the lib folder that is included in the project. Swagger version is 1.5.

How to generate a random model

The marshal class is able to create a model given this ordered argument list: File, the name of output file; Road number, number of roads to be generated; Area number, number of parking areas to be generated; Vehicle number, number of vehicles to be generated; Seed, the seed to initialize the Random class.

If those are not specified, Marshal class will use the default values. This class can be run as a standard Java program.

Service

To test the server you have first to run TomCat and then to build and deploy the Web Service. Then to run the TomCat server you can use: ant -f service-build.xml start-tomcat

To deploy the service (build is implied in deployment) you can use: ant -f service-build.xml deployWS

Client

In the project there are three client useful as example and test. The client classes are provided in src folder and the model is already generated.

To run the client can be used the ANT script build.xml provided in the client folder.

To run the example (single vehicle) client you can use: ant -f build.xml run-client-one

To run the administration example client you can use: ant -f build.xml run-admin

To run the example (multi vehicle) client you can use: ant -f build.xml run-client-multi

Server Folder structure

SRC: It is the folder containing the source file of the project made of four packages: application, containing the application sub-package model, containing the model (classes generated by xjc) sub-package resource, containing the resource sub-package, util, containing ModelValidationProvider Interceptor, Marshal class useful to write a Model into xml file, ModelGenerator class useful to make a random model given a seed, ReadModel, a debug class which function is to read a given XML.

TEST: In this folder there are the JUnit test files. There are five classes that are VTServiceTest to test basic command of VTService class, UpdateVehicleTest to test the update functions of Vehicles useful for PUT method, UpdateVehiclePositionTest to the test the update position functions of Vehicle useful for POST method, DeleteTest to test the delete functions of vehicle, CreateNewVehicle to test the Path and Vehicles creation.

XSD: contains the XSD schema of the model.

XML: contains xml-test.xml file (used by Test classes), xml-gen.xml that is a random generated model that is used in deployment, vehicleExample.xml that is an example of a vehicle representation useful for testing in Swagger.

LIB: contains the Swagger libraries

CLIENT: see Client folder structure

Client Folder structure

Client is a sub-project organized similarly to the server proect.

SRC contains the two packages that composes the client, that are model (automatically generated by xjc from xsd) and client that contais three example of client a simple client simulating one vehicle a simple client simulating administration task a complex client simulating more vehicle

XSD contains the XSD file (same of the server)

About

DP2 Project of 2017

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published