Beispiel #1
0
  private Topic createdTopic(String owner) {
    Topic topicNew = new Topic();

    topicNew.setOwner(owner);
    topicNew.setTopicName("TestTopic");
    topicNew.setCreatedDate(new Date());
    topicNew.setModifiedBy("root");
    topicNew.setModifiedDate(new Date());
    topicNew.setLastPostBy("root");
    topicNew.setLastPostDate(new Date());
    topicNew.setDescription("Topic description");
    topicNew.setPostCount(0);
    topicNew.setViewCount(0);
    topicNew.setIsNotifyWhenAddPost("");
    topicNew.setIsModeratePost(false);
    topicNew.setIsClosed(false);
    topicNew.setIsLock(false);
    topicNew.setIsWaiting(false);
    topicNew.setIsActive(true);
    topicNew.setIcon("classNameIcon");
    topicNew.setIsApproved(true);
    topicNew.setCanView(new String[] {});
    topicNew.setCanPost(new String[] {});
    return topicNew;
  }
Beispiel #2
0
  @Override
  public void inject(HashMap<String, String> params) throws Exception {

    //
    int number = param(params, NUMBER);
    String topicPrefix = params.get(TOPIC_PREFIX);

    //
    int fromUser = param(params, FROM_USER);
    int toUser = param(params, TO_USER);
    String userPrefix = params.get(USER_PREFIX);

    //
    int toForum = param(params, TO_FORUM);
    String forumPrefix = params.get(FORUM_PREFIX);
    init(userPrefix, null, forumPrefix, topicPrefix, null, 0);

    String forumName = forumBase + toForum;
    Forum forum = getForumByName(forumName);
    if (forum == null) {
      getLog()
          .info(
              "forum name is '"
                  + forumName
                  + "' wrong. Please set it exactly. Aborting injection ...");
      return;
    }

    Category cat = getCategoryByForumName(forumName);

    //
    for (int i = fromUser; i <= toUser; ++i) {
      String owner = userBase + i;

      //
      for (int j = 0; j < number; ++j) {
        String topicName = topicName();

        Topic topicNew = new Topic();

        topicNew.setOwner(owner);
        topicNew.setTopicName(topicName);
        topicNew.setCreatedDate(new Date());
        topicNew.setModifiedBy(owner);
        topicNew.setModifiedDate(new Date());
        topicNew.setLastPostBy(owner);
        topicNew.setLastPostDate(new Date());
        topicNew.setDescription(lorem.getParagraphs());
        topicNew.setPostCount(0);
        topicNew.setViewCount(0);
        topicNew.setIsNotifyWhenAddPost("");
        topicNew.setIsModeratePost(false);
        topicNew.setIsClosed(false);
        topicNew.setIsLock(false);
        topicNew.setIsWaiting(false);
        topicNew.setIsActive(true);
        topicNew.setIcon("classNameIcon");
        topicNew.setIsApproved(true);
        topicNew.setCanView(new String[] {});
        topicNew.setCanPost(new String[] {});

        //
        forumService.saveTopic(
            cat.getId(), forum.getId(), topicNew, true, false, new MessageBuilder());
        ++topicNumber;
        //
        getLog().info("Topic '" + topicName + "' in forum '" + forumName + "' created by " + owner);
      }
    }
  }