Package org.internna.iwebmvc.model

Examples of org.internna.iwebmvc.model.I18nText


    @Autowired private DAO baseDao;

    @Before
    public void init() throws Exception {
        Link link = new Link();
        link.setReadableText(new I18nText());
        link.getReadableText().add(new Locale("en"), "hi");
        link.getReadableText().add(new Locale("es"), "hola");
        link.setUrl("http://localhost/application");
        link.setTooltipText(new I18nText());
        link.getTooltipText().add(new Locale("en"), "hi");
        link.getTooltipText().add(new Locale("es"), "hola");
        baseDao.create(link);
    }
View Full Code Here


        link = linkParser.parse(link);
        assertNull(link.getReadableText());
        assertNull(link.getTooltipText());
        link = new Link();
        link.setId(unique.getId());
        link.setReadableText(new I18nText());
        link.getReadableText().add(new Locale("en"), "new");
        link.getReadableText().add(new Locale("es"), "nuevo");
        link.setTooltipText(new I18nText());
        link.getTooltipText().add(new Locale("en"), "tooltip");
        link.getTooltipText().add(new Locale("es"), "etiqueta");
        link = linkParser.parse(link);
        assertEquals(link.getReadableText().getId(), unique.getReadableText().getId());
        assertEquals("new", link.getReadableText().getData().get(0).getTranslation());
View Full Code Here

    private RemoteEntityManagerImpl impl = new RemoteEntityManagerImpl();

    @Before
    public void init() throws Exception {
        Link l = new Link();
        l.setReadableText(new I18nText());
        l.getReadableText().add(Locale.CANADA, "a");
        l.setTooltipText(new I18nText());
        l.getReadableText().add(Locale.UK, "b");
        l.setUrl("http://www.google.com");
        dao.create(l);
        generatedID = l.getId();
        securityDAO.createAuthority("registered_user");
View Full Code Here

    }

    @Test
    public void testParse() {
        assertNull(textParser.parse(null));
        I18nText text = new I18nText();
        assertEquals(text, textParser.parse(text));
        text.add(new Locale("en"), "hi");
        text.add(new Locale("es"), "hola");
        baseDao.create(text);
        I18nText textNew = new I18nText();
        textNew.setId(text.getId());
        textNew.add(new Locale("en"), "other");
        textNew.add(new Locale("es"), "otro");
        I18nText parsed = textParser.parse(textNew);
        assertNotNull(parsed.getData().get(0).getId());
        assertEquals(parsed.getData().get(0).getTranslation(), "other");
        baseDao.update(parsed);
        assertTrue(baseDao.find(LocalizedValue.class, 0, 100).size() == 2 + number);
        assertTrue(baseDao.find(I18nText.class, parsed.getId()).getData().size() == 2);
    }
View Full Code Here

        user.setName("Poller");
        user.setPassword("poller");
        user.addRole((RoleImpl) securityDAO.findAuthority("polladmin"));
        securityDAO.createUser(user);
        Poll clubPoll = new Poll();
        clubPoll.setQuestion(new I18nText());
        clubPoll.getQuestion().add(new Locale("en"), "What's your favorite european football club?");
        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");
        options.get(4).getAnswer().add(new Locale("es"), "PSV Eindhoven");
        List<PollVote> votes4 = new ArrayList<PollVote>(1);
        votes4.add(new PollVote());
        votes4.get(0).setIP("192.168.1.1");
View Full Code Here

    @Test
    public void testParseContMore() {
        Poll p = new Poll();
        p.setId(baseDao.first(Poll.class).getId());
        p.setQuestion(new I18nText());
        p.getQuestion().add(new Locale("en"), "club");
        p.getQuestion().add(new Locale("es"), "equipo");
        p = pollParser.parse(p);
        assertNotNull(p.getQuestion().getId());
        assertEquals("club", p.getQuestion().getData().get(0).getTranslation());
View Full Code Here

        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());
        p.getQuestion().add(new Locale("en"), "What's your favorite european football club?");
        baseDao.update(p);
        assertTrue(baseDao.find(Poll.class, 0, 100).size() == 1);
        assertTrue(baseDao.find(PollOption.class, 0, 100).size() == 2);
    }
View Full Code Here

            m.setName(new Name());
            m.getName().setName("John Smith");
            m.setSex(sex.get(0));
            m.setPhotos(new MultiDocument().addDocument(photoJohn).addDocument(house).addDocument(car).addDocument(dog));
            m.setBlog(new Link());
            m.getBlog().setReadableText(new I18nText());
            m.getBlog().getReadableText().add(new Locale("en"), "My tech blog");
            m.getBlog().getReadableText().add(new Locale("es"), "Mi blog de tecnolog�a");
            m.getBlog().setUrl("http://internna.blogspot.com");
            m.getBlog().setTooltipText(new I18nText());
            m.getBlog().getTooltipText().add(new Locale("en"), "A must read!");
            m.getBlog().getTooltipText().add(new Locale("es"), "�De lectura obligada!");
            dao.create(m, false);
            Person f = new Person();
            f.setName(new Name());
            f.getName().setName("Mary Poppins");
            f.setSex(sex.get(1));
            f.setPhotos(new MultiDocument().addDocument(photoMary));
            dao.create(f, false);
            Calendar calendar = Calendar.getInstance();
            int num = 1000;
            boolean emitted = false;
            Currency eur = Currency.obtain("EUR", dao), usd = Currency.obtain("USD", dao);
            int count = 0;
            for (int i = 0; i < (30 + Math.round(Math.random() * 20)); i++) {
              emitted = !emitted;
                Order o = new Order();
                o.setAmount(new Amount());
                double aux = Math.random();
                try {
                    o.setIdentifier(new I18nText());
                    for (Locale l : supportedLocales) o.getIdentifier().add(l, l + ":" + StringUtils.SHA1(String.valueOf(aux)));
              } catch (Exception e) {};
                o.getAmount().setAmount(aux * 1024 * 1024);
                o.getAmount().setCurrency(aux > 0.5 ? usd : eur);
                o.setOrderNumber(num++);
View Full Code Here

  @Override public void execute() {
        if (logger.isInfoEnabled()) logger.info("Executing startup task [GeneratePollTableDataStartupTask]");
        if (dao.first(Poll.class) == null) {
            if (logger.isInfoEnabled()) logger.info("Poll table is empty. Generating test data...");
            Poll clubPoll = new Poll();
            clubPoll.setQuestion(new I18nText());
            clubPoll.getQuestion().add(new Locale("en"), "What's your favorite european football club?");
            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");
            options.get(4).getAnswer().add(new Locale("es"), "PSV Eindhoven");
            List<PollVote> votes4 = new ArrayList<PollVote>(1);
            votes4.add(new PollVote());
            votes4.get(0).setIP("192.168.1.5");
View Full Code Here

            for (String code : codes) {
                if (logger.isDebugEnabled()) logger.debug("Creating country [" + code + "]");
                try {
                    Country country = new Country();
                    country.setIsoCodeAlpha(code);
                    country.setCountry(new I18nText());
                    for (int index = 0; index < entries.length; index++)
                      country.getCountry().add(entries[index].getKey(), entries[index].getValue().getProperty(code));
                    country.setDefaultCountry(code.equals(defaultCountry));
                    dao.create(country, false);
                    if (count++ % 25 == 0) {
View Full Code Here

TOP

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

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.