use of org.talend.designer.mapper.external.data.ExternalMapperTable in project tdi-studio-se by Talend.
the class DesignerMapperService method getRepositorySchemaIds.
public List<String> getRepositorySchemaIds(IExternalData nodeData) {
List<String> schemaIds = new ArrayList<String>();
if (nodeData != null && nodeData instanceof ExternalMapperData) {
ExternalMapperData mapperData = (ExternalMapperData) nodeData;
List<ExternalMapperTable> inputTables = mapperData.getInputTables();
if (inputTables != null && inputTables.size() > 0) {
for (ExternalMapperTable inputTable : inputTables) {
String id = inputTable.getId();
if (id != null && !schemaIds.contains(id)) {
schemaIds.add(id);
}
}
}
List<ExternalMapperTable> outputTables = mapperData.getOutputTables();
if (outputTables != null && outputTables.size() > 0) {
for (ExternalMapperTable outputTable : outputTables) {
String id = outputTable.getId();
if (id != null && !schemaIds.contains(id)) {
schemaIds.add(id);
}
}
}
}
return schemaIds;
}
use of org.talend.designer.mapper.external.data.ExternalMapperTable in project tdi-studio-se by Talend.
the class MapperComponent method replaceLocationsInAllExpressions.
/**
* DOC amaumont Comment method "replaceLocations".
*
* @param oldLocation
* @param newLocation
* @param tableRenamed TODO
* @param newTableName
* @param newColumnName
*/
private void replaceLocationsInAllExpressions(TableEntryLocation oldLocation, TableEntryLocation newLocation, boolean tableRenamed) {
// replace old location by new location for all expressions in mapper
List<ExternalMapperTable> tables = new ArrayList<ExternalMapperTable>(externalData.getInputTables());
tables.addAll(new ArrayList<ExternalMapperTable>(externalData.getVarsTables()));
tables.addAll(new ArrayList<ExternalMapperTable>(externalData.getOutputTables()));
DataMapExpressionParser dataMapExpressionParser = new DataMapExpressionParser(LanguageProvider.getCurrentLanguage());
// loop on all tables
for (ExternalMapperTable table : tables) {
List<ExternalMapperTableEntry> metadataTableEntries = table.getMetadataTableEntries();
String expressionFilter = replaceLocation(oldLocation, newLocation, table.getExpressionFilter(), dataMapExpressionParser, tableRenamed);
if (expressionFilter != null) {
table.setExpressionFilter(expressionFilter);
}
if (metadataTableEntries != null) {
// loop on all entries of current table
for (ExternalMapperTableEntry entry : metadataTableEntries) {
String expression = replaceLocation(oldLocation, newLocation, entry.getExpression(), dataMapExpressionParser, tableRenamed);
if (expression != null) {
entry.setExpression(expression);
}
}
// for (ExternalMapperTableEntry entry : metadataTableEntries) {
}
if (table.getConstraintTableEntries() != null) {
for (ExternalMapperTableEntry entry : table.getConstraintTableEntries()) {
String expression = replaceLocation(oldLocation, newLocation, entry.getExpression(), dataMapExpressionParser, tableRenamed);
if (expression != null) {
entry.setExpression(expression);
}
}
}
if (table.getGlobalMapKeysValues() != null) {
for (ExternalMapperTableEntry entry : table.getGlobalMapKeysValues()) {
String expression = replaceLocation(oldLocation, newLocation, entry.getExpression(), dataMapExpressionParser, tableRenamed);
if (expression != null) {
entry.setExpression(expression);
}
}
}
}
// for (ExternalMapperTable table : tables) {
}
use of org.talend.designer.mapper.external.data.ExternalMapperTable in project tdi-studio-se by Talend.
the class MapperComponent method hasOrRenameData.
/**
*
* DOC amaumont Comment method "hasOrRenameData".
*
* @param oldName
* @param newName can be null if <code>renameAction</code> is false
* @param renameAction true to rename in all expressions, false to get boolean if present in one of the expressions
* @return
*/
@Override
protected boolean hasOrRenameData(String oldName, String newName, boolean renameAction) {
if (oldName == null || newName == null && renameAction) {
throw new NullPointerException();
}
if (externalData != null) {
List<ExternalMapperTable> tables = new ArrayList<ExternalMapperTable>(externalData.getInputTables());
tables.addAll(externalData.getOutputTables());
if (externalData.getVarsTables() != null) {
tables.addAll(externalData.getVarsTables());
}
for (ExternalMapperTable table : tables) {
if (table.getExpressionFilter() != null) {
Pattern pattern = getRenamePattern(oldName);
if (pattern != null) {
PatternMatcher matcher = new Perl5Matcher();
((Perl5Matcher) matcher).setMultiline(true);
if (renameAction) {
Perl5Substitution substitution = getRenameSubstitution(newName);
String expression = renameDataIntoExpression(pattern, matcher, substitution, table.getExpressionFilter());
table.setExpressionFilter(expression);
} else {
if (hasDataIntoExpression(pattern, matcher, table.getExpressionFilter())) {
return true;
}
}
}
}
List<ExternalMapperTableEntry> metadataTableEntries = table.getMetadataTableEntries();
if (metadataTableEntries != null) {
// loop on all entries of current table
for (ExternalMapperTableEntry entry : metadataTableEntries) {
if (hasOrRenameEntry(entry, oldName, newName, renameAction)) {
// existed
return true;
}
}
// for (ExternalMapperTableEntry entry : metadataTableEntries) {
}
if (table.getConstraintTableEntries() != null) {
for (ExternalMapperTableEntry entry : table.getConstraintTableEntries()) {
if (hasOrRenameEntry(entry, oldName, newName, renameAction)) {
// existed
return true;
}
}
}
}
}
return false;
}
use of org.talend.designer.mapper.external.data.ExternalMapperTable in project tdi-studio-se by Talend.
the class ExternalDataConverter method prepareVarsTables.
private List<VarsTable> prepareVarsTables(ExternalMapperData externalData) {
List<VarsTable> varsTablesList = new ArrayList<VarsTable>();
if (externalData != null) {
List<ExternalMapperTable> varsExternalTables = externalData.getVarsTables();
for (ExternalMapperTable persistentTable : varsExternalTables) {
VarsTable varsTable = new VarsTable(this.mapperManager, persistentTable.getName());
varsTable.initFromExternalData(persistentTable);
varsTablesList.add(varsTable);
}
}
if (varsTablesList.size() == 0) {
VarsTable varsTable = new VarsTable(this.mapperManager, VarsTable.PREFIX_VARS_TABLE_NAME);
varsTable.setMinimized(true);
varsTablesList.add(varsTable);
}
return varsTablesList;
}
use of org.talend.designer.mapper.external.data.ExternalMapperTable 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