Package net.baguajie.domains

Examples of net.baguajie.domains.Activity


      trackShipRepository.save(ts);
    }
    if(tracked){
      trackShipRepository.save(ts);
      // save activity
      Activity activity = new Activity();
      activity.setOwner(signInUser.getId());
      activity.setCreatedAt(new Date());
      activity.setTargetSpot(target.getId());
      activity.setType(ActivityType.TRACK);
      activity.setBy(sessionUtil.getBy(session));
      activityRepository.save(activity);
    }
    return new AjaxResult(AjaxResultCode.SUCCESS);
  }
View Full Code Here


    }
    if(result.hasErrors()){
      return new AjaxResult(AjaxResultCode.INVALID,
          BindingErrors.from(result));
    }
    Activity activity = activityRepository.findOne(bean.getActId());
    if(activity==null){
      throw new RuntimeException("Invalid activity id:" + bean.getActId());
    }
    if(activity.getTargetSpot() == null ||
        (ActivityType.SPOT != activity.getType() &&
          ActivityType.FORWARD != activity.getType())){
      throw new RuntimeException("Invalid activity type:" + activity.getType());
    }
    Spot target = spotRepository.findOne(activity.getTargetSpot());
 
    // save forward as comment
    Forward fwd = Forward.from(bean, signInUser);
    fwd.setAct(activity);
    fwd = forwardRepository.save(fwd);
   
    // incr forwarded count of original activity
    activityRepository.inc(activity.getId(), "forwardedCount", 1);
   
    // save forward activity
    activity = new Activity();
    activity.setOwner(signInUser.getId());
    activity.setCreatedAt(new Date());
    activity.setTargetSpot(target.getId());
    activity.setContent(bean.getContent());
    activity.setType(ActivityType.FORWARD);
    activity.setBasedOn(bean.getActId());
    activity.setBy(sessionUtil.getBy(session));
    activityRepository.save(activity);
   
    // incr forwarded count of target spot
    spotRepository.inc(target.getId(), "forwardedCount", 1);
   
View Full Code Here

      userRepository.inc(target.getId(), "fansCount", 1);
    }
    if(followed){
      followShipRepository.save(fs);
      // save activity
      Activity activity = new Activity();
      activity.setOwner(signInUser.getId());
      activity.setCreatedAt(new Date());
      activity.setTargetUser(target.getId());
      activity.setType(ActivityType.FOLLOW);
      activity.setBy(sessionUtil.getBy(session));
      activityRepository.save(activity);
    }
    return new AjaxResult(AjaxResultCode.SUCCESS);
  }
View Full Code Here

    }
    if(result.hasErrors()){
      return new AjaxResult(AjaxResultCode.INVALID,
          BindingErrors.from(result));
    }
    Activity activity = activityRepository.findOne(bean.getActId());
    if(activity==null){
      throw new RuntimeException("Invalid activity id:" + bean.getActId());
    }
    // save comment
    Comment cmt = Comment.from(bean, signInUser);
    cmt.setAct(activity);
    cmt = commentRepository.save(cmt);
   
    // incr commented count of orignal activity
    activityRepository.inc(activity.getId(), "commentedCount", 1);
   
    // incr comment count of sign in user
    userRepository.inc(signInUser.getId(), "commentCount", 1);
   
    if(activity.getTargetSpot()!=null){
      Spot spot = spotRepository.findOne(activity.getTargetSpot());
      // incr commented count of target spot
      spotRepository.inc(spot.getId(), "commentedCount", 1);
    }
   
    // save cmt activity
    activity = new Activity();
    activity.setOwner(signInUser.getId());
    activity.setCreatedAt(new Date());
    activity.setTargetSpot(activity.getTargetSpot());
    activity.setTargetUser(activity.getOwner());
    activity.setContent(bean.getContent());
    activity.setType(ActivityType.COMMENT);
    activity.setBasedOn(bean.getActId());
    activity.setBy(sessionUtil.getBy(session));
    activityRepository.save(activity);
   
    return new AjaxResult(AjaxResultCode.SUCCESS, cmt);
  }
View Full Code Here

      if(act.getTargetUser()!=null){
        User targetUser = userRepository.findOne(act.getTargetUser());
        vo.setTargetUser(targetUser);
      }
      if(StringUtils.hasText(act.getBasedOn())){
        Activity basedOnAct = activityRepository.findOne(act.getBasedOn());
        ActivityVo basedOn = ActivityVo.from(basedOnAct);
        basedOn.setOwner(userRepository.findOne(basedOnAct.getOwner()));
        vo.setBasedOn(basedOn);
      }
      activities.add(vo);
    }
    return activities;
View Full Code Here

      Pageable pageable = new PageRequest(0,
          ApplicationConfig.pinCmtPageSize,
          new Sort(new Order(Direction.DESC, "createdAt")));
      for(Spot spot : spots){
        try{
          Activity act = activityRepository.getByOwnerAndTargetSpotAndType(
              spot.getCreatedBy().getId(), spot.getId(), ActivityType.SPOT.name());
          Page<Comment> cmts = null;
          if(act!=null){
             cmts = commentRepository.findByAct(
                act.getId(), pageable);
          }
          if(spot.getPlace()==null){
            pins.add(PinVo.from(spot,
                cityMetaRepository.getByPinyin(StringUtils.hasText(spot.getCity())?
                    spot.getCity():ApplicationConfig.defaultCityPinyin), act, cmts));
View Full Code Here

 
  @RemotingInclude
  public ROResult getComments(String spotId, String createdById) {
    ROResult result = new ROResult();
    try {
      Activity act = activityRepository.getByOwnerAndTargetSpotAndType(
          createdById, spotId, ActivityType.SPOT.name());
      if(act == null)
      {
        throw new RuntimeException("Could not find the relative activity.");
      }
      List<Comment> comments = commentRepository.findByAct(act.getId());
      result.setResult(comments);
    } catch (Exception e) {
      result.setErrorCode(new ErrorCode(ErrorCode.BUSINESS_ERROR,
          ErrorCode.ERROR, e.getMessage()));
      result.addErrorMsg(e.getMessage());
View Full Code Here

    if(spots!=null){
      pageable = new PageRequest(0,
          ApplicationConfig.pinCmtPageSize,
          new Sort(new Order(Direction.DESC, "createdAt")));
      for(Spot spot : spots){
        Activity act = activityRepository.getByOwnerAndTargetSpotAndType(
            spot.getCreatedBy().getId(), spot.getId(), ActivityType.SPOT.name());
        Page<Comment> cmts = null;
        if(act!=null){
           cmts = commentRepository.findByAct(
              act.getId(), pageable);
        }
        if(spot.getPlace()==null){
          pins.add(PinVo.from(spot,
              cityMetaRepository.getByPinyin(StringUtils.hasText(spot.getCity())?
                  spot.getCity():ApplicationConfig.defaultCityPinyin), act, cmts));
View Full Code Here

          ApplicationConfig.pinCmtPageSize,
          new Sort(new Order(Direction.DESC, "createdAt")));
      for(TrackShip ts : tss){
        if(ts.getTarget()==null) continue;
        Spot spot = ts.getTarget();
        Activity act = activityRepository.getByOwnerAndTargetSpotAndType(
            spot.getCreatedBy().getId(), spot.getId(), ActivityType.SPOT.name());
        Page<Comment> cmts = null;
        if(act!=null){
           cmts = commentRepository.findByAct(
              act.getId(), pageable);
        }
        if(spot.getPlace()==null){
          pins.add(PinVo.from(spot,
              cityMetaRepository.getByPinyin(StringUtils.hasText(spot.getCity())?
                  spot.getCity():ApplicationConfig.defaultCityPinyin), act, cmts));
View Full Code Here

    spot = spotRepository.save(spot);
    // increase spot count
    signInUser.setSpotCount(signInUser.getSpotCount()+1);
    userRepository.save(signInUser);
    // save activity
    Activity activity = new Activity();
    activity.setOwner(signInUser.getId());
    activity.setCreatedAt(new Date());
    activity.setTargetSpot(spot.getId());
    activity.setType(ActivityType.SPOT);
    activity.setBy(sessionUtil.getBy(session));
    activityRepository.save(activity);
   
    return new AjaxResult(AjaxResultCode.SUCCESS);
  }
View Full Code Here

TOP

Related Classes of net.baguajie.domains.Activity

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.