use of org.talend.core.model.process.IConnection in project tdi-studio-se by Talend.
the class XMLMapperHelper method hasAllInOne.
private static boolean hasAllInOne(final INode xmlMapperNode) {
boolean hasAllInOne = false;
List<? extends IConnection> outConnections = (List<? extends IConnection>) xmlMapperNode.getOutgoingConnections();
XmlMapData xmlMapData = (XmlMapData) ElementParameterParser.getObjectValueXMLTree(xmlMapperNode);
if (xmlMapData != null && outConnections != null && outConnections.size() > 0) {
List<OutputXmlTree> outputTables = xmlMapData.getOutputTrees();
HashMap<String, IConnection> hNameToConnection = new HashMap<String, IConnection>();
for (IConnection connection : outConnections) {
hNameToConnection.put(connection.getName(), connection);
}
for (OutputXmlTree outputTable : outputTables) {
String tableName = outputTable.getName();
IConnection connection = hNameToConnection.get(tableName);
if (connection == null) {
continue;
}
if (outputTable.isAllInOne()) {
hasAllInOne = true;
break;
}
}
}
return hasAllInOne;
}
use of org.talend.core.model.process.IConnection in project tdi-studio-se by Talend.
the class ConnectionCreateCommandTest method executeSimpleInputToSimpleOutput2.
/**
* simple input to simple output with metadata already existing and schema auto propagate.
*/
private ConnectionCreateCommand executeSimpleInputToSimpleOutput2() {
IProcess2 process = getFakeProcess();
Node simpleInputNode = NodeTestCreator.createSimpleInputNode(process);
// simple tests only since it's simply using the class ConnectionManager which already have JUnits.
List<Object> args = new ArrayList<Object>();
args.add(simpleInputNode.getUniqueName());
//$NON-NLS-1$
args.add("connectionName");
simpleInputNode.getMetadataList().clear();
IMetadataTable table1 = createSimpleMetadata1();
table1.setTableName(simpleInputNode.getUniqueName());
table1.setLabel(simpleInputNode.getUniqueName());
//$NON-NLS-1$
table1.setAttachedConnector("FLOW");
simpleInputNode.getMetadataList().add(table1);
// set null, the command should take the schema from the component directly
args.add(null);
//$NON-NLS-1$
ConnectionCreateCommand ccc = new ConnectionCreateCommand(simpleInputNode, "FLOW", args);
ConnectionCreateCommand.setCreatingConnection(true);
Node simpleOutputNode = NodeTestCreator.createSimpleOutputNode(process);
simpleOutputNode.getMetadataList().clear();
IMetadataTable table2 = createSimpleMetadata2();
table2.setTableName(simpleOutputNode.getUniqueName());
table2.setLabel(simpleOutputNode.getUniqueName());
//$NON-NLS-1$
table2.setAttachedConnector("FLOW");
simpleOutputNode.getMetadataList().add(table2);
ccc.setTarget(simpleOutputNode);
ccc.execute();
assertEquals(simpleInputNode.getOutgoingConnections().size(), 1);
assertEquals(simpleOutputNode.getIncomingConnections().size(), 1);
assertEquals(simpleOutputNode.getMetadataList().size(), 1);
IMetadataTable outputMetadata = simpleOutputNode.getMetadataList().get(0);
// metadata should have been propagated automatically
assertMetadataIsSame(table1, outputMetadata);
IConnection connection = simpleInputNode.getOutgoingConnections().get(0);
assertEquals(simpleOutputNode.getIncomingConnections().get(0), connection);
assertEquals(connection.getSource(), simpleInputNode);
assertEquals(connection.getTarget(), simpleOutputNode);
assertEquals(connection.getMetaName(), simpleInputNode.getUniqueName());
//$NON-NLS-1$
assertEquals(connection.getConnectorName(), "FLOW");
//$NON-NLS-1$
INodeConnector inputConnector = simpleInputNode.getConnectorFromName("FLOW");
//$NON-NLS-1$
INodeConnector outputConnector = simpleOutputNode.getConnectorFromName("FLOW");
assertEquals(inputConnector.getCurLinkNbOutput(), 1);
assertEquals(outputConnector.getCurLinkNbInput(), 1);
return ccc;
}
use of org.talend.core.model.process.IConnection in project tdi-studio-se by Talend.
the class FOXMain method createUI.
/**
* create UI".
*
* @param parent
* @return
*/
public void createUI(Composite parent) {
if (!connector.istWriteXMLField() && !connector.istMDMOutput()) {
IConnection inConn = null;
List<? extends IConnection> incomeConnections = connector.getIncomingConnections();
if (connector.istFileOutputMSXML() && incomeConnections.size() < 1) {
MessageBox message = new MessageBox(parent.getShell(), SWT.APPLICATION_MODAL | SWT.OK);
//$NON-NLS-1$
message.setText(Messages.getString("FOXMain.inputlinkError"));
//$NON-NLS-1$
message.setMessage(Messages.getString("FOXMain.noInputLink"));
if (message.open() == SWT.OK) {
((Shell) parent).close();
return;
}
for (IConnection conn : incomeConnections) {
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("FOXMain.0"));
//$NON-NLS-1$
messageBox.setMessage(Messages.getString("FOXMain.1"));
if (messageBox.open() == SWT.OK) {
((Shell) parent).close();
return;
}
}
}
}
}
// add by wzhang. for component tFileOutputMSXML
if (connector.istFileOutputMSXML()) {
generatorUI = new FOXMultiSchemaUI(parent, foxManager);
} else {
generatorUI = new FOXUI(parent, foxManager);
}
generatorUI.init();
}
use of org.talend.core.model.process.IConnection in project tdi-studio-se by Talend.
the class MultiFOXManager method getMultiSchemaData.
public List<IMetadataTable> getMultiSchemaData() {
List<IMetadataTable> schemas = new ArrayList<IMetadataTable>();
List<? extends IConnection> incomingConnections = NodeUtil.getIncomingConnections(foxComponent, IConnectionCategory.FLOW);
for (IConnection connection : incomingConnections) {
connection.getMetadataTable().setLabel(connection.getUniqueName());
schemas.add(connection.getMetadataTable());
}
return schemas;
}
use of org.talend.core.model.process.IConnection in project tdi-studio-se by Talend.
the class FOXManager method initModel.
public void initModel() {
IMetadataTable metadataTable = foxComponent.getMetadataTable();
if (metadataTable == null) {
metadataTable = new MetadataTable();
}
String componentName = foxComponent.getComponent().getName();
// if (componentName.equals("tWriteXMLField")) { //$NON-NLS-1$ //$NON-NLS-2$
IConnection inConn = null;
for (IConnection conn : foxComponent.getIncomingConnections()) {
if ((conn.getLineStyle().equals(EConnectionType.FLOW_MAIN)) || (conn.getLineStyle().equals(EConnectionType.FLOW_REF))) {
inConn = conn;
break;
}
}
if (inConn != null) {
metadataTable = inConn.getMetadataTable();
}
// }
treeData = new ArrayList<FOXTreeNode>();
FOXTreeNode rootNode = null;
FOXTreeNode current = null;
FOXTreeNode temp = null;
FOXTreeNode mainNode = null;
String mainPath = null;
String currentPath = null;
String defaultValue = null;
int nodeOrder = 0;
boolean haveOrder = true;
// build root tree
List<Map<String, String>> rootTable = (List<Map<String, String>>) foxComponent.getTableList(FileOutputXMLComponent.ROOT);
for (Map<String, String> rootMap : rootTable) {
String newPath = rootMap.get(FileOutputXMLComponent.PATH);
defaultValue = rootMap.get(FileOutputXMLComponent.VALUE);
String orderValue = rootMap.get(FileOutputXMLComponent.ORDER);
if (orderValue == null || "".equals(orderValue)) {
haveOrder = false;
}
if (haveOrder) {
nodeOrder = Integer.valueOf(rootMap.get(FileOutputXMLComponent.ORDER)).intValue();
}
if (rootMap.get(FileOutputXMLComponent.ATTRIBUTE).equals("attri")) {
//$NON-NLS-1$
temp = new Attribute(newPath);
temp.setDefaultValue(defaultValue);
temp.setAttribute(true);
current.addChild(temp);
} else if (rootMap.get(FileOutputXMLComponent.ATTRIBUTE).equals("ns")) {
//$NON-NLS-1$
temp = new NameSpaceNode(newPath);
temp.setDefaultValue(defaultValue);
temp.setNameSpace(true);
current.addChild(temp);
} else {
temp = this.addElement(current, currentPath, newPath, defaultValue);
if (rootNode == null) {
rootNode = temp;
}
if (rootMap.get(FileOutputXMLComponent.ATTRIBUTE).equals("main")) {
//$NON-NLS-1$
temp.setMain(true);
mainNode = temp;
mainPath = newPath;
}
current = temp;
currentPath = newPath;
}
if (haveOrder) {
temp.setOrder(nodeOrder);
}
String columnName = rootMap.get(FileOutputXMLComponent.COLUMN);
if (columnName != null && columnName.length() > 0) {
temp.setColumn(metadataTable.getColumn(columnName));
}
}
// build group tree
current = mainNode;
currentPath = mainPath;
boolean isFirst = true;
List<Map<String, String>> groupTable = (List<Map<String, String>>) foxComponent.getTableList(FileOutputXMLComponent.GROUP);
for (Map<String, String> groupMap : groupTable) {
String newPath = groupMap.get(FileOutputXMLComponent.PATH);
defaultValue = groupMap.get(FileOutputXMLComponent.VALUE);
String orderValue = groupMap.get(FileOutputXMLComponent.ORDER);
if (orderValue == null || "".equals(orderValue)) {
haveOrder = false;
}
if (haveOrder) {
nodeOrder = Integer.valueOf(groupMap.get(FileOutputXMLComponent.ORDER)).intValue();
}
if (groupMap.get(FileOutputXMLComponent.ATTRIBUTE).equals("attri")) {
//$NON-NLS-1$
temp = new Attribute(newPath);
temp.setDefaultValue(defaultValue);
temp.setAttribute(true);
current.addChild(temp);
} else if (groupMap.get(FileOutputXMLComponent.ATTRIBUTE).equals("ns")) {
//$NON-NLS-1$
temp = new NameSpaceNode(newPath);
temp.setDefaultValue(defaultValue);
temp.setNameSpace(true);
current.addChild(temp);
} else {
temp = this.addElement(current, currentPath, newPath, defaultValue);
if (groupMap.get(FileOutputXMLComponent.ATTRIBUTE).equals("main")) {
//$NON-NLS-1$
temp.setMain(true);
mainNode = temp;
mainPath = newPath;
}
if (isFirst) {
temp.setGroup(true);
isFirst = false;
}
current = temp;
currentPath = newPath;
}
if (haveOrder) {
temp.setOrder(nodeOrder);
}
String columnName = groupMap.get(FileOutputXMLComponent.COLUMN);
if (columnName != null && columnName.length() > 0) {
temp.setColumn(metadataTable.getColumn(columnName));
}
}
// build loop tree
current = mainNode;
currentPath = mainPath;
isFirst = true;
List<Map<String, String>> loopTable = (List<Map<String, String>>) foxComponent.getTableList(FileOutputXMLComponent.LOOP);
for (Map<String, String> loopMap : loopTable) {
String newPath = loopMap.get(FileOutputXMLComponent.PATH);
defaultValue = loopMap.get(FileOutputXMLComponent.VALUE);
String orderValue = loopMap.get(FileOutputXMLComponent.ORDER);
if (orderValue == null || "".equals(orderValue)) {
haveOrder = false;
}
if (haveOrder) {
nodeOrder = Integer.valueOf(loopMap.get(FileOutputXMLComponent.ORDER)).intValue();
}
if (loopMap.get(FileOutputXMLComponent.ATTRIBUTE).equals("attri")) {
//$NON-NLS-1$
temp = new Attribute(newPath);
temp.setDefaultValue(defaultValue);
temp.setAttribute(true);
current.addChild(temp);
} else if (loopMap.get(FileOutputXMLComponent.ATTRIBUTE).equals("ns")) {
//$NON-NLS-1$
temp = new NameSpaceNode(newPath);
temp.setDefaultValue(defaultValue);
temp.setNameSpace(true);
current.addChild(temp);
} else {
temp = this.addElement(current, currentPath, newPath, defaultValue);
if (rootNode == null) {
rootNode = temp;
}
if (loopMap.get(FileOutputXMLComponent.ATTRIBUTE).equals("main")) {
//$NON-NLS-1$
temp.setMain(true);
}
if (isFirst) {
temp.setLoop(true);
isFirst = false;
}
current = temp;
currentPath = newPath;
}
if (haveOrder) {
temp.setOrder(nodeOrder);
}
String columnName = loopMap.get(FileOutputXMLComponent.COLUMN);
if (columnName != null && columnName.length() > 0) {
temp.setColumn(metadataTable.getColumn(columnName));
}
}
if (rootNode == null) {
//$NON-NLS-1$
rootNode = new Element("rootTag");
}
rootNode.setParent(null);
if (haveOrder) {
orderNode(rootNode);
}
treeData.add(rootNode);
}
Aggregations