use of org.talend.designer.mapper.external.connection.IOConnection 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.external.connection.IOConnection in project tdi-studio-se by Talend.
the class OutputDataMapTableView method initColumnsOfTableColumns.
@Override
public void initColumnsOfTableColumns(final TableViewerCreator tableViewerCreatorForColumns) {
IOConnection connection = ((OutputTable) getDataMapTable()).getConnection();
TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
//$NON-NLS-1$
column.setTitle(Messages.getString("OutputDataMapTableView.columnTitle.expression"));
column.setId(DataMapTableView.ID_EXPRESSION_COLUMN);
expressionCellEditor = createExpressionCellEditor(tableViewerCreatorForColumns, column, new Zone[] { Zone.INPUTS, Zone.VARS }, false);
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<OutputColumnTableEntry, String>() {
public String get(OutputColumnTableEntry bean) {
return bean.getExpression();
}
public void set(OutputColumnTableEntry bean, String value) {
bean.setExpression(value);
mapperManager.getProblemsManager().checkProblemsForTableEntry(bean, true);
tableViewerCreatorForColumns.getTableViewer().refresh(bean);
}
});
column.setModifiable(!mapperManager.componentIsReadOnly());
//$NON-NLS-1$
column.setDefaultInternalValue("");
column.setWeight(COLUMN_EXPRESSION_SIZE_WEIGHT);
column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
column.setTitle(DataMapTableView.COLUMN_NAME);
column.setId(DataMapTableView.ID_NAME_COLUMN);
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<OutputColumnTableEntry, String>() {
public String get(OutputColumnTableEntry bean) {
return bean.getMetadataColumn().getLabel();
}
public void set(OutputColumnTableEntry bean, String value) {
bean.getMetadataColumn().setLabel(value);
}
});
column.setWeight(COLUMN_NAME_SIZE_WEIGHT);
if (PluginChecker.isTraceDebugPluginLoaded() && mapperManager.isTracesActive() && connection != null) {
column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
column.setTitle("Preview");
column.setId(DataMapTableView.PREVIEW_COLUMN);
column.setWeight(COLUMN_NAME_SIZE_WEIGHT);
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<OutputColumnTableEntry, String>() {
public String get(OutputColumnTableEntry bean) {
IMetadataColumn metadataColumn = bean.getMetadataColumn();
if (metadataColumn != null) {
String label = metadataColumn.getLabel();
TraceData preview = bean.getPreviewValue();
if (preview != null && preview.getData() != null) {
return preview.getData().get(label);
}
}
return "";
}
public void set(OutputColumnTableEntry bean, String value) {
// do nothing
}
});
}
configureCellModifier(tableViewerCreatorForColumns);
}
use of org.talend.designer.mapper.external.connection.IOConnection in project tdi-studio-se by Talend.
the class ProblemsAnalyserTest method testGetLookupTableProblem.
@Test
public void testGetLookupTableProblem() {
MapperComponent mapperComponent = createMapperComponent();
ExternalMapperData externalData = (ExternalMapperData) mapperComponent.getExternalData();
MapperManager mapperManager = mapperComponent.getMapperMain().getMapperManager();
ExternalDataConverter converter = new ExternalDataConverter(mapperManager);
MapperMain mapperMain = ((MapperComponent) mapperManager.getAbstractMapComponent()).getMapperMain();
List<? extends IConnection> incomingConnections = new ArrayList<IConnection>(mapperManager.getAbstractMapComponent().getIncomingConnections());
ArrayList<IOConnection> inputsIOConnections = mapperMain.createIOConnections(incomingConnections);
ArrayList<InputTable> inputTables = converter.prepareInputTables(inputsIOConnections, externalData);
InputTable lookupTable = inputTables.get(1);
ProblemsAnalyser analyser = new ProblemsAnalyser(mapperManager);
// match mode:Unique Match +no expression
lookupTable.setMatchingMode(TMAP_MATCHING_MODE.UNIQUE_MATCH);
analyser.getLookupTableProblem(lookupTable, mapperManager.isTableHasAtLeastOneHashKey(lookupTable));
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);
lookupTable.getColumnEntries().get(0).setExpression("row1.newColumn1");
analyser = new ProblemsAnalyser(mapperComponent.getMapperMain().getMapperManager());
analyser.getLookupTableProblem(lookupTable, mapperManager.isTableHasAtLeastOneHashKey(lookupTable));
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'.");
}
use of org.talend.designer.mapper.external.connection.IOConnection in project tdi-studio-se by Talend.
the class InputTable method hasReadOnlyMetadataColumns.
/*
* (non-Javadoc)
*
* @see org.talend.designer.mapper.model.table.AbstractInOutTable#hasReadOnlyMetadataColumns()
*/
@Override
public boolean hasReadOnlyMetadataColumns() {
boolean hasReadOnlyMetadataColumns = false;
IOConnection connection = getConnection();
if (connection != null) {
INode source = connection.getSource();
if (source != null) {
hasReadOnlyMetadataColumns = connection.isReadOnly() || !connection.isActivate() || source.isReadOnly();
if (!hasReadOnlyMetadataColumns) {
for (IElementParameter param : source.getElementParameters()) {
if (param.getFieldType() == EParameterFieldType.SCHEMA_TYPE) {
if (param.isReadOnly()) {
hasReadOnlyMetadataColumns = true;
break;
}
}
}
}
}
}
return hasReadOnlyMetadataColumns;
}
use of org.talend.designer.mapper.external.connection.IOConnection in project tdi-studio-se by Talend.
the class ExternalDataConverter method prepareInputTables.
public ArrayList<InputTable> prepareInputTables(List<IOConnection> inputConnections, ExternalMapperData externalData) {
ArrayList<InputTable> inputDataMapTables = new ArrayList<InputTable>();
ArrayList<IOConnection> remainingConnections = new ArrayList<IOConnection>(inputConnections);
// case externalData IS NOT initialized
if (externalData == null || externalData.getInputTables().size() == 0) {
for (IOConnection connection : inputConnections) {
InputTable inputTable = new InputTable(this.mapperManager, connection, connection.getName());
inputTable.initFromExternalData(null);
if (EConnectionType.FLOW_MAIN != connection.getConnectionType()) {
inputTable.setMatchingMode(TMAP_MATCHING_MODE.ALL_ROWS);
}
if (connection.getTable() == null) {
inputTable.setReadOnly(true);
}
inputDataMapTables.add(inputTable);
}
} else {
// case externalData IS initialized
Map<String, IOConnection> nameToInputConnection = new HashMap<String, IOConnection>();
for (IOConnection connection : inputConnections) {
nameToInputConnection.put(connection.getName(), connection);
}
for (ExternalMapperTable persistentTable : externalData.getInputTables()) {
IOConnection connection = nameToInputConnection.get(persistentTable.getName());
if (connection != null) {
InputTable inputTable = new InputTable(this.mapperManager, connection, connection.getName());
inputTable.initFromExternalData(persistentTable);
inputDataMapTables.add(inputTable);
remainingConnections.remove(connection);
// remove table settings in main ,set false in case the value is true in previous version
if (EConnectionType.FLOW_MAIN == connection.getConnectionType()) {
inputTable.setActivateCondensedTool(false);
// bug TDI-8027
inputTable.setPersistent(false);
}
if (connection.getTable() == null) {
inputTable.setReadOnly(true);
}
}
}
for (IOConnection connection : remainingConnections) {
InputTable inputTable = new InputTable(this.mapperManager, connection, connection.getName());
inputTable.initFromExternalData(null);
inputDataMapTables.add(inputTable);
// remove table settings in main ,set false in case the value is true in previous version
if (EConnectionType.FLOW_MAIN == connection.getConnectionType()) {
inputTable.setActivateCondensedTool(false);
// bug TDI-8027
inputTable.setPersistent(false);
} else {
inputTable.setMatchingMode(TMAP_MATCHING_MODE.ALL_ROWS);
}
if (connection.getTable() == null) {
inputTable.setReadOnly(true);
}
}
}
// sort for put table with main connection at top position of the list
Collections.sort(inputDataMapTables, new Comparator<InputTable>() {
public int compare(InputTable o1, InputTable o2) {
if (o1.isMainConnection()) {
return -1;
} else if (o2.isMainConnection()) {
return 1;
}
return 0;
}
});
return inputDataMapTables;
}
Aggregations