Package com.orchestranetworks.addon.dint.template


package com.orchestranetworks.addon.dint.template
Provides classes and interfaces that represent a specification for a user defined template.

Examples to create a specification for a user defined template:

  1. Example code for CSV export:

    Create an instance of CSVExportTemplateSpec:

                    CSVExportTemplateSpec templateSpec = new CSVExportTemplateSpec(
                            "7c67ed6a-3106-47b0-9bf8-0440e6238657", // this's template UUID, you can get from admin page.
                            outputFile,
                            session);
                    
  2. Example code for CSV import:

    Create an instance of CSVImportTemplateSpec:

                    CSVImportTemplateSpec templateSpec = new CSVImportTemplateSpec(
                            "7c67ed6a-3106-47b0-9bf8-0440e6238657", // this's template UUID, you can get from admin page.
                            inputFile,
                            session);
                    
  3. Example code for Excel export:

    Create an instance of ExcelExportTemplateSpec:

                    ExcelExportTemplateSpec templateSpec = new ExcelExportTemplateSpec(
                            "7c67ed6a-3106-47b0-9bf8-0440e6238657", // this's template UUID, you can get from admin page.
                            outputFile,
                            session);
                    
  4. Example code for Excel import:

    Create an instance of ExcelImportTemplateSpec:

                    ExcelImportTemplateSpec templateSpec = new ExcelImportTemplateSpec(
                            "7c67ed6a-3106-47b0-9bf8-0440e6238657", // this's template UUID, you can get from admin page.
                            inputFile,
                            session);
                    
  5. Example code for SQL export:

    Create an instance of SQLExportTemplateSpec:

                    SQLExportTemplateSpec templateSpec = new SQLExportTemplateSpec(
                            "7c67ed6a-3106-47b0-9bf8-0440e6238657", // this's template UUID, you can get from admin page.
                            session);
                    
  6. Example code for SQL import:

    Create an instance of SQLImportTemplateSpec:

                    SQLImportTemplateSpec templateSpec = new SQLImportTemplateSpec(
                            "7c67ed6a-3106-47b0-9bf8-0440e6238657", // this's template UUID, you can get from admin page.
                            session);
                    
  7. Example code for data transfer within EBX:

    Create an instance of EBXTransferTemplateSpec:

                    EBXTransferTemplateSpec templateSpec = new EBXTransferTemplateSpec(
                            "7c67ed6a-3106-47b0-9bf8-0440e6238657", // this's template UUID, you can get from admin page.
                            session);
                    

Example code to customize a user defined template:

  1. In case of data import or data export, it's possible to overwrite the source or the target EBX dataset configured in the template with another, which has the same data model:

                    templateSpec.setDataset(aDatasetWithSameDataModel); 
                    
  2. In case of data transfer, it's possible to overwrite the source dataset or the target datasets configured in the template:

                    templateSpec.setSourceDataset(aDataset); 
                    
                    templateSpec.addTargetDatasets(datasets); 
                    

Example code to define the configuration for a user defined template:

  1. Example code for identifying a template using its unique name:

    Create an instance of CSVImportTemplateSpec:

                    CSVImportTemplateSpec templateSpec = new CSVImportTemplateSpec(
                            TemplateConfig.forTable("aUniqueTemplateName", anAdaptationTable) // a template name is unique for each data model
                            inputFile,
                            session);
                    
  2. Example code for configuring files for invalid records when executing with a template:

    Create an instance of CSVImportTemplateSpec:

                    CSVImportTemplateSpec templateSpec = new CSVImportTemplateSpec(
                            TemplateConfig.forTable("aUniqueTemplateName", anAdaptationTable) // a template name is unique for each data model
                            inputFile,
                            session);
                    templateSpec.setInvalidDataFolder(aFolder, "fileNamePrefix_", "_fileNameSuffix.csv");
                    
  3. Example code for configuring EBX's procedure when executing with a template:

    Create an instance of CSVImportTemplateSpec:

                    CSVImportTemplateSpec templateSpec = new CSVImportTemplateSpec(
                            TemplateConfig.forTable("aUniqueTemplateName", anAdaptationTable) // a template name is unique for each data model
                            inputFile,
                            session);
                    templateSpec.configureProcedure(context -> context.setTriggerActivation(false));
                    
  4. Example code for overwriting existing mappings in a template:

    Create an instance of CSVImportTemplateSpec:

                    CSVImportTemplateSpec templateSpec = new CSVImportTemplateSpec(
                            TemplateConfig.forTable("aUniqueTemplateName", anAdaptationTable) // a template name is unique for each data model
                            inputFile,
                            session);
                    TemplateConfig<CSVSourceTable, EBXTargetTable> templateConfig = templateSpec.getTemplateConfig();
                    
                    // modify the first table mapping
                    templateConfig.modifyTableMapping(TableMappingSelector.atIndex(0), context -> {
                            
                            MappingStepSelector<TransformationMappingStep> crossRefStepSelector = MappingStepSelectorBuilder
                                    .fromField(step -> {
                                            CSVTable table = context.getSourceTable().getTable();
                                            return table.get("Id").getPath().equals(step.getField().getPath());
                                    })
                                    .nextTransformation(step -> {
                                            return CrossReference.getInstance()
                                                    .getCodeForTemplate()
                                                    .equals(step.getTransformationDefinition().getCode());
                                    })
                                    .select()
                                    .throwErrorIfNotFound("Could not find the cross reference transformation step mapped from the Id source field.");
                            
                            context.modifyStep(crossRefStepSelector, step -> {
                                    step.param(CrossReference.DATASPACE, "anotherDataspace");
                                    step.param(CrossReference.DATASET, "anotherDataset");
                            });
                    });
                    

Execute the user defined template specification and get results:

DataIntegrationExecutionResults results = DataIntegrationExecutor.getInstance().execute(templateSpec);