boolean isExisted;
try {
boolean isMentor = true; // for mentors
Key key = KeyFactory.createKey(Participant.class.getSimpleName(),
pi.getId());
Participant user = pm.findParticipantByEmail(getUserId());
Participant m = pm.findById(key);
if (m.getMentors().contains(user.getKey())) {
isExisted = true;
} else if (m.getMentees().contains(user.getKey())) {
isExisted = true;
} else {
isExisted = false;
}
List<Participant> participants = new ArrayList<Participant>();
if (m.getMentors().size() != 0) {
try {
participants = pm.getMentors(m);
} catch(Exception e) {}
for (Participant p : participants) {
MentorsResult mentor = new MentorsResult(p.getName(),
isMentor);
result.add(mentor);
}
participants.clear();
}
if (m.getMentees().size() != 0) {
isMentor = false; // for mentees
try {
participants = pm.getMentees(m);
} catch(Exception e) {}
for (Participant p : participants) {