use of org.talend.core.model.process.IConnection in project tdi-studio-se by Talend.
the class TableByRowController method init.
// when delete the input link should delete the data in the model
private void init(IElement elem, final IElementParameter param) {
if (elem instanceof Node) {
List<IConnection> listConnection = (List<IConnection>) ((Node) elem).getInputs();
List<String> names = new ArrayList<String>();
for (IConnection con : listConnection) {
names.add(con.getName());
}
List<Map<String, Object>> tableValues = (List<Map<String, Object>>) param.getValue();
for (Map<String, Object> map : tableValues) {
Iterator it = map.keySet().iterator();
while (it.hasNext()) {
String key = (String) it.next();
if (!names.contains(key)) {
it.remove();
}
}
}
}
}
use of org.talend.core.model.process.IConnection in project tdi-studio-se by Talend.
the class HL7OutputManager method initModel.
public void initModel() {
List<? extends IConnection> incomingConnections = NodeUtil.getIncomingConnections(hl7Component, IConnectionCategory.FLOW);
// HL7Root root = new HL7Root("root");
List<Map<String, String>> maps = (List<Map<String, String>>) ElementParameterParser.getObjectValue(hl7Component, //$NON-NLS-1$
"__SCHEMAS__");
List<String> schemaList = new ArrayList<String>();
for (IMetadataTable table : hl7Component.getMetadataList()) {
if (table.getLabel() != null) {
schemaList.add(table.getLabel());
}
}
List<Map<String, String>> rootTable = hl7Component.getTableList(HL7InputComponent.ROOT);
Map<String, IMetadataTable> schemaNameToInputTable = new HashMap<String, IMetadataTable>();
if (!maps.isEmpty()) {
for (Map<String, String> map : maps) {
String schemaName = map.get("SCHEMA");
int first = schemaName.indexOf("_");
int second = schemaName.lastIndexOf("_");
if (first > 0 && first < second) {
schemaName = schemaName.substring(first + 1, second);
}
IMetadataTable metadataTable = null;
for (IConnection connection : incomingConnections) {
if (connection.getUniqueName().equals(map.get("PARENT_ROW"))) {
metadataTable = connection.getMetadataTable();
metadataTable.setLabel(connection.getUniqueName());
schemaNameToInputTable.put(schemaName, metadataTable);
break;
}
}
}
} else {
for (String schemaName : schemaList) {
IMetadataTable metadataTable = null;
for (IConnection connection : incomingConnections) {
if (connection.getUniqueName().equals(schemaName)) {
metadataTable = connection.getMetadataTable();
metadataTable.setLabel(connection.getUniqueName());
schemaNameToInputTable.put(schemaName, metadataTable);
}
}
}
}
Map<String, HL7TreeNode> mapNodes = new HashMap<String, HL7TreeNode>();
treeData = new ArrayList<HL7TreeNode>();
HL7TreeNode rootNode = null;
HL7TreeNode current = null;
HL7TreeNode temp = null;
String currentPath = null;
String defaultValue = null;
int nodeOrder = 0;
boolean haveOrder = true;
// build root tree
for (Map<String, String> rootMap : rootTable) {
String newPath = rootMap.get(HL7InputComponent.PATH);
String columnName = rootMap.get(HL7InputComponent.COLUMN);
defaultValue = rootMap.get(HL7InputComponent.VALUE);
String orderValue = rootMap.get(HL7InputComponent.ORDER);
boolean repeatable = Boolean.valueOf(rootMap.get("REPEATABLE"));
if (orderValue == null || "".equals(orderValue)) {
haveOrder = false;
}
String rowName = columnName;
if (columnName != null && columnName.contains(":")) {
String[] names = columnName.split(":");
rowName = names[0];
columnName = names[1];
} else {
columnName = null;
}
temp = this.addElement(current, currentPath, newPath, defaultValue, mapNodes);
if (temp == null) {
// should not happen
continue;
}
if (rootNode == null) {
rootNode = temp;
}
if (rootMap.get(HL7InputComponent.ATTRIBUTE).equals("main")) {
//$NON-NLS-1$
temp.setMain(true);
}
current = temp;
currentPath = newPath;
temp.setRepetable(repeatable);
if (haveOrder) {
temp.setOrder(nodeOrder);
}
if (rowName != null && rowName.length() > 0) {
temp.setRow(rowName);
}
if (columnName != null) {
IMetadataTable metadataTable = schemaNameToInputTable.get(rowName);
// group node can not get the metadata table
if (metadataTable == null) {
IMetadataTable metadataTableTemp = null;
for (IConnection connection : incomingConnections) {
metadataTableTemp = connection.getMetadataTable();
String connectionName = metadataTableTemp.getLabel();
if (connectionName == null) {
connectionName = connection.getUniqueName();
}
if (columnName.startsWith(connectionName)) {
break;
}
}
temp.setColumnName(columnName);
if (metadataTableTemp != null) {
temp.setColumn(metadataTableTemp.getColumn(columnName));
temp.setTable(metadataTableTemp);
}
} else {
temp.setColumnName(columnName);
temp.setColumn(metadataTable.getColumn(columnName));
temp.setTable(metadataTable);
}
}
}
if (rootNode == null) {
rootNode = new Element("rootTag");
}
if (haveOrder) {
orderNode(rootNode);
}
// the root node should not set the ColumnLabel
if (rootNode.getRow() != null) {
rootNode.setRow(null);
}
treeData.add(rootNode);
contents.put(rootNode.getColumnLabel(), treeData);
initCurrentSchema();
}
use of org.talend.core.model.process.IConnection in project tdi-studio-se by Talend.
the class UIManager method setTraceFilterParaMapper.
/**
* DOC wzhang Comment method "setTraceFilterParaMapper".
*/
public void setTraceFilterParaMapper(Map<IConnection, Set<String>> preColumnSet, List<? extends AbstractInOutTable> curTables, Map<IConnection, Map<String, String>> changedColumnMap) {
for (IConnection curConn : preColumnSet.keySet()) {
Set<String> addedColumns = new HashSet<String>();
Set<String> preColSet = preColumnSet.get(curConn);
Map<String, String> changedColumns = changedColumnMap.get(curConn);
for (AbstractInOutTable table : curTables) {
String curTableName = table.getName();
if (curTableName.equals(curConn.getUniqueName())) {
if (changedColumns != null) {
for (String newName : changedColumns.keySet()) {
String oldName = changedColumns.get(newName);
if (preColSet.contains(oldName)) {
preColSet.remove(oldName);
preColSet.add(newName);
}
}
}
List<IMetadataColumn> curTableColumn = table.getMetadataTable().getListColumns();
for (IMetadataColumn curColumn : curTableColumn) {
if (!(preColSet.contains(curColumn.getLabel()))) {
addedColumns.add(curColumn.getLabel());
}
}
}
}
CorePlugin.getDefault().getDesignerCoreService().updateTraceColumnValues(curConn, changedColumns, addedColumns);
}
}
use of org.talend.core.model.process.IConnection in project tdi-studio-se by Talend.
the class MapDataHelper method rebuildModelInputs.
public void rebuildModelInputs(List<? extends IConnection> inputConn, XmlMapData mapData) {
// remove no used input tree
if (mapData.getInputTrees().size() != inputConn.size()) {
List treesToRemove = new ArrayList();
for (InputXmlTree inputTree : mapData.getInputTrees()) {
boolean found = false;
for (IConnection connection : inputConn) {
if (inputTree.getName().equals(connection.getName())) {
found = true;
}
}
if (!found) {
for (TreeNode treeNode : inputTree.getNodes()) {
XmlMapUtil.detachNodeConnections(treeNode, mapData, true);
}
treesToRemove.add(inputTree);
XmlMapUtil.detachFilterSource(inputTree, mapData);
}
}
mapData.getInputTrees().removeAll(treesToRemove);
}
for (IConnection inData : inputConn) {
String name = inData.getName();
InputXmlTree inputTree = null;
for (InputXmlTree in : mapData.getInputTrees()) {
if (in.getName() != null && in.getName().equals(name)) {
inputTree = in;
break;
}
}
if (inputTree == null) {
inputTree = XmlmapFactory.eINSTANCE.createInputXmlTree();
inputTree.setName(name);
inputTree.setLookup(EConnectionType.FLOW_MAIN != inData.getLineStyle());
mapData.getInputTrees().add(inputTree.isLookup() ? mapData.getInputTrees().size() : 0, inputTree);
} else {
inputTree.setLookup(EConnectionType.FLOW_MAIN != inData.getLineStyle());
}
if (inputTree.getLookupMode() == null) {
inputTree.setLookupMode(XML_MAP_LOOKUP_MODE.LOAD_ONCE.toString());
}
if (inputTree.getMatchingMode() == null) {
inputTree.setMatchingMode(XML_MAP_MATCHING_MODE.ALL_ROWS.toString());
}
rebuildInputTree(inputTree, inData.getMetadataTable(), mapData);
}
}
use of org.talend.core.model.process.IConnection in project tdi-studio-se by Talend.
the class ConnectionManager method canConnect.
private static boolean canConnect(INode source, INode target, EConnectionType connType, String connectionName, boolean refactorJoblet) {
if (source.equals(target)) {
return false;
}
if (!refactorJoblet && (!target.isActivate() || !source.isActivate())) {
return false;
}
boolean skipSameProcessTest = false;
if (newlineStyle.equals(EConnectionType.FLOW_MAIN)) {
int nbMain = 0;
for (IConnection connec : target.getIncomingConnections()) {
if (connec.getLineStyle().equals(EConnectionType.FLOW_MAIN)) {
nbMain++;
}
}
int maxFlowInput = 0;
if (target.getConnectorFromName(EConnectionType.FLOW_MAIN.getName()) != null) {
maxFlowInput = target.getConnectorFromName(EConnectionType.FLOW_MAIN.getName()).getMaxLinkInput();
}
if (maxFlowInput > 1 && nbMain >= 1 && (nbMain <= maxFlowInput || maxFlowInput == -1)) {
// if the component accept several connections on the input, all inputs must come from the same process
boolean isExtensionComponent = false;
AbstractProcessProvider findProcessProviderFromPID = AbstractProcessProvider.findProcessProviderFromPID(IComponent.JOBLET_PID);
if (findProcessProviderFromPID != null) {
isExtensionComponent = findProcessProviderFromPID.isExtensionComponent(target);
}
if (!isExtensionComponent && !source.sameProcessAs(target, false)) {
return false;
}
skipSameProcessTest = true;
}
}
if (!skipSameProcessTest && source.sameProcessAs(target, false)) {
return false;
}
// limit the use of the tUnite, avoid a conflict in case source link is in a merge part, and target use merge.
if (!source.getLinkedMergeInfo().isEmpty() && (!target.getLinkedMergeInfo().isEmpty() || target.getComponent().useMerge())) {
return false;
}
// Check existing connections to avoid to have more than one link
// no matter the type of the connection and the direction
List<Connection> connections = new ArrayList<Connection>((List<Connection>) source.getOutgoingConnections());
connections.removeAll(source.getOutgoingConnections(EConnectionType.FLOW_MAIN));
// connections = source.getOutgoingConnections();
for (int i = 0; i < connections.size(); i++) {
if ((connections.get(i)).getTarget().equals(target)) {
return false;
}
}
connections = new ArrayList<Connection>((List<Connection>) source.getIncomingConnections());
connections.removeAll(source.getIncomingConnections(EConnectionType.FLOW_MAIN));
// connections = source.getIncomingConnections();
for (int i = 0; i < connections.size(); i++) {
if ((connections.get(i)).getSource().equals(target)) {
return false;
}
}
if (connType.hasConnectionCategory(IConnectionCategory.DEPENDENCY)) {
if (!(Boolean) target.getPropertyValue(EParameterName.STARTABLE.getName())) {
return false;
}
boolean isJoblet = false;
if (PluginChecker.isJobLetPluginLoaded()) {
IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
if (service != null) {
if (service.isJobletComponent(target) && !connType.hasConnectionCategory(IConnectionCategory.FLOW)) {
List<INodeConnector> freeTriggerBuiltConnectors = service.getFreeTriggerBuiltConnectors(target, connType, true);
if (freeTriggerBuiltConnectors.isEmpty()) {
return false;
}
isJoblet = true;
}
// for bug 10973
if (service.isTriggerNode(target) && target.getIncomingConnections() != null && target.getIncomingConnections().size() >= 1) {
return false;
}
}
}
if (!isJoblet && !target.isELTComponent() && !target.isSubProcessStart()) {
return false;
}
}
connections = (List<Connection>) target.getIncomingConnections();
for (int i = 0; i < connections.size(); i++) {
if (connType == EConnectionType.TABLE || connType == EConnectionType.TABLE_REF) {
if ((connections.get(i)).isActivate()) {
if ((connections.get(i)).getName().equals(connectionName)) {
return false;
}
}
}
}
boolean targetHasHashLinks = ((Process) target.getProcess()).isThereLinkWithHash(target) | newlineStyle.hasConnectionCategory(IConnectionCategory.USE_HASH);
if (connType.hasConnectionCategory(IConnectionCategory.CONDITION)) {
if (targetHasHashLinks) {
return false;
}
}
if (targetHasHashLinks && source.hasRunIfLink()) {
return false;
}
return true;
}
Aggregations