View Javadoc

1   package net.sf.imca.model;
2   
3   import java.util.Comparator;
4   
5   import net.sf.imca.model.entities.CommitteeMemberEntity;
6   
7   public class CommitteeMemberComparator implements Comparator<CommitteeMemberEntity> {
8   
9       public int compare(CommitteeMemberEntity o1, CommitteeMemberEntity o2) {
10          
11          Integer i1 = getRating(o1.getPositionName());
12          Integer i2 = getRating(o2.getPositionName());
13          
14          return i1.compareTo(i2);
15      }
16      
17      private Integer getRating(String positionName) {
18          
19          if (positionName.toLowerCase().startsWith("pres")) {
20              return 0;
21          }
22          if (positionName.toLowerCase().startsWith("sec")) {
23              return 10;
24          }
25          if (positionName.toLowerCase().startsWith("tre")) {
26              return 20;
27          }
28          if (positionName.toLowerCase().indexOf("represetative") >= 0) {
29              return 60;
30          }
31          if (positionName.toLowerCase().startsWith("web")) {
32              return 70;
33          }
34          if (positionName.toLowerCase().startsWith("con")) {
35              return 90;
36          }
37          return 100;
38      }
39  
40  }