Package liquibase.util.csv

Examples of liquibase.util.csv.CSVWriter


    protected void writeHeader(File file) throws IOException {
        FileWriter writer = null;
        try {
            writer = new FileWriter(file);
            CSVWriter csvWriter = new CSVWriter(writer);
            csvWriter.writeNext(new String[]{
                    "ID",
                    "AUTHOR",
                    "FILENAME",
                    "DATEEXECUTED",
                    "ORDEREXECUTED",
View Full Code Here


        try {
            reader = new FileReader(oldFile);
            writer = new FileWriter(newFile);
            CSVReader csvReader = new CSVReader(reader);
            CSVWriter csvWriter = new CSVWriter(writer);
            String[] line;
            while ((line = csvReader.readNext()) != null) {
                if (changeSet == null || (line[COLUMN_ID].equals(changeSet.getId()) && line[COLUMN_AUTHOR].equals(changeSet.getAuthor()) && line[COLUMN_FILENAME].equals(changeSet.getFilePath()))) {
                    line = replaceLogic.execute(line);
                }
                if (line != null) {
                    csvWriter.writeNext(line);
                }
            }

            csvWriter.flush();
            csvWriter.close();
            writer = null;

            csvReader.close();
            reader = null;
View Full Code Here

        try {
            reader = new FileReader(oldFile);
            writer = new FileWriter(newFile);
            CSVReader csvReader = new CSVReader(reader);
            CSVWriter csvWriter = new CSVWriter(writer);
            String[] line;
            while ((line = csvReader.readNext()) != null) {
                csvWriter.writeNext(line);
            }

            String[] newLine = new String[11];
            newLine[COLUMN_ID] = changeSet.getId();
            newLine[COLUMN_AUTHOR] = changeSet.getAuthor();
            newLine[COLUMN_FILENAME] =  changeSet.getFilePath();
            newLine[COLUMN_DATEEXECUTED] = new ISODateFormat().format(new java.sql.Timestamp(new Date().getTime()));
            newLine[COLUMN_ORDEREXECUTED] = String.valueOf(getNextSequenceValue());
            newLine[COLUMN_EXECTYPE] = execType.value;
            newLine[COLUMN_MD5SUM] = changeSet.generateCheckSum().toString();
            newLine[COLUMN_DESCRIPTION] = changeSet.getDescription();
            newLine[COLUMN_COMMENTS] = changeSet.getComments();
            newLine[COLUMN_TAG] = "";
            newLine[COLUMN_LIQUIBASE] = LiquibaseUtil.getBuildVersion().replaceAll("SNAPSHOT", "SNP");

            csvWriter.writeNext(newLine);

            csvWriter.flush();
            csvWriter.close();
            writer = null;

            csvReader.close();
            reader = null;
View Full Code Here

            if (!parentDir.isDirectory()) {
                throw new RuntimeException(parentDir
                        + " is not a directory");
            }

            CSVWriter outputFile = new CSVWriter(new BufferedWriter(new FileWriter(fileName)));
            String[] dataTypes = new String[columnNames.size()];
            String[] line = new String[columnNames.size()];
            for (int i = 0; i < columnNames.size(); i++) {
                line[i] = columnNames.get(i);
            }
            outputFile.writeNext(line);

            int rowNum = 0;
            while (rs.next()) {
                line = new String[columnNames.size()];

                for (int i = 0; i < columnNames.size(); i++) {
                    Object value = JdbcUtils.getResultSetValue(rs, i + 1);
                    if (dataTypes[i] == null && value != null) {
                        if (value instanceof Number) {
                            dataTypes[i] = "NUMERIC";
                        } else if (value instanceof Boolean) {
                            dataTypes[i] = "BOOLEAN";
                        } else if (value instanceof Date) {
                            dataTypes[i] = "DATE";
                        } else {
                            dataTypes[i] = "STRING";
                        }
                    }
                    if (value == null) {
                        line[i] = "NULL";
                    } else {
                        if (value instanceof Date) {
                            line[i] = new ISODateFormat().format(((Date) value));
                        } else {
                            line[i] = value.toString();
                        }
                    }
                }
                outputFile.writeNext(line);
                rowNum++;
                if (rowNum % 5000 == 0) {
                    outputFile.flush();
                }
            }
            outputFile.flush();
            outputFile.close();

            LoadDataChange change = new LoadDataChange();
            change.setFile(fileName);
            change.setEncoding("UTF-8");
            if (outputControl.getIncludeCatalog()) {
View Full Code Here

TOP

Related Classes of liquibase.util.csv.CSVWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.