Package org.apache.jackrabbit.ocm.testmodel

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


            // --------------------------------------------------------------------------------
            residual = new Residual.ResidualNodes();
            residual.setPath("/test");

            HashMap<String, Paragraph> map = new HashMap<String, Paragraph>();
            map.put("value1", new Paragraph("Value1"));
            map.put("value2", new Paragraph("Value2"));
            map.put("value3", new Paragraph("Value3"));
            map.put("value4", new Paragraph("Value4"));
            residual.setElements(map);

            ocm.update(residual);
            ocm.save();

            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------
            residual = (Residual) ocm.getObject( "/test");
            assertNotNull("Object is null", residual);
            assertTrue("Incorrect number of values", residual.getElements().size() == 4);
            assertTrue("Incorrect collection element type", (residual.getElements().get("value2") instanceof Paragraph));
            assertEquals("Incorrect collection element text", ((Paragraph) residual.getElements().get("value2")).getText(), "Value2");

            // --------------------------------------------------------------------------------
            // Update the object
            // --------------------------------------------------------------------------------
            map = new HashMap<String, Paragraph>();
            map.put("value11", new Paragraph("Value11"));
            map.put("value12", new Paragraph("Value12"));
            map.put("value13", new Paragraph("Value13"));
            map.put("value14", new Paragraph("Value14"));
            map.put("value15", new Paragraph("Value15"));
            residual.setElements(map);

            ocm.update(residual);
            ocm.save();
View Full Code Here


            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
View Full Code Here

            // --------------------------------------------------------------------------------
            // 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();
View Full Code Here

   
    private boolean containsText(Collection paragraphs, String text)
    {
      Iterator iterator = paragraphs.iterator();
      while (iterator.hasNext()) {
      Paragraph paragraph = (Paragraph) iterator.next();
      if (paragraph.getText().equals(text))
      {
        return true;
      }
     
    }
View Full Code Here

            // --------------------------------------------------------------------------------
            // 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();
View Full Code Here

   
    private boolean containsText(Collection paragraphs, String text)
    {
      Iterator iterator = paragraphs.iterator();
      while (iterator.hasNext()) {
      Paragraph paragraph = (Paragraph) iterator.next();
      if (paragraph.getText().equals(text))
      {
        return true;
      }
     
    }
View Full Code Here

               page.setPath("/page");
               page.setTitle("Page Title");             
               ocm.insert(page);
               ocm.save();
             
               Paragraph p1 = new Paragraph("para1");
               p1.setPath("/page/paragraph");
               ocm.insert(p1);
             
               Paragraph p2 = new Paragraph("para1");
               p2.setPath("/page/paragraph");
               ocm.insert(p2);
             fail();             
             
             }
             catch(Exception e)
View Full Code Here

            // --------------------------------------------------------------------------------
            residual = new Residual.ResidualNodes();
            residual.setPath("/test");

            HashMap<String,Paragraph> map = new HashMap<String,Paragraph>();
            map.put("value1", new Paragraph("Value1"));
            map.put("value2", new Paragraph("Value2"));
            map.put("value3", new Paragraph("Value3"));
            map.put("value4", new Paragraph("Value4"));
            residual.setElements(map);

            ocm.update(residual);
            ocm.save();

            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------
            residual = (Residual) ocm.getObject( "/test");
            assertNotNull("Object is null", residual);
            assertTrue("Incorrect number of values", residual.getElements().size() == 4);
            assertTrue("Incorrect collection element type", (residual.getElements().get("value2") instanceof Paragraph));
            assertEquals("Incorrect collection element text", ((Paragraph) residual.getElements().get("value2")).getText(), "Value2");

            // --------------------------------------------------------------------------------
            // Update the object
            // --------------------------------------------------------------------------------
            map = new HashMap<String,Paragraph>();
            map.put("value11", new Paragraph("Value11"));
            map.put("value12", new Paragraph("Value12"));
            map.put("value13", new Paragraph("Value13"));
            map.put("value14", new Paragraph("Value14"));
            map.put("value15", new Paragraph("Value15"));
            residual.setElements(map);

            ocm.update(residual);
            ocm.save();
View Full Code Here

            // --------------------------------------------------------------------------------
            // 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();
View Full Code Here

   
    private boolean containsText(Collection paragraphs, String text)
    {
      Iterator iterator = paragraphs.iterator();
      while (iterator.hasNext()) {
      Paragraph paragraph = (Paragraph) iterator.next();
      if (paragraph.getText().equals(text))
      {
        return true;
      }
     
    }
View Full Code Here

TOP

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

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.