Subversion Repositories eFlore/Applications.del

Rev

Rev 1127 | Rev 1832 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

package org.tela_botanica.del.client.utils;

import java.util.Comparator;

import org.tela_botanica.del.client.modeles.InterventionForum;
import org.tela_botanica.del.client.modeles.MoyenneVote;
import org.tela_botanica.del.client.modeles.PropositionDetermination;
import org.tela_botanica.del.client.services.CalculVoteDeterminationService;

import com.google.gwt.user.client.Window;

public class ComparateurPropositionDetermination implements Comparator<InterventionForum> {

        @Override
        public int compare(InterventionForum intervention1, InterventionForum intervention2) {
                int entierRetour = 0;
                
                if (intervention1 instanceof PropositionDetermination && intervention2 instanceof PropositionDetermination) {
                        
                        PropositionDetermination proposition1 = (PropositionDetermination) intervention1;
                        PropositionDetermination proposition2 = (PropositionDetermination) intervention2;
                        
                        // si 1 est prop et 2 est prop
                        MoyenneVote moyenneP1 = CalculVoteDeterminationService.calculerVoteDetermination(proposition1);
                        int scoreP1 = moyenneP1.getScore();
                        
                        MoyenneVote moyenneP2 = CalculVoteDeterminationService.calculerVoteDetermination(proposition2);
                        int scoreP2 = moyenneP2.getScore();
                        
                        
                        if (scoreP1 < scoreP2) {
                                entierRetour = 1;
                        }
                } else {
                        entierRetour = 1;
                }
                //si 1 est prop et 2 est comm OU si 1 est comm et 2 est prop ou les 2 sont comm
                return entierRetour;
        }

}