@Deprecated public abstract class LineBasedImporter extends JsonImporter
Importer that handles data from a file that can be delimited into
one or more lines. Each line is considered a single group of data that can be
converted to a multimap and imported in one or more records in Concourse.| Modifier and Type | Field and Description |
|---|---|
protected boolean |
useOptimizedSplitPath
Deprecated.
A flag that indicates whether the importer should use the optimized split
path that takes advantage of the
QuoteAwareStringSplitter. |
logANNOTATE_DATA_SOURCE_OPTION_NAME, concourse, DATA_SOURCE_ANNOTATION_KEY, params| Modifier | Constructor and Description |
|---|---|
protected |
LineBasedImporter(Concourse concourse,
Logger log)
Deprecated.
Construct a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
protected abstract String |
delimiter()
Deprecated.
The delimiter that is used to split fields on each line.
|
protected String[] |
header()
Deprecated.
This method is provided so the subclass can provide an ordered array of
headers if they are not provided in the file as the first line.
|
Set<Long> |
importFile(String file)
Deprecated.
Import the data from
file into Concourse and return the
record ids where the data was imported. |
Set<Long> |
importFile(String file,
String resolveKey)
Deprecated.
Import the data contained in
file into Concourse. |
protected JsonElement |
transformValue(String key,
String value)
Deprecated.
At a minimum, this method is responsible for taking a raw source string
value and converting it to a
JsonElement. |
protected abstract void |
validateFileFormat(String line)
Deprecated.
Check
line to determine if is valid for the the file format that
is supported by the importer. |
importJsonString, importString, upsertJsonStringprotected boolean useOptimizedSplitPath
QuoteAwareStringSplitter.protected LineBasedImporter(Concourse concourse,
Logger log)
concourse - public final Set<Long> importFile(String file)
Importerfile into Concourse and return the
record ids where the data was imported.importFile in class JsonImporterfile - the path of the file to import; relative paths will be
resolved against the user.dir system property. When
using the ImportCli, prior
to passing the path to this method, relative paths are
converted to absolute paths by resolving against the directory
from which the CLI process is launchedSet that contains the ids of the records affected by
the importpublic final Set<Long> importFile(String file, @Nullable String resolveKey)
file into Concourse.
Note that if resolveKey is specified, an attempt
will be made to add the data in from each group into the existing records
that are found using resolveKey and its corresponding value in
the group.
file - resolveKey - ImportResult objects that describes the
records created/affected from the import and whether any errors
occurred.protected abstract String delimiter()
protected String[] header()
protected JsonElement transformValue(String key, String value)
JsonElement. The default
implementation makes an effort to represent numeric and boolean values as
appropriate json primitives. All other kinds of
values are represented as strings, which is the correct format for the
server to handle masquerading types (i.e. resolvable links, links, tags,
forced doubles, etc).
The default behaviour is appropriate in most cases, but this method can be used by subclasses to define dynamic intermediary transformations to data to better prepare it for import.
The server will convert raw data of the form
@<key>@value@<key>@ into a Link to all the
records where key equals value in Concourse. For this purpose, the
subclass can convert the raw value to this form using the
Convert.stringToResolvableLinkSpecification(String, String)
method.
key - value - protected abstract void validateFileFormat(String line) throws IllegalArgumentException
line to determine if is valid for the the file format that
is supported by the importer.line - is a line of the file being importedIllegalArgumentException - if the line from the file is
not acceptable for the file format