Package nexj.core.meta

Examples of nexj.core.meta.Attribute$DirectInverseDependency


            metaclass.setDescription(table.getDescription());
  
            for (int i = 0; i < table.getColumnCount(); ++i)
            {
               final Column column = table.getColumn(i);
               final Attribute attribute = new Attribute(getAttributeName(column.getName(), metaclass));
               boolean bRequired = !column.isNullable() && column.getType() != Primitive.STRING;

               if (bRequired)
               {
                  Component component = column.getConverter();

                  if (component != null)
                  {
                     try
                     {
                        bRequired = (((Converter)component.getInstance(null)).getInverseFunction().invoke(null) == null);
                     }
                     catch (Throwable e)
                     {
                        // Still required if an error occurs
                     }
                  }
               }

               attribute.setDescription(column.getDescription());
               attribute.setMetaclass(metaclass);
               attribute.setDeclarator(metaclass);
               attribute.setRootDeclarator(metaclass);
               attribute.setType(column.getType());
               attribute.setRequired(bRequired);
               attribute.setOrdinal(metaclass.getAttributeCount());
               metaclass.addAttribute(attribute);

               final RelationalPrimitiveMapping mapping = new RelationalPrimitiveMapping();

               mapping.setColumn(column);
               mapping.setAttribute(attribute);

               fixupList2.add(new Fixup()
               {
                  public void fixup()
                  {
                     relationalMapping.addAttributeMapping(mapping);
                  }
               });
            }
           
            for (int i = 0; i < table.getRelatedKeyCount(); ++i)
            {
               final Index index = table.getRelatedKey(i);
  
               if (!index.getTable().isAspect())
               {
                  final Index primaryKey = table.getPrimaryKey();
                  final String sClassName = getClassName(index.getTable().getTableName(), sPrefix, nameMap);
                  final Attribute attribute = new Attribute(getAttributeName(sClassName, metaclass));
     
                  attribute.setMetaclass(metaclass);
                  attribute.setDeclarator(metaclass);
                  attribute.setRootDeclarator(metaclass);
                  attribute.setCollection(true);
                  attribute.setOrdinal(metaclass.getAttributeCount());
                  metaclass.addAttribute(attribute);
     
                  final RelationalClassMapping mapping = new RelationalClassMapping();
     
                  mapping.setAttribute(attribute);
                  mapping.setSourceKey(primaryKey);
                  mapping.setDestinationKey(index);
     
                  fixupList.add(new Fixup()
                  {
                     public void fixup()
                     {
                        final Metaclass mc = getMetadata().getMetaclass(sClassName);
                       
                        attribute.setType(mc);
                        mapping.setMapping(mc.getPersistenceMapping());
                       
                        Attribute a = new Attribute(getAttributeName(metaclass.getName(), mc));
                       
                        a.setMetaclass(mc);
                        a.setDeclarator(mc);
                        a.setRootDeclarator(mc);
                        a.setOrdinal(mc.getAttributeCount());
                        a.setType(metaclass);
                        a.setReverse(attribute);
                        attribute.setReverse(a);
                        mc.addAttribute(a);
     
                        final RelationalClassMapping m = new RelationalClassMapping();
     
View Full Code Here


   {
      Pair attributes = null;

      for (Iterator iter = instance.getMetaclass().getInstanceAttributeIterator(); iter.hasNext();)
      {
         Attribute attribute = (Attribute)iter.next();

         if (instance.isUpdateable(attribute) && instance.isDirty(attribute.getOrdinal()))
         {
            attributes = new Pair(attribute.getSymbol(), attributes);
         }
      }

      TransferObject tobj = (TransferObject)RPCUtil.transfer(instance, attributes, RPCUtil.TF_ALL);
View Full Code Here

      m_writer.closeElement();
      m_writer.startElement("Attributes");

      for (Iterator itr = metaclass.getInstanceAttributeIterator(); itr.hasNext();)
      {
         Attribute attribute = (Attribute)itr.next();

         if (attribute.getDeclarator() == metaclass)
         {
            exportAttribute(attribute);
         }
      }

      for (Iterator itr = metaclass.getStaticAttributeIterator(); itr.hasNext();)
      {
         Attribute attribute = (Attribute)itr.next();

         if (attribute.getDeclarator() == metaclass)
         {
            exportAttribute(attribute);
         }
      }
View Full Code Here

               bInvoked = instance.invokeSuspendedEvent();
               bDeleted = (instance.getState() == Instance.DELETED);

               if (nAttrIndex <= 0)
               {
                  Attribute attribute = instance.getMetaclass().findAttribute("attributes");

                  if (attribute != null && !attribute.isStatic())
                  {
                     attributes = (Pair)instance.getValue(attribute.getOrdinal());
                  }
               }
            }

            if (resultArray[i << 1] == null)
View Full Code Here

      if (metaclass != null)
      {
         for (Iterator/*<Attribute>*/ itr = metaclass.getAttributeIterator(); itr.hasNext();)
         {
            Attribute attribute = (Attribute)itr.next();
  
            if (!attribute.isStatic() && !attribute.isCalculated() &&
               attribute.getVisibility() == Metaclass.PUBLIC && !attribute.isCollection())
            {
               attributes = new Pair(attribute.getSymbol(), attributes);
            }
         }
      }

      return attributes;
View Full Code Here

         m_sType = meta.getName();

         for (Iterator itr = meta.getAttributeIterator(); itr.hasNext();)
         {
            Attribute attribute = (Attribute)itr.next();

            if (attribute.getVisibility() != Metaclass.PUBLIC)
            {
               continue;
            }

            AttributeInfo attrInfo;

            if (attribute.getType().isPrimitive())
            {
               // can resolve primitive Marshallers immediately since this is not a primitive
               // Marshaller hence no danger of recursion loop
               attrInfo = (Primitive.ANY.equals(attribute.getType()))
                        ? new AttributeInfo(attribute, null, true)
                        : new AttributeInfo(attribute,
                                            getMarshallerByClass(((Primitive)attribute.getType())
                                                                    .getClassObject()),
                                            false);
            }
            else if (attribute.getType() instanceof Metaclass)
            {
               // don't initialize marshaller to avoid recursive creation of self
               attrInfo = new AttributeInfo(attribute, null, bDynamicMetaclassTypes);
            }
            else
            {
               // need value to determine proper marshaller to use (assume it has a static type)
               attrInfo = new AttributeInfo(attribute, null, false);
            }

            m_attributeMap.put(attribute.getName(), attrInfo);
         }
      }
View Full Code Here

         }

         for (Lookup.Iterator itr = m_attributeMap.valueIterator(); itr.hasNext();)
         {
            AttributeInfo attrInfo = (AttributeInfo)itr.next();
            Attribute attribute = attrInfo.m_attribute;

            if (attribute.getVisibility() != Metaclass.PUBLIC)
            {
               continue;
            }

            Object value = tobj.findValue(attribute.getName(), Undefined.VALUE);

            if (value == Undefined.VALUE)
            {
               continue;
            }

            Marshaller attrMsh = attrInfo.m_marshaller; // get cached marshaller

            // if this is the first time through marshaller then initialize metaclass marshaller
            if (attrMsh == null)
            {
               if (attribute.getType() instanceof Metaclass)
               {
                  // determine proper marshaller based on attribute to guarantee valid type output
                  attrMsh = mrsh.findMetaclassMarshaller(attribute.getType().getName());
               }
               else if (!attrInfo.m_bDynamicMarshaller && value != null)
               {
                  // might is reachable for non-Metaclass attributes e.g. Throwable
                  attrMsh = mrsh.findMarshaller(value);
               }

               if (attrMsh == null && !attrInfo.m_bDynamicMarshaller && value != null)
               {
                  throw new SOAPMarshallerException("err.rpc.mshType",
                                                    new Object[]{attribute.getType().getName()});
               }

               // cache the marshaller for future reference
               if (attrMsh != null)
               {
                  synchronized(this)
                  {
                     // guarantee all instances will use same marshaller
                     if (attrInfo.m_marshaller == null)
                     {  // store for future lookups
                        attrInfo.m_marshaller = attrMsh;
                     }
                     else
                     {
                        attrMsh = attrInfo.m_marshaller;
                     }
                  }
               }
            }

            // if this is a dynamic marshaller for a metaclass that is not the same as attribute
            if (attrInfo.m_bDynamicMarshaller &&
                attrMsh instanceof MetaclassMarshaller &&
                value instanceof TransferObject &&
                ((TransferObject)value).getClassName() != null && // if unspecified then == default
                !((TransferObject)value).getClassName().equals(attribute.getType().getName()))
            {
               attrMsh = null;
            }

            if (value != null) // do not marshal null values since they will not work with MS.NET
            {
               if (attribute.isCollection())
               {
                  mrsh.marshalInline(((Iterable)value).iterator(), XML.TNS_NS, attrInfo.m_sName, attrMsh, MF_NIL);
               }
               else
               {
View Full Code Here

         for (Lookup.Iterator/*<Attribute, ObjectInstanceAccessor>*/ itr =
                 m_attributeMap.iterator();
              itr.hasNext();)
         {
            Attribute attribute = (Attribute)itr.next();
            ObjectInstanceAccessor accessor = (ObjectInstanceAccessor)itr.getValue();

            value = accessor.getValue(nObj, unmsh);

            // ObjectListAccessor use null to indicate there are no elements present
            value = (accessor instanceof ObjectListAccessor && value == null) ? EMPTY : value;

            if (value != EMPTY)
            {  // if have an explicitly set value
               instance.setValue(attribute.getName(), value);
               bRef = false; // ref can only have class & oid
            }
         }

         // remember valid compleated value
View Full Code Here

         if (m_metaclass != null)
         {
            for (Iterator/*<Attribute>*/ itr = m_metaclass.getAttributeIterator(); itr.hasNext();)
            {
               Attribute attribute = (Attribute)itr.next();
  
               if (attribute.getVisibility() != Metaclass.PUBLIC)
               {
                  continue; // ignore non-publicly visible attributes
               }

               String sTmpName = XSDGenerator.computeElementName(attribute);
               QName qType = getQualifiedType(attribute.getType());
               Unmarshaller unmarshaller =
                  unmsh.getUnmarshaller(qType.getNamespaceURI(), qType.getLocalPart(), null);

               if (unmarshaller != null)
               {
                  QName type = XML.getTNSType(sTmpName);
                  ObjectInstanceAccessor accessor = (attribute.isCollection())
                     ? new ObjectListAccessor(type, false, true, unmarshaller, false)
                     : new ObjectInstanceAccessor(type, false, true, unmarshaller, false);

                  addAccessor(accessor);
                  attributeMap.put(attribute, accessor);
View Full Code Here

   protected void addAttributeDependencies(Metaclass meta)
   {
      // add all attribute types
      for (Iterator/*<Attribute>*/ itr = meta.getAttributeIterator(); itr.hasNext();)
      {
         Attribute attr = (Attribute)itr.next();

         if (!attr.isStatic() && (!m_bCompatible || attr.isCompatible()))
         {
            setRequiredType(attr.getType(), false); // collections will repeat same element per item
         }
      }
   }
View Full Code Here

TOP

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

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.