Package com.orchestranetworks.addon.dex.mapping


package com.orchestranetworks.addon.dex.mapping

Classes and interfaces to configure mapping between source and target applications.


Creating application mapping for data transfer

  1. Define the source application and target application:

                    CommonApplication sourceApplication = new CommonApplication(
    sourceLogicalName,
    ApplicationType.EBX);
    CommonApplication targetApplication = new CommonApplication(
    targetLogicalName,
    ApplicationType.EBX);
  2. Create the mapping for tables and fields:

                    AdaptationTable srcAdaptationTable = transferConfigurationSpec.getCurrentDataset()
    .getTable(Path.parse("/root/Libraries"));
    EBXField sourceIdField = new EBXField(
    srcAdaptationTable.getTableOccurrenceRootNode()
    .getNode(Path.parse("/root/Libraries/Id")));
    EBXField sourceNameField = new EBXField(
    srcAdaptationTable.getTableOccurrenceRootNode()
    .getNode(Path.parse("/root/Libraries/Name")));
    List<EBXField> srcEBXFields = new ArrayList<EBXField>();
    srcEBXFields.add(sourceIdField);
    srcEBXFields.add(sourceNameField);
    EBXTable srcEBXTable = new EBXTable(srcAdaptationTable, srcEBXFields);

    AdaptationTable tarAdaptationTable = transferConfigurationSpec.getTargetDataset()
    .getTable(Path.parse("/root/LibrariesTarget"));
    EBXField targetIdField = new EBXField(
    tarAdaptationTable.getTableOccurrenceRootNode()
    .getNode(Path.parse("/root/LibrariesTarget/IdTarget")));
    EBXField targetNameField = new EBXField(
    tarAdaptationTable.getTableOccurrenceRootNode()
    .getNode(Path.parse("/root/LibrariesTarget/NameTarget")));
    List<EBXField> tarEBXFields = new ArrayList<EBXField>();
    tarEBXFields.add(targetIdField);
    tarEBXFields.add(targetNameField);
    EBXTable tarEBXTable = new EBXTable(tarAdaptationTable, tarEBXFields);

    FieldMappingList<EBXField, EBXField> fieldMappingList = new FieldMappingList<EBXField, EBXField>();
    FieldMapping<EBXField, EBXField> idFieldMapping = new FieldMapping<EBXField, EBXField>(
    sourceIdField,
    targetIdField);
    FieldMapping<EBXField, EBXField> nameFieldMapping = new FieldMapping<EBXField, EBXField>(
    sourceNameField,
    targetNameField);
    fieldMappingList.add(idFieldMapping);
    fieldMappingList.add(nameFieldMapping);

    TableMapping<EBXField, EBXField> tableMapping = new TableMapping<EBXField, EBXField>(
    srcEBXTable,
    tarEBXTable,
    fieldMappingList);
    TableMappingList<EBXField, EBXField> tableMappingList = new TableMappingList<EBXField, EBXField>();
    tableMappingList.add(tableMapping);
  3. Please refer to the com.orchestranetworks.addon.dex.common.generation package for examples of generating EBX® tables.

  4. When transferring data using a transformation function, define the transformation function and its parameters for field mapping as shown below:

                    idFieldMapping.setTransformationDefinition(transformationDefinition);
    idFieldMapping.setActualParameterDefinitions(actualParameterDefinitions);

    Please refer to the com.orchestranetworks.addon.dex.transformation package for examples of creating the transformation function.

  5. A validator can be defined on a table mapping in a similar manner:

                    tableMapping.setValidatorDefinition(validatorDefinition);
  6. Please refer to the com.orchestranetworks.addon.dex.validator package for examples of creating the validator.

  7. You can use the list of table mappings to create an application mapping:

                    ApplicationMapping<EBXField, EBXField> applicationMapping = new ApplicationMapping<EBXField, EBXField>(
    sourceApplication,
    targetApplication,
    tableMappingList);

Please refer to the com.orchestranetworks.addon.dex.common.generation package for examples of generating an application mapping for data transfer.


Creating the application mapping for XML import

To create an application mapping used for XML import:

  1. Define the source and target application:

                    CommonApplication sourceApplication = new CommonApplication(
    sourceLogicalName,
    ApplicationType.XML);
    CommonApplication targetApplication = new CommonApplication(
    targetLogicalName,
    ApplicationType.EBX);
  2. Create mappings for tables and fields:

                    TableMappingList<XMLField, EBXField> tableMappingList = new TableMappingList<XMLField, EBXField>();
    AdaptationTable targetAdaptationTable = xmlImportConfigurationSpec.getCurrentDataset()
    .getTable(Path.parse("/root/Libraries"));
    List<XMLField> sourceFields = new ArrayList<XMLField>();
    XMLField sourceIdField = new XMLField("/root/Libraries/Id");
    XMLField sourceNameField = new XMLField("/root/Libraries/Name");
    sourceFields.add(sourceIdField);
    sourceFields.add(sourceNameField);
    XMLTable srcXMLTable = new XMLTable("/root/Libraries", sourceFields);

    EBXField targetIdField = new EBXField(
    targetAdaptationTable.getTableOccurrenceRootNode()
    .getNode(Path.parse("/root/Libraries/Id")));
    EBXField targetNameField = new EBXField(
    targetAdaptationTable.getTableOccurrenceRootNode()
    .getNode(Path.parse("/root/Libraries/Name")));
    FieldMapping<XMLField, EBXField> idFieldMapping = new FieldMapping<XMLField, EBXField>(
    sourceIdField,
    targetIdField);
    FieldMapping<XMLField, EBXField> nameFieldMapping = new FieldMapping<XMLField, EBXField>(
    sourceNameField,
    targetNameField);
    FieldMappingList<XMLField, EBXField> fieldMappingList = new FieldMappingList<XMLField, EBXField>();
    fieldMappingList.add(idFieldMapping);
    fieldMappingList.add(nameFieldMapping);

    List<EBXField> ebxFields = new ArrayList<EBXField>();
    ebxFields.add(targetIdField);
    ebxFields.add(targetNameField);
    EBXTable tarEBXTable = new EBXTable(targetAdaptationTable, ebxFields);
    tableMappingList.add(
    new TableMapping<XMLField, EBXField>(srcXMLTable, tarEBXTable, fieldMappingList));
  3. Please refer to the com.orchestranetworks.addon.dex.common.generation package for examples of generating EBX® and XML tables for XML import.

  4. When importing using a transformation function, define the transformation function and its field mapping parameters:

                    idFieldMapping.setTransformationDefinition(transformationDefinition);
    idFieldMapping.setActualParameterDefinitions(actualParameterDefinitions);

    Please refer to the com.orchestranetworks.addon.dex.transformation package for examples of creating the transformation function.

  5. Validator can be defined on table mapping in a similar manner:

                    tableMapping.setValidatorDefinition(validatorDefinition);
  6. Please refer to the com.orchestranetworks.addon.dex.validator package for examples of creating the validator.

  7. Use the list of table mappings to create the application mapping:

                    ApplicationMapping<XMLField, EBXField> applicationMapping = new ApplicationMapping<XMLField, EBXField>(
    sourceApplication,
    targetApplication,
    tableMappingList);

Please refer to the com.orchestranetworks.addon.dex.common.generation package for examples of generating an application mapping for XML import.


Creating an application mapping for XML export

To create an application mapping used to export XML:

  1. Define the source and target applications as shown below:

                    CommonApplication sourceApplication = new CommonApplication(
    sourceLogicalName,
    ApplicationType.EBX);
    CommonApplication targetApplication = new CommonApplication(
    targetLogicalName,
    ApplicationType.XML);
  2. Create mappings for tables and fields:

                    TableMappingList<EBXField, XMLField> tableMappingList = new TableMappingList<EBXField, XMLField>();
    AdaptationTable sourceAdaptationTable = xmlExportConfigurationSpec.getCurrentDataset()
    .getTable(Path.parse("/root/Libraries"));
    EBXField sourceIdField = new EBXField(
    sourceAdaptationTable.getTableOccurrenceRootNode()
    .getNode(Path.parse("/root/Libraries/Id")));
    EBXField sourceNameField = new EBXField(
    sourceAdaptationTable.getTableOccurrenceRootNode()
    .getNode(Path.parse("/root/Libraries/Name")));

    List<XMLField> targetXMLFields = new ArrayList<XMLField>();
    XMLField targetIdField = new XMLField("/root/Libraries/Id");
    XMLField targetNameField = new XMLField("/root/Libraries/Name");
    targetXMLFields.add(targetIdField);
    targetXMLFields.add(targetNameField);
    XMLTable tarXMLTable = new XMLTable("/root/Libraries", targetXMLFields);

    FieldMapping<EBXField, XMLField> idFieldMapping = new FieldMapping<EBXField, XMLField>(
    sourceIdField,
    targetIdField);
    FieldMapping<EBXField, XMLField> nameFieldMapping = new FieldMapping<EBXField, XMLField>(
    sourceNameField,
    targetNameField);
    FieldMappingList<EBXField, XMLField> fieldMappingList = new FieldMappingList<EBXField, XMLField>();
    fieldMappingList.add(idFieldMapping);
    fieldMappingList.add(nameFieldMapping);

    List<EBXField> ebxFields = new ArrayList<EBXField>();
    ebxFields.add(sourceIdField);
    ebxFields.add(sourceNameField);
    EBXTable srcEBXTable = new EBXTable(sourceAdaptationTable, ebxFields);
    tableMappingList.add(
    new TableMapping<EBXField, XMLField>(srcEBXTable, tarXMLTable, fieldMappingList));
  3. Please refer to the com.orchestranetworks.addon.dex.common.generation package for examples of generating EBX® and XML tables for XML export.

  4. Use the following steps when using a transformation function during export, define the transformation function and its field mapping parameters:

                    idFieldMapping.setTransformationDefinition(transformationDefinition);
    idFieldMapping.setActualParameterDefinitions(actualParameterDefinitions);

    Please refer to the com.orchestranetworks.addon.dex.transformation package for examples of creating the transformation function.

  5. Use a list of table mappings to create the application mapping:

                    ApplicationMapping<EBXField, XMLField> applicationMapping = new ApplicationMapping<EBXField, XMLField>(
    sourceApplication,
    targetApplication,
    tableMappingList);

Please refer to the com.orchestranetworks.addon.dex.common.generation package for examples of generating application mapping for XML export.


Creating the application mapping for SQL import

To create an application mapping used for SQL import:

  1. Define the source and target applications:

                    CommonApplication sourceApplication = new CommonApplication(
    sourceLogicalName,
    ApplicationType.DEFAULT_SQL);
    CommonApplication targetApplication = new CommonApplication(
    targetLogicalName,
    ApplicationType.EBX);
  2. Define the SQL table, and EBX® table:

                    List<SQLField> sqlFields = new ArrayList<SQLField>();
    SQLField idSQLField = new SQLField("SUBJECTID", "SUBJECTID", SQLDataType.INTEGER);
    SQLField nameSQLField = new SQLField("SUBJECTNAME", "SUBJECTNAME", SQLDataType.VARCHAR);
    sqlFields.add(idSQLField);
    sqlFields.add(nameSQLField);
    SQLTable sqlTable = new SQLTable("PUBLIC", "SUBJECT", sqlFields);

    AdaptationTable currentTable = sqlImportConfigurationSpec.getCurrentDataset()
    .getTable(Path.parse("/root/Subject"));
    EBXField idEBXField = new EBXField(
    currentTable.getTableOccurrenceRootNode().getNode(Path.parse("/root/Subject/Id")));
    EBXField nameEBXField = new EBXField(
    currentTable.getTableOccurrenceRootNode().getNode(Path.parse("/root/Subject/Name")));
    List<EBXField> ebxFields = new ArrayList<EBXField>();
    ebxFields.add(idEBXField);
    ebxFields.add(nameEBXField);
    EBXTable ebxTable = new EBXTable(currentTable, ebxFields);
  3. Please refer to package com.orchestranetworks.addon.dex.common.generation for examples of generating EBX® table and SQL table for import SQL.

  4. Using the tables you just defined, create a table mapping and then create application mapping:

                    TableMappingList<SQLField, EBXField> tableMappingList = new TableMappingList<SQLField, EBXField>();
    FieldMapping<SQLField, EBXField> idFieldMapping = new FieldMapping<SQLField, EBXField>(
    idSQLField,
    idEBXField);
    FieldMapping<SQLField, EBXField> nameFieldMapping = new FieldMapping<SQLField, EBXField>(
    nameSQLField,
    nameEBXField);
    FieldMappingList<SQLField, EBXField> fieldMappingList = new FieldMappingList<SQLField, EBXField>();
    fieldMappingList.add(idFieldMapping);
    fieldMappingList.add(nameFieldMapping);
    tableMappingList.add(
    new TableMapping<SQLField, EBXField>(sqlTable, ebxTable, fieldMappingList));

    ApplicationMapping<SQLField, EBXField> applicationMapping = new ApplicationMapping<SQLField, EBXField>(
    sourceApplication,
    targetApplication,
    tableMappingList);
  5. When using FieldMapperDefinition, declare FieldMapperDefinition for the table mapping:

                    Map<TableMapping, FieldMapperDefinition> tableMappingDef = new LinkedHashMap<TableMapping, FieldMapperDefinition>();
    tableMappingDef.put(tableMapping, fieldMapperDefinition);
    sqlImportConfigurationSpec.setFieldMapperDefinitions(tableMappingDef);

Please refer to the com.orchestranetworks.addon.dex.common.generation package for examples of an generating application mapping for SQL import.


Creating an application mapping for SQL export

To create an application mapping used to export SQL:

  1. Define the source and target applications:

                    CommonApplication sourceApplication = new CommonApplication(
    sourceLogicalName,
    ApplicationType.EBX);
    CommonApplication targetApplication = new CommonApplication(
    targetLogicalName,
    ApplicationType.DEFAULT_SQL);
  2. Define the SQL table, and EBX® table:

                    List<SQLField> sqlFields = new ArrayList<SQLField>();
    SQLField idSQLField = new SQLField("SUBJECTID", "SUBJECTID", SQLDataType.INTEGER);
    SQLField nameSQLField = new SQLField("SUBJECTNAME", "SUBJECTNAME", SQLDataType.VARCHAR);
    sqlFields.add(idSQLField);
    sqlFields.add(nameSQLField);
    SQLTable sqlTable = new SQLTable("PUBLIC", "SUBJECT", sqlFields);

    AdaptationTable currentTable = sqlExportConfigurationSpec.getCurrentDataset()
    .getTable(Path.parse("/root/Subject"));
    EBXField idEBXField = new EBXField(
    currentTable.getTableOccurrenceRootNode()
    .getNode(Path.parse("/root/Subject/Id")));
    EBXField nameEBXField = new EBXField(
    currentTable.getTableOccurrenceRootNode()
    .getNode(Path.parse("/root/Subject/Name")));
    List<EBXField> ebxFields = new ArrayList<EBXField>();
    ebxFields.add(idEBXField);
    ebxFields.add(nameEBXField);
    EBXTable ebxTable = new EBXTable(currentTable, ebxFields);
  3. Please refer to package com.orchestranetworks.addon.dex.common.generation for examples of generating EBX® and SQL tables for SQL export.

  4. Using the tables you've just defined create a table mapping and then application mapping:

                    TableMappingList<EBXField, SQLField> tableMappingList = new TableMappingList<EBXField, SQLField>();
    FieldMapping<EBXField, SQLField> idFieldMapping = new FieldMapping<EBXField, SQLField>(
    idEBXField,
    idSQLField);
    FieldMapping<EBXField, SQLField> nameFieldMapping = new FieldMapping<EBXField, SQLField>(
    nameEBXField,
    nameSQLField);
    FieldMappingList<EBXField, SQLField> fieldMappingList = new FieldMappingList<EBXField, SQLField>();
    fieldMappingList.add(idFieldMapping);
    fieldMappingList.add(nameFieldMapping);
    tableMappingList.add(
    new TableMapping<EBXField, SQLField>(ebxTable, sqlTable, fieldMappingList));

    ApplicationMapping<EBXField, SQLField> applicationMapping = new ApplicationMapping<EBXField, SQLField>(
    sourceApplication,
    targetApplication,
    tableMappingList);
  5. When using FieldMapperDefinition, declare FieldMapperDefinition for the table mapping:

                    Map<TableMapping, FieldMapperDefinition> tableMappingDef = new LinkedHashMap<TableMapping, FieldMapperDefinition>();
    tableMappingDef.put(tableMapping, fieldMapperDefinition);
    sqlExportConfig.setFieldMapperDefinitions(tableMappingDef);

Please refer to the com.orchestranetworks.addon.dex.common.generation package for examples of generating an application mapping for SQL export.


Creating an application mapping for CSV import

To create an application mapping for CSV import:

  1. Define the CSV Table, and EBX® Table:

    • The following example shows how to define a CSV table:

                      CSVTable csvTable = new CSVTable("Employee");
      List<CSVField> csvFields = new ArrayList<CSVField>();
      CSVField idCSVField = new CSVField(0, "Id", "Id");
      CSVField nameCSVField = new CSVField(1, "Name", "Name");
      CSVField dateOfBirthCSVField = new CSVField(2, "DateOfBirth", "DateOfBirth");
      dateOfBirthCSVField.setDateFormatPattern("dd/MM/yyyy");
      csvFields.add(idCSVField);
      csvFields.add(nameCSVField);
      csvFields.add(dateOfBirthCSVField);
      csvTable.setFields(csvFields);
    • The following example shows how to define an EBX® table:

                      AdaptationTable employeeTable = dataset.getTable(Path.parse("/root/Employee"));
      EBXField idEBXField = new EBXField(
      employeeTable.getTableOccurrenceRootNode()
      .getNode(Path.parse("/root/Employee/Id")));
      EBXField nameEBXField = new EBXField(
      employeeTable.getTableOccurrenceRootNode()
      .getNode(Path.parse("/root/Employee/Name")));
      EBXField dateOfBirthEBXField = new EBXField(
      employeeTable.getTableOccurrenceRootNode()
      .getNode(Path.parse("/root/Employee/DateOfBirth")));
      List<EBXField> employeeFields = new ArrayList<EBXField>();
      employeeFields.add(idEBXField);
      employeeFields.add(nameEBXField);
      employeeFields.add(dateOfBirthEBXField);
      EBXTable ebxTable = new EBXTable(employeeTable, employeeFields);

    Please refer to package com.orchestranetworks.addon.dex.common.generation for examples of generating EBX® tables.

  2. Use CSVTable and EBXTable to create a table mapping list. Then, create the application mapping as shown below:

                    TableMapping<CSVField, EBXField> tableMapping = new TableMapping<CSVField, EBXField>(csvTable, ebxTable);

    FieldMappingList<CSVField, EBXField> fieldMappingList = new FieldMappingList<CSVField, EBXField>();
    FieldMapping<CSVField, EBXField> idFieldMapping = new FieldMapping<CSVField, EBXField>(idCSVField, idEBXField);
    FieldMapping<CSVField, EBXField> nameFieldMapping = new FieldMapping<CSVField, EBXField>(nameCSVField, nameEBXField);
    FieldMapping<CSVField, EBXField> dateOfBirthFieldMapping = new FieldMapping<CSVField, EBXField>(dateOfBirthCSVField, dateOfBirthEBXField);
    fieldMappingList.add(idFieldMapping);
    fieldMappingList.add(nameFieldMapping);
    fieldMappingList.add(dateOfBirthFieldMapping);

    tableMapping.setFieldMappings(fieldMappingList);
    tableMappingList.add(tableMapping);
    CommonApplication sourceApplication = new CommonApplication(sourceLogicalName, ApplicationType.CSV);
    CommonApplication targetApplication = new CommonApplication(targetLogicalName, ApplicationType.EBX);
    ApplicationMapping<CSVField, EBXField> applicationMapping = new ApplicationMapping<CSVField, EBXField>(sourceApplication, targetApplication, tableMappingList);

    When importing with a reference column, define the reference column for field mapping:

                    FieldMapping<CSVField, EBXField> fkClassFieldMapping = new FieldMapping<CSVField, EBXField>(fkClassCSVField, fkClassEBXField);
    SchemaNode fkClassNode = fkClassEBXField.getSchemaNode();
    SchemaNode tableReferenceNode = fkClassNode.getFacetOnTableReference().getTableNode();
    SchemaNode idReferenceTblNode = tableReferenceNode.getNode(Path.parse("/Id"));
    EBXLinkField idLinkField = new EBXLinkField(referenceAdaptationTable,idReferenceTblNode, locale);
    fkClassFieldMapping.setReferenceField(idLinkField);
    fieldMappingList.add(fkClassFieldMapping);
  3. When importing using a transformation function, define the transformation function and its field mapping parameters:

                    idFieldMapping.setTransformationDefinition(transformationDefinition);
    idFieldMapping.setActualParameterDefinitions(actualParameterDefinitions);

    Please refer to the com.orchestranetworks.addon.dex.transformation package for examples of creating the transformation function.

  4. Define the validator on table mapping in the same manner:

                    tableMapping.setValidatorDefinition(validatorDefinition);

    Please refer to the com.orchestranetworks.addon.dex.validator package for examples of creating the validator.


Creating an application mapping CSV export

To create an application mapping used for CSV export:

  1. Define the CSV and EBX® tables as shown above in the CSV import example. Then, create an application mapping as follows:

                    TableMapping<EBXField, CSVField> tableMapping = new TableMapping<EBXField, CSVField>(ebxTable,csvTable);

    FieldMappingList<EBXField, CSVField> fieldMappingList = new FieldMappingList<EBXField, CSVField>();
    FieldMapping<EBXField, CSVField> idFieldMapping = new FieldMapping<EBXField, CSVField>(idEBXField, idCSVField);
    FieldMapping<EBXField, CSVField> nameFieldMapping = new FieldMapping<EBXField, CSVField>(nameEBXField, nameCSVField);
    FieldMapping<EBXField, CSVField> dateOfBirthFieldMapping = new FieldMapping<EBXField, CSVField>(dateOfBirthEBXField, dateOfBirthCSVField);
    fieldMappingList.add(idFieldMapping);
    fieldMappingList.add(nameFieldMapping);
    fieldMappingList.add(dateOfBirthFieldMapping);
                    tableMapping.setFieldMappings(fieldMappingList);
                    tableMappingList.add(tableMapping);
                    CommonApplication sourceApplication = new CommonApplication(sourceLogicalName, ApplicationType.EBX);
                    CommonApplication targetApplication = new CommonApplication(targetLogicalName, ApplicationType.CSV);
                    ApplicationMapping<EBXField, CSVField> applicationMapping = new ApplicationMapping<EBXField, CSVField>(sourceApplication, targetApplication, tableMappingList);
    

    When exporting with a reference column, define the reference column for the field mapping:

                    FieldMapping<EBXField, CSVField> fkClassFieldMapping = new FieldMapping<EBXField, CSVField>(fkClassEBXField, fkClassCSVField);
    SchemaNode fkClassNode = fkClassEBXField.getSchemaNode();
    SchemaNode tableReferenceNode = fkClassNode.getFacetOnTableReference().getTableNode();
    SchemaNode idReferenceTblNode = tableReferenceNode.getNode(Path.parse("/Id"));
    EBXLinkField idLinkField = new EBXLinkField(referenceAdaptationTable,idReferenceTblNode, locale);
    fkClassFieldMapping.setReferenceField(idLinkField);
    fieldMappingList.add(fkClassFieldMapping);
  2. When exporting using a transformation function, define the transformation function for the field mapping:

                    idFieldMapping.setTransformationDefinition(transformationDefinition);

    Please refer to the com.orchestranetworks.addon.dex.transformation package for examples of creating the transformation function.


Creating an application mapping for Excel import

The following sections demonstrate importing with single and multiple tables.

Importing with a single table.

  1. Define a Spreadsheet table:

                    List<SpreadsheetField> libraryFields = new LinkedList<SpreadsheetField>();
    SpreadsheetField libraryIdField = new SpreadsheetField(0, "id", "LibraryID");
    SpreadsheetField libraryNameField = new SpreadsheetField(1, "name", "LibraryName");
    libraryFields.add(libraryIdField);
    libraryFields.add(libraryNameField);
    SpreadsheetTable libraryTable = new SpreadsheetTable(0, "Library", libraryFields);
  2. Define an EBX® table:

                    AdaptationTable sourceAdaptationTable = dataset.getTable(Path.parse("/root/Library"));
    EBXField idEBXField = new EBXField(
    sourceAdaptationTable.getTableOccurrenceRootNode()
    .getNode(Path.parse("/root/Library/Id")));
    EBXField nameEBXField = new EBXField(
    sourceAdaptationTable.getTableOccurrenceRootNode()
    .getNode(Path.parse("/root/Library/Name")));
    List<EBXField> ebxFields = new ArrayList<EBXField>();
    ebxFields.add(idEBXField);
    ebxFields.add(nameEBXField);
    EBXTable ebxTable = new EBXTable(sourceAdaptationTable, ebxFields);
  3. Please refer to package com.orchestranetworks.addon.dex.common.generation for examples of generating EBX® tables.

  4. Create an application mapping:

                    TableMappingList<SpreadsheetField, EBXField> tableMappingList = new TableMappingList<SpreadsheetField, EBXField>();
    TableMapping<SpreadsheetField, EBXField> tableMapping = new TableMapping<SpreadsheetField, EBXField>(libraryTable, ebxTable);

    FieldMappingList<SpreadsheetField, EBXField> fieldMappingList = new FieldMappingList<SpreadsheetField, EBXField>();
    FieldMapping<SpreadsheetField, EBXField> idFieldMapping = new FieldMapping<SpreadsheetField, EBXField>(libraryIdField, idEBXField);
    FieldMapping<SpreadsheetField, EBXField> nameFieldMapping = new FieldMapping<SpreadsheetField, EBXField>(libraryNameField, nameEBXField);
    fieldMappingList.add(idFieldMapping);
    fieldMappingList.add(nameFieldMapping);

    tableMapping.setFieldMappings(fieldMappingList);
    tableMappingList.add(tableMapping);
    CommonApplication sourceApplication = new CommonApplication(sourceLogicalName, ApplicationType.EXCEL);
    CommonApplication targetApplication = new CommonApplication(targetLogicalName, ApplicationType.EBX);
    ApplicationMapping<SpreadsheetField, EBXField> applicationMapping = new ApplicationMapping<SpreadsheetField, EBXField>(sourceApplication, targetApplication, tableMappingList);

Importing Excel with multiple tables.

  1. Define the Spreadsheet tables:

                    List<SpreadsheetField> librarySpreadsheetFieldFields = new LinkedList<SpreadsheetField>();
    SpreadsheetField libraryIdField = new SpreadsheetField(0, "id", "LibraryID");
    SpreadsheetField libraryNameField = new SpreadsheetField(1, "name", "LibraryName");
    librarySpreadsheetFieldFields.add(libraryIdField);
    librarySpreadsheetFieldFields.add(libraryNameField);
    SpreadsheetTable librarySpreadsheetTable = new SpreadsheetTable(0, "Library", librarySpreadsheetFieldFields);

    List<SpreadsheetField> courseSpreadsheetFields = new LinkedList<SpreadsheetField>();
    SpreadsheetField courseIDField = new SpreadsheetField(0, "id", "CourseID");
    SpreadsheetField courseNameField = new SpreadsheetField(1, "name", "CourseName");
    courseSpreadsheetFields.add(courseIDField);
    courseSpreadsheetFields.add(courseNameField);
    SpreadsheetTable courseSpreadsheetTable = new SpreadsheetTable(1, "Course", courseSpreadsheetFields);

    List<SpreadsheetTable> spreadsheetTables = new LinkedList<SpreadsheetTable>();
    spreadsheetTables.add(librarySpreadsheetTable);
    spreadsheetTables.add(courseSpreadsheetTable);
  2. Define the EBX® tables:

                    AdaptationTable libraryAdaptationTable = dataset.getTable(Path.parse("/root/Library"));
    EBXField libraryIdEBXField = new EBXField(
    libraryAdaptationTable.getTableOccurrenceRootNode()
    .getNode(Path.parse("/root/Library/Id")));
    EBXField libraryNameEBXField = new EBXField(
    libraryAdaptationTable.getTableOccurrenceRootNode()
    .getNode(Path.parse("/root/Library/Name")));
    List<EBXField> libraryEBXFields = new ArrayList<EBXField>();
    libraryEBXFields.add(libraryIdEBXField);
    libraryEBXFields.add(libraryNameEBXField);
    EBXTable libraryEBXTable = new EBXTable(libraryAdaptationTable, libraryEBXFields);

    AdaptationTable courseAdaptationTable = dataset.getTable(Path.parse("/root/Course"));
    EBXField courseIdEBXField = new EBXField(
    courseAdaptationTable.getTableOccurrenceRootNode()
    .getNode(Path.parse("/root/Course/Id")));
    EBXField courseNameEBXField = new EBXField(
    courseAdaptationTable.getTableOccurrenceRootNode()
    .getNode(Path.parse("/root/Course/Name")));
    List<EBXField> courseEBXFields = new ArrayList<EBXField>();
    courseEBXFields.add(courseIdEBXField);
    courseEBXFields.add(courseNameEBXField);
    EBXTable courseEBXTable = new EBXTable(courseAdaptationTable, courseEBXFields);

    List<EBXTable> ebxTables = new ArrayList<EBXTable>();
    ebxTables.add(libraryEBXTable);
    ebxTables.add(courseEBXTable);
  3. Please refer to package com.orchestranetworks.addon.dex.common.generation for examples of generating EBX® tables.

  4. Create an application mapping:

                    TableMappingList<SpreadsheetField, EBXField> tableMappingList = new TableMappingList<SpreadsheetField, EBXField>();

    FieldMappingList<SpreadsheetField, EBXField> libraryFieldMappings = new FieldMappingList<SpreadsheetField, EBXField>();
    libraryFieldMappings
    .add(new FieldMapping<SpreadsheetField, EBXField>(libraryIdField, libraryIdEBXField));
    libraryFieldMappings.add(
    new FieldMapping<SpreadsheetField, EBXField>(libraryNameField, libraryNameEBXField));
    TableMapping<SpreadsheetField, EBXField> libraryTableMapping = new TableMapping<SpreadsheetField, EBXField>(
    librarySpreadsheetTable,
    libraryEBXTable,
    libraryFieldMappings);
    tableMappingList.add(libraryTableMapping);

    FieldMappingList<SpreadsheetField, EBXField> courseFieldMappings = new FieldMappingList<SpreadsheetField, EBXField>();
    courseFieldMappings
    .add(new FieldMapping<SpreadsheetField, EBXField>(courseIDField, courseIdEBXField));
    courseFieldMappings
    .add(new FieldMapping<SpreadsheetField, EBXField>(courseNameField, courseNameEBXField));
    TableMapping<SpreadsheetField, EBXField> courseTableMapping = new TableMapping<SpreadsheetField, EBXField>(
    courseSpreadsheetTable,
    courseEBXTable,
    courseFieldMappings);
    tableMappingList.add(courseTableMapping);

    CommonApplication sourceApplication = new CommonApplication(sourceLogicalName, ApplicationType.EXCEL);
    CommonApplication targetApplication = new CommonApplication(targetLogicalName, ApplicationType.EBX);
    ApplicationMapping<SpreadsheetField, EBXField> applicationMapping = new ApplicationMapping<SpreadsheetField, EBXField>(sourceApplication, targetApplication, tableMappingList);

    When importing with a reference column, define the reference column for the field mapping:

                    FieldMapping<SpreadsheetField, EBXField> fkClassFieldMapping = new FieldMapping<SpreadsheetField, EBXField>(fkClassSpreadsheetField, fkClassEBXField);
    SchemaNode fkClassNode = fkClassEBXField.getSchemaNode();
    SchemaNode tableReferenceNode = fkClassNode.getFacetOnTableReference().getTableNode();
    SchemaNode idReferenceTblNode = tableReferenceNode.getNode(Path.parse("/Id"));
    EBXLinkField idLinkField = new EBXLinkField(referenceAdaptationTable,idReferenceTblNode, locale);
    fkClassFieldMapping.setReferenceField(idLinkField);
    courseFieldMappings.add(fkClassFieldMapping);
  5. When importing using a transformation function, define the transformation function and its field mapping parameters:

                    fieldMapping.setTransformationDefinition(transformationDefinition);
    fieldMapping.setActualParameterDefinitions(actualParameterDefinitions);

    Please refer to the com.orchestranetworks.addon.dex.transformation package for examples of creating the transformation function.

  6. The validator can be defined on the table mapping in the same way:

                    libraryTableMapping.setValidatorDefinition(validatorDefinition);

    Please refer to the com.orchestranetworks.addon.dex.validator package for examples of creating the validation.


Creating an application mapping for Excel export

The following sections show how to export Excel with single, and multiple tables.

Exporting Excel with a single table

Define the spreadsheet table and EBX® table as shown in the above example of importing Excel with single table. After that, create an application mapping as follows:

                TableMappingList<EBXField, SpreadsheetField> tableMappingList = new TableMappingList<EBXField, SpreadsheetField>();
TableMapping<EBXField, SpreadsheetField> tableMapping = new TableMapping<EBXField, SpreadsheetField>(libraryEBXTable, librarySpreadsheetTable);

FieldMappingList<EBXField, SpreadsheetField> fieldMappingList = new FieldMappingList<EBXField, SpreadsheetField>();
FieldMapping<EBXField, SpreadsheetField> idFieldMapping = new FieldMapping<EBXField, SpreadsheetField>(libraryIdEBXField, libraryIdField);
FieldMapping<EBXField, SpreadsheetField> nameFieldMapping = new FieldMapping<EBXField, SpreadsheetField>(libraryNameEBXField, libraryNameField);
fieldMappingList.add(idFieldMapping);
fieldMappingList.add(nameFieldMapping);

tableMapping.setFieldMappings(fieldMappingList);
tableMappingList.add(tableMapping);
CommonApplication sourceApplication = new CommonApplication(sourceLogicalName, ApplicationType.EBX);
CommonApplication targetApplication = new CommonApplication(targetLogicalName, ApplicationType.EXCEL);
ApplicationMapping<EBXField, SpreadsheetField> applicationMapping = new ApplicationMapping<EBXField, SpreadsheetField>(sourceApplication, targetApplication, tableMappingList);

Exporting Excel with multiple tables

  1. Define the spreadsheet tables and EBX® tables as shown in the above example of importing Excel with multiple tables. Then, create the application mapping as follows:
                    TableMappingList<EBXField, SpreadsheetField> tableMappingList = new TableMappingList<EBXField, SpreadsheetField>();
                    FieldMappingList<EBXField, SpreadsheetField> libraryFieldMappings = new FieldMappingList<EBXField, SpreadsheetField>();
                    libraryFieldMappings
                            .add(new FieldMapping<EBXField, SpreadsheetField>(libraryIdEBXField, libraryIdField));
                    libraryFieldMappings.add(
                            new FieldMapping<EBXField, SpreadsheetField>(libraryNameEBXField, libraryNameField));
                    TableMapping<EBXField, SpreadsheetField> libraryTableMapping = new TableMapping<EBXField, SpreadsheetField>(
                            libraryEBXTable,
                            librarySpreadsheetTable,
                            libraryFieldMappings);
                    tableMappingList.add(libraryTableMapping);
    
                    FieldMappingList<EBXField, SpreadsheetField> courseFieldMappings = new FieldMappingList<EBXField, SpreadsheetField>();
                    courseFieldMappings
                            .add(new FieldMapping<EBXField, SpreadsheetField>(courseIdEBXField, courseIDField));
                    courseFieldMappings
                            .add(new FieldMapping<EBXField, SpreadsheetField>(courseNameEBXField, courseNameField));
                    TableMapping<EBXField, SpreadsheetField> courseTableMapping = new TableMapping<EBXField, SpreadsheetField>(
                            courseEBXTable,
                            courseSpreadsheetTable,
                            courseFieldMappings);
                    tableMappingList.add(courseTableMapping);
    
                    CommonApplication sourceApplication = new CommonApplication(sourceLogicalName, ApplicationType.EBX);
                    CommonApplication targetApplication = new CommonApplication(targetLogicalName, ApplicationType.EXCEL);
                    ApplicationMapping<EBXField, SpreadsheetField> applicationMapping = new ApplicationMapping<EBXField, SpreadsheetField>(sourceApplication, targetApplication, tableMappingList);
    

    When exporting with a reference column, define the reference column for field mapping:

                    FieldMapping<EBXField, SpreadsheetField> fkClassFieldMapping = new FieldMapping<EBXField, SpreadsheetField>(fkClassEBXField, fkClassSpreadsheetField);
                    SchemaNode fkClassNode = fkClassEBXField.getSchemaNode();
                    SchemaNode tableReferenceNode = fkClassNode.getFacetOnTableReference().getTableNode();
                    SchemaNode idReferenceTblNode = tableReferenceNode.getNode(Path.parse("/Id"));
                    EBXLinkField idLinkField = new EBXLinkField(referenceAdaptationTable,idReferenceTblNode, locale);
                    fkClassFieldMapping.setReferenceField(idLinkField);
                    fieldMappingList.add(fkClassFieldMapping);
    
  2. When exporting using a transformation function, define the transformation function and its field mapping parameters:

                    fieldMapping.setTransformationDefinition(transformationDefinition);
                    fieldMapping.setActualParameterDefinitions(actualParameterDefinitions);
    

    Please refer to package com.orchestranetworks.addon.dex.transformation for examples of creating the transformation function.

Example of creating a field mapper for SQL import and export

You must define a field mapper before adding it to your FieldMapperCatalog.

For example:

public class TestFieldMapperDefinition implements FieldMapperDefinition
{
public UserMessage getLabel()
{
return UserMessage.createInfo("Test field mapper");
}

public UserMessage getDescription()
{
return UserMessage.createInfo("Test field mapper");
}

public FieldMapper getFieldMapper()
{
return new TestFieldMapper();
}
}

Next, create the implementation definition.

public final class TestFieldMapper implements FieldMapper
{
public FieldMappingList execute(FieldMapperContext context) throws DataExchangeException
{
if (context == null)
{
throw new DataExchangeException(UserMessage.createError("Context is not initialized."));
}

SQLTable sourceTable = (SQLTable) context.getSourceTable();
EBXTable targetTable = (EBXTable) context.getTargetTable();
FieldMappingList<SQLField, EBXField> fieldMappings = new FieldMappingList<SQLField, EBXField>();

SQLField column1 = sourceTable.getFields().get(0);
SQLField column2 = sourceTable.getFields().get(1);
EBXField field1 = targetTable.getFields().get(0);
EBXField field2 = targetTable.getFields().get(1);

// Map the 'column1' column in SQL with the 'field1' schema node in EBX®.
FieldMapping<SQLField, EBXField> fieldMapping1 = new FieldMapping<SQLField, EBXField>(
column1,
field1);
fieldMappings.add(fieldMapping1);

// Map the 'column2' column in SQL with the 'field2' schema node in EBX®.
FieldMapping<SQLField, EBXField> fieldMapping2 = new FieldMapping<SQLField, EBXField>(
column2,
field2);
fieldMappings.add(fieldMapping2);

return fieldMappings;
}
}

Finally, register the field mapper definition in the add-on to make it available in the configuration:

FieldMapperCatalog.add(new TestFieldMapperDefinition());

Get list of CSV Tables for CSV Import/Export service

                TableHelperSpec tableHelperSpec = new TableHelperSpec();
                tableHelperSpec.setCSVTableHelper(new CSVTableHelperImpl());
                CSVTableHelper tableHelper = TableHelperFactory.getCSVTableHelper();
                String csvApplicationLogicalName = "CSV_TestComplexPKAndFK-1509001203732";
                List<CSVTable> csvTables = tableHelper.getTables(csvApplicationLogicalName, currentDataset, session);

Get list of Excel Tables for Excel Import/Export service

                TableHelperSpec tableHelperSpec = new TableHelperSpec();
                tableHelperSpec.setSpreadsheetTableHelper(new SpreadsheetTableHelperImpl());
                SpreadsheetTableHelper tableHelper = TableHelperFactory.getSpreadsheetTableHelper();
                String excelApplicationLogicalName = "Excel_StudentTable_IgnoredColumns-1527024243726";
                List<SpreadsheetTable> excelTables = tableHelper.getTables(excelApplicationLogicalName, currentDataset, this.session);