Package org.apache.art

Examples of org.apache.art.Artist


        // fetch updated artist into the new context, and see if the original
        // one gets updated
        Expression qual = ExpressionFactory.matchExp("artistName", newName);
        List artists = altContext.performQuery(new SelectQuery(Artist.class, qual));
        assertEquals(1, artists.size());
        Artist altArtist = (Artist) artists.get(0);

        // check underlying cache
        DataRow freshSnapshot = context
                .getObjectStore()
                .getDataRowCache()
                .getCachedSnapshot(altArtist.getObjectId());
        assertNotNull(freshSnapshot);
        assertEquals(newName, freshSnapshot.get("ARTIST_NAME"));

        // check both artists
        assertEquals(newName, altArtist.getArtistName());

        ThreadedTestHelper helper = new ThreadedTestHelper() {

            @Override
            protected void assertResult() throws Exception {
View Full Code Here


        DataContext altContext = mirrorDataContext(context);

        // make sure we have a fully resolved copy of an artist object
        // in the second context
        final Artist altArtist = (Artist) altContext.getGraphManager().getNode(
                artist.getObjectId());
        assertNotNull(altArtist);
        assertFalse(altArtist == artist);
        assertEquals(originalName, altArtist.getArtistName());
        assertEquals(PersistenceState.COMMITTED, altArtist.getPersistenceState());

        // Update Artist
        artist.setArtistName(newName);

        // no changes propagated till commit...
        assertEquals(originalName, altArtist.getArtistName());
        context.commitChanges();

        // check underlying cache
        DataRow freshSnapshot = context
                .getObjectStore()
                .getDataRowCache()
                .getCachedSnapshot(altArtist.getObjectId());
        assertEquals(newName, freshSnapshot.get("ARTIST_NAME"));

        // check peer artist
        ThreadedTestHelper helper = new ThreadedTestHelper() {

            @Override
            protected void assertResult() throws Exception {
                assertEquals(newName, altArtist.getArtistName());
            }
        };
        helper.assertWithTimeout(3000);
    }
View Full Code Here

        DataContext altContext = mirrorDataContext(context);

        // make sure we have a fully resolved copy of an artist object
        // in the second context
        final Artist altArtist = (Artist) altContext.getGraphManager().getNode(
                artist.getObjectId());
        assertNotNull(altArtist);
        assertFalse(altArtist == artist);
        assertEquals(originalName, altArtist.getArtistName());
        assertEquals(PersistenceState.COMMITTED, altArtist.getPersistenceState());

        // Update Artist peers independently
        artist.setArtistName(newName);
        artist.setDateOfBirth(newDate);
        altArtist.setArtistName(newAltName);

        context.commitChanges();

        // check underlying cache
        DataRow freshSnapshot = context
                .getObjectStore()
                .getDataRowCache()
                .getCachedSnapshot(altArtist.getObjectId());
        assertEquals(newName, freshSnapshot.get("ARTIST_NAME"));
        assertEquals(newDate, freshSnapshot.get("DATE_OF_BIRTH"));

        // check peer artist
        ThreadedTestHelper helper = new ThreadedTestHelper() {

            @Override
            protected void assertResult() throws Exception {
                assertEquals(newAltName, altArtist.getArtistName());
                assertEquals(newDate, altArtist.getDateOfBirth());
                assertEquals(PersistenceState.MODIFIED, altArtist.getPersistenceState());
            }
        };
        helper.assertWithTimeout(3000);

    }
View Full Code Here

        DataContext altContext = mirrorDataContext(context);

        // make sure we have a fully resolved copy of an artist object
        // in the second context
        final Artist altArtist = (Artist) altContext.getGraphManager().getNode(
                artist.getObjectId());
        assertNotNull(altArtist);
        assertFalse(altArtist == artist);
        assertEquals(artist.getArtistName(), altArtist.getArtistName());
        assertEquals(PersistenceState.COMMITTED, altArtist.getPersistenceState());

        // Update Artist
        context.deleteObject(artist);
        context.commitChanges();

        // check underlying cache
        assertNull(context.getObjectStore().getDataRowCache().getCachedSnapshot(
                altArtist.getObjectId()));

        // check peer artist
        ThreadedTestHelper helper = new ThreadedTestHelper() {

            @Override
            protected void assertResult() throws Exception {
                assertEquals(PersistenceState.TRANSIENT, altArtist.getPersistenceState());
                assertNull(altArtist.getObjectContext());
            }
        };
        helper.assertWithTimeout(3000);
    }
View Full Code Here

        DataContext altContext = mirrorDataContext(context);

        // make sure we have a fully resolved copy of an artist object
        // in the second context
        final Artist altArtist = (Artist) altContext.getGraphManager().getNode(
                artist.getObjectId());
        assertNotNull(altArtist);
        assertFalse(altArtist == artist);
        assertEquals(PersistenceState.HOLLOW, altArtist.getPersistenceState());

        // Update Artist
        context.deleteObject(artist);
        context.commitChanges();

        // check underlying cache
        assertNull(context.getObjectStore().getDataRowCache().getCachedSnapshot(
                altArtist.getObjectId()));

        // check peer artist
        ThreadedTestHelper helper = new ThreadedTestHelper() {

            @Override
            protected void assertResult() throws Exception {
                assertEquals(PersistenceState.TRANSIENT, altArtist.getPersistenceState());
                assertNull(altArtist.getObjectContext());
            }
        };
        helper.assertWithTimeout(3000);
    }
View Full Code Here

        DataContext altContext = mirrorDataContext(context);

        // make sure we have a fully resolved copy of an artist object
        // in the second context
        final Artist altArtist = (Artist) altContext.getGraphManager().getNode(
                artist.getObjectId());
        assertNotNull(altArtist);
        assertFalse(altArtist == artist);

        // modify peer
        altArtist.setArtistName("version2");
        assertEquals(PersistenceState.MODIFIED, altArtist.getPersistenceState());

        // Update Artist
        context.deleteObject(artist);
        context.commitChanges();

        // check underlying cache
        assertNull(context.getObjectStore().getDataRowCache().getCachedSnapshot(
                altArtist.getObjectId()));

        // check peer artist
        ThreadedTestHelper helper = new ThreadedTestHelper() {

            @Override
            protected void assertResult() throws Exception {
                assertEquals(PersistenceState.NEW, altArtist.getPersistenceState());
            }
        };
        helper.assertWithTimeout(3000);

        // check if now we can save this object again, and with the original
        // ObjectId
        ObjectId id = altArtist.getObjectId();
        assertNotNull(id);
        assertNotNull(id.getIdSnapshot().get(Artist.ARTIST_ID_PK_COLUMN));
        assertFalse(id.isTemporary());

        altContext.commitChanges();

        assertEquals(PersistenceState.COMMITTED, altArtist.getPersistenceState());

        // create independent context and fetch artist in it
        DataContext context3 = getDomain().createDataContext(false);
        List artists = context3.performQuery(new ObjectIdQuery(id));
        assertEquals(1, artists.size());
        Artist artist3 = (Artist) artists.get(0);
        assertEquals(id, artist3.getObjectId());
    }
View Full Code Here

        DataContext altContext = mirrorDataContext(context);

        // make sure we have a fully resolved copy of an artist object
        // in the second context
        final Artist altArtist = (Artist) altContext.getGraphManager().getNode(
                artist.getObjectId());
        assertNotNull(altArtist);
        assertFalse(altArtist == artist);

        // delete peer
        altContext.deleteObject(altArtist);

        // Update Artist
        context.deleteObject(artist);
        context.commitChanges();

        // check underlying cache
        assertNull(context.getObjectStore().getDataRowCache().getCachedSnapshot(
                altArtist.getObjectId()));

        // check peer artist
        ThreadedTestHelper helper = new ThreadedTestHelper() {

            @Override
            protected void assertResult() throws Exception {
                assertEquals(PersistenceState.TRANSIENT, altArtist.getPersistenceState());
                assertNull(altArtist.getObjectContext());
            }
        };
        helper.assertWithTimeout(3000);

        assertFalse(altContext.hasChanges());
View Full Code Here

        // make sure we have a fully resolved copy of an artist and painting
        // objects
        // in the second context

        final Artist altArtist = (Artist) altContext.getGraphManager().getNode(
                artist.getObjectId());
        final Painting altPainting1 = (Painting) altContext.getGraphManager().getNode(
                painting1.getObjectId());
        final Painting altPainting2 = (Painting) altContext.getGraphManager().getNode(
                painting2.getObjectId());

        assertEquals(artist.getArtistName(), altArtist.getArtistName());
        assertEquals(painting1.getPaintingTitle(), altPainting1.getPaintingTitle());
        assertEquals(painting2.getPaintingTitle(), altPainting2.getPaintingTitle());
        assertEquals(2, altArtist.getPaintingArray().size());
        assertEquals(PersistenceState.COMMITTED, altArtist.getPersistenceState());
        assertEquals(PersistenceState.COMMITTED, altPainting1.getPersistenceState());
        assertEquals(PersistenceState.COMMITTED, altPainting2.getPersistenceState());

        // make sure toOne relationships from Paintings
        // are resolved...
        altPainting1.getToArtist();
        altPainting2.getToArtist();
        assertSame(altArtist, altPainting1.readPropertyDirectly("toArtist"));
        assertSame(altArtist, altPainting2.readPropertyDirectly("toArtist"));

        // delete painting
        context.deleteObject(painting1);
        context.commitChanges();

        // check underlying cache
        assertNull(context.getObjectStore().getDataRowCache().getCachedSnapshot(
                painting1.getObjectId()));

        // check peer artist
        ThreadedTestHelper helper = new ThreadedTestHelper() {

            @Override
            protected void assertResult() throws Exception {
                assertEquals(PersistenceState.TRANSIENT, altPainting1
                        .getPersistenceState());
                assertEquals(PersistenceState.COMMITTED, altArtist.getPersistenceState());

                Collection list = altArtist.getPaintingArray();
                assertEquals(1, list.size());
                assertFalse(list.contains(altPainting1));
            }
        };
        helper.assertWithTimeout(3000);
View Full Code Here

        // make sure we have a fully resolved copy of an artist and painting
        // objects
        // in the second context

        final Artist altArtist = (Artist) altContext.getGraphManager().getNode(
                artist.getObjectId());
        final Painting altPainting1 = (Painting) altContext.getGraphManager().getNode(
                painting1.getObjectId());

        assertEquals(artist.getArtistName(), altArtist.getArtistName());
        assertEquals(painting1.getPaintingTitle(), altPainting1.getPaintingTitle());
        assertEquals(1, altArtist.getPaintingArray().size());
        assertEquals(PersistenceState.COMMITTED, altArtist.getPersistenceState());
        assertEquals(PersistenceState.COMMITTED, altPainting1.getPersistenceState());

        // insert new painting and add to artist
        Painting painting2 = (Painting) context.newObject("Painting");
        painting2.setPaintingTitle("p2");
        painting2.setToArtist(artist);
        context.commitChanges();

        // check peer artist

        // use threaded helper as a barrier, to avoid triggering faults earlier than
        // needed
        ThreadedTestHelper helper = new ThreadedTestHelper() {

            @Override
            protected void assertResult() throws Exception {
                Object value = altArtist.readPropertyDirectly("paintingArray");
                assertTrue("Unexpected: " + value, value instanceof ToManyList);
                assertTrue(((ToManyList) value).isFault());
            }
        };
        helper.assertWithTimeout(2000);
        List list = altArtist.getPaintingArray();
        assertEquals(2, list.size());
    }
View Full Code Here

        // create alternative context
        final DataContext altContext = mirrorDataContext(context);

        // make sure we have a fully resolved copy of an artist object
        // in the second context
        final Artist altArtist = (Artist) altContext.getGraphManager().getNode(
                artist.getObjectId());
        altContext.prepareForAccess(altArtist, null, false);
        assertEquals(PersistenceState.COMMITTED, altArtist.getPersistenceState());

        context.invalidateObjects(Collections.singletonList(artist));

        // original context
        assertEquals(PersistenceState.HOLLOW, artist.getPersistenceState());
        assertNull(context.getObjectStore().getDataRowCache().getCachedSnapshot(
                artist.getObjectId()));

        // alternate context
        new ThreadedTestHelper() {

            @Override
            protected void assertResult() throws Exception {
                assertEquals(PersistenceState.HOLLOW, altArtist.getPersistenceState());
                assertNull(altContext
                        .getObjectStore()
                        .getDataRowCache()
                        .getCachedSnapshot(altArtist.getObjectId()));
            }
        }.assertWithTimeout(5000);

        // resolve object
        assertEquals(originalName, altArtist.getArtistName());
        DataRow altFreshSnapshot = altContext
                .getObjectStore()
                .getDataRowCache()
                .getCachedSnapshot(altArtist.getObjectId());
        assertNotNull(altFreshSnapshot);
        assertEquals(originalName, altFreshSnapshot.get("ARTIST_NAME"));

    }
View Full Code Here

TOP

Related Classes of org.apache.art.Artist

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.