Diagrammes de Séquence
Ce document contient les diagrammes de séquence montrant les flux d'interaction pour chaque endpoint de l'API PersonAPI.
Gestion des Personnes
Création d'une Personne
sequenceDiagram
Client->>+PersonController: POST /api/v1/persons
PersonController->>+PersonService: addPerson(person)
PersonService->>PersonMapper: dtoToEntity(person)
PersonMapper-->>PersonService: personEntity
PersonService->>+PersonRepository: save(personEntity)
PersonRepository-->>-PersonService: savedEntity
PersonService->>PersonMapper: entityToRepresentation(savedEntity)
PersonService-->>-PersonController: personRepresentation
PersonController-->>-Client: 201 CREATED
Mise à jour d'une Personne
sequenceDiagram
Client->>+PersonController: PUT /api/v1/persons/{personId}
PersonController->>+PersonService: updatePerson(personId, person)
PersonService->>+PersonRepository: findByIdAndIsDeletedFalse(personId)
PersonRepository-->>-PersonService: existingPersonEntity
PersonService->>PersonMapper: entityToDto(existingPersonEntity)
PersonService->>PersonUtils: compareIgnoringFields(person, existingPerson)
alt changements détectés
PersonService->>PersonUtils: areAttributesNotEmpty(person)
alt personne complète
PersonService->>PersonMapper: dtoToEntity(existingPersonEntity, person)
PersonService->>PersonRepository: save(existingPersonEntity)
end
end
PersonService-->>-PersonController: personRepresentation
PersonController-->>-Client: 200 OK
Suppression d'une Personne
sequenceDiagram
Client->>+PersonController: DELETE /api/v1/persons/{personId}
PersonController->>+PersonService: deletePerson(personId)
PersonService->>+PersonRepository: findByIdAndIsDeletedFalse(personId)
PersonRepository-->>-PersonService: existingPersonEntity
PersonService->>PersonService: setDeleted(true)
PersonService->>PersonRepository: save(existingPersonEntity)
PersonService-->>-PersonController: void
PersonController-->>-Client: 204 NO CONTENT
Récupération d'une Personne
sequenceDiagram
Client->>+PersonController: GET /api/v1/persons/{personId}
PersonController->>+PersonService: getPerson(personId)
PersonService->>+PersonRepository: findByIdAndIsDeletedFalse(personId)
PersonRepository-->>-PersonService: existingPersonEntity
PersonService->>PersonMapper: entityToRepresentation(existingPersonEntity)
PersonService-->>-PersonController: personRepresentation
PersonController-->>-Client: 200 OK
Liste des Personnes
sequenceDiagram
Client->>+PersonController: GET /api/v1/persons
PersonController->>+PersonService: listPersons(request, page, size)
PersonService->>PersonSpecification: searchWithParams(attachmentIds, personIds)
PersonService->>+PersonRepository: findAll(specification, pageable)
PersonRepository-->>-PersonService: Page<PersonEntity>
PersonService->>PersonService: Mappage des entités vers DTOs
PersonService-->>-PersonController: ListPersonResume
PersonController-->>-Client: 200 OK
Gestion des Favoris
Ajout d'un Favori
sequenceDiagram
Client->>+PersonController: POST /api/v1/persons/{personId}/favorites
PersonController->>+FavoriteService: addFavorite(personId, favorite)
FavoriteService->>+PersonRepository: findByIdAndIsDeletedFalse(personId)
PersonRepository-->>-FavoriteService: personEntity
FavoriteService->>+FavoriteRepository: findByEntityIdAndPerson_Id(entityId, personId)
alt favori existe
FavoriteRepository-->>FavoriteService: existingFavorite
FavoriteService->>FavoriteService: setDeleted(false)
else favori n'existe pas
FavoriteService->>FavoriteMapper: dtoToEntity(favorite)
FavoriteService->>FavoriteService: setPerson(personEntity)
end
FavoriteService->>FavoriteRepository: save(favoriteEntity)
FavoriteRepository-->>FavoriteService: savedEntity
FavoriteService->>FavoriteMapper: entityToRepresentation(savedEntity)
FavoriteService-->>-PersonController: favoriteRepresentation
PersonController-->>-Client: 201 CREATED
Suppression d'un Favori
sequenceDiagram
Client->>+PersonController: DELETE /api/v1/persons/{personId}/favorites/{favoriteId}
PersonController->>+FavoriteService: deleteFavorite(personId, favoriteId)
FavoriteService->>+PersonRepository: findByIdAndIsDeletedFalse(personId)
PersonRepository-->>-FavoriteService: personEntity
FavoriteService->>+FavoriteRepository: findByIdAndPerson_IdAndIsDeletedFalse(favoriteId, personId)
FavoriteRepository-->>-FavoriteService: favoriteEntity
FavoriteService->>FavoriteService: setDeleted(true)
FavoriteService->>FavoriteRepository: save(favoriteEntity)
FavoriteService-->>-PersonController: void
PersonController-->>-Client: 204 NO CONTENT
Liste des Favoris
sequenceDiagram
Client->>+PersonController: GET /api/v1/persons/{personId}/favorites
PersonController->>+FavoriteService: listFavorites(personId, entityType, size, page)
FavoriteService->>+PersonRepository: findByIdAndIsDeletedFalse(personId)
PersonRepository-->>-FavoriteService: personEntity
FavoriteService->>FavoriteSpecification: searchWithParams(personId, entityType)
FavoriteService->>+FavoriteRepository: findAll(specification, pageable)
FavoriteRepository-->>-FavoriteService: Page<FavoriteEntity>
FavoriteService->>FavoriteService: Mappage des entités vers DTOs
FavoriteService-->>-PersonController: ListFavoriteResume
PersonController-->>-Client: 200 OK
Gestion des Pièces Jointes
Ajout d'une Pièce Jointe
sequenceDiagram
Client->>+PersonController: POST /api/v1/persons/{personId}/attachments
PersonController->>+AttachmentService: addAttachment(personId, attachment)
AttachmentService->>+PersonRepository: findByIdAndIsDeletedFalse(personId)
PersonRepository-->>-AttachmentService: personEntity
AttachmentService->>+AttachmentRepository: findByEntityIdAndPerson_Id(entityId, personId)
alt pièce jointe existe
AttachmentRepository-->>AttachmentService: existingAttachment
AttachmentService->>AttachmentService: setDeleted(false)
else pièce jointe n'existe pas
AttachmentService->>AttachmentMapper: dtoToEntity(attachment)
AttachmentService->>AttachmentService: setPerson(personEntity)
end
AttachmentService->>AttachmentRepository: save(attachmentEntity)
AttachmentRepository-->>AttachmentService: savedEntity
AttachmentService->>AttachmentMapper: entityToRepresentation(savedEntity)
AttachmentService-->>-PersonController: attachmentRepresentation
PersonController-->>-Client: 201 CREATED
Suppression d'une Pièce Jointe
sequenceDiagram
Client->>+PersonController: DELETE /api/v1/persons/{personId}/attachments/{entityId}
PersonController->>+AttachmentService: deleteAttachment(personId, entityId)
AttachmentService->>+PersonRepository: findByIdAndIsDeletedFalse(personId)
PersonRepository-->>-AttachmentService: personEntity
AttachmentService->>+AttachmentRepository: findByEntityIdAndPersonIdAndIsDeletedFalse(entityId, personId)
AttachmentRepository-->>-AttachmentService: attachmentEntity
AttachmentService->>AttachmentService: setDeleted(true)
AttachmentService->>AttachmentRepository: save(attachmentEntity)
AttachmentService-->>-PersonController: void
PersonController-->>-Client: 204 NO CONTENT
Liste des Pièces Jointes
sequenceDiagram
Client->>+PersonController: GET /api/v1/persons/{personId}/attachments
PersonController->>+AttachmentService: listAttachments(personId, size, page)
AttachmentService->>+PersonRepository: findByIdAndIsDeletedFalse(personId)
PersonRepository-->>-AttachmentService: personEntity
AttachmentService->>AttachmentSpecification: searchWithParams(personId)
AttachmentService->>+AttachmentRepository: findAll(specification, pageable)
AttachmentRepository-->>-AttachmentService: Page<AttachmentEntity>
AttachmentService->>AttachmentService: Mappage des entités vers DTOs
AttachmentService-->>-PersonController: ListAttachmentResume
PersonController-->>-Client: 200 OK