Beispiel #1
0
 public int getItemCount() {
   List<String> is = getItems();
   if (is == null || is.isEmpty()) {
     return 0;
   }
   int cnt = 0;
   for (String item : is) {
     if (!StringUtil.isEmpty(item)) {
       cnt++;
     }
   }
   return cnt;
 }
Beispiel #2
0
  /**
   * 対象スポットの取得
   *
   * @return
   * @throws NoContentsException
   */
  public User getUser() throws NoContentsException {

    String userId = asString("userId");

    // spot Id がNullの場合
    if (StringUtil.isEmpty(userId)) {
      throw new NoContentsException();
    }

    // スポットの取得
    User user = UserService.getUser(userId);

    if (user == null) throw new NoContentsException();

    return user;
  }
  /**
   * ユーザーがバトロンとなったコンテンツ一覧を取得(新しい順)
   *
   * @param userModel
   * @param num
   * @return
   */
  public S3QueryResultList<TransmitHistoryModel> getHistoryListByUser(
      UserModel userModel, int num, String cursor) {

    if (StringUtil.isEmpty(cursor)) return getHistoryListByUser(userModel, num);

    ModelRefAttributeMeta<TransmitHistoryModel, ModelRef<UserModel>, UserModel> refMeta =
        meta.userModelRef;

    S3QueryResultList<TransmitHistoryModel> list =
        Datastore.query(meta)
            .filter(refMeta.equal(userModel.getKey()))
            .encodedStartCursor(cursor)
            .sort(new Sort(meta.createDate, SortDirection.DESCENDING))
            .limit(num)
            .asQueryResultList();

    return list;
  }
Beispiel #4
0
  /**
   * ユーザーリストを取得
   *
   * @return
   */
  public static S3QueryResultList<UserModel> getUserList(String cursor) {

    S3QueryResultList<UserModel> list = null;

    // 最初のページをキャッシュする
    if (StringUtil.isEmpty(cursor)) {
      // Memcache に存在した場合はMemcache内のmodelを返す
      list = Memcache.get(USER_LIST_FIRST_30);
      if (Utils.isNotEmpty(list)) return list;

      // DBから取得し、存在した場合はMemcacheに入れる
      list = userModelDao.getUserList(Constants.SERVICE_USER_LIST_LIMIT_NUM);
      if (Utils.isNotEmpty(list)) Memcache.put(USER_LIST_FIRST_30, list);

    } else {
      list = userModelDao.getUserList(Constants.SERVICE_USER_LIST_LIMIT_NUM, cursor);
    }

    return list == null
        ? new S3QueryResultList<UserModel>(new ArrayList<UserModel>(), null, null, null, false)
        : list;
  }
Beispiel #5
0
  @Override
  public Navigation run() throws Exception {
    requestScope("isSmartPhone", String.valueOf(isSmartPhone()));
    requestScope("isLocal", String.valueOf(isLocal()));

    String siteId = asString("siteId");
    if (StringUtil.isEmpty(siteId.trim())) throw new NoContentsException();

    User user = null;
    try {
      user = UserService.getBySiteId(siteId);
      requestScope("user", user);
    } catch (ObjectNotExistException e) {
      throw new NoContentsException();
    }

    List<SitePage> pageList = null;
    try {
      pageList = PageService.getList(user);
      requestScope("pageList", pageList);
    } catch (ObjectNotExistException e) {
      throw new NoContentsException();
    }

    try {
      if (user.getSiteId().equals(getLoginUser().getSiteId())) {
        requestScope("isEditMode", String.valueOf(true));
      } else {
        requestScope("isEditMode", String.valueOf(false));
      }
    } catch (NoLoginException e) {
      requestScope("isEditMode", String.valueOf(false));
    }

    return execute(user);
  }