use of org.talend.designer.core.model.utils.emf.talendfile.ContextType in project tdi-studio-se by Talend.
the class JobContextUtils method getContextsMap.
public static Map<String, Map<String, String>> getContextsMap(ProcessItem processItem) {
Map<String, Map<String, String>> contextValues = new HashMap<String, Map<String, String>>();
ProcessType process = processItem.getProcess();
if (process != null) {
EList<?> context = process.getContext();
if (context != null) {
for (Object next : context) {
ContextType ct = (ContextType) next;
Map<String, String> contextParams = getContextParametersMapByGroup(processItem, ct.getName());
contextValues.put(ct.getName(), contextParams);
}
}
}
return contextValues;
}
use of org.talend.designer.core.model.utils.emf.talendfile.ContextType in project tdi-studio-se by Talend.
the class AddContextCommentValueMigrationTaskTest method testAddContextCommentValue.
@Test
public void testAddContextCommentValue() {
testItem.setDefaultContext("Default");
String[] paramNames = new String[] { "p1", "p2", "p3" };
String[] comments = new String[] { "c1", "c2", "c3" };
// context item before 5.6.1
// comments always in the first group of context no matter it's default group or not.
testItem.getContext().add(createContextType("DEV", paramNames, comments));
testItem.getContext().add(createContextType("PROD", paramNames, null));
testItem.getContext().add(createContextType("Default", paramNames, null));
AddContextCommentValueMigrationTask task = new AddContextCommentValueMigrationTask();
task.execute(testItem);
List<ContextType> contexts = testItem.getContext();
for (ContextType context : contexts) {
List<ContextParameterType> params = context.getContextParameter();
for (ContextParameterType param : params) {
if (param.getName().equals("p1")) {
assertEquals("c1", param.getComment());
} else if (param.getName().equals("p2")) {
assertEquals("c2", param.getComment());
} else if (param.getName().equals("p3")) {
assertEquals("c3", param.getComment());
}
}
}
}
use of org.talend.designer.core.model.utils.emf.talendfile.ContextType in project tdi-studio-se by Talend.
the class AddContextCommentValueMigrationTaskTest method createContextType.
private ContextType createContextType(String contextName, String[] paramNames, String[] comments) {
ContextType context = TalendFileFactory.eINSTANCE.createContextType();
context.setName(contextName);
for (int i = 0; i < paramNames.length; i++) {
ContextParameterType param = TalendFileFactory.eINSTANCE.createContextParameterType();
param.setName(paramNames[i]);
param.setType("id_String");
if (comments != null) {
param.setComment(comments[i]);
} else {
param.setComment("");
}
context.getContextParameter().add(param);
}
return context;
}
use of org.talend.designer.core.model.utils.emf.talendfile.ContextType in project tdi-studio-se by Talend.
the class FixUnevenItemContextParametersMigrationTaskTest method testChangeParamOrder.
@Test
public void testChangeParamOrder() {
testItem.getProcess().setDefaultContext("Default");
String[] paramNames = new String[] { "new1", "new2", "new3" };
// default
ContextType defaultGroup = createContextType("Default", paramNames);
testItem.getProcess().getContext().add(defaultGroup);
// group1
paramNames = new String[] { "new3", "new2", "new1" };
ContextType group1 = createContextType("group1", paramNames);
testItem.getProcess().getContext().add(group1);
FixUnevenItemContextParametersMigrationTask migration = new FixUnevenItemContextParametersMigrationTask();
migration.execute(testItem);
Assert.assertEquals(((ContextParameterType) group1.getContextParameter().get(0)).getName(), "new1");
Assert.assertEquals(((ContextParameterType) group1.getContextParameter().get(1)).getName(), "new2");
Assert.assertEquals(((ContextParameterType) group1.getContextParameter().get(2)).getName(), "new3");
}
use of org.talend.designer.core.model.utils.emf.talendfile.ContextType in project tdi-studio-se by Talend.
the class FixUnevenItemContextParametersMigrationTaskTest method testChangeType.
@Test
public void testChangeType() {
testItem.getProcess().setDefaultContext("Default");
String[] paramNames = new String[] { "new1", "new2", "new3" };
// default
ContextType defaultGroup = createContextType("Default", paramNames);
testItem.getProcess().getContext().add(defaultGroup);
((ContextParameterType) defaultGroup.getContextParameter().get(0)).setType("id_Date");
// group1
ContextType group1 = createContextType("group1", paramNames);
testItem.getProcess().getContext().add(group1);
FixUnevenItemContextParametersMigrationTask migration = new FixUnevenItemContextParametersMigrationTask();
migration.execute(testItem);
Assert.assertEquals(((ContextParameterType) group1.getContextParameter().get(0)).getType(), "id_Date");
}
Aggregations