Package nexj.core.meta

Examples of nexj.core.meta.Attribute$InverseDependency


      for (int i = 0; i < nCount; i++)
      {
         if (instance.isDirty(i))
         {
            Attribute attribute = metaclass.getInstanceAttribute(i);
            AttributeMapping attributeMapping = m_mapping.getAttributeMapping(attribute);

            if (attributeMapping != null && (attribute.getType().isPrimitive() ||
               !((VirtualClassMapping)attributeMapping).getKey(false).isObjectKey()))
            {
               m_attributeSet.set(i);
            }
         }
View Full Code Here


      UpdateMapping updateMapping = mapping.getUpdateMapping();
      Metaclass metaclass = mapping.getMetaclass();
      List updateList = updateMapping.getUpdateCases(m_attributeSet);

      // Execute updates
      Attribute lockingAttribute = mapping.getLockingAttribute();
      int nLockingOrdinal = (lockingAttribute == null) ? -1 : lockingAttribute.getOrdinal();
      String sLockingAttributeName = (lockingAttribute == null) ? null : lockingAttribute.getName();
      VirtualDataSourceFragment fragment = (VirtualDataSourceFragment)getFragment();

      for (int i = 0, nSize = updateList.size(); i < nSize; i++)
      {
         UpdateMappingCase update = (UpdateMappingCase)updateList.get(i);
         BitSet updateAttrSet = update.getAttributeSet();
         ArrayList tobjList =  new ArrayList(nEnd - nStart);
         int nUpdateAttrCount = updateAttrSet.cardinality() + ((nLockingOrdinal >= 0) ? 1 : 0);
         boolean bIgnoreDirty = !update.isDirty();
         boolean bFull = update.isFull();

         for (int k = nStart; k < nEnd; k++)
         {
            VirtualUpdate work = (VirtualUpdate)workArray[k];
            Instance instance = work.getInstance();
            TransferObject tobj = new TransferObject(instance.getOID(), metaclass.getName(), EVENT, nUpdateAttrCount);

            if (bFull)
            {
               for (int m = 0, nCount = metaclass.getInstanceAttributeCount(); m < nCount; m++)
               {
                  Attribute attribute = metaclass.getInstanceAttribute(m);

                  if (bIgnoreDirty || instance.isDirty(m))
                  {
                     setValue(tobj, attribute, instance.getValue(m));
                  }
               }
            }
            else
            {
               for (int m = updateAttrSet.nextSetBit(0); m >= 0; m = updateAttrSet.nextSetBit(m + 1))
               {
                  Attribute attribute = metaclass.getInstanceAttribute(m);

                  if (bIgnoreDirty || instance.isDirty(m))
                  {
                     setValue(tobj, attribute, instance.getValue(m));
                  }
View Full Code Here

            // Compute OID from attribute values
            Object[] valueArray = null;

            for (int i = 0; i < nCount; i++)
            {
               Attribute attribute = metaclass.getInstanceAttribute(i);

               if (attribute.getType().isPrimitive())
               {
                  VirtualPrimitiveMapping attrMapping = (VirtualPrimitiveMapping)mapping.getAttributeMapping(attribute);

                  if (attrMapping != null// ignore non-persisted attributes
                  {
View Full Code Here

   public Object getValue(OID oid, Source source)
   {
      if (source instanceof Field)
      {
         Field field = (Field)source;
         Attribute attribute = field.getAttribute();

         if (attribute.getType().isPrimitive())
         {
            VirtualPrimitiveMapping attrMapping = (VirtualPrimitiveMapping)field.getAttributeMapping();
            int nKeyPart = attrMapping.getObjectKeyPart();

            if (nKeyPart >= 0)
View Full Code Here

      {
         root.visit(new Query.Visitor()
         {
            public boolean visit(Query query)
            {
               Attribute attribute = query.getAttribute();

               root.addOutputQuery(query);

               if (query.isRoot())
               {
View Full Code Here

               if (sortKey.isUnique())
               {
                  for (int i = 0, n = sortKey.getAttributeCount(); i < n; i++)
                  {
                     Attribute attr = sortKey.getAttribute(i);

                     if (attr == null || !attrSet.get(attr.getOrdinal()))
                     {
                        continue loop;
                     }
                  }
View Full Code Here

    */
   public void addAttributeMapping(AttributeMapping mapping)
   {
      verifyNotReadOnly();

      Attribute attribute = mapping.getAttribute();

      if (m_mappingArray == null)
      {
         m_mappingArray = new AttributeMapping[attribute.getMetaclass().getInstanceAttributeCount()];
      }

      if (m_mappingArray[attribute.getOrdinal()] != null)
      {
         throw new MetadataException("err.meta.attributeMappingDup",
            new Object[]{attribute.getName(), getMetaclass().getName()});
      }

      m_mappingArray[attribute.getOrdinal()] = mapping;
      mapping.setPersistenceMapping(this);
   }
View Full Code Here

                           String sAttributeName = XMLUtil.getStringAttr(element, "attribute");

                           if (sAttributeName != null)
                           {
                              Attribute attribute = metaclass.getAttribute(sAttributeName);
                              VirtualPrimitiveMapping primitiveMapping = new VirtualPrimitiveMapping();

                              primitiveMapping.setObjectKeyPart(keyTypeList.size() - 1);
                              primitiveMapping.setAttribute(attribute);
                              mapping.addAttributeMapping(primitiveMapping);
                              primitiveMapping.validate(metadata, m_helper.getWarnings());
                           }
                        }
                     });

                     mapping.setKey((Primitive[])keyTypeList.toArray(new Primitive[keyTypeList.size()]));
                  }
               });

               XMLUtil.withFirstChildElement(element, "AttributeMappings", false,
                  new XMLUtil.ElementHandler()
               {
                  public void handleElement(Element element)
                  {
                     XMLUtil.forEachChildElement(element, "AttributeMapping", new XMLUtil.ElementHandler()
                     {
                        public void handleElement(Element element)
                        {
                           String sName = XMLUtil.getReqStringAttr(element, "name");
                           int nMaxLength = XMLUtil.getIntAttr(element, "maxLength", 0);
                           final Attribute attribute = metaclass.getAttribute(sName);
                           AttributeMapping attrMapping;

                           if (attribute.getType().isPrimitive())
                           {
                              VirtualPrimitiveMapping primitiveMapping = new VirtualPrimitiveMapping();

                              attrMapping = primitiveMapping;

                              if (element.hasAttribute("attributes"))
                              {
                                 throw new MetadataException("err.meta.persistence.virtual.invalidPropertySpecified",
                                    new Object[]{"attributes", sName, metaclass.getName()});
                              }

                              if (XMLUtil.getBooleanAttr(element, "objectSourceKey", false))
                              {
                                 throw new MetadataException("err.meta.persistence.virtual.invalidPropertySpecified",
                                    new Object[]{"objectSourceKey", sName, metaclass.getName()});
                              }

                              if (element.hasAttribute("destinationKey"))
                              {
                                 throw new MetadataException("err.meta.persistence.virtual.invalidPropertySpecified",
                                    new Object[]{"destinationKey", sName, metaclass.getName()});
                              }

                              if (nMaxLength != 0)
                              {
                                 if (attribute.getType() != Primitive.BINARY && attribute.getType() != Primitive.STRING)
                                 {
                                    throw new MetadataException("err.meta.persistence.virtual.maxLengthSpecified",
                                       new Object[]{attribute.getName(), metaclass.getName()});
                                 }

                                 primitiveMapping.setMaxLength(nMaxLength);
                              }
                           }
                           else
                           {
                              final VirtualClassMapping classMapping = new VirtualClassMapping();

                              attrMapping = classMapping;

                              classMapping.setComposition((Pair)m_helper.parse(
                                 XMLUtil.getStringAttr(element, "attributes"),
                                 true, null, null, metadata.getGlobalEnvironment()
                              ));

                              final boolean bObjectSourceKey = XMLUtil.getBooleanAttr(element, "objectSourceKey", false);
                              final String sDestinationKeyName = XMLUtil.getStringAttr(element, "destinationKey");

                              if (nMaxLength != 0)
                              {
                                 throw new MetadataException("err.meta.persistence.virtual.maxLengthSpecified",
                                    new Object[]{attribute.getName(), metaclass.getName()});
                              }

                              loader.addPersistenceMappingFixup(new ContextFixup(m_helper)
                              {
                                 public void fixup()
                                 {
                                    Metaclass type = (Metaclass)attribute.getType();
                                    PersistenceMapping assocClassMapping = type.getPersistenceMapping();

                                    if (assocClassMapping == null)
                                    {
                                       throw new MetadataException("err.meta.missingAssocPersistenceMapping",
                                          new Object[]{attribute.getName(), metaclass.getName(), type.getName()});
                                    }

                                    classMapping.setSourceKey((bObjectSourceKey) ? mapping.getObjectKey() : new VirtualKey(attribute));
                                    classMapping.setDestinationKey(assocClassMapping.addForeignKey(sDestinationKeyName, classMapping));
                                 }
View Full Code Here

               addTable(mapping.getTable(i));
            }

            for (int i = 0, nCount = mapping.getMetaclass().getInstanceAttributeCount(); i < nCount; ++i)
            {
               Attribute baseAttribute = mapping.getMetaclass().getInstanceAttribute(i);
               AttributeMapping baseAttrMapping = mapping.getAttributeMapping(baseAttribute);

               if (baseAttrMapping != null)
               {
                  Attribute derivedAttribute = m_metaclass.getDerivedAttribute(baseAttribute);
                  AttributeMapping derivedAttrMapping = getAttributeMapping(derivedAttribute);

                  if (derivedAttrMapping == null)
                  {
                     if (derivedAttribute.getType() == baseAttribute.getType())
                     {
                        derivedAttrMapping = (AttributeMapping)baseAttrMapping.clone(derivedAttribute);
                        derivedAttrMapping.setAttribute(derivedAttribute);
                        addAttributeMapping(derivedAttrMapping);
                     }
                  }
                  else if (m_typeCodeAttribute != null || mapping.m_typeCodeAttribute != null)
                  {
                     boolean bMismatch;

                     if (baseAttrMapping instanceof RelationalPrimitiveMapping)
                     {
                        bMismatch = (((RelationalPrimitiveMapping)derivedAttrMapping).getColumn() !=
                           ((RelationalPrimitiveMapping)baseAttrMapping).getColumn());
                     }
                     else
                     {
                        RelationalClassMapping baseClassMapping = (RelationalClassMapping)baseAttrMapping;
                        RelationalClassMapping classMapping = (RelationalClassMapping)derivedAttrMapping;

                        bMismatch = (classMapping.getDestinationKey() != baseClassMapping.getDestinationKey() ||
                           classMapping.getSourceKey() != baseClassMapping.getSourceKey());
                     }

                     if (bMismatch)
                     {
                        MetadataValidationException e = new MetadataValidationException(
                           "err.meta.persistenceMappingMismatch",
                           new Object[]{derivedAttribute.getName(), m_metaclass.getName(), mapping.getMetaclass().getName()});

                        derivedAttribute.setProperties(e);

                        throw e;
                     }
                  }
               }
View Full Code Here

      // Set up the default reverse association mappings

      for (int i = 0, nCount = m_metaclass.getInstanceAttributeCount(); i < nCount; ++i)
      {
         Attribute attribute = m_metaclass.getInstanceAttribute(i);
         Attribute reverse = attribute.getReverse();

         if (reverse != null && attribute.isSymmetric())
         {
            RelationalClassMapping mapping = (RelationalClassMapping)getAttributeMapping(attribute);

            if (mapping == null)
            {
               AttributeMapping attributeMapping = reverse.findPersistenceMapping(this, true);

               if (attributeMapping instanceof RelationalClassMapping)
               {
                  RelationalClassMapping reverseMapping = (RelationalClassMapping)attributeMapping;
View Full Code Here

TOP

Related Classes of nexj.core.meta.Attribute$InverseDependency

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.