コード例 #1
0
 // you'll have to set the def db, project - the session context would do that for us -
 // i.e. this test does not handle use statements correctly
 @SuppressWarnings({"rawtypes", "unchecked"})
 private Pair<SchemaContext, Persistable<?, ?>> roundTrip(String sql, String defaultDatabase)
     throws Exception {
   PECreateStatement firstTime = null;
   PECreateStatement secondTime = null;
   CatalogDAO catalog = CatalogDAOFactory.newInstance();
   SchemaContext secondPC = null;
   try {
     catalog.begin();
     SchemaContext firstPC = buildContext(catalog);
     if (defaultDatabase != null)
       firstPC.setCurrentDatabase(firstPC.findDatabase(defaultDatabase));
     firstTime = trip(firstPC, catalog, sql, defaultDatabase);
     // don't persist yet
     String gen = firstTime.getSQL(firstPC, true, false);
     echo(gen);
     secondPC = buildContext(catalog);
     if (defaultDatabase != null)
       secondPC.setCurrentDatabase(secondPC.findDatabase(defaultDatabase));
     secondTime = trip(secondPC, catalog, gen, defaultDatabase);
     // make sure the objects are the same
     String diffs = firstTime.getCreated().differs(firstPC, secondTime.getCreated(), false);
     if (diffs != null) fail(diffs);
     persistToCatalog(catalog, secondPC, secondTime);
     catalog.commit();
     // now, we're going to load that persistable object and compare it to the second time
     catalog.begin();
     checkLoad(catalog, secondTime.getCreated(), defaultDatabase);
     catalog.rollbackNoException();
   } finally {
     catalog.close();
   }
   return new Pair<SchemaContext, Persistable<?, ?>>(secondPC, secondTime.getCreated());
 }
コード例 #2
0
  private void initializeCatalogServices() throws Exception {
    CatalogDAO c = CatalogDAOFactory.newInstance();
    try {
      c.recoverTransactions();

      // Create and configure all Dynamic Site Providers
      for (Provider provider : c.findAllProviders()) {
        SiteProviderContext ctxt = new SiteProviderContextInitialisation(provider.getName(), c);
        SiteProviderFactory.addProvider(
            ctxt,
            provider.getPlugin(),
            provider.getName(),
            provider.isEnabled(),
            provider.getConfig());
      }

      // Create and configure External Services
      for (ExternalService es : c.findAllExternalServices()) {
        // enclose in try/catch in case an early service fails we still
        // start the later ones
        try {
          ExternalServiceFactory.register(es.getName(), es.getPlugin());
        } catch (Exception e) {
          e.printStackTrace();
        }
      }

      //			GlobalConfigVariableHandler.initializeGlobalVariables(getGlobalVariables(c));
    } finally {
      c.close();
    }
  }
コード例 #3
0
 public String[] generateCatalog() throws PEException {
   CatalogDAO c = CatalogDAOFactory.newInstance();
   String[] current = null;
   try {
     CatalogGenerator generator = Singletons.require(CatalogGenerator.class);
     current =
         generator.buildCreateCurrentSchema(
             c,
             Singletons.require(HostService.class)
                 .getProperties()); // TODO: this looks like we are only looking up the host to get
                                    // something for the catalog. -sgossard
   } finally {
     c.close();
   }
   return current;
 }