Search in sources :

Example 1 with GenericConnParamName

use of org.talend.metadata.managment.ui.utils.GenericConnParamName in project tdi-studio-se by Talend.

the class GenericContextUtil method setPropertiesForContextMode.

public static void setPropertiesForContextMode(String prefixName, Connection connection, Set<IConnParamName> paramSet) {
    if (connection == null) {
        return;
    }
    if (connection instanceof GenericConnection) {
        GenericConnection genericConn = (GenericConnection) connection;
        ComponentProperties componentProperties = getComponentProperties(genericConn);
        String originalVariableName = prefixName + ConnectionContextHelper.LINE;
        String genericVariableName = null;
        for (IConnParamName param : paramSet) {
            if (param instanceof GenericConnParamName) {
                GenericConnParamName genericParam = (GenericConnParamName) param;
                String paramVarName = genericParam.getContextVar();
                genericVariableName = originalVariableName + paramVarName;
                matchContextForAttribues(componentProperties, genericParam, genericVariableName);
            }
        }
        updateComponentProperties(genericConn, componentProperties);
    }
}
Also used : ComponentProperties(org.talend.components.api.properties.ComponentProperties) GenericConnParamName(org.talend.metadata.managment.ui.utils.GenericConnParamName) IConnParamName(org.talend.metadata.managment.ui.model.IConnParamName) GenericConnection(org.talend.repository.generic.model.genericMetadata.GenericConnection)

Example 2 with GenericConnParamName

use of org.talend.metadata.managment.ui.utils.GenericConnParamName in project tdi-studio-se by Talend.

the class GenericContextUtilTest method createConnParamName.

private GenericConnParamName createConnParamName(String paramName) {
    GenericConnParamName connParamName = new GenericConnParamName();
    connParamName.setName(paramName);
    connParamName.setContextVar(getValidContextVarName(paramName));
    return connParamName;
}
Also used : GenericConnParamName(org.talend.metadata.managment.ui.utils.GenericConnParamName)

Example 3 with GenericConnParamName

use of org.talend.metadata.managment.ui.utils.GenericConnParamName in project tdi-studio-se by Talend.

the class GenericContextHandler method getContextParams.

@Override
public Set<IConnParamName> getContextParams() {
    Set<IConnParamName> contextParams = new HashSet<>();
    if (parameters != null) {
        for (IElementParameter param : parameters) {
            if (param instanceof GenericElementParameter) {
                GenericElementParameter genericElementParameter = (GenericElementParameter) param;
                if (genericElementParameter.isSupportContext()) {
                    GenericConnParamName connParamName = new GenericConnParamName();
                    String paramName = genericElementParameter.getName();
                    connParamName.setName(paramName);
                    connParamName.setContextVar(getValidContextVarName(paramName));
                    contextParams.add(connParamName);
                }
            }
        }
    }
    return contextParams;
}
Also used : GenericConnParamName(org.talend.metadata.managment.ui.utils.GenericConnParamName) GenericElementParameter(org.talend.designer.core.generic.model.GenericElementParameter) IElementParameter(org.talend.core.model.process.IElementParameter) IConnParamName(org.talend.metadata.managment.ui.model.IConnParamName) HashSet(java.util.HashSet)

Example 4 with GenericConnParamName

use of org.talend.metadata.managment.ui.utils.GenericConnParamName in project tdi-studio-se by Talend.

the class GenericContextUtil method matchContextForAttribues.

private static void matchContextForAttribues(ComponentProperties componentProperties, IConnParamName param, String genericVariableName) {
    GenericConnParamName genericParam = (GenericConnParamName) param;
    String paramName = genericParam.getName();
    String paramValue = ContextParameterUtils.getNewScriptCode(genericVariableName, ECodeLanguage.JAVA);
    setPropertyValue(componentProperties, paramName, paramValue, true);
}
Also used : GenericConnParamName(org.talend.metadata.managment.ui.utils.GenericConnParamName)

Example 5 with GenericConnParamName

use of org.talend.metadata.managment.ui.utils.GenericConnParamName in project tdi-studio-se by Talend.

the class GenericContextUtil method setPropertiesForExistContextMode.

public static void setPropertiesForExistContextMode(Connection connection, Set<IConnParamName> paramSet, Map<ContextItem, List<ConectionAdaptContextVariableModel>> adaptMap) {
    if (connection == null) {
        return;
    }
    if (connection instanceof GenericConnection) {
        GenericConnection genericConn = (GenericConnection) connection;
        ComponentProperties componentProperties = getComponentProperties(genericConn);
        ContextItem currentContext = null;
        for (IConnParamName param : paramSet) {
            if (param instanceof GenericConnParamName) {
                String genericVariableName = null;
                GenericConnParamName genericParam = (GenericConnParamName) param;
                if (adaptMap != null && adaptMap.size() > 0) {
                    for (Map.Entry<ContextItem, List<ConectionAdaptContextVariableModel>> entry : adaptMap.entrySet()) {
                        currentContext = entry.getKey();
                        List<ConectionAdaptContextVariableModel> modelList = entry.getValue();
                        for (ConectionAdaptContextVariableModel model : modelList) {
                            if (model.getValue().equals(genericParam.getName())) {
                                genericVariableName = model.getName();
                                break;
                            }
                        }
                    }
                }
                if (genericVariableName != null) {
                    genericVariableName = getCorrectVariableName(currentContext, genericVariableName, genericParam);
                    matchContextForAttribues(componentProperties, genericParam, genericVariableName);
                }
            }
        }
        updateComponentProperties(genericConn, componentProperties);
    }
}
Also used : ContextItem(org.talend.core.model.properties.ContextItem) ComponentProperties(org.talend.components.api.properties.ComponentProperties) GenericConnParamName(org.talend.metadata.managment.ui.utils.GenericConnParamName) IConnParamName(org.talend.metadata.managment.ui.model.IConnParamName) ArrayList(java.util.ArrayList) List(java.util.List) GenericConnection(org.talend.repository.generic.model.genericMetadata.GenericConnection) ConectionAdaptContextVariableModel(org.talend.core.ui.context.model.table.ConectionAdaptContextVariableModel) Map(java.util.Map)

Aggregations

GenericConnParamName (org.talend.metadata.managment.ui.utils.GenericConnParamName)6 IConnParamName (org.talend.metadata.managment.ui.model.IConnParamName)4 ComponentProperties (org.talend.components.api.properties.ComponentProperties)3 GenericConnection (org.talend.repository.generic.model.genericMetadata.GenericConnection)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 JavaType (org.talend.core.model.metadata.types.JavaType)1 IContextParameter (org.talend.core.model.process.IContextParameter)1 IElementParameter (org.talend.core.model.process.IElementParameter)1 ContextItem (org.talend.core.model.properties.ContextItem)1 ConectionAdaptContextVariableModel (org.talend.core.ui.context.model.table.ConectionAdaptContextVariableModel)1 GenericElementParameter (org.talend.designer.core.generic.model.GenericElementParameter)1