Class ImportSpec

java.lang.Object
com.orchestranetworks.service.ImportSpec

public class ImportSpec extends Object
Defines the settings of an import.

To be valid, an instance of this class must define at least an XML or CSV source and a target dataset. The XML or CSV document used as the source must be a subset or a complete document that conforms to the data model associated with the target dataset.

Usage

The following is a code sample for importing a CSV table:

 private ImportSpec getImportSpecForCSV(
        File csvFile,
        AdaptationTable table,
        Header headerType)
 {
        ExportImportCSVSpec csvSpec = new ExportImportCSVSpec();
        csvSpec.setHeader(headerType);

        ImportSpec importSpec = new ImportSpec();
        importSpec.setSourceFile(csvFile);
        importSpec.setTargetAdaptationTable(table);
        importSpec.setCSVSpec(csvSpec);
        return importSpec;
 }
 

Specification:

The complete specification of XML imports is available in the reference document XML imports.

The complete specification of CSV imports is available in the reference document CSV imports.

See Also:
  • Constructor Details

    • ImportSpec

      public ImportSpec()
  • Method Details

    • getTargetAdaptation

      public Adaptation getTargetAdaptation()
      See Also:
    • setTargetAdaptation

      public void setTargetAdaptation(Adaptation aTarget)
      Specifies the target dataset of the import.

      In the case of an import of a specific table, the method setTargetAdaptationTable must be used instead.

      Parameters:
      aTarget - the dataset that will be updated with the imported XML content.
    • setTargetAdaptationTable

      public void setTargetAdaptationTable(AdaptationTable aTargetTable)
      Specifies the target table of the import.
      Parameters:
      aTargetTable - the table that will be updated with the imported CSV content.
      See Also:
    • getImportMode

      public ImportSpecMode getImportMode()
      Returns the import mode.
      See Also:
    • setImportMode

      public void setImportMode(ImportSpecMode mode)
      Specifies the import mode: 'insert', 'insert or update', 'update only', 'replace'.

      If not specified, the 'insert' mode is used.

    • getSourceFile

      public File getSourceFile()
      See Also:
    • setSourceFile

      public void setSourceFile(File aSource)
      Specifies the XML or CSV document that serves as the source of the import.
      Parameters:
      aSource - the XML or CSV document to import.
    • getSourceStream

      public InputStream getSourceStream()
      See Also:
    • setSourceStream

      public void setSourceStream(InputStream aSource)
      Specifies that the import process must read the document from the specified stream.

      The source stream is a more general alternative than the source file.

      It is up to the caller of this method to provide a buffered input stream (if needed for performance).

      Parameters:
      aSource - the stream containing the XML or CSV content to import.
    • isCloseStreamWhenFinished

      public boolean isCloseStreamWhenFinished()
      See Also:
    • setCloseStreamWhenFinished

      public void setCloseStreamWhenFinished(boolean closeStreamWhenFinished)
      Specifies that the import process must close the stream when complete.

      If not set, this property is true.

    • getCSVSpec

      public ExportImportCSVSpec getCSVSpec()
      Returns the specific setting that have been specified for a CSV import, null if an XML import is to be made.
      See Also:
    • setCSVSpec

      public void setCSVSpec(ExportImportCSVSpec csvSpec)
      Specifies the specific settings for a CSV import instead of an XML import.

      If not specified, the XML import is performed.

    • isUnmatchedXMLElementIgnored

      public boolean isUnmatchedXMLElementIgnored()
      Since:
      5.8.1
      See Also:
    • setUnmatchedXMLElementIgnored

      public void setUnmatchedXMLElementIgnored(boolean isUnmatchedXMLElementIgnored)
      Specifies whether the XML import should be tolerant to ignore extra columns that are not defined in the model.
      • If set to true, the import process will be successful even if the XML file contains columns that are not defined in the model. The data included in the extra columns will be lost.
      • If set to false (the default), the import process will fail if the XML file contains columns that are not defined in the model.
      Since:
      5.8.1
    • isComputedValuesIncluded

      public boolean isComputedValuesIncluded()
      Since:
      5.7.0
      See Also:
    • setComputedValuesIncluded

      public void setComputedValuesIncluded(boolean computedValuesIncluded)
      Specifies whether the CSV file to be imported contains computed fields.
      • If set to true (default), the CSV file to be imported contains computed columns.
      • If set to false, the CSV file to be imported does not contain computed columns.

      This property must be set when importing a CSV file without header into a table having computed columns.

      Since:
      5.7.0
    • isByDelta

      public boolean isByDelta()
      Since:
      5.2.4
      See Also:
    • setByDelta

      public void setByDelta(boolean byDelta)
      Defines whether the by delta mode is enabled, which allows ignoring absent XML elements.

      By default this mode is disabled.

      The complete behavior is described in the sections Insert/Update operation.

      Since:
      5.2.4
    • isDetailedResult

      public boolean isDetailedResult()
      See Also:
    • setDetailedResult

      public void setDetailedResult(boolean detailedResult)
      Enables the details of an import. Default is false.
      See Also:
    • isUpdateByDelta

      @Deprecated public boolean isUpdateByDelta()
      Deprecated.
      Since version 5.2.4, this method has been replaced by isByDelta.
      See Also:
    • setUpdateByDelta

      @Deprecated public void setUpdateByDelta(boolean updateByDelta)
      Deprecated.
      Since version 5.2.4, this method has been replaced by setByDelta.
      See Also:
    • toStringInfo

      public String toStringInfo()
      Returns information about the main attributes of this instance.
    • toString

      public String toString()
      Overrides:
      toString in class Object