Package nexj.core.admin.etl

Examples of nexj.core.admin.etl.DataLoader


         importData(false);
      }
      else if (sCommand.equals("recreate"))
      {
         init();
         new DataLoader(m_context).recreateSchema(getDataSourceSet());
         importData(true);
      }
      else if (sCommand.equals("reset"))
      {
         init();
         new DataLoader(m_context).deleteData(getDataSourceSet());
         importData(true);
      }
      else if (sCommand.equals("recreateschema"))
      {
         init();
         new DataLoader(m_context).recreateSchema(getDataSourceSet());
      }
      else if (sCommand.equals("upgrade"))
      {
         init();
         upgradeData(false);
      }
      else if (sCommand.equals("upgradedump"))
      {
         String sDumpURLs = getProperty("dump.urls");
         String sDumpURLArray[];

         if (sDumpURLs != null)
         {
            if (hasProperty("dump.url") || hasProperty("old.dump.url"))
            {
               throw new IllegalArgumentException(
                  "Properties \"dump.url\" and \"old.dump.url\" cannot be specified with \"dump.urls\"");
            }

            sDumpURLArray = StringUtil.split(sDumpURLs, ' ');
         }
         else
         {
            sDumpURLArray = new String[] {getRequiredProperty("dump.url")};
         }

         String sPreviousMetaURL = getRequiredProperty("old.meta.url");
         String sBaseURLProperty = getProperty("old.meta.base.url");
         Properties properties = new Properties(SysUtil.getConfigProperties())
         {
            private static final long serialVersionUID = -6961684990382643373L;

            /**
             * @see java.util.Properties#getProperty(java.lang.String,
             *      java.lang.String)
             */
            public String getProperty(String sKey, String sDefaultValue)
            {
               String sValue = getOverride(sKey);

               return (sValue != null) ? sValue : super.getProperty(sKey, sDefaultValue);
            }

            /**
             * @see java.util.Properties#getProperty(java.lang.String)
             */
            public String getProperty(String sKey)
            {
               String sValue = getOverride(sKey);

               return (sValue != null) ? sValue : super.getProperty(sKey);
            }

            protected String getOverride(String sKey)
            {
               if (sKey.startsWith("meta.") && !sKey.equals(XMLMetadataLoader.BASE_URL_PROPERTY))
               {
                  return DataLoadTool.this.getProperty("old." + sKey);
               }

               return null;
            }
         };

         properties.setProperty(XMLMetadataLoader.BASE_URL_PROPERTY, sBaseURLProperty == null ? "" : sBaseURLProperty);

         Metadata oldMetadata = null;

         for (int nDumpIndex = 0; nDumpIndex < sDumpURLArray.length; ++nDumpIndex)
         {
            String sPreviousDumpURL;

            if (sDumpURLs == null)
            {
               sPreviousDumpURL = getProperty("old.dump.url", sDumpURLArray[nDumpIndex]);
            }
            else
            {
               sPreviousDumpURL = sDumpURLArray[nDumpIndex];
               setProperty("dump.url", sDumpURLArray[nDumpIndex]);
            }

            if (s_logger.isInfoEnabled())
            {
               s_logger.info("Upgrading dump " + sDumpURLArray[nDumpIndex] + "...");
            }

            s_logger.info("Loading current repository");
            init();

            // drop any tables that may exist for the current schema
            new DataLoader(m_context).dropSchema(getDataSourceSet());

            s_logger.info("Loading old repository");

            if (oldMetadata == null)
            {
               oldMetadata = new MetadataLoaderDispatcher().load(sPreviousMetaURL, properties, MetadataLoader.DEFAULT, null);
            }

            init(oldMetadata);

            s_logger.info("Recreating the old data");
            new DataLoader(m_context).recreateSchema(getDataSourceSet());
            importData(true, sPreviousDumpURL);

            s_logger.info("Upgrading the data");
            init();
            upgradeData(true);

            s_logger.info("Exporting the data");
            init();
            exportData();
         }

         s_logger.info("Upgrade dump completed");
      }
      else if (sCommand.equals("version"))
      {
         init();

         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


      InputStream in = new BufferedInputStream(URLUtil.openStream(
         new URL(URLUtil.toURL(getRequiredProperty("dump.url")))));

      try
      {
         Pair p = new DataLoader(m_context).getDumpVersion(in);
        
         if (p != null)
         {
            printVersion((String)p.getHead(), (String)p.getTail());
         }
View Full Code Here

   /**
    * @return A new initialized data loader instance.
    */
   protected DataLoader createDataLoader()
   {
      DataLoader loader = new DataLoader(m_context);

      loader.setCompressed(StringUtil.parseBoolean(getProperty("dump.compressed", "true")));

      String sMarshaller = getProperty("dump.format");

      if (sMarshaller != null)
      {
         if (sMarshaller.indexOf('.') < 0)
         {
            sMarshaller = SysUtil.PACKAGE + ".core.rpc." + sMarshaller.toLowerCase(Locale.ENGLISH) +
               '.' + sMarshaller + "Marshaller";
         }

         loader.setMarshallerClassName(sMarshaller);
      }

      return loader;
   }
View Full Code Here

      try
      {
         Upgrade upgrade = metadata.getUpgrade("Main");

         upgrade.validate(metadata, null);
         new DataLoader(m_context).upgrade(getDataSourceSet(), upgrade, bForce);
         metadata.getMetaclass("SysUpgrade").invoke("upgrade");
         bCommit = true;
      }
      finally
      {
View Full Code Here

         in = new BufferedInputStream(in);
      }

      try
      {
         new DataLoader(m_context).importData(in, getDataSourceSet(), bSkipRead);
      }
      finally
      {
         IOUtil.close(in);
      }
View Full Code Here

         }
      }

      try
      {
         new DataLoader(context).generateScript(out, in, dataSourceSet);
      }
      finally
      {
         IOUtil.close(in);
         out.close();
View Full Code Here

               InputStream is = null;
               Pair dumpVersion = null;

               try
               {
                  dumpVersion = new DataLoader(null).getDumpVersion(is = m_helper.getResourceAsStream(sFullName));
               }
               catch (Exception e)
               {
                  throw new MetadataException("err.meta.dumpLoad", new Object[]
                  {
View Full Code Here

            for (Iterator argItr = new ArgumentIterator(context, utest); argItr.hasNext(); )
            {
               Object[] variableArray = (Object[])argItr.next();
               String sTestArguments = formatLoopVariables(variableArray, utest.getLoopCount());
               DataLoader dataLoader = new DataLoader(context);
               URL dumpURL = getDumpURL(utest);
               boolean bResetDB = dumpURL != null;

               m_unitTestLogger.begin(utest, sTestArguments);

               if (bResetDB && !bReady)
               {
                  if (m_container != null)
                  {
                     m_container.suspend();
                  }

                  bReady = true;

                  if (nUnitTest == 0)
                  {
                     try
                     {
                        dataLoader.recreateSchema((Set)null);
                     }
                     catch (Throwable e)
                     {
                        m_unitTestLogger.err(utest, e);

                        return;
                     }
                  }
                  else
                  {
                     bFirstRun = false;
                  }
               }

               byte nMode = utest.getMode();
               int nTestCase = 0;

               if (utest.hasInitializer())
               {
                  ++nTestCase;
               }

               if (utest.hasFinalizer())
               {
                  ++nTestCase;
               }

               Object[] functionObjArray = null;

               if (utest.getFunction() != null)
               {
                  functionObjArray = (Object[])context.getMachine().invoke(utest.getFunction(), variableArray);
               }

               boolean bFirstTestCase = true;

               for (Iterator itr = utest.getUnitTestCaseIterator(); itr.hasNext();
                  bFirstRun = false, bFirstTestCase = false, bResetDB = dumpURL != null && nMode != UnitTest.MODE_DIRTY)
               {
                  UnitTestCase testCase = (UnitTestCase)itr.next();

                  if (!isEnabled(utest, testCase))
                  {
                     nTestCase++;
                     continue;
                  }

                  if (bResetDB)
                  {
                     if (!bFirstTestCase && m_container != null)
                     {
                        m_container.suspend();
                     }

                     if (!bFirstRun)
                     {
                        try
                        {
                           dataLoader.deleteData((Set)null);
                        }
                        catch (Throwable e)
                        {
                           m_unitTestLogger.err(utest, e);

                           return;
                        }
                     }

                     InputStream in = null;

                     try
                     {
                        in = new BufferedInputStream(URLUtil.openStream(dumpURL));
                        dataLoader.importData(in, true);
                     }
                     catch (Throwable e)
                     {
                        m_unitTestLogger.err(utest, e);
View Full Code Here

TOP

Related Classes of nexj.core.admin.etl.DataLoader

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.