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);
}
}
}
}
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);
}
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;
}
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;
}
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'.");
}
Aggregations