Search in sources :

Example 26 with Poster

use of it.vige.rubia.model.Poster in project rubia-forums by flashboss.

the class ForumsModuleImpl method createWatch.

@Override
public void createWatch(Poster poster, Forum forum, int mode) throws ModuleException {
    try {
        if (poster == null) {
            throw new ModuleException("poster must not be null");
        }
        if (forum == null) {
            throw new ModuleException("forum must not be null");
        }
        Poster posterOld = findPosterByUserId(poster.getUserId());
        if (posterOld == null) {
            em.persist(poster);
        }
        em.merge(poster);
        ForumWatch forumWatch = new ForumWatch();
        forumWatch.setPoster(poster);
        forumWatch.setForum(forum);
        forumWatch.setMode(mode);
        em.persist(forumWatch);
        // it is required
        em.flush();
    // for clustered versions
    } catch (Exception e) {
        String errorMessage = "Cannot create forum watch";
        throw new ModuleException(errorMessage, e);
    }
}
Also used : ForumWatch(it.vige.rubia.model.ForumWatch) Poster(it.vige.rubia.model.Poster) NoResultException(javax.persistence.NoResultException) NonUniqueResultException(javax.persistence.NonUniqueResultException)

Example 27 with Poster

use of it.vige.rubia.model.Poster in project rubia-forums by flashboss.

the class ForumsModuleImpl method createTopic.

@Override
public Topic createTopic(Forum forum, String userId, String subject, TopicType type) throws ModuleException {
    try {
        Poster poster = findPosterByUserId(userId);
        if (poster == null) {
            poster = createPoster(userId);
        }
        em.persist(poster);
        Topic topic = new Topic();
        topic.setSubject(subject);
        topic.setForum(forum);
        topic.setPoster(poster);
        topic.setType(type);
        topic.setPoll(null);
        em.persist(topic);
        em.flush();
        return topic;
    } catch (Exception e) {
        String errorMessage = "Cannot create topic";
        throw new ModuleException(errorMessage, e);
    }
}
Also used : Poster(it.vige.rubia.model.Poster) Topic(it.vige.rubia.model.Topic) NoResultException(javax.persistence.NoResultException) NonUniqueResultException(javax.persistence.NonUniqueResultException)

Example 28 with Poster

use of it.vige.rubia.model.Poster in project rubia-forums by flashboss.

the class ForumsModuleImpl method createWatch.

@Override
public void createWatch(Poster poster, Topic topic, int mode) throws ModuleException {
    try {
        if (poster == null) {
            throw new ModuleException("poster must not be null");
        }
        if (topic == null) {
            throw new ModuleException("topic must not be null");
        }
        Poster posterOld = findPosterByUserId(poster.getUserId());
        if (posterOld == null) {
            em.persist(poster);
        }
        em.merge(poster);
        // it is required
        em.flush();
        // for clustered versions
        TopicWatch topicWatch = new TopicWatch();
        topicWatch.setPoster(poster);
        topicWatch.setTopic(topic);
        topicWatch.setMode(mode);
        em.persist(topicWatch);
        // it is required
        em.flush();
    // for clustered versions
    } catch (Exception e) {
        String errorMessage = "Cannot create topic watch";
        throw new ModuleException(errorMessage, e);
    }
}
Also used : Poster(it.vige.rubia.model.Poster) TopicWatch(it.vige.rubia.model.TopicWatch) NoResultException(javax.persistence.NoResultException) NonUniqueResultException(javax.persistence.NonUniqueResultException)

Example 29 with Poster

use of it.vige.rubia.model.Poster in project rubia-forums by flashboss.

the class PortalUtil method getPoster.

/**
 * @param forumsModule
 *            DOCUMENT_ME
 * @param userModule
 *            DOCUMENT_ME
 * @return the current user
 * @throws Exception
 *             DOCUMENT_ME
 */
public static Poster getPoster(ForumsModule forumsModule, UserModule userModule) throws Exception {
    Poster poster = null;
    User user = getUser(userModule);
    String userId = user.getId();
    poster = forumsModule.findPosterByUserId(userId);
    if (poster == null) {
        poster = new Poster(userId);
    }
    return poster;
}
Also used : User(it.vige.rubia.auth.User) Poster(it.vige.rubia.model.Poster)

Example 30 with Poster

use of it.vige.rubia.model.Poster in project rubia-forums by flashboss.

the class PortalUtil method getGuestPoster.

public static Poster getGuestPoster(UserModule userModule, ForumsModule forumsModule) throws Exception {
    Poster poster = null;
    User user = null;
    String guestUserName = forumsModule.getGuestUserName();
    try {
        user = userModule.findUserByUserName(guestUserName);
    } catch (Exception e) {
    }
    Long userId = parseLong(user.getId());
    poster = forumsModule.findPosterByUserId(String.valueOf(userId));
    if (poster == null) {
        poster = new Poster(userId.toString());
    }
    return poster;
}
Also used : User(it.vige.rubia.auth.User) Poster(it.vige.rubia.model.Poster) Long.parseLong(java.lang.Long.parseLong)

Aggregations

Poster (it.vige.rubia.model.Poster)46 Post (it.vige.rubia.model.Post)20 WebElement (org.openqa.selenium.WebElement)18 Topic (it.vige.rubia.model.Topic)17 Forum (it.vige.rubia.model.Forum)14 Test (org.junit.Test)13 Message (it.vige.rubia.model.Message)11 ParseException (java.text.ParseException)10 Category (it.vige.rubia.model.Category)7 CreateTopic.createTopic (it.vige.rubia.selenium.forum.action.CreateTopic.createTopic)7 RemoveTopic.removeTopic (it.vige.rubia.selenium.forum.action.RemoveTopic.removeTopic)7 Date (java.util.Date)7 CreateForum.createForum (it.vige.rubia.selenium.adminpanel.action.CreateForum.createForum)6 RemoveForum.removeForum (it.vige.rubia.selenium.adminpanel.action.RemoveForum.removeForum)6 NoResultException (javax.persistence.NoResultException)6 NonUniqueResultException (javax.persistence.NonUniqueResultException)6 VerifyPost.getLastPostOfCurrentForum (it.vige.rubia.selenium.forum.action.VerifyPost.getLastPostOfCurrentForum)5 VerifyTopic (it.vige.rubia.selenium.forum.action.VerifyTopic)5 VerifyTopic.getPoster (it.vige.rubia.selenium.forum.action.VerifyTopic.getPoster)5 DateFormat (java.text.DateFormat)5