コード例 #1
0
 protected Collection<String> getScripts(
     Map<Schema, Collection<String>> schemaScripts,
     ScriptGeneratorManager scriptGeneratorManager,
     boolean dropSchema,
     boolean useSchema) {
   Collection<String> scripts = newArrayList();
   if (schemaScripts.size() == 1) {
     Map.Entry<Schema, Collection<String>> schemaScript =
         schemaScripts.entrySet().iterator().next();
     Schema schema = schemaScript.getKey();
     if (dropSchema) {
       scripts.add(getDropSchema(schema, scriptGeneratorManager));
     }
     if (useSchema) {
       scripts.add(getUseSchema(schema, scriptGeneratorManager));
     }
     scripts.addAll(schemaScript.getValue());
   } else {
     for (Map.Entry<Schema, Collection<String>> schemaScript : schemaScripts.entrySet()) {
       Schema schema = schemaScript.getKey();
       Dialect dialect = scriptGeneratorManager.getTargetDialect();
       if (dropSchema) {
         scripts.add(getDropSchema(schema, scriptGeneratorManager));
       }
       if (useSchema) {
         scripts.add(
             schema.getIdentifier() != null
                 ? dialect.getUseSchema(scriptGeneratorManager.getName(schema))
                 : dialect.getUseSchema(scriptGeneratorManager.getName(schema.getCatalog())));
       }
       scripts.addAll(schemaScript.getValue());
     }
   }
   return scripts;
 }
コード例 #2
0
 protected Query createQuery(InspectionContext inspectionContext, String schema, String sequence)
     throws SQLException {
   SelectQuery query = new SelectQuery();
   query.column("*");
   Dialect dialect = inspectionContext.getDialect();
   query.from(dialect.getIdentifier(schema, null) + "." + dialect.getIdentifier(sequence, null));
   return query;
 }
コード例 #3
0
 public static String getDropSchema(Schema schema, ScriptGeneratorManager scriptGeneratorManager) {
   String dropSchema = null;
   Dialect dialect = scriptGeneratorManager.getTargetDialect();
   if (scriptGeneratorManager.getTargetSchema() != null) {
     dropSchema = dialect.getDropSchema(scriptGeneratorManager.getTargetSchema(), true);
   } else if (scriptGeneratorManager.getTargetCatalog() != null) {
     dropSchema = dialect.getDropSchema(scriptGeneratorManager.getTargetCatalog(), true);
   }
   if (dropSchema == null) {
     dropSchema =
         schema.getIdentifier() != null
             ? dialect.getDropSchema(scriptGeneratorManager.getName(schema))
             : dialect.getDropSchema(scriptGeneratorManager.getName(schema.getCatalog()));
   }
   return dropSchema;
 }