-
Notifications
You must be signed in to change notification settings - Fork 2
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 #112 from MORE-Platform/111_participant_ids_endpoint
#111 Add an Endpoint to List Participants for External Services
- Loading branch information
Showing
8 changed files
with
189 additions
and
32 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
36 changes: 36 additions & 0 deletions
36
src/main/java/io/redlink/more/data/controller/transformer/ParticipantTransformer.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,36 @@ | ||
package io.redlink.more.data.controller.transformer; | ||
|
||
import io.redlink.more.data.api.app.v1.model.ParticipantDTO; | ||
import io.redlink.more.data.api.app.v1.model.ParticipantStatusDTO; | ||
import io.redlink.more.data.api.app.v1.model.ParticipantStudyGroupDTO; | ||
import io.redlink.more.data.model.Participant; | ||
|
||
public final class ParticipantTransformer { | ||
|
||
private ParticipantTransformer() {} | ||
|
||
public static ParticipantDTO toDTO(Participant participant) { | ||
if (participant == null) { | ||
return null; | ||
} | ||
return new ParticipantDTO( | ||
String.valueOf(participant.id()), | ||
participant.alias(), | ||
ParticipantStatusDTO.fromValue(participant.status()), | ||
toGroupDto(participant), | ||
BaseTransformers.toOffsetDateTime(participant.start()) | ||
); | ||
} | ||
|
||
private static ParticipantStudyGroupDTO toGroupDto(Participant participant) { | ||
if (participant.studyGroupId().isPresent()) { | ||
final int groupId = participant.studyGroupId().getAsInt(); | ||
return new ParticipantStudyGroupDTO( | ||
String.valueOf(groupId), | ||
participant.studyGroupTitle() | ||
); | ||
} else { | ||
return null; | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package io.redlink.more.data.model; | ||
|
||
import java.time.Instant; | ||
import java.util.OptionalInt; | ||
|
||
public record Participant( | ||
int id, | ||
String alias, | ||
String status, | ||
OptionalInt studyGroupId, | ||
String studyGroupTitle, | ||
Instant start | ||
) {} |
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