Search in sources :

Example 6 with Person

use of com.bigcrowd.noticeBoard.entities.Person in project Notice-Board by FulvioFPimentel.

the class PersonService method savePerson.

@Transactional
public PersonAllDTO savePerson(PersonSaveDTO dto) {
    Person person = new Person();
    person.setName(dto.getName());
    person.setCellPhone(dto.getCellPhone());
    person.setPassword(passwordEncoder.encode(dto.getPassword()));
    Role role = roleRepository.getById(3L);
    person.getRoles().add(role);
    person = personRepository.saveAndFlush(person);
    return new PersonAllDTO(person, person.getRoles());
}
Also used : Role(com.bigcrowd.noticeBoard.entities.Role) PersonAllDTO(com.bigcrowd.noticeBoard.dto.PersonAllDTO) Person(com.bigcrowd.noticeBoard.entities.Person) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with Person

use of com.bigcrowd.noticeBoard.entities.Person in project Notice-Board by FulvioFPimentel.

the class PersonService method updatePerson.

public PersonSaveDTO updatePerson(Long id, PersonSaveDTO dto) {
    Person person = personRepository.getById(id);
    person.setName(dto.getName());
    person.setCellPhone(dto.getCellPhone());
    person.setPassword(passwordEncoder.encode(dto.getPassword()));
    person = personRepository.saveAndFlush(person);
    return new PersonSaveDTO(person);
}
Also used : PersonSaveDTO(com.bigcrowd.noticeBoard.dto.savesDTO.PersonSaveDTO) Person(com.bigcrowd.noticeBoard.entities.Person)

Example 8 with Person

use of com.bigcrowd.noticeBoard.entities.Person in project Notice-Board by FulvioFPimentel.

the class PersonService method findById.

@Transactional(readOnly = true)
public PersonDesignationsDTO findById(Long id) {
    Optional<Person> obj = personRepository.findById(id);
    Person person = obj.get();
    List<Designation> designations = designationRepository.findAllByPerson(person);
    return new PersonDesignationsDTO(person, designations);
}
Also used : Designation(com.bigcrowd.noticeBoard.entities.Designation) PersonDesignationsDTO(com.bigcrowd.noticeBoard.dto.PersonDesignationsDTO) Person(com.bigcrowd.noticeBoard.entities.Person) Transactional(org.springframework.transaction.annotation.Transactional)

Example 9 with Person

use of com.bigcrowd.noticeBoard.entities.Person 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 10 with Person

use of com.bigcrowd.noticeBoard.entities.Person 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

Person (com.bigcrowd.noticeBoard.entities.Person)10 Transactional (org.springframework.transaction.annotation.Transactional)6 Designation (com.bigcrowd.noticeBoard.entities.Designation)5 DesignationSaveDTO (com.bigcrowd.noticeBoard.dto.savesDTO.DesignationSaveDTO)4 Assignment (com.bigcrowd.noticeBoard.entities.Assignment)4 Meeting (com.bigcrowd.noticeBoard.entities.Meeting)3 CanticleSaveDTO (com.bigcrowd.noticeBoard.dto.savesDTO.CanticleSaveDTO)2 MeetingSaveDTO (com.bigcrowd.noticeBoard.dto.savesDTO.MeetingSaveDTO)2 PersonSaveDTO (com.bigcrowd.noticeBoard.dto.savesDTO.PersonSaveDTO)2 PrayerSaveDTO (com.bigcrowd.noticeBoard.dto.savesDTO.PrayerSaveDTO)2 SessionSaveDTO (com.bigcrowd.noticeBoard.dto.savesDTO.SessionSaveDTO)2 SubSessionSaveDTO (com.bigcrowd.noticeBoard.dto.savesDTO.SubSessionSaveDTO)2 Canticle (com.bigcrowd.noticeBoard.entities.Canticle)2 Prayer (com.bigcrowd.noticeBoard.entities.Prayer)2 Presidency (com.bigcrowd.noticeBoard.entities.Presidency)2 Role (com.bigcrowd.noticeBoard.entities.Role)2 Segmentation (com.bigcrowd.noticeBoard.entities.Segmentation)2 Session (com.bigcrowd.noticeBoard.entities.Session)2 SubSession (com.bigcrowd.noticeBoard.entities.SubSession)2 Support (com.bigcrowd.noticeBoard.entities.Support)2