Search in sources :

Example 1 with CsvSettings

use of org.eclipse.scout.rt.server.csv.CsvSettings in project scout.rt by eclipse.

the class CsvSqlAdapter method importDataIntoTable.

@SuppressWarnings("squid:S00107")
public void importDataIntoTable(File f, String encoding, Locale contentLocale, int headerRowCount, String colSeparator, String textDelimiter, String tableName, String groupKeyColumnName, Object groupKeyValue, String lineNumberColumnName, List<String> csvColumnNames, List<String> csvColumnTypes, boolean allowVariableColumnCount) {
    if (encoding == null) {
        encoding = StandardCharsets.UTF_8.name();
    }
    CsvSettings params = new CsvSettings();
    params.setFile(f);
    params.setEncoding(encoding);
    params.setContentLocale(contentLocale);
    params.setHeaderRowCount(headerRowCount);
    params.setColSeparator((colSeparator == null) ? 0 : colSeparator.charAt(0));
    params.setTextDelimiter((textDelimiter == null) ? 0 : textDelimiter.charAt(0));
    params.setTableName(tableName);
    params.setGroupKeyColumnName(groupKeyColumnName);
    params.setGroupKeyValue(groupKeyValue);
    params.setLineNumberColumnName(lineNumberColumnName);
    params.setAllowVariableColumnCount(allowVariableColumnCount);
    if (csvColumnNames != null) {
        params.setCsvColumnNames(csvColumnNames);
    }
    if (csvColumnTypes != null) {
        params.setCsvColumnTypes(csvColumnTypes);
    }
    importData(params);
}
Also used : CsvSettings(org.eclipse.scout.rt.server.csv.CsvSettings)

Example 2 with CsvSettings

use of org.eclipse.scout.rt.server.csv.CsvSettings in project scout.rt by eclipse.

the class CsvSqlAdapter method exportDataFromTable.

/**
 * Export a table's data into a file
 *
 * @param f
 *          file to write data to
 * @param contentLocale
 *          see {@link CsvHelper}
 * @param colSeparator
 *          see {@link CsvHelper}
 * @param textDelimiter
 *          see {@link CsvHelper}
 * @param tableName
 *          database table to export from
 * @param groupKeyColumnName
 *          the column where the id for this import is stored (or null if not used)
 * @param groupKeyValue
 *          the id for this csv import
 * @param lineNumberColumnName
 *          where the line number starting with 1 is stored
 * @param csvColumnNames
 *          the names that should appear in the csv file
 * @param writeColumnNames
 *          the sql names that are exported
 * @param csvColumnTypes
 *          the csv types of the corresponding column
 * @param writeColumnTypes
 *          the sql types of the corresponding column
 */
@SuppressWarnings("squid:S00107")
public void exportDataFromTable(File f, String encoding, Locale contentLocale, String colSeparator, String textDelimiter, String tableName, String groupKeyColumnName, Object groupKeyValue, String lineNumberColumnName, List<String> csvColumnNames, boolean writeColumnNames, List<String> csvColumnTypes, boolean writeColumnTypes) {
    if (encoding == null) {
        encoding = StandardCharsets.UTF_8.name();
    }
    CsvSettings params = new CsvSettings();
    params.setFile(f);
    params.setEncoding(encoding);
    params.setContentLocale(contentLocale);
    params.setColSeparator((colSeparator == null) ? 0 : colSeparator.charAt(0));
    params.setTextDelimiter((textDelimiter == null) ? 0 : textDelimiter.charAt(0));
    params.setTableName(tableName);
    params.setGroupKeyColumnName(groupKeyColumnName);
    params.setGroupKeyValue(groupKeyValue);
    params.setLineNumberColumnName(lineNumberColumnName);
    params.setWriteColumnNames(writeColumnNames);
    params.setWriteColumnTypes(writeColumnTypes);
    if (csvColumnNames != null) {
        params.setCsvColumnNames(csvColumnNames);
    }
    if (csvColumnTypes != null) {
        params.setCsvColumnTypes(csvColumnTypes);
    }
    exportData(params);
}
Also used : CsvSettings(org.eclipse.scout.rt.server.csv.CsvSettings)

Example 3 with CsvSettings

use of org.eclipse.scout.rt.server.csv.CsvSettings in project scout.rt by eclipse.

the class CsvSqlAdapter method exportDataWithSql.

/**
 * Export sql select data into a file
 *
 * @param f
 *          file to write data to
 * @param contentLocale
 *          see {@link CsvHelper}
 * @param colSeparator
 *          see {@link CsvHelper}
 * @param textDelimiter
 *          see {@link CsvHelper}
 * @param sqlSelect
 *          the source sql statement
 * @param bindBase
 *          the necessary jdbc binds
 * @param csvColumnNames
 *          the names that should appear in the csv file
 * @param writeColumnNames
 *          the sql names that are exported
 * @param csvColumnTypes
 *          the csv types of the corresponding column
 * @param writeColumnTypes
 *          the sql types of the corresponding column
 */
@SuppressWarnings("squid:S00107")
public void exportDataWithSql(File f, String encoding, Locale contentLocale, String colSeparator, String textDelimiter, String sqlSelect, NVPair[] bindBase, List<String> csvColumnNames, boolean writeColumnNames, List<String> csvColumnTypes, boolean writeColumnTypes) {
    if (encoding == null) {
        encoding = StandardCharsets.UTF_8.name();
    }
    try {
        CsvSettings params = new CsvSettings();
        params.setFile(f);
        params.setEncoding(encoding);
        params.setContentLocale(contentLocale);
        params.setColSeparator((colSeparator == null) ? 0 : colSeparator.charAt(0));
        params.setTextDelimiter((textDelimiter == null) ? 0 : textDelimiter.charAt(0));
        params.setSqlSelect(sqlSelect);
        params.setBindBase(bindBase);
        params.setWriteColumnNames(writeColumnNames);
        params.setWriteColumnTypes(writeColumnTypes);
        if (csvColumnNames != null) {
            params.setCsvColumnNames(csvColumnNames);
        }
        if (csvColumnTypes != null) {
            params.setCsvColumnTypes(csvColumnTypes);
        }
        exportData(params);
    } catch (Exception e) {
        throw new ProcessingException(e.getMessage(), e);
    }
}
Also used : CsvSettings(org.eclipse.scout.rt.server.csv.CsvSettings) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException) IOException(java.io.IOException) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException)

Aggregations

CsvSettings (org.eclipse.scout.rt.server.csv.CsvSettings)3 IOException (java.io.IOException)1 ProcessingException (org.eclipse.scout.rt.platform.exception.ProcessingException)1