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

public abstract class EntityCsv<T extends EntityInterface> extends Object
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.
  • Field Details

  • Constructor Details

  • Method Details

    • importCsv

      public final CsvImportResult importCsv(String csv, boolean dryRun) throws IOException
      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

      public final String exportCsv(T entity) throws IOException
      Throws:
      IOException
    • exportCsv

      public final String exportCsv(List<T> entities) throws IOException
      Throws:
      IOException
    • getCsvDocumentation

      public static CsvDocumentation getCsvDocumentation(String entityType)
    • addRecord

      protected abstract void addRecord(CsvFile csvFile, T entity)
      Implement this method to export an entity into a list of fields to create a CSV record
    • addRecord

      public final void addRecord(CsvFile csvFile, List<String> recordList)
      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

      protected EntityInterface getEntityByName(String entityType, String fqn)
    • 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

      public static String[] getResultHeaders(List<CsvHeader> csvHeaders)
    • 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

      public String failed(String exception, CsvErrorType errorType)
    • invalidHeader

      public static String invalidHeader(String expected, String actual)
    • invalidFieldCount

      public static String invalidFieldCount(int expectedFieldCount, int actualFieldCount)
    • fieldRequired

      public static String fieldRequired(int field)
    • invalidField

      public static String invalidField(int field, String error)
    • entityNotFound

      public static String entityNotFound(int field, String entityType, String fqn)
    • columnNotFound

      public static String columnNotFound(int field, String columnFqn)
    • invalidOwner

      public static String invalidOwner(int field)
    • invalidBoolean

      public static String invalidBoolean(int field, String fieldValue)
    • resetRequiredColumns

      public static List<CsvHeader> resetRequiredColumns(List<CsvHeader> headers, List<String> columnNames)
    • 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