-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #89 from InseeFr/feat_record_communication
Feat record communication
- Loading branch information
Showing
11 changed files
with
132 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...y/datacollectionmanagement/questioning/controller/QuestioningCommunicationController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package fr.insee.survey.datacollectionmanagement.questioning.controller; | ||
|
||
import fr.insee.survey.datacollectionmanagement.config.auth.user.AuthorityPrivileges; | ||
import fr.insee.survey.datacollectionmanagement.constants.Constants; | ||
import fr.insee.survey.datacollectionmanagement.questioning.domain.Questioning; | ||
import fr.insee.survey.datacollectionmanagement.questioning.domain.QuestioningCommunication; | ||
import fr.insee.survey.datacollectionmanagement.questioning.dto.QuestioningCommunicationDto; | ||
import fr.insee.survey.datacollectionmanagement.questioning.service.QuestioningService; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.modelmapper.ModelMapper; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.security.access.prepost.PreAuthorize; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.text.ParseException; | ||
import java.util.Set; | ||
|
||
@RestController | ||
@PreAuthorize(AuthorityPrivileges.HAS_MANAGEMENT_PRIVILEGES) | ||
@Tag(name = "2 - Questioning", description = "Enpoints to create, update, delete and find entities around the questionings") | ||
@Slf4j | ||
@RequiredArgsConstructor | ||
public class QuestioningCommunicationController { | ||
|
||
private final QuestioningService questioningService; | ||
|
||
private final ModelMapper modelMapper; | ||
|
||
@Operation(summary = "Search for questioning communications by questioning id") | ||
@GetMapping(value = Constants.API_QUESTIONING_ID_QUESTIONING_COMMUNICATIONS, produces = "application/json") | ||
public ResponseEntity<?> findQuestioningCommunicationsByQuestioningId(@PathVariable("id") Long id) { | ||
Questioning questioning = questioningService.findbyId(id); | ||
Set<QuestioningCommunication> setQe = questioning.getQuestioningCommunications(); | ||
return ResponseEntity.status(HttpStatus.OK) | ||
.body(setQe.stream() | ||
.map(this::convertToDto).toList()); | ||
|
||
} | ||
|
||
|
||
private QuestioningCommunicationDto convertToDto(QuestioningCommunication questioningCommunication) { | ||
return modelMapper.map(questioningCommunication, QuestioningCommunicationDto.class); | ||
} | ||
|
||
private QuestioningCommunication convertToEntity(QuestioningCommunicationDto questioningCommunicationDto) throws ParseException { | ||
return modelMapper.map(questioningCommunicationDto, QuestioningCommunication.class); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...fr/insee/survey/datacollectionmanagement/questioning/domain/QuestioningCommunication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package fr.insee.survey.datacollectionmanagement.questioning.domain; | ||
|
||
import fr.insee.survey.datacollectionmanagement.questioning.util.StatusCommunication; | ||
import fr.insee.survey.datacollectionmanagement.questioning.util.TypeCommunicationEvent; | ||
import jakarta.persistence.*; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
import java.util.Date; | ||
|
||
@Entity | ||
@Getter | ||
@Setter | ||
@Table(indexes = { | ||
@Index(name = "idQuestioningComm_index", columnList = "questioning_id") | ||
}) | ||
public class QuestioningCommunication { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "questioning_communication_seq") | ||
private Long id; | ||
|
||
private Date date; | ||
@Enumerated(EnumType.STRING) | ||
private TypeCommunicationEvent type; | ||
|
||
@ManyToOne | ||
private Questioning questioning; | ||
@Enumerated(EnumType.STRING) | ||
private StatusCommunication status; | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
...fr/insee/survey/datacollectionmanagement/questioning/dto/QuestioningCommunicationDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package fr.insee.survey.datacollectionmanagement.questioning.dto; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
import java.util.Date; | ||
|
||
@Getter | ||
@Setter | ||
public class QuestioningCommunicationDto { | ||
|
||
private Long id; | ||
private Long questioningId; | ||
private Date date; | ||
private String type; | ||
private String status; | ||
|
||
} |
5 changes: 5 additions & 0 deletions
5
...n/java/fr/insee/survey/datacollectionmanagement/questioning/util/StatusCommunication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package fr.insee.survey.datacollectionmanagement.questioning.util; | ||
|
||
public enum StatusCommunication { | ||
AUTOMATIC, MANUAL | ||
} |
5 changes: 5 additions & 0 deletions
5
...ava/fr/insee/survey/datacollectionmanagement/questioning/util/TypeCommunicationEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package fr.insee.survey.datacollectionmanagement.questioning.util; | ||
|
||
public enum TypeCommunicationEvent { | ||
COURRIER_OUVERTURE, MAIL_OUVERTURE, COURRIER_RELANCE, MAIL_RELANCE, COURRIER_MED, COURRIER_CNR; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters