Class XMLImporter

java.lang.Object
com.axelor.data.xml.XMLImporter
All Implemented Interfaces:
Importer

public class XMLImporter extends Object implements Importer
XML data importer.

This class also provides run(ImportTask) method to import data programmatically.

For example:
 XMLImporter importer = new XMLImporter("path/to/xml-config.xml");

 importer.runTask(new ImportTask(){

        public void configure() throws IOException {
                input("contacts.xml", new File("data/xml/contacts.xml"));
                input("contacts.xml", new File("data/xml/contacts2.xml"));
        }

        public boolean handle(ImportException e) {
                System.err.println("Import error: " + e);
                return true;
        }
 }
 
  • Constructor Details

    • XMLImporter

      @Inject public XMLImporter(@Named("axelor.data.config") String configFile, @Named("axelor.data.dir") String dataDir)
    • XMLImporter

      public XMLImporter(String configFile)
  • Method Details

    • setContext

      public void setContext(Map<String,Object> context)
      Description copied from interface: Importer
      Set global context.
      Specified by:
      setContext in interface Importer
      Parameters:
      context - the global context
    • addListener

      public void addListener(Listener listener)
      Description copied from interface: Importer
      Add a data import event listener.
      Specified by:
      addListener in interface Importer
      Parameters:
      listener - the listener
    • clearListener

      public void clearListener()
      Description copied from interface: Importer
      Clear listeners.
      Specified by:
      clearListener in interface Importer
    • setCanClear

      public void setCanClear(boolean canClear)
    • run

      public void run()
      Description copied from interface: Importer
      Run the data import task.
      Specified by:
      run in interface Importer
    • run

      public void run(ImportTask task)
      Description copied from interface: Importer
      Run the specified import task.
      Specified by:
      run in interface Importer
      Parameters:
      task - the task to run