Package com.bugyal.imentor.server.data

Examples of com.bugyal.imentor.server.data.Participant


    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) {
View Full Code Here


  @Override
  public boolean deleteOpportunity(long id) {
    Key key = KeyFactory.createKey(Opportunity.class.getSimpleName(), id);
    if (om.deleteOpportunity(key)) {
      try {
        Participant pi = pm.findParticipantByEmail(getUserId());
        return pm.deleteOpportuniryFromParticipant(pi.getKey(), key);
      } catch (MentorException e) {
        e.printStackTrace();
      }
    }
    return false;
View Full Code Here

  @Override
  public boolean removeMentorForOpportunity(long id) {
    Key opportunityKey = KeyFactory.createKey(Opportunity.class
        .getSimpleName(), id);
    Participant mentor = null;
    try {
      mentor = pm.findParticipantByEmail(getUserId());
      if (om.removeMentorFromOpportunity(opportunityKey, mentor.getKey())) {
        mentor.removeMentoringOpportunity(opportunityKey);
        pm.save(mentor);
        return true;
      }
    } catch (MentorException e) {
      e.printStackTrace();
View Full Code Here

  @Override
  public boolean addMentorToOpportunity(long id) {
    Key opportunityKey = KeyFactory.createKey(Opportunity.class
        .getSimpleName(), id);
    Participant mentor = null;
    try {
      mentor = pm.findParticipantByEmail(getUserId());
      if (om.addMentorToOpportunity(opportunityKey, mentor.getKey())) {
        return pm.saveOpportunityToParticipant(mentor.getKey(),
            opportunityKey, true);
      }
    } catch (MentorException e) {
      e.printStackTrace();
    }
View Full Code Here

      boolean isMentor = true; // for mentors
      Key key = KeyFactory.createKey(Opportunity.class.getSimpleName(),
          id);
      MentorsResult mentor = new MentorsResult();

      Participant user = pm.findParticipantByEmail(getUserId());
      Opportunity o = om.findById(key);

      if (o.getMentors().contains(user.getKey())) {
        isExisted = true;
      } else {
        isExisted = false;
      }
View Full Code Here

  }

  @Override
  public List<SearchResult> getMyMentors() {
    try {
      Participant p = pm.findParticipantByEmail(getUserId());
      List<SearchResult> result = new ArrayList<SearchResult>();
      List<Participant> participants = new ArrayList<Participant>();
      if (p.getMentors().size() != 0) {
        participants = pm.getMentors(p);
        for (Participant pi : participants) {
          result.add(new SearchResult(
              ValueObjectGenerator.create(pi), true, pi
                  .getHasSubjects(), 0));
View Full Code Here

  }

  @Override
  public List<SearchResult> getMyMentees() {
    try {
      Participant p = pm.findParticipantByEmail(getUserId());
      List<SearchResult> result = new ArrayList<SearchResult>();
      List<Participant> participants = new ArrayList<Participant>();

      if (p.getMentees().size() != 0) {
        participants = pm.getMentees(p);
        for (Participant pi : participants) {
          result.add(new SearchResult(
              ValueObjectGenerator.create(pi), false, pi
                  .getNeedSubjects(), 0));
        }
      }
      if (p.getMentoringOpportunities().size() != 0) {
        for (Key key : p.getMentoringOpportunities()) {
          Opportunity o = om.findById(key);
          result.add(new SearchResult(ValueObjectGenerator.create(o),
              o.getSubjects(), 0));
        }
      }
View Full Code Here

  @Override
  public List<OpportunityVO> find(List<String> subjects, ParticipantVO me)
      throws IllegalArgumentException {
    Key key = KeyFactory.createKey(Participant.class.getSimpleName(), me
        .getId());
    Participant p = pm.findById(key);

    List<OpportunityVO> rList = new ArrayList<OpportunityVO>();

    List<Opportunity> oList = null;
    if (subjects != null) {
View Full Code Here

      throw new MeException("Cannot create already created participant");
    }

    Location location = new Location(p.getLatitude(), p.getLongitude(), p
        .getLocationString(), p.getRadius());
    Participant pi = null;
    try {
      pi = pm.createParticipant(p.getName(), p.getGender(), location, p
          .getEmail(), p.getFacebookId());
      pm.addHasKnowledge(pi, p.getHasSubjects(), 1, pi);
      pm.addNeedKnowledge(pi, p.getNeedSubjects(), 1, pi);
View Full Code Here

  private void save(Opportunity oi, OpportunityVO o) throws MentorException {
    Location location = new Location(o.getLatitude(), o.getLongitude(), o
        .getLocString(), o.getRadius());
    oi.setLocation(location);
    Participant savedBy = pm.findParticipantByEmail(getUserId());

    if (o.getSubjects() != null) {
      oi.resetSubjects(o.getSubjects(), savedBy);
    }
View Full Code Here

TOP

Related Classes of com.bugyal.imentor.server.data.Participant

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.