Commit cb2177bf authored by LAVENIER's avatar LAVENIER
Browse files

[fix] Fix save Landing with LandedTrip : must set the tripId and fetch the...

[fix] Fix save Landing with LandedTrip : must set the tripId and fetch the trip in graphql service - fix IMAGINE-540
[fix] Fix landing deletion
parent 12ef3595
......@@ -168,10 +168,12 @@ public class LandingServiceImpl implements LandingService {
public void delete(int id) {
// Create events (before deletion, to be able to join VO)
Landing toDelete = null;
LandingVO deletedVO = null;
Integer tripId = null;
if (enableTrash) {
deletedVO = get(id);
toDelete = landingRepository.getById(id);
deletedVO = landingRepository.toVO(toDelete);
tripId = deletedVO.getTripId();
if (tripId != null) {
deletedVO.setTrip(tripRepository.get(tripId)); // TODO full VO loading
......@@ -183,10 +185,13 @@ public class LandingServiceImpl implements LandingService {
}
// Apply deletion
landingRepository.deleteById(id);
if (toDelete == null)
landingRepository.deleteById(id);
else
landingRepository.delete(toDelete);
// Publish events
publisher.publishEvent(new EntityDeleteEvent(id, Trip.class.getSimpleName(), deletedVO));
publisher.publishEvent(new EntityDeleteEvent(id, Landing.class.getSimpleName(), deletedVO));
}
@Override
......@@ -275,6 +280,7 @@ public class LandingServiceImpl implements LandingService {
.withOperationGroup(true)
.build());
source.setTripId(savedTrip.getId());
source.setTrip(savedTrip);
}
}
......
......@@ -898,6 +898,7 @@ public class DataGraphQLService {
@GraphQLQuery(name = "trip", description = "Get landing's trip")
public TripVO getTripByLanding(@GraphQLContext LandingVO landing) {
if (landing.getTrip() != null) return landing.getTrip(); // Used updated entity, if exists (e.g. when saving)
if (landing.getTripId() == null) return null;
return tripService.get(landing.getTripId());
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment