use of org.talend.cwm.db.connection.DelimitedFileSQLExecutor in project tdq-studio-se by Talend.
the class MatchAnalysisExecutor method getSQLExectutor.
/**
* getSQLExectutor .
*
* @param modelElement
* @return
*/
private ISQLExecutor getSQLExectutor(Analysis analysis, RecordMatchingIndicator recordMatchingIndicator, Map<MetadataColumn, String> columnMap) {
ModelElement modelElement = analysis.getContext().getAnalysedElements().get(0);
ISQLExecutor sqlExecutor = null;
if (modelElement instanceof TdColumn) {
sqlExecutor = new DatabaseSQLExecutor();
} else if (modelElement instanceof MetadataColumn) {
sqlExecutor = new DelimitedFileSQLExecutor();
}
// Tune on store on disk option when needed.
Boolean isStoreOnDisk = PluginChecker.isTDQLoaded() ? TaggedValueHelper.getValueBoolean(SQLExecutor.STORE_ON_DISK_KEY, analysis) : Boolean.FALSE;
if (sqlExecutor != null && isStoreOnDisk) {
sqlExecutor.setStoreOnDisk(Boolean.TRUE);
sqlExecutor.initStoreOnDiskHandler(analysis, recordMatchingIndicator, columnMap);
}
return sqlExecutor;
}
use of org.talend.cwm.db.connection.DelimitedFileSQLExecutor in project tdq-studio-se by Talend.
the class DataPreviewHandler method createPreviewData.
public List<Object[]> createPreviewData(ModelElement[] columns, int limit, boolean isRandomData) throws SQLException {
// no columns be selected so that no data can be read
if (columns == null || columns.length == 0) {
return new ArrayList<Object[]>();
}
// use ModelElement instead of node to get the data source type directly.
// get connection from column[0]
boolean isDelimitedFile = false;
ModelElement modelElement = columns[0];
if (modelElement instanceof MetadataColumn && !(modelElement instanceof TdColumn)) {
isDelimitedFile = true;
connection = ConnectionHelper.getTdDataProvider((MetadataColumn) modelElement);
} else if (modelElement instanceof TdColumn) {
connection = ConnectionHelper.getTdDataProvider((TdColumn) modelElement);
} else {
// other case it is not support by now
// $NON-NLS-1$
log.warning(DefaultMessagesImpl.getString("DataPreviewHandler.UnSupportType"));
return new ArrayList<Object[]>();
}
ISQLExecutor sqlExecutor = null;
if (isDelimitedFile) {
sqlExecutor = new DelimitedFileSQLExecutor();
} else {
// is database
sqlExecutor = new DatabaseSQLExecutor();
}
// set limit
sqlExecutor.setLimit(limit);
sqlExecutor.setShowRandomData(isRandomData);
return sqlExecutor.executeQuery(connection, Arrays.asList(columns), dataFilter);
}
Aggregations