diff --git a/Workspace/server/src/main/WEB-INF/classes/com/pqt/server/module/client/ClientEntry.java b/Workspace/server/src/main/WEB-INF/classes/com/pqt/server/module/client/ClientEntry.java new file mode 100644 index 00000000..2f577782 --- /dev/null +++ b/Workspace/server/src/main/WEB-INF/classes/com/pqt/server/module/client/ClientEntry.java @@ -0,0 +1,58 @@ +package com.pqt.server.module.client; + +import com.pqt.core.entities.members.Client; + +import java.util.Date; + +public class ClientEntry { + private Client client; + private Date timestamp; + + public ClientEntry(Client client) { + this.client = client; + timestamp = new Date(); + } + + public ClientEntry(Client client, Date timestamp) { + this.client = client; + this.timestamp = timestamp; + } + + public Client getClient() { + return client; + } + + public void setClient(Client client) { + this.client = client; + } + + public Date getTimestamp() { + return timestamp; + } + + public void setTimestamp(Date timestamp) { + this.timestamp = timestamp; + } + + public boolean check(Client client){ + return this.client.equals(client); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + ClientEntry that = (ClientEntry) o; + + if (client != null ? !client.equals(that.client) : that.client != null) return false; + return timestamp != null ? timestamp.equals(that.timestamp) : that.timestamp == null; + } + + @Override + public int hashCode() { + int result = client != null ? client.hashCode() : 0; + result = 31 * result + (timestamp != null ? timestamp.hashCode() : 0); + return result; + } +} diff --git a/Workspace/server/src/main/WEB-INF/classes/com/pqt/server/module/client/ClientService.java b/Workspace/server/src/main/WEB-INF/classes/com/pqt/server/module/client/ClientService.java index 94665ef1..26a03396 100644 --- a/Workspace/server/src/main/WEB-INF/classes/com/pqt/server/module/client/ClientService.java +++ b/Workspace/server/src/main/WEB-INF/classes/com/pqt/server/module/client/ClientService.java @@ -4,34 +4,88 @@ import com.pqt.core.entities.members.Client; import java.util.Date; import java.util.HashSet; +import java.util.List; import java.util.Set; +import java.util.stream.Collectors; -//TODO écrire javadoc //TODO ajouter logs + +/** + * Cette classe correspond au service de gestion des clients. + *
+ * Un client est une instance du logiciel de composition des commandes, ce dernier étant la principale entitée capable + * d'envoyer des requêtes aux serveurs de données. + * + * Ce service est censé permettre la tracabilité des clients se connectant au serveur, en gardant en cache tous les + * clients avec des horodateurs représentant la date et l'heure de la dernière requête reçue de chaque client. + */ public class ClientService { - private Set