use of org.talend.designer.core.model.utils.emf.talendfile.impl.ContextParameterTypeImpl in project tdi-studio-se by Talend.
the class ComponentChooseDialog method createContext.
private void createContext(List<Object> sourceList) {
if (sourceList.size() == 0) {
return;
}
boolean created = false;
for (Object source : sourceList) {
if (source instanceof RepositoryNode) {
RepositoryNode sourceNode = (RepositoryNode) source;
Item item = sourceNode.getObject().getProperty().getItem();
if (item instanceof ContextItem) {
ContextItem contextItem = (ContextItem) item;
EList context = contextItem.getContext();
Set<String> contextSet = new HashSet<String>();
Iterator iterator = context.iterator();
while (iterator.hasNext()) {
Object obj = iterator.next();
if (obj instanceof ContextTypeImpl) {
EList contextParameters = ((ContextTypeImpl) obj).getContextParameter();
Iterator contextParas = contextParameters.iterator();
while (contextParas.hasNext()) {
ContextParameterTypeImpl contextParameterType = (ContextParameterTypeImpl) contextParas.next();
String name = contextParameterType.getName();
contextSet.add(name);
}
}
}
IEditorInput editorInput = editor.getEditorInput();
if (editorInput instanceof JobEditorInput) {
JobEditorInput jobInput = (JobEditorInput) editorInput;
IProcess2 process = jobInput.getLoadedProcess();
IContextManager contextManager = process.getContextManager();
List<IContext> listContext = contextManager.getListContext();
// context group will reflect absolutely if no context variable in contextViewer
// if (!ConnectionContextHelper.containsVariable(contextManager)) {
// for bug 15608
// ConnectionContextHelper.addContextVarForJob(process, contextItem, contextManager);
// ConnectionContextHelper.checkAndAddContextsVarDND(contextItem, contextManager);
Set<String> addedVars = ConnectionContextHelper.checkAndAddContextVariables(contextItem, contextSet, process.getContextManager(), false);
if (addedVars != null && !addedVars.isEmpty() && !ConnectionContextHelper.isAddContextVar(contextItem, contextManager, contextSet)) {
// show
Map<String, Set<String>> addedVarsMap = new HashMap<String, Set<String>>();
addedVarsMap.put(item.getProperty().getLabel(), contextSet);
if (ConnectionContextHelper.showContextdialog(process, contextItem, process.getContextManager(), addedVarsMap, contextSet)) {
created = true;
}
}
// } else {
// Set<String> addedContext = ConnectionContextHelper.checkAndAddContextVariables(contextItem,
// contextSet, contextManager, false);
// if (addedContext != null && addedContext.size() > 0) {
// ConnectionContextHelper.addContextVarForJob(process, contextItem, contextSet);
// created = true;
// }
// }
}
}
}
}
if (created) {
RepositoryPlugin.getDefault().getDesignerCoreService().switchToCurContextsView();
}
}
use of org.talend.designer.core.model.utils.emf.talendfile.impl.ContextParameterTypeImpl in project tdi-studio-se by Talend.
the class JSONConnectionContextHelper method setContextParameter.
public static void setContextParameter(ContextItem item, Set<String> addedVars, List<ContextParameterTypeImpl> list, JobContext jobContext) {
for (ContextParameterTypeImpl contextImpl : list) {
for (String var : addedVars) {
if (var.equals(contextImpl.getName())) {
JobContextParameter contextParam = new JobContextParameter();
ContextUtils.updateParameter(contextImpl, contextParam);
contextParam.setSource(item.getProperty().getId());
contextParam.setContext(jobContext);
jobContext.getContextParameterList().add(contextParam);
}
}
}
}
use of org.talend.designer.core.model.utils.emf.talendfile.impl.ContextParameterTypeImpl in project tdi-studio-se by Talend.
the class JSONConnectionContextHelper method checkAndAddContextVariables.
public static void checkAndAddContextVariables(ContextItem item, IContextManager contextManager, Set<String> addedVars, Set<String> contextGoupNameSet) {
EList context = item.getContext();
Map<String, List<ContextParameterTypeImpl>> map = new HashMap<String, List<ContextParameterTypeImpl>>();
Iterator iterator = context.iterator();
while (iterator.hasNext()) {
Object obj = iterator.next();
if (obj instanceof ContextTypeImpl) {
ContextTypeImpl contextTypeImpl = (ContextTypeImpl) obj;
String name = contextTypeImpl.getName();
EList contextParameters = contextTypeImpl.getContextParameter();
Iterator contextParas = contextParameters.iterator();
List<ContextParameterTypeImpl> list = new ArrayList<ContextParameterTypeImpl>();
while (contextParas.hasNext()) {
ContextParameterTypeImpl contextParameterType = (ContextParameterTypeImpl) contextParas.next();
list.add(contextParameterType);
}
map.put(name, list);
}
}
if (map.isEmpty()) {
return;
}
String defaultContextName = item.getDefaultContext();
Set<String> existGroupNameSet = new HashSet<String>();
for (IContext con : contextManager.getListContext()) {
existGroupNameSet.add(con.getName());
}
if (contextGoupNameSet.isEmpty()) {
contextGoupNameSet.add(defaultContextName);
}
Set<String> alreadyUpdateNameSet = new HashSet<String>();
for (String key : map.keySet()) {
for (String groupName : contextGoupNameSet) {
boolean isExtraGroup = false;
for (String existGroup : existGroupNameSet) {
if (key.equals(existGroup)) {
isExtraGroup = true;
alreadyUpdateNameSet.add(existGroup);
break;
}
}
if (key.equals(groupName) || isExtraGroup) {
List<ContextParameterTypeImpl> list = map.get(key);
JobContext jobContext = new JobContext(key);
boolean isExistContext = false;
if (isExtraGroup) {
for (IContext con : contextManager.getListContext()) {
if (key.equals(con.getName())) {
if (con instanceof JobContext) {
jobContext = (JobContext) con;
isExistContext = true;
break;
}
}
}
}
setContextParameter(item, addedVars, list, jobContext);
if (!isExistContext) {
contextManager.getListContext().add(jobContext);
}
break;
}
}
}
// if job context group is not in current add's context,then update context group value to default group value
existGroupNameSet.removeAll(alreadyUpdateNameSet);
List<ContextParameterTypeImpl> list = map.get(defaultContextName);
if (list == null) {
return;
}
}
use of org.talend.designer.core.model.utils.emf.talendfile.impl.ContextParameterTypeImpl in project tdi-studio-se by Talend.
the class JSONConnectionContextHelper method checkAndAddContextsVarDND.
/**
*
* wzhang Comment method "checkAndAddContextsVarDND".
*
* @param item
* @param contextManager
*/
public static void checkAndAddContextsVarDND(ContextItem item, IContextManager contextManager) {
EList context = item.getContext();
Map<String, List<ContextParameterTypeImpl>> map = new HashMap<String, List<ContextParameterTypeImpl>>();
Iterator iterator = context.iterator();
while (iterator.hasNext()) {
Object obj = iterator.next();
if (obj instanceof ContextTypeImpl) {
ContextTypeImpl contextTypeImpl = (ContextTypeImpl) obj;
String name = contextTypeImpl.getName();
EList contextParameters = contextTypeImpl.getContextParameter();
Iterator contextParas = contextParameters.iterator();
List<ContextParameterTypeImpl> list = new ArrayList<ContextParameterTypeImpl>();
while (contextParas.hasNext()) {
ContextParameterTypeImpl contextParameterType = (ContextParameterTypeImpl) contextParas.next();
list.add(contextParameterType);
}
map.put(name, list);
}
}
if (map.isEmpty()) {
return;
}
contextManager.getListContext().clear();
String defaultContextName = item.getDefaultContext();
for (String key : map.keySet()) {
List<ContextParameterTypeImpl> list = map.get(key);
JobContext jobContext = new JobContext(key);
for (ContextParameterTypeImpl contextImpl : list) {
JobContextParameter contextParam = new JobContextParameter();
ContextUtils.updateParameter(contextImpl, contextParam);
contextParam.setSource(item.getProperty().getId());
contextParam.setContext(jobContext);
jobContext.getContextParameterList().add(contextParam);
}
contextManager.getListContext().add(jobContext);
if (key.equals(defaultContextName)) {
contextManager.setDefaultContext(jobContext);
}
}
}
use of org.talend.designer.core.model.utils.emf.talendfile.impl.ContextParameterTypeImpl in project tesb-studio-se by Talend.
the class CamelEditorDropTargetListener method createContext.
private void createContext() {
if (selectSourceList.size() == 0) {
return;
}
boolean created = false;
for (Object source : selectSourceList) {
if (source instanceof RepositoryNode) {
RepositoryNode sourceNode = (RepositoryNode) source;
Item item = sourceNode.getObject().getProperty().getItem();
if (item instanceof ContextItem) {
ContextItem contextItem = (ContextItem) item;
EList context = contextItem.getContext();
Set<String> contextSet = new HashSet<String>();
Iterator iterator = context.iterator();
while (iterator.hasNext()) {
Object obj = iterator.next();
if (obj instanceof ContextTypeImpl) {
EList contextParameters = ((ContextTypeImpl) obj).getContextParameter();
Iterator contextParas = contextParameters.iterator();
while (contextParas.hasNext()) {
ContextParameterTypeImpl contextParameterType = (ContextParameterTypeImpl) contextParas.next();
String name = contextParameterType.getName();
contextSet.add(name);
}
}
}
IEditorInput editorInput = editor.getEditorInput();
if (editorInput instanceof JobEditorInput) {
JobEditorInput jobInput = (JobEditorInput) editorInput;
IProcess2 process = jobInput.getLoadedProcess();
IContextManager contextManager = process.getContextManager();
List<IContext> listContext = contextManager.getListContext();
Set<String> addedVars = ConnectionContextHelper.checkAndAddContextVariables(contextItem, contextSet, process.getContextManager(), false);
if (addedVars != null && !addedVars.isEmpty() && !ConnectionContextHelper.isAddContextVar(contextItem, contextManager, contextSet)) {
// show
Map<String, Set<String>> addedVarsMap = new HashMap<String, Set<String>>();
addedVarsMap.put(item.getProperty().getLabel(), contextSet);
if (ConnectionContextHelper.showContextdialog(process, contextItem, process.getContextManager(), addedVarsMap, contextSet)) {
created = true;
}
} else {
//$NON-NLS-1$
MessageDialog.openInformation(//$NON-NLS-1$
editor.getEditorSite().getShell(), //$NON-NLS-1$
"Adding Context", //$NON-NLS-1$
"Context \"" + contextItem.getProperty().getDisplayName() + "\" already exist.");
}
}
}
}
}
if (created) {
RepositoryPlugin.getDefault().getDesignerCoreService().switchToCurContextsView();
}
}
Aggregations