Package org.apache.jackrabbit.ocm.testmodel

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


  {
         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


           
          // --------------------------------------------------------------------------------
            // 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", ((Paragraph) page.getParagraphs().iterator().next()).getText().equals("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", ((Paragraph) page.getParagraphs().iterator().next()).getText().equals("Para 1"));
           
            // --------------------------------------------------------------------------------
            // Export to check the content
            // --------------------------------------------------------------------------------          
            this.exportDocument("target/NTCollectionExport.xml", "/test", true, false);
View Full Code Here

           
          // --------------------------------------------------------------------------------
            // 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", ((Paragraph) page.getParagraphs().iterator().next()).getText().equals("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", ((Paragraph) page.getParagraphs().iterator().next()).getText().equals("Para 1"));
           
            // --------------------------------------------------------------------------------
            // Export to check the content
            // --------------------------------------------------------------------------------          
            this.exportDocument("target/NTCollectionExport.xml", "/test", true, false);
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

            // --------------------------------------------------------------------------------
            // Create and store an object graph in the repository
            // --------------------------------------------------------------------------------

            Page page = new Page();
            page.setPath("/test");
            page.setTitle("Page Title");
           
            Collection 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.insert(page);
            ocm.save();
           
            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------          
            page = (Page) ocm.getObject("/test");
            paragraphs = page.getParagraphs();
            for (Iterator iter = paragraphs.iterator(); iter.hasNext();) {
        Paragraph paragraph = (Paragraph) iter.next();
        System.out.println("Paragraph path : " + paragraph.getPath());       
      }           
            Paragraph p1 = (Paragraph) ocm.getObject("/test/collection-element[2]");
            Page paraPage = p1.getPage();
            assertNotNull("Parent page is null", paraPage);
            assertTrue("Invalid parent page", paraPage.getPath().equals("/test"));
           
            // --------------------------------------------------------------------------------
            // Remove the object
            // --------------------------------------------------------------------------------          
            ocm.remove("/test");
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

    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

            // --------------------------------------------------------------------------------
            // Create and store an object graph in the repository
            // --------------------------------------------------------------------------------

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

            List<Paragraph> paragraphs = new ArrayList<Paragraph>();

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

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

            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------
            page = (Page) ocm.getObject("/test");
            paragraphs = page.getParagraphs();
            for (Paragraph paragraph : paragraphs) {
        log.info("Paragraph path : " + paragraph.getPath());       
      }
            Paragraph p1 = (Paragraph) ocm.getObject("/test/paragraph[2]");
            Page paraPage = p1.getPage();
            assertNotNull("Parent page is null", paraPage);
            assertTrue("Invalid parent page", paraPage.getPath().equals("/test"));

            // --------------------------------------------------------------------------------
            // Remove the object
            // --------------------------------------------------------------------------------
            ocm.remove("/test");
View Full Code Here

  {
         ObjectContentManager ocm = getObjectContentManager();
             try
             {
             
               Page page = new Page();
               page.setPath("/page");
               page.setTitle("Page Title");             
               ocm.insert(page);
               ocm.save();
             
               Paragraph p1 = new Paragraph("para1");
               p1.setPath("/page/paragraph");
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

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.