use of org.talend.designer.mapper.external.data.ExternalMapperTableEntry in project tdi-studio-se by Talend.
the class MapperHelper method getPersistentTableEntitys.
private static List<MapperTableEntry> getPersistentTableEntitys(List<ExternalMapperTableEntry> entities) {
List<MapperTableEntry> persistentEntities = new ArrayList<MapperTableEntry>();
for (ExternalMapperTableEntry entity : entities) {
final MapperTableEntry emfMapperTableEntry = MapperFactory.eINSTANCE.createMapperTableEntry();
emfMapperTableEntry.setExpression(entity.getExpression());
emfMapperTableEntry.setName(entity.getName());
emfMapperTableEntry.setNullable(entity.isNullable());
emfMapperTableEntry.setType(entity.getType());
emfMapperTableEntry.setOperator(entity.getOperator());
persistentEntities.add(emfMapperTableEntry);
}
return persistentEntities;
}
use of org.talend.designer.mapper.external.data.ExternalMapperTableEntry in project tdi-studio-se by Talend.
the class ProblemsAnalyser method checkExpressionSyntaxProblems.
private void checkExpressionSyntaxProblems(ICodeProblemsChecker codeChecker, ILanguage currentLanguage, boolean keyLanguageCheckerIsUsed, ExternalMapperTable table, List<ExternalMapperTableEntry> entries, PROBLEM_KEY_FIELD problemKeyField) {
for (ExternalMapperTableEntry entry : entries) {
List<Problem> problems = null;
if (keyLanguageCheckerIsUsed) {
String key = mapperManager.buildProblemKey(problemKeyField, table.getName(), entry.getName());
problems = codeChecker.getProblemsFromKey(key);
} else {
problems = checkCodeProblems(entry.getExpression());
}
if (problems != null) {
String location = currentLanguage.getLocation(table.getName(), entry.getName());
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
String prefix = "Expression of " + problemKeyField.getLabel() + " " + location + " is invalid : ";
for (Problem problem : problems) {
if (!problem.getDescription().startsWith(prefix)) {
//$NON-NLS-1$
String description = prefix + problem.getDescription() + ".";
problem.setDescription(description);
}
addProblem(problem);
}
}
}
// for (ExternalMapperTableEntry entry : metadataTableEntries) {
}
use of org.talend.designer.mapper.external.data.ExternalMapperTableEntry in project tdi-studio-se by Talend.
the class ProblemsAnalyser method checkLookupTablesKeyProblems.
public void checkLookupTablesKeyProblems(ExternalMapperData externalData) {
List<ExternalMapperTable> lookupTables = new ArrayList<ExternalMapperTable>(externalData.getInputTables());
List<? extends IConnection> mainConnections = mapperManager.getAbstractMapComponent().getIncomingConnections(EConnectionType.FLOW_MAIN);
if (mainConnections.size() == 1) {
ExternalMapperTable mainTable = null;
for (ExternalMapperTable table : lookupTables) {
if (mainConnections.get(0).getName().equals(table.getName())) {
mainTable = table;
break;
}
}
if (mainTable != null) {
lookupTables.remove(mainTable);
}
}
for (ExternalMapperTable table : lookupTables) {
List<ExternalMapperTableEntry> columnEntries = table.getMetadataTableEntries();
boolean atLeastOneExpressionFilled = false;
for (ExternalMapperTableEntry entry : columnEntries) {
if (!StringUtils.isEmpty(entry.getExpression())) {
atLeastOneExpressionFilled = true;
break;
}
}
if (!atLeastOneExpressionFilled) {
String matchingMode = table.getMatchingMode();
if (!TMAP_MATCHING_MODE.ALL_ROWS.name().equals(matchingMode)) {
addProblem(new Problem(null, //$NON-NLS-1$ //$NON-NLS-2$
"The lookup table '" + table.getName() + "' should have at least one expression key filled.", ProblemStatus.WARNING));
}
} else {
String matchingMode = table.getMatchingMode();
if (TMAP_MATCHING_MODE.ALL_ROWS.name().equals(matchingMode)) {
addProblem(new Problem(null, "The expression key can't be used in lookup table '" + table.getName() + "' with match mode 'All Rows'.", ProblemStatus.WARNING));
}
}
}
}
use of org.talend.designer.mapper.external.data.ExternalMapperTableEntry in project tdi-studio-se by Talend.
the class OutputTable method initFromExternalData.
public void initFromExternalData(ExternalMapperTable externalMapperTable) {
super.initFromExternalData(externalMapperTable);
if (externalMapperTable != null) {
this.reject = externalMapperTable.isReject();
this.rejectInnerJoin = externalMapperTable.isRejectInnerJoin();
this.isJoinTableOf = externalMapperTable.getIsJoinTableOf();
this.isErrorRejectTable = externalMapperTable.isErrorRejectTable();
List<ExternalMapperTableEntry> externalConstraintTableEntries = externalMapperTable.getConstraintTableEntries();
if (externalConstraintTableEntries != null) {
if (!mapperManager.isAdvancedMap()) {
for (ExternalMapperTableEntry entry : externalConstraintTableEntries) {
FilterTableEntry filterTableEntry = new FilterTableEntry(this, entry.getName(), entry.getExpression());
// mapperManager.getProblemsManager().checkProblemsForTableEntry(filterTableEntry, false);
addFilterEntry(filterTableEntry);
}
} else {
ILanguage currentLanguage = LanguageProvider.getCurrentLanguage();
JavaGenerationManager javaGenerationManager = new JavaGenerationManager(currentLanguage);
DataMapExpressionParser expressionParser = new DataMapExpressionParser(currentLanguage);
String expressionFilter = javaGenerationManager.buildConditions(externalConstraintTableEntries, expressionParser);
if (!expressionFilter.trim().equals("")) {
//$NON-NLS-1$
this.getExpressionFilter().setExpression(expressionFilter);
this.setActivateExpressionFilter(true);
}
}
}
}
}
use of org.talend.designer.mapper.external.data.ExternalMapperTableEntry in project tdi-studio-se by Talend.
the class VarsTable method initFromExternalData.
public void initFromExternalData(ExternalMapperTable externalMapperTable) {
super.initFromExternalData(externalMapperTable);
if (externalMapperTable != null) {
List<ExternalMapperTableEntry> metadataTableEntries = externalMapperTable.getMetadataTableEntries();
if (metadataTableEntries != null) {
for (ExternalMapperTableEntry externalMapperTableEntry : metadataTableEntries) {
VarTableEntry varTableEntry = new VarTableEntry(this, externalMapperTableEntry.getName(), externalMapperTableEntry.getExpression(), externalMapperTableEntry.getType());
// mapperManager.getProblemsManager().checkProblemsForTableEntry(varTableEntry, false);
if (LanguageManager.getCurrentLanguage() == ECodeLanguage.JAVA) {
varTableEntry.setNullable(externalMapperTableEntry.isNullable());
}
addColumnEntry(varTableEntry);
}
}
} else {
setMinimized(true);
}
}
Aggregations