use of org.talend.designer.core.model.components.NodeConnector in project tdi-studio-se by Talend.
the class NodeTest method testGetNodeConnectorsShowIf1FlowConnector.
@Test
public void testGetNodeConnectorsShowIf1FlowConnector() {
Process process = new Process(new FakePropertyImpl());
IComponent sourceCom = ComponentsFactoryProvider.getInstance().get("tMysqlInput", ComponentCategory.CATEGORY_4_DI.getName());
Node node = new Node(sourceCom, process);
// create node connector for test
List<INodeConnector> listConnector = new ArrayList<>();
NodeConnector connector = new NodeConnector(node);
connector.setDefaultConnectionType(EConnectionType.FLOW_MAIN);
connector.setName(EConnectionType.FLOW_MAIN.getName());
connector.setMaxLinkOutput(1);
connector.setShowIf("SHOW_FLOW_CONNECTOR == 'true'");
listConnector.add(connector);
node.setListConnector(listConnector);
// create a test param with default value 'false'
IElementParameter param = addShowIfParam(node);
Assert.assertNull(node.getConnectorFromName(EConnectionType.FLOW_MAIN.getName()));
Assert.assertNull(node.getConnectorFromType(EConnectionType.FLOW_MAIN));
Assert.assertEquals(node.getConnectorsFromType(EConnectionType.FLOW_MAIN).size(), 0);
// make connector show if to 'true'
param.setValue(true);
Assert.assertNotNull(node.getConnectorFromName(EConnectionType.FLOW_MAIN.getName()));
Assert.assertNotNull(node.getConnectorFromType(EConnectionType.FLOW_MAIN));
Assert.assertEquals(node.getConnectorsFromType(EConnectionType.FLOW_MAIN).size(), 1);
}
use of org.talend.designer.core.model.components.NodeConnector in project tdi-studio-se by Talend.
the class NodeTest method testGetNodeConnectorsShowIf2FlowConnector.
@Test
public void testGetNodeConnectorsShowIf2FlowConnector() {
Process process = new Process(new FakePropertyImpl());
IComponent sourceCom = ComponentsFactoryProvider.getInstance().get("tMysqlInput", ComponentCategory.CATEGORY_4_DI.getName());
Node node = new Node(sourceCom, process);
// create node connector for test
List<INodeConnector> listConnector = new ArrayList<>();
NodeConnector connector1 = new NodeConnector(node);
connector1.setDefaultConnectionType(EConnectionType.FLOW_MAIN);
connector1.setName(EConnectionType.FLOW_MAIN.getName());
connector1.setMaxLinkOutput(1);
listConnector.add(connector1);
connector1.setShowIf("SHOW_FLOW_CONNECTOR == 'true'");
NodeConnector connector2 = new NodeConnector(node);
connector2.setDefaultConnectionType(EConnectionType.FLOW_MAIN);
connector2.setName(EConnectionType.FLOW_MAIN.getName());
connector2.setMaxLinkInput(-1);
connector2.setMaxLinkOutput(-1);
connector2.setShowIf("SHOW_FLOW_CONNECTOR == 'false'");
listConnector.add(connector2);
node.setListConnector(listConnector);
// create a test param with default value 'false'
IElementParameter param = addShowIfParam(node);
Assert.assertTrue(node.getConnectorFromName(EConnectionType.FLOW_MAIN.getName()) == connector2);
Assert.assertTrue(node.getConnectorFromType(EConnectionType.FLOW_MAIN) == connector2);
Assert.assertEquals(node.getConnectorsFromType(EConnectionType.FLOW_MAIN).size(), 1);
// make connector show if to 'true'
param.setValue(true);
Assert.assertTrue(node.getConnectorFromName(EConnectionType.FLOW_MAIN.getName()) == connector1);
Assert.assertTrue(node.getConnectorFromType(EConnectionType.FLOW_MAIN) == connector1);
Assert.assertEquals(node.getConnectorsFromType(EConnectionType.FLOW_MAIN).size(), 1);
// connector with same name should have the same current input/output
connector1.setCurLinkNbInput(10);
connector1.setCurLinkNbOutput(100);
Assert.assertEquals(connector1.getCurLinkNbInput(), 10);
Assert.assertEquals(connector1.getCurLinkNbOutput(), 100);
Assert.assertEquals(connector2.getCurLinkNbInput(), 10);
Assert.assertEquals(connector2.getCurLinkNbOutput(), 100);
}
use of org.talend.designer.core.model.components.NodeConnector in project tdi-studio-se by Talend.
the class ValidationRulesUtil method createRejectConnector.
public static INodeConnector createRejectConnector(INode node) {
INodeConnector rejectConnector = null;
if (isHasValidationRule(node)) {
boolean isHas = false;
for (INodeConnector connector : node.getListConnector()) {
if ("VALIDATION_REJECT".equals(connector.getName())) {
//$NON-NLS-1$
isHas = true;
}
}
if (!isHas) {
rejectConnector = new NodeConnector(node);
rejectConnector.setDefaultConnectionType(EConnectionType.FLOW_MAIN);
//$NON-NLS-1$
rejectConnector.setLinkName("Validation Reject");
//$NON-NLS-1$
rejectConnector.setMenuName("Validation Reject");
rejectConnector.setMaxLinkInput(-1);
rejectConnector.setMinLinkInput(0);
rejectConnector.setMaxLinkOutput(1);
rejectConnector.setMinLinkOutput(0);
rejectConnector.setBuiltIn(false);
rejectConnector.setMultiSchema(false);
rejectConnector.setMergeAllowDifferentSchema(false);
//$NON-NLS-1$
rejectConnector.setName("VALIDATION_REJECT");
RGB rgb = new RGB(243, 99, 0);
rejectConnector.addConnectionProperty(EConnectionType.FLOW_MAIN, rgb, 2);
rejectConnector.getConnectionProperty(EConnectionType.FLOW_MAIN).setRGB(rgb);
//$NON-NLS-1$
rejectConnector.setBaseSchema("FLOW");
rejectConnector.addConnectionProperty(EConnectionType.FLOW_REF, rgb, 2);
rejectConnector.addConnectionProperty(EConnectionType.FLOW_MERGE, rgb, 2);
if (!node.getListConnector().contains(rejectConnector)) {
((List<INodeConnector>) node.getListConnector()).add(rejectConnector);
}
}
}
return rejectConnector;
}
use of org.talend.designer.core.model.components.NodeConnector in project tdi-studio-se by Talend.
the class Component method addStandardType.
/**
* Add default connector type, if not already defined by component.
*
* @param listConnector
* @param type
* @param parentNode
* @return
*/
private INodeConnector addStandardType(List<INodeConnector> listConnector, EConnectionType type, INode parentNode) {
NodeConnector nodeConnector = new NodeConnector(parentNode);
nodeConnector.setName(type.getName());
nodeConnector.setBaseSchema(type.getName());
nodeConnector.setDefaultConnectionType(type);
nodeConnector.setLinkName(type.getDefaultLinkName());
nodeConnector.setMenuName(type.getDefaultMenuName());
nodeConnector.addConnectionProperty(type, type.getRGB(), type.getDefaultLineStyle());
listConnector.add(nodeConnector);
return nodeConnector;
}
use of org.talend.designer.core.model.components.NodeConnector in project tdi-studio-se by Talend.
the class JobletUtil method createConnectors.
public List<INodeConnector> createConnectors(INode node, IProcess2 process) {
List<INodeConnector> listConnector = new ArrayList<INodeConnector>();
if (process == null) {
return listConnector;
}
if (process.getProperty().getItem() instanceof JobletProcessItem) {
JobletProcess jobletProcess = ((JobletProcessItem) process.getProperty().getItem()).getJobletProcess();
EList<JobletNode> jobletLinks = jobletProcess.getJobletNodes();
INodeConnector nodeConnector;
int nbInput = 0;
int nbOutput = 0;
int jobletNbInput = 0;
for (JobletNode jNode : jobletLinks) {
if (jNode.isInput()) {
jobletNbInput++;
}
}
boolean multipleInput = jobletNbInput > 1;
for (JobletNode jNode : jobletLinks) {
String name = ComponentUtilities.getNodeUniqueName(jNode);
if (jNode.isTrigger()) {
// createTriggerConnector(listConnector, node);
} else {
if (jNode.isInput()) {
if (multipleInput) {
nodeConnector = new NodeConnector(node);
nodeConnector.setName(name);
nodeConnector.setBaseSchema(EConnectionType.FLOW_MAIN.getName());
nodeConnector.setDefaultConnectionType(EConnectionType.FLOW_MAIN);
nodeConnector.setMaxLinkInput(1);
nodeConnector.setMinLinkInput(0);
nodeConnector.setMaxLinkOutput(0);
nodeConnector.setMinLinkOutput(0);
listConnector.add(nodeConnector);
}
nbInput++;
} else {
nodeConnector = new NodeConnector(node);
nodeConnector.setName(name);
nodeConnector.setBaseSchema(EConnectionType.FLOW_MAIN.getName());
nodeConnector.setBuiltIn(true);
nodeConnector.setMaxLinkOutput(1);
nodeConnector.setMinLinkOutput(1);
// achen modify to fix bug 6205
String displayName = getDisplayName(jNode);
nodeConnector.setLinkName("Joblet " + name);
nodeConnector.setMenuName(displayName);
nodeConnector.setDefaultConnectionType(EConnectionType.FLOW_MAIN);
nodeConnector.addConnectionProperty(EConnectionType.FLOW_MAIN, EConnectionType.FLOW_MAIN.getRGB(), EConnectionType.FLOW_MAIN.getDefaultLineStyle());
nodeConnector.addConnectionProperty(EConnectionType.FLOW_REF, EConnectionType.FLOW_REF.getRGB(), EConnectionType.FLOW_REF.getDefaultLineStyle());
nodeConnector.addConnectionProperty(EConnectionType.FLOW_MERGE, EConnectionType.FLOW_MERGE.getRGB(), EConnectionType.FLOW_MERGE.getDefaultLineStyle());
listConnector.add(nodeConnector);
nbOutput++;
}
}
}
}
createTriggerConnector(listConnector, node);
return listConnector;
}
Aggregations