Search in sources :

Example 1 with Support

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();
    }
}
Also used : Designation(com.bigcrowd.noticeBoard.entities.Designation) Support(com.bigcrowd.noticeBoard.entities.Support) Segmentation(com.bigcrowd.noticeBoard.entities.Segmentation) Meeting(com.bigcrowd.noticeBoard.entities.Meeting) ArrayList(java.util.ArrayList) Prayer(com.bigcrowd.noticeBoard.entities.Prayer)

Example 2 with Support

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());
}
Also used : Assignment(com.bigcrowd.noticeBoard.entities.Assignment) SupportSaveDTO(com.bigcrowd.noticeBoard.dto.savesDTO.SupportSaveDTO) Designation(com.bigcrowd.noticeBoard.entities.Designation) DesignationSaveDTO(com.bigcrowd.noticeBoard.dto.savesDTO.DesignationSaveDTO) Support(com.bigcrowd.noticeBoard.entities.Support) Person(com.bigcrowd.noticeBoard.entities.Person) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with Support

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());
}
Also used : Assignment(com.bigcrowd.noticeBoard.entities.Assignment) Designation(com.bigcrowd.noticeBoard.entities.Designation) DesignationSaveDTO(com.bigcrowd.noticeBoard.dto.savesDTO.DesignationSaveDTO) Support(com.bigcrowd.noticeBoard.entities.Support) Meeting(com.bigcrowd.noticeBoard.entities.Meeting) SupportDTO(com.bigcrowd.noticeBoard.dto.SupportDTO) Person(com.bigcrowd.noticeBoard.entities.Person) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Designation (com.bigcrowd.noticeBoard.entities.Designation)3 Support (com.bigcrowd.noticeBoard.entities.Support)3 DesignationSaveDTO (com.bigcrowd.noticeBoard.dto.savesDTO.DesignationSaveDTO)2 Assignment (com.bigcrowd.noticeBoard.entities.Assignment)2 Meeting (com.bigcrowd.noticeBoard.entities.Meeting)2 Person (com.bigcrowd.noticeBoard.entities.Person)2 Transactional (org.springframework.transaction.annotation.Transactional)2 SupportDTO (com.bigcrowd.noticeBoard.dto.SupportDTO)1 SupportSaveDTO (com.bigcrowd.noticeBoard.dto.savesDTO.SupportSaveDTO)1 Prayer (com.bigcrowd.noticeBoard.entities.Prayer)1 Segmentation (com.bigcrowd.noticeBoard.entities.Segmentation)1 ArrayList (java.util.ArrayList)1