Package org.apache.jackrabbit.ocm.testmodel

Examples of org.apache.jackrabbit.ocm.testmodel.Page


          // --------------------------------------------------------------------------------
            // Create and store an object graph in the repository with a null collection
            // --------------------------------------------------------------------------------

            Page page = new Page();
            page.setPath("/test");
            page.setTitle("Page Title");

            ocm.insert(page);
            ocm.save();

            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------
            page = (Page) ocm.getObject( "/test");
            assertNull("page.getParagraphs is not null", page.getParagraphs());
            assertTrue("Incorrect page title", page.getTitle().equals("Page Title"));

            // --------------------------------------------------------------------------------
            // Create and store an object graph in the repository
            // --------------------------------------------------------------------------------
            ArrayList paragraphs = new ArrayList();

            paragraphs.add(new Paragraph("Para 1"));
            paragraphs.add(new Paragraph("Para 2"));
            paragraphs.add(new Paragraph("Para 3"));
            page.setParagraphs(paragraphs);

            ocm.update(page);
            ocm.save();

            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------
            page = (Page) ocm.getObject( "/test");
            assertNotNull("page.getParagraphs is null", page.getParagraphs());
            assertTrue("Incorrect page title", page.getTitle().equals("Page Title"));
            assertTrue("Incorrect page.getParagraphs size", page.getParagraphs().size() == 3);
            assertTrue("Incorrect para element", this.containsText(page.getParagraphs(),"Para 1"));

            // --------------------------------------------------------------------------------
            // Update the object
            // --------------------------------------------------------------------------------
            paragraphs = new ArrayList();

            paragraphs.add(new Paragraph("Para 1"));
            paragraphs.add(new Paragraph("Para 2"));
            paragraphs.add(new Paragraph("Para 4"));
            paragraphs.add(new Paragraph("Para 5"));
            page.setParagraphs(paragraphs);

            ocm.update(page);
            ocm.save();

            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------

            page = (Page) ocm.getObject( "/test");
            assertNotNull("page.getParagraphs is null", page.getParagraphs());
            assertTrue("Incorrect page title", page.getTitle().equals("Page Title"));
            assertTrue("Incorrect page.getParagraphs size", page.getParagraphs().size() == 4);
            assertTrue("Incorrect para element", this.containsText(page.getParagraphs(),"Para 1"));

            // --------------------------------------------------------------------------------
            // Export to check the content
            // --------------------------------------------------------------------------------
            this.exportDocument("target/NTCollectionExport.xml", "/test", true, false);
View Full Code Here


  {
       ObjectContentManager ocm = getObjectContentManager();
         try
         {
         
           Page page = new Page();
           page.setPath("/page");
           page.setTitle("Page Title");             
           page.addParagraph(new Paragraph("para1"));
           page.addParagraph(new Paragraph("para2"));
           ocm.insert(page);
           ocm.save();
         
           page.addParagraph(new Paragraph("para3"));
           page.setTitle("Page Title 2");
           ocm.checkout("/page");
           ocm.update(page);
           ocm.save();
           ocm.checkin("/page");
         
           page.addParagraph(new Paragraph("para4"));
           page.setTitle("Page Title 3");
           ocm.checkout("/page");
           ocm.update(page);
           ocm.save();
           ocm.checkin("/page");             

           VersionIterator versionIterator = ocm.getAllVersions("/page");
           assertNotNull("VersionIterator is null", versionIterator);
           assertTrue("Invalid number of versions found", versionIterator.getSize() == 3);
         
           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;
             }
            
             page = (Page) ocm.getObject("/page", version.getName());
             assertNotNull("Page is null for version " + version.getName(), page);
            
             if (version.getName().equals("1.0"))
             {
              assertEquals("Invalid title for version " + version.getName(),page.getTitle(), "Page Title 2");
             }
            
             if (version.getName().equals("1.1"))
             {
              assertEquals("Invalid title for version " + version.getName(),page.getTitle(), "Page Title 3");
             }
            
           }
         
           Version baseVersion = ocm.getBaseVersion("/page");
           log.info("Base version : " + baseVersion.getName());

           Version rootVersion = ocm.getRootVersion("/page");
           log.info("Root version : " + rootVersion.getName());
                        
             //Get the latest version
           page = (Page) ocm.getObject( "/page");
           assertNotNull("Last version is nulll", page);
           assertTrue("Invalid number of paragraph found in the last  version", page.getParagraphs().size() == 4);

         
         }
         catch(Exception e)
         {
View Full Code Here

  {
         ObjectContentManager ocm = getObjectContentManager();
             try
             {
             
               Page page = new Page();
               page.setPath("/page");
               page.setTitle("Page Title");             
               page.addParagraph(new Paragraph("para1"));
               page.addParagraph(new Paragraph("para2"));
               ocm.insert(page);
               ocm.save();
             

               page.addParagraph(new Paragraph("para3"));
               ocm.checkout("/page");
               ocm.update(page);
               ocm.save();
               ocm.checkin("/page", new String[] {"A", "B"});
             
               page.addParagraph(new Paragraph("para4"));
               ocm.checkout("/page");
               ocm.update(page);
               ocm.save();
               ocm.checkin("/page", new String[] {"C", "D"});          
View Full Code Here

      Node root = session.getRootNode();
      root.addNode("test");
      root.addNode("test/node1");
      root.addNode("test/node2");
     
      Page page = new Page();
      page.setPath("/test/node1/page1");
      page.setTitle("Page 1 Title");
     
      ArrayList paragraphs = new ArrayList();
     
      paragraphs.add(new Paragraph("Para 1"));
      paragraphs.add(new Paragraph("Para 2"));
      paragraphs.add(new Paragraph("Para 3"));
      paragraphs.add(new Paragraph("Another Para "));
      page.setParagraphs(paragraphs);
     
      ocm.insert(page);
           
     
      page = new Page();
      page.setPath("/test/node1/page2");
      page.setTitle("Page 2 Title");
     
      paragraphs = new ArrayList();
     
      paragraphs.add(new Paragraph("Para 1"));
      paragraphs.add(new Paragraph("Para 2"));
      paragraphs.add(new Paragraph("Para 5"));
      paragraphs.add(new Paragraph("Another Para"));
      page.setParagraphs(paragraphs);
     
      ocm.insert(page);
     
      page = new Page();
      page.setPath("/test/node2/page1");
      page.setTitle("Page 3 Title");
     
      paragraphs = new ArrayList();
     
      paragraphs.add(new Paragraph("Para 1"));
      paragraphs.add(new Paragraph("Para 4"));
      paragraphs.add(new Paragraph("Para 5"));
      paragraphs.add(new Paragraph("Another Para"));
      page.setParagraphs(paragraphs);
     
      ocm.insert( page);

      page = new Page();
      page.setPath("/test/node2/page2");
      page.setTitle("Page 4 Title");
     
      paragraphs = new ArrayList();
     
      paragraphs.add(new Paragraph("Para 6"));
      paragraphs.add(new Paragraph("Para 7"));
      paragraphs.add(new Paragraph("Para 8"));
      paragraphs.add(new Paragraph("Another Para"));
      page.setParagraphs(paragraphs);
     
      ocm.insert(page);
      ocm.save();
     
     
View Full Code Here

            iterator = (ObjectIterator) ocm.getObjectIterator(query);
              log.info("getObjectIterator takes : " + (System.currentTimeMillis() - start));
              assertEquals("wrong results count", 4, iterator.getSize());
              assertEquals("wrong initial position", 0, iterator.getPosition());
              assertTrue("no objects returned", iterator.hasNext());
              Page page = (Page) iterator.next();
              assertEquals("wrong first result", "Page 1 Title", page.getTitle());
              iterator.skip(1);
              assertEquals("wrong position after skip", 2, iterator.getPosition());
              page = (Page) iterator.next();
              assertEquals("wrong third result", "Page 3 Title", page.getTitle());
        }
        catch (Exception e)
        {
            e.printStackTrace();
            fail("Exception occurs during the unit test : " + e);
View Full Code Here

      root.addNode("test/node1");
      root.addNode("test/node2");
     
      root.save();
     
      Page page = new Page();
      page.setPath("/test/node1/page1");
      page.setTitle("Page 1 Title");
     
      ArrayList paragraphs = new ArrayList();
     
      paragraphs.add(new Paragraph("Para 1"));
      paragraphs.add(new Paragraph("Para 2"));
      paragraphs.add(new Paragraph("Para 3"));
      paragraphs.add(new Paragraph("Another Para "));
      page.setParagraphs(paragraphs);
     
      ocm.insert(page);
           
     
      page = new Page();
      page.setPath("/test/node1/page2");
      page.setTitle("Page 2 Title");
     
      paragraphs = new ArrayList();
     
      paragraphs.add(new Paragraph("Para 1"));
      paragraphs.add(new Paragraph("Para 2"));
      paragraphs.add(new Paragraph("Para 5"));
      paragraphs.add(new Paragraph("Another Para"));
      page.setParagraphs(paragraphs);
     
      ocm.insert(page);
     
      page = new Page();
      page.setPath("/test/node2/page1");
      page.setTitle("Page 3 Title");
     
      paragraphs = new ArrayList();
     
      paragraphs.add(new Paragraph("Para 1"));
      paragraphs.add(new Paragraph("Para 4"));
      paragraphs.add(new Paragraph("Para 5"));
      paragraphs.add(new Paragraph("Another Para"));
      page.setParagraphs(paragraphs);
     
      ocm.insert(page);

      page = new Page();
      page.setPath("/test/node2/page2");
      page.setTitle("Page 4 Title");
     
      paragraphs = new ArrayList();
     
      paragraphs.add(new Paragraph("Para 6"));
      paragraphs.add(new Paragraph("Para 7"));
      paragraphs.add(new Paragraph("Para 8"));
      paragraphs.add(new Paragraph("Another Para"));
      page.setParagraphs(paragraphs);
     
      ocm.insert(page);
     
      ocm.save();
     
View Full Code Here

  {
         ObjectContentManager ocm = getObjectContentManager();
             try
             {

               Page page = new Page();
               page.setPath("/page");
               page.setTitle("Page Title");
               page.addParagraph(new Paragraph("para1"));
               page.addParagraph(new Paragraph("para2"));
               ocm.insert(page);
               ocm.save();

               page.addParagraph(new Paragraph("para3"));
               page.setTitle("Page Title 2");
               ocm.checkout("/page");
               ocm.update(page);
               ocm.save();
               ocm.checkin("/page");

               page.addParagraph(new Paragraph("para4"));
               page.setTitle("Page Title 3");
               ocm.checkout("/page");
               ocm.update(page);
               ocm.save();
               ocm.checkin("/page");

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

               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;
                 }

                 page = (Page) ocm.getObject("/page", version.getName());
                 assertNotNull("Page is null for version " + version.getName(), page);

                 if (version.getName().equals("1.0"))
                 {
                  assertEquals("Invalid title for version " + version.getName(),page.getTitle(), "Page Title 2");
                 }

                 if (version.getName().equals("1.1"))
                 {
                  assertEquals("Invalid title for version " + version.getName(),page.getTitle(), "Page Title 3");
                 }

               }

               Version baseVersion = ocm.getBaseVersion("/page");
               log.info("Base version : " + baseVersion.getName());

               Version rootVersion = ocm.getRootVersion("/page");
               log.info("Root version : " + rootVersion.getName());
               //this.exportDocument("/home/christophe/export.xml", "/jcr:system/jcr:versionStorage", true, false);

                 //Get the latest version
               page = (Page) ocm.getObject( "/page");
               assertNotNull("Last version is nulll", page);
               assertTrue("Invalid number of paragraph found in the last  version", page.getParagraphs().size() == 4);


             }
             catch(Exception e)
             {
View Full Code Here

  {
         ObjectContentManager ocm = getObjectContentManager();
             try
             {

               Page page = new Page();
               page.setPath("/page");
               page.setTitle("Page Title");
               page.addParagraph(new Paragraph("para1"));
               page.addParagraph(new Paragraph("para2"));
               ocm.insert(page);
               ocm.save();


               page.addParagraph(new Paragraph("para3"));
               ocm.checkout("/page");
               ocm.update(page);
               ocm.save();
               ocm.checkin("/page", new String[] {"A", "B"});

               page.addParagraph(new Paragraph("para4"));
               ocm.checkout("/page");
               ocm.update(page);
               ocm.save();
               ocm.checkin("/page", new String[] {"C", "D"});
View Full Code Here

    private void importData() throws JcrMappingException
    {
        try {
      ObjectContentManager ocm = getObjectContentManager();
     
      Page page = new Page();
      page.setPath("/test");
      page.setTitle("Page Title");
     
      ArrayList paragraphs = new ArrayList();
     
      paragraphs.add(new Paragraph("Para 1"));
      paragraphs.add(new Paragraph("Para 2"));
      paragraphs.add(new Paragraph("Para 3"));
      paragraphs.add(new Paragraph("Another Para "));
      page.setParagraphs(paragraphs);
     
      ocm.insert(page);
     
      //add an extra node with other page objects
      Node root = ocm.getSession().getRootNode();
      root.addNode("folder");
      page = new Page();
      page.setPath("/folder/test");
      page.setTitle("Page Title");
     
      paragraphs = new ArrayList();
     
      paragraphs.add(new Paragraph("Para 1.1"));
      paragraphs.add(new Paragraph("Para 1.2"));
      paragraphs.add(new Paragraph("Para 1.3"));
      paragraphs.add(new Paragraph("1.Another Para "));
      page.setParagraphs(paragraphs);
     
      ocm.insert(page);

      page = new Page();
      page.setPath("/folder/test");
      page.setTitle("Page Title");
     
      paragraphs = new ArrayList();
     
      paragraphs.add(new Paragraph("Para 2.1"));
      paragraphs.add(new Paragraph("Para 2.2"));
      paragraphs.add(new Paragraph("Para 2.3"));
      paragraphs.add(new Paragraph("2.Another Para "));
      page.setParagraphs(paragraphs);
     
      ocm.insert(page);

      page = new Page();
      page.setPath("/folder/test");
      page.setTitle("Page Title");
     
      paragraphs = new ArrayList();
     
      paragraphs.add(new Paragraph("Para 3.1"));
      paragraphs.add(new Paragraph("Para 3.2"));
      paragraphs.add(new Paragraph("Para 3.3"));
      paragraphs.add(new Paragraph("3.Another Para "));
      page.setParagraphs(paragraphs);
     
      ocm.insert(page);

      page = new Page();
      page.setPath("/folder/test");
      page.setTitle("Page Title");
     
      paragraphs = new ArrayList();
     
      paragraphs.add(new Paragraph("Para 4.1"));
      paragraphs.add(new Paragraph("Para 4.2"));
      paragraphs.add(new Paragraph("Para 4.3"));
      paragraphs.add(new Paragraph("4.Another Para "));
      page.setParagraphs(paragraphs);
     
      ocm.insert(page);
     
      ocm.save();
    }
View Full Code Here

    private void importData() throws JcrMappingException
    {
      ObjectContentManager ocm = getObjectContentManager();

        Page page = new Page();
        page.setPath("/test");
        page.setTitle("Page Title");

        ArrayList paragraphs = new ArrayList();

        paragraphs.add(new Paragraph("Para 1"));
        paragraphs.add(new Paragraph("Para 2"));
        paragraphs.add(new Paragraph("Para 3"));
        paragraphs.add(new Paragraph("Another Para "));
        page.setParagraphs(paragraphs);

        ocm.insert(page);
        ocm.save();

View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.ocm.testmodel.Page

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.