Package org.apache.art

Examples of org.apache.art.Painting


        try {
            assertEquals(3, objects.size());

            Iterator it = objects.iterator();
            while (it.hasNext()) {
                Painting p = (Painting) it.next();
                Artist a = p.getToArtist();
                assertEquals(PersistenceState.COMMITTED, a.getPersistenceState());

                List list = a.getGroupArray();
                assertNotNull(list);
                assertFalse("artist's groups not resolved: " + a, ((ValueHolder) list).isFault());
View Full Code Here


        SelectQuery q = new SelectQuery(Painting.class);
        q.addOrdering("db:PAINTING_ID", true);
        List paints = context.performQuery(q);

        Painting p1 = (Painting) paints.get(0);
        Painting p2 = (Painting) paints.get(1);

        Artist a1 = p1.getToArtist();
        assertSame(a1, p2.getToArtist());

        assertNotNull(context
                .getParentDataDomain()
                .getSharedSnapshotCache()
                .getCachedSnapshot(p1.getObjectId()));
        assertNotNull(context
                .getParentDataDomain()
                .getSharedSnapshotCache()
                .getCachedSnapshot(p2.getObjectId()));

        createTestData("testRefreshCollectionToOneUpdate");

        RefreshQuery refresh = new RefreshQuery(paints);
        context.performQuery(refresh);

        assertNull(context
                .getParentDataDomain()
                .getSharedSnapshotCache()
                .getCachedSnapshot(p1.getObjectId()));
        assertNull(context
                .getParentDataDomain()
                .getSharedSnapshotCache()
                .getCachedSnapshot(p2.getObjectId()));

        assertEquals(PersistenceState.HOLLOW, p1.getPersistenceState());
        assertEquals(PersistenceState.HOLLOW, p2.getPersistenceState());

        assertNotSame(a1, p1.getToArtist());
        assertNotSame(a1, p2.getToArtist());
        assertEquals("b", p1.getToArtist().getArtistName());
    }
View Full Code Here

        q.setCachePolicy(QueryMetadata.LOCAL_CACHE);
        q.setCacheGroups("X");
        List paints = context.performQuery(q);

        // fetch P1 separately from cached query
        Painting p1 = DataObjectUtils.objectForPK(context, Painting.class, 33001);

        Painting p2 = (Painting) paints.get(0);
        Artist a1 = p2.getToArtist();
        assertSame(a1, p1.getToArtist());

        assertNotNull(context
                .getParentDataDomain()
                .getSharedSnapshotCache()
                .getCachedSnapshot(p1.getObjectId()));

        assertNotNull(context
                .getParentDataDomain()
                .getSharedSnapshotCache()
                .getCachedSnapshot(p2.getObjectId()));

        createTestData("testRefreshCollectionToOneUpdate");

        RefreshQuery refresh = new RefreshQuery(q);
        context.performQuery(refresh);

        assertNotNull(context
                .getParentDataDomain()
                .getSharedSnapshotCache()
                .getCachedSnapshot(p1.getObjectId()));

        // probably refreshed eagerly
        assertNotNull(context
                .getParentDataDomain()
                .getSharedSnapshotCache()
                .getCachedSnapshot(p2.getObjectId()));

        assertEquals(PersistenceState.COMMITTED, p1.getPersistenceState());
        assertEquals(PersistenceState.COMMITTED, p2.getPersistenceState());

        assertSame(a1, p1.getToArtist());
        assertNotSame(a1, p2.getToArtist());
        assertEquals("c", p1.getToArtist().getArtistName());
        assertEquals("b", p2.getToArtist().getArtistName());
    }
View Full Code Here

        q.setCachePolicy(QueryMetadata.SHARED_CACHE);
        q.setCacheGroups("X");
        List paints = context.performQuery(q);

        // fetch P1 separately from cached query
        Painting p1 = DataObjectUtils.objectForPK(context, Painting.class, 33001);

        Painting p2 = (Painting) paints.get(0);
        Artist a1 = p2.getToArtist();
        assertSame(a1, p1.getToArtist());

        assertNotNull(context
                .getParentDataDomain()
                .getSharedSnapshotCache()
                .getCachedSnapshot(p1.getObjectId()));

        assertNotNull(context
                .getParentDataDomain()
                .getSharedSnapshotCache()
                .getCachedSnapshot(p2.getObjectId()));

        createTestData("testRefreshCollectionToOneUpdate");

        RefreshQuery refresh = new RefreshQuery(q);
        context.performQuery(refresh);

        assertNotNull(context
                .getParentDataDomain()
                .getSharedSnapshotCache()
                .getCachedSnapshot(p1.getObjectId()));

        // probably refreshed eagerly
        assertNotNull(context
                .getParentDataDomain()
                .getSharedSnapshotCache()
                .getCachedSnapshot(p2.getObjectId()));

        assertEquals(PersistenceState.COMMITTED, p1.getPersistenceState());
        assertEquals(PersistenceState.COMMITTED, p2.getPersistenceState());

        assertSame(a1, p1.getToArtist());
        assertNotSame(a1, p2.getToArtist());
        assertEquals("c", p1.getToArtist().getArtistName());
        assertEquals("b", p2.getToArtist().getArtistName());
    }
View Full Code Here

        q.setCachePolicy(QueryMetadata.LOCAL_CACHE);
        q.setCacheGroups("X");
        List paints = context.performQuery(q);

        // fetch P1 separately from cached query
        Painting p1 = DataObjectUtils.objectForPK(context, Painting.class, 33001);

        Painting p2 = (Painting) paints.get(0);
        Artist a1 = p2.getToArtist();
        assertSame(a1, p1.getToArtist());

        assertNotNull(context
                .getParentDataDomain()
                .getSharedSnapshotCache()
                .getCachedSnapshot(p1.getObjectId()));

        assertNotNull(context
                .getParentDataDomain()
                .getSharedSnapshotCache()
                .getCachedSnapshot(p2.getObjectId()));

        createTestData("testRefreshCollectionToOneUpdate");

        // results are served from cache and therefore are not refreshed
        context.performQuery(q);
        assertSame(a1, p1.getToArtist());
        assertSame(a1, p2.getToArtist());
        assertEquals("c", p1.getToArtist().getArtistName());
        assertEquals("c", p2.getToArtist().getArtistName());

        RefreshQuery refresh = new RefreshQuery("X");

        // this should invalidate results for the next query run
        context.performQuery(refresh);

        // this should force a refresh
        context.performQuery(q);

        assertEquals(PersistenceState.COMMITTED, p1.getPersistenceState());
        assertEquals(PersistenceState.COMMITTED, p2.getPersistenceState());

        assertSame(a1, p1.getToArtist());
        assertNotSame(a1, p2.getToArtist());
        assertEquals("c", p1.getToArtist().getArtistName());
        assertEquals("b", p2.getToArtist().getArtistName());
    }
View Full Code Here

        q.addOrdering("db:ARTIST_ID", true);
        List artists = context.performQuery(q);

        Artist a1 = (Artist) artists.get(0);
        Artist a2 = (Artist) artists.get(1);
        Painting p1 = a1.getPaintingArray().get(0);
        Painting p2 = a1.getPaintingArray().get(0);

        assertNotNull(context
                .getParentDataDomain()
                .getSharedSnapshotCache()
                .getCachedSnapshot(a1.getObjectId()));
        assertNotNull(context
                .getParentDataDomain()
                .getSharedSnapshotCache()
                .getCachedSnapshot(a2.getObjectId()));
        assertNotNull(context
                .getParentDataDomain()
                .getSharedSnapshotCache()
                .getCachedSnapshot(p1.getObjectId()));
        assertNotNull(context
                .getParentDataDomain()
                .getSharedSnapshotCache()
                .getCachedSnapshot(p2.getObjectId()));

        RefreshQuery refresh = new RefreshQuery();
        context.performQuery(refresh);

        assertNull(context
                .getParentDataDomain()
                .getSharedSnapshotCache()
                .getCachedSnapshot(a1.getObjectId()));
        assertNull(context
                .getParentDataDomain()
                .getSharedSnapshotCache()
                .getCachedSnapshot(a2.getObjectId()));
        assertNull(context
                .getParentDataDomain()
                .getSharedSnapshotCache()
                .getCachedSnapshot(p1.getObjectId()));
        assertNull(context
                .getParentDataDomain()
                .getSharedSnapshotCache()
                .getCachedSnapshot(p2.getObjectId()));

        assertEquals(PersistenceState.HOLLOW, a1.getPersistenceState());
        assertEquals(PersistenceState.HOLLOW, a2.getPersistenceState());
        assertEquals(PersistenceState.HOLLOW, p1.getPersistenceState());
        assertEquals(PersistenceState.HOLLOW, p2.getPersistenceState());
    }
View Full Code Here

            List toMany = (List) a1.readPropertyDirectly("paintingArray");
            assertNotNull(toMany);
            assertFalse(((ValueHolder) toMany).isFault());
            assertEquals(1, toMany.size());

            Painting p1 = (Painting) toMany.get(0);
            assertEquals("P_" + a1.getArtistName(), p1.getPaintingTitle());

            Artist a2 = (Artist) artists.get(1);
            List toMany2 = (List) a2.readPropertyDirectly("paintingArray");
            assertNotNull(toMany2);
            assertFalse(((ValueHolder) toMany2).isFault());
            assertEquals(1, toMany2.size());

            Painting p2 = (Painting) toMany2.get(0);
            assertEquals("P_" + a2.getArtistName(), p2.getPaintingTitle());
        }
        finally {
            unblockQueries();
        }
    }
View Full Code Here

                List toMany = (List) a.readPropertyDirectly("paintingArray");
                assertNotNull(toMany);
                assertFalse(((ValueHolder) toMany).isFault());
                assertEquals(1, toMany.size());

                Painting p = (Painting) toMany.get(0);
                assertEquals(
                        "Invalid prefetched painting:" + p,
                        "P_" + a.getArtistName(),
                        p.getPaintingTitle());
            }
        }
        finally {
            unblockQueries();
        }
View Full Code Here

        blockQueries();

        try {
            assertEquals(1, results.size());

            Painting painting = (Painting) results.get(0);

            // The parent must be fully fetched, not just HOLLOW (a fault)
            assertEquals(PersistenceState.COMMITTED, painting
                    .getToArtist()
                    .getPersistenceState());
        }
        finally {
            unblockQueries();
View Full Code Here

        try {
            assertEquals(24, paintings.size());

            // see that artists are resolved...

            Painting px = (Painting) paintings.get(3);
            Artist ax = (Artist) px.readProperty(Painting.TO_ARTIST_PROPERTY);
            assertEquals(PersistenceState.COMMITTED, ax.getPersistenceState());
        }
        finally {
            unblockQueries();
        }
View Full Code Here

TOP

Related Classes of org.apache.art.Painting

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.