use of org.talend.designer.xmlmap.model.emf.xmlmap.IConnection in project tdi-studio-se by Talend.
the class XmlMapTreeContainerLayout method getLookupConnectionSize.
/*
* (non-Javadoc)
*
* @see org.talend.designer.newabstractmap.figures.layout.TreeContainerLayout#getLookupConnectionSize()
*/
@Override
protected int getLookupConnectionSize(AbstractTableContainer tableContainer) {
if (tableContainer instanceof InputXmlTreeFigure) {
InputXmlTree inputModel = ((InputXmlTreeFigure) tableContainer).getInputXmlTree();
List<TreeNode> nodeList = inputModel.getNodes();
int maxSize = 0;
List<IConnection> lookConnections = XmlMapUtil.getAllNodeLookConnections(inputModel);
List<IConnection> filterConnections = XmlMapUtil.getInputTreeFilterConnections(inputModel);
if (lookConnections.size() < filterConnections.size()) {
maxSize = filterConnections.size();
} else {
maxSize = lookConnections.size();
}
return maxSize;
}
return 0;
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.IConnection in project tdi-studio-se by Talend.
the class XmlMapFilterConnectionPart method calculateConnOffset.
protected int calculateConnOffset() {
FilterConnection model = (FilterConnection) getModel();
if (model.getSource() == null) {
return 0;
}
TreeNode sourceTreeNode = (TreeNode) model.getSource();
AbstractInOutTree inputTreeNodeRoot = XmlMapUtil.getAbstractInOutTree(sourceTreeNode);
List<IConnection> outConns = new ArrayList<IConnection>();
if (inputTreeNodeRoot instanceof InputXmlTree) {
outConns.addAll(XmlMapUtil.getInputTreeFilterConnections((InputXmlTree) inputTreeNodeRoot));
}
int indexOf = outConns.indexOf(model);
if (indexOf != -1) {
return -(indexOf + 1) * XmlMapUtil.DEFAULT_OFFSET_FILTER;
}
return 0;
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.IConnection in project tdi-studio-se by Talend.
the class XmlMapDataImpl method equals.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated not
*/
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
XmlMapDataImpl dbObj = (XmlMapDataImpl) obj;
EList<InputXmlTree> inputs = dbObj.getInputTrees();
EList<OutputXmlTree> outputs = dbObj.getOutputTrees();
EList<VarTable> vars = dbObj.getVarTables();
EList<IConnection> conns = dbObj.getConnections();
if (inputs.size() != getInputTrees().size()) {
return false;
}
if (outputs.size() != getOutputTrees().size()) {
return false;
}
if (vars.size() != getVarTables().size()) {
return false;
}
if (getConnections().size() != conns.size()) {
return false;
}
for (InputXmlTree inputTable : inputTrees) {
boolean found = false;
for (InputXmlTree input : inputs) {
if (inputTable.getName().equals(input.getName())) {
found = true;
if (!inputTable.equals(input)) {
return false;
}
break;
}
}
if (found == false) {
return false;
}
}
for (OutputXmlTree outputTable : outputTrees) {
boolean found = false;
for (OutputXmlTree output : outputs) {
if (outputTable.getName().equals(output.getName())) {
found = true;
if (!outputTable.equals(output)) {
return false;
}
break;
}
}
if (found == false) {
return false;
}
}
for (VarTable varTable : varTables) {
boolean found = false;
for (VarTable var : vars) {
if (varTable.getName().equals(var.getName())) {
found = true;
if (!varTable.equals(var)) {
return false;
}
break;
}
}
if (found == false) {
return false;
}
}
return true;
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.IConnection in project tdi-studio-se by Talend.
the class XmlMapLookupConnectionPart method calculateConnOffset.
protected int calculateConnOffset() {
LookupConnection model = (LookupConnection) getModel();
if (model.getSource() == null) {
return 0;
}
TreeNode sourceTreeNode = (TreeNode) model.getSource();
List<IConnection> outConns = new ArrayList<IConnection>();
TreeNode inputTreeNodeRoot = XmlMapUtil.getTreeNodeRoot(sourceTreeNode);
if (inputTreeNodeRoot != null) {
InputXmlTree inputTree = (InputXmlTree) inputTreeNodeRoot.eContainer();
outConns.addAll(XmlMapUtil.getAllNodeLookConnections(inputTree));
}
int indexOf = outConns.indexOf(model);
if (indexOf != -1) {
return -(indexOf + 1) * XmlMapUtil.DEFAULT_OFFSET;
}
return 0;
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.IConnection in project tdi-studio-se by Talend.
the class XmlMapService method externalEmfDataClone.
/*
* (non-Javadoc)
*
* @see
* org.talend.core.service.IXmlMapService#externalEmfDataClone(org.talend.designer.core.model.utils.emf.talendfile
* .AbstractExternalData)
*/
@Override
public AbstractExternalData externalEmfDataClone(AbstractExternalData externalEmfData) {
if (!(externalEmfData instanceof XmlMapData)) {
return externalEmfData;
}
Map<EObject, EObject> nodeMaps = new HashMap<EObject, EObject>();
XmlMapData newXmlMapData = XmlmapFactory.eINSTANCE.createXmlMapData();
XmlMapData xmlMapData = (XmlMapData) externalEmfData;
EList<InputXmlTree> oriInputs = xmlMapData.getInputTrees();
EList<OutputXmlTree> oriOutputs = xmlMapData.getOutputTrees();
EList<VarTable> oriVars = xmlMapData.getVarTables();
EList<IConnection> oriConns = xmlMapData.getConnections();
for (IConnection oriConn : oriConns) {
if (oriConn instanceof INodeConnection) {
AbstractNode sourceNode = ((INodeConnection) oriConn).getSource();
AbstractNode targetNode = ((INodeConnection) oriConn).getTarget();
EObject source = null;
if (nodeMaps.get(sourceNode) != null) {
source = nodeMaps.get(sourceNode);
} else {
source = cloneTreeNode(sourceNode);
nodeMaps.put(sourceNode, source);
}
EObject target = null;
if (nodeMaps.get(targetNode) != null) {
target = nodeMaps.get(targetNode);
} else {
target = cloneTreeNode(targetNode);
nodeMaps.put(targetNode, target);
}
if (oriConn instanceof Connection) {
new XmlMapConnectionBuilder().createConnection((AbstractNode) source, (AbstractNode) target, newXmlMapData);
} else if (oriConn instanceof LookupConnection) {
new XmlMapConnectionBuilder().createLookupConnection((TreeNode) source, (TreeNode) target, newXmlMapData);
}
} else if (oriConn instanceof FilterConnection) {
AbstractNode sourceNode = ((FilterConnection) oriConn).getSource();
AbstractInOutTree targetNode = ((FilterConnection) oriConn).getTarget();
EObject source = null;
if (nodeMaps.get(sourceNode) != null) {
source = nodeMaps.get(sourceNode);
} else {
source = cloneTreeNode(sourceNode);
nodeMaps.put(sourceNode, source);
}
EObject target = null;
if (nodeMaps.get(targetNode) != null) {
target = nodeMaps.get(targetNode);
} else {
target = cloneTreeNode(targetNode);
nodeMaps.put(targetNode, target);
}
new XmlMapConnectionBuilder().createFilterConnection((AbstractNode) source, (AbstractInOutTree) target, newXmlMapData);
}
}
for (InputXmlTree inputXml : oriInputs) {
InputXmlTree newInputXml = null;
if (nodeMaps.get(inputXml) == null) {
newInputXml = (InputXmlTree) cloneTreeNode(inputXml);
} else {
newInputXml = (InputXmlTree) nodeMaps.get(inputXml);
}
if (inputXml.getNodes() != null) {
for (TreeNode treeNode : inputXml.getNodes()) {
EObject obj = nodeMaps.get(treeNode);
if ((obj != null) && !newInputXml.getNodes().contains(obj)) {
newInputXml.getNodes().add((TreeNode) obj);
}
}
}
if (!newXmlMapData.getInputTrees().contains(newInputXml)) {
newXmlMapData.getInputTrees().add(newInputXml);
}
nodeMaps.put(inputXml, newInputXml);
}
for (OutputXmlTree outputXml : oriOutputs) {
OutputXmlTree newOutputXml = null;
if (nodeMaps.get(outputXml) == null) {
newOutputXml = (OutputXmlTree) cloneTreeNode(outputXml);
} else {
newOutputXml = (OutputXmlTree) nodeMaps.get(outputXml);
}
if (outputXml.getNodes() != null) {
for (OutputTreeNode treeNode : outputXml.getNodes()) {
EObject obj = nodeMaps.get(treeNode);
if ((obj != null) && !newOutputXml.getNodes().contains(obj)) {
newOutputXml.getNodes().add((OutputTreeNode) obj);
}
}
}
// }
if (!newXmlMapData.getOutputTrees().contains(newOutputXml)) {
newXmlMapData.getOutputTrees().add(newOutputXml);
}
nodeMaps.put(outputXml, newOutputXml);
}
for (VarTable varXml : oriVars) {
VarTable newVarXml = null;
if (nodeMaps.get(varXml) == null) {
newVarXml = XmlmapFactory.eINSTANCE.createVarTable();
newVarXml.setMinimized(varXml.isMinimized());
newVarXml.setName(varXml.getName());
if (varXml.getNodes() != null) {
for (VarNode treeNode : varXml.getNodes()) {
EObject obj = nodeMaps.get(treeNode);
if (obj != null) {
newVarXml.getNodes().add((VarNode) obj);
}
}
}
if (!newXmlMapData.getVarTables().contains(newVarXml)) {
newXmlMapData.getVarTables().add(newVarXml);
}
nodeMaps.put(varXml, newVarXml);
}
}
return newXmlMapData;
}
Aggregations