public ResponseContext execute(ResponseContext resc) throws BusinessLogicException {
    try {
      RequestContext reqc = getRequestContext();

      String[] targets = reqc.getParameter("target");
      String[] status = reqc.getParameter("status");

      MySqlConnectionManager.getInstance().beginTransaction();

      AbstractDaoFactory factory = AbstractDaoFactory.getFactory("users");
      AbstractDao dao = factory.getAbstractDao();

      List users = new ArrayList();

      for (int i = 0; i < targets.length; i++) {
        Map params = new HashMap();
        params.put("value", targets[i]);
        params.put("where", "where user_id=?");

        UserBean ub = (UserBean) dao.read(params);

        params.put("userId", targets[i]);
        params.put("userbean", ub);
        params.put("userStatus", status[i]);

        dao.update(params);

        users.add(ub.getUserName());
      }

      MySqlConnectionManager.getInstance().commit();
      MySqlConnectionManager.getInstance().closeConnection();

      Map result = new HashMap();
      result.put("list", users);
      result.put("want", "削除");

      resc.setResult(result);
      resc.setTarget("AccountChangeResult");

      return resc;
    } catch (IntegrationException e) {
      throw new BusinessLogicException(e.getMessage(), e);
    }
  }
  public ResponseContext execute(ResponseContext resc) throws BusinessLogicException {
    try {
      RequestContext reqc = getRequestContext();
      String communityId = reqc.getParameter("communityId")[0];
      Map params = new HashMap();

      // 削除されていないコミュニティを取得するための条件
      params.put("where", "where community_id=? and community_delete_flag=0");
      params.put("communityId", reqc.getParameter("communityId")[0]);
      // DAOの中でキーの値が統一されていないため、同じ値を違うキーで入れています。
      // 犯人は土屋。
      params.put("commId", reqc.getParameter("communityId")[0]);

      MySqlConnectionManager.getInstance().beginTransaction();

      // コミュニティを取得
      AbstractDaoFactory factory = AbstractDaoFactory.getFactory("community");
      AbstractDao dao = factory.getAbstractDao();
      CommunityBean cb = (CommunityBean) dao.read(params);

      // コミュニティがもつトピックを取得
      factory = AbstractDaoFactory.getFactory("topic");
      dao = factory.getAbstractDao();
      cb.setTopics(dao.readAll(params));

      MySqlConnectionManager.getInstance().commit();

      resc.setResult(cb);
      resc.setTarget("topiclist");

      return resc;

    } catch (NullPointerException e) {
      throw new ParameterInvalidException("入力内容が足りません", e);
    } catch (IntegrationException e) {
      throw new BusinessLogicException(e.getMessage(), e);
    } finally {

      MySqlConnectionManager.getInstance().closeConnection();
    }
  }
  public ResponseContext execute(ResponseContext resc) throws BusinessLogicException {
    try {
      RequestContext reqc = getRequestContext();

      String[] articleId = reqc.getParameter("articleId");

      String status = reqc.getParameter("status")[0];

      Map params = new HashMap();

      params.put("status", status);

      AbstractDaoFactory factory = AbstractDaoFactory.getFactory("article");
      AbstractDao dao = factory.getAbstractDao();

      for (int i = 0; i < articleId.length; i++) {
        params.put("articleId", articleId[i]);

        MySqlConnectionManager.getInstance().beginTransaction();

        ArticleBean ab = (ArticleBean) dao.read(params);

        params.put("articlebean", ab);
        dao.update(params);

        MySqlConnectionManager.getInstance().commit();
        MySqlConnectionManager.getInstance().closeConnection();
      }

      resc.setTarget("publicationrangesetting");

      return resc;

    } catch (IntegrationException e) {
      throw new BusinessLogicException(e.getMessage(), e);
    }
  }
Example #4
0
  public ResponseContext execute(ResponseContext resc) throws BusinessLogicException {
    try {
      RequestContext reqc = getRequestContext();

      Map result = new HashMap();

      MySqlConnectionManager.getInstance().beginTransaction();

      // TOPで表示する新着記事の取得
      AbstractDaoFactory factory = AbstractDaoFactory.getFactory("sort");
      AbstractDao dao = factory.getAbstractDao();
      Map param1 = new HashMap();
      param1.put("sortType", "0");
      List articles = dao.readAll(param1);
      Iterator itr = articles.iterator();

      while (itr.hasNext()) {
        ArticleBean ab = (ArticleBean) itr.next();
        param1.clear();
        param1.put("articleId", ab.getArticleId());
        factory = AbstractDaoFactory.getFactory("tag");
        dao = factory.getAbstractDao();

        ab.setTags(dao.readAll(param1));

        factory = AbstractDaoFactory.getFactory("comment");
        dao = factory.getAbstractDao();
        ab.setComments(dao.readAll(param1));
      }

      if (articles.size() <= 6) {
        result.put("article", sliceArticleBody(articles));
      } else {
        List nArticles = new ArrayList();
        for (int i = 0; i < 6; i++) {
          nArticles.add(articles.get(i));
        }
        result.put("article", sliceArticleBody(nArticles));
      }

      factory = AbstractDaoFactory.getFactory("blog");
      dao = factory.getAbstractDao();
      List blogs = dao.readAll(new HashMap());

      if (blogs.size() <= 3) {
        result.put("blog", blogs);
      } else {
        List nBlogs = new ArrayList();
        for (int i = 0; i < 3; i++) {
          nBlogs.add(blogs.get(i));
        }

        result.put("blog", nBlogs);
      }

      factory = AbstractDaoFactory.getFactory("community");
      dao = factory.getAbstractDao();

      Map param2 = new HashMap();
      param2.put("where", "Where community_delete_flag=0 ");
      param2.put("sort", " order by communities.community_created_date desc ");
      List communities = dao.readAll(param2);

      if (communities.size() <= 5) {
        result.put("community", communities);
      } else {
        List nCommunities = new ArrayList();
        for (int i = 0; i < 5; i++) {
          nCommunities.add(communities.get(i));
        }

        result.put("community", nCommunities);
      }

      // ブログタブで表示する学科ごとの新着記事の取得
      factory = AbstractDaoFactory.getFactory("users");
      dao = factory.getAbstractDao();
      Map param3 = new HashMap();
      param3.put("userStatus", "0");
      param3.put("where", " and admin_flag > ?");
      param3.put("value", "1");
      List users = dao.readAll(param3);
      factory = AbstractDaoFactory.getFactory("article");
      dao = factory.getAbstractDao();
      List departmentArticles = new ArrayList();
      for (int i = 0; i < users.size(); i++) {
        UserBean ub = (UserBean) users.get(i);
        Map param = new HashMap();
        param.put("userId", ub.getId());
        param.put("flag", "0");
        param.put("option", "limit 1 ");
        List departmentArticle = dao.readAll(param);
        departmentArticles.add((ArticleBean) departmentArticle.get(0));
      }
      result.put("department", sliceArticleBody(departmentArticles));

      MySqlConnectionManager.getInstance().commit();
      MySqlConnectionManager.getInstance().closeConnection();

      resc.setResult(result);
      resc.setTarget("top");

      return resc;

    } catch (NullPointerException e) {
      throw new ParameterInvalidException("入力内容が足りません", e);
    } catch (IntegrationException e) {
      throw new BusinessLogicException(e.getMessage(), e);
    }
  }