public class ImportSpec extends Object
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.
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; }
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.
ProcedureContext.doImport(ImportSpec)
,
ExportSpec
Constructor and Description |
---|
ImportSpec() |
Modifier and Type | Method and Description |
---|---|
ExportImportCSVSpec |
getCSVSpec()
Returns the specific setting that have been specified for a
CSV import,
null if an XML import
is to be made. |
ImportSpecMode |
getImportMode()
Returns the import mode.
|
File |
getSourceFile() |
InputStream |
getSourceStream() |
Adaptation |
getTargetAdaptation() |
boolean |
isByDelta() |
boolean |
isCloseStreamWhenFinished() |
boolean |
isComputedValuesIncluded() |
boolean |
isDetailedResult() |
boolean |
isUnmatchedXMLElementIgnored() |
boolean |
isUpdateByDelta()
Deprecated.
Since version 5.2.4, this method has been replaced by
isByDelta . |
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 by
setByDelta . |
String |
toString() |
String |
toStringInfo()
Returns information about the main attributes of this instance.
|
public Adaptation getTargetAdaptation()
setTargetAdaptation(Adaptation)
public void setTargetAdaptation(Adaptation aTarget)
In the case of an import of a specific table, the method
setTargetAdaptationTable
must be used instead.
aTarget
- the dataset that will be updated with the imported XML content.public void setTargetAdaptationTable(AdaptationTable aTargetTable)
aTargetTable
- the table that will be updated with the imported CSV content.setTargetAdaptation(Adaptation)
public ImportSpecMode getImportMode()
setImportMode(ImportSpecMode)
public void setImportMode(ImportSpecMode mode)
If not specified, the 'insert
' mode is used.
public File getSourceFile()
setSourceFile(File)
public void setSourceFile(File aSource)
aSource
- the XML or CSV document to import.public InputStream getSourceStream()
setSourceStream(InputStream)
public void setSourceStream(InputStream aSource)
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).
aSource
- the stream containing the XML or CSV content to import.public boolean isCloseStreamWhenFinished()
setCloseStreamWhenFinished(boolean)
public void setCloseStreamWhenFinished(boolean closeStreamWhenFinished)
If not set, this property is true
.
public ExportImportCSVSpec getCSVSpec()
null
if an XML import
is to be made.setCSVSpec(ExportImportCSVSpec)
public void setCSVSpec(ExportImportCSVSpec csvSpec)
If not specified, the XML import is performed.
public boolean isUnmatchedXMLElementIgnored()
setUnmatchedXMLElementIgnored(boolean)
public void setUnmatchedXMLElementIgnored(boolean isUnmatchedXMLElementIgnored)
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.false
(the default), the import process will fail if the XML file contains columns
that are not defined in the model.public boolean isComputedValuesIncluded()
setComputedValuesIncluded(boolean)
public void setComputedValuesIncluded(boolean computedValuesIncluded)
true
(default), the CSV file to be imported contains computed columns.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.
public boolean isByDelta()
setByDelta(boolean)
public void setByDelta(boolean byDelta)
By default this mode is disabled.
The complete behavior is described in the sections Insert/Update operation.
public boolean isDetailedResult()
setDetailedResult(boolean)
public void setDetailedResult(boolean detailedResult)
false
.public boolean isUpdateByDelta()
isByDelta
.isByDelta()
public void setUpdateByDelta(boolean updateByDelta)
setByDelta
.setByDelta(boolean)
public String toStringInfo()