Package org.internna.iwebmvc.model

Examples of org.internna.iwebmvc.model.PollOption


        clubPoll.getQuestion().add(new Locale("es"), "�Cual es tu equipo de futbol favorito de Europa?");
        clubPoll.setStoreVotes(true);
        clubPoll.setRandomizeOptions(true);
        clubPoll.setAllowAnonymousVotes(true);
        List<PollOption> options = new ArrayList<PollOption>(5);
        options.add(new PollOption());
        options.get(0).setPoll(clubPoll);
        options.get(0).setOrder(0);
        options.get(0).setTotalVotes(2);
        options.get(0).setAnswer(new I18nText());
        options.get(0).getAnswer().add(new Locale("en"), "Real Madrid");
        options.get(0).getAnswer().add(new Locale("es"), "Real Madrid C.F.");
        List<PollVote> votes = new ArrayList<PollVote>(2);
        votes.add(new PollVote());
        votes.get(0).setIP("127.0.0.4");
        votes.get(0).setOption(options.get(0));
        votes.add(new PollVote());
        votes.get(1).setIP("127.0.0.2");
        votes.get(1).setOption(options.get(0));
        options.get(0).setVotes(votes);
        options.add(new PollOption());
        options.get(1).setPoll(clubPoll);
        options.get(1).setOrder(1);
        options.get(1).setTotalVotes(1);
        options.get(1).setAnswer(new I18nText());
        options.get(1).getAnswer().add(new Locale("en"), "AC Milan");
        options.get(1).getAnswer().add(new Locale("es"), "AC Milan");
        List<PollVote> votes2 = new ArrayList<PollVote>(1);
        votes2.add(new PollVote());
        votes2.get(0).setIP("192.168.1.8");
        votes2.get(0).setOption(options.get(1));
        options.get(1).setVotes(votes2);
        options.add(new PollOption());
        options.get(2).setPoll(clubPoll);
        options.get(2).setOrder(2);
        options.get(2).setTotalVotes(2);
        options.get(2).setAnswer(new I18nText());
        options.get(2).getAnswer().add(new Locale("en"), "Manchester United");
        options.get(2).getAnswer().add(new Locale("es"), "Manchester United");
        List<PollVote> votes3 = new ArrayList<PollVote>(2);
        votes3.add(new PollVote());
        votes3.get(0).setIP("192.168.1.2");
        votes3.get(0).setOption(options.get(2));
        votes3.add(new PollVote());
        votes3.get(1).setAuthor((UserImpl) securityDAO.findUser("poller"));
        votes3.get(1).setOption(options.get(2));
        options.get(2).setVotes(votes3);
        options.add(new PollOption());
        options.get(3).setPoll(clubPoll);
        options.get(3).setOrder(3);
        options.get(3).setTotalVotes(0);
        options.get(3).setAnswer(new I18nText());
        options.get(3).getAnswer().add(new Locale("en"), "Bayern Munich");
        options.get(3).getAnswer().add(new Locale("es"), "Bayern Munich");
        options.add(new PollOption());
        options.get(4).setPoll(clubPoll);
        options.get(4).setOrder(4);
        options.get(4).setTotalVotes(1);
        options.get(4).setAnswer(new I18nText());
        options.get(4).getAnswer().add(new Locale("en"), "PSV Eindhoven");
View Full Code Here


    public void testParse() {
        assertNull(pollParser.parse(null));
        Poll p = new Poll();
        assertEquals(p, pollParser.parse(p));
        p.setOptions(new ArrayList<PollOption>(1));
        p.addOption(new PollOption());
        p = pollParser.parse(p);
        assertEquals(p, p.getOptions().iterator().next().getPoll());
    }
View Full Code Here

    @Test
    public void testParseContOther() {
        Poll p = new Poll();
        p.setId(baseDao.first(Poll.class).getId());
        PollOption aPollOption = baseDao.first(PollOption.class);
        PollOption copy = new PollOption();
        copy.setId(aPollOption.getId());
        copy.setAnswer(new I18nText());
        for (LocalizedValue value : aPollOption.getAnswer().getData())
            copy.getAnswer().add(value);
        copy.getAnswer().add(new Locale("it"), "x");
        p.addOption(copy);
        PollOption newOption = new PollOption();
        newOption.setAnswer(new I18nText());
        newOption.getAnswer().add(new Locale("en"), "a");
        newOption.getAnswer().add(new Locale("en"), "b");
        p.addOption(newOption);
        p = pollParser.parse(p);
        assertTrue(p.getOptions().size() == 2);
        assertTrue(p.getOptions().iterator().next().getAnswer().getData().size() == 2);
        p.setQuestion(new I18nText());
View Full Code Here

            clubPoll.getQuestion().add(new Locale("es"), "�Cual es tu equipo de f�tbol favorito de Europa?");
            clubPoll.setStoreVotes(true);
            clubPoll.setRandomizeOptions(true);
            clubPoll.setAllowAnonymousVotes(true);
            List<PollOption> options = new ArrayList<PollOption>(5);
            options.add(new PollOption());
            options.get(0).setPoll(clubPoll);
            options.get(0).setOrder(0);
            options.get(0).setTotalVotes(2);
            options.get(0).setAnswer(new I18nText());
            options.get(0).getAnswer().add(new Locale("en"), "Real Madrid");
            options.get(0).getAnswer().add(new Locale("es"), "Real Madrid C.F.");
            List<PollVote> votes = new ArrayList<PollVote>(2);
            votes.add(new PollVote());
            votes.get(0).setIP("127.0.0.4");
            votes.get(0).setOption(options.get(0));
            votes.add(new PollVote());
            votes.get(1).setIP("127.0.0.2");
            votes.get(1).setOption(options.get(0));
            options.get(0).setVotes(votes);
            options.add(new PollOption());
            options.get(1).setPoll(clubPoll);
            options.get(1).setOrder(1);
            options.get(1).setTotalVotes(1);
            options.get(1).setAnswer(new I18nText());
            options.get(1).getAnswer().add(new Locale("en"), "AC Milan");
            options.get(1).getAnswer().add(new Locale("es"), "AC Milan");
            List<PollVote> votes2 = new ArrayList<PollVote>(1);
            votes2.add(new PollVote());
            votes2.get(0).setIP("192.168.1.8");
            votes2.get(0).setOption(options.get(1));
            options.get(1).setVotes(votes2);
            options.add(new PollOption());
            options.get(2).setPoll(clubPoll);
            options.get(2).setOrder(2);
            options.get(2).setTotalVotes(2);
            options.get(2).setAnswer(new I18nText());
            options.get(2).getAnswer().add(new Locale("en"), "Manchester United");
            options.get(2).getAnswer().add(new Locale("es"), "Manchester United");
            List<PollVote> votes3 = new ArrayList<PollVote>(2);
            votes3.add(new PollVote());
            votes3.get(0).setIP("192.168.1.2");
            votes3.get(0).setOption(options.get(2));
            votes3.add(new PollVote());
            votes3.get(1).setAuthor((UserImpl) securityDAO.findUser("iwebmvc"));
            votes3.get(1).setOption(options.get(2));
            options.get(2).setVotes(votes3);
            options.add(new PollOption());
            options.get(3).setPoll(clubPoll);
            options.get(3).setOrder(3);
            options.get(3).setTotalVotes(0);
            options.get(3).setAnswer(new I18nText());
            options.get(3).getAnswer().add(new Locale("en"), "Bayern Munich");
            options.get(3).getAnswer().add(new Locale("es"), "Bayern Munich");
            options.add(new PollOption());
            options.get(4).setPoll(clubPoll);
            options.get(4).setOrder(4);
            options.get(4).setTotalVotes(1);
            options.get(4).setAnswer(new I18nText());
            options.get(4).getAnswer().add(new Locale("en"), "PSV Eindhoven");
View Full Code Here

    @Transactional
    @Override public synchronized DomainEntity vote(UUID pollId, UUID pollOptionId, HttpServletRequest request) {
        Assert.notNull(pollId);
        Assert.notNull(pollOptionId);
        Poll poll = dao.find(Poll.class, pollId);
        PollOption option = dao.find(PollOption.class, pollOptionId);
        User user = userManager.getActiveUser(request);
        String IPAddress = request.getRemoteAddr();
        if (poll.getUserVote(user, IPAddress, dao) == null) {
            if (poll.isAllowAnonymousVotes() | !user.isAnonymous()) {
                option.vote();
                dao.update(option);
                if (poll.isStoreVotes()) {
                    PollVote pollVote = new PollVote();
                    pollVote.setVoteTime(new Date());
                    pollVote.setIP(IPAddress);
View Full Code Here

TOP

Related Classes of org.internna.iwebmvc.model.PollOption

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.