Package org.apache.art

Examples of org.apache.art.Painting


    protected void createArtist(double paintingPrice) {
        Artist a = ctxt.newObject(Artist.class);
        a.setArtistName("An Artist");

        Painting p = ctxt.newObject(Painting.class);
        p.setPaintingTitle("A Painting");
        // converting double to string prevents rounding weirdness...
        p.setEstimatedPrice(new BigDecimal("" + paintingPrice));
        a.addToPaintingArray(p);

        ctxt.commitChanges();
    }
View Full Code Here


        Artist a = child.newObject(Artist.class);
        a.setArtistName("X");
        child.commitChanges();

        Painting p1 = child.newObject(Painting.class);
        p1.setPaintingTitle("P1");
        a.addToPaintingArray(p1);

        Painting p2 = child.newObject(Painting.class);
        p2.setPaintingTitle("P2");
        a.addToPaintingArray(p2);

        a.removeFromPaintingArray(p2);

        // this causes an error on commit
View Full Code Here

       
        Artist artist = context.newObject(Artist.class);
        artist.setArtistName("111");
        ObjectContext child = context.createChildContext();
       
        Painting painting = child.newObject(Painting.class);
        painting.setPaintingTitle("222");
       
        Artist localParentMt = (Artist) child.localObject(artist.getObjectId(), null);
        assertEquals(0, artist.getPaintingArray().size());
        assertEquals(0, localParentMt.getPaintingArray().size());
       
        painting.setToArtist(localParentMt);
       
        assertEquals(0, artist.getPaintingArray().size());
        assertEquals(1, localParentMt.getPaintingArray().size());
        assertEquals(localParentMt.getPaintingArray().get(0).getObjectContext(), child);
       
View Full Code Here

        assertNotNull(counts);
        assertEquals(1, counts.length);
        assertEquals(1, counts[0]);

        Painting p = (Painting) context.localObject(new ObjectId(
                "Painting",
                Painting.PAINTING_ID_PK_COLUMN,
                512), null);
        assertEquals("No Painting Like This", p.getPaintingTitle());
    }
View Full Code Here

        assertNotNull(counts);
        assertEquals(1, counts.length);
        assertEquals(1, counts[0]);

        Painting p = (Painting) context.localObject(new ObjectId(
                "Painting",
                Painting.PAINTING_ID_PK_COLUMN,
                300), null);
        assertEquals("Go Figure", p.getPaintingTitle());
    }
View Full Code Here

    public void testRollbackNew() {
        Artist artist = (Artist) context.newObject("Artist");
        artist.setArtistName("a");

        Painting p1 = (Painting) context.newObject("Painting");
        p1.setPaintingTitle("p1");
        p1.setToArtist(artist);

        Painting p2 = (Painting) context.newObject("Painting");
        p2.setPaintingTitle("p2");
        p2.setToArtist(artist);

        Painting p3 = (Painting) context.newObject("Painting");
        p3.setPaintingTitle("p3");
        p3.setToArtist(artist);

        // before:
        assertEquals(artist, p1.getToArtist());
        assertEquals(3, artist.getPaintingArray().size());
View Full Code Here

        String artistName = "rollbackTestArtist";
        String paintingTitle = "rollbackTestPainting";
        Artist artist = (Artist) context.newObject("Artist");
        artist.setArtistName(artistName);

        Painting painting = (Painting) context.newObject("Painting");
        painting.setPaintingTitle(paintingTitle);
        painting.setToArtist(artist);

        try {
            context.rollbackChanges();
        }
        catch (Exception e) {
View Full Code Here

    public void testRollbackRelationshipModification() {
        String artistName = "relationshipModArtist";
        String paintingTitle = "relationshipTestPainting";
        Artist artist = (Artist) context.newObject("Artist");
        artist.setArtistName(artistName);
        Painting painting = (Painting) context.newObject("Painting");
        painting.setPaintingTitle(paintingTitle);
        painting.setToArtist(artist);
        context.commitChanges();

        painting.setToArtist(null);
        assertEquals(0, artist.getPaintingArray().size());
        context.rollbackChanges();

        assertTrue(((ValueHolder) artist.getPaintingArray()).isFault());
        assertEquals(1, artist.getPaintingArray().size());
        assertEquals(artist, painting.getToArtist());

        // Check that the reverse relationship was handled
        assertEquals(1, artist.getPaintingArray().size());
        context.commitChanges();

        DataContext freshContext = createDataContext();
        SelectQuery query = new SelectQuery(Painting.class);
        query.setQualifier(ExpressionFactory.matchExp("paintingTitle", paintingTitle));
        List queryResults = freshContext.performQuery(query);

        assertEquals(1, queryResults.size());
        Painting queriedPainting = (Painting) queryResults.get(0);

        // NB: This is an easier comparison than manually fetching artist
        assertEquals(artistName, queriedPainting.getToArtist().getArtistName());
    }
View Full Code Here

        DataContext context = createDataContext();
        ObjectContext childContext = context.createChildContext();

        Artist a = DataObjectUtils.objectForPK(childContext, Artist.class, 33001);
        Painting p = childContext.newObject(Painting.class);
        p.setPaintingTitle("X");
        a.addToPaintingArray(p);

        childContext.commitChangesToParent();

        childContext.deleteObject(p);
View Full Code Here

        DataContext context = createDataContext();
        ObjectContext childContext = context.createChildContext();
        ObjectContext childContextPeer = context.createChildContext();

        Painting childP1 = DataObjectUtils.objectForPK(
                childContext,
                Painting.class,
                33001);

        // trigger object creation in the peer nested DC
        DataObjectUtils.objectForPK(childContextPeer, Painting.class, 33001);
        childP1.setToArtist(null);

        blockQueries();

        try {
            childContext.commitChangesToParent();
            assertEquals(PersistenceState.COMMITTED, childP1.getPersistenceState());

            Painting parentP1 = (Painting) context.getGraphManager().getNode(
                    childP1.getObjectId());

            assertNotNull(parentP1);
            assertEquals(PersistenceState.MODIFIED, parentP1.getPersistenceState());
            assertNull(parentP1.getToArtist());
        }
        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.