All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.akquinet.jbosscc.guttenbase.hints.ColumnOrderHint Maven / Gradle / Ivy

The newest version!
package de.akquinet.jbosscc.guttenbase.hints;

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;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

/**
 * Determine order of columns in SELECT statement. This will of course also influence the ordering of the resulting INSERT statement.
 *
 * 

* © 2012-2034 akquinet tech@spree *

*

*

* Hint is used by {@link AbstractStatementCreator} to determine column order * Hint is used by {@link InsertStatementFiller} to determine column order * Hint is 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()); columns.sort(sourceColumnComparator); return columns; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy