use of org.talend.designer.core.model.components.NodeConnector in project tdi-studio-se by Talend.
the class JobletUtil method createTriggerConnector.
private void createTriggerConnector(List<INodeConnector> listConnector, INode jobletNode) {
IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
if (service != null) {
List<INode> triggerNodes = service.getTriggerNodes(jobletNode.getJobletNode());
for (INode node : triggerNodes) {
// INode node = jobletNode;
EConnectionType triggerConnType = service.getTriggerNodeConnType(node);
if (triggerConnType == null) {
continue;
}
boolean isInput = service.isTriggerInputNode(node);
INodeConnector nodeConnector = null;
String name = node.getUniqueName();
nodeConnector = new NodeConnector(jobletNode);
nodeConnector.setName(name);
nodeConnector.setBaseSchema(triggerConnType.getName());
nodeConnector.setBuiltIn(true);
nodeConnector.setMaxLinkOutput(isInput ? 0 : 1);
nodeConnector.setMinLinkOutput(0);
nodeConnector.setMaxLinkInput(isInput ? 1 : 0);
nodeConnector.setMinLinkInput(0);
String displayName = conDisplayName(node.getLabel(), name);
//$NON-NLS-1$ //$NON-NLS-2$
nodeConnector.setLinkName(triggerConnType.getDefaultLinkName() + " (" + displayName + ")");
//$NON-NLS-1$ //$NON-NLS-2$
nodeConnector.setMenuName(triggerConnType.getDefaultMenuName() + " (" + displayName + ")");
nodeConnector.setDefaultConnectionType(triggerConnType);
nodeConnector.addConnectionProperty(triggerConnType, triggerConnType.getRGB(), triggerConnType.getDefaultLineStyle());
listConnector.add(nodeConnector);
}
}
}
use of org.talend.designer.core.model.components.NodeConnector in project tdi-studio-se by Talend.
the class Component method createConnectors.
@Override
public List<INodeConnector> createConnectors(INode parentNode) {
List<INodeConnector> listConnector = new ArrayList<>();
ComponentProperties componentProperties = ComponentsUtils.getComponentProperties(getName());
Set<? extends Connector> inputConnectors = componentProperties.getPossibleConnectors(false);
if (inputConnectors.isEmpty()) {
INodeConnector connector = null;
connector = addStandardType(listConnector, EConnectionType.FLOW_MAIN, parentNode);
connector.setMaxLinkInput(0);
connector.setMaxLinkOutput(0);
} else {
for (Connector connector : inputConnectors) {
addGenericType(listConnector, EConnectionType.FLOW_MAIN, connector.getName(), parentNode, componentProperties, false);
}
}
Set<? extends Connector> outputConnectors = componentProperties.getPossibleConnectors(true);
List<? extends Connector> sortedOutputConnectors = new ArrayList<>(outputConnectors);
sortedOutputConnectors.sort(new Comparator<Connector>() {
@Override
public int compare(Connector o1, Connector o2) {
if (Connector.MAIN_NAME.equals(o1.getName())) {
return -1;
}
if (Connector.MAIN_NAME.equals(o2.getName())) {
return 1;
}
return 0;
}
});
for (Connector connector : sortedOutputConnectors) {
EConnectionType type = EConnectionType.FLOW_MAIN;
if (Connector.REJECT_NAME.equals(connector.getName())) {
type = EConnectionType.REJECT;
}
addGenericType(listConnector, type, connector.getName(), parentNode, componentProperties, true);
}
addStandardType(listConnector, EConnectionType.RUN_IF, parentNode);
addStandardType(listConnector, EConnectionType.ON_COMPONENT_OK, parentNode);
addStandardType(listConnector, EConnectionType.ON_COMPONENT_ERROR, parentNode);
addStandardType(listConnector, EConnectionType.ON_SUBJOB_OK, parentNode);
addStandardType(listConnector, EConnectionType.ON_SUBJOB_ERROR, parentNode);
Set<ConnectorTopology> topologies = componentDefinition.getSupportedConnectorTopologies();
createIterateConnectors(topologies, listConnector, parentNode);
for (int i = 0; i < EConnectionType.values().length; i++) {
EConnectionType currentType = EConnectionType.values()[i];
if ((currentType == EConnectionType.FLOW_REF) || (currentType == EConnectionType.FLOW_MERGE)) {
continue;
}
boolean exists = false;
for (INodeConnector curNodeConn : listConnector) {
if (curNodeConn.getDefaultConnectionType().equals(currentType)) {
exists = true;
if (currentType == EConnectionType.FLOW_MAIN) {
curNodeConn.addConnectionProperty(EConnectionType.FLOW_REF, EConnectionType.FLOW_REF.getRGB(), EConnectionType.FLOW_REF.getDefaultLineStyle());
curNodeConn.addConnectionProperty(EConnectionType.FLOW_MERGE, EConnectionType.FLOW_MERGE.getRGB(), EConnectionType.FLOW_MERGE.getDefaultLineStyle());
}
}
}
if (!exists) {
// will add by default all connectors not defined in
NodeConnector nodeConnector = new NodeConnector(parentNode);
nodeConnector.setDefaultConnectionType(currentType);
nodeConnector.setName(currentType.getName());
nodeConnector.setBaseSchema(currentType.getName());
nodeConnector.addConnectionProperty(currentType, currentType.getRGB(), currentType.getDefaultLineStyle());
nodeConnector.setLinkName(currentType.getDefaultLinkName());
nodeConnector.setMenuName(currentType.getDefaultMenuName());
if ((currentType == EConnectionType.PARALLELIZE) || (currentType == EConnectionType.SYNCHRONIZE)) {
nodeConnector.setMaxLinkInput(1);
} else {
nodeConnector.setMaxLinkInput(0);
}
nodeConnector.setMaxLinkOutput(0);
nodeConnector.setMinLinkInput(0);
nodeConnector.setMinLinkOutput(0);
listConnector.add(nodeConnector);
}
}
return listConnector;
}
use of org.talend.designer.core.model.components.NodeConnector in project tdi-studio-se by Talend.
the class AbstractFakeComponent method createBaseConnector.
protected NodeConnector createBaseConnector(INode node, EConnectionType currentType) {
NodeConnector nodeConnector = new NodeConnector(node);
nodeConnector.setDefaultConnectionType(currentType);
// set the default values
nodeConnector.setLinkName(currentType.getDefaultLinkName());
nodeConnector.setMenuName(currentType.getDefaultMenuName());
RGB rgb = currentType.getRGB();
Integer lineStyle = currentType.getDefaultLineStyle();
String connectorName = currentType.getName();
nodeConnector.setName(connectorName);
//$NON-NLS-1$
nodeConnector.setMenuName(connectorName + ".MENU");
//$NON-NLS-1$
nodeConnector.setLinkName(connectorName + ".LINK");
nodeConnector.addConnectionProperty(currentType, rgb, lineStyle);
nodeConnector.setBaseSchema(nodeConnector.getName());
return nodeConnector;
}
use of org.talend.designer.core.model.components.NodeConnector in project tdi-studio-se by Talend.
the class SimpleInputComponent method createConnectors.
@Override
public List<? extends INodeConnector> createConnectors(INode node) {
List<NodeConnector> nodeConnectors = new ArrayList<NodeConnector>();
NodeConnector connector = createBaseConnector(node, EConnectionType.FLOW_MAIN);
connector.setMaxLinkInput(0);
connector.setMaxLinkOutput(1);
nodeConnectors.add(connector);
return nodeConnectors;
}
use of org.talend.designer.core.model.components.NodeConnector in project tdi-studio-se by Talend.
the class UpdateELTMapComponentCommandTest method before.
@Before
public void before() {
Process process = new Process(createProperty());
sourceNode = new Node(sourceComponent, process);
INodeConnector connector = new NodeConnector(sourceNode);
connector.setName("connector");
connector.setDefaultConnectionType(EConnectionType.FLOW_MAIN);
ArrayList<INodeConnector> connectors = new ArrayList<INodeConnector>();
connectors.add(connector);
sourceNode.setListConnector(connectors);
targetNode = new Node(targetComponent, process);
DbMapComponent component = new DbMapComponent();
targetNode.setExternalNode(component);
connection = new Connection(sourceNode, targetNode, EConnectionType.FLOW_MAIN, "connector", "meta", "oldTable", true);
inputs = (List<ExternalDbMapTable>) targetNode.getExternalData().getInputTables();
ExternalDbMapTable input = new ExternalDbMapTable();
input.setName("oldTable");
input.setTableName("oldTable");
inputs.add(input);
outputs = (List<ExternalDbMapTable>) targetNode.getExternalData().getOutputTables();
ExternalDbMapTable output = new ExternalDbMapTable();
ExternalDbMapEntry entry = new ExternalDbMapEntry("oldTable", "oldTable.column");
output.setMetadataTableEntries(new ArrayList<ExternalDbMapEntry>());
output.getMetadataTableEntries().add(entry);
outputs.add(output);
}
Aggregations