Package nexj.core.runtime

Examples of nexj.core.runtime.InstanceArrayList$InstanceSublist


            if (value == Undefined.VALUE)
            {
               if (assoc.isCollection())
               {
                  instanceList = new InstanceArrayList();
                  instanceList.setAssociation(container, assoc, true);
                  instanceList.setLazy(false);
                  container.setOldValueDirect(assoc.getOrdinal(), instanceList);
               }
               else
View Full Code Here


            m_instanceList = m_cachedInstanceList;
            m_bEOF = true;
         }
         else
         {
            m_instanceList = new InstanceArrayList((m_nMaxCount >= 0) ? m_nMaxCount + 1 : 9);
         }
      }
      else
      {
         m_instanceList.clear();
      }

      if (m_cachedInstanceList != null)
      {
         if (m_instanceList != m_cachedInstanceList)
         {
            int nCount = m_cachedInstanceList.size() - m_nTotalCount;

            if (nCount <= 0)
            {
               m_bEOF = true;
            }
            else
            {
               if (m_nMaxCount > 0 && m_nMaxCount < nCount)
               {
                  nCount = m_nMaxCount;
               }

               if (nCount > m_nLimit && m_nLimit > 0 && nMaxCount < 0)
               {
                  throw new DataVolumeException("err.persistence.instanceCount",
                     new Object[]{m_query.getMetaclass().getName(), Primitive.createInteger(m_nLimit)});
               }

               for (int i = m_nTotalCount; --nCount >= 0; ++i)
               {
                  m_instanceList.add(m_cachedInstanceList.getInstance(i), InstanceList.DIRECT);
               }
            }
         }
      }
      else
      {
         while (internalStep(bDiscardExtra) && !bStep)
         {
            int nCount = m_instanceList.getCount();

            if (nCount > m_nLimit && m_nLimit > 0 && nMaxCount < 0)
            {
               throw new DataVolumeException("err.persistence.instanceCount",
                  new Object[]{m_query.getMetaclass().getName(), Primitive.createInteger(m_nLimit)});
            }
         }
      }

      m_nTotalCount += Math.max(m_instanceList.getCount() - m_nOffset, 0);

      if (!bStep)
      {
         completeQuery();
         logDuration(lStartTime, false);
      }

      if (m_bEOF)
      {
         release();
      }
      else
      {
         if (m_instanceSet != null)
         {
            m_instanceSet.clear();
         }
      }

      // Remove the empty elements according to the query offset

      InstanceList instanceList;

      if (m_nOffset > 0)
      {
         int nCount = m_instanceList.getCount() - m_nOffset;

         if (nCount < 0)
         {
            nCount = 0;
         }

         instanceList = new InstanceArrayList(nCount);

         for (int i = m_nOffset; nCount > 0; ++i, --nCount)
         {
            instanceList.add(m_instanceList.getInstance(i), InstanceList.DIRECT);
         }
View Full Code Here

    */
   public InstanceList next(int nMaxCount)
   {
      if (m_bEOF)
      {
         return new InstanceArrayList(0);
      }

      internalNext(nMaxCount, false);

      InstanceList instanceList = m_instanceList;
View Full Code Here

   }

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

      list = (InstanceArrayList)Query.createRead(relationalClass,
         parse("(firstName lastName (relFKToVirtNone 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("relFKToVirtNone");
      assertEquals("Beaver", inst2.getValue("commonName"));
      assertEquals("Castor canadensis", inst2.getValue("scientificName"));

      inst = list.getInstance(1);
      assertEquals("Zoe", inst.getValue("firstName"));
      inst2 = (Instance)inst.getValue("relFKToVirtNone");
      assertEquals("Spider", inst2.getValue("commonName"));
   }
View Full Code Here

   public void testLazyRelationalJoiningVirtual() throws Exception
   {
      Metaclass relationalClass = getMetadata().getMetaclass("PetOwner");
      Metaclass virtualClass = getMetadata().getMetaclass("Animal");
      InstanceArrayList list;
      Instance inst;
      int nStartCallCount;

      nStartCallCount = ((Integer)virtualClass.getValue("objectKeyReadCount")).intValue();
      list = (InstanceArrayList)Query.createRead(relationalClass,
         null,
         null,
         null,
         -1, 0, false, Query.SEC_NODE, m_context).read();

      assertEquals(2, list.getCount());
      assertEquals(nStartCallCount, ((Integer)virtualClass.getValue("objectKeyReadCount")).intValue());
      inst = list.getInstance(0);
      assertEquals(nStartCallCount, ((Integer)virtualClass.getValue("objectKeyReadCount")).intValue());
      s_logger.info("***** Start lazy load *****");
      assertEquals("Joe", inst.getValue("firstName"));
      s_logger.info("***** End lazy load *****");

 
View Full Code Here

   public void testLazyVirtualJoiningRelational() throws Exception
   {
      Metaclass virtualClass = getMetadata().getMetaclass("Animal");
      ReadCountHook readCountHook = (ReadCountHook)((SQLAdapter)getMetadata().getDataSource("DefaultRelationalDatabase").getComponent().getInstance(m_context)).getSQLHook();
      InstanceArrayList list;
      Instance inst;
      int nStartReadCount;

      nStartReadCount = readCountHook.getReadCount();
      list = (InstanceArrayList)Query.createRead(virtualClass,
         null,
         null,
         null,
         -1, 0, false, Query.SEC_NODE, m_context).read();

      assertEquals(4, list.getCount());
      assertEquals(nStartReadCount, readCountHook.getReadCount());
      inst = list.getInstance(0);
      assertEquals(nStartReadCount, readCountHook.getReadCount());
      assertEquals("Dog", inst.getValue("commonName"));
      assertEquals(nStartReadCount, readCountHook.getReadCount());
   }
View Full Code Here

   }

   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,
         -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("virtAttrFromRelFK"));

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

      inst = list.getInstance(2);
      assertEquals("Spider", inst.getValue("commonName"));
      inst2 = (Instance)inst.getValue("virtAttrFromRelFK");
      assertEquals("Joe", inst2.getValue("firstName"));
      assertEquals("Test", inst2.getValue("lastName"));
   }
View Full Code Here

   }

   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);
      assertEquals("Dog", inst.getValue("commonName"));
      assertEquals(0, ((InstanceArrayList)inst.getValue("virtCollFromRelFK")).size());

      inst = list.getInstance(1);
      assertEquals("Cat", inst.getValue("commonName"));
      list2 = (InstanceArrayList)inst.getValue("virtCollFromRelFK");
      assertEquals(1, list2.size());
      inst2 = list2.getInstance(0);
      assertEquals("Joe", inst2.getValue("firstName"));
      assertEquals("Test", inst2.getValue("lastName"));
   }
View Full Code Here

   }

   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))"),
         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("virtFKToRelNone");
      assertEquals("Zoe", inst2.getValue("firstName"));

      inst = list.getInstance(1);
      assertEquals("Cat", inst.getValue("commonName"));
      inst2 = (Instance)inst.getValue("virtFKToRelNone");
      assertEquals("Joe", inst2.getValue("firstName"));
      assertEquals("Test", inst2.getValue("lastName"));
     
      inst = list.getInstance(2);
      assertEquals("Spider", inst.getValue("commonName"));
      assertNull(inst.getValue("virtFKToRelNone"));
   }
View Full Code Here

   }

   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,
         -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("relAttrFromVirtFK");
      assertEquals("Spider", inst2.getValue("commonName"));

      inst = list.getInstance(1);
      assertEquals("Zoe", inst.getValue("firstName"));
      inst2 = (Instance)inst.getValue("relAttrFromVirtFK");
      assertEquals("Beaver", inst2.getValue("commonName"));
      assertEquals("Castor canadensis", inst2.getValue("scientificName"));
   }
View Full Code Here

TOP

Related Classes of nexj.core.runtime.InstanceArrayList$InstanceSublist

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.