Package nexj.core.meta

Examples of nexj.core.meta.Metaclass$AttributeDependencyVisitor


      assertEquals(nStartReadCount, readCountHook.getReadCount());
   }

   public void testReadAssocRelationalFKToVirtualAttr() throws Exception
   {
      Metaclass relationalClass = getMetadata().getMetaclass("PetOwner");
      InstanceArrayList list;
      Instance inst, inst2;

      list = (InstanceArrayList)Query.createRead(relationalClass,
         parse("(firstName lastName (relFKToVirtAttr commonName))"),
         null,
         null,
         -1, 0, false, Query.SEC_NODE, m_context).read();

      assertEquals(2, list.getCount());
      inst = list.getInstance(0);
      assertEquals("Joe", inst.getValue("firstName"));
      inst2 = (Instance)inst.getValue("relFKToVirtAttr");
      assertEquals("Spider", inst2.getValue("commonName"));

      inst = list.getInstance(1);
      assertEquals("Zoe", inst.getValue("firstName"));
      inst2 = (Instance)inst.getValue("relFKToVirtAttr");
      assertEquals("Cat", inst2.getValue("commonName"));
      assertEquals("Felis catus", inst2.getValue("scientificName"));

      // Read the reverse attribute
      Metaclass virtualClass = getMetadata().getMetaclass("Animal");

      list = (InstanceArrayList)Query.createRead(virtualClass,
         parse("(commonName (virtAttrFromRelFK firstName))"),
         null,
         null,
View Full Code Here


      assertEquals("Test", inst2.getValue("lastName"));
   }

   public void testReadAssocRelationalFKToVirtualCollection() throws Exception
   {
      Metaclass relationalClass = getMetadata().getMetaclass("PetOwner");
      InstanceArrayList list;
      Instance inst, inst2;

      list = (InstanceArrayList)Query.createRead(relationalClass,
         parse("(firstName (relFKToVirtColl scientificName))"),
         parse("(= (@ lastName) \"Test\")"),
         parse("((firstName . #f))"),
         -1, 0, false, Query.SEC_NODE, m_context).read();

      assertEquals(2, list.getCount());
      inst = list.getInstance(0);
      assertEquals("Zoe", inst.getValue("firstName"));
      assertNull(inst.getValue("relFKToVirtColl"));
      inst = list.getInstance(1);
      assertEquals("Joe", inst.getValue("firstName"));
      inst2 = (Instance)inst.getValue("relFKToVirtColl");
      assertEquals("Felis catus", inst2.getValue("scientificName"));
      assertEquals("Cat", inst2.getValue("commonName"));


      // Read the reverse (the virtual collection)
      Metaclass virtualClass = getMetadata().getMetaclass("Animal");
      InstanceArrayList list2;

      list = (InstanceArrayList)virtualClass.invoke("read", new Object[]{
         parse("(commonName (virtCollFromRelFK firstName))"), null, null, null, null, null
      });

      assertEquals(4, list.size());
      inst = list.getInstance(0);
View Full Code Here

      assertEquals("Test", inst2.getValue("lastName"));
   }

   public void testReadAssocVirtualFKToRelationalNone() throws Exception
   {
      Metaclass virtualClass = getMetadata().getMetaclass("Animal");
      InstanceArrayList list;
      Instance inst, inst2;

      list = (InstanceArrayList)Query.createRead(virtualClass,
         parse("(commonName (virtFKToRelNone firstName lastName))"),
View Full Code Here

      assertNull(inst.getValue("virtFKToRelNone"));
   }

   public void testReadAssocVirtualFKToRelationalAttr() throws Exception
   {
      Metaclass virtualClass = getMetadata().getMetaclass("Animal");
      InstanceArrayList list;
      Instance inst, inst2;

      list = (InstanceArrayList)Query.createRead(virtualClass,
         parse("(commonName (virtFKToRelAttr firstName))"),
         null,
         null,
         -1, 0, false, Query.SEC_NODE, m_context).read();

      assertEquals(4, list.getCount());

      inst = list.getInstance(0);
      assertEquals("Dog", inst.getValue("commonName"));
      assertNull(inst.getValue("virtFKToRelAttr"));

      inst = list.getInstance(2);
      assertEquals("Spider", inst.getValue("commonName"));
      inst2 = (Instance)inst.getValue("virtFKToRelAttr");
      assertEquals("Joe", inst2.getValue("firstName"));
      assertEquals("Test", inst2.getValue("lastName"));

      inst = list.getInstance(3);
      assertEquals("Beaver", inst.getValue("commonName"));
      inst2 = (Instance)inst.getValue("virtFKToRelAttr");
      assertEquals("Zoe", inst2.getValue("firstName"));


      // Read the reverse attribute
      Metaclass relationalClass = getMetadata().getMetaclass("PetOwner");

      list = (InstanceArrayList)Query.createRead(relationalClass,
         parse("(firstName (relAttrFromVirtFK commonName))"),
         null,
         null,
View Full Code Here

      assertEquals("Castor canadensis", inst2.getValue("scientificName"));
   }

   public void testReadAssocVirtualFKToRelationalCollection() throws Exception
   {
      Metaclass virtualClass = getMetadata().getMetaclass("Animal");
      InstanceArrayList list;
      Instance inst, inst2;

      list = (InstanceArrayList)Query.createRead(virtualClass,
         parse("(commonName (virtFKToRelColl firstName lastName))"),
         null,
         null,
         -1, 0, false, Query.SEC_NODE, m_context).read();

      assertEquals(4, list.getCount());
      inst = list.getInstance(0);
      assertEquals("Dog", inst.getValue("commonName"));
      inst2 = (Instance)inst.getValue("virtFKToRelColl");
      assertEquals("Zoe", inst2.getValue("firstName"));

      inst = list.getInstance(1);
      assertEquals("Cat", inst.getValue("commonName"));
      inst2 = (Instance)inst.getValue("virtFKToRelColl");
      assertEquals("Zoe", inst2.getValue("firstName"));
      assertEquals("Test", inst2.getValue("lastName"));

      inst = list.getInstance(2);
      assertEquals("Spider", inst.getValue("commonName"));
      assertNull(inst.getValue("virtFKToRelColl"));


      // Read the reverse (the relational collection)
      Metaclass relationalClass = getMetadata().getMetaclass("PetOwner");
      InstanceArrayList list2;

      list = (InstanceArrayList)Query.createRead(relationalClass,
         parse("(firstName (relCollFromVirtFK commonName))"),
         parse("(= (@ lastName) \"Test\")"),
View Full Code Here

      assertEquals("Felis catus", inst2.getValue("scientificName"));
   }

   public void testReadAssocVirtualAttrToRelationalFKNoAttr() throws Exception
   {
      Metaclass virtualClass = getMetadata().getMetaclass("Animal");
      InstanceArrayList list;
      Instance inst, inst2;

      list = (InstanceArrayList)Query.createRead(virtualClass,
         parse("(commonName (virtAttrToRelFKNoAttr firstName lastName))"),
View Full Code Here

   /**
    * Tests that an attribute in a where clause does not get expanded into OID components.
    */
   public void testReadAssocVirtualFKToRelationalCollectionWhereClause() throws Exception
   {
      Metaclass virtualClass = getMetadata().getMetaclass("Animal");
      InstanceArrayList list;
      Instance inst, inst2;

      list = (InstanceArrayList)Query.createRead(virtualClass,
         parse("(commonName (virtFKToRelColl firstName))"),
View Full Code Here

      assertTrue(list.isEmpty());
   }

   public void testReadAssocMultipartVirtualFKToRelationalPK()
   {
      Metaclass testClass = getMetadata().getMetaclass("TestVirtualClass");
      InstanceList list = Query.createRead(testClass,
         parse("(f1)"), parse("(= (@ f) 1)"), null, -1, 0, false, Query.SEC_ALL, m_context
      ).read();

      assertEquals("Cottage", ((Instance)list.getInstance(0).getValue("f1")).getValue("caption"));
View Full Code Here

      }
      catch (MetadataLookupException e)
      {
      }

      Metaclass test = m_meta.getMetaclass("mod1:Test");

      assertEquals("mod1:Test", test.getName());
      assertSame(test, test.getAttribute("test").getType());
   }
View Full Code Here

      {
         boolean bLogged = false;

         for (Iterator itr = metadata.getMetaclassIterator(); itr.hasNext();)
         {
            Metaclass metaclass = (Metaclass)itr.next();

            if (metaclass.hasAspect(aspect))
            {
               if (!bLogged)
               {
                  if (s_logger.isDebugEnabled())
                  {
                     s_logger.debug("Started " + sDescription);
                  }

                  bLogged = true;
               }

               metaclass.invoke(sEvent);

               if (bPreCommit)
               {
                  context.getUnitOfWork().commit(false);
               }
View Full Code Here

TOP

Related Classes of nexj.core.meta.Metaclass$AttributeDependencyVisitor

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.