Search in sources :

Example 1 with ColumnNameChangedExt

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;
}
Also used : ColumnNameChanged(org.talend.core.model.metadata.ColumnNameChanged) INode(org.talend.core.model.process.INode) ColumnNameChangedExt(org.talend.core.model.metadata.ColumnNameChangedExt) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode)

Example 2 with ColumnNameChangedExt

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());
                }
            }
        }
    }
}
Also used : ColumnNameChanged(org.talend.core.model.metadata.ColumnNameChanged) ColumnNameChangedExt(org.talend.core.model.metadata.ColumnNameChangedExt) JSONObject(org.talend.utils.json.JSONObject) List(java.util.List) ArrayList(java.util.ArrayList)

Example 3 with ColumnNameChangedExt

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());
            }
        }
    }
}
Also used : ColumnNameChanged(org.talend.core.model.metadata.ColumnNameChanged) ColumnNameChangedExt(org.talend.core.model.metadata.ColumnNameChangedExt)

Aggregations

ColumnNameChanged (org.talend.core.model.metadata.ColumnNameChanged)3 ColumnNameChangedExt (org.talend.core.model.metadata.ColumnNameChangedExt)3 ArrayList (java.util.ArrayList)1 List (java.util.List)1 INode (org.talend.core.model.process.INode)1 Node (org.talend.designer.core.ui.editor.nodes.Node)1 JSONObject (org.talend.utils.json.JSONObject)1