Package com.orchestranetworks.addon.dataexchange


package com.orchestranetworks.addon.dataexchange

Classes and interfaces to call {addon.label} import, export and transfer data.


Example of a {addon.label} XML export

        DataExchangeExportDataAccessSpec dataAccessSpec = new DataExchangeExportDataAccessSpec(dataset,currentTable,session);

        DataExchangeExportSpec exportSpec = new DataExchangeExportSpec();
        exportSpec.setDataAccessSpec(dataAccessSpec);
        exportSpec.setTablePaths(tablePaths);
        exportSpec.setExportType(DataExchangeExportType.EXPORT_DEFAULT_XML);
        exportSpec.setTargetApplicationLogicalName(targetApplicationLogicalName);
        exportSpec.setTargetVersion(version);

        DataExchangeExportResult exportResult = DataExchangeFactory.getDataExchangeExport().execute(exportSpec);

Example of a {addon.label} XML import

        DataExchangeDataAccessSpec dataAccessSpec = new DataExchangeDataAccessSpec(datasetOrRecord,session);
        File importedFile = new File(importedFilePath);
        
        DataExchangeImportSpec importSpec = new DataExchangeImportSpec();
        importSpec.setDataAccessSpec(dataAccessSpec);
        importSpec.setTablePaths(tablePaths);
        importSpec.setImportedFile(importedFile);
        importSpec.setImportType(DataExchangeImportType.IMPORT_XML);
        importSpec.setImportMode(DataExchangeImportMode.UPDATE_AND_INSERT);

        DataExchangeImportResult importResult = DataExchangeFactory.getDataExchangeImport().execute(importSpec);

Example of a {addon.label} data transfer

        DataExchangeDataAccessSpec dataAccessSpec = new DataExchangeDataAccessSpec(dataset,currentTable,session);

        DataExchangeTransferSpec transferSpec = new DataExchangeTransferSpec();
        transferSpec.setDataAccessSpec(dataAccessSpec);
        transferSpec.setTablePaths(tablePaths);
        transferSpec.setTransferType(DataExchangeTransferType.TRANSFER_DATA);
        transferSpec.setImportMode(DataExchangeImportMode.UPDATE_AND_INSERT);
        transferSpec.setTargetDataspace(targetDataspaceKey);
        transferSpec.setTargetDataset(targetDatasetName);
        transferSpec.setTransferOption(DataExchangeTransferOption.IN_SAME_DATA_MODEL);
        
        DataExchangeImportResult transferResult = DataExchangeFactory.getDataExchangeTransferData().execute(transferSpec);

The following example shows how to create table mappings in order to transfer data from many tables to many tables

        List<TableMapping> tableMappings = new ArrayList<TableMapping>();
        
        // case 1: Transfer data from EmployeeSourceTable table to EmployeeTargetTable table, ClassTargetTable table
        TableMapping firstMapping = new TableMapping();
        firstMapping.setSourceTablePath(employeeSourceTablePath);
        firstMapping.setTargetTablePath(employeeTargetTablePath);
        tableMappings.add(firstMapping);
        
        TableMapping secondMapping = new TableMapping();
        secondMapping.setSourceTablePath(employeeSourceTablePath);
        secondMapping.setTargetTablePath(classTargetTablePath);
        tableMappings.add(secondMapping);
        
        // case 2: Transfer data from DepartmentSourceTable table, EmployeeSourceTable table to DepartmentTargetTable table
        TableMapping thirdMapping = new TableMapping();
        thirdMapping.setSourceTablePath(departmentSourceTablePath);
        thirdMapping.setTargetTablePath(departmentTargetTablePath);
        tableMappings.add(thirdMapping);
        
        TableMapping fourthMapping = new TableMapping();
        fourthMapping.setSourceTablePath(employeeSourceTablePath);
        fourthMapping.setTargetTablePath(departmentTargetTablePath);
        tableMappings.add(fourthMapping);
        
        transferSpec.setTableMappings(tableMappings);

Example of a {addon.label} default SQL import

        DataExchangeDataAccessSpec dataAccessSpec = new DataExchangeDataAccessSpec(dataset,currentTable,session);

        Set<SQLMappingTable> sqlMappingTables = new HashSet<SQLMappingTable>();
        
        SQLMappingTable mappingTable = new SQLMappingTable();
        mappingTable.setTablePath(tablePath);
        mappingTable.setSQLMappingColumnDefinition(sqlMappingColumnDefinition);
        
        SQLTableOrViewSpec sqlTableOrViewSpec = new SQLTableOrViewSpec();
        sqlTableOrViewSpec.setSchemaName(schemaName);
        sqlTableOrViewSpec.setSQLTableOrView(sqlTableOrViewName);
        sqlTableOrViewSpec.setSQLPredicate(sqlPredicate);
        mappingTable.setSQLTableOrViewSpec(sqlTableOrViewSpec);
        
        sqlMappingTables.add(mappingTable);

        DataExchangeImportSQLSpec importSpec = new DataExchangeImportSQLSpec();
        importSpec.setDataAccessSpec(dataAccessSpec);
        importSpec.setImportType(DataExchangeImportType.IMPORT_DEFAULT_SQL);
        importSpec.setImportMode(DataExchangeImportMode.UPDATE_AND_INSERT);
        importSpec.setSQLMappingTables(sqlMappingTables);
        
        DataExchangeImportResult importResult = DataExchangeFactory.getDataExchangeImport().execute(importSpec);

Example of a {addon.label} default SQL export

        DataExchangeExportDataAccessSpec dataAccessSpec = new DataExchangeExportDataAccessSpec(dataset,currentTable,session);

        Set<SQLMappingTable> sqlMappingTables = new HashSet<SQLMappingTable>();
        
        SQLMappingTable mappingTable = new SQLMappingTable();
        mappingTable.setTablePath(tablePath);
        mappingTable.setSQLMappingColumnDefinition(sqlMappingColumnDefinition);
        
        SQLTableOrViewSpec sqlTableOrViewSpec = new SQLTableOrViewSpec();
        sqlTableOrViewSpec.setSchemaName(schemaName);
        sqlTableOrViewSpec.setSQLTableOrView(sqlTableOrViewName);
        mappingTable.setSQLTableOrViewSpec(sqlTableOrViewSpec);
        
        sqlMappingTables.add(mappingTable);

        List<Path> tablePaths = new ArrayList<Path>();
        tablePaths.add(tablePath);
        
        DataExchangeExportSQLSpec exportSpec = new DataExchangeExportSQLSpec();
        exportSpec.setDataAccessSpec(dataAccessSpec);
        exportSpec.setExportType(DataExchangeExportType.EXPORT_DEFAULT_SQL);
        exportSpec.setSQLImportMode(DataExchangeImportMode.UPDATE_AND_INSERT);
        exportSpec.setSQLMappingTables(sqlMappingTables);
        exportSpec.setTablePaths(tablePaths);
        exportSpec.setPredicates(predicate);
        
        DataExchangeExportResult exportResult = DataExchangeFactory.getDataExchangeExport().execute(exportSpec);

Please refer to package com.orchestranetworks.addon.dataexchange.sql for examples of the SQL column mapping.