use of com.bigcrowd.noticeBoard.entities.Support in project Notice-Board by FulvioFPimentel.
the class MeetingService method delete.
public void delete(Long id) {
try {
Meeting meeting = repository.getById(id);
for (Support sub : meeting.getSupports()) {
List<Designation> desig = new ArrayList<>();
sub.getDesignations().forEach(x -> desig.add(x));
sub.getDesignations().clear();
for (Designation des : desig) {
designationRepository.delete(designationRepository.getById(des.getId()));
}
supportRepository.deleteById(sub.getId());
}
for (Prayer prayer : meeting.getPrayers()) {
designationRepository.deleteById(prayer.getDesignation().getId());
prayerRepository.deleteById(prayer.getId());
}
meeting.getCanticles().clear();
meeting.getPrayers().clear();
List<Segmentation> seg = segmentationRepository.findByMeeting(meeting);
for (Segmentation s : seg) {
for (Designation des : s.getDesignations()) {
designationRepository.deleteById(des.getId());
}
segmentationRepository.deleteById(s.getId());
}
designationRepository.deleteById(meeting.getPresidency().getDesignation().getId());
presidencyRepository.deleteById(meeting.getPresidency().getId());
repository.deleteById(id);
} catch (RuntimeException e) {
e.getMessage();
}
}
use of com.bigcrowd.noticeBoard.entities.Support in project Notice-Board by FulvioFPimentel.
the class SupportService method update.
@Transactional
public SupportSaveDTO update(Long id, SupportSaveDTO dto) {
Support support = supportRepository.getById(id);
support.setMeeting(support.getMeeting());
for (DesignationSaveDTO desig : dto.getDesignations()) {
Designation designation = designationRepository.getById(desig.getId());
Assignment assignment = assignmentRepository.getById(desig.getAssignment().getId());
Person person = personRepository.getById(desig.getPerson().getId());
designation.setAssignment(assignment);
designation.setPerson(person);
designation = designationRepository.saveAndFlush(designation);
support.getDesignations().add(designation);
}
support = supportRepository.saveAndFlush(support);
return new SupportSaveDTO(support, support.getDesignations());
}
use of com.bigcrowd.noticeBoard.entities.Support in project Notice-Board by FulvioFPimentel.
the class SupportService method saveSupport.
@Transactional
public SupportDTO saveSupport(SupportSaveDTO dto) {
Meeting meeting = meetingRepository.getById(dto.getMeetingId());
Support support = new Support();
support.setMeeting(meeting);
for (DesignationSaveDTO desg : dto.getDesignations()) {
Assignment Assignment = assignmentRepository.getById(desg.getAssignment().getId());
Person person = personRepository.getById(desg.getPerson().getId());
Designation designation = new Designation();
designation.setAssignment(Assignment);
designation.setPerson(person);
designation = designationRepository.saveAndFlush(designation);
support.getDesignations().add(designation);
}
support = supportRepository.saveAndFlush(support);
return new SupportDTO(support, support.getDesignations());
}
Aggregations