Package org.internna.iwebmvc.model

Examples of org.internna.iwebmvc.model.MultiDocument


        doc2.setAuthor((UserImpl) securityDAO.findUser("adminuser"));
        doc2.setContents(FileCopyUtils.copyToByteArray(getClass().getResourceAsStream("/void.gif")));
        baseDao.create(doc2);
        generatedDocIDs.add(doc2.getId());
        byte[] contents = FileCopyUtils.copyToByteArray(getClass().getResourceAsStream("/void.gif"));
        MultiDocument md = new MultiDocument();
        Document doc = new Document();
        doc.setTemporal(false);
        doc.setIdentifier("void image");
        doc.setWidth(1);
        doc.setHeight(1);
        doc.setCreation(new Date());
        doc.setMimeType("image/gif");
        doc.setAuthor((UserImpl) securityDAO.findUser("adminuser"));
        doc.setContents(contents);
        Document doc3 = new Document();
        doc3.setTemporal(false);
        doc3.setIdentifier("blank image");
        doc3.setWidth(1);
        doc3.setHeight(1);
        doc3.setCreation(new Date());
        doc3.setMimeType("image/gif");
        doc3.setAuthor((UserImpl) securityDAO.findUser("adminuser"));
        doc3.setContents(contents);
        Document doc4 = new Document();
        doc4.setTemporal(false);
        doc4.setIdentifier("blank image");
        doc4.setWidth(1);
        doc4.setHeight(1);
        doc4.setCreation(new Date());
        doc4.setMimeType("image/gif");
        doc4.setAuthor((UserImpl) securityDAO.findUser("adminuser"));
        doc4.setContents(contents);
        Document doc5 = new Document();
        doc5.setTemporal(false);
        doc5.setIdentifier("blank image");
        doc5.setWidth(1);
        doc5.setHeight(1);
        doc5.setCreation(new Date());
        doc5.setMimeType("image/gif");
        doc5.setAuthor((UserImpl) securityDAO.findUser("adminuser"));
        doc5.setContents(contents);
        SimpleEntity entity = new SimpleEntity("john");
        entity.setPhotos(md.addDocument(doc).addDocument(doc3).addDocument(doc4).addDocument(doc5));
        baseDao.create(entity);
        assertNotNull(baseDao.first(SimpleEntity.class));
        assertNotNull(baseDao.first(MultiDocument.class));
    }
View Full Code Here


    }

    @Test
    public void testParseNulls() throws Exception {
        assertNull(multiDocumentParser.parse(null));
        MultiDocument md = new MultiDocument();
        assertNull(multiDocumentParser.parse(md));
        md.addDocument(new Document());
        md.addDocument(new Document());
        assertNull(multiDocumentParser.parse(md));
        SimpleEntity entity = baseDao.first(SimpleEntity.class);
        md = baseDao.first(MultiDocument.class);
        md.removeAll();
        MultiDocument parsed = multiDocumentParser.parse(md);
        assertNull(parsed);
        entity.setPhotos(parsed);
        baseDao.update(entity);
        assertNull(baseDao.first(MultiDocument.class));
    }
View Full Code Here

        assertNull(baseDao.first(MultiDocument.class));
    }

    @Test
    public void testParseAdd() throws Exception {
        MultiDocument md = new MultiDocument();
        Document doc = baseDao.find(Document.class, generatedDocIDs.get(0));
        assertNull(doc.getDocumentGroup());
        md.addDocument(doc);
        MultiDocument parsed = multiDocumentParser.parse(md);
        baseDao.update(parsed);
        assertTrue(parsed.getDocuments().size() == 1);
        assertEquals(parsed, parsed.getDocuments().iterator().next().getDocumentGroup());
        assertFalse(parsed.getDocuments().iterator().next().isTemporal());
        assertNotNull(baseDao.find(Document.class, generatedDocIDs.get(0)).getDocumentGroup());
    }
View Full Code Here

        assertNotNull(baseDao.find(Document.class, generatedDocIDs.get(0)).getDocumentGroup());
    }

    @Test
    public void testParseModify() throws Exception {
        MultiDocument bmd = baseDao.first(MultiDocument.class);
        MultiDocument md = new MultiDocument();
        md.setId(bmd.getId());
        for (Document doc : bmd.getDocuments()) {
            Document ndoc = new Document();
            ndoc.setId(doc.getId());
            ndoc.setIdentifier(doc.getIdentifier());
            md.addDocument(ndoc);
        }
        Document mod = md.getDocuments().iterator().next();
        mod.setIdentifier("newimageid");
        MultiDocument parsed = multiDocumentParser.parse(md);
        baseDao.update(parsed);
        assertEquals(md, parsed);
        for (Document d : parsed.getDocuments())
            if (d.getId().equals(mod.getId()))
                assertEquals("newimageid", d.getIdentifier());
    }
View Full Code Here

                assertEquals("newimageid", d.getIdentifier());
    }

    @Test
    public void testParseRemove() throws Exception {
        MultiDocument bmd = baseDao.first(MultiDocument.class);
        int size = bmd.getDocuments().size() - 1;
        MultiDocument md = new MultiDocument();
        md.setId(bmd.getId());
        boolean add = false;
        for (Document doc : bmd.getDocuments()) {
            if (add) {
                Document ndoc = new Document();
                ndoc.setTemporal(true);
                ndoc.setId(doc.getId());
                ndoc.setIdentifier(doc.getIdentifier());
                md.addDocument(ndoc);
            } else add = true;
        }
        MultiDocument parsed = multiDocumentParser.parse(md);
        baseDao.update(parsed);
        assertFalse(CollectionUtils.isEmpty(parsed.getDocuments()));
        assertTrue(parsed.getDocuments().size() == size);
        assertTrue(parsed.getDocuments().iterator().next().getHeight() == 1);
        assertFalse(parsed.getDocuments().iterator().next().isTemporal());
    }
View Full Code Here

        assertFalse(parsed.getDocuments().iterator().next().isTemporal());
    }

    @Test
    public void testParseComplete() throws Exception {
        MultiDocument bmd = baseDao.first(MultiDocument.class);
        MultiDocument md = new MultiDocument();
        md.setId(bmd.getId());
        Iterator<Document> it = bmd.getDocuments().iterator();
        it.next();
        Document d = it.next();
        md.addDocument(d);
        md.addDocument(it.next());
        d.setIdentifier("newimageid");
        Document ndoc = baseDao.find(Document.class, generatedDocIDs.get(0));
        assertNull(ndoc.getDocumentGroup());
        md.addDocument(ndoc);
        MultiDocument parsed = multiDocumentParser.parse(md);
        baseDao.update(parsed);
        assertTrue(parsed.getDocuments().size() == 3);
        for (Document pdoc : parsed.getDocuments())
            if (pdoc.getId().equals(d.getId()))
                assertEquals("newimageid", pdoc.getIdentifier());
    }
View Full Code Here

    }

    @Test
    public void testParseComplicated() throws Exception {
        SimpleEntity entity = baseDao.first(SimpleEntity.class);
        MultiDocument bmd = entity.getPhotos();
        assertTrue(bmd.getDocuments().size() == 4);
        MultiDocument md = new MultiDocument();
        md.setId(bmd.getId());
        md.addDocument(new Document());
        md.getDocuments().iterator().next().setId(bmd.getDocuments().iterator().next().getId());
        Document doc2 = new Document();
        doc2.setTemporal(false);
        doc2.setIdentifier("void image");
        doc2.setWidth(1);
        doc2.setHeight(1);
        doc2.setCreation(new Date());
        doc2.setMimeType("image/gif");
        doc2.setAuthor((UserImpl) securityDAO.findUser("adminuser"));
        doc2.setContents(FileCopyUtils.copyToByteArray(getClass().getResourceAsStream("/void.gif")));
        md.addDocument(doc2);
        Document doc = baseDao.find(Document.class, generatedDocIDs.get(0));
        assertNull(doc.getDocumentGroup());
        Document t = new Document();
        t.setId(doc.getId());
        md.addDocument(t);
        entity.setPhotos(multiDocumentParser.parse(md));
        baseDao.update(entity);
        assertTrue(entity.getPhotos().getDocuments().size() == 2);
    }
View Full Code Here

            List<Sex> sex = dao.findByNamedQuery("Sex.findAll", 0, 2, null);
            Person m = new Person();
            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);
View Full Code Here

    @Override public MultiDocument parse(MultiDocument up) {
        if (up != null) {
            purge(up);
            if (CollectionUtils.isEmpty(up.getDocuments())) {
                if (up.getId() != null) {
                    MultiDocument old = getDao().find(MultiDocument.class, up.getId());
                    old.removeAll();
                    getDao().remove(old);
                }
                return null;
            } else {
                UUID id = up.getId();
                if (id != null) {
                    MultiDocument old = getDao().find(MultiDocument.class, id);
                    old.removeAll();
                    for (Document doc : up.getDocuments()) {
                        Document parsed = documentParser.parse(doc);
                        parsed.setDocumentGroup(old);
                        old.addDocument(parsed);
                    }
                    if (old.getDocuments().size() == 0) {
                        getDao().remove(old);
                        return null;
                    }
                    return old;
                }
View Full Code Here

TOP

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

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.