de.akquinet.jbosscc.guttenbase.hints.TableOrderHint Maven / Gradle / Ivy
package de.akquinet.jbosscc.guttenbase.hints;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import de.akquinet.jbosscc.guttenbase.mapping.TableOrderComparatorFactory;
import de.akquinet.jbosscc.guttenbase.meta.DatabaseMetaData;
import de.akquinet.jbosscc.guttenbase.meta.TableMetaData;
import de.akquinet.jbosscc.guttenbase.repository.ConnectorRepository;
import de.akquinet.jbosscc.guttenbase.tools.AbstractTableCopyTool;
import de.akquinet.jbosscc.guttenbase.tools.CheckSchemaCompatibilityTool;
import de.akquinet.jbosscc.guttenbase.tools.CheckEqualTableDataTool;
/**
* Determine order of tables during copying/comparison.
*
*
* © 2012 akquinet tech@spree
*
*
* @Applicable-For-Source
* @Hint-Used-By {@link CheckSchemaCompatibilityTool} to determine table order
* @Hint-Used-By {@link AbstractTableCopyTool} to determine table order
* @Hint-Used-By {@link CheckEqualTableDataTool} to determine table order
*
* @author M. Dahm
*/
public abstract class TableOrderHint implements ConnectorHint {
@Override
public Class getConnectorHintType() {
return TableOrderComparatorFactory.class;
}
/**
* Helper method
*/
public static List getSortedTables(final ConnectorRepository connectorRepository, final String connectorId)
throws SQLException {
final DatabaseMetaData databaseMetaData = connectorRepository.getDatabaseMetaData(connectorId);
final Comparator comparator = connectorRepository.getConnectorHint(connectorId, TableOrderComparatorFactory.class)
.getValue().createComparator();
final List tables = new ArrayList(databaseMetaData.getTableMetaData());
Collections.sort(tables, comparator);
return tables;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy