Search in sources :

Example 1 with AktienfreundeNetExporter

use of name.abuchen.portfolio.datatransfer.csv.AktienfreundeNetExporter in project portfolio by buchen.

the class ExportWizard method performFinish.

@Override
public boolean performFinish() {
    Object exportItem = exportPage.getExportItem();
    Class<?> exportClass = exportPage.getExportClass();
    File file = getFile(exportItem);
    if (file == null)
        return false;
    try {
        // account transactions
        if (exportItem == AccountTransaction.class) {
            new CSVExporter().exportAccountTransactions(file, client.getAccounts());
        } else if (exportClass == AccountTransaction.class) {
            new CSVExporter().exportAccountTransactions(file, (Account) exportItem);
        } else // portfolio transactions
        if (exportItem == PortfolioTransaction.class) {
            new CSVExporter().exportPortfolioTransactions(file, client.getPortfolios());
        } else if (exportClass == PortfolioTransaction.class) {
            new CSVExporter().exportPortfolioTransactions(file, (Portfolio) exportItem);
        } else // master data
        if (exportItem == Security.class) {
            new CSVExporter().exportSecurityMasterData(new File(file, Messages.ExportWizardSecurityMasterData + ".csv"), // $NON-NLS-1$
            client.getSecurities());
        } else if (exportClass == Security.class) {
            if (Messages.ExportWizardSecurityMasterData.equals(exportItem))
                new CSVExporter().exportSecurityMasterData(file, client.getSecurities());
            else if (Messages.ExportWizardMergedSecurityPrices.equals(exportItem))
                new CSVExporter().exportMergedSecurityPrices(file, client.getSecurities());
            else if (Messages.ExportWizardAllTransactionsAktienfreundeNet.equals(exportItem))
                new AktienfreundeNetExporter().exportAllTransactions(file, client);
        } else // historical quotes
        if (exportItem == SecurityPrice.class) {
            new CSVExporter().exportSecurityPrices(file, client.getSecurities());
        } else if (exportClass == SecurityPrice.class) {
            new CSVExporter().exportSecurityPrices(file, (Security) exportItem);
        } else {
            throw new UnsupportedOperationException(MessageFormat.format(Messages.ExportWizardUnsupportedExport, exportClass, exportItem));
        }
    } catch (IOException e) {
        PortfolioPlugin.log(e);
        MessageDialog.openError(getShell(), Messages.ExportWizardErrorExporting, e.getMessage());
    }
    return true;
}
Also used : Account(name.abuchen.portfolio.model.Account) Portfolio(name.abuchen.portfolio.model.Portfolio) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) IOException(java.io.IOException) Security(name.abuchen.portfolio.model.Security) CSVExporter(name.abuchen.portfolio.datatransfer.csv.CSVExporter) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) AktienfreundeNetExporter(name.abuchen.portfolio.datatransfer.csv.AktienfreundeNetExporter) SecurityPrice(name.abuchen.portfolio.model.SecurityPrice) File(java.io.File)

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 AktienfreundeNetExporter (name.abuchen.portfolio.datatransfer.csv.AktienfreundeNetExporter)1 CSVExporter (name.abuchen.portfolio.datatransfer.csv.CSVExporter)1 Account (name.abuchen.portfolio.model.Account)1 AccountTransaction (name.abuchen.portfolio.model.AccountTransaction)1 Portfolio (name.abuchen.portfolio.model.Portfolio)1 PortfolioTransaction (name.abuchen.portfolio.model.PortfolioTransaction)1 Security (name.abuchen.portfolio.model.Security)1 SecurityPrice (name.abuchen.portfolio.model.SecurityPrice)1