Package nexj.core.meta.persistence

Examples of nexj.core.meta.persistence.DataSource


         DataLoader loader = new DataLoader(m_context);
        
         for (Iterator itr = loader.getDataSourceIterator(getDataSourceSet()); itr.hasNext();)
         {
            DataSource ds = (DataSource)itr.next();
            SchemaVersion version = loader.getSchemaVersion(ds);

            if (version != null)
            {
               printVersion(version.getNamespace(), version.getVersion());
View Full Code Here


    */
   protected RelationalDatabase getDatabase(Metadata metadata) throws IllegalArgumentException
   {
      metadata = (metadata == null) ? Repository.getMetadata() : metadata;

      DataSource ds = metadata.getDataSource(getRequiredProperty("meta.datasource"));

      if (ds instanceof RelationalDatabase)
      {
         return (RelationalDatabase)ds;
      }

      throw new IllegalArgumentException("Data source \"" + ds.getName() +
                                         "\" is not a relational database");
   }
View Full Code Here

      InvocationContext context = null;
      Context contextSaved = ThreadContextHolder.getContext();

      try
      {
         DataSource db = metadata.getDataSource(sDataSource);
         Component comp = metadata.findComponent("System.InvocationContext");
         context = (comp != null) ? (InvocationContext)comp.getInstance(null) : new InvocationContext(metadata);

         context.initialize(null);
         context.setLocale(Locale.getDefault());
         context.setProtected(false);
         context.setSecure(false);
         context.setPartitioned(false);

         for (Iterator itr = db.getFragmentIterator(); itr.hasNext();)
         {
            Object o = itr.next();

            if (o instanceof RelationalDatabaseFragment)
            {
View Full Code Here

      Table table = schema.getTable(m_singleColTableStep.getName());

      assertNotNull(table);
      assertEquals(Table.EXTERNAL, table.getType()); // comes in as Table.EXTERNAL from DB

      DataSource ds = schema.getDataSource();

      for (Iterator/*<DataSourceAdapter>*/ itr = ds.getType().getAdapterIterator(); itr.hasNext();)
      {
         String sName = ((DataSourceAdapter)itr.next()).getName();

         if (!ds.getAdapter().getName().equals(sName)) // adapter name not matching current adapter
         {
            stmt.addAdapter(sName, ds.getType());
            break;
         }
      }

      if (stmt.getAdapterCount() == 0)
View Full Code Here

      assertEquals("[non-collection:default-value]", output.toString());

      // set schema.getMetadata().isTestEnvironment() return value for test
      XMLMetadata metadata = new XMLMetadata(null, null, null, null, null);
      DataSourceType dsType = new DataSourceType(null);
      DataSource ds = new DataSource(null) {};

      dsType.setMetadata(metadata);
      ds.setType(dsType);
      schema.setDataSource(ds);

      // iftest enabled
      metadata.setTestEnvironment(true);
      output.getBuffer().setLength(0);
View Full Code Here

      {
         byte nReplication = mapping.getFragmentReplication();

         if (nReplication != PersistenceMapping.REPLICATION_NONE)
         {
            DataSource dataSource = mapping.getDataSource();

            if (dataSource.getFragmentCount() != 1)
            {
               UnitOfWork uow = m_uow;

               if (uow == null)
               {
                  uow = m_context.getUnitOfWork();
               }

               if (nReplication == PersistenceMapping.REPLICATION_UNICAST)
               {
                  if (getFragmentName() == null)
                  {
                     Attribute attribute = mapping.getFragmentAttribute();

                     if (attribute != null)
                     {
                        uow.addReplicationFragment(this, (String)((attribute.isStatic()) ?
                           m_metaclass : (Accessor)this).getValue(attribute.getOrdinal()));
                     }
                  }
                  else
                  {
                     uow.addReplicationFragment(this, null);
                  }
               }
               else if (nReplication == PersistenceMapping.REPLICATION_BROADCAST)
               {
                  if (getFragmentName() == null)
                  {
                     for (Iterator itr = dataSource.getFragmentIterator(); itr.hasNext();)
                     {
                        uow.addReplicationFragment(this, ((DataSourceFragment)itr.next()).getName());
                     }
                  }
                  else
View Full Code Here

   public static VersionUpgrade create(
      String sName, Metadata metadata, Machine machine, Upgrade upgrade)
   {
      Metaclass versionClass = metadata.getMetaclass(Metadata.VERSION_CLASS_NAME);
      PersistenceMapping mapping = versionClass.getPersistenceMapping();
      DataSource ds = mapping.getDataSource();

      if (ds instanceof RelationalDatabase) // SysVersion persisted in RDBMS
      {
         Table table = ((RelationalMapping)mapping).getPrimaryTable();
         RelationalSchemaUpgrade version = new RelationalSchemaUpgrade(sName);
View Full Code Here

               scriptUpgrade.compile(m_machine);
               upgrade.addVersion(scriptUpgrade);
            }
            else
            {
               DataSource dataSource = m_metadata.getDataSource(XMLUtil.getReqStringAttr(element, "dataSource"));
               XMLPersistenceMetadataLoader loader = (XMLPersistenceMetadataLoader)m_helper.getClassInstance(dataSource.getType().getLoader());

               upgrade.addVersion(loader.loadUpgrade(element, sName, dataSource, m_helper));
            }
         }
View Full Code Here

      boolean bFirstRelationalDatabase = true;

      for (Iterator itr = m_loader.getMetadata().getDataSourceIterator(); itr.hasNext() && bFirstRelationalDatabase; )
      {
         DataSource ds = (DataSource)itr.next();

         if (ds instanceof RelationalDatabase)
         {
            bFirstRelationalDatabase = false;
         }
      }

      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();

               for (Iterator itr = m_loader.getMetadata().getDataSourceIterator(); itr.hasNext(); )
               {
                  DataSource ds = (DataSource)itr.next();

                  if (ds instanceof RelationalDatabase)
                  {
                     RelationalDatabase rel = (RelationalDatabase)ds;
View Full Code Here

         context.getTransactionManager().setTransactionTimeout(86400);
         context.beginTransaction();

         for (Iterator dataSourceItr = metadata.getDataSourceIterator(); dataSourceItr.hasNext();)
         {
            DataSource dataSource = (DataSource)dataSourceItr.next();

            if (dataSource.isEnabled() && dataSource.getComponent() != null)
            {
               for (Iterator fragmentItr = dataSource.getFragmentIterator(); fragmentItr.hasNext();)
               {
                  DataSourceFragment fragment = (DataSourceFragment)fragmentItr.next();
                  String sFragment = (fragment.getName() == null) ? "" : fragment.getName();

                  context.setFragmentName(sFragment);

                  SchemaVersion version = ((PersistenceAdapter)dataSource.getComponent()
                     .getInstance(context)).getVersion(dataSource.getSchema());

                  if (version != null)
                  {
                     if (!metadata.getNamespace().equals(version.getNamespace()))
                     {
                        throw new PersistenceException("err.persistence.storageNamespace",
                           new Object[]{version.getNamespace(), dataSource.getName(),
                              sFragment, metadata.getNamespace()});
                     }

                     if (!metadata.getVersion().equals(version.getVersion()))
                     {
                        throw new PersistenceException("err.persistence.storageVersion",
                           new Object[]{version.getVersion(), dataSource.getName(),
                           sFragment, metadata.getVersion(), metadata.getNamespace()});
                     }
                  }
               }
            }
View Full Code Here

TOP

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

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.