Class ImportSpec
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.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the specific setting that have been specified for a CSV import,null
if an XML import is to be made.Returns the import mode.boolean
boolean
boolean
boolean
boolean
boolean
Deprecated.void
setByDelta
(boolean byDelta) Defines whether the by delta mode is enabled, which allows ignoring absent XML elements.void
setCloseStreamWhenFinished
(boolean closeStreamWhenFinished) Specifies that the import process must close the stream when complete.void
setComputedValuesIncluded
(boolean computedValuesIncluded) Specifies whether the CSV file to be imported contains computed fields.void
setCSVSpec
(ExportImportCSVSpec csvSpec) Specifies the specific settings for a CSV import instead of an XML import.void
setDetailedResult
(boolean detailedResult) Enables the details of an import.void
setImportMode
(ImportSpecMode mode) Specifies the import mode: 'insert', 'insert or update', 'update only', 'replace'.void
setSourceFile
(File aSource) Specifies the XML or CSV document that serves as the source of the import.void
setSourceStream
(InputStream aSource) Specifies that the import process must read the document from the specified stream.void
setTargetAdaptation
(Adaptation aTarget) Specifies the target dataset of the import.void
setTargetAdaptationTable
(AdaptationTable aTargetTable) Specifies the target table of the import.void
setUnmatchedXMLElementIgnored
(boolean isUnmatchedXMLElementIgnored) Specifies whether the XML import should be tolerant to ignore extra columns that are not defined in the model.void
setUpdateByDelta
(boolean updateByDelta) Deprecated.Since version 5.2.4, this method has been replaced bysetByDelta
.toString()
Returns information about the main attributes of this instance.
-
Constructor Details
-
ImportSpec
public ImportSpec()
-
-
Method Details
-
getTargetAdaptation
- See Also:
-
setTargetAdaptation
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
Specifies the target table of the import.- Parameters:
aTargetTable
- the table that will be updated with the imported CSV content.- See Also:
-
getImportMode
Returns the import mode.- See Also:
-
setImportMode
Specifies the import mode: 'insert', 'insert or update', 'update only', 'replace'.If not specified, the '
insert
' mode is used. -
getSourceFile
- See Also:
-
setSourceFile
Specifies the XML or CSV document that serves as the source of the import.- Parameters:
aSource
- the XML or CSV document to import.
-
getSourceStream
- See Also:
-
setSourceStream
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
Returns the specific setting that have been specified for a CSV import,null
if an XML import is to be made.- See Also:
-
setCSVSpec
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
- If set to
-
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
- If set to
-
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 isfalse
. -
isUpdateByDelta
Deprecated.Since version 5.2.4, this method has been replaced byisByDelta
.- See Also:
-
setUpdateByDelta
Deprecated.Since version 5.2.4, this method has been replaced bysetByDelta
.- See Also:
-
toStringInfo
Returns information about the main attributes of this instance. -
toString
-
isByDelta
.