de.akquinet.jbosscc.guttenbase.hints.ColumnOrderHint Maven / Gradle / Ivy
package de.akquinet.jbosscc.guttenbase.hints;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import de.akquinet.jbosscc.guttenbase.mapping.ColumnOrderComparatorFactory;
import de.akquinet.jbosscc.guttenbase.meta.ColumnMetaData;
import de.akquinet.jbosscc.guttenbase.meta.TableMetaData;
import de.akquinet.jbosscc.guttenbase.repository.ConnectorRepository;
import de.akquinet.jbosscc.guttenbase.statements.AbstractStatementCreator;
import de.akquinet.jbosscc.guttenbase.statements.InsertStatementFiller;
import de.akquinet.jbosscc.guttenbase.tools.CheckEqualTableDataTool;
/**
* Determine order of columns in SELECT statement. This will of course also influence the ordering of the resulting INSERT statement.
*
*
* © 2012 akquinet tech@spree
*
*
* @Applicable-For-Source
* @Hint-Used-By {@link AbstractStatementCreator} to determine column order
* @Hint-Used-By {@link InsertStatementFiller} to determine column order
* @Hint-Used-By {@link CheckEqualTableDataTool} to determine column order
*
* @author M. Dahm
*/
public abstract class ColumnOrderHint implements ConnectorHint {
@Override
public Class getConnectorHintType() {
return ColumnOrderComparatorFactory.class;
}
/**
* Helper method
*/
public static List getSortedColumns(final ConnectorRepository connectorRepository, final String connectorId,
final TableMetaData tableMetaData) {
final Comparator sourceColumnComparator = connectorRepository
.getConnectorHint(connectorId, ColumnOrderComparatorFactory.class).getValue().createComparator();
final List columns = new ArrayList(tableMetaData.getColumnMetaData());
Collections.sort(columns, sourceColumnComparator);
return columns;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy