use of org.talend.core.model.process.IConnection in project tdi-studio-se by Talend.
the class NodesSubTree method buildCamelSubTree.
/**
* Build the SubSubTrees..
*
* @param nodes
*/
private void buildCamelSubTree(INode node, boolean breakWhenMerge) {
if (DEBUG) {
System.out.print(node.getUniqueName());
}
for (IConnection connection : node.getOutgoingCamelSortedConnections()) {
if (connection.getTarget().isActivate()) {
buildCamelSubTree(connection.getTarget(), breakWhenMerge);
}
}
visitedNodesMainCode.put(node, 0);
nodes.add(node);
}
use of org.talend.core.model.process.IConnection in project tdi-studio-se by Talend.
the class AlfrescoOutputManager method createUI.
/**
* Checks the connections and creates the UI (a dialog actually)
*
* @param parent
* @return
*/
public AlfrescoModelDialog createUI(Composite parent) {
IConnection inConn = null;
AbstractNode connector = this.alfrescoOutputComponent;
for (IConnection conn : connector.getIncomingConnections()) {
if ((conn.getLineStyle().equals(EConnectionType.FLOW_MAIN)) || (conn.getLineStyle().equals(EConnectionType.FLOW_REF))) {
inConn = conn;
break;
}
}
if (inConn != null) {
if (!inConn.getMetadataTable().sameMetadataAs(connector.getMetadataList().get(0))) {
MessageBox messageBox = new MessageBox(parent.getShell(), SWT.APPLICATION_MODAL | SWT.OK);
//$NON-NLS-1$
messageBox.setText(Messages.getString("AlfrescoOutputManager.schemaError.title"));
//$NON-NLS-1$
messageBox.setMessage(Messages.getString("AlfrescoOutputManager.schemaError.msg"));
if (messageBox.open() == SWT.OK) {
((Shell) parent).close();
return null;
}
}
}
// first load the model :
try {
// NB. or when modelManager is created
modelManager.load();
} catch (AlfrescoOutputException aoex) {
MessageDialog.openError(new Shell(Display.getCurrent(), SWT.APPLICATION_MODAL), Messages.getString("AlfrescoOutputManager.failedLoadModel"), //$NON-NLS-1$
aoex.getMessage());
modelManager.clear();
}
// then create and open the model dialog :
AlfrescoModelDialog alfrescoModelDialog = new AlfrescoModelDialog(parent.getShell(), this);
alfrescoModelDialog.open();
// NB. this dialog is non-blocking ; model save is done in its okPressed()
return alfrescoModelDialog;
}
use of org.talend.core.model.process.IConnection in project tdi-studio-se by Talend.
the class GenericElementParameter method updateSchema.
private void updateSchema() {
IElement element = this.getElement();
if (element instanceof Node) {
Node node = (Node) element;
List<INodeConnector> connectors = node.getConnectorsFromType(EConnectionType.FLOW_MAIN);
for (INodeConnector connector : connectors) {
if (connector instanceof GenericNodeConnector) {
Connector componentConnector = ((GenericNodeConnector) connector).getComponentConnector();
Schema schema = null;
schema = getRootProperties().getSchema(componentConnector, ((GenericNodeConnector) connector).isOutput());
IMetadataTable mainTable = node.getMetadataFromConnector(connector.getName());
if (schema != null && mainTable != null) {
MetadataTable metadataTable = MetadataToolAvroHelper.convertFromAvro(schema);
IMetadataTable newTable = MetadataToolHelper.convert(metadataTable);
if (!mainTable.sameMetadataAs(newTable) || !newTable.sameMetadataAs(mainTable)) {
mainTable.setListColumns(newTable.getListColumns());
List<IElementParameter> schemaParameters = node.getElementParametersFromField(EParameterFieldType.SCHEMA_REFERENCE);
updateSchemaParameters(schemaParameters, connector.getName(), schema);
if (this.askPropagate == null && node.getOutgoingConnections().size() != 0) {
boolean hasPropagation = false;
for (IConnection connection : node.getOutgoingConnections()) {
if (connector.getName().equals(connection.getConnectorName())) {
if (isSchemaPropagated(connection.getTarget())) {
hasPropagation = true;
break;
}
}
}
if (hasPropagation) {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
askPropagate = ChangeMetadataCommand.askPropagate();
}
});
}
}
if (this.askPropagate != null && this.askPropagate) {
for (IConnection connection : node.getOutgoingConnections()) {
if (connector.getName().equals(connection.getConnectorName())) {
INode target = connection.getTarget();
if (!isSchemaPropagated(target)) {
continue;
}
ChangeMetadataCommand cmd = new ChangeMetadataCommand(target, null, null, newTable, null);
cmd.setPropagate(true);
IProcess process = node.getProcess();
if (process instanceof org.talend.designer.core.ui.editor.process.Process) {
CommandStack commandStack = ((org.talend.designer.core.ui.editor.process.Process) process).getCommandStack();
commandStack.execute(cmd);
}
}
}
}
}
}
}
}
this.askPropagate = null;
}
}
use of org.talend.core.model.process.IConnection in project tdi-studio-se by Talend.
the class CreateComponentOnLinkHelper method setupTMap.
public static void setupTMap(Node node) {
if (!GlobalServiceRegister.getDefault().isServiceRegistered(IDesignerMapperService.class)) {
return;
}
IConnection inputConnection = node.getIncomingConnections().get(0);
IConnection outputConnection = node.getOutgoingConnections().get(0);
if (outputConnection.getMetadataTable() != null && inputConnection.getMetadataTable() != null) {
outputConnection.getMetadataTable().setListColumns(inputConnection.getMetadataTable().clone(false).getListColumns());
((Process) node.getProcess()).checkProcess();
}
if ("tMap".equals(node.getComponent().getName())) {
IDesignerMapperService service = (IDesignerMapperService) GlobalServiceRegister.getDefault().getService(IDesignerMapperService.class);
service.createAutoMappedNode(node, inputConnection, outputConnection);
}
}
use of org.talend.core.model.process.IConnection in project tdi-studio-se by Talend.
the class UpdateNodeParameterCommand method syncSchemaForTMap.
private void syncSchemaForTMap(Node node) {
for (IConnection conn : node.getOutgoingConnections()) {
if (conn.getLineStyle() == EConnectionType.FLOW_MAIN) {
IMetadataTable metadataTable = null;
for (IMetadataTable table : node.getMetadataList()) {
if (table.getTableName() != null && table.getTableName().equals(conn.getMetadataTable().getTableName())) {
metadataTable = table;
}
}
if (metadataTable != null) {
Node target = (Node) conn.getTarget();
IElementParameter schemaTypeParam = target.getElementParameterFromField(EParameterFieldType.SCHEMA_TYPE);
if (schemaTypeParam == null) {
schemaTypeParam = target.getElementParameterFromField(EParameterFieldType.SCHEMA_REFERENCE);
}
if (schemaTypeParam != null) {
ChangeMetadataCommand cmd = new ChangeMetadataCommand(target, schemaTypeParam, null, metadataTable);
cmd.setRepositoryMode(true);
cmd.execute(true);
}
}
}
}
}
Aggregations