Search in sources :

Example 1 with ImportConfiguration

use of com.axelor.apps.base.db.ImportConfiguration in project axelor-open-suite by axelor.

the class AccountChartService method importAccountChartData.

public void importAccountChartData(AccountChart act, File configFile, Map<String, Object> importContext) throws IOException, AxelorException {
    ImportConfiguration importConfiguration = new ImportConfiguration();
    importConfiguration.setDataMetaFile(act.getMetaFile());
    importConfiguration.setBindMetaFile(metaFiles.upload(configFile));
    factoryImporter.createImporter(importConfiguration).run(importContext);
}
Also used : ImportConfiguration(com.axelor.apps.base.db.ImportConfiguration)

Example 2 with ImportConfiguration

use of com.axelor.apps.base.db.ImportConfiguration in project axelor-open-suite by axelor.

the class ImportConfigurationBaseRepository method copy.

@Override
public ImportConfiguration copy(ImportConfiguration entity, boolean deep) {
    ImportConfiguration importConfiguration = super.copy(entity, deep);
    importConfiguration.setImportHistoryList(null);
    importConfiguration.setStatusSelect(ImportConfigurationRepository.STATUS_DRAFT);
    importConfiguration.setStartDateTime(null);
    importConfiguration.setEndDateTime(null);
    return importConfiguration;
}
Also used : ImportConfiguration(com.axelor.apps.base.db.ImportConfiguration)

Example 3 with ImportConfiguration

use of com.axelor.apps.base.db.ImportConfiguration in project axelor-open-suite by axelor.

the class ImportCityServiceImpl method importCityData.

/**
 * Imports city data
 *
 * @param configXmlFile
 * @param dataCsvFile
 * @return
 */
protected ImportHistory importCityData(File configXmlFile, File dataCsvFile) {
    ImportHistory importHistory = null;
    try {
        ImportConfiguration importConfiguration = new ImportConfiguration();
        importConfiguration.setBindMetaFile(metaFiles.upload(configXmlFile));
        importConfiguration.setDataMetaFile(metaFiles.upload(dataCsvFile));
        importHistory = factoryImporter.createImporter(importConfiguration).run();
    } catch (Exception e) {
        TraceBackService.trace(e);
        printWriter.append(e.getLocalizedMessage() + " at " + e.getStackTrace()[0] + "\n");
    }
    return importHistory;
}
Also used : ImportConfiguration(com.axelor.apps.base.db.ImportConfiguration) AxelorException(com.axelor.exception.AxelorException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) ImportHistory(com.axelor.apps.base.db.ImportHistory)

Example 4 with ImportConfiguration

use of com.axelor.apps.base.db.ImportConfiguration in project axelor-open-suite by axelor.

the class ImportDemoDataServiceImpl method importFileData.

private MetaFile importFileData(File dataFile, File configFile, String dataFileName, String configFileName) throws IOException, AxelorException {
    ImportConfiguration config = new ImportConfiguration();
    MetaFile configMetaFile = metaFiles.upload(new FileInputStream(configFile), configFileName + ".xml");
    MetaFile dataMetaFile = metaFiles.upload(new FileInputStream(dataFile), dataFileName + ".csv");
    config.setBindMetaFile(configMetaFile);
    config.setDataMetaFile(dataMetaFile);
    config.setTypeSelect("csv");
    ImportHistory importHistory = factoryImporter.createImporter(config).run();
    MetaFiles.getPath(configMetaFile).toFile().delete();
    MetaFiles.getPath(dataMetaFile).toFile().delete();
    return importHistory.getLogMetaFile();
}
Also used : ImportConfiguration(com.axelor.apps.base.db.ImportConfiguration) MetaFile(com.axelor.meta.db.MetaFile) FileInputStream(java.io.FileInputStream) ImportHistory(com.axelor.apps.base.db.ImportHistory)

Example 5 with ImportConfiguration

use of com.axelor.apps.base.db.ImportConfiguration in project axelor-open-suite by axelor.

the class ICalendarController method importCalendarFile.

public void importCalendarFile(ActionRequest request, ActionResponse response) throws IOException, ParserException {
    ImportConfiguration imp = request.getContext().asType(ImportConfiguration.class);
    Object object = request.getContext().get("_id");
    ICalendar cal = null;
    if (object != null) {
        Long id = Long.valueOf(object.toString());
        cal = Beans.get(ICalendarRepository.class).find(id);
    }
    if (cal == null) {
        cal = new ICalendar();
    }
    File data = MetaFiles.getPath(imp.getDataMetaFile()).toFile();
    Beans.get(ICalendarService.class).load(cal, data);
    response.setCanClose(true);
    response.setReload(true);
}
Also used : ICalendar(com.axelor.apps.base.db.ICalendar) ImportConfiguration(com.axelor.apps.base.db.ImportConfiguration) File(java.io.File) ICalendarService(com.axelor.apps.base.ical.ICalendarService)

Aggregations

ImportConfiguration (com.axelor.apps.base.db.ImportConfiguration)9 ImportHistory (com.axelor.apps.base.db.ImportHistory)4 File (java.io.File)4 FileInputStream (java.io.FileInputStream)2 IOException (java.io.IOException)2 FECImport (com.axelor.apps.account.db.FECImport)1 ICalendar (com.axelor.apps.base.db.ICalendar)1 ImportConfigurationRepository (com.axelor.apps.base.db.repo.ImportConfigurationRepository)1 ICalendarService (com.axelor.apps.base.ical.ICalendarService)1 AppBaseService (com.axelor.apps.base.service.app.AppBaseService)1 ImportService (com.axelor.apps.base.service.imports.ImportService)1 AxelorException (com.axelor.exception.AxelorException)1 MetaFile (com.axelor.meta.db.MetaFile)1 UnknownHostException (java.net.UnknownHostException)1 Path (java.nio.file.Path)1