public String getMemberStatusByUserName(String memberUserName) {
return memberDao.getMemberStatusByUserName(memberUserName);
}
public StatisticsVO getAllStatistics(){
StatisticsVO stats = new StatisticsVO();
List<MemberVO> members = memberDao.getAllStatistics();
Map<String, Integer> dormitoryMap = new TreeMap<String, Integer>();
Map<String, Integer> countryMap = new TreeMap<String, Integer>();
Map<String, Integer> emailMap = new TreeMap<String, Integer>();
int maleCount = 0;//
int femaleCount = 0;//
int unknownGenderCount = 0;
int deactivatedAccountCount = 0;//
int deletedAccountCount = 0;//
int lockedAccountCount = 0;//
int totalCount = 0;//
int newMembers = 0;//
int noEmailCount = 0;//
for (MemberVO mem : members){
// Gender
if (mem.getGender().equalsIgnoreCase(BaseConstants.GENDER_MALE)){
maleCount++;
}
else if (mem.getGender().equalsIgnoreCase(BaseConstants.GENDER_FEMALE)){
femaleCount++;
}
else if (mem.getGender().equalsIgnoreCase(BaseConstants.GENDER_UNKNOWN)){
unknownGenderCount++;
}
// Country
String key = mem.getCountryLabel();
if (key != null && key.length() > 0){
if (!countryMap.containsKey(key)){
countryMap.put(key, 1);
}
else{
int currNumber = countryMap.get(key);
countryMap.remove(key);
countryMap.put(key, currNumber+1);
}
}
// Dormitory
String key1 = mem.getDormitoryLabel();
if (key1 != null && key1.length() > 0){
if (!dormitoryMap.containsKey(key1)){
dormitoryMap.put(key1, 1);
}
else{
int currNumber = dormitoryMap.get(key1);
dormitoryMap.remove(key1);
dormitoryMap.put(key1, currNumber+1);
}
}
// Email
String email = mem.getEmail();
String key2 = null;
String[] emailArray = null;
if (email != null && email.length() > 1){
emailArray = email.split("@");
key2 = emailArray[1].toLowerCase();
}
if (key2 != null && key2.length() > 0){
if (!emailMap.containsKey(key2)){
emailMap.put(key2, 1);
}
else{
int currNumber = emailMap.get(key2);
emailMap.remove(key2);
emailMap.put(key2, currNumber+1);
}
}
// Status
if (mem.getMemberStatus().equalsIgnoreCase(BaseConstants.ACCOUNT_DEACTIVATED)){
deactivatedAccountCount++;
}
else if (mem.getMemberStatus().equalsIgnoreCase(BaseConstants.ACCOUNT_LOCKED)){
lockedAccountCount++;
}
else if(mem.getMemberStatus().equalsIgnoreCase(BaseConstants.ACCOUNT_UNAPPROVED)){
newMembers++;
}
else if(mem.getMemberStatus().equalsIgnoreCase(BaseConstants.ACCOUNT_DELETED)){
deletedAccountCount++;
}
// no email
if (mem.getEmail() == null || mem.getEmail().equalsIgnoreCase("")){
noEmailCount++;
}
totalCount++;
}
stats.setEmailMap(emailMap);
stats.setMaleCount(maleCount);
stats.setFemaleCount(femaleCount);
stats.setUnknownGenderCount(unknownGenderCount);
stats.setDormitoryMap(dormitoryMap);
stats.setCountryMap(countryMap);
stats.setTotalCount(totalCount);
stats.setLockedAccountCount(lockedAccountCount);
stats.setDeactivatedAccountCount(deactivatedAccountCount);
stats.setNewMembers(newMembers);
stats.setNoEmailCount(noEmailCount);
stats.setDeletedAccountCount(deletedAccountCount);
return stats;
}