# Linaris_MAUI_SAE_201

## Diagramme de classe

```plantuml
@startuml
class Artist {
    - string name
    + Artist(string name)
    + boolean Equals(object obj)
    + int GetHashCode()
    + string ToString()
}

class Album {
    - string name
    - string description
    - string imageURL
    - string information
    + Album(string name, string file_Name, Artist artist, string description, string information)
    + Album()
    + void AddTitle(Title title)
    + void RemoveTitle(Title title)
    + boolean Equals(object obj)
    + int GetHashCode()
    + string ToString()
}

class Playlist {
    - string name
    - string description
    - string imageURL
    - int index = 0
    + boolean shuffle = false
    + boolean loop = false
    + boolean looptitle = false
    - List<int> played
    + Playlist(string nom, string description, string imageURL)
    + Playlist()
    + void AddTitle(CustomTitle morceau)
    + void RemoveTitle(CustomTitle morceau)
    + void NextTitle()
    + void PreviousTitle()
    + Title? GetCurrentTitle()
    + boolean Equals(object? obj)
    + int GetHashCode()
    + string ToString()
    - int RandomGenerator(int n)
}

class Title {
    - string name
    - string imageURL
    - string information
    + Title(string nom, string file_Name, string informations)
    + boolean Equals(object? obj)
    + int GetHashCode()
    + string ToString()
}

enum Genre
{
    HIP_HOP
    POP
    ROCK
    ELECTRO
    CLASSIQUE
    JAZZ
    VARIETE_FRANCAISE
    VARIETE_INTERNATIONALE
    REGGAE
    RAP
    RNB
    DISCO
    BLUES
    COUNTRY
    FUNK
    GOSPEL
    METAL
    K_POP
}

class CustomTitle {
    - string path
    + CustomTitle(string name, string imageURL, string information, string path)
    + CustomTitle()
    + boolean Equals(object? obj)
    + int GetHashCode()
    + string ToString()
}

class InfoTitle {
    - string description
    - List<Artist> feat
    + InfoTitle(string name, string imageURL, string information, Artist artist, string description, Genre genre)
    + InfoTitle()
    + void AddFeat(Artist artist)
    + void RemoveFeat(Artist artiste)
    + boolean Equals(object? obj)
    + int GetHashCode()
    + string ToString()

}

interface IDataManager {
    + void AddAlbum(Album album)
    + void AddAlbums(List<Album> albumsList)
    + void AddArtist(Artist artist)
    + void AddArtists(List<Artist> artistsList)
    + void AddPlaylist(Playlist playlist)
    + void AddPlaylists(List<Playlist> playlistsList)
    + void AddCustomTitle(CustomTitle title)
    + void AddCustomTitles(List<CustomTitle> customTitlesList)
    + void AddInfoTitle(InfoTitle title)
    + void AddInfoTitles(List<InfoTitle> infoTitlesList)
    + List<CustomTitle> GetCustomTitles()
    + CustomTitle? GetCustomTitleByUrl(string custom)
    + List<InfoTitle> GetInfoTitles()
    + InfoTitle? GetInfoTitleByUrl(string url)
    + List<Album> GetAlbums()
    + Album? GetAlbumByUrl(string url)
    + List<Artist> GetArtists()
    + Artist? GetArtistByName(string name)
    + List<Playlist> GetPlaylists()
    + Playlist? GetPlaylistByUrl(string url)
    + void UpdateCustomTitle(CustomTitle title, string name, string url, string info, string path)
    + void UpdateCustomTitleByUrl(string url, string name, string newUrl, string info, string path)
    + void UpdateInfoTitle(InfoTitle title, string name, string url, string info, Artist artist, string description, Genre genre)
    + void UpdateInfoTitleByName(string url, string name, string newUrl, string info, Artist artist, string description, Genre genre)
    + void UpdateInfoTitleByArtistName(InfoTitle title, string name, string url, string info, string artist, string description, Genre genre)
    + void UpdateInfoTitleByNameByArtistName(string url, string name, string newUrl, string info, string artist, string description, Genre genre)
    + void UpdateAlbum(Album album, string name, string url, Artist artist, string description, string info)
    + void UpdateAlbumByUrl(string url, string name, string newUrl, Artist artist, string description, string info)
    + void UpdateAlbumByArtistName(Album album, string name, string url, string artist, string description, string info)
    + void UpdateAlbumByUrlByArtistName(string url, string name, string newUrl, string artist, string description, string info)
    + void UpdatePlaylist(Playlist playlist, string name, string description, string url)
    + void UpdatePlaylistByUrl(string url, string name, string description, string newUrl)
    + void UpdateArtist(Artist artist, string name)
    + void UpdateArtistByName(string name, string newName)
    + void RemoveAlbum(Album album)
    + void RemoveAlbums(List<Album> albumsList)
    + void RemoveArtist(Artist artist)
    + void RemoveArtists(List<Artist> artistsList)
    + void RemovePlaylist(Playlist playlist)
    + void RemovePlaylists(List<Playlist> playlistsList)
    + void RemoveCustomTitle(CustomTitle title)
    + void RemoveCustomTitles(List<CustomTitle> customTitlesList)
    + void RemoveInfoTitle(InfoTitle title)
    + void RemoveInfoTitles(List<InfoTitle> infoTitlesList)
    + void LoadSerialization()
    + void SaveSerialization()
    + boolean ExistsPlaylist(Playlist playlist)
    + boolean ExistsPlaylistByUrl(string url)
    + boolean ExistsAlbum(Album album)
    + boolean ExistsAlbumByUrl(string url)
    + boolean ExistsArtist(Artist artist)
    + boolean ExistsArtistByName(string name)
    + boolean ExistsCustomTitle(CustomTitle title)
    + boolean ExistsCustomTitleByUrl(string url)
    + boolean ExistsInfoTitle(InfoTitle title)
    + boolean ExistsInfoTitleByUrl(string url)
}

class Manager {
    + {static} int MAX_NAME_LENGTH = 75
    + {static} int MAX_DESCRIPTION_LENGTH = 500
    + {static} string DEFAULT_NAME = "Unknown"
    + {static} string DEFAULT_URL = "none.png"
    + {static} string DEFAULT_DESC = ""
    - List<Album> albums
    - List<CustomTitle> customTitles
    - List<InfoTitle> infoTitles
    - List<Playlist> playlists
    - List<Artist> artists
    + Manager(IDataManager dataManager)
    + void AddAlbum(Album album)
    + void AddCustomTitle(CustomTitle title)
    + void AddInfoTitle(InfoTitle title)
    + void AddPlaylist(Playlist playlist)
    + void AddArtist(Artist artist)
    + void RemoveAlbum(Album album)
    + void RemoveCustomTitle(CustomTitle title)
    + void RemoveInfoTitle(InfoTitle title)
    + void RemovePlaylist(Playlist playlist)
    + IEnumerable<Playlist> GetPlaylists()
    + IEnumerable<Album> GetAlbums()
    + IEnumerable<CustomTitle> GetCustomTitles()
    + IEnumerable<InfoTitle> GetInfoTitles()
    + IEnumerable<Artist> GetArtists()
    + void LoadSerialization()
    + void SaveSerialization()

}

class StubAlbum {
    + StubAlbum()
    + List<Album> GetAlbums()
    + Album? GetAlbumByUrl(string url)
    + void AddAlbum(Album album)
    + void RemoveAlbum(Album album)

}

class StubArtist {
    + StubArtist()
    + List<Artist> GetArtists()
    + Artist? GetArtistByName(string name)
    + void AddArtist(Artist artist)
    + void RemoveArtist(Artist artist)

}

class StubCustomTitle {
    + StubCustomTitle()
    + List<CustomTitle> GetCustomTitles()
    + List<CustomTitle> GetCustomTitlesByUrl(List<string> urls)
    + void AddCustomTitle(CustomTitle customTitle)
    + void RemoveCustomTitle(CustomTitle customTitle)

}

class StubInfoTitle {
    + StubInfoTitle()
    + List<InfoTitle> GetInfoTitles()
    + List<InfoTitle> GetInfoTitlesByUrl(List<string> urls)
    + void AddInfoTitle(InfoTitle title)
    + void RemoveInfoTitle(InfoTitle title)
    + {static} void AddFeat(InfoTitle infoTitle, Artist artist)
    + {static} void RemoveFeat(InfoTitle infoTitle, Artist artist)

}

class StubPlaylist {
    + StubPlaylist()
    + List<Playlist> GetPlaylists()
    + Playlist? GetPlaylistByUrl(string url)
    + void AddPlaylist(Playlist playlist)
    + void RemovePlaylist(Playlist playlist)

}

class StubManager {
    + StubManager()
    + List<Album> GetAlbums()
    + List<Artist> GetArtists()
    + List<Playlist> GetPlaylists()
    + List<CustomTitle> GetCustomTitles()
    + List<InfoTitle> GetInfoTitles()
    + void AddAlbum(Album album)
    + void AddCustomTitle(CustomTitle title)
    + void AddInfoTitle(InfoTitle title)
    + {static} void AddFeat(InfoTitle infoTitle, Artist artist)
    + void AddPlaylist(Playlist playlist)
    + void AddArtist(Artist artist)
    + void RemoveAlbum(Album album)
    + void RemoveCustomTitle(CustomTitle title)
    + void RemoveInfoTitle(InfoTitle title)
    + void RemovePlaylist(Playlist playlist)
    + void RemoveArtist(Artist artist)
    + void LoadSerialization()
    + void SaveSerialization()
    + CustomTitle? GetCustomTitleByUrl(string custom)
    + InfoTitle? GetInfoTitleByUrl(string url)
    + Album? GetAlbumByUrl(string url)
    + Artist? GetArtistByName(string name)
    + void AddAlbums(List<Album> albumsList)
    + void AddArtists(List<Artist> artistsList)
    + void AddPlaylists(List<Playlist> playlistsList)
    + void AddCustomTitles(List<CustomTitle> customTitlesList)
    + void AddInfoTitles(List<InfoTitle> infoTitlesList)
    + Playlist? GetPlaylistByUrl(string url)
    + void UpdateCustomTitle(CustomTitle title, string name, string url, string info, string path)
    + void UpdateCustomTitleByUrl(string url, string name, string newUrl, string info, string path)
    + void UpdateInfoTitle(InfoTitle title, string name, string url, string info, Artist artist, string description, Genre genre)
    + void UpdateInfoTitleByName(string url, string name, string newUrl, string info, Artist artist, string description, Genre genre)
    + void UpdateInfoTitleByArtistName(InfoTitle title, string name, string url, string info, string artist, string description, Genre genre)
    + void UpdateInfoTitleByNameByArtistName(string url, string name, string newUrl, string info, string artist, string description, Genre genre)
    + void UpdateAlbum(Album album, string name, string url, Artist artist, string description, string info)
    + void UpdateAlbumByUrl(string url, string name, string newUrl, Artist artist, string description, string info)
    + void UpdateAlbumByArtistName(Album album, string name, string url, string artist, string description, string info)
    + void UpdateAlbumByUrlByArtistName(string url, string name, string newUrl, string artist, string description, string info)
    + void UpdatePlaylist(Playlist playlist, string name, string description, string url)
    + void UpdatePlaylistByUrl(string url, string name, string description, string newUrl)
    + void UpdateArtist(Artist artist, string name)
    + void UpdateArtistByName(string name, string newName)
    + void RemoveAlbums(List<Album> albumsList)
    + void RemoveArtists(List<Artist> artistsList)
    + void RemovePlaylists(List<Playlist> playlistsList)
    + void RemoveCustomTitles(List<CustomTitle> customTitlesList)
    + void RemoveInfoTitles(List<InfoTitle> infoTitlesList)
    + boolean ExistsPlaylist(Playlist playlist)
    + boolean ExistsPlaylistByUrl(string url)
    + boolean ExistsAlbum(Album album)
    + boolean ExistsAlbumByUrl(string url)
    + boolean ExistsArtist(Artist artist)
    + boolean ExistsArtistByName(string name)
    + boolean ExistsCustomTitle(CustomTitle title)
    + boolean ExistsCustomTitleByUrl(string url)
    + boolean ExistsInfoTitle(InfoTitle title)
    + boolean ExistsInfoTitleByUrl(string url)

}

class LinqXmlSerialization {
    - {static} string XMLPATH
    - {static} string XMLFILEPLAYLISTS
    - {static} string XMLFILEALBUMS
    - {static} string XMLFILECUSTOMS
    - {static} string XMLFILEINFOS
    - {static} string XMLFILEARTISTS
    + LinqXmlSerialization()
    + void AddAlbum(Album album)
    + void AddArtist(Artist artist)
    + void AddCustomTitle(CustomTitle title)
    + void AddInfoTitle(InfoTitle title)
    + void AddPlaylist(Playlist playlist)
    + List<Album> GetAlbums()
    + List<Artist> GetArtists()
    + List<CustomTitle> GetCustomTitles()
    + List<InfoTitle> GetInfoTitles()
    + List<Playlist> GetPlaylists()
    + void RemoveAlbum(Album album)
    + void RemoveArtist(Artist artist)
    + void RemoveCustomTitle(CustomTitle title)
    + void RemoveInfoTitle(InfoTitle title)
    + void RemovePlaylist(Playlist playlist)
    + void LoadSerialization()
    + void SaveSerialization()
    + void LoadPlaylists()
    + void SavePlaylists()
    + void LoadArtists()
    + void SaveArtists()
    + void LoadCustomTitles()
    + void SaveCustomTitles()
    + void LoadAlbums()
    + void SaveAlbums()
    + void LoadInfoTitles()
    + void SaveInfoTitles()
    + {static} Genre GetGenreByName(string genre)
    + InfoTitle? GetInfoTitleByUrl(string url)
    + Artist? GetArtistByName(string name)
    + Album? GetAlbumByUrl(string url)
    + CustomTitle? GetCustomTitleByUrl(string custom)
    + void AddAlbums(List<Album> albumsList)
    + void AddArtists(List<Artist> artistsList)
    + void AddPlaylists(List<Playlist> playlistsList)
    + void AddCustomTitles(List<CustomTitle> customTitlesList)
    + void AddInfoTitles(List<InfoTitle> infoTitlesList)
    + Playlist? GetPlaylistByUrl(string url)
    + void UpdateCustomTitle(CustomTitle title, string name, string url, string info, string path)
    + void UpdateCustomTitleByUrl(string url, string name, string newUrl, string info, string path)
    + void UpdateInfoTitle(InfoTitle title, string name, string url, string info, Artist artist, string description, Genre genre)
    + void UpdateInfoTitleByName(string url, string name, string newUrl, string info, Artist artist, string description, Genre genre)
    + void UpdateInfoTitleByArtistName(InfoTitle title, string name, string url, string info, string artist, string description, Genre genre)
    + void UpdateInfoTitleByNameByArtistName(string url, string name, string newUrl, string info, string artist, string description, Genre genre)
    + void UpdateAlbum(Album album, string name, string url, Artist artist, string description, string info)
    + void UpdateAlbumByUrl(string url, string name, string newUrl, Artist artist, string description, string info)
    + void UpdateAlbumByArtistName(Album album, string name, string url, string artist, string description, string info)
    + void UpdateAlbumByUrlByArtistName(string url, string name, string newUrl, string artist, string description, string info)
    + void UpdatePlaylist(Playlist playlist, string name, string description, string url)
    + void UpdatePlaylistByUrl(string url, string name, string description, string newUrl)
    + void UpdateArtist(Artist artist, string name)
    + void UpdateArtistByName(string name, string newName)
    + void RemoveAlbums(List<Album> albumsList)
    + void RemoveArtists(List<Artist> artistsList)
    + void RemovePlaylists(List<Playlist> playlistsList)
    + void RemoveCustomTitles(List<CustomTitle> customTitlesList)
    + void RemoveInfoTitles(List<InfoTitle> infoTitlesList)
    + boolean ExistsPlaylist(Playlist playlist)
    + boolean ExistsPlaylistByUrl(string url)
    + boolean ExistsAlbum(Album album)
    + boolean ExistsAlbumByUrl(string url)
    + boolean ExistsArtist(Artist artist)
    + boolean ExistsArtistByName(string name)
    + boolean ExistsCustomTitle(CustomTitle title)
    + boolean ExistsCustomTitleByUrl(string url)
    + boolean ExistsInfoTitle(InfoTitle title)
    + boolean ExistsInfoTitleByUrl(string url)
}

Album o-- "+ artist" Artist
Album o-- "- titles*" Title
Playlist o-- "- titles*" Title
CustomTitle <|-- Title
InfoTitle <|-- Title
InfoTitle o-- "+ genre" Genre
InfoTitle o-- "+ artist" Artist
Manager *-- "+ datamanager" IDataManager
StubArtist *-- "- artists*" Artist
StubAlbum *-- "- stubArtist" StubArtist
StubAlbum *-- "- albums*" Album
StubCustomTitle *-- "- customTitles*" CustomTitle
StubInfoTitle *-- "- stubArtist" StubArtist
StubInfoTitle *-- "- infoTitles*" InfoTitle
StubPlaylist *-- "- playlists*" Playlist
StubManager <|-- IDataManager
StubManager *-- "- stubArtist" StubArtist
StubManager *-- "- stubPlaylist" StubPlaylist
StubManager *-- "- stubAlbum" StubAlbum
StubManager *-- "- stubInfoTitle" StubInfoTitle
StubManager *-- "- stubCustomTitle" StubCustomTitle
LinqXmlSerialization <|-- IDataManager
LinqXmlSerialization o-- "- artists*" Artist
LinqXmlSerialization o-- "- albums*" Album
LinqXmlSerialization o-- "- playlists*" Playlist
LinqXmlSerialization o-- "- infotitles*" InfoTitle
LinqXmlSerialization o-- "- customtitles*" CustomTitle
@enduml
```

### Explications

#### Album

Cette classe sert à modéliser des albums de musique. Ils ne sont pas jouables et sont uniquement implantés à titre informatif. Dans ce but, elle comporte plusieurs attributs comme un nom, une description, des informations complémentaires
ou encore une URL pour son image (la pochette).


#### Artist

Cette classe sert à modéliser les artistes qui réalise les albums. Il ne possède qu'un nom en atrribut.

#### Title

Cette classe sert à modé+liser différents titres. Il possède plusieurs attributs comme un nom, une URL pour son image (cover) ainsi que des informations complémentaires.


#### InfoTitle

Cette classe hérite de **Title**. Elle hérite donc de tout ses attributs. Comme son nom l'indique, ces titres ont comme spécificité d'être uniquement informatif. Ils sont contenus dans les albums. Elle possède également d'autres attributs comme
une description, un artiste (classe **Artist**) et une liste d'artiste pour les featuring.

#### CustomTitle

Cette classe hérite de **Title**. Elle hérite donc de tout ses attributs. Ces titres sont destinés à pouvoir être ajouter dans des playlists et à être jouer.
Hormis les attributs hérités, cette classe possède un attribut path (chemin) qui lui permet d'indiquer où se situe le fichier audio.


#### Playlist

Cette classe possède une structure similaire à la classe **Album**. Elle contient des titres personnalisés (**CustomTitle**). Les morceaux sont joués dans un ordre
précis (du premier jusqu'au dernier).


#### LinqXmlSerialization

Notre sérialisation fonctionne avec lecture/écriture dans des fichiers XML. Pour cela, nous utilisons la bibliothèque *LINQ_XML* qui nous permet de créer et de modifier les différents fichiers.


## Diagramme de paquetage

![DP](Images/Diagramme_paquetage.png)

### Explications

Notre projet est un projet MAUI se nommant **Linaris**. Une erreur a été effectuée lors de la conception, ce qui fait que nos vues
portent le même nom. Pour les différencier, le paquet *Linaris* qui concerne les vues sera écrit en italique.

#### Model

Le paquet **Model** est une bibliothèque de classes C#. Certaines se trouvent à la racine de celle-ci. D'autres se trouvent dans des sous-dossiers
comme la sérialisation (**Serialization**) ou encore les stubs (**Stub**).

La **sérialisation** a besoin du **stub** pour pouvoir stocker et charger les informations présentes dans les différents fichiers de sauvergarde.

#### Linaris

Ce paquet contient nos différentes vues codées en C#/XAML.
Nos vues (*Linaris*) ont besoin de Model afin d'effectuer le data-binding pour que notre application ne soit pas uniquement graphique.

#### Console

Ce paquet contient une application console C#.
Pour effectuer différents test fonctionnels sur nos différentes classes du modèle, l'application console (**Console**) a besoin de celui-ci.

#### TestUnitaires

Ce paquet contient les tests unitaires de nos différentes classes. Il utilise *xUnit* pour les réaliser.
Pour effectuer ceux-ci, le paquet correspondant (**TestUnitaires**) dépend du modèle.


## Diagramme de séquence

### LoadSerialization()


```plantuml
@startuml
autonumber
actor       Utilisateur    as user
participant  Front   as   vues
participant  Serialization   as   seria
participant  Files   as   files
collections Collections as lists
group LoadSerialization [On Start]
    user -> vues : Démarre l'application
    vues -> seria : Appelle la fonction de chargement
    seria -> files : Récupère les données des fichiers
    seria -> lists : Demande les données dans les collections
    seria <-- lists : Retourne les données
    vues <-- seria : Données utilisables par les vues
end
@enduml
```




