Package nexj.core.meta.persistence

Examples of nexj.core.meta.persistence.Key


               }
            }

            private void setParentItem(Query query, Attribute attribute, ClassMapping mapping)
            {
               Key srcKey = mapping.getKey(false);

               if (srcKey.isObjectKey())
               {
                  // Child has FK
                  query.setParentItem(createOIDItem(query.getParent()));
               }
               else
View Full Code Here


               continue;
            }
         }

         // Find out if the sort key includes the primary key
         Key pk = getObjectKey();
         boolean bMatch = false;
         boolean bAscending = true;

         for (int i = 0, k = -1; i < sortKey.getAttributeCount(); i++)
         {
            Attribute attr = sortKey.getAttribute(i);

            if (attr == null)
            {
               bMatch = true;
               bAscending = sortKey.isAscending(i);

               break;
            }

            if (optionalSet != null && optionalSet.get(attr.getOrdinal()))
            {
               continue;
            }

            if (getAttributeMapping(attr) instanceof VirtualPrimitiveMapping)
            {
               VirtualPrimitiveMapping mapping = (VirtualPrimitiveMapping)getAttributeMapping(attr);

               if (mapping.getObjectKeyPart() >= 0)
               {
                  if (k == -1)
                  {
                     if (mapping.getObjectKeyPart() == 0)
                     {
                        k = 1;
                        bAscending = sortKey.isAscending(i);

                        continue;
                     }

                     break;
                  }

                  if (mapping.getObjectKeyPart() == k)
                  {
                     if ((pk.isPartAscending(0) ^ pk.isPartAscending(k)) != (bAscending ^ sortKey.isAscending(i)))
                     {
                        break;
                     }
                     else
                     {
                        if (k == pk.getPartCount() - 1)
                        {
                           bMatch = true;

                           break;
                        }
                     }
                  }
                  else
                  {
                     break;
                  }
               }
            }
         }

         Pair key = null;

         // If the above is true, then append the primary key
         // at the end of the sort key
         if (bMatch)
         {
            Pair[] objKeyAttributeArray = new Pair[pk.getPartCount()];

            for (int i = 0; i < m_metaclass.getInstanceAttributeCount(); i++)
            {
               Attribute attr = m_metaclass.getInstanceAttribute(i);

               if (getAttributeMapping(attr) instanceof VirtualPrimitiveMapping)
               {
                  VirtualPrimitiveMapping mapping = (VirtualPrimitiveMapping)getAttributeMapping(attr);

                  if (mapping.getObjectKeyPart() >= 0)
                  {
                     objKeyAttributeArray[mapping.getObjectKeyPart()] = new Pair(
                        attr.getSymbol(),
                        Boolean.valueOf(bAscending ^ !pk.isPartAscending(mapping.getObjectKeyPart()))
                     );
                  }
               }
            }
View Full Code Here

    * @throws IOException If an I/O error occurs.
    */
   protected void exportObjectKey(VirtualMapping mapping) throws IOException
   {
      Metaclass metaclass = mapping.getMetaclass();
      Key key = mapping.getObjectKey();
      int nCount = (key == null) ? 0 : key.getPartCount();

      if (nCount > 0)
      {
         m_writer.startElement("KeyParts");

         for (int i = 0; i < nCount; i++)
         {
            Primitive type = key.getPartType(i);

            m_writer.openElement("KeyPart");
            m_writer.writeAttribute("type", type.getName());

            for (int k = 0, nAttrCount = metaclass.getInstanceAttributeCount(); k < nAttrCount; k++)
View Full Code Here

         m_partTypeArray = new Primitive[] {(Primitive)attribute.getType()};
         m_bPartAscendingArray = new boolean[] {true};
      }
      else
      {
         Key objKey = ((Metaclass)attribute.getType()).getPersistenceMapping().getObjectKey();
         int nPartCount = objKey.getPartCount();

         m_bOIDAttribute = true;
         m_partTypeArray = new Primitive[nPartCount];
         m_bPartAscendingArray = new boolean[nPartCount];

         for (int i = 0; i < nPartCount; i++)
         {
            m_partTypeArray[i] = objKey.getPartType(i);
            m_bPartAscendingArray[i] = objKey.isPartAscending(i);
         }
      }
   }
View Full Code Here

               PersistenceMapping mapping = metaclass.getPersistenceMapping();

               if (mapping != null)
               {
                  Object[] valueArray = oid.getValueArray();
                  Key key = mapping.getObjectKey();

                  if (key.getPartCount() != valueArray.length)
                  {
                     throw new RequestException("err.rpc.oidPartCount", new Object[]
                     {
                        metaclass.getName()
                     });
                  }

                  for (int i = 0; i < valueArray.length; ++i)
                  {
                     valueArray[i] = key.getPartType(i).convert(valueArray[i]);
                  }
               }

               instance = new Instance(metaclass, m_context);
               m_context.getUnitOfWork().lock(instance.cache(oid), tobj.getEventName() != null);
View Full Code Here

                  Query query = source.getQuery();
                  Field[] fieldArray = query.getAdapter().getFields(query);

                  if (fieldArray != null)
                  {
                     Key key = query.getPersistenceMapping().getObjectKey();

                     for (int k = 0; k < fieldArray.length; ++k)
                     {
                        Field field = fieldArray[k];

                        field.setGroupedBy(true);

                        // No need to normalize
                        if (k == 0)
                        {
                           op.setSource(field);
                           op.setType(key.getPartType(k));
                           unconvert((AttributeOperator)op);
                        }
                        else
                        {
                           addGroupBy(++i, unconvert(new AttributeOperator(field)));
View Full Code Here

                  Query query = op.getSource().getQuery();
                  Field[] fieldArray = query.getAdapter().getFields(query);

                  if (fieldArray != null)
                  {
                     Key key = query.getPersistenceMapping().getObjectKey();
                     boolean bAscending = isOrderByAscending(i) ^ key.isPartAscending(0);

                     for (int k = 0; k < fieldArray.length; ++k)
                     {
                        // No need to normalize
                        if (k == 0)
                        {
                           op.setSource(fieldArray[k]);
                           op.setType(key.getPartType(k));
                           unconvert((AttributeOperator)op);
                        }
                        else
                        {
                           addOrderBy(++i, unconvert(new AttributeOperator(fieldArray[k])),
                              bAscending ^ key.isPartAscending(k));
                        }
                     }
                  }
               }
            }
View Full Code Here

         }

         for (int i = 0, n = mapping.getDenormCount(); i < n; ++i)
         {
            RelationalClassDenorm denorm = (RelationalClassDenorm)mapping.getDenorm(i);
            Key dstKey = ((RelationalClassMapping)denorm.getMapping()).getDestinationKey();

            SQLWork work = findWork(uow, instance, denorm.getSourceKey().getTable());

            if (work != null)
            {
View Full Code Here

      {
         Query query = (Query)source;

         if (query.getAttribute() != null)
         {
            Key key = query.getKey(true);

            if (key.isObjectKeyPart())
            {
               Field[] fieldArray = getFields(source);
               int nCount = fieldArray.length;

               if (nCount != oid.getCount() && nCount <= key.getPartCount())
               {
                  Object[] valueArray = new Object[nCount];

                  for (int i = 0; i < nCount; ++i)
                  {
                     int nOrdinal = key.getObjectKeyPartOrdinal(i);

                     if (nOrdinal >= oid.getCount())
                     {
                        return oid.getValueArray();
                     }
View Full Code Here

      {
         Query query = source.getQuery();

         if (query.getParent() != null)
         {
            Key key = query.getKey(false);

            if (key.isObjectKeyPart())
            {
               int nCount = key.getPartCount();
               Object[] valueArray = new Object[nCount];

               for (int i = 0; i < nCount; ++i)
               {
                  int nOrdinal = key.getObjectKeyPartOrdinal(i);

                  if (nOrdinal >= oid.getCount())
                  {
                     return Undefined.VALUE;
                  }
View Full Code Here

TOP

Related Classes of nexj.core.meta.persistence.Key

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.