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;
 }
 protected void processSequence(
     InspectionContext inspectionContext, Schema schema, Column column, ResultSet sequences)
     throws SQLException {
   if (sequences.next()) {
     String name = sequences.getString("SEQUENCE_NAME");
     Sequence sequence = schema.getSequence(name);
     if (sequence == null) {
       schema.addSequence(sequence = new Sequence(name));
     }
     /**
      * Increments the LAST_VALUE by 1, as PostgreSQL LAST_VALUE number points to a value which is
      * already used by a table
      */
     sequence.setLastValue((sequences.getLong("LAST_VALUE") + 1L));
     sequence.setStartWith(sequences.getLong("START_VALUE"));
     sequence.setMinValue(sequences.getLong("MIN_VALUE"));
     sequence.setMaxValue(sequences.getLong("MAX_VALUE"));
     sequence.setIncrementBy(sequences.getLong("INCREMENT_BY"));
     sequence.setCache(sequences.getInt("CACHE_VALUE"));
     sequence.setCycle("T".equalsIgnoreCase(sequences.getString("IS_CYCLED")));
     if (column != null) {
       column.setSequence(sequence);
     }
     inspectionContext.getInspectionResults().addObject(sequence);
   }
 }
 protected boolean addScripts(Schema schema, ScriptGeneratorManager manager) {
   boolean generate = true;
   Identifier catalogId = valueOf(manager.getSourceCatalog());
   if (catalogId != null) {
     generate = ObjectUtils.equals(catalogId, schema.getCatalog().getIdentifier());
   }
   Identifier schemaId = valueOf(manager.getSourceSchema());
   if (generate && schemaId != null) {
     generate = ObjectUtils.equals(schemaId, schema.getIdentifier());
   }
   return generate;
 }
 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;
 }