Package com.orchestranetworks.addon.dex.configuration
Classes and interfaces to define specifications for the import, export and transfer data services.
Overview
The examples shown herein show how to specify configurations for data import, export and transfer. In most instances you'll need to define and generate source tables. For more information on this topic and to see examples, you can refer to the com.orchestranetworks.addon.dex.common.generation
package.
Creating a data transfer configuration
The following steps outline the process of creating a data transfer configuration:
-
Define the list of EBX® source tables:
AdaptationTable libraryAdaptationTable = sourceDataset.getTable(Path.parse("/root/Libraries")); EBXField libraryIdField = new EBXField( libraryAdaptationTable.getTableOccurrenceRootNode() .getNode(Path.parse("/root/Libraries/Id"))); EBXField libraryNameField = new EBXField( libraryAdaptationTable.getTableOccurrenceRootNode() .getNode(Path.parse("/root/Libraries/Name"))); List<EBXField> libraryFields = new ArrayList<EBXField>(); libraryFields.add(libraryIdField); libraryFields.add(libraryNameField); EBXTable libraryTable = new EBXTable(libraryAdaptationTable, libraryFields); AdaptationTable courseAdaptationTable = sourceDataset.getTable(Path.parse("/root/Courses")); EBXField courseIdField = new EBXField( courseAdaptationTable.getTableOccurrenceRootNode() .getNode(Path.parse("/root/Courses/Id"))); EBXField courseNameField = new EBXField( courseAdaptationTable.getTableOccurrenceRootNode() .getNode(Path.parse("/root/Courses/Name"))); List<EBXField> courseFields = new ArrayList<EBXField>(); courseFields.add(courseIdField); courseFields.add(courseNameField); EBXTable courseTable = new EBXTable(courseAdaptationTable, courseFields); List<EBXTable> sourceEBXTables = new ArrayList<EBXTable>(); sourceEBXTables.add(libraryTable); sourceEBXTables.add(courseTable);
-
Use the list of source tables to create the transfer data configuration specification:
TransferConfigurationSpec transferConfig = new TransferConfigurationSpec( sourceDataset, sourceEBXTables, targetDataset, session);
-
When transferring data with table filters, define a TableFilter for each source table as shown below:
Map<EBXTable, TableFilter> sourceTableFilters = new HashMap<EBXTable, TableFilter>(); EBXTable sourceTable = new EBXTable(sourceDataset.getTable(Path.parse("/root/Libraries"))); TableFilter tableFilter = new TableFilter(); tableFilter.setPredicate("contains(./LibraryID,'ID001')"); sourceTableFilters.put(sourceTable, tableFilter); TransferConfigurationSpec transferConfigWithTableFilter = new TransferConfigurationSpec( sourceDataset, sourceEBXTables, sourceTableFilters, targetDataset, session);
Creating an XML import configuration
The following steps demonstrate how to create an XML import configuration:
-
Define the source XML table as follows:
List<XMLField> sourceFields = new ArrayList<XMLField>(); XMLField sourceFieldName = new XMLField("/root/Libraries/Name"); XMLField sourceFieldStatus = new XMLField("/root/Libraries/Status"); sourceFields.add(sourceFieldName); sourceFields.add(sourceFieldStatus); XMLTable srcXMLTable = new XMLTable("/root/Libraries", sourceFields);
-
Use the source table to create the configuration specification:
XMLImportConfigurationSpec importSpec = new XMLImportConfigurationSpec( currentTable, srcXMLTable, session); File importedFile = new File(importedFilePath); importSpec.setImportedFile(importedFile);
Creating an XML export configuration
The following shows how to create an XML export configuration:
XMLExportConfigurationSpec exportSpec = new XMLExportConfigurationSpec( currentTable, session);
When exporting XML with table filters, use the steps below:
-
Define the EBX® source table:
AdaptationTable libraryAdaptationTable = sourceDataset.getTable(Path.parse("/root/Libraries")); EBXField libraryIdField = new EBXField( libraryAdaptationTable.getTableOccurrenceRootNode() .getNode(Path.parse("/root/Libraries/Id"))); EBXField libraryNameField = new EBXField( libraryAdaptationTable.getTableOccurrenceRootNode() .getNode(Path.parse("/root/Libraries/Name"))); List<EBXField> libraryFields = new ArrayList<EBXField>(); libraryFields.add(libraryIdField); libraryFields.add(libraryNameField); EBXTable ebxTable = new EBXTable(libraryAdaptationTable, libraryFields);
-
Create the TableFilter and apply it along with the EBX® source table:
TableFilter tableFilter = new TableFilter(); tableFilter.setPredicate("contains(./LibraryID,'ID001')"); XMLExportConfigurationSpec exportConfig = new XMLExportConfigurationSpec( ebxTable, tableFilter, session);
Creating an SQL import configuration
Create the configuration with the data source declared in the application server as follows:
SQLImportConfigurationSpec sqlConfigSpec = new SQLImportConfigurationSpec( currentTable, sqlDataSourceName, sqlTableOrView, session);
Without having to declare the data source in the application server, you can also create the configuration by defining a JNDI data source as shown below:
JNDIDataSource jndiDataSource = new JNDIDataSource(); jndiDataSource.setName(sqlDataSourceName); jndiDataSource.setURL(url); jndiDataSource.setUser(username); jndiDataSource.setPassword(password); SQLImportConfigurationSpec sqlConfigSpec = new SQLImportConfigurationSpec(currentTable,jndiDataSource,sqlTableOrView,session);
When importing SQL with table filters, define a TableFilter
for the source table as shown below:
TableFilter tableFilter = new TableFilter(); tableFilter.setPredicate("SQLLibraryID ='ID001'"); SQLImportConfigurationSpec sqlConfigSpec = new SQLImportConfigurationSpec( currentTable, sqlDataSourceName, sqlTableOrView, tableFilter, session);
Creating a configuration for SQL export
Create the configuration with the data source declared in the application server as follows:
SQLExportConfigurationSpec sqlConfigSpec = new SQLExportConfigurationSpec( currentTable, sqlDataSourceName, session);
Without having to declare the data source in the application server, you can also create the configuration by defining a JNDI data source as shown below:
JNDIDataSource jndiDataSource = new JNDIDataSource(); jndiDataSource.setName(sqlDataSourceName); jndiDataSource.setURL(url); jndiDataSource.setUser(username); jndiDataSource.setPassword(password); SQLExportConfigurationSpec sqlConfigSpec = new SQLExportConfigurationSpec( currentTable, jndiDataSource, session);
When exporting SQL with table filters, define a TableFilter
for the source table as shown below:
TableFilter tableFilter = new TableFilter(); tableFilter.setPredicate("contains(./LibraryID,'ID001')"); SQLExportConfigurationSpec sqlConfigSpec = new SQLExportConfigurationSpec( currentTable, tableFilter, sqlDataSourceName, session);
Creating a configuration for CSV import
AdaptationTable sourceTable = sourceDataset.getTable(Path.parse("/root/Libraries")); List<CSVField> csvFields = new ArrayList<CSVField>(); CSVField idField = new CSVField(0, "Id", "Id"); CSVField nameField = new CSVField(1, "Name", "Name"); csvFields.add(idField); csvFields.add(nameField); CSVTable csvTable = new CSVTable("Libraries", csvFields); CSVImportConfigurationSpec importCSVSpec = new CSVImportConfigurationSpec( sourceTable, csvTable, session); File importedFile = new File(importedFilePath); importCSVSpec.setImportedFile(importedFile); importCSVSpec.setSeparator(Separator.SEMICOLON.getSeparatorCharacter()); importCSVSpec.setFileEncoding("UTF-8");
Creating a configuration for CSV export
AdaptationTable currentTable = dataset.getTable(Path.parse("/root/Library")); TableFilter tableFilter = new TableFilter(); tableFilter.setPredicate("contains(./LibraryID,'ID001')"); CSVExportConfigurationSpec exportCSVSpec = new CSVExportConfigurationSpec( currentTable, tableFilter, session);
Creating a configuration for Excel import
The following example shows how to define a configuration using a single 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 spreadsheetTable = new SpreadsheetTable(0, "Library", libraryFields); SpreadsheetImportConfigurationSpec importSpreadsheetConfig = new SpreadsheetImportConfigurationSpec( currentTable, spreadsheetTable, session);
When using multiple tables:
List<SpreadsheetTable> spreadsheetTables = new LinkedList<SpreadsheetTable>(); 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); spreadsheetTables.add(libraryTable); List<SpreadsheetField> courseFields = new LinkedList<SpreadsheetField>(); SpreadsheetField courseIDField = new SpreadsheetField(0, "id", "CourseID"); SpreadsheetField courseCreditsField = new SpreadsheetField(1, "credits", "CourseCredits"); courseFields.add(courseIDField); courseFields.add(courseCreditsField); SpreadsheetTable courseTable = new SpreadsheetTable(1, "Course", courseFields); spreadsheetTables.add(courseTable); SpreadsheetImportConfigurationSpec importSpreadsheetConfig = new SpreadsheetImportConfigurationSpec( dataset, spreadsheetTables, session);
Creating a configuration for Excel export
To create an Excel export configuration:
-
Define the EBX® source tables:
AdaptationTable libraryAdaptationTable = dataset.getTable(Path.parse("/root/Libraries")); EBXField libraryIdField = new EBXField( libraryAdaptationTable.getTableOccurrenceRootNode() .getNode(Path.parse("/root/Libraries/Id"))); EBXField libraryNameField = new EBXField( libraryAdaptationTable.getTableOccurrenceRootNode() .getNode(Path.parse("/root/Libraries/Name"))); List<EBXField> libraryFields = new ArrayList<EBXField>(); libraryFields.add(libraryIdField); libraryFields.add(libraryNameField); EBXTable libraryTable = new EBXTable(libraryAdaptationTable, libraryFields); AdaptationTable courseAdaptationTable = dataset.getTable(Path.parse("/root/Courses")); EBXField courseIdField = new EBXField( courseAdaptationTable.getTableOccurrenceRootNode() .getNode(Path.parse("/root/Courses/Id"))); EBXField courseNameField = new EBXField( courseAdaptationTable.getTableOccurrenceRootNode() .getNode(Path.parse("/root/Courses/Name"))); List<EBXField> courseFields = new ArrayList<EBXField>(); courseFields.add(courseIdField); courseFields.add(courseNameField); EBXTable courseTable = new EBXTable(courseAdaptationTable, courseFields); List<EBXTable> sourceTables = new ArrayList<EBXTable>(); sourceTables.add(libraryTable); sourceTables.add(courseTable);
-
When exporting a single table:
EBXTable sourceTable = sourceTables.get(0); TableFilter tableFilter = new TableFilter(); tableFilter.setPredicate("contains(./LibraryID,'ID001')"); SpreadsheetExportConfigurationSpec exportSpreadsheetConfigurationSpec = new SpreadsheetExportConfigurationSpec( sourceTable, tableFilter, session); exportSpreadsheetConfigurationSpec.setHeaderExported(true); exportSpreadsheetConfigurationSpec.setFileFormat(SpreadsheetFileFormat.EXCEL2003);
-
When exporting multiple tables:
Map<EBXTable, TableFilter> sourceTableFilters = new HashMap<EBXTable, TableFilter>(); TableFilter tableFilter = new TableFilter(); tableFilter.setPredicate("contains(./LibraryID,'ID001')"); sourceTableFilters.put(libraryTable, tableFilter); SpreadsheetExportConfigurationSpec exportSpreadsheetConfigurationSpec = new SpreadsheetExportConfigurationSpec( dataset, sourceTables, sourceTableFilters, session); exportSpreadsheetConfigurationSpec.setHeaderExported(true); exportSpreadsheetConfigurationSpec.setFileFormat(SpreadsheetFileFormat.EXCEL2007); exportSpreadsheetConfigurationSpec.setReferenceSheetIncluded(false);
-
ClassDescriptionConfigurationSpec<T extends Table>Specifies the configuration used for data import, export and transfer.Specifies the configuration used when exporting data to a CSV file.Specifies the configuration used when importing data from a CSV file.Defines the formatting of an Excel file's data cell.Specifies a data cell's position in an Excel file.Defines a data cell's template in an Excel file.Represents the character used to denote a decimal.ExportConfigurationSpec<T extends Table>Defines the configuration used for data export.Defines the configuration used to export the {addon.label} configuration to an XML file.Defines the configuration used for exporting data to a file.FileImportConfigurationSpec<T extends Table>Specifies the configuration used when importing data from a file.Defines the possible font styles.ImportConfigurationSpec<T extends Table>Specifies the configuration used for data import.Defines the configuration used to import the {addon.label} configuration from an XML file.Specifies the configuration used for importing data to a file.Specifies the scope when importing add-on configuration data from an XML file.Defines the JNDI configuration for executing Import and Export of SQL without requiring global configuration in the application server.Represents the characters used to signify the end of a CSV line.Defines the possible separator characters.Defines the possible service types.Specifies the configuration used to export data to an Excel file.Specifies a spreadsheet template configuration for exporting data to an Excel file.Defines the possible Excel file formats.Defines the configuration used when importing data from an Excel file.Provides a cell data template for an Excel file.Defines the configuration used to export data to an external database.Defines the configuration used for importing data from an external database.Specifies the configuration used for the subtitle template in an exported file.Specifies a configuration used to filter tables.Specifies the configuration used for the title template in the exported file, such as title's starting position and text style.Specifies the configuration used for data transfer.Specifies the configuration used when exporting data to an XML file.Specifies the configuration used to import data from an XML file.