use of org.talend.designer.mapper.external.data.ExternalMapperTable in project tdi-studio-se by Talend.
the class ProblemsAnalyserTest method createMapperComponent.
private MapperComponent createMapperComponent() {
IComponent tMysqlComponent = ComponentsFactoryProvider.getInstance().get("tMysqlInput", ComponentCategory.CATEGORY_4_DI.getName());
IComponent tMapComponent = ComponentsFactoryProvider.getInstance().get("tMap", ComponentCategory.CATEGORY_4_DI.getName());
Property property1 = PropertiesFactory.eINSTANCE.createProperty();
//$NON-NLS-1$
property1.setId("property1");
//$NON-NLS-1$
property1.setVersion("0.1");
//$NON-NLS-1$
property1.setLabel("test1");
Process process = new Process(property1);
Node tMysqlInput_1 = new Node(tMysqlComponent, process);
IMetadataTable tMysqlInput_1_table = tMysqlInput_1.getMetadataTable("tMysqlInput_1");
createMetadataColumns(tMysqlInput_1_table, 2);
Node tMysqlInput_2 = new Node(tMysqlComponent, process);
IMetadataTable tMysqlInput_2_table = tMysqlInput_2.getMetadataTable("tMysqlInput_2");
createMetadataColumns(tMysqlInput_2_table, 2);
Node tMap_1 = new Node(tMapComponent, process);
Connection row1 = new Connection(tMysqlInput_1, tMap_1, EConnectionType.FLOW_MAIN, EConnectionType.FLOW_MAIN.getName(), "tMysqlInput_1", "row1", "row1", false);
Connection row2 = new Connection(tMysqlInput_2, tMap_1, EConnectionType.FLOW_REF, EConnectionType.FLOW_MAIN.getName(), "tMysqlInput_1", "row2", "row2", false);
tMap_1.getExternalNode().initialize();
MapperComponent mapperComponent = (MapperComponent) tMap_1.getExternalNode();
ExternalMapperData externalData = (ExternalMapperData) mapperComponent.getExternalData();
ExternalMapperTable externalTable = prepareExternalData(tMysqlInput_1_table);
externalTable.setName(row1.getName());
externalData.getInputTables().add(externalTable);
externalTable = prepareExternalData(tMysqlInput_2_table);
externalTable.setName(row2.getName());
externalData.getInputTables().add(externalTable);
return mapperComponent;
}
use of org.talend.designer.mapper.external.data.ExternalMapperTable in project tdi-studio-se by Talend.
the class ProblemsAnalyser method checkExpressionSyntaxProblems.
/**
* DOC amaumont Comment method "checkExpressionSyntaxProblems".
*
* @param tables
* @param codeChecker
*/
private void checkExpressionSyntaxProblems(List<ExternalMapperTable> tables, ICodeProblemsChecker codeChecker) {
ILanguage currentLanguage = LanguageProvider.getCurrentLanguage();
boolean keyLanguageCheckerIsUsed = currentLanguage.getCodeLanguage() == ECodeLanguage.JAVA;
for (ExternalMapperTable table : tables) {
List<ExternalMapperTableEntry> metadataTableEntries = table.getMetadataTableEntries();
// loop on all entries of current table
if (metadataTableEntries != null) {
checkExpressionSyntaxProblems(codeChecker, currentLanguage, keyLanguageCheckerIsUsed, table, metadataTableEntries, JavaGenerationManager.PROBLEM_KEY_FIELD.METADATA_COLUMN);
}
List<ExternalMapperTableEntry> globalMapKeysValues = table.getGlobalMapKeysValues();
// loop on all entries of current table
if (globalMapKeysValues != null) {
checkExpressionSyntaxProblems(codeChecker, currentLanguage, keyLanguageCheckerIsUsed, table, globalMapKeysValues, JavaGenerationManager.PROBLEM_KEY_FIELD.GLOBAL_MAP);
}
if (table.getConstraintTableEntries() != null || table.isActivateExpressionFilter() && table.getExpressionFilter() != null && !table.getExpressionFilter().trim().equals("")) {
//$NON-NLS-1$
//$NON-NLS-1$ //$NON-NLS-2$
String prefix = "Filter invalid in table " + table.getName() + " : ";
if (table.getConstraintTableEntries() != null) {
for (ExternalMapperTableEntry entry : table.getConstraintTableEntries()) {
checkFilterEntry(codeChecker, keyLanguageCheckerIsUsed, table, prefix, entry.getExpression());
}
}
if (table.isActivateExpressionFilter() && table.getExpressionFilter() != null && !table.getExpressionFilter().trim().equals("")) {
//$NON-NLS-1$
checkFilterEntry(codeChecker, keyLanguageCheckerIsUsed, table, prefix, table.getExpressionFilter());
}
}
}
// for (ExternalMapperTable table : tables) {
}
use of org.talend.designer.mapper.external.data.ExternalMapperTable in project tdi-studio-se by Talend.
the class ProblemsAnalyser method checkOutputTablesProblems.
/**
* DOC amaumont Comment method "checkOutputTablesProblems".
*
* @param extOutputTables
*/
private void checkOutputTablesProblems(List<ExternalMapperTable> extOutputTables) {
ArrayList<ExternalMapperTable> rejectTables = new ArrayList<ExternalMapperTable>();
ArrayList<ExternalMapperTable> normalTables = new ArrayList<ExternalMapperTable>();
ArrayList<ExternalMapperTable> normalTablesWithFilter = new ArrayList<ExternalMapperTable>();
for (ExternalMapperTable outputTable : extOutputTables) {
if (outputTable.isReject()) {
rejectTables.add(outputTable);
} else if (!outputTable.isRejectInnerJoin()) {
if (outputTable.getExpressionFilter() != null && outputTable.isActivateExpressionFilter() && //$NON-NLS-1$
!outputTable.getExpressionFilter().trim().equals("") || outputTable.getConstraintTableEntries() != null && outputTable.getConstraintTableEntries().size() > 0) {
normalTablesWithFilter.add(outputTable);
} else {
normalTables.add(outputTable);
}
}
}
if (rejectTables.size() > 0 && normalTables.size() > 0) {
//$NON-NLS-1$
String tables = "";
int normalTablesListSize = normalTables.size();
for (int i = 0; i < normalTablesListSize; i++) {
ExternalMapperTable normalOutputTable = normalTables.get(i);
if (i > 0) {
//$NON-NLS-1$
tables += ", ";
}
//$NON-NLS-1$ //$NON-NLS-2$
tables += "\"" + normalOutputTable.getName() + "\"";
}
//$NON-NLS-1$
String description = Messages.getString("Problem.warning.unusableReject", new Object[] { tables });
addProblem(new Problem(null, description, ProblemStatus.WARNING));
}
}
use of org.talend.designer.mapper.external.data.ExternalMapperTable in project tdi-studio-se by Talend.
the class MapperHelper method isGeneratedAsVirtualComponent.
/**
*
* DOC YeXiaowei Comment method "isGeneratedAsVirtualComponent".
*
* @param mapperNode
* @return
*/
public static boolean isGeneratedAsVirtualComponent(final INode mapperNode) {
if (isMapperOnBigDataProcess(mapperNode.getComponent().getPaletteType())) {
return false;
}
boolean hasPersistentSortedLookup = false;
List<IConnection> incomingConnections = (List<IConnection>) mapperNode.getIncomingConnections();
ExternalMapperData internalExternalData = (ExternalMapperData) mapperNode.getExternalNode().getExternalData();
if (internalExternalData != null && incomingConnections.size() > 0) {
List<ExternalMapperTable> inputTables = internalExternalData.getInputTables();
int sizeInputTables = inputTables.size();
HashMap<String, IConnection> hNameToConnection = new HashMap<String, IConnection>();
for (IConnection connection : incomingConnections) {
hNameToConnection.put(connection.getName(), connection);
}
for (int iInputTable = 1; iInputTable < sizeInputTables; iInputTable++) {
// T_TM_M_241
ExternalMapperTable inputTable = inputTables.get(iInputTable);
String tableName = inputTable.getName();
IConnection connection = hNameToConnection.get(tableName);
if (connection == null) {
continue;
}
if (inputTable != null) {
// T_TM_M_245
List<ExternalMapperTableEntry> metadataTableEntries = inputTable.getMetadataTableEntries();
if (metadataTableEntries == null) {
continue;
}
if (inputTable.isPersistent() && !"ALL_ROWS".equals(inputTable.getMatchingMode()) && !"DYNAMIC".equals(inputTable.getLookupMode())) {
//$NON-NLS-1$ //$NON-NLS-2$
hasPersistentSortedLookup = true;
}
}
// T_TM_M_245
}
// T_TM_M_241
}
return hasPersistentSortedLookup;
}
Aggregations