use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode in project tdi-studio-se by Talend.
the class InputLoopTableUtil method getInputLoopNodesTable.
private static InputLoopNodesTable getInputLoopNodesTable(OutputTreeNode outputNode) {
InputLoopNodesTable inputLoopNodesTable = null;
AbstractInOutTree abstractTree = XmlMapUtil.getAbstractInOutTree(outputNode);
List<InputLoopNodesTable> listInputLoopNodesTablesEntry = ((OutputXmlTree) abstractTree).getInputLoopNodesTables();
if (!XmlMapUtil.hasDocument(abstractTree)) {
if (listInputLoopNodesTablesEntry.size() == 0) {
inputLoopNodesTable = XmlmapFactory.eINSTANCE.createInputLoopNodesTable();
listInputLoopNodesTablesEntry.add(inputLoopNodesTable);
} else if (listInputLoopNodesTablesEntry != null && listInputLoopNodesTablesEntry.size() == 1) {
inputLoopNodesTable = listInputLoopNodesTablesEntry.get(0);
}
} else {
OutputTreeNode loopParentOutputTreeNode = (OutputTreeNode) XmlMapUtil.getLoopParentNode(outputNode);
if (loopParentOutputTreeNode != null) {
inputLoopNodesTable = loopParentOutputTreeNode.getInputLoopNodesTable();
if (inputLoopNodesTable == null) {
inputLoopNodesTable = XmlmapFactory.eINSTANCE.createInputLoopNodesTable();
loopParentOutputTreeNode.setInputLoopNodesTable(inputLoopNodesTable);
listInputLoopNodesTablesEntry.add(inputLoopNodesTable);
}
}
}
return inputLoopNodesTable;
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode in project tdi-studio-se by Talend.
the class TreeNodeEditPart method performRequest.
@Override
public void performRequest(Request req) {
if (RequestConstants.REQ_DIRECT_EDIT.equals(req.getType())) {
Figure figure = null;
DirectEditRequest drequest = (DirectEditRequest) req;
Point figureLocation = drequest.getLocation();
if (getFigure() instanceof TableTreeEntityFigure) {
XmlmapTreeNodeFigure treeNodeFigure = (XmlmapTreeNodeFigure) getFigure();
ArrayList collection = new ArrayList();
collection.add(treeNodeFigure.getExpressionFigure());
collection.add(treeNodeFigure.getBranchContent());
figure = (Figure) treeNodeFigure.findFigureAt(figureLocation.x, figureLocation.y, new FigureSearch(collection));
}
if (figure instanceof IWidgetCell) {
directEditManager = new XmlMapNodeDirectEditManager(this, new XmlMapNodeCellEditorLocator(figure, this));
}
if (directEditManager != null) {
TreeNode outputTreeNode = (TreeNode) getModel();
if (figure instanceof ExpressionFigure) {
if (XmlMapUtil.isExpressionEditable(outputTreeNode)) {
Point location = drequest.getLocation();
if (figure.containsPoint(location)) {
directEditManager.show();
((XmlMapGraphicViewer) getViewer()).getMapperManager().setCurrentDirectEditManager(directEditManager);
}
}
} else if (!(((TreeNode) getModel()).eContainer() instanceof AbstractInOutTree)) {
// disable for RC2
// directEditManager.show();
// ((XmlMapGraphicViewer)
// getViewer()).getMapperManager().setCurrentDirectEditManager(directEditManager);
}
}
}
super.performRequest(req);
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode in project tdi-studio-se by Talend.
the class XmlMapComponent method checkNeededRoutines.
@Override
public List<String> checkNeededRoutines(List<String> possibleRoutines, String additionalString) {
List<String> routinesToAdd = new ArrayList<String>();
XmlMapData xmlMapData = (XmlMapData) getExternalEmfData();
for (String routine : possibleRoutines) {
List<OutputXmlTree> listOutput = xmlMapData.getOutputTrees();
for (OutputXmlTree outTable : listOutput) {
List<OutputTreeNode> listOutEntry = outTable.getNodes();
if (listOutEntry != null && !listOutEntry.isEmpty()) {
for (OutputTreeNode outEntry : listOutEntry) {
String expression = outEntry.getExpression();
if (expression != null && !routinesToAdd.contains(routine) && expression.contains(routine + additionalString)) {
routinesToAdd.add(routine);
}
}
}
String filter = outTable.getExpressionFilter();
if (filter != null && !routinesToAdd.contains(routine) && filter.contains(routine + additionalString)) {
routinesToAdd.add(routine);
}
}
List<InputXmlTree> listInput = xmlMapData.getInputTrees();
for (InputXmlTree inputTable : listInput) {
List<TreeNode> listInEntry = inputTable.getNodes();
if (listInEntry != null && !listInEntry.isEmpty()) {
for (TreeNode inEntry : listInEntry) {
String expression = inEntry.getExpression();
if (expression != null && !routinesToAdd.contains(routine) && expression.contains(routine + additionalString)) {
routinesToAdd.add(routine);
}
}
}
String filter = inputTable.getExpressionFilter();
if (filter != null && !routinesToAdd.contains(routine) && filter.contains(routine + additionalString)) {
routinesToAdd.add(routine);
}
}
List<VarTable> listVar = xmlMapData.getVarTables();
for (VarTable varTable : listVar) {
List<VarNode> listVarEntry = varTable.getNodes();
if (listVarEntry != null && !listVarEntry.isEmpty()) {
for (VarNode varEntry : listVarEntry) {
String expression = varEntry.getExpression();
if (expression != null && !routinesToAdd.contains(routine) && expression.contains(routine + additionalString)) {
routinesToAdd.add(routine);
}
}
}
}
}
return routinesToAdd;
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode in project tdi-studio-se by Talend.
the class XmlMapService method cloneTreeNode.
private EObject cloneTreeNode(EObject node) {
if (node instanceof AbstractInOutTree) {
AbstractInOutTree source = null;
AbstractInOutTree oriSource = null;
if (node instanceof InputXmlTree) {
oriSource = (InputXmlTree) node;
source = XmlmapFactory.eINSTANCE.createInputXmlTree();
((InputXmlTree) source).setActivateGlobalMap(((InputXmlTree) oriSource).isActivateGlobalMap());
((InputXmlTree) source).setInnerJoin(((InputXmlTree) oriSource).isInnerJoin());
((InputXmlTree) source).setLookup(((InputXmlTree) oriSource).isLookup());
((InputXmlTree) source).setLookupMode(((InputXmlTree) oriSource).getLookupMode());
((InputXmlTree) source).setMatchingMode(((InputXmlTree) oriSource).getMatchingMode());
((InputXmlTree) source).setPersistent(((InputXmlTree) oriSource).isPersistent());
} else if (node instanceof OutputXmlTree) {
oriSource = (OutputXmlTree) node;
source = XmlmapFactory.eINSTANCE.createOutputXmlTree();
((OutputXmlTree) source).setAllInOne(((OutputXmlTree) oriSource).isAllInOne());
((OutputXmlTree) source).setEnableEmptyElement(((OutputXmlTree) oriSource).isEnableEmptyElement());
((OutputXmlTree) source).setErrorReject(((OutputXmlTree) oriSource).isErrorReject());
((OutputXmlTree) source).setReject(((OutputXmlTree) oriSource).isReject());
((OutputXmlTree) source).setRejectInnerJoin(((OutputXmlTree) oriSource).isRejectInnerJoin());
}
source.setActivateCondensedTool(oriSource.isActivateCondensedTool());
source.setActivateExpressionFilter(oriSource.isActivateExpressionFilter());
source.setExpressionFilter(oriSource.getExpressionFilter());
source.setMinimized(oriSource.isMinimized());
source.setMultiLoops(oriSource.isMultiLoops());
source.setName(oriSource.getName());
return source;
} else if (node instanceof VarNode) {
VarNode oriSource = (VarNode) node;
VarNode source = XmlmapFactory.eINSTANCE.createVarNode();
source.setExpression(oriSource.getExpression());
source.setName(oriSource.getName());
source.setNullable(oriSource.isNullable());
source.setType(oriSource.getType());
return source;
} else if (node instanceof TreeNode) {
TreeNode source = null;
TreeNode oriSource = null;
if (node instanceof OutputTreeNode) {
oriSource = (OutputTreeNode) node;
source = XmlmapFactory.eINSTANCE.createOutputTreeNode();
((OutputTreeNode) source).setAggregate(((OutputTreeNode) oriSource).isAggregate());
((OutputTreeNode) source).setInputLoopNodesTable(((OutputTreeNode) oriSource).getInputLoopNodesTable());
} else if (node instanceof GlobalMapNode) {
oriSource = (GlobalMapNode) node;
source = XmlmapFactory.eINSTANCE.createGlobalMapNode();
return source;
} else {
oriSource = (TreeNode) node;
source = XmlmapFactory.eINSTANCE.createTreeNode();
}
source.setChoice(oriSource.isChoice());
source.setDefaultValue(oriSource.getDefaultValue());
source.setExpression(oriSource.getExpression());
source.setGroup(oriSource.isGroup());
source.setKey(oriSource.isKey());
source.setLoop(oriSource.isLoop());
source.setMain(oriSource.isMain());
source.setName(oriSource.getName());
source.setNodeType(oriSource.getNodeType());
source.setNullable(oriSource.isNullable());
source.setOptional(oriSource.isOptional());
source.setPattern(oriSource.getPattern());
source.setSubstitution(oriSource.isSubstitution());
source.setType(oriSource.getType());
source.setXpath(oriSource.getXpath());
return source;
}
return null;
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode in project tdi-studio-se by Talend.
the class XmlMapUtilTest method testUpdateXPathAndExpression.
@Test
public void testUpdateXPathAndExpression() {
XmlMapData data = XmlmapFactory.eINSTANCE.createXmlMapData();
InputXmlTree inputTree = XmlmapFactory.eINSTANCE.createInputXmlTree();
inputTree.setName("row1");
OutputXmlTree outputTree = XmlmapFactory.eINSTANCE.createOutputXmlTree();
outputTree.setName("out1");
data.getInputTrees().add(inputTree);
data.getOutputTrees().add(outputTree);
TreeNode doc = XmlmapFactory.eINSTANCE.createTreeNode();
initTreeNode(doc, "doc", "id_Document", NodeType.ELEMENT, "row1/doc", "");
inputTree.getNodes().add(doc);
TreeNode school = XmlmapFactory.eINSTANCE.createTreeNode();
initTreeNode(school, "school", "id_String", NodeType.ELEMENT, "row1.doc:/school", "");
doc.getChildren().add(school);
TreeNode student = XmlmapFactory.eINSTANCE.createTreeNode();
initTreeNode(student, "student", "id_String", NodeType.ELEMENT, "row1.doc:/school/student", "");
school.getChildren().add(student);
TreeNode name = XmlmapFactory.eINSTANCE.createTreeNode();
initTreeNode(name, "name", "id_String", NodeType.ATTRIBUT, "row1.doc:/school/student/@name", "");
student.getChildren().add(name);
OutputTreeNode outColumn = XmlmapFactory.eINSTANCE.createOutputTreeNode();
initTreeNode(outColumn, "outColumn", "id_String", NodeType.ELEMENT, "out1/outColumn", "[row1.doc:/school/student/@name]");
outputTree.getNodes().add(outColumn);
createConnection(data, name, outColumn);
// rename schema column
doc.setName("document");
XmlMapUtil.updateXPathAndExpression(data, new XmlMapExpressionManager(), doc, "document", 2, true);
assertTrue(doc.getXpath().equals("row1/document"));
assertTrue(school.getXpath().equals("row1.document:/school"));
assertTrue(student.getXpath().equals("row1.document:/school/student"));
assertTrue(name.getXpath().equals("row1.document:/school/student/@name"));
assertTrue(outColumn.getExpression().equals("[row1.document:/school/student/@name]"));
// rename doc child
school.setName("kindergarten");
XmlMapUtil.updateXPathAndExpression(data, new XmlMapExpressionManager(), school, "kindergarten", 3, true);
assertTrue(doc.getXpath().equals("row1/document"));
assertTrue(school.getXpath().equals("row1.document:/kindergarten"));
assertTrue(student.getXpath().equals("row1.document:/kindergarten/student"));
assertTrue(name.getXpath().equals("row1.document:/kindergarten/student/@name"));
assertTrue(outColumn.getExpression().equals("[row1.document:/kindergarten/student/@name]"));
}
Aggregations