Search in sources :

Example 26 with ExternalMapperTable

use of org.talend.designer.mapper.external.data.ExternalMapperTable in project tdi-studio-se by Talend.

the class MapperComponentDocumentation method generateMapperTablesInfo.

/**
     * This method used for generating all mapper tables information into xml file.
     * 
     * @param externalNodeElement
     * @param tables
     * @param mapperTableType
     */
private void generateMapperTablesInfo(Element externalNodeElement, List<ExternalMapperTable> tables, String mapperTableType) {
    //$NON-NLS-1$
    Element mapperTableElement = externalNodeElement.addElement("mapperTable");
    //$NON-NLS-1$
    mapperTableElement.addAttribute("type", HTMLDocUtils.checkString(mapperTableType));
    Element tableElement = null;
    for (ExternalMapperTable table : tables) {
        //$NON-NLS-1$
        tableElement = mapperTableElement.addElement("table");
        generateTableSummaryInfo(mapperTableElement, tableElement, table);
        List<ExternalMapperTableEntry> globalMapKeysValuesEntries = table.getGlobalMapKeysValues();
        if (HTMLDocUtils.checkList(globalMapKeysValuesEntries)) {
            //$NON-NLS-1$
            Element globalMapKeysValuesElement = tableElement.addElement("globalMapKeysValues");
            for (ExternalMapperTableEntry entry : globalMapKeysValuesEntries) {
                generateTablesEntriesInfo(globalMapKeysValuesElement, entry);
            }
        }
        List<ExternalMapperTableEntry> metadataTableEntries = table.getMetadataTableEntries();
        if (HTMLDocUtils.checkList(metadataTableEntries)) {
            //$NON-NLS-1$
            Element metadataTableEntriesElement = tableElement.addElement("metadataTableEntries");
            for (ExternalMapperTableEntry entry : metadataTableEntries) {
                generateTablesEntriesInfo(metadataTableEntriesElement, entry);
            }
        }
        List<ExternalMapperTableEntry> constraintTableEntries = table.getConstraintTableEntries();
        if (HTMLDocUtils.checkList(constraintTableEntries)) {
            //$NON-NLS-1$
            Element constraintTableEntriesElement = tableElement.addElement("constraintTableEntries");
            for (ExternalMapperTableEntry entry : constraintTableEntries) {
                generateTablesEntriesInfo(constraintTableEntriesElement, entry);
            }
        }
    }
}
Also used : ExternalMapperTableEntry(org.talend.designer.mapper.external.data.ExternalMapperTableEntry) Element(org.dom4j.Element) ExternalMapperTable(org.talend.designer.mapper.external.data.ExternalMapperTable)

Example 27 with ExternalMapperTable

use of org.talend.designer.mapper.external.data.ExternalMapperTable in project tdi-studio-se by Talend.

the class MapperComponentDocumentation method generateXMLInfo.

/**
     * Generates all information which for XML file.
     */
private void generateXMLInfo(INode externalNode) {
    document = DocumentHelper.createDocument();
    //$NON-NLS-1$
    Element externalNodeElement = document.addElement("externalNode");
    generateMessages(externalNodeElement);
    //$NON-NLS-1$
    externalNodeElement.addAttribute("name", HTMLDocUtils.checkString(this.componentName));
    //$NON-NLS-1$
    externalNodeElement.addAttribute("preview", HTMLDocUtils.checkString(this.previewPicPath));
    //$NON-NLS-1$
    Element parametersElement = externalNodeElement.addElement("parameters");
    List elementParameterList = externalNode.getElementParameters();
    generateParameters(parametersElement, elementParameterList);
    List<ExternalMapperTable> inputTables = externalData.getInputTables();
    List<ExternalMapperTable> outputTables = externalData.getOutputTables();
    List<ExternalMapperTable> varTables = externalData.getVarsTables();
    handleMapperTablesInfo(inputTables, externalNodeElement, IHTMLDocConstants.MAPPER_TABLE_INPUT);
    handleMapperTablesInfo(outputTables, externalNodeElement, IHTMLDocConstants.MAPPER_TABLE_OUPUT);
    handleMapperTablesInfo(varTables, externalNodeElement, IHTMLDocConstants.MAPPER_TABLE_VAR);
}
Also used : Element(org.dom4j.Element) ArrayList(java.util.ArrayList) List(java.util.List) ExternalMapperTable(org.talend.designer.mapper.external.data.ExternalMapperTable)

Example 28 with ExternalMapperTable

use of org.talend.designer.mapper.external.data.ExternalMapperTable in project tdi-studio-se by Talend.

the class ExternalDataConverter method prepareExternalData.

/**
     * 
     * Prepare ExternalMapperData object from internal data.
     * 
     * @param mapperModel
     * @return
     */
public ExternalMapperData prepareExternalData(MapperModel mapperModel, ExternalMapperUiProperties uiProperties) {
    ExternalMapperData externalData = new ExternalMapperData();
    inputTables = new ArrayList<ExternalMapperTable>();
    externalData.setInputTables(inputTables);
    outputTables = new ArrayList<ExternalMapperTable>();
    externalData.setOutputTables(outputTables);
    varsTables = new ArrayList<ExternalMapperTable>();
    externalData.setVarsTables(varsTables);
    loadInExternalData(mapperModel.getInputDataMapTables());
    loadInExternalData(mapperModel.getVarsDataMapTables());
    loadInExternalData(mapperModel.getOutputDataMapTables());
    externalData.setUiProperties(uiProperties);
    return externalData;
}
Also used : ExternalMapperTable(org.talend.designer.mapper.external.data.ExternalMapperTable) ExternalMapperData(org.talend.designer.mapper.external.data.ExternalMapperData)

Example 29 with ExternalMapperTable

use of org.talend.designer.mapper.external.data.ExternalMapperTable in project tdi-studio-se by Talend.

the class ProblemsAnalyserTest method prepareExternalData.

private ExternalMapperTable prepareExternalData(IMetadataTable table) {
    ExternalMapperTable externalMapperTable = new ExternalMapperTable();
    ArrayList<ExternalMapperTableEntry> perTableEntries = new ArrayList<ExternalMapperTableEntry>();
    for (IMetadataColumn column : table.getListColumns()) {
        ExternalMapperTableEntry externalMapperTableEntry = new ExternalMapperTableEntry();
        externalMapperTableEntry.setName(column.getLabel());
        externalMapperTableEntry.setType(column.getTalendType());
        externalMapperTableEntry.setNullable(column.isNullable());
        perTableEntries.add(externalMapperTableEntry);
    }
    externalMapperTable.setMetadataTableEntries(perTableEntries);
    return externalMapperTable;
}
Also used : ExternalMapperTableEntry(org.talend.designer.mapper.external.data.ExternalMapperTableEntry) ArrayList(java.util.ArrayList) ExternalMapperTable(org.talend.designer.mapper.external.data.ExternalMapperTable) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn)

Example 30 with ExternalMapperTable

use of org.talend.designer.mapper.external.data.ExternalMapperTable in project tdi-studio-se by Talend.

the class ProblemsAnalyserTest method testCheckLookupTablesKeyProblems.

@Test
public void testCheckLookupTablesKeyProblems() {
    MapperComponent mapperComponent = createMapperComponent();
    ProblemsAnalyser analyser = new ProblemsAnalyser(mapperComponent.getMapperMain().getMapperManager());
    IExternalData externalData = mapperComponent.getExternalData();
    ExternalMapperTable lookupTable = (ExternalMapperTable) externalData.getInputTables().get(1);
    // match mode:Unique Match +no expression
    lookupTable.setMatchingMode(TMAP_MATCHING_MODE.UNIQUE_MATCH.name());
    analyser.checkLookupTablesKeyProblems((ExternalMapperData) externalData);
    List<Problem> problems = analyser.getProblems();
    Assert.assertEquals(problems.size(), 1);
    Assert.assertEquals(problems.get(0).getDescription(), "The lookup table 'row2' should have at least one expression key filled.");
    // match mode:All Row +expression
    lookupTable.setMatchingMode(TMAP_MATCHING_MODE.ALL_ROWS.name());
    lookupTable.getMetadataTableEntries().get(0).setExpression("row1.newColumn1");
    analyser = new ProblemsAnalyser(mapperComponent.getMapperMain().getMapperManager());
    analyser.checkLookupTablesKeyProblems((ExternalMapperData) externalData);
    problems = analyser.getProblems();
    Assert.assertEquals(problems.size(), 1);
    Assert.assertEquals(problems.get(0).getDescription(), "The expression key can't be used in lookup table 'row2' with match mode 'All Rows'.");
}
Also used : Problem(org.talend.core.model.process.Problem) IExternalData(org.talend.core.model.process.IExternalData) ExternalMapperTable(org.talend.designer.mapper.external.data.ExternalMapperTable) MapperComponent(org.talend.designer.mapper.MapperComponent) Test(org.junit.Test)

Aggregations

ExternalMapperTable (org.talend.designer.mapper.external.data.ExternalMapperTable)34 ArrayList (java.util.ArrayList)20 ExternalMapperData (org.talend.designer.mapper.external.data.ExternalMapperData)13 ExternalMapperTableEntry (org.talend.designer.mapper.external.data.ExternalMapperTableEntry)11 List (java.util.List)5 HashMap (java.util.HashMap)4 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)4 IExternalData (org.talend.core.model.process.IExternalData)4 IOConnection (org.talend.designer.mapper.external.connection.IOConnection)4 IConnection (org.talend.core.model.process.IConnection)3 Problem (org.talend.core.model.process.Problem)3 MapperComponent (org.talend.designer.mapper.MapperComponent)3 OutputTable (org.talend.designer.mapper.model.table.OutputTable)3 Element (org.dom4j.Element)2 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)2 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)2 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)2 InputTable (org.talend.designer.mapper.model.emf.mapper.InputTable)2 OutputTable (org.talend.designer.mapper.model.emf.mapper.OutputTable)2 UiProperties (org.talend.designer.mapper.model.emf.mapper.UiProperties)2