Package org.openmetadata.csv
Class EntityCsv<T extends EntityInterface>
java.lang.Object
org.openmetadata.csv.EntityCsv<T>
- Direct Known Subclasses:
DatabaseRepository.DatabaseCsv,DatabaseSchemaRepository.DatabaseSchemaCsv,GlossaryRepository.GlossaryCsv,TableRepository.TableCsv,TeamRepository.TeamCsv,UserRepository.UserCsv
EntityCsv provides export and import capabilities for an entity. Each entity must implement the
abstract methods to provide entity specific processing functionality to export an entity to a CSV
record, and import an entity from a CSV record.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidImplement this method to export an entity into a list of fields to create a CSV recordprotected abstract voidImplement this method to export an entity into a list of fields to create a CSV recordstatic StringcolumnNotFound(int field, String columnFqn) protected abstract voidcreateEntity(org.apache.commons.csv.CSVPrinter resultsPrinter, List<org.apache.commons.csv.CSVRecord> csvRecords) Implement this method to a CSV record and turn it into an entityprotected voidcreateEntity(org.apache.commons.csv.CSVPrinter resultsPrinter, org.apache.commons.csv.CSVRecord csvRecord, T entity) static StringentityNotFound(int field, String entityType, String fqn) final Stringfinal Stringfailed(String exception, CsvErrorType errorType) static StringfieldRequired(int field) protected final BooleangetBoolean(org.apache.commons.csv.CSVPrinter printer, org.apache.commons.csv.CSVRecord csvRecord, int fieldNumber) static CsvDocumentationgetCsvDocumentation(String entityType) protected EntityInterfacegetEntityByName(String entityType, String fqn) protected final EntityReferencegetEntityReference(org.apache.commons.csv.CSVPrinter printer, org.apache.commons.csv.CSVRecord csvRecord, int fieldNumber, String entityType) protected final EntityReferencegetEntityReference(org.apache.commons.csv.CSVPrinter printer, org.apache.commons.csv.CSVRecord csvRecord, int fieldNumber, String entityType, String fqn) protected final List<EntityReference>getEntityReferences(org.apache.commons.csv.CSVPrinter printer, org.apache.commons.csv.CSVRecord csvRecord, int fieldNumber, String entityType) final org.apache.commons.csv.CSVRecordgetNextRecord(org.apache.commons.csv.CSVPrinter resultsPrinter, List<org.apache.commons.csv.CSVRecord> csvRecords) final org.apache.commons.csv.CSVRecordgetNextRecord(org.apache.commons.csv.CSVPrinter resultsPrinter, List<CsvHeader> csvHeaders, List<org.apache.commons.csv.CSVRecord> csvRecords) getOwner(org.apache.commons.csv.CSVPrinter printer, org.apache.commons.csv.CSVRecord csvRecord, int fieldNumber) Owner field is in entityType;entityName formatgetOwnerAsUser(org.apache.commons.csv.CSVPrinter printer, org.apache.commons.csv.CSVRecord csvRecord, int fieldNumber) Owner field is in entityName formatstatic String[]getResultHeaders(List<CsvHeader> csvHeaders) getTagLabels(org.apache.commons.csv.CSVPrinter printer, org.apache.commons.csv.CSVRecord csvRecord, int fieldNumber) final CsvImportResultImport entities from a CSV fileprotected voidimportFailure(org.apache.commons.csv.CSVPrinter printer, String failedReason, org.apache.commons.csv.CSVRecord inputRecord) protected voidimportSuccess(org.apache.commons.csv.CSVPrinter printer, org.apache.commons.csv.CSVRecord inputRecord, String successDetails) static StringinvalidBoolean(int field, String fieldValue) static StringinvalidField(int field, String error) static StringinvalidFieldCount(int expectedFieldCount, int actualFieldCount) static StringinvalidHeader(String expected, String actual) static StringinvalidOwner(int field) resetRequiredColumns(List<CsvHeader> headers, List<String> columnNames)
-
Field Details
-
FIELD_ERROR_MSG
- See Also:
-
IMPORT_STATUS_HEADER
- See Also:
-
IMPORT_STATUS_DETAILS
- See Also:
-
IMPORT_SUCCESS
- See Also:
-
IMPORT_FAILED
- See Also:
-
IMPORT_SKIPPED
- See Also:
-
ENTITY_CREATED
- See Also:
-
ENTITY_UPDATED
- See Also:
-
processRecord
protected boolean processRecord -
dryRunCreatedEntities
-
recordIndex
protected int recordIndex
-
-
Constructor Details
-
EntityCsv
-
-
Method Details
-
importCsv
Import entities from a CSV file- Throws:
IOException
-
createEntity
protected abstract void createEntity(org.apache.commons.csv.CSVPrinter resultsPrinter, List<org.apache.commons.csv.CSVRecord> csvRecords) throws IOException Implement this method to a CSV record and turn it into an entity- Throws:
IOException
-
exportCsv
- Throws:
IOException
-
exportCsv
- Throws:
IOException
-
getCsvDocumentation
-
addRecord
Implement this method to export an entity into a list of fields to create a CSV record -
addRecord
Implement this method to export an entity into a list of fields to create a CSV record -
getOwner
public EntityReference getOwner(org.apache.commons.csv.CSVPrinter printer, org.apache.commons.csv.CSVRecord csvRecord, int fieldNumber) throws IOException Owner field is in entityType;entityName format- Throws:
IOException
-
getOwnerAsUser
public EntityReference getOwnerAsUser(org.apache.commons.csv.CSVPrinter printer, org.apache.commons.csv.CSVRecord csvRecord, int fieldNumber) throws IOException Owner field is in entityName format- Throws:
IOException
-
getBoolean
protected final Boolean getBoolean(org.apache.commons.csv.CSVPrinter printer, org.apache.commons.csv.CSVRecord csvRecord, int fieldNumber) throws IOException - Throws:
IOException
-
getEntityReference
protected final EntityReference getEntityReference(org.apache.commons.csv.CSVPrinter printer, org.apache.commons.csv.CSVRecord csvRecord, int fieldNumber, String entityType) throws IOException - Throws:
IOException
-
getEntityByName
-
getEntityReference
protected final EntityReference getEntityReference(org.apache.commons.csv.CSVPrinter printer, org.apache.commons.csv.CSVRecord csvRecord, int fieldNumber, String entityType, String fqn) throws IOException - Throws:
IOException
-
getEntityReferences
protected final List<EntityReference> getEntityReferences(org.apache.commons.csv.CSVPrinter printer, org.apache.commons.csv.CSVRecord csvRecord, int fieldNumber, String entityType) throws IOException - Throws:
IOException
-
getTagLabels
protected final List<TagLabel> getTagLabels(org.apache.commons.csv.CSVPrinter printer, org.apache.commons.csv.CSVRecord csvRecord, int fieldNumber) throws IOException - Throws:
IOException
-
getResultHeaders
-
getNextRecord
public final org.apache.commons.csv.CSVRecord getNextRecord(org.apache.commons.csv.CSVPrinter resultsPrinter, List<CsvHeader> csvHeaders, List<org.apache.commons.csv.CSVRecord> csvRecords) throws IOException - Throws:
IOException
-
getNextRecord
public final org.apache.commons.csv.CSVRecord getNextRecord(org.apache.commons.csv.CSVPrinter resultsPrinter, List<org.apache.commons.csv.CSVRecord> csvRecords) throws IOException - Throws:
IOException
-
createEntity
protected void createEntity(org.apache.commons.csv.CSVPrinter resultsPrinter, org.apache.commons.csv.CSVRecord csvRecord, T entity) throws IOException - Throws:
IOException
-
failed
-
invalidHeader
-
invalidFieldCount
-
fieldRequired
-
invalidField
-
entityNotFound
-
columnNotFound
-
invalidOwner
-
invalidBoolean
-
resetRequiredColumns
-
importSuccess
protected void importSuccess(org.apache.commons.csv.CSVPrinter printer, org.apache.commons.csv.CSVRecord inputRecord, String successDetails) throws IOException - Throws:
IOException
-
importFailure
protected void importFailure(org.apache.commons.csv.CSVPrinter printer, String failedReason, org.apache.commons.csv.CSVRecord inputRecord) throws IOException - Throws:
IOException
-