Search in sources :

Example 6 with CSVInput

use of com.axelor.data.csv.CSVInput in project axelor-open-suite by axelor.

the class DataImportServiceImpl method createCSVInput.

private CSVInput createCSVInput(FileTab fileTab, String fileName) {
    boolean update = false;
    String searchCall = fileTab.getSearchCall();
    if (fileTab.getImportType() != FileFieldRepository.IMPORT_TYPE_FIND_NEW && (CollectionUtils.isNotEmpty(fileTab.getSearchFieldSet()) || StringUtils.notBlank(searchCall))) {
        update = true;
    }
    XStream stream = XStreamUtils.createXStream();
    stream.processAnnotations(CSVInput.class);
    CSVInput input = (CSVInput) stream.fromXML("<input update=\"" + update + "\" />");
    input.setFileName(fileName);
    input.setSeparator(CSV_SEPRATOR);
    input.setTypeName(fileTab.getMetaModel().getFullName());
    input.setCallable(INPUT_CALLABLE);
    input.setSearch(null);
    input.setBindings(new ArrayList<>());
    input.setSearchCall(searchCall);
    return input;
}
Also used : XStream(com.thoughtworks.xstream.XStream) CSVInput(com.axelor.data.csv.CSVInput)

Aggregations

CSVInput (com.axelor.data.csv.CSVInput)6 MetaModel (com.axelor.meta.db.MetaModel)4 ArrayList (java.util.ArrayList)4 App (com.axelor.apps.base.db.App)3 CSVConfig (com.axelor.data.csv.CSVConfig)3 Model (com.axelor.db.Model)3 Mapper (com.axelor.db.mapper.Mapper)3 Property (com.axelor.db.mapper.Property)3 File (java.io.File)3 IOException (java.io.IOException)3 List (java.util.List)3 DataReaderService (com.axelor.apps.tool.reader.DataReaderService)2 Inflector (com.axelor.common.Inflector)2 DataAdapter (com.axelor.data.adapter.DataAdapter)2 CSVBind (com.axelor.data.csv.CSVBind)2 CSVImporter (com.axelor.data.csv.CSVImporter)2 AxelorException (com.axelor.exception.AxelorException)2 MetaFile (com.axelor.meta.db.MetaFile)2 Inject (com.google.inject.Inject)2 FileOutputStream (java.io.FileOutputStream)2