1127 |
gduche |
1 |
package org.tela_botanica.del.client.utils;
|
|
|
2 |
|
|
|
3 |
import java.util.Comparator;
|
|
|
4 |
|
1128 |
gduche |
5 |
import org.tela_botanica.del.client.modeles.InterventionForum;
|
1127 |
gduche |
6 |
import org.tela_botanica.del.client.modeles.MoyenneVote;
|
|
|
7 |
import org.tela_botanica.del.client.modeles.PropositionDetermination;
|
|
|
8 |
import org.tela_botanica.del.client.services.CalculVoteDeterminationService;
|
|
|
9 |
|
1128 |
gduche |
10 |
import com.google.gwt.user.client.Window;
|
1127 |
gduche |
11 |
|
1128 |
gduche |
12 |
public class ComparateurPropositionDetermination implements Comparator<InterventionForum> {
|
|
|
13 |
|
1127 |
gduche |
14 |
@Override
|
1128 |
gduche |
15 |
public int compare(InterventionForum intervention1, InterventionForum intervention2) {
|
|
|
16 |
int entierRetour = 0;
|
1127 |
gduche |
17 |
|
1128 |
gduche |
18 |
if (intervention1 instanceof PropositionDetermination && intervention2 instanceof PropositionDetermination) {
|
|
|
19 |
|
|
|
20 |
PropositionDetermination proposition1 = (PropositionDetermination) intervention1;
|
|
|
21 |
PropositionDetermination proposition2 = (PropositionDetermination) intervention2;
|
|
|
22 |
|
|
|
23 |
// si 1 est prop et 2 est prop
|
|
|
24 |
MoyenneVote moyenneP1 = CalculVoteDeterminationService.calculerVoteDetermination(proposition1);
|
|
|
25 |
int scoreP1 = moyenneP1.getScore();
|
|
|
26 |
|
|
|
27 |
MoyenneVote moyenneP2 = CalculVoteDeterminationService.calculerVoteDetermination(proposition2);
|
|
|
28 |
int scoreP2 = moyenneP2.getScore();
|
|
|
29 |
|
|
|
30 |
|
|
|
31 |
if (scoreP1 < scoreP2) {
|
|
|
32 |
entierRetour = 1;
|
|
|
33 |
}
|
|
|
34 |
} else {
|
1127 |
gduche |
35 |
entierRetour = 1;
|
|
|
36 |
}
|
1128 |
gduche |
37 |
//si 1 est prop et 2 est comm OU si 1 est comm et 2 est prop ou les 2 sont comm
|
1127 |
gduche |
38 |
return entierRetour;
|
|
|
39 |
}
|
|
|
40 |
|
|
|
41 |
}
|