Hi,

I'm working with composed beans: parent bean have several versions,  child
beans has also several versions. When I retrieve  a specific Version of the
parent, its children are always the last version of them... I would like to
keep the versionned  relation between Parent and Children.... How can I do
this ?

Lets take an example to explain with code what mean:

Customized Test from 
trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/version/AnnotationBasicVersionningTest.java

@Node(jcrMixinTypes = "mix:versionable")
public class PressRelease {
        @Field(path = true) String path;
        @Field String title;
        @Field Date pubDate;
        @Field String content;
        @Bean Author author;

....


@Node(jcrMixinTypes = "mix:versionable")
public class Author {

        @Field(path = true) String path;
        @Field String name;
        @Field String description;
....




                ObjectContentManager ocm = getOcm();
                try {

                        PressRelease pressRelease = new PressRelease();
                        pressRelease.setContent("content v1");
                        pressRelease.setPath("/pressrelease1");
                        pressRelease.setPubDate(new Date());
                        pressRelease.setTitle("Title");

                        Author author = new Author();
                        author.setName("John");
                        author.setDescription("no description");
                        pressRelease.setAuthor(author);
                        ocm.insert(pressRelease);
                        ocm.save();

                        pressRelease.setContent("content v2");
                        ocm.checkout("/pressrelease1");
                        pressRelease.getAuthor().setDescription("not yet a 
description");
                        ocm.update(pressRelease);
                        ocm.save();
                        ocm.checkin("/pressrelease1");

                        pressRelease.setContent("content v3");
                        ocm.checkout("/pressrelease1");
                        pressRelease.getAuthor().setDescription("Real john 
description");
                        ocm.update(pressRelease);
                        ocm.save();
                        ocm.checkin("/pressrelease1");

                        VersionIterator versionIterator = ocm
                                        .getAllVersions("/pressrelease1");
                        
                        assertNotNull(versionIterator, "VersionIterator is 
null") ;
                        assertTrue( versionIterator.getSize() == 3, "Invalid 
number of versions
found");

                        while (versionIterator.hasNext()) {
                                Version version = (Version) 
versionIterator.next();
                                log.info("version found : " + version.getName() 
+ " - "
                                                + version.getPath() + " - "
                                                + 
version.getCreated().getTime());
                                if 
(version.getName().equals("jcr:rootVersion")) {
                                        continue;
                                }

                                pressRelease = (PressRelease) 
ocm.getObject("/pressrelease1",
version.getName());
                                assertNotNull(pressRelease,"pressRelease is 
null for version " +
version.getName() );

                                if (version.getName().equals("1.0")) {
                                        assertEquals( 
pressRelease.getContent(),"content v2");
                                        assertEquals( 
pressRelease.getAuthor().getDescription(),"not yet a
description");
                                }

                                if (version.getName().equals("1.1")) {
                                        assertEquals( 
pressRelease.getContent(),"content v3");
                                        assertEquals( 
pressRelease.getAuthor().getDescription(),"Real john
description");
                                }

                        }

                } catch (Exception e) {
                        e.printStackTrace();
                        fail(e.getMessage());

                }
                

FAILED: testVersionBetweenCompositeObjetcs
java.lang.AssertionError: expected:<not yet a description> but was:<Real
john description>

=>
Child bean relation: Parent bean is  related to the last version of the
Child... 

How can we define a 'Versionned' child bean relation ?
( a Parent Version bean is related to a version of the child)

Regards,

Gerald Reinhart



-- 
View this message in context: 
http://www.nabble.com/Versioning-and-composition-%3A-a-specific-version-of-the-parent-is-always-related-with-the-last-version-of-the-child---tp21935873p21935873.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.

Reply via email to