use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree in project tdi-studio-se by Talend.
the class XmlMapUtil method checkMultiLoopsStatus.
public static boolean checkMultiLoopsStatus(AbstractInOutTree tree) {
// set multiloops to true only if one doc schema have more then one loops , if a table have two doc schema but
// each one only have one loop,multiloops should be false
List<? extends TreeNode> children = new ArrayList<TreeNode>();
if (tree instanceof InputXmlTree) {
children = ((InputXmlTree) tree).getNodes();
} else if (tree instanceof OutputXmlTree) {
children = ((OutputXmlTree) tree).getNodes();
}
List<TreeNode> docChildren = new ArrayList<TreeNode>();
for (TreeNode child : children) {
if (DOCUMENT.equals(child.getType())) {
docChildren.add(child);
}
}
List<TreeNode> loopNodes = new ArrayList<TreeNode>();
for (TreeNode doc : docChildren) {
getChildLoops(loopNodes, doc.getChildren());
if (loopNodes.size() > 1) {
return true;
}
}
return false;
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree in project tdi-studio-se by Talend.
the class XmlMapUtil method removeloopInOutputTree.
/**
*
* DOC WCHEN Remove source loops refrenced from input main
*
* @param mapData
* @param mainInput
* @param oldLoopsFromInput
* @param checkProblem
*/
public static void removeloopInOutputTree(XmlMapData mapData, InputXmlTree mainInput, List<TreeNode> oldLoopsFromInput, boolean checkProblem) {
boolean isMainInputMultiLoop = mainInput == null ? false : mainInput.isMultiLoops();
EList<OutputXmlTree> outputTrees = mapData.getOutputTrees();
for (OutputXmlTree outputTree : outputTrees) {
if (isMainInputMultiLoop) {
for (TreeNode oldLoop : oldLoopsFromInput) {
EList<InputLoopNodesTable> inputLoopNodesTables = outputTree.getInputLoopNodesTables();
for (InputLoopNodesTable inputLoopTable : inputLoopNodesTables) {
inputLoopTable.getInputloopnodes().remove(oldLoop);
}
}
} else {
List<TreeNode> multiLoopsForXmlTree = getMultiLoopsForXmlTree(outputTree);
for (TreeNode loop : multiLoopsForXmlTree) {
((OutputTreeNode) loop).setInputLoopNodesTable(null);
}
outputTree.getInputLoopNodesTables().clear();
}
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree in project tdi-studio-se by Talend.
the class ProblemsAnalyser method checkProblems.
public void checkProblems(AbstractInOutTree abstractTree) {
// clear problems for the tree before recheck it
if (treeAndProblems.get(abstractTree) != null) {
treeAndProblems.get(abstractTree).clear();
}
// check problems for InputLoopTable in output
final XmlMapData copyOfMapData = mapperManager.getExternalData();
// check problems for InputLoopTable in output
InputXmlTree mainInputTree = mapperManager.getMainInputTree();
if (abstractTree instanceof OutputXmlTree) {
checkInputLoopTablesProblem((OutputXmlTree) abstractTree, mainInputTree);
}
isMultipleDocType = false;
List<? extends TreeNode> nodes = null;
if (abstractTree instanceof InputXmlTree) {
nodes = ((InputXmlTree) abstractTree).getNodes();
} else if (abstractTree instanceof OutputXmlTree) {
nodes = ((OutputXmlTree) abstractTree).getNodes();
}
if (nodes != null) {
checkTreeNodesProblem(abstractTree, nodes);
}
if (treeAndProblems.get(abstractTree) == null || treeAndProblems.get(abstractTree).isEmpty()) {
treeAndProblems.remove(abstractTree);
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree in project tdi-studio-se by Talend.
the class XmlMapConnectionBuilder method rebuildLink.
private void rebuildLink(int inputTreeIndex, List<TreeNode> children, XmlMapData mapData) {
for (TreeNode treeNode : children) {
if (XmlMapUtil.isDragable(treeNode)) {
String expression = XmlMapUtil.convertToExpression(treeNode.getXpath());
XmlMapExpressionManager expressionManager = new XmlMapExpressionManager();
TableEntryLocation sourceLocation = expressionManager.parseTableEntryLocation(expression).get(0);
// LOOKUP ,FILTER
for (int i = inputTreeIndex; i < mapData.getInputTrees().size(); i++) {
InputXmlTree treeTarget = mapData.getInputTrees().get(i);
if (hasMaptchedLocation(expressionManager, sourceLocation, treeTarget, ExpressionType.EXPRESSION_FILTER)) {
createFilterConnection(treeNode, treeTarget, mapData);
}
checkTargetChildren(expressionManager, treeTarget.getNodes(), treeNode, sourceLocation, mapData);
}
// VAR
for (VarNode varNode : mapData.getVarTables().get(0).getNodes()) {
if (hasMaptchedLocation(expressionManager, sourceLocation, varNode, ExpressionType.EXPRESSION)) {
createConnection(treeNode, varNode, mapData);
}
}
// OUTPUT,FILTER
for (int i = 0; i < mapData.getOutputTrees().size(); i++) {
OutputXmlTree outputTree = mapData.getOutputTrees().get(i);
if (hasMaptchedLocation(expressionManager, sourceLocation, outputTree, ExpressionType.EXPRESSION_FILTER)) {
createFilterConnection(treeNode, outputTree, mapData);
}
checkTargetChildren(expressionManager, outputTree.getNodes(), treeNode, sourceLocation, mapData);
}
}
if (!treeNode.getChildren().isEmpty()) {
rebuildLink(inputTreeIndex, treeNode.getChildren(), mapData);
}
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree in project tdi-studio-se by Talend.
the class XmlMapNodeDirectEditManager method createCellEditorOn.
@Override
protected CellEditor createCellEditorOn(Composite composite) {
Composite parent = (Composite) source.getViewer().getControl();
CellEditor cellEditor = null;
Figure figure = null;
if (this.locator instanceof XmlMapNodeCellEditorLocator) {
XmlMapNodeCellEditorLocator lo = (XmlMapNodeCellEditorLocator) locator;
figure = lo.getFigure();
}
if (figure instanceof IComboCell) {
try {
// tree setting can be edit or not
if (source instanceof InputXmlTreeEditPart) {
InputXmlTree inputTree = (InputXmlTree) ((InputXmlTreeEditPart) source).getModel();
if (DirectEditType.JOIN_MODEL.equals(((IComboCell) figure).getDirectEditType())) {
if (!XmlMapUtil.hasAtLeastOneHashKey(inputTree)) {
return null;
}
}
if (DirectEditType.PERSISTENT_MODEL.equals(((IComboCell) figure).getDirectEditType())) {
if (LOOKUP_MODE.CACHE_OR_RELOAD.toString().equals(inputTree.getLookupMode())) {
return null;
}
}
}
if (source instanceof OutputXmlTreeEditPart) {
OutputXmlTree outputTree = (OutputXmlTree) ((OutputXmlTreeEditPart) source).getModel();
if (DirectEditType.ALL_IN_ONE.equals(((IComboCell) figure).getDirectEditType())) {
if (!XmlMapUtil.hasDocument(outputTree)) {
return null;
}
boolean hasAggregate = false;
for (int i = 0; i < outputTree.getNodes().size(); i++) {
OutputTreeNode outputTreeNode = outputTree.getNodes().get(i);
hasAggregate = hasAggreage(outputTreeNode);
if (hasAggregate) {
break;
}
}
if (hasAggregate) {
return null;
}
} else if (DirectEditType.ENABLE_EMPTY_ELEMENT.equals(((IComboCell) figure).getDirectEditType())) {
if (!XmlMapUtil.hasDocument(outputTree)) {
return null;
}
}
}
cellEditor = new XmlComboCellEditor();
cellEditor.create(composite);
((XmlComboCellEditor) cellEditor).setItems(getComboItemsByType(((IComboCell) figure).getDirectEditType()));
cellAndType.put(cellEditor, ((IComboCell) figure).getDirectEditType());
} catch (Exception e) {
return null;
}
} else if (figure instanceof ITextCell) {
// this one is created for direct doc child name , no use anymore...
cellEditor = new TextCellEditor(composite);
cellAndType.put(cellEditor, ((ITextCell) figure).getDirectEditType());
// for the search
XmlMapNodeCellEditorLocator lo = (XmlMapNodeCellEditorLocator) locator;
if (lo.getFigure() != null && lo.getFigure() instanceof VarNodeTextLabel) {
figure = (VarNodeTextLabel) lo.getFigure();
if (figure.getParent() != null && figure.getParent() instanceof XmlMapSearchZoneToolBar) {
XmlMapSearchZoneToolBar searchZone = (XmlMapSearchZoneToolBar) figure.getParent();
if (searchZone.getSearchMaps().size() > 0) {
searchZone.getSearchZoneMapper().hightlightAll(searchZone.getSearchMaps(), false);
searchZone.getSearchZoneMapper().setHightlightAll(false);
searchZone.getSearchMaps().clear();
searchZone.hightLightAll.setSelected(false);
}
}
}
} else if (figure instanceof IExpressionBuilderCell && model instanceof AbstractNode) {
IService expressionBuilderDialogService = GlobalServiceRegister.getDefault().getService(IExpressionBuilderDialogService.class);
CellEditorDialogBehavior behavior = new CellEditorDialogBehavior();
cellEditor = new ExpressionCellEditor(composite, behavior, source, DirectEditType.EXPRESSION);
((ExpressionCellEditor) cellEditor).setOwnerId(((AbstractNode) model).getExpression());
IExpressionBuilderDialogController dialog = ((IExpressionBuilderDialogService) expressionBuilderDialogService).getExpressionBuilderInstance(parent, (ExpressionCellEditor) cellEditor, null);
cellAndType.put(cellEditor, DirectEditType.EXPRESSION);
behavior.setCellEditorDialog(dialog);
} else if (figure instanceof ITextAreaCell) {
TextAreaBehavior behavior = new TextAreaBehavior();
cellEditor = new ExpressionCellEditor(composite, behavior, source, DirectEditType.EXPRESSION_FILTER);
cellAndType.put(cellEditor, DirectEditType.EXPRESSION_FILTER);
} else if (figure instanceof IExpressionBuilderCell && model instanceof InputXmlTree) {
IService expressionBuilderDialogService = GlobalServiceRegister.getDefault().getService(IExpressionBuilderDialogService.class);
CellEditorDialogBehavior behavior = new CellEditorDialogBehavior();
cellEditor = new ExpressionCellEditor(composite, behavior, source, DirectEditType.EXPRESSION);
((ExpressionCellEditor) cellEditor).setOwnerId(((InputXmlTree) model).getLookupMode());
IExpressionBuilderDialogController dialog = ((IExpressionBuilderDialogService) expressionBuilderDialogService).getExpressionBuilderInstance(parent, (ExpressionCellEditor) cellEditor, null);
cellAndType.put(cellEditor, DirectEditType.EXPRESSION);
behavior.setCellEditorDialog(dialog);
}
// }
return cellEditor;
}
Aggregations