Package com.bugyal.imentor.server.data

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


    Location location = new Location(o.getLatitude(), o.getLongitude(), o
        .getLocString(), o.getRadius());
    Opportunity oi = null;
    List<Participant> contacts = new ArrayList<Participant>();

    Participant participant = null;
    try {
      participant = pm.findParticipantByEmail(getUserId());
      if (participant != null) {
        contacts.add(participant);
      }
    } catch (MentorException e) {
      e.printStackTrace();
    }

    // TODO(raman): Understand why MentorException is not getting thrown.
    oi = om.createOpportunity(location, o.getSubjects(), o
        .getRequiredMentors(), contacts, o.getPriority(), o
        .getMessage(), participant);

    if (oi != null) {
      try {
        participant.addCreatedOpportuny(oi.getKey());
        pm.saveOpportunityToParticipant(participant.getKey(), oi
            .getKey(), false); // here false is to indicate it is
        // new opportunity
      } catch (Exception e) {
        e.printStackTrace();
      }
View Full Code Here


  public ParticipantVO update(ParticipantVO p) throws MeException {
    if (p.getId() == null) {
      throw new MeException("New participant, cannot update.");
    }

    Participant pi = null;
    Key key = KeyFactory.createKey(Participant.class.getSimpleName(), p
        .getId());

    try {
      pi = pm.findById(key);
View Full Code Here

  @Override
  public SearchResponse filterList(double latitude, double longitude,
      String strlocation, int radius, List<String> hasSubs,
      List<String> needSubs) {
    SearchResponse response = new SearchResponse();
    Participant pi;
    Point pt = new Point(latitude, longitude);
    try {
      Set<String> hasSubjects = new HashSet<String>();
      Set<String> needSubjects = new HashSet<String>();

      for (String s : hasSubs) {
        hasSubjects.add(s);
      }
      for (String s : needSubs) {
        needSubjects.add(s);
      }

      List<SearchResult> has = new ArrayList<SearchResult>();
      List<SearchResult> need = new ArrayList<SearchResult>();

      Location location = new Location(latitude, longitude, strlocation,
          radius);
      long temp = System.currentTimeMillis();
      List<Participant> participants = pm.searchParticipantsBySubjects(
          needSubs, location, true);
      pi= pm.findParticipantByEmail(getUserId());
      LOG.info("For TOME searchParticipantsBySubjects(needSubs,location, true) "
              + (System.currentTimeMillis() - temp));

      for (Participant p : participants) {
        List<String> matchingSubs = new ArrayList<String>();
        for (String s : p.getHasSubjects()) {
          if (needSubjects.contains(s)) {
            matchingSubs.add(s);
          }
        }
        has.add(new SearchResult(ValueObjectGenerator.create(p), true,
            matchingSubs, GeocellUtils
                .distance(pt, p.getLocation())));
      }
      temp = System.currentTimeMillis();
      participants = pm.searchParticipantsBySubjects(hasSubs, location,
          false);
      LOG.info("For TOME searchParticipantsBySubjects(hasSubs, location, false) "
              + (System.currentTimeMillis() - temp));

      for (Participant p : participants) {
        List<String> matchingSubs = new ArrayList<String>();
        for (String s : p.getNeedSubjects()) {
          if (hasSubjects.contains(s)) {
            matchingSubs.add(s);
          }
        }
        need.add(new SearchResult(ValueObjectGenerator.create(p),
            false, matchingSubs, GeocellUtils.distance(pt, p
                .getLocation())));
      }
      temp = System.currentTimeMillis();
      List<Opportunity> opportunities = om.searchOpportunities(location,
          hasSubs);
      LOG.info("For TOME searchOpportunities(location, hasSubs) "
          + (System.currentTimeMillis() - temp));

      for (Opportunity o : opportunities) {

        List<String> matchingSubs = new ArrayList<String>();
        for (String s : o.getSubjects()) {
          if (hasSubjects.contains(s)) {
            matchingSubs.add(s);
          }
        }
        need.add(new SearchResult(ValueObjectGenerator.create(o),
            matchingSubs, GeocellUtils
                .distance(pt, o.getLocation())));
      }
           
      for(SearchResult s: need) {
        if(s.isTypeParticipant()) {
          if(s.getP().getEmail().equals(pi.getEmail())) {
            need.remove(s);
          }
        }
      }
      for(SearchResult s: has) {
        if(s.getP().getEmail().equals(pi.getEmail())) {
          has.remove(s);         
        }
      }
      response.setHas(has);
      response.setNeed(need);
View Full Code Here

      List<String> hasSubjects = getRandomList();
      List<String> needSubjects = getRandomList();

      ParticipantManager participantManager = MentorManager.INSTANCE
          .getParticipantManager();
      Participant participant = participantManager.createParticipant(
          name, gender, getRandomLocation(), email, "100002992300278");

      participantManager.addHasKnowledge(participant, hasSubjects, 1,
          participant);
      participantManager.addNeedKnowledge(participant, needSubjects, 1,
          participant);

      if (r.nextFloat() < 0.1) {
        List<Participant> contacts = new ArrayList<Participant>();
        contacts.add(participant);
        Opportunity o = MentorManager.INSTANCE.getOpportunityManager()
            .createOpportunity(getRandomLocation(),
                getRandomList(), r.nextInt(7), contacts,
                r.nextInt(4), rs.nextString(), participant);
        for (int loc = 0; loc < o.getContacts().size(); loc++) {
          Participant p = MentorManager.INSTANCE
              .getParticipantManager().findById(
                  o.getContacts().get(loc));
          p.addCreatedOpportuny(o.getKey());
          MentorManager.INSTANCE.getParticipantManager().save(p);
        }
      }

    }
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.