Commit 4d3763be authored by Ololw's avatar Ololw
Browse files

Merge branch 'Dev' into Raph

parents 6a72d939 7b90ad82
Pipeline #17283 failed with stages
in 1 minute and 37 seconds
stages:
- build
- test
- deploy
build_job:
stage: build
script:
- sudo cp /home/ec2-user/deploy-script-Dev.sh .
- sudo ./deploy-script-Dev.sh --build
push_job:
stage: test
script:
- sudo cp /home/ec2-user/deploy-script-Dev.sh .
- sudo ./deploy-script-Dev.sh --build --push
deploy_job:
stage: deploy
script:
- sudo cp /home/ec2-user/deploy-script-Dev.sh .
- sudo cp /home/ec2-user/app-machine-access.pem .
- sudo ./deploy-script-Dev.sh --deploy
when: manual
This diff is collapsed.
......@@ -19,15 +19,24 @@
"@fortawesome/fontawesome-svg-core": "1.2.4",
"@fortawesome/free-solid-svg-icons": "5.3.1",
"@ng-bootstrap/ng-bootstrap": "3.0.0",
"@types/bootstrap": "^4.1.3",
"@types/daterangepicker": "^3.0.0",
"@types/html2canvas": "0.0.35",
"@types/jspdf": "^1.2.2",
"bootstrap": "^4.1.3",
"bootstrap-daterangepicker": "^3.0.3",
"chart.js": "^2.7.3",
"core-js": "2.5.7",
"html2canvas": "^1.0.0-alpha.12",
"jquery": "^3.3.1",
"jspdf": "^1.4.1",
"moment": "2.22.2",
"ng-jhipster": "0.5.4",
"ngx-cookie": "2.0.1",
"ngx-infinite-scroll": "0.5.1",
"ngx-webstorage": "2.0.1",
"popper.js": "^1.14.4",
"npm": "^6.5.0",
"popper.js": "^1.14.6",
"reflect-metadata": "0.1.12",
"rxjs": "6.1.0",
"rxjs-compat": "6.1.0",
......@@ -43,7 +52,7 @@
"@types/node": "9.4.7",
"angular-router-loader": "0.8.5",
"angular2-template-loader": "0.6.2",
"browser-sync": "2.24.6",
"browser-sync": "^2.26.3",
"browser-sync-webpack-plugin": "2.2.2",
"cache-loader": "1.2.2",
"codelyzer": "4.2.1",
......@@ -66,10 +75,13 @@
"mini-css-extract-plugin": "0.4.2",
"moment-locales-webpack-plugin": "1.0.5",
"optimize-css-assets-webpack-plugin": "5.0.1",
"postcss-loader": "2.1.1",
"prettier": "1.11.1",
"proxy-middleware": "0.15.0",
"raw-loader": "0.5.1",
"rimraf": "2.6.1",
"sass": "1.13.0",
"sass-loader": "7.1.0",
"simple-progress-webpack-plugin": "1.1.2",
"style-loader": "0.20.3",
"tapable": "1.0.0",
......@@ -81,18 +93,15 @@
"tslint-config-prettier": "1.9.0",
"tslint-loader": "3.6.0",
"typescript": "2.7.2",
"sass": "1.13.0",
"sass-loader": "7.1.0",
"postcss-loader": "2.1.1",
"xml2js": "0.4.19",
"webpack": "4.8.0",
"webpack-cli": "2.1.3",
"webpack-dev-server": "3.1.5",
"webpack-dev-server": "^3.1.10",
"webpack-merge": "4.1.2",
"webpack-notifier": "1.6.0",
"webpack-visualizer-plugin": "0.1.11",
"workbox-webpack-plugin": "3.2.0",
"write-file-webpack-plugin": "4.2.0"
"write-file-webpack-plugin": "4.2.0",
"xml2js": "0.4.19"
},
"engines": {
"node": ">=8.9.0"
......
......@@ -117,13 +117,13 @@ public class Taux implements Serializable {
", taux=" + getTaux() +
"}";
}
public String bodyResponse()
{
return "{\n"
+ "\"date\": \"" + getDate() + "\",\n"
+ "\"taux\": " + getTaux() + "\n"
+ "}";
}
}
......@@ -231,4 +231,13 @@ public class User extends AbstractAuditingEntity implements Serializable {
", activationKey='" + activationKey + '\'' +
"}";
}
public String firstAndLastName()
{
return "{\n"
+ "\"firstName\": \"" + firstName + "\",\n"
+ "\"lastName\": \"" + lastName + "\"\n"
+ "}";
}
}
......@@ -3,6 +3,7 @@ package com.mycompany.myapp.repository;
import java.util.List;
import com.mycompany.myapp.domain.Course;
import com.mycompany.myapp.domain.Taxi;
public interface CourseRepositoryCustom
{
......@@ -10,4 +11,6 @@ public interface CourseRepositoryCustom
public List<Course> getWaitingCourses();
public List<Course> getInProgressCourses();
public List<Course> getDoneCourses();
public Taxi getTaxi(long id);
}
......@@ -11,6 +11,7 @@ import javax.persistence.Query;
import java.time.Instant;
import com.mycompany.myapp.domain.Course;
import com.mycompany.myapp.domain.Taxi;
public class CourseRepositoryImpl implements CourseRepositoryCustom
{
......@@ -67,4 +68,15 @@ public class CourseRepositoryImpl implements CourseRepositoryCustom
return query.getResultList();
}
@Override
public Taxi getTaxi(long id)
{
Query query = entityManager.createNativeQuery("SELECT * FROM mytransport.taxi as taxi WHERE taxi.id = ?", Taxi.class);
query.setParameter(1, id);
List<Taxi> taxis = query.getResultList();
if(!taxis.isEmpty())
return taxis.get(0);
return null;
}
}
......@@ -10,6 +10,6 @@ import org.springframework.stereotype.Repository;
*/
@SuppressWarnings("unused")
@Repository
public interface TaxiRepository extends JpaRepository<Taxi, Long> {
public interface TaxiRepository extends JpaRepository<Taxi, Long>, TaxiRepositoryCustom {
}
package com.mycompany.myapp.repository;
import java.util.List;
import com.mycompany.myapp.domain.Taxi;
public interface TaxiRepositoryCustom
{
public List<Taxi> getTaxisDisponibleUser(String login);
}
package com.mycompany.myapp.repository;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import com.mycompany.myapp.domain.ROLE_MANAGER_TAXI;
import com.mycompany.myapp.domain.Taxi;
import com.mycompany.myapp.domain.User;
public class TaxiRepositoryImpl implements TaxiRepositoryCustom
{
@PersistenceContext
EntityManager entityManager;
@Override
public List<Taxi> getTaxisDisponibleUser(String login)
{
List<User> users;
List<ROLE_MANAGER_TAXI> taxiManagers;
ROLE_MANAGER_TAXI taxiM;
//Recup de l'utilisateur par le login
Query query = entityManager.createNativeQuery(
"SELECT * FROM mytransport.jhi_user " + "WHERE mytransport.jhi_user.login = ? ", User.class);
query.setParameter(1, login);
users = query.getResultList();
if (users.isEmpty())
return null;
User user = users.get(0);
//Recup du taxi manager par l'utilisateur
query = entityManager.createNativeQuery(
"Select * FROM mytransport.role_manager_taxi as taxim WHERE taxim.user_id = ? ",
ROLE_MANAGER_TAXI.class);
query.setParameter(1, user.getId());
taxiManagers = query.getResultList();
if(taxiManagers.isEmpty())
{
return null;
}
//Cas où on a trouve un taxi manager
taxiM = taxiManagers.get(0);
//On fait une query pour recup tous les taxis affillies au manager, qui ont le statut en attente
query = entityManager.createNativeQuery(
"Select * FROM mytransport.taxi as taxi WHERE taxi.manager_id = ? AND taxi.statut = 'ATTENTE'",
Taxi.class);
query.setParameter(1, taxiM.getId());
return query.getResultList();
}
}
......@@ -16,7 +16,7 @@ import java.time.Instant;
* Spring Data JPA repository for the User entity.
*/
@Repository
public interface UserRepository extends JpaRepository<User, Long> {
public interface UserRepository extends JpaRepository<User, Long>, UserRepositoryCustom {
String USERS_BY_LOGIN_CACHE = "usersByLogin";
......
package com.mycompany.myapp.repository;
import com.mycompany.myapp.domain.User;
public interface UserRepositoryCustom
{
public User getConducteur(long id);
}
package com.mycompany.myapp.repository;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import com.mycompany.myapp.domain.ROLE_CONDUCTEUR_TAXI;
import com.mycompany.myapp.domain.User;
import com.mycompany.myapp.domain.Vehicule;
public class UserRepositoryImpl implements UserRepositoryCustom
{
@PersistenceContext
EntityManager entityManager;
@Override
public User getConducteur(long idTaxi)
{
List<ROLE_CONDUCTEUR_TAXI> drivers;
Query query = entityManager.createNativeQuery(
"SELECT * FROM mytransport.role_conducteur_taxi as driver WHERE driver.taxi_id = ?",
ROLE_CONDUCTEUR_TAXI.class);
query.setParameter(1, idTaxi);
drivers = query.getResultList();
if (drivers.isEmpty())
return null;
return drivers.get(0).getUser();
}
}
......@@ -18,27 +18,6 @@ public class VehiculeRepositoryImpl implements VehiculeRepositoryCustom
@PersistenceContext
EntityManager entityManager;
// Retourne les vehicules disponibles d'une agence entre deux dates
public List<Vehicule> findAllAvailableVehiculesrate(long idAgence, Instant startDate, Instant endDate)
{
Query query = entityManager.createNativeQuery("" + "SELECT * FROM mytransport.vehicule as vehicule "
+ "WHERE vehicule.agence_id = ? " + "AND NOT EXISTS( "
+ "SELECT id FROM mytransport.reservation as reservation WHERE reservation.vehicule_id = vehicule.id) "
+ "UNION " + "SELECT * FROM mytransport.vehicule as vehi " + "WHERE vehi.agence_id = ? "
+ "AND vehi.id NOT IN ( " + "SELECT DISTINCT id FROM mytransport.reservation "
+ "WHERE mytransport.reservation.start_date BETWEEN ? AND ? "
+ "OR mytransport.reservation.end_date BETWEEN ? AND ? " + ") " + "", Vehicule.class);
query.setParameter(1, idAgence);
query.setParameter(2, idAgence);
query.setParameter(3, startDate);
query.setParameter(4, endDate);
query.setParameter(5, startDate);
query.setParameter(6, endDate);
return query.getResultList();
}
public List<Vehicule> findAllAvailableVehicules(long idAgence, Instant startDate, Instant endDate)
{
List<Vehicule> vehicules;
......@@ -60,17 +39,10 @@ public class VehiculeRepositoryImpl implements VehiculeRepositoryCustom
vehicule = vehicules.get(i);
// On recupere les reservations
/*query = entityManager.createNativeQuery(
"" + "SELECT * FROM mytransport.reservation as reservation " + "WHERE reservation.vehicule_id = ? "
+ "AND (reservation.start_date BETWEEN ? AND ? OR reservation.end_date BETWEEN ? AND ?) "
+ "ORDER BY reservation.start_date",
Reservation.class);*/
query = entityManager.createNativeQuery(
"" + "SELECT * FROM mytransport.reservation as reservation " + "WHERE reservation.vehicule_id = ? "
+ "AND (? BETWEEN reservation.start_date AND reservation.end_date OR ? BETWEEN reservation.start_date AND reservation.end_date) ",
+ "AND (reservation.start_date BETWEEN ? AND ? OR reservation.end_date BETWEEN ? AND ? "
+ "OR (? BETWEEN reservation.start_date AND reservation.end_date OR ? BETWEEN reservation.start_date AND reservation.end_date)) ",
Reservation.class);
......@@ -79,6 +51,10 @@ public class VehiculeRepositoryImpl implements VehiculeRepositoryCustom
query.setParameter(1, vehicule.getId());
query.setParameter(2, startDate);
query.setParameter(3, endDate);
query.setParameter(4, startDate);
query.setParameter(5, endDate);
query.setParameter(6, startDate);
query.setParameter(7, endDate);
reservations = query.getResultList();
......@@ -97,7 +73,11 @@ public class VehiculeRepositoryImpl implements VehiculeRepositoryCustom
Reservation reservationNext;
if (reservations.isEmpty())
{
System.out.println("ici0");
return true;
}
for (int i = 0; i < reservations.size(); i++)
{
......@@ -110,6 +90,7 @@ public class VehiculeRepositoryImpl implements VehiculeRepositoryCustom
Instant dateLimiteDebut = reservation.getStartDate().minus(nbJours, ChronoUnit.DAYS);
if (dateLimiteDebut.compareTo(startDate) > 0)
{
System.out.println("ici1");
return true;
}
}
......@@ -121,6 +102,7 @@ public class VehiculeRepositoryImpl implements VehiculeRepositoryCustom
Instant dateLimiteFin = reservation.getEndDate().plus(nbJours, ChronoUnit.DAYS);
if (dateLimiteFin.compareTo(endDate) < 0)
{
System.out.println("ici2");
return true;
}
}
......@@ -131,6 +113,7 @@ public class VehiculeRepositoryImpl implements VehiculeRepositoryCustom
if (reservation.getEndDate().plus(nbJours, ChronoUnit.DAYS)
.compareTo(reservationNext.getStartDate()) < 0)
{
System.out.println("ici3");
return true;
}
}
......@@ -160,24 +143,26 @@ public class VehiculeRepositoryImpl implements VehiculeRepositoryCustom
vehicule = vehicules.get(i);
// On recupere les reservations
/*query = entityManager.createNativeQuery(
"" + "SELECT * FROM mytransport.reservation as reservation " + "WHERE reservation.vehicule_id = ? "
+ "AND (reservation.start_date BETWEEN ? AND ? OR reservation.end_date BETWEEN ? AND ?) "
+ "ORDER BY reservation.start_date",
Reservation.class);*/
query = entityManager.createNativeQuery(
"" + "SELECT * FROM mytransport.reservation as reservation " + "WHERE reservation.vehicule_id = ? "
+ "AND ( ? BETWEEN reservation.start_date AND reservation.end_date OR ? BETWEEN reservation.start_date AND reservation.end_date) "
// + "AND ( ? BETWEEN reservation.start_date AND reservation.end_date OR ? BETWEEN reservation.start_date AND reservation.end_date) "
+ "AND ( reservation.start_date BETWEEN ? AND ? OR reservation.end_date BETWEEN ? AND ? "
+ "OR ( ? BETWEEN reservation.start_date AND reservation.end_date OR ? BETWEEN reservation.start_date AND reservation.end_date)) "
+ "ORDER BY reservation.start_date",
Reservation.class);
query.setParameter(1, vehicule.getId());
query.setParameter(2, startDate);
query.setParameter(3, endDate);
query.setParameter(4, startDate);
query.setParameter(5, endDate);
query.setParameter(6, startDate);
query.setParameter(7, endDate);
reservations = query.getResultList();
System.out.println("\n\n\n"+vehicule);
System.out.println(reservations+"\n\n\n");
if (disponibiliteFlex(startDate, endDate, nbJours, reservations))
{
......
......@@ -2,6 +2,7 @@ package com.mycompany.myapp.web.rest;
import com.codahale.metrics.annotation.Timed;
import com.mycompany.myapp.domain.Course;
import com.mycompany.myapp.domain.Taxi;
import com.mycompany.myapp.repository.CourseRepository;
import com.mycompany.myapp.repository.search.CourseSearchRepository;
import com.mycompany.myapp.web.rest.errors.BadRequestAlertException;
......@@ -15,7 +16,7 @@ import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.net.URI;
import java.net.URISyntaxException;
import java.time.Instant;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
......@@ -98,6 +99,39 @@ public class CourseResource {
.headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, course.getId().toString()))
.body(result);
}
/**
* PUT /courses/puttaxi/:idCourse/:idTaxi/:debutEffectif/: : Updates an existing course to put a taxi and a start date
*
*@param idCourse the if of the course
* @param idTaxi the id of the taxi
* @param debutEffectif the start date
* @return the ResponseEntity with status 200 (OK),
*/
@PutMapping("/courses/puttaxi/{idCourse}/{idTaxi}/{debutEffectif}")
@Timed
public ResponseEntity<Course> updateCourseTaxi(@PathVariable Long idCourse ,@PathVariable Long idTaxi, @PathVariable Instant debutEffectif ) throws URISyntaxException {
log.debug("REST request to update Course with a taxi");
Optional<Course> courseOptional = courseRepository.findById(idCourse);
Course course = courseOptional.get();
course.setDebut_effectif(debutEffectif);
Taxi taxi = courseRepository.getTaxi(idTaxi);
if(taxi != null)
{
course.setTaxi(taxi);
Course result = courseRepository.save(course);
courseSearchRepository.save(result);
return ResponseEntity.ok()
.headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, course.getId().toString()))
.body(result);
}
return null;
}
/**
* GET /courses : get all the courses.
......
......@@ -71,7 +71,7 @@ public class MailResource {
final User logged_user = userService.getUserWithAuthorities().get();
log.debug("Logged user is " + logged_user.getFirstName());
log.debug("Its mail is " + logged_user.getEmail());
log.debug("Its email is " + logged_user.getEmail());
// get document in attachement
log.debug("File size is : " + file.getSize());
......@@ -79,7 +79,7 @@ public class MailResource {
InputStream fip;
try {
fip = file.getInputStream();
mailService.sendEmailWithAttachment("ecom.mytransport@gmail.com", "Swagga", "", true, true, "fichier attaché", fip);
mailService.sendEmailWithAttachment(logged_user.getEmail(), "Rapport d'agence", "", true, true, "Rapport.pdf", fip);
return ResponseEntity.ok().body("file uploaded : " + file.getSize());
......
......@@ -43,7 +43,7 @@ public class TauxResource {
this.tauxRepository = tauxRepository;
this.tauxSearchRepository = tauxSearchRepository;
}
/**
* POST /tauxes : Create a new taux.
......@@ -114,8 +114,8 @@ public class TauxResource {
Optional<Taux> taux = tauxRepository.findById(id);
return ResponseUtil.wrapOrNotFound(taux);
}
/**
* GET /tauxes/agence/:id/:startDate/:endDate : get tauxes of :id agency between :startDate and :endDate
*
......@@ -128,15 +128,15 @@ public class TauxResource {
// public ResponseEntity<List<Taux>> getTauxesForAgence(@PathVariable Long id, @PathVariable Instant startDate, @PathVariable Instant endDate) {
//public ResponseEntity<List<Taux>> getTauxesForAgence(@RequestParam("id") long id, @RequestParam("startDate") Instant startDate, @RequestParam("endDate") Instant endDate)
public ResponseEntity<String> getTauxesForAgence(@RequestParam("id") long id, @RequestParam("startDate") Instant startDate, @RequestParam("endDate") Instant endDate)
{
{
log.debug("REST request to get Tauxes for agence : {}", id);
List<Taux> tauxes = tauxRepository.getTauxWithIdAgence(id, startDate, endDate);
//--------*********************************
//Optional<List<Taux>> taux = Optional.ofNullable(tauxes);
//return ResponseUtil.wrapOrNotFound(taux);
String envoie = "[\n";
for(int i =0; i < tauxes.size(); i++)
......@@ -148,10 +148,9 @@ public class TauxResource {
}
}
envoie = envoie + "\n]";
return ResponseEntity.ok().body(envoie);
// return ResponseUtil.wrapOrNotFound(taux);
}
/**
......
......@@ -4,6 +4,7 @@ import com.codahale.metrics.annotation.Timed;
import com.mycompany.myapp.domain.Taxi;
import com.mycompany.myapp.repository.TaxiRepository;
import com.mycompany.myapp.repository.search.TaxiSearchRepository;
import com.mycompany.myapp.security.SecurityUtils;
import com.mycompany.myapp.web.rest.errors.BadRequestAlertException;
import com.mycompany.myapp.web.rest.util.HeaderUtil;
import io.github.jhipster.web.util.ResponseUtil;
......@@ -120,6 +121,23 @@ public class TaxiResource {
Optional<Taxi> taxi = taxiRepository.findById(id);
return ResponseUtil.wrapOrNotFound(taxi);
}
/**
* GET /taxisDispo : get dispnobile taxis.
*
* @return the ResponseEntity with status 200 (OK) and with body taxis, or with status 404 (Not Found)