use of org.talend.designer.mapper.model.table.InputTable in project tdi-studio-se by Talend.
the class ProblemsManager method checkLookupExpressionProblem.
public boolean checkLookupExpressionProblem() {
if (mapperManager.isBigDataProcess()) {
List<DataMapTableView> inputsTablesView = mapperManager.getUiManager().getInputsTablesView();
List<DataMapTableView> lookupTables = new ArrayList<DataMapTableView>();
List<IColumnEntry> entityWithoutProblem = new ArrayList<IColumnEntry>();
DataMapTableView firstLookup = null;
for (int i = 0; i < inputsTablesView.size(); i++) {
DataMapTableView inputTableView = inputsTablesView.get(i);
InputTable dataMapTable = (InputTable) inputTableView.getDataMapTable();
boolean mainConnection = dataMapTable.isMainConnection();
if (mainConnection) {
continue;
}
if (firstLookup == null) {
firstLookup = inputTableView;
} else {
lookupTables.add(inputTableView);
}
}
if (firstLookup == null || lookupTables.isEmpty()) {
return false;
}
List<List<IColumnEntry>> otherLookupEntities = new ArrayList<List<IColumnEntry>>();
for (DataMapTableView otherLookup : lookupTables) {
otherLookupEntities.add(new ArrayList<IColumnEntry>(otherLookup.getDataMapTable().getColumnEntries()));
}
List<IColumnEntry> lookupEntity = firstLookup.getDataMapTable().getColumnEntries();
for (IColumnEntry firstLookupEntity : lookupEntity) {
String expression = firstLookupEntity.getExpression();
if (expression == null || expression.trim().equals("")) {
continue;
}
//$NON-NLS-1$//$NON-NLS-2$
expression = expression.replaceAll("\\s*", "").trim();
Map<List<IColumnEntry>, IColumnEntry> entitiesFound = new HashMap<List<IColumnEntry>, IColumnEntry>();
for (List<IColumnEntry> tableEntities : otherLookupEntities) {
for (IColumnEntry entityInOtherLookup : tableEntities) {
String expressionInOtherLookup = entityInOtherLookup.getExpression();
if (expressionInOtherLookup == null || expressionInOtherLookup.trim().equals("")) {
continue;
}
//$NON-NLS-1$//$NON-NLS-2$
expressionInOtherLookup = expressionInOtherLookup.replaceAll("\\s*", "").trim();
// only match the first one
if (expression.equals(expressionInOtherLookup)) {
entitiesFound.put(tableEntities, entityInOtherLookup);
break;
}
}
}
if (entitiesFound.size() == otherLookupEntities.size()) {
for (List<IColumnEntry> tableEntities : entitiesFound.keySet()) {
entityWithoutProblem.add(entitiesFound.get(tableEntities));
entityWithoutProblem.add(firstLookupEntity);
tableEntities.remove(entitiesFound.get(tableEntities));
}
}
}
// add back the first lookup table
lookupTables.add(firstLookup);
if (entityWithoutProblem.isEmpty()) {
// no common expressions in lookup tables , then show red background color for all
for (DataMapTableView lookupTable : lookupTables) {
List<IColumnEntry> columnEntries = lookupTable.getDataMapTable().getColumnEntries();
for (IColumnEntry entity : columnEntries) {
if (entity.getExpression() == null || entity.getExpression().trim().equals("")) {
continue;
}
addLookupProblem(entity);
}
lookupTable.getTableViewerCreatorForColumns().refresh();
}
} else {
for (DataMapTableView lookupTable : lookupTables) {
boolean needRefresh = false;
List<IColumnEntry> columnEntries = lookupTable.getDataMapTable().getColumnEntries();
for (IColumnEntry entity : columnEntries) {
if (entity.getExpression() == null || entity.getExpression().trim().equals("") || entityWithoutProblem.contains(entity)) {
if (entity.getProblems() != null) {
needRefresh = entity.getProblems().remove(lookupProblem);
if (entity.getProblems().isEmpty()) {
entity.setProblems(null);
}
}
} else {
addLookupProblem(entity);
needRefresh = true;
}
}
if (needRefresh) {
lookupTable.getTableViewerCreatorForColumns().refresh();
}
}
}
return true;
}
return false;
}
use of org.talend.designer.mapper.model.table.InputTable in project tdi-studio-se by Talend.
the class UIManager method parseAllExpressions.
/**
* DOC amaumont Comment method "processAllExpressions".
*
* @param newLinksMustHaveSelectedState TODO
*/
@SuppressWarnings("unchecked")
public void parseAllExpressions(DataMapTableView dataMapTableView, boolean newLinksMustHaveSelectedState) {
List<IColumnEntry> columnsEntriesList = dataMapTableView.getDataMapTable().getColumnEntries();
parseAllExpressions(columnsEntriesList, newLinksMustHaveSelectedState);
if (mapperManager.isAdvancedMap() && (dataMapTableView.getZone() == Zone.INPUTS || dataMapTableView.getZone() == Zone.OUTPUTS)) {
AbstractInOutTable table = (AbstractInOutTable) dataMapTableView.getDataMapTable();
if (dataMapTableView.getZone() == Zone.INPUTS) {
InputTable inputTable = (InputTable) table;
List<GlobalMapEntry> globalMapEntries = inputTable.getGlobalMapEntries();
if (globalMapEntries != null && !inputTable.isMainConnection()) {
parseAllExpressions(globalMapEntries, newLinksMustHaveSelectedState);
}
}
if (table.isActivateExpressionFilter()) {
ExpressionFilterEntry expressionFilter = table.getExpressionFilter();
parseExpression(expressionFilter.getExpression(), expressionFilter, newLinksMustHaveSelectedState, false, false);
}
} else if (dataMapTableView.getZone() == Zone.OUTPUTS) {
List<ITableEntry> constraintEntriesList = dataMapTableView.getTableViewerCreatorForFilters().getInputList();
parseAllExpressions(constraintEntriesList, newLinksMustHaveSelectedState);
}
}
use of org.talend.designer.mapper.model.table.InputTable in project tdi-studio-se by Talend.
the class ProblemsAnalyser method checkKeysProblems.
/**
* DOC amaumont Comment method "checkKeysProblems".
*
* @param incomingConnections
* @param inputTables
*/
private void checkKeysProblems(ArrayList<InputTable> inputTables) {
ILanguage currentLanguage = LanguageProvider.getCurrentLanguage();
if (!mapperManager.isAdvancedMap()) {
for (InputTable table : inputTables) {
if (table.isMainConnection()) {
continue;
}
String tableName = table.getName();
List<IColumnEntry> columnEntries = table.getColumnEntries();
for (IColumnEntry entry : columnEntries) {
InputColumnTableEntry inputEntry = (InputColumnTableEntry) entry;
String columnName = entry.getName();
if (mapperManager.checkEntryHasInvalidUncheckedKey(inputEntry)) {
String description = //$NON-NLS-1$
"Key of " + currentLanguage.getLocation(tableName, columnName) + //$NON-NLS-1$
" input entry should be checked or expression should be removed. ";
addProblem(new Problem(null, description, ProblemStatus.WARNING));
}
if (mapperManager.checkEntryHasInvalidCheckedKey(inputEntry)) {
String description = //$NON-NLS-1$
"Key of " + currentLanguage.getLocation(tableName, columnName) + //$NON-NLS-1$
" input entry should be unchecked or expression should be filled. ";
addProblem(new Problem(null, description, ProblemStatus.WARNING));
}
}
}
}
}
use of org.talend.designer.mapper.model.table.InputTable in project tdi-studio-se by Talend.
the class ProblemsAnalyser method checkProblems.
public List<Problem> checkProblems(ExternalMapperData externalData) {
problems.clear();
if (externalData != null) {
checkLookupTablesKeyProblems(externalData);
ICodeProblemsChecker codeChecker = LanguageProvider.getCurrentLanguage().getCodeChecker();
if (mapperManager.isCheckSyntaxEnabled()) {
List<ExternalMapperTable> extInputTables = new ArrayList<ExternalMapperTable>(externalData.getInputTables());
List<ExternalMapperTable> extVarTables = new ArrayList<ExternalMapperTable>(externalData.getVarsTables());
List<ExternalMapperTable> extOutputTables = new ArrayList<ExternalMapperTable>(externalData.getOutputTables());
checkExpressionSyntaxProblems(extInputTables, codeChecker);
checkExpressionSyntaxProblems(extVarTables, codeChecker);
checkExpressionSyntaxProblems(extOutputTables, codeChecker);
List<? extends IConnection> incomingConnections = new ArrayList<IConnection>(this.mapperManager.getAbstractMapComponent().getIncomingConnections());
ExternalDataConverter converter = new ExternalDataConverter(mapperManager);
MapperMain mapperMain = ((MapperComponent) mapperManager.getAbstractMapComponent()).getMapperMain();
ArrayList<IOConnection> inputsIOConnections = mapperMain.createIOConnections(incomingConnections);
ArrayList<InputTable> inputTables = converter.prepareInputTables(inputsIOConnections, externalData);
checkKeysProblems(inputTables);
checkOutputTablesProblems(extOutputTables);
}
}
return getProblems();
}
use of org.talend.designer.mapper.model.table.InputTable in project tdi-studio-se by Talend.
the class ExpressionProposalProvider method getProposals.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.fieldassist.IContentProposalProvider#getProposals(java.lang.String, int)
*/
public IContentProposal[] getProposals(String contents, int position) {
List<IContentProposal> proposals = new ArrayList<IContentProposal>();
TableEntryLocation sourceEntryLocation = new TableEntryLocation();
for (IDataMapTable table : this.tables) {
List<IColumnEntry> dataMapTableEntries = table.getColumnEntries();
for (IColumnEntry entrySource : dataMapTableEntries) {
sourceEntryLocation.tableName = entrySource.getParentName();
sourceEntryLocation.columnName = entrySource.getName();
if (mapperManager.getUiManager().checkSourceLocationIsValid(entrySource, currentModifiedEntry)) {
proposals.add(new EntryContentProposal(entrySource, this.currentLanguage));
}
}
// for the globalMap
if (table instanceof InputTable) {
InputTable inputTable = (InputTable) table;
List<GlobalMapEntry> globalMapEntries = inputTable.getGlobalMapEntries();
for (GlobalMapEntry entry : globalMapEntries) {
proposals.add(new EntryContentProposal(entry, this.currentLanguage));
}
}
}
for (IContentProposalProvider contentProposalProvider : otherContentProposalProviders) {
proposals.addAll(Arrays.asList(contentProposalProvider.getProposals(contents, position)));
}
IContentProposal[] res = new IContentProposal[proposals.size()];
res = proposals.toArray(res);
return res;
}
Aggregations