Package com.ikanow.infinit.e.data_model.store.social.person

Examples of com.ikanow.infinit.e.data_model.store.social.person.PersonPojo


    catch (Exception e) {} // fail out and return false
    return false;
  }
  public static Set<ObjectId> getCommunities(ObjectId userId) {
    HashSet<ObjectId> userCommunities = new HashSet<ObjectId>();
    PersonPojo personQuery = new PersonPojo();
    personQuery.set_id(userId);
    PersonPojo person = PersonPojo.fromDb(DbManager.getSocial().getPerson().findOne(personQuery.toDb()), PersonPojo.class);
    if ((null != person) && (null != person.getCommunities())) {
      for (PersonCommunityPojo comm:  person.getCommunities()) {
        userCommunities.add(comm.get_id());
      }
    }
    return userCommunities;
  }//TESTED (CustomSavedQueryTestCode:*)
 
View Full Code Here


   * @return
   * @throws Exception
   */
  public static List<ObjectId> getUserCommunities(ObjectId submitterId) {
    // Set up the query
    PersonPojo personQuery = new PersonPojo();
    personQuery.set_id(submitterId);
   
    BasicDBObject dbo = (BasicDBObject) DbManager.getSocial().getPerson().findOne(personQuery.toDb());
    PersonPojo person = PersonPojo.fromDb(dbo, PersonPojo.class);
   
    if (null == person) {
      throw new RuntimeException("User no longer exists?");
    }
    if ((null == person.getCommunities()) || person.getCommunities().isEmpty()) {
      throw new RuntimeException("Corrupt user, no community access?");
    }
    ArrayList<ObjectId> retVal = new ArrayList<ObjectId>(person.getCommunities().size());
    for (PersonCommunityPojo personInfo: person.getCommunities()) {
      retVal.add(personInfo.get_id());
    }
    return retVal;
  }
View Full Code Here

        try {
          // If here then grab source if I'm allowed
          // a) get my communities:
          if (null == _userCommunities) {
            BasicDBObject personQuery = new BasicDBObject("_id", _callingUserId);
            PersonPojo person = PersonPojo.fromDb(MongoDbManager.getSocial().getPerson().findOne(personQuery), PersonPojo.class);
            if (null == person) {
              addErrMessage("Didn't find user: " + _callingUserId);
              return null;
            }
            _userCommunities = new ArrayList<ObjectId>(person.getCommunities().size());
            for (PersonCommunityPojo personComm: person.getCommunities()) {
              _userCommunities.add(personComm.get_id());
            }
          }//TESTED (by hand)
         
          // b) try getting the source
View Full Code Here

   * @param id
   * @return
   */
  public static PersonPojo getPerson(String id)
  {
    PersonPojo person = null;
   
    try
    {
      // Set up the query
      PersonPojo personQuery = new PersonPojo();
      personQuery.set_id(new ObjectId(id));
     
      BasicDBObject dbo = (BasicDBObject) DbManager.getSocial().getPerson().findOne(personQuery.toDb());
      person = PersonPojo.fromDb(dbo, PersonPojo.class);
    }
    catch (Exception e)
    {
      logger.error("Exception Message: " + e.getMessage(), e);
View Full Code Here

    static public HashSet<ObjectId> getUserCommunities(String userIdStr) {
      return getUserCommunities(userIdStr, null);
    }
   
    static public HashSet<ObjectId> getUserCommunities(String userIdStr, Pattern regex) {
      PersonPojo person = SocialUtils.getPerson(userIdStr);
      HashSet<ObjectId> memberOf = new HashSet<ObjectId>();
      if (null != person) {
        if (null != person.getCommunities()) {
          for (PersonCommunityPojo community: person.getCommunities()) {
            if ((null == regex) || regex.matcher(community.getName()).find()) {
              memberOf.add(community.get_id());
            }
          }
        }
View Full Code Here

  private static boolean emailSourceApprovalRequest(SourcePojo source)
  {
   
   
    // Get Information for Person requesting the new source
    PersonPojo p = SocialUtils.getPerson(source.getOwnerId().toString());
   
    // Get the root URL to prepend to the approve/reject link below
    PropertiesManager propManager = new PropertiesManager();
    String rootUrl = propManager.getUrlRoot();
   
    // Subject Line
    String subject = "Approve/Reject New Source: " + source.getTitle();
   
    // Get array of community IDs and get corresponding CommunityPojo objects
    ArrayList<CommunityPojo> communities = SocialUtils.getCommunities(source.getCommunityIds());
   
    // Iterate over the communities and send an email to each set of owner/moderators requesting
    // that the approve or reject the source
    for (CommunityPojo c : communities)
    {
      // Email address or addresses to send to
      // Extract email addresses for owners and moderators from list of community members
      StringBuffer sendTo = new StringBuffer();
      Set<CommunityMemberPojo> members = c.getMembers();
      CommunityMemberPojo owner = null;
      for (CommunityMemberPojo member : members)
      {
        if (member.getUserType().equalsIgnoreCase("owner") || member.getUserType().equalsIgnoreCase("moderator"))
        {
          owner = member;
          if (sendTo.length() > 0) sendTo.append(";");
          sendTo.append(member.getEmail());
        }
      }
      if (0 == sendTo.length()) {
        throw new RuntimeException("community " + c.getName() + " / " + c.getId() + " has no owner/moderator");
      }
     
      //create a community request and post to db
      CommunityApprovePojo cap = new CommunityApprovePojo();
      cap.set_id(new ObjectId());
      cap.setCommunityId( c.getId().toString() );
      cap.setIssueDate(new Date());
      cap.setPersonId(owner.get_id().toString());
      cap.setRequesterId(p.get_id().toString());
      cap.setType("source");
      cap.setSourceId(source.getId().toString());
      DbManager.getSocial().getCommunityApprove().insert(cap.toDb());   
     
      // Message Body
      String body = "<p>" + p.getDisplayName() + " has requested that the following source be " +
        "added to the " + c.getName() + " community:</p>" +
        "<p>" +
        "Title: " + source.getTitle() + "<br/>" +
        "Description: " + source.getDescription() + "<br/>" +
        "URL (eg): " + source.getRepresentativeUrl() + "<br/>" +
View Full Code Here

   * @return
   */
  private static boolean emailSourceApproval(SourcePojo source, String approverIdStr, String decision)
  {
    // Get Information for Person requesting the new source
    PersonPojo submitter = SocialUtils.getPerson(source.getOwnerId().toString());
   
    // Get Information for Person making approval decision
    PersonPojo approver = SocialUtils.getPerson(approverIdStr);
 
    // Subject Line
    String subject = "Request to add new Source " + source.getTitle() + " was " + decision;

    // Message Body
    String body = "<p>Your request to add the following source:</p>" +
    "<p>" +
    "Title: " + source.getTitle() + "<br/>" +
    "Description: " + source.getDescription() + "<br/>" +
    "URL: " + source.getRepresentativeUrl() + "<br/>" +
    "</p>" +
    "<p>Was <b>" + decision + "</b> by " + approver.getDisplayName() + "</p>";

    // Send
    new SendMail(new PropertiesManager().getAdminEmailAddress(), submitter.getEmail(), subject, body).send("text/html")
    return true;
  }
View Full Code Here

    ResponsePojo rp = new ResponsePojo();
   
    try
    {
      // Set up the query
      PersonPojo personQuery = new PersonPojo();
      try {
        personQuery.set_id(new ObjectId(id));
      }
      catch (Exception e) { // Not an id, try email
        personQuery.setEmail(id);
      }
     
      BasicDBObject dbo = (BasicDBObject) DbManager.getSocial().getPerson().findOne(personQuery.toDb());
      PersonPojo person = PersonPojo.fromDb(dbo, PersonPojo.class);
     
      rp.setData(person, new PersonPojoApiMap());
      rp.setResponse(new ResponseObject("Person Info", true, "Person info returned successfully"))
    }
    catch (Exception e)
View Full Code Here

  public ResponsePojo listPerson(String userId)
  {
    ResponsePojo rp = new ResponsePojo();
    try
    {
      PersonPojo person = SocialUtils.getPerson(userId)
      boolean isAdmin = RESTTools.adminLookup(userId);
      CommunityPojo system_comm = getSystemCommunity();
      List<ObjectId> communityIds = new ArrayList<ObjectId>();
      for ( PersonCommunityPojo community : person.getCommunities())
      {
        ObjectId comm_id = community.get_id();
        if ( allowedToSeeCommunityMembers(comm_id, isAdmin, system_comm) )
        {
          communityIds.add(comm_id);
View Full Code Here

    //Step 1 Create the person object
    //NOTE we use to store subscription info (i.e. in the peoplepojo)
    //but it was never used anywhere (validating subscription?)
    //its in the WPUserPojo that comes across
    ObjectId profileId = new ObjectId();
    PersonPojo pp = new PersonPojo();
    pp.set_id(profileId);
    pp.setAccountStatus("active");
    if ((null == wpu.getEmail()) || (0 == wpu.getEmail().size())) {
      rp.setResponse(new ResponseObject("WP Register User",false,"Need to specify email"));
      return rp;
    }//TESTED (2c)
    pp.setEmail(wpu.getEmail().get(0));
    pp.setFirstName(wpu.getFirstname()); // (optional but one of this + last name must be set)
    pp.setLastName(wpu.getLastname()); // (optional but one of this + first name must be set)
    if ((null == wpu.getFirstname()) || wpu.getFirstname().isEmpty()){
      if (null == wpu.getLastname()) {
        rp.setResponse(new ResponseObject("WP Register User",false,"Need to specify one of firstname,lastname"));
        return rp;
      }
      pp.setDisplayName(wpu.getLastname());
    }//TESTED (2d)
    else if ((null == wpu.getLastname()) || wpu.getLastname().isEmpty()) {
      pp.setDisplayName(wpu.getFirstname());     
    }
    else {
      pp.setDisplayName(wpu.getFirstname() + " " + wpu.getLastname());           
    }
   
    // Check if user is already present (+set "primary keys"):
   
    if (null == wpu.getWPUserID()) { // WPUserId is optional, uses email if not present
      wpu.setWPUserID(pp.getEmail());
    }
    else { // Check WPU (+email later)
      PersonPojo personQuery = new PersonPojo();
      personQuery.setWPUserID(wpu.getWPUserID()); // (can be null, that's fine)           
      DBObject dboperson = DbManager.getSocial().getPerson().findOne(personQuery.toDb());
      if (null != dboperson) {
        rp.setResponse(new ResponseObject("WP Register User",false,"User already exists, both WPUserId and first email must be unique"));
        return rp;       
      }//TESTED (2e)
    }   
    pp.setWPUserID(wpu.getWPUserID());
   
    PersonPojo personQuery = new PersonPojo();
    personQuery.setEmail(pp.getEmail());
    DBObject dboperson = DbManager.getSocial().getPerson().findOne(personQuery.toDb());
    if (null != dboperson) {
      rp.setResponse(new ResponseObject("WP Register User",false,"User already exists, both WPUserId and first email must be unique"));
      return rp;       
    }//TESTED (2f)
   
View Full Code Here

TOP

Related Classes of com.ikanow.infinit.e.data_model.store.social.person.PersonPojo

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.