Package org.apache.art

Examples of org.apache.art.Painting


        query.addOrdering(Painting.PAINTING_TITLE_PROPERTY, true);
        List objects = childContext.performQuery(query);

        assertEquals(6, objects.size());

        Painting childModifiedSimple = (Painting) objects.get(0);
        childModifiedSimple.setPaintingTitle("C_PT");

        Painting childModifiedToOne = (Painting) objects.get(1);
        childModifiedToOne.setToArtist(childModifiedSimple.getToArtist());

        Artist childModifiedToMany = ((Painting) objects.get(2)).getToArtist();

        // ensure painting array is fully resolved...
        childModifiedToMany.getPaintingArray().size();
        childModifiedToMany.addToPaintingArray((Painting) objects.get(3));

        blockQueries();

        Painting parentModifiedSimple = null;
        Artist parentModifiedToMany = null;
        try {

            childContext.commitChangesToParent();

            assertEquals(PersistenceState.COMMITTED, childModifiedSimple
                    .getPersistenceState());
            assertEquals(PersistenceState.COMMITTED, childModifiedToOne
                    .getPersistenceState());
            assertEquals(PersistenceState.COMMITTED, childModifiedToMany
                    .getPersistenceState());

            parentModifiedSimple = (Painting) context.getGraphManager().getNode(
                    childModifiedSimple.getObjectId());

            Painting parentModifiedToOne = (Painting) context.getGraphManager().getNode(
                    childModifiedToOne.getObjectId());

            parentModifiedToMany = (Artist) context.getGraphManager().getNode(
                    childModifiedToMany.getObjectId());

            assertNotNull(parentModifiedSimple);
            assertEquals(PersistenceState.MODIFIED, parentModifiedSimple
                    .getPersistenceState());
            assertEquals("C_PT", parentModifiedSimple.getPaintingTitle());
            assertNotNull(context.getObjectStore().getChangesByObjectId().get(
                    parentModifiedSimple.getObjectId()));

            assertNotNull(parentModifiedToOne);
            assertEquals(PersistenceState.MODIFIED, parentModifiedToOne
                    .getPersistenceState());
            assertNotNull(parentModifiedToOne.getToArtist());
            assertEquals(33001, DataObjectUtils.intPKForObject(parentModifiedToOne
                    .getToArtist()));
            assertNotNull(context.getObjectStore().getChangesByObjectId().get(
                    parentModifiedToOne.getObjectId()));

            // indirectly modified....
            assertNotNull(parentModifiedToMany);
            assertEquals(PersistenceState.MODIFIED, parentModifiedToMany
                    .getPersistenceState());
View Full Code Here


        deleteTestData();

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

        Painting childMaster = childContext.newObject(Painting.class);
        childMaster.setPaintingTitle("Master");

        PaintingInfo childDetail1 = childContext.newObject(PaintingInfo.class);
        childDetail1.setTextReview("Detail1");
        childDetail1.setPainting(childMaster);

        try {
            childContext.commitChangesToParent();

            assertEquals(PersistenceState.COMMITTED, childMaster.getPersistenceState());
            assertEquals(PersistenceState.COMMITTED, childDetail1.getPersistenceState());

            Painting parentMaster = (Painting) context.getGraphManager().getNode(
                    childMaster.getObjectId());

            assertNotNull(parentMaster);
            assertEquals(PersistenceState.NEW, parentMaster.getPersistenceState());

            PaintingInfo parentDetail1 = (PaintingInfo) context
                    .getGraphManager()
                    .getNode(childDetail1.getObjectId());

            assertNotNull(parentDetail1);
            assertEquals(PersistenceState.NEW, parentDetail1.getPersistenceState());

            assertSame(parentMaster, parentDetail1.getPainting());
            assertSame(parentDetail1, parentMaster.getToPaintingInfo());
        }
        finally {
            unblockQueries();
        }
    }
View Full Code Here

        deleteTestData();
        createTestData("testPhantomModificationsValidateToOne");
        DataContext context = createDataContext();

        List objects = context.performQuery(new SelectQuery(Painting.class));
        Painting p1 = (Painting) objects.get(0);

        p1.setPaintingTitle(p1.getPaintingTitle());
        p1.resetValidationFlags();
        context.commitChanges();

        assertFalse("To-one relationship presence caused incorrect validation call.", p1
                .isValidateForSaveCalled());
    }
View Full Code Here

        DataContext context = createDataContext();

        List objects = context.performQuery(new SelectQuery(Artist.class));
        Artist a1 = (Artist) objects.get(0);

        Painting p1 = context.newObject(Painting.class);
        p1.setPaintingTitle("XXX");
        a1.addToPaintingArray(p1);
        a1.resetValidationFlags();
        context.commitChanges();

        assertFalse(a1.isValidateForSaveCalled());
View Full Code Here

        SelectQuery query = new SelectQuery(Painting.class);
        List objects = context.performQuery(query);
        assertEquals(1, objects.size());

        Painting p1 = (Painting) objects.get(0);

        Artist oldArtist = p1.getToArtist();
        Artist newArtist = DataObjectUtils.objectForPK(
                context,
                Artist.class,
                33002);

        assertNotSame(oldArtist, newArtist);

        p1.setToArtist(newArtist);
        p1.setToArtist(oldArtist);

        context.commitChanges();

        assertEquals(PersistenceState.COMMITTED, p1.getPersistenceState());
        assertEquals(PersistenceState.COMMITTED, oldArtist.getPersistenceState());
        assertEquals(PersistenceState.COMMITTED, newArtist.getPersistenceState());
    }
View Full Code Here

        SelectQuery query = new SelectQuery(Painting.class);
        List objects = context.performQuery(query);
        assertEquals(1, objects.size());

        Painting p1 = (Painting) objects.get(0);

        Artist oldArtist = p1.getToArtist();
        Artist newArtist = DataObjectUtils.objectForPK(
                context,
                Artist.class,
                33002);

        assertNotSame(oldArtist, newArtist);

        p1.setToArtist(newArtist);
        p1.setToArtist(oldArtist);

        p1.resetValidationFlags();
        context.commitChanges();
        assertFalse(p1.isValidateForSaveCalled());
    }
View Full Code Here

       
        DataDomain domain = getDomain();
       
        ObjectContext context = createDataContext();
       
        Painting p = context.newObject(Painting.class);
        p.setPaintingTitle("sample");
       
        SelectQuery query = new SelectQuery(Painting.class);
       
        query.addPrefetch(Painting.TO_GALLERY_PROPERTY);
        query.addPrefetch(Painting.TO_ARTIST_PROPERTY);
View Full Code Here

        a1.setArtistName("a1");

        Artist a2 = context.newObject(Artist.class);
        a2.setArtistName("a2");

        Painting p12 = context.newObject(Painting.class);
        p12.setPaintingTitle("p12");
        a2.addToPaintingArray(p12);
        Painting p22 = context.newObject(Painting.class);
        p22.setPaintingTitle("p22");
        a2.addToPaintingArray(p22);

        context.commitChanges();

        EJBQLQuery query = new EJBQLQuery(
View Full Code Here

        diff.apply(diffChecker);
        assertEquals(1, diffChecker.getCallbackCount());
        assertSame(a.getObjectId(), newIds[0]);
       
        // commit a mix of new and modified
        Painting p = context.newObject(Painting.class);
        p.setPaintingTitle("PT");
        p.setToArtist(a);
        a.setArtistName(a.getArtistName() + "_");
       
        GraphDiff diff2 = context.flushToParent(true);
        assertNotNull(diff2);
        assertFalse(context.hasChanges());

        final Object[] newIds2 = new Object[1];

        MockGraphChangeHandler diffChecker2 = new MockGraphChangeHandler() {

            @Override
            public void nodeIdChanged(Object nodeId, Object newId) {
                super.nodeIdChanged(nodeId, newId);

                newIds2[0] = newId;
            }
        };

        diff2.apply(diffChecker2);
        assertEquals(1, diffChecker2.getCallbackCount());
        assertSame(p.getObjectId(), newIds2[0]);
    }
View Full Code Here

        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

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.