Examples of ContextFixup


Examples of nexj.core.meta.xml.XMLMetadataHelper.ContextFixup

         if (action.getType() == Action.MAIN)
         {
            throw new MetadataException("err.meta.relativeMainAction");
         }

         m_actionFixupList.add(new ContextFixup(m_helper)
         {
            public void fixup()
            {
               action.setNextAction(sRelativeName);
            }
View Full Code Here

Examples of nexj.core.meta.xml.XMLMetadataHelper.ContextFixup

         }

         loadDocumentation(enumerationElement, metaclass);
         m_metadata.defineMetaclass(sBaseName, metaclass).addDerived(metaclass);

         m_inheritanceCheckList.add(new ContextFixup(m_helper)
         {
            public void fixup()
            {
               metaclass.checkInheritance();
            }
         });

         if (sParentEnumeration != null)
         {
            final String sAssociation = XMLUtil.getStringAttr(enumerationElement, "association");

            if (sAssociation == null)
            {
               throw new MetadataException("err.meta.missingEnumAssoc", new Object[]{sEnumerationName});
            }

            final String sReverse = XMLUtil.getStringAttr(enumerationElement, "reverse");

            if (sReverse == null)
            {
               throw new MetadataException("err.meta.missingEnumReverse", new Object[]{sEnumerationName});
            }

            XMLMetadataHelper.validateName(sAssociation);

            m_attributeGenerationList.add(new ContextFixup(m_helper)
            {
               public void fixup()
               {
                  final Metaclass parentMetaclass = m_metadata.getMetaclass(sParentEnumeration);

                  final Attribute parentAttribute = new Attribute(sReverse);

                  parentAttribute.setMetaclass(metaclass);
                  parentAttribute.setDeclarator(metaclass);
                  parentAttribute.setType(parentMetaclass);
                  parentAttribute.setRequired(true);

                  metaclass.addAttribute(parentAttribute);

                  final Attribute childAttribute = new Attribute(sAssociation);

                  childAttribute.setMetaclass(parentMetaclass);
                  childAttribute.setDeclarator(parentMetaclass);
                  childAttribute.setType(metaclass);
                  childAttribute.setCollection(true);
                  childAttribute.setReverse(parentAttribute);

                  parentMetaclass.addAttribute(childAttribute);

                  m_persistenceMappingGenerationList.add(new ContextFixup(m_helper)
                  {
                     public void fixup()
                     {
                        copyAttributeMapping(parentAttribute, metaclass.getAttribute("parent"));
                        copyAttributeMapping(childAttribute, parentMetaclass.getAttribute("children"));
                     }

                     protected void copyAttributeMapping(Attribute dst, Attribute src)
                     {
                        PersistenceMapping mapping = src.getMetaclass().getPersistenceMapping();

                        if (mapping.getAttributeMapping(dst) != null)
                        {
                           return;
                        }

                        for (PersistenceMapping baseMapping = mapping;
                           baseMapping != null && baseMapping.isCompatible(mapping);
                           baseMapping = baseMapping.getBaseMapping())
                        {
                           Attribute attribute = baseMapping.getMetaclass().findAttribute(src.getName());

                           if (attribute != null)
                           {
                              AttributeMapping attributeMapping = baseMapping.getAttributeMapping(attribute);

                              if (attributeMapping != null)
                              {
                                 attributeMapping = (AttributeMapping)attributeMapping.clone();

                                 attributeMapping.setPersistenceMapping(mapping);
                                 attributeMapping.setAttribute(dst);

                                 ((ClassMapping)attributeMapping).setMapping(((Metaclass)dst.getType()).getPersistenceMapping());

                                 mapping.addAttributeMapping(attributeMapping);

                                 return;
                              }
                           }
                        }

                        throw new MetadataException("err.meta.enumAssociation",
                           new Object[]{src.getName(), src.getMetaclass().getName()});
                     }
                  });
               }
            });
         }

         final String sTypeCode = XMLUtil.getReqStringAttr(enumerationElement, "typeCode");

         m_inheritance1stPassFixupList.add(new ContextFixup(m_helper)
         {
            public void fixup()
            {
               Attribute attribute = null;

               for (PersistenceMapping mapping = metaclass.getPersistenceMapping();
                  mapping != null; mapping = mapping.getBaseMapping())
               {
                  attribute = mapping.getTypeCodeAttribute();

                  if (attribute != null)
                  {
                     attribute = metaclass.getDerivedAttribute(attribute);

                     break;
                  }
               }

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

               attribute.setValue(attribute.getType().convert(sTypeCode));
            }
         });
      }

      if (m_bValidatedOnly)
      {
         XMLUtil.withFirstChildElement(enumerationElement, "Locales", false, new ElementHandler()
         {
            public void handleElement(Element localesElement)
            {
               final Set localeSet = new HashHolder();

               XMLUtil.forEachChildElement(localesElement, "Locale",
                  m_helper.new ElementHandler("locale")
               {
                  public void handleElement(Element localeElement, String sLocale)
                  {
                     if (!localeSet.add(sLocale))
                     {
                        throw new MetadataException("err.meta.enumLocaleDup",
                           new Object[]{sLocale, sEnumerationName});
                     }

                     XMLUtil.getReqStringAttr(localeElement, "caption");
                  }
               });
            }
         });
      }

      final Set valueSet = new HashHolder();
      m_enumerationValueMap.put(sEnumerationName, valueSet);

      XMLUtil.withFirstChildElement(enumerationElement, "Values", false, new ElementHandler()
      {
         public void handleElement(Element valuesElement)
         {
            final Set nameSet = new HashHolder();
            final Set behaveAsSet = new HashHolder();
            final Set externSet = new HashHolder();
            final List fixupList = new ArrayList();

            XMLUtil.forEachChildElement(valuesElement, "Value",
               m_helper.new ElementHandler("value")
            {
               public void handleElement(Element valueElement, String sName)
               {
                  XMLMetadataHelper.validateName(sName);

                  fixupList.add(sName);

                  if (!nameSet.add(sName))
                  {
                     throw new MetadataException("err.meta.enumValueNameDup",
                        new Object[]{sName, sEnumerationName});
                  }

                  final String sValue = XMLUtil.getReqStringAttr(valueElement, "value");

                  if (!valueSet.add(sValue))
                  {
                     throw new MetadataException("err.meta.enumValueDup",
                        new Object[]{sValue, sEnumerationName});
                  }

                  fixupList.add(sValue);

                  boolean bHasBehavior = XMLUtil.getBooleanAttr(valueElement, "hasBehavior", false);

                  fixupList.add(Boolean.valueOf(bHasBehavior));

                  String sBehaveAsValue = XMLUtil.getStringAttr(valueElement, "behaveAsValue");

                  if (sBehaveAsValue != null)
                  {
                     if (bHasBehavior)
                     {
                        if (!sBehaveAsValue.equals(sValue))
                        {
                           throw new MetadataException("err.meta.enumBehaveAsValueMismatch",
                              new Object[]{sBehaveAsValue, sValue, sEnumerationName});
                        }
                     }
                     else
                     {
                        if (sBehaveAsValue.equals(sValue))
                        {
                           throw new MetadataException("err.meta.enumInvalidSelfReference",
                              new Object[]{sValue, sEnumerationName});
                        }

                        behaveAsSet.add(sBehaveAsValue);
                     }
                  }

                  String sExternValue = XMLUtil.getStringAttr(valueElement, "externalValue");

                  if (sExternValue != null)
                  {
                     if (!externSet.add(sExternValue))
                     {
                        throw new MetadataException("err.meta.enumExternValueDup",
                           new Object[]{sExternValue, sEnumerationName});
                     }
                  }

                  final String sParentValue = XMLUtil.getStringAttr(valueElement, "parentValue");

                  if (sParentValue != null)
                  {
                     if (sParentEnumeration == null)
                     {
                        throw new MetadataException("err.meta.enumParentValue", new Object[]{sEnumerationName});
                     }

                     m_inheritanceFixupList.add(new ContextFixup(m_helper)
                     {
                        public void fixup()
                        {
                           Metaclass parent = m_metadata.getMetaclass(sParentEnumeration);

                           if (!((Set)m_enumerationValueMap.get(sParentEnumeration)).contains(parent.getAttribute("value").getType().convert(sParentValue)))
                           {
                              throw new MetadataLookupException("err.meta.enumParentValueLookup", sParentValue, sParentEnumeration);
                           }
                        }
                     });
                  }
                  else
                  {
                     if (sParentEnumeration != null)
                     {
                        throw new MetadataException("err.meta.enumNoParentValue", new Object[]{sValue, sEnumerationName});
                     }
                  }

                  if (m_bValidatedOnly)
                  {
                     XMLUtil.withFirstChildElement(valueElement, "Locales", false, new ElementHandler()
                     {
                        public void handleElement(Element localesElement)
                        {
                           final Set localeSet = new HashHolder();

                           XMLUtil.forEachChildElement(localesElement, "Locale",
                              m_helper.new ElementHandler("locale")
                           {
                              public void handleElement(Element localeElement, String sLocale)
                              {
                                 if (!localeSet.add(sLocale))
                                 {
                                    throw new MetadataException("err.meta.enumValueLocaleDup",
                                       new Object[]{sLocale, sValue, sEnumerationName});
                                 }

                                 XMLUtil.getReqStringAttr(localeElement, "caption");
                              }
                           });
                        }
                     });
                  }
               }
            });

            if (behaveAsSet.size() != 0)
            {
               // Remove the values that have no behavior
               for (int i = 0, n = fixupList.size(); i != n; i += 3)
               {
                  if (!((Boolean)fixupList.get(i + 2)).booleanValue())
                  {
                     valueSet.remove(fixupList.get(i + 1));
                  }
               }

               for (Iterator itr = behaveAsSet.iterator(); itr.hasNext();)
               {
                  String sValue = (String)itr.next();

                  if (!valueSet.contains(sValue))
                  {
                     throw new MetadataLookupException("err.meta.enumBehaveAsValueLookup",
                        sValue, sEnumerationName);
                  }
               }
            }

            valueSet.clear();

            m_attributeGenerationList.add(new ContextFixup(m_helper)
            {
               public void fixup()
               {
                  Primitive type = null;
View Full Code Here

Examples of nexj.core.meta.xml.XMLMetadataHelper.ContextFixup

      loadActivity(workflowElement.getFirstChild(), workflow);
      m_metadata.addWorkflow(workflow);
      m_helper.fixup(m_flowFixupList.iterator());
      m_flowFixupList = null;

      m_persistenceMappingFixupList.add(new ContextFixup(m_helper)
      {
         public void fixup()
         {
            workflow.resolve(m_machine);
         }
View Full Code Here

Examples of nexj.core.meta.xml.XMLMetadataHelper.ContextFixup

                  step = new Goto();
               }

               final Step fstep = step;

               m_flowFixupList.add(new ContextFixup(getHelper())
               {
                  public void fixup()
                  {
                     fstep.setNext(activity.getFlow().getFlowStep(sNextStepName));
                  }
View Full Code Here

Examples of nexj.core.meta.xml.XMLMetadataHelper.ContextFixup

      final String sResponse = XMLUtil.getStringAttr(messageElement, "response");

      if (sResponse != null)
      {
         addPreInheritanceMessageFixup(new ContextFixup(getHelper())
         {
            public void fixup()
            {
               message.setResponse(m_metadata.getMessage(sResponse));
            }
         });
      }

      String sDerivation = XMLUtil.getStringAttr(messageElement, "derivation", "virtual");

      if (sDerivation.equals("virtual"))
      {
         message.setDerivation(Message.DERIVATION_VIRTUAL);
      }
      else if (sDerivation.equals("final"))
      {
         message.setDerivation(Message.DERIVATION_FINAL);
      }
      else if (sDerivation.equals("abstract"))
      {
         message.setDerivation(Message.DERIVATION_ABSTRACT);
      }
      else
      {
         throw new MetadataException("err.meta.integration.messageDerivation",
            new Object[] {sDerivation, message.getName()});
      }

      final String sBaseMessage = XMLUtil.getStringAttr(messageElement, "base");

      if (!loadMessageRef(null, message, messageElement, sName))
      {
         CompositeMessagePart compMsgPart = new CompositeMessagePartInstance(sName);

         message.setRoot(compMsgPart);
         loadCompositeMessagePart(messageElement, compMsgPart, message);
      }

      m_metadata.addMessage(message);

      if (sBaseMessage != null)
      {
         addPreInheritanceMessageFixup(new ContextFixup(m_helper)
         {
            public void fixup()
            {
               Message baseMessage = m_metadata.getMessage(sBaseMessage);
View Full Code Here

Examples of nexj.core.meta.xml.XMLMetadataHelper.ContextFixup

      int nCookie = m_helper.pushMarker("fullName", partRef.getFullPath());

      try
      {
         addPreInheritanceMessageFixup(new ContextFixup(m_helper)
         {
            public void fixup()
            {
               CompositeMessagePart root = m_metadata.getMessage(sRef).getRoot();
View Full Code Here

Examples of nexj.core.meta.xml.XMLMetadataHelper.ContextFixup

      final String sBase = XMLUtil.getStringAttr(transformationElement, "base");

      if (sBase != null)
      {
         addTransformationFixup(new ContextFixup(m_helper)
         {
            public void fixup()
            {
               Transformation baseTransformation = m_metadata.getTransformation(sBase);
View Full Code Here

Examples of nexj.core.meta.xml.XMLMetadataHelper.ContextFixup

                     argument.setSource(source);
                  }
                  else
                  {
                     m_postInheritanceTransformationFixupList.add(new ContextFixup(getHelper())
                     {
                        public void fixup()
                        {
                           argument.setMapping(transformation, sMapping);
                        }
View Full Code Here

Examples of nexj.core.meta.xml.XMLMetadataHelper.ContextFixup

               }
            });
         }
      });

      addSingletonFixup(new ContextFixup(m_helper)
      {
         public void fixup()
         {
            MessageTable table = iface.getRequestTable();
View Full Code Here

Examples of nexj.core.meta.xml.XMLMetadataHelper.ContextFixup

      loadSequence(serviceElement, service);
      m_metadata.addService(service);
      m_helper.fixup(m_flowFixupList.iterator());
      m_flowFixupList = null;

      m_persistenceMappingFixupList.add(new ContextFixup(m_helper)
      {
         public void fixup()
         {
            service.resolve(m_machine);
         }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.