Package org.apache.jackrabbit.ocm.testmodel

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


        try {
      // --------------------------------------------------------------------------------
      // Create and store an object graph in the repository
      // --------------------------------------------------------------------------------
      A a = new A();
      a.setPath("/source");
      a.setA1("a1");
      a.setA2("a2");
      B b = new B();
      b.setB1("b1");
      b.setB2("b2");
      a.setB(b);
     
      C c1 = new C();
      c1.setId("first");
      c1.setName("First Element");
      C c2 = new C();
      c2.setId("second");
      c2.setName("Second Element");
     
      C c3 = new C();
      c3.setId("third");
      c3.setName("Third Element");
     
     
      Collection collection = new ArrayList();
      collection.add(c1);
      collection.add(c2);
      collection.add(c3);
     
      a.setCollection(collection);
     
      ocm.insert(a);
          ocm.save();
     
      // --------------------------------------------------------------------------------
      // Copy the object
      // --------------------------------------------------------------------------------     
          ocm.move("/source", "/result");
          // --------------------------------------------------------------------------------
      // Get the object
      // --------------------------------------------------------------------------------
      a = (A) ocm.getObject("/result");
      assertNotNull("a is null", a);
      assertTrue("Invalid field a1", a.getA1().equals("a1"));
      assertTrue("Invalid field b.b1", a.getB().getB1().equals("b1"));
      assertTrue("Invalid number of items in field collection", a.getCollection().size() == 3);
     
      assertFalse("Object with path /source still exists", ocm.objectExists("/source"));
     
      // --------------------------------------------------------------------------------
      // Remove objects
View Full Code Here


          ObjectContentManager ocm = getObjectContentManager();

            // --------------------------------------------------------------------------------
            // Create and store an object graph in the repository
            // --------------------------------------------------------------------------------
            A a = new A();
            a.setPath("/test");
            C c1 = new C();
            c1.setId("first");
            c1.setName("First Element");
            C c2 = new C();
            c2.setId("second");
            c2.setName("Second Element");

            C c3 = new C();
            c3.setId("third");
            c3.setName("Third Element");


            Collection collection = new ArrayList();
            collection.add(c1);
            collection.add(c2);
            collection.add(c3);

            a.setCollection(collection);

            ocm.insert(a);
            ocm.save();

            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------
            a = (A) ocm.getObject( "/test");
            assertNotNull("a.collection is null", a.getCollection());
            assertEquals("Incorrect a.collection size", 3, a.getCollection().size());
            assertEquals("Incorrect a.collection", "first", ((C) a.getCollection().iterator().next()).getId());

            // --------------------------------------------------------------------------------
            // Update the object
            // --------------------------------------------------------------------------------
            C c4 = new C();
            c4.setId("Fourth");
            c4.setName("Fourth Element");

            collection = new ArrayList();
            collection.add(c1);
            collection.add(c2);
            collection.add(c3);
            collection.add(c4);
            a.setCollection(collection);

            ocm.update(a);
            ocm.save();

            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------
            a = (A) ocm.getObject( "/test");
            assertNotNull("a is null", a);
            assertNotNull("a.collection is null", a.getCollection());
            assertEquals("Incorrect collection size", 4, a.getCollection().size());
            assertEquals("Incorrect a.collection", "first", ((C) a.getCollection().iterator().next()).getId());

        }
        catch (Exception e)
        {
            e.printStackTrace();
View Full Code Here

      try
      {
        // ------------------------------------------------------------------------
        // Create a main object (a) with a null attribute (A.b)
        // ------------------------------------------------------------------------       
      A a = new A();
      a.setPath("/test");
      a.setA1("a1");
      ocm.insert(a);
      ocm.save();
     
        // ------------------------------------------------------------------------
        // Retrieve
        // ------------------------------------------------------------------------
      a = (A) ocm.getObject("/test");
      assertNotNull("Object is null", a);
      assertNull("attribute is not null", a.getB());
     
      B b = new B();
      b.setB1("b1");
      b.setB2("b2");
      a.setB(b);
     
      ocm.update(a);
      ocm.save();

        // ------------------------------------------------------------------------
        // Retrieve
        // ------------------------------------------------------------------------
      a = (A) ocm.getObject("/test");
      assertNotNull("Object is null", a);
      assertNotNull("attribute is null", a.getB());
     
        // ------------------------------------------------------------------------
      // Remove object
        // ------------------------------------------------------------------------     
      ocm.remove("/test");
View Full Code Here


            // --------------------------------------------------------------------------------
            // Create and store an object graph in the repository
            // --------------------------------------------------------------------------------
            A a = new A();
            a.setPath("/test");
            a.setA1("a1");
            a.setA2("a2");
            B b = new B();
            b.setB1("b1");
            b.setB2("b2");
            a.setB(b);

            C c1 = new C();
            c1.setId("first");
            c1.setName("First Element");
            C c2 = new C();
            c2.setId("second");
            c2.setName("Second Element");

            C c3 = new C();
            c3.setId("third");
            c3.setName("Third Element");


            Collection collection = new ArrayList();
            collection.add(c1);
            collection.add(c2);
            collection.add(c3);

            a.setCollection(collection);

            ocm.insert(a);
            ocm.save();


            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------
            a = (A) ocm.getObject( "/test");
            assertNotNull("a is null", a);

            // --------------------------------------------------------------------------------
            // Check if the object is locked
            // --------------------------------------------------------------------------------
            assertFalse("the object is locked", ocm.isLocked("/test"));

            // --------------------------------------------------------------------------------
            // Lock the object
            // --------------------------------------------------------------------------------

            Lock lock = ocm.lock("/test", true, false);
            assertTrue("the Lock owner is not correct", lock.getLockOwner().equals("superuser"));

            // --------------------------------------------------------------------------------
            // Check if the object is locked
            // --------------------------------------------------------------------------------
            assertTrue("the object is not locked", ocm.isLocked("/test"));

            // --------------------------------------------------------------------------------
            // Unlock the object
            // --------------------------------------------------------------------------------
            ocm.unlock("/test", lock.getLockToken());

            // --------------------------------------------------------------------------------
            // Check if the object is locked
            // --------------------------------------------------------------------------------
            assertFalse("the object is locked", ocm.isLocked("/test"));

            // --------------------------------------------------------------------------------
            // Lock & update
            // --------------------------------------------------------------------------------
            lock = ocm.lock("/test", true, false);
            a = (A) ocm.getObject("/test");
            a.setA1("new a1 Value");
            ocm.update(a);
            ocm.save();
            ocm.unlock("/test", lock.getLockToken());

View Full Code Here

      try
      {
        // ------------------------------------------------------------------------
        // Create a main object (a) with a null attribute (A.b)
        // ------------------------------------------------------------------------       
      A a = new A();
      a.setPath("/test");
      a.setA1("a1");
      ocm.insert(a);
      ocm.save();
     
        // ------------------------------------------------------------------------
        // Retrieve
        // ------------------------------------------------------------------------
      a = (A) ocm.getObject("/test");
      assertNotNull("Object is null", a);
      assertNull("attribute is not null", a.getB());
     
      B b = new B();
      b.setB1("b1");
      b.setB2("b2");
      a.setB(b);
     
      ocm.update(a);
      ocm.save();

        // ------------------------------------------------------------------------
        // Retrieve
        // ------------------------------------------------------------------------
      a = (A) ocm.getObject("/test");
      assertNotNull("Object is null", a);
      assertNotNull("attribute is null", a.getB());
     
        // ------------------------------------------------------------------------
      // Remove object
        // ------------------------------------------------------------------------     
      ocm.remove("/test");
View Full Code Here


            // --------------------------------------------------------------------------------
            // Create and store an object graph in the repository
            // --------------------------------------------------------------------------------
            A a = new A();
            a.setPath("/test");
            a.setA1("a1");
            a.setA2("a2");
            B b = new B();
            b.setB1("b1");
            b.setB2("b2");
            a.setB(b);

            C c1 = new C();
            c1.setId("first");
            c1.setName("First Element");
            C c2 = new C();
            c2.setId("second");
            c2.setName("Second Element");

            C c3 = new C();
            c3.setId("third");
            c3.setName("Third Element");


            Collection collection = new ArrayList();
            collection.add(c1);
            collection.add(c2);
            collection.add(c3);

            a.setCollection(collection);

            ocm.insert(a);
            ocm.save();


            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------
            a = (A) ocm.getObject( "/test");
            assertNotNull("a is null", a);
            assertTrue("Incorrect a1", a.getA1().equals("a1"));
            assertNotNull("a.b is null", a.getB());
            assertTrue("Incorrect a.b.b1", a.getB().getB1().equals("b1"));
            assertNotNull("a.collection is null", a.getCollection());
            assertTrue("Incorrect a.collection", ((C) a.getCollection().iterator().next()).getId().equals("first"));

            // --------------------------------------------------------------------------------
            // Update the object
            // --------------------------------------------------------------------------------
            a.setA1("new value");
            B newB = new B();
            newB.setB1("new B1");
            newB.setB2("new B2");
            a.setB(newB);


            ocm.update(a);
            ocm.save();

            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------
            a = (A) ocm.getObject("/test");
            assertNotNull("a is null", a);
            assertTrue("Incorrect a1", a.getA1().equals("new value"));
            assertNotNull("a.b is null", a.getB());
            assertTrue("Incorrect a.b.b1", a.getB().getB1().equals("new B1"));



        }
        catch (Exception e)
View Full Code Here


            // --------------------------------------------------------------------------------
            // Create and store an object graph in the repository
            // --------------------------------------------------------------------------------
            A a = new A();
            a.setPath("/test");
            a.setA1("a1");
            a.setA2("a2");
            B b = new B();
            b.setB1("b1");
            b.setB2("b2");
            a.setB(b);

            C c1 = new C();
            c1.setId("first");
            c1.setName("First Element");
            C c2 = new C();
            c2.setId("second");
            c2.setName("Second Element");

            C c3 = new C();
            c3.setId("third");
            c3.setName("Third Element");


            Collection collection = new ArrayList();
            collection.add(c1);
            collection.add(c2);
            collection.add(c3);

            a.setCollection(collection);

            ocm.insert(a);
            ocm.save();


            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------
            a = (A) ocm.getObject( "/test");
            assertNotNull("a is null", a);
            assertTrue("Incorrect a1", a.getA1().equals("a1"));
            assertNotNull("a.b is null", a.getB());
            assertTrue("Incorrect a.b.b1", a.getB().getB1().equals("b1"));
            assertNotNull("a.collection is null", a.getCollection());
            assertTrue("Incorrect a.collection", ((C) a.getCollection().iterator().next()).getId().equals("first"));

            // --------------------------------------------------------------------------------
            // Update the object
            // --------------------------------------------------------------------------------
            a.setA1("new value");
            B newB = new B();
            newB.setB1("new B1");
            newB.setB2("new B2");
            a.setB(newB);


            ocm.update(a);
            ocm.save();

            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------
            a = (A) ocm.getObject("/test");
            assertNotNull("a is null", a);
            assertTrue("Incorrect a1", a.getA1().equals("new value"));
            assertNotNull("a.b is null", a.getB());
            assertTrue("Incorrect a.b.b1", a.getB().getB1().equals("new B1"));



        }
        catch (Exception e)
View Full Code Here


            // --------------------------------------------------------------------------------
            // Create and store an object graph in the repository
            // --------------------------------------------------------------------------------
            A a = new A();
            a.setPath("/test");
            a.setA1("a1");
            a.setA2("a2");
            B b = new B();
            b.setB1("b1");
            b.setB2("b2");
            a.setB(b);

            C c1 = new C();
            c1.setId("first");
            c1.setName("First Element");
            C c2 = new C();
            c2.setId("second");
            c2.setName("Second Element");

            C c3 = new C();
            c3.setId("third");
            c3.setName("Third Element");


            Collection collection = new ArrayList();
            collection.add(c1);
            collection.add(c2);
            collection.add(c3);

            a.setCollection(collection);

            ocm.insert(a);
            ocm.save();


            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------
            a = (A) ocm.getObject( "/test");
            assertNotNull("a is null", a);
            assertTrue("Incorrect a1", a.getA1().equals("a1"));
            assertNotNull("a.b is null", a.getB());
            assertTrue("Incorrect a.b.b1", a.getB().getB1().equals("b1"));
            assertNotNull("a.collection is null", a.getCollection());
            assertTrue("Incorrect a.collection", ((C) a.getCollection().iterator().next()).getId().equals("first"));

            // --------------------------------------------------------------------------------
            // Update the object
            // --------------------------------------------------------------------------------
            a.setA1("new value");
            B newB = new B();
            newB.setB1("new B1");
            newB.setB2("new B2");
            a.setB(newB);


            ocm.update(a);
            ocm.save();

            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------
            a = (A) ocm.getObject("/test");
            assertNotNull("a is null", a);
            assertTrue("Incorrect a1", a.getA1().equals("new value"));
            assertNotNull("a.b is null", a.getB());
            assertTrue("Incorrect a.b.b1", a.getB().getB1().equals("new B1"));



        }
        catch (Exception e)
View Full Code Here

TOP

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

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.