use of org.talend.designer.dbmap.external.data.ExternalDbMapEntry in project tdi-studio-se by Talend.
the class DbMapComponentDocumentation method generateMapperTablesInfo.
/**
* This method used for generating all mapper tables information into xml file.
*
* @param externalNodeElement
* @param tables
* @param mapperTableType
*/
private void generateMapperTablesInfo(Element externalNodeElement, List<ExternalDbMapTable> tables, String mapperTableType) {
//$NON-NLS-1$
Element mapperTableElement = externalNodeElement.addElement("mapperTable");
//$NON-NLS-1$
mapperTableElement.addAttribute("type", HTMLDocUtils.checkString(mapperTableType));
Element tableElement = null;
for (ExternalDbMapTable table : tables) {
//$NON-NLS-1$
tableElement = mapperTableElement.addElement("table");
generateTableSummaryInfo(mapperTableElement, tableElement, table);
List<ExternalDbMapEntry> metadataTableEntries = table.getMetadataTableEntries();
if (!HTMLDocUtils.checkList(metadataTableEntries)) {
continue;
}
//$NON-NLS-1$
Element metadataTableEntriesElement = tableElement.addElement("metadataTableEntries");
for (ExternalDbMapEntry entry : metadataTableEntries) {
generateTablesEntriesInfo(metadataTableEntriesElement, entry);
}
/**
* generate custom Where clauses conditions entries
*/
List<ExternalDbMapEntry> customWhereConditionsEntries = table.getCustomWhereConditionsEntries();
if (!HTMLDocUtils.checkList(customWhereConditionsEntries)) {
continue;
}
//$NON-NLS-1$
Element customWhereConditionsEntriesElement = tableElement.addElement("customWhereConditionsEntries");
for (ExternalDbMapEntry entry : customWhereConditionsEntries) {
generateTablesEntriesInfo(customWhereConditionsEntriesElement, entry);
}
/**
* generate custom Other clauses conditions entries
*/
List<ExternalDbMapEntry> customOtherConditionsEntries = table.getCustomOtherConditionsEntries();
if (!HTMLDocUtils.checkList(customOtherConditionsEntries)) {
continue;
}
//$NON-NLS-1$
Element customOtherConditionsEntriesElement = tableElement.addElement("customOtherConditionsEntries");
for (ExternalDbMapEntry entry : customOtherConditionsEntries) {
generateTablesEntriesInfo(customOtherConditionsEntriesElement, entry);
}
}
}
use of org.talend.designer.dbmap.external.data.ExternalDbMapEntry in project tdi-studio-se by Talend.
the class UpdateELTMapComponentCommand method execute.
private void execute(String oldValue, String newValue) {
connection.setName(newValue);
// update table name
for (IExternalMapTable input : newInputTables) {
if (input instanceof ExternalDbMapTable) {
ExternalDbMapTable dbMapTable = (ExternalDbMapTable) input;
if (oldValue.equals(dbMapTable.getName()) || oldValue.equals(dbMapTable.getTableName())) {
dbMapTable.setName(newValue);
dbMapTable.setTableName(newValue);
}
}
}
// update expression
for (IExternalMapTable output : newOutputTables) {
if (output instanceof ExternalDbMapTable) {
List<ExternalDbMapEntry> entries = ((ExternalDbMapTable) output).getMetadataTableEntries();
for (ExternalDbMapEntry entry : entries) {
String expression = entry.getExpression();
if (expression != null && !"".equals(expression.trim())) {
//$NON-NLS-1$
//$NON-NLS-1$
int index = expression.lastIndexOf(".");
// at least "a.b"
if (index > 0) {
String connectionName = expression.substring(0, index);
if (oldValue.equals(connectionName)) {
entry.setExpression(newValue + expression.substring(index, expression.length()));
}
}
}
}
}
}
}
use of org.talend.designer.dbmap.external.data.ExternalDbMapEntry in project tdi-studio-se by Talend.
the class InputTable method initFromExternalData.
/*
* (non-Javadoc)
*
* @see
* org.talend.designer.dbmap.model.table.AbstractInOutTable#initFromExternalData(org.talend.designer.dbmap.external
* .data.ExternalMapperTable)
*/
@Override
public void initFromExternalData(ExternalDbMapTable externalMapperTable) {
boolean isAliasTable = externalMapperTable != null && externalMapperTable.getAlias() != null;
if (isAliasTable) {
// dbmap table is alias
setMetadataTable(connection.getTable().clone());
} else if (connection != null) {
// dbmap table references a physical table
setMetadataTable(connection.getTable());
}
super.initFromExternalData(externalMapperTable);
List<IMetadataColumn> columns = getMetadataTable().getListColumns();
Map<String, ExternalDbMapEntry> nameToPerTabEntry = new HashMap<String, ExternalDbMapEntry>();
if (externalMapperTable != null && externalMapperTable.getMetadataTableEntries() != null) {
for (ExternalDbMapEntry perTableEntry : externalMapperTable.getMetadataTableEntries()) {
nameToPerTabEntry.put(perTableEntry.getName(), perTableEntry);
}
}
ArrayList<IMetadataColumn> columnsToRemove = new ArrayList<IMetadataColumn>();
for (IMetadataColumn column : columns) {
InputColumnTableEntry inputEntry = (InputColumnTableEntry) getNewTableEntry(column);
ExternalDbMapEntry externalMapperTableEntry = nameToPerTabEntry.get(inputEntry.getMetadataColumn().getLabel());
// Entry match with current column
if (externalMapperTableEntry != null) {
fillInputEntry(inputEntry, externalMapperTableEntry);
nameToPerTabEntry.remove(externalMapperTableEntry.getName());
}
if (externalMapperTableEntry != null || !isAliasTable) {
dataMapTableEntries.add(inputEntry);
} else {
columnsToRemove.add(column);
}
}
columns.removeAll(columnsToRemove);
// create unmatching entries
for (ExternalDbMapEntry perTableEntry : nameToPerTabEntry.values()) {
MetadataColumn column = new MetadataColumn();
column.setLabel(perTableEntry.getName());
InputColumnTableEntry inputEntry = (InputColumnTableEntry) getNewTableEntry(column);
ExternalDbMapEntry externalMapperTableEntry = nameToPerTabEntry.get(inputEntry.getMetadataColumn().getLabel());
fillInputEntry(inputEntry, externalMapperTableEntry);
dataMapTableEntries.add(inputEntry);
columns.add(column);
}
if (externalMapperTable != null) {
joinType = mapperManager.getCurrentLanguage().getJoin(externalMapperTable.getJoinType());
if (joinType == null) {
joinType = mapperManager.getCurrentLanguage().getAvailableJoins()[0];
}
alias = externalMapperTable.getAlias();
tableName = externalMapperTable.getTableName() != null ? externalMapperTable.getTableName() : connection.getName();
}
}
use of org.talend.designer.dbmap.external.data.ExternalDbMapEntry in project tdi-studio-se by Talend.
the class OutputTable method initFromExternalData.
@Override
public void initFromExternalData(ExternalDbMapTable externalMapperTable) {
super.initFromExternalData(externalMapperTable);
List<IMetadataColumn> columns = this.metadataTable.getListColumns();
Map<String, ExternalDbMapEntry> nameToPerTabEntry = new HashMap<String, ExternalDbMapEntry>();
if (externalMapperTable != null && externalMapperTable.getMetadataTableEntries() != null) {
for (ExternalDbMapEntry perTableEntry : externalMapperTable.getMetadataTableEntries()) {
nameToPerTabEntry.put(perTableEntry.getName(), perTableEntry);
}
}
for (IMetadataColumn column : columns) {
AbstractInOutTableEntry columnEntry = getNewTableEntry(column);
ExternalDbMapEntry externalMapperTableEntry = nameToPerTabEntry.get(columnEntry.getMetadataColumn().getLabel());
// Entry match with current column
if (externalMapperTableEntry != null) {
columnEntry.setExpression(externalMapperTableEntry.getExpression());
}
dataMapTableEntries.add(columnEntry);
}
if (externalMapperTable != null) {
List<ExternalDbMapEntry> externalWhereConstraintTableEntries = externalMapperTable.getCustomWhereConditionsEntries();
if (externalWhereConstraintTableEntries != null) {
for (ExternalDbMapEntry entry : externalWhereConstraintTableEntries) {
FilterTableEntry whereFilterTableEntry = new FilterTableEntry(this, entry.getName(), entry.getExpression(), FilterTableEntry.WHERE_FILTER);
// mapperManager.getProblemsManager().checkProblemsForTableEntry(filterTableEntry, false);
addWhereFilterEntry(whereFilterTableEntry);
}
}
List<ExternalDbMapEntry> externalOtherConstraintTableEntries = externalMapperTable.getCustomOtherConditionsEntries();
if (externalOtherConstraintTableEntries != null) {
for (ExternalDbMapEntry entry : externalOtherConstraintTableEntries) {
FilterTableEntry otherFilterTableEntry = new FilterTableEntry(this, entry.getName(), entry.getExpression(), FilterTableEntry.OTHER_FILTER);
// mapperManager.getProblemsManager().checkProblemsForTableEntry(filterTableEntry, false);
addOtherFilterEntry(otherFilterTableEntry);
}
}
}
}
use of org.talend.designer.dbmap.external.data.ExternalDbMapEntry in project tdi-studio-se by Talend.
the class VarsTable method initFromExternalData.
public void initFromExternalData(ExternalDbMapTable externalMapperTable) {
super.initFromExternalData(externalMapperTable);
if (externalMapperTable != null) {
List<ExternalDbMapEntry> metadataTableEntries = externalMapperTable.getMetadataTableEntries();
if (metadataTableEntries != null) {
for (ExternalDbMapEntry externalMapperTableEntry : metadataTableEntries) {
IColumnEntry varTableEntry = new VarTableEntry(this, externalMapperTableEntry.getName(), externalMapperTableEntry.getExpression(), externalMapperTableEntry.getOperator());
// mapperManager.getProblemsManager().checkProblemsForTableEntry(varTableEntry, false);
addColumnEntry(varTableEntry);
}
}
} else {
setMinimized(true);
}
}
Aggregations