Package org.richfaces.photoalbum.model

Examples of org.richfaces.photoalbum.model.MetaTag


                    }
                }

                for (String s : toks) {
                    // Find metatag in early associated tags
                    MetaTag t = image.getTagByName(s);

                    // Find metatag in database
                    t = getTagByName(s);
                    if (t != null) {
                        // If found simple add reference to it
                        image.addMetaTag(t);
                    } else {
                        // Create new metatag
                        t = new MetaTag();
                        t.setTag(s);
                        image.addMetaTag(t);
                        // Persist to database to prevent concurrent creation of other metatags with given name
                        em.persist(t);
                    }
                }
View Full Code Here


     *
     * @param tag - string representation of metatag
     * @return metatag object or null
     */
    public MetaTag getTagByName(String tag) {
        final MetaTag t;
        try {
            t = (MetaTag) em.createNamedQuery(Constants.TAG_BY_NAME_QUERY).setParameter(Constants.TAG_PARAMETER, tag)
                .getSingleResult();
        } catch (NoResultException nre) {
            // If not found
View Full Code Here

    private void insertData() throws Exception {
        utx.begin();
        em.joinTransaction();
        System.out.println("Inserting records...");
        for (String tag : TAG_NAMES) {
            MetaTag m = new MetaTag();
            m.setTag(tag);
            em.persist(m);
        }
        utx.commit();
        // clear the persistence context (first-level cache)
        em.clear();
View Full Code Here

    @Test
    public void isImageEditedWithMetaTags() throws Exception {
        Image image = helper.getAllImages(em).get(0);
        List<MetaTag> tags = image.getImageTags();
        MetaTag removedTag = tags.get(0);

        String metaTagsByImageId = "select m from MetaTag m join m.images i where i.id = :id";
        List<MetaTag> _tagsById = em.createQuery(metaTagsByImageId, MetaTag.class).setParameter("id", image.getId())
            .getResultList();

        Assert.assertTrue(_tagsById.contains(removedTag));
        Assert.assertTrue(removedTag.getImages().contains(image));

        tags.remove(0);
        Assert.assertFalse(tags.contains(removedTag));

        removedTag.removeImage(image);
        Assert.assertFalse(removedTag.getImages().contains(image));
        image.setImageTags(tags);

        ia.editImage(image, true);

        List<MetaTag> tagsById = em.createQuery(metaTagsByImageId, MetaTag.class).setParameter("id", image.getId())
            .getResultList();

        Image editedImage = helper.getAllImages(em).get(0);

        String tagById = "select m from MetaTag m where id = :id";
        MetaTag m = em.createQuery(tagById, MetaTag.class).setParameter("id", removedTag.getId()).getSingleResult();

        Assert.assertFalse(tagsById.contains(removedTag));
        Assert.assertFalse(m.getImages().contains(editedImage));
    }
View Full Code Here

        Assert.assertEquals(2, ia.getCountIdenticalImages(image.getAlbum(), image.getPath()).intValue());
    }

    @Test
    public void isMetaTagFoundByName() throws Exception {
        MetaTag tag = helper.getAllMetaTags(em).get(0);

        Assert.assertEquals(tag, ia.getTagByName(tag.getTag()));

        Assert.assertNull(ia.getTagByName("*" + tag.getTag()));
    }
View Full Code Here

        Assert.assertNull(ia.getTagByName("*" + tag.getTag()));
    }

    @Test
    public void areTagsSuggested() throws Exception {
        MetaTag tag = helper.getAllMetaTags(em).get(0);
        String tagName = tag.getTag();

        String[] parts = { tagName.substring(0, 4), tagName.substring(5) };

        List<MetaTag> suggestedTags = ia.getTagsLikeString(parts[0]);
        Assert.assertTrue("suggestion for '" + parts[0] + "'", suggestedTags.contains(tag));
View Full Code Here

TOP

Related Classes of org.richfaces.photoalbum.model.MetaTag

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.