use of org.talend.core.model.metadata.ColumnNameChangedExt in project tdi-studio-se by Talend.
the class ColumnListController method isUpdateColumnEnable.
private static boolean isUpdateColumnEnable(IElementParameter param, List<ColumnNameChanged> columnsChanged, IElementParameter tmpParam) {
ColumnNameChanged tmpChanged = columnsChanged.get(0);
if (tmpChanged instanceof ColumnNameChangedExt && param.getElement() instanceof Node) {
INode curNode = (Node) param.getElement();
INode changedNode = ((ColumnNameChangedExt) tmpChanged).getChangedNode();
if (changedNode == null) {
return false;
}
if (changedNode != curNode) {
// if not update current node, only update the prev/lookup column list
if (tmpParam.getFieldType() == EParameterFieldType.PREV_COLUMN_LIST || tmpParam.getFieldType() == EParameterFieldType.LOOKUP_COLUMN_LIST) {
return true;
}
} else {
// if update current node, only update the self column list
if (tmpParam.getFieldType() == EParameterFieldType.COLUMN_LIST) {
return true;
}
}
} else {
// only update self column list
if (tmpParam.getFieldType() == EParameterFieldType.COLUMN_LIST) {
return true;
}
}
return false;
}
use of org.talend.core.model.metadata.ColumnNameChangedExt in project tdi-studio-se by Talend.
the class ColumnListController method syncNodePropertiesTableColumns.
/**
*
* DOC ggu Comment method "syncNodePropertiesTableColumns".<BR/>
*
* synchronize COLUMN_LIST, PREV_COLUMN_LIST, LOOKUP_COLUMN_LIST in table. <br/>
* when modified column name of schema .
*
* @param param
* @param columnsChanged
* @param columnNameList
* @param tmpParam
*/
private static void syncNodePropertiesTableColumns(IElementParameter param, List<ColumnNameChanged> columnsChanged, String[] columnNameList, IElementParameter tmpParam) {
if (columnsChanged == null || columnsChanged.isEmpty()) {
return;
}
if (columnNameList == null || columnNameList.length == 0) {
return;
}
if (!isUpdateColumnEnable(param, columnsChanged, tmpParam)) {
return;
}
//$NON-NLS-1$
String componentUniqueName = "";
//$NON-NLS-1$
String preRowLookup = "";
if (tmpParam.getFieldType() == EParameterFieldType.LOOKUP_COLUMN_LIST && columnNameList[0].indexOf(".") > 0) {
//$NON-NLS-1$
ColumnNameChanged tmpChanged = columnsChanged.get(0);
if (tmpChanged instanceof ColumnNameChangedExt) {
//$NON-NLS-1$
componentUniqueName = ((ColumnNameChangedExt) tmpChanged).getChangedNode().getUniqueName() + ".";
//$NON-NLS-1$
preRowLookup = columnNameList[0].substring(0, columnNameList[0].indexOf(".") + 1);
}
}
for (ColumnNameChanged colChanged : columnsChanged) {
String newName = preRowLookup + colChanged.getNewName();
ColumnNameChanged theChanged = null;
for (String element : columnNameList) {
if (newName.equals(element)) {
theChanged = colChanged;
break;
}
}
// found
if (theChanged != null && param.getValue() != null) {
for (Map<String, Object> currentLine : (List<Map<String, Object>>) param.getValue()) {
if (currentLine.get(tmpParam.getName()).equals(componentUniqueName + theChanged.getOldName())) {
currentLine.put(tmpParam.getName(), componentUniqueName + theChanged.getNewName());
}
}
}
}
}
use of org.talend.core.model.metadata.ColumnNameChangedExt in project tdi-studio-se by Talend.
the class ColumnListController method syncNodePropertiesColumns.
/**
*
* DOC ggu Comment method "syncNodePropertiesColumns".<BR/>
*
* synchronize COLUMN_LIST, PREV_COLUMN_LIST, LOOKUP_COLUMN_LIST
*
* @param param
* @param columnsChanged
* @param columnNameList
*/
private static void syncNodePropertiesColumns(IElementParameter param, List<ColumnNameChanged> columnsChanged, String[] columnNameList) {
if (columnsChanged == null || columnsChanged.isEmpty()) {
return;
}
if (columnNameList == null || columnNameList.length == 0) {
return;
}
if (!isUpdateColumnEnable(param, columnsChanged, param)) {
return;
}
//$NON-NLS-1$
String componentUniqueName = "";
//$NON-NLS-1$
String preRowLookup = "";
if (param.getFieldType() == EParameterFieldType.LOOKUP_COLUMN_LIST && columnNameList[0].indexOf(".") > 0) {
//$NON-NLS-1$
ColumnNameChanged tmpChanged = columnsChanged.get(0);
if (tmpChanged instanceof ColumnNameChangedExt) {
//$NON-NLS-1$
componentUniqueName = ((ColumnNameChangedExt) tmpChanged).getChangedNode().getUniqueName() + ".";
//$NON-NLS-1$
preRowLookup = columnNameList[0].substring(0, columnNameList[0].indexOf(".") + 1);
}
}
for (ColumnNameChanged colChanged : columnsChanged) {
boolean found = false;
String newName = preRowLookup + colChanged.getNewName();
for (String element : columnNameList) {
if (newName.equals(element)) {
found = true;
break;
}
}
if (found) {
if (param.getValue().equals(componentUniqueName + colChanged.getOldName())) {
param.setValue(componentUniqueName + colChanged.getNewName());
}
}
}
}
Aggregations