Search in sources :

Example 1 with EParamName

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

the class JSONConnectionContextHelper method getConnVariables.

private static Set<String> getConnVariables(ConnectionItem connectionItem, Set<IConnParamName> paramSet) {
    if (connectionItem == null) {
        return null;
    }
    Set<String> varList = new HashSet<String>();
    Iterator<IConnParamName> paramIt = paramSet.iterator();
    while (paramIt.hasNext()) {
        Object param = paramIt.next();
        if (param instanceof EDBParamName) {
            varList.add(((EDBParamName) param).name());
        }
        if (param instanceof EFileParamName) {
            varList.add(((EFileParamName) param).name());
        }
        if (param instanceof EParamName) {
            varList.add(((EParamName) param).name());
        }
    }
    return varList;
}
Also used : EParamName(org.talend.metadata.managment.ui.utils.OtherConnectionContextUtils.EParamName) EDBParamName(org.talend.metadata.managment.ui.utils.DBConnectionContextUtils.EDBParamName) EFileParamName(org.talend.metadata.managment.ui.utils.FileConnectionContextUtils.EFileParamName) IConnParamName(org.talend.metadata.managment.ui.model.IConnParamName) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) HashSet(java.util.HashSet)

Example 2 with EParamName

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

the class JSONConnectionContextHelper method setJSONFilePropertiesForExistContextMode.

static void setJSONFilePropertiesForExistContextMode(JSONFileConnection jsonConn, Set<IConnParamName> paramSet, Map<ContextItem, List<ConectionAdaptContextVariableModel>> map) {
    if (jsonConn == null) {
        return;
    }
    String jsonVariableName = null;
    for (IConnParamName param : paramSet) {
        if (param instanceof EParamName) {
            EParamName jsonParam = (EParamName) param;
            if (map != null && map.size() > 0) {
                for (Map.Entry<ContextItem, List<ConectionAdaptContextVariableModel>> entry : map.entrySet()) {
                    List<ConectionAdaptContextVariableModel> modelList = entry.getValue();
                    for (ConectionAdaptContextVariableModel model : modelList) {
                        if (model.getValue().equals(jsonParam.name())) {
                            jsonVariableName = model.getName();
                            break;
                        }
                    }
                }
            }
            if (jsonConn.isInputModel()) {
                switch(jsonParam) {
                    case FilePath:
                        jsonConn.setJSONFilePath(ContextParameterUtils.getNewScriptCode(jsonVariableName, LANGUAGE));
                        break;
                    case Encoding:
                        jsonConn.setEncoding(ContextParameterUtils.getNewScriptCode(jsonVariableName, LANGUAGE));
                        break;
                    case XPathQuery:
                        EList schema = jsonConn.getSchema();
                        if (schema != null) {
                            if (schema.get(0) instanceof JSONXPathLoopDescriptor) {
                                JSONXPathLoopDescriptor descriptor = (JSONXPathLoopDescriptor) schema.get(0);
                                descriptor.setAbsoluteXPathQuery(ContextParameterUtils.getNewScriptCode(jsonVariableName, LANGUAGE));
                            }
                        }
                    default:
                }
            } else {
                if (jsonParam.equals(EParamName.OutputFilePath)) {
                    jsonConn.setOutputFilePath(ContextParameterUtils.getNewScriptCode(jsonVariableName, LANGUAGE));
                }
            }
        }
    }
}
Also used : ContextItem(org.talend.core.model.properties.ContextItem) JSONXPathLoopDescriptor(org.talend.repository.model.json.JSONXPathLoopDescriptor) EParamName(org.talend.metadata.managment.ui.utils.OtherConnectionContextUtils.EParamName) EList(org.eclipse.emf.common.util.EList) IConnParamName(org.talend.metadata.managment.ui.model.IConnParamName) List(java.util.List) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) ConectionAdaptContextVariableModel(org.talend.core.ui.context.model.table.ConectionAdaptContextVariableModel) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

IConnParamName (org.talend.metadata.managment.ui.model.IConnParamName)2 EParamName (org.talend.metadata.managment.ui.utils.OtherConnectionContextUtils.EParamName)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 EList (org.eclipse.emf.common.util.EList)1 ContextItem (org.talend.core.model.properties.ContextItem)1 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)1 ConectionAdaptContextVariableModel (org.talend.core.ui.context.model.table.ConectionAdaptContextVariableModel)1 EDBParamName (org.talend.metadata.managment.ui.utils.DBConnectionContextUtils.EDBParamName)1 EFileParamName (org.talend.metadata.managment.ui.utils.FileConnectionContextUtils.EFileParamName)1 JSONXPathLoopDescriptor (org.talend.repository.model.json.JSONXPathLoopDescriptor)1