Examples of ContextFixup


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

                  step = new Jump();
               }

               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

      if (sActivation.equals("singleton"))
      {
         component.setActivation(Component.SINGLETON);

         addSingletonFixup(new ContextFixup(m_helper)
         {
            public void fixup()
            {
               component.getInstance(null);
            }
View Full Code Here

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

            "/" + initializer.getName());

         component.setMetadata(m_metadata);
         loadComponent(element, component);

         m_componentFixupList.add(new ContextFixup(m_helper)
         {
            public void fixup()
            {
               initializer.initializeValue(component);
            }
View Full Code Here

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

      if (element == null)
      {
         final String sValue = m_helper.getElementValue(propertyElement);

         m_componentFixupList.add(new ContextFixup(m_helper)
         {
            public void fixup()
            {
               if (StringUtil.isEmpty(sValue))
               {
                  initializer.initializeValue(null);
               }
               else
               {
                  Component component = initializer.getComponent().getMetadata().getComponent(sValue);

                  if (!m_bRuntimeExcluded && !type.isAssignableFrom(component.getType()))
                  {
                     throw new MetadataException("err.meta.propertyTypeMismatch",
                        new Object[]{initializer.getName(), initializer.getComponent().getName()});
                  }

                  initializer.initializeValue(component);
               }
            }
         });
      }
      else
      {
         final Component component = new Component(initializer.getComponent().getName() +
            "/" + initializer.getName());

         component.setMetadata(m_metadata);
         loadComponent(element, component);

         if (!m_bRuntimeExcluded && !type.isAssignableFrom(component.getType()))
         {
            throw new MetadataException("err.meta.propertyTypeMismatch",
               new Object[]{initializer.getName(), initializer.getComponent().getName()});
         }

         m_componentFixupList.add(new ContextFixup(m_helper)
         {
            public void fixup()
            {
               initializer.initializeValue(component);
            }
View Full Code Here

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

    * Adds a singleton fixup handler.
    * @param component The component to fixup.
    */
   public void addSingletonFixup(final Component component)
   {
      addSingletonFixup(new ContextFixup(m_helper)
      {
         public void fixup()
         {
            component.getInstance(null);
         }
View Full Code Here

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

      if (bFirstRelationalDatabase)
      {
         if (!loader.isEnvironmentOnly())
         {
            // Find unmapped columns from mapped tables and set their required flag
            m_loader.addSingletonFixup(new ContextFixup(getHelper())
            {
               public void fixup()
               {
                  RelationalMapping.resolve(m_loader.getMetadata());
               }
            });
         }

         m_loader.addIOFixup(new ContextFixup(getHelper())
         {
            public void fixup()
            {
               Lookup aliasFragmentMap = new HashTab();
View Full Code Here

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

      XMLMetadataLoader.parsePatterns(XMLUtil.getStringAttr(tableElement, "aspects"),
         new XMLMetadataLoader.PatternHandler()
         {
            public void handlePattern(final String sName, final boolean bInclusive)
            {
               m_tableFixupList.add(new ContextFixup(getHelper())
               {
                  public void fixup()
                  {
                     table.addAspectOverride(table.getSchema().getTable(sName), bInclusive);
                  }
               });
            }
         });

      XMLMetadataLoader.parsePatterns(XMLUtil.getStringAttr(tableElement, "pointcuts"),
         new XMLMetadataLoader.PatternHandler()
         {
            public void handlePattern(final String sPattern, final boolean bInclusive)
            {
               table.addPointcutPattern(sPattern, bInclusive);
            }
         });

      XMLUtil.withFirstChildElement(tableElement, "Columns", false, new ElementHandler()
      {
         public void handleElement(Element columnsElement)
         {
            XMLUtil.forEachChildElement(columnsElement, "Column",
               getHelper().new ElementHandler("column")
            {
               public void handleElement(Element columnElement, String sColumnName)
               {
                  XMLMetadataHelper.validateName(sColumnName);
                 
                  Column column = new Column(sColumnName, table);

                  loadColumn(columnElement, column);
                  table.addColumn(column);
               }
            });
         }
      });

      XMLUtil.withFirstChildElement(tableElement, "Indexes", false, new ElementHandler()
      {
         public void handleElement(Element indexesElement)
         {
            XMLUtil.forEachChildElement(indexesElement, "Index",
               getHelper().new ElementHandler("index")
            {
               public void handleElement(Element indexElement, String sIndexName)
               {
                  XMLMetadataHelper.validateName(sIndexName, XMLMetadataHelper.NAME_DOT);

                  final Index index = new Index(table);

                  loadIndex(indexElement, sIndexName, index);

                  m_indexFixupList.add(new ContextFixup(getHelper())
                  {
                     public void fixup()
                     {
                        table.addIndex(index);
                     }
                  });
               }
            });
         }
      });

      XMLUtil.withFirstChildElement(tableElement, "View", false, new ElementHandler()
      {
         public void handleElement(Element viewElement)
         {
            final SQLScript script = new SQLScript();

            loadSQLScript(viewElement, script);
            table.setViewScript(script);
            table.setViewAutoUpdated(
               XMLUtil.getBooleanAttr(viewElement, "autoupdated", table.isViewAutoUpdated()));
         }
      });

      String sHints = XMLUtil.getStringAttr(tableElement, "hints");

      if (sHints != null)
      {
         for (StringTokenizer tokenizer = new StringTokenizer(sHints); tokenizer.hasMoreTokens();)
         {
            table.addHint(tokenizer.nextToken());
         }
      }

      final String sPrimaryKey = (table.isAspect()) ? XMLUtil.getStringAttr(tableElement, "primaryKey") :
         XMLUtil.getReqStringAttr(tableElement, "primaryKey");

      m_keyFixupList.add(new ContextFixup(getHelper())
      {
         public void fixup()
         {
            if (sPrimaryKey != null)
            {
View Full Code Here

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

      final String sConverterName = XMLUtil.getStringAttr(columnElement, "converter");

      if (sConverterName != null)
      {
         m_loader.addComponentFixup(new ContextFixup(getHelper())
         {
            public void fixup()
            {
               column.setConverter(column.getTable().getSchema().getMetadata().getComponent(sConverterName));
            }
         });
      }

      if (column.getType() == null)
      {
         m_loader.addComponentFixup(new ContextFixup(getHelper())
         {
            public void fixup()
            {
               column.computeType();
            }
         });
      }

      if (column.getTable().isAspect() && (sConverterName != null || column.getType() == null))
      {
         m_loader.addComponentFixup(new ContextFixup(getHelper())
         {
            public void fixup()
            {
               for (Iterator itr = column.getTable().getSchema().getTableIterator(); itr.hasNext();)
               {
View Full Code Here

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

      XMLMetadataLoader.parsePatterns(XMLUtil.getStringAttr(indexElement, "aspects"),
         new XMLMetadataLoader.PatternHandler()
         {
            public void handlePattern(final String sName, final boolean bInclusive)
            {
               m_aspectFixupList.add(new ContextFixup(getHelper())
               {
                  public void fixup()
                  {
                     index.addAspectOverride(index.getTable().getSchema().getIndex(sName), bInclusive);
                  }
               });
            }
         });

      final String sRelatedTableName = XMLUtil.getStringAttr(indexElement, "relatedTable");

      if (sRelatedTableName != null)
      {
         m_indexFixupList.add(new ContextFixup(getHelper())
         {
            public void fixup()
            {
               index.getTable().getSchema().getTable(sRelatedTableName).addRelatedKey(index);
            }
         });
      }

      XMLUtil.forEachChildElement(indexElement, "IndexColumn",
         getHelper().new ElementHandler("column")
      {
         public void handleElement(Element element, final String sName)
         {
            final boolean bAscending = XMLUtil.getBooleanAttr(element, "ascending", true);

            m_indexFixupList.add(new ContextFixup(getHelper())
            {
               public void fixup()
               {
                  index.addIndexColumn(new IndexColumn(index.getTable().getColumn(sName), bAscending));
               }
View Full Code Here

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

                  {
                     relationalMapping.setKeyGenerator(RelationalMapping.KEY_GEN_IDENTITY);
                  }
                  else
                  {
                     m_loader.addComponentFixup(new ContextFixup(getHelper())
                     {
                        public void fixup()
                        {
                           relationalMapping.setKeyGenerator(
                              relationalMapping.getMetaclass().getMetadata()
                              .getComponent(sKeyGeneratorName));
                        }
                     });
                  }
               }

               XMLUtil.withFirstChildElement(relationalMappingElement, "AttributeMappings", false, new ElementHandler()
               {
                  public void handleElement(Element attributeMappingsElement)
                  {
                     XMLUtil.forEachChildElement(attributeMappingsElement, "AttributeMapping",
                        getHelper().new ElementHandler("attribute")
                     {
                        public void handleElement(Element attributeMappingElement, String sAttributeName)
                        {
                           final Attribute attribute = metaclass.getAttribute(sAttributeName);
                           final String sTableName = XMLUtil.getStringAttr(attributeMappingElement, "table");
                           final String sColumnName = XMLUtil.getStringAttr(attributeMappingElement, "column");
                           final String sSourceKeyName = XMLUtil.getStringAttr(attributeMappingElement, "sourceKey");
                           final String sDestinationKeyName = XMLUtil.getStringAttr(attributeMappingElement, "destinationKey");
                           AttributeMapping mapping;
                          
                           m_persistenceMappingElement = null;
                           XMLUtil.withFirstChildElement(attributeMappingElement,
                              "PersistenceMapping", false, m_persistenceMappingElementHandler);

                           if (attribute.getType().isPrimitive())
                           {
                              if (sColumnName == null || sSourceKeyName != null ||
                                 sDestinationKeyName != null || m_persistenceMappingElement != null)
                              {
                                 throw new MetadataException("err.meta.primitiveRelationalMapping",
                                    new Object[]{attribute.getName(), metaclass.getName()});
                              }
                             
                              if (attribute.isCollection())
                              {
                                 throw new MetadataException("err.meta.unsupportedRelationalMapping",
                                    new Object[]{attribute.getName(), metaclass.getName()});
                              }

                              RelationalPrimitiveMapping primitiveMapping = new RelationalPrimitiveMapping();
                              Table table = (sTableName == null) ? relationalMapping.getPrimaryTable() : m_schema.getTable(sTableName);

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

                              primitiveMapping.setColumn(table.getColumn(sColumnName));
                              primitiveMapping.setAttribute(attribute);
                              mapping = primitiveMapping;
                           }
                           else
                           {
                              if (sTableName != null || sColumnName != null ||
                                 m_persistenceMappingElement != null &&
                                 (sSourceKeyName != null || sDestinationKeyName != null))
                              {
                                 throw new MetadataException("err.meta.classRelationalMapping",
                                    new Object[]{attribute.getName(), metaclass.getName()});
                              }
                             
                              final RelationalClassMapping classMapping = new RelationalClassMapping();
                             
                              classMapping.setAttribute(attribute);

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

                                 classMapping.setSourceKey(relationalMapping.getPrimaryTable().getPrimaryKey());
                                 classMapping.setMapping(m_loader.loadPersistenceMapping(m_persistenceMappingElement, (Metaclass)attribute.getType()));
                              }
                              else
                              {
                                 if (sSourceKeyName != null)
                                 {
                                    classMapping.setSourceKey(m_schema.getIndex(sSourceKeyName));
                                 }
                                 else
                                 {
                                    Table primaryTable = relationalMapping.getPrimaryTable();

                                    if (primaryTable != null)
                                    {
                                       classMapping.setSourceKey(primaryTable.getPrimaryKey());
                                    }
                                 }

                                 m_loader.addPersistenceMappingFixup(new ContextFixup(getHelper())
                                 {
                                    public void fixup()
                                    {
                                       Metaclass type = (Metaclass)attribute.getType();
                                       PersistenceMapping mapping = type.getPersistenceMapping();

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

                                       classMapping.setDestinationKey(mapping.addForeignKey(sDestinationKeyName, classMapping));
                                    }
                                 });
                              }

                              mapping = classMapping;
                           }

                           relationalMapping.addAttributeMapping(mapping);
                        }
                     });
                  }
               });

               XMLUtil.withFirstChildElement(relationalMappingElement, "Hook", false, new ElementHandler()
               {
                  public void handleElement(Element componentElement)
                  {
                     final Component hook = new Component("<PersistenceHook:" + metaclass.getName() + ">");

                     m_loader.loadComponent(componentElement, hook);

                     if (!loader.isRuntimeExcluded())
                     {
                        m_loader.addComponentFixup(new ContextFixup(getHelper())
                        {
                           public void fixup()
                           {
                              relationalMapping.setHook(hook);
                           }
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.