use of org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree in project tdi-studio-se by Talend.
the class XmlMapTableTree method createColumns.
@Override
protected void createColumns() {
layoutManager.setAjustToTableWidth(false);
// table column title
MapperTable xmlTree = tableModelManager.getModel();
boolean hasExpression = false;
if (xmlTree instanceof InputXmlTree) {
InputXmlTree inputTree = (InputXmlTree) xmlTree;
if (inputTree.isLookup()) {
expressionColumn = new TableColumn(ColumnKeyConstant.KEY_EXPRESSION);
expressionColumn.setText("Exp.key");
this.addColumn(expressionColumn);
columnSash = new ColumnSash(this);
columnSash.setLeftColumn(expressionColumn);
this.addSeparator(columnSash);
hasExpression = true;
}
} else {
expressionColumn = new TableColumn(ColumnKeyConstant.KEY_EXPRESSION);
expressionColumn.setText("Expression");
this.addColumn(expressionColumn);
columnSash = new ColumnSash(this);
columnSash.setLeftColumn(expressionColumn);
this.addSeparator(columnSash);
hasExpression = true;
}
nameColumn = new TableColumn(ColumnKeyConstant.KEY_NAME);
nameColumn.setText("Column");
if (columnSash != null) {
columnSash.setRightColumn(nameColumn);
}
this.addColumn(nameColumn);
if (hasExpression) {
layoutManager.setWeight(0, 0.5);
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree in project tdi-studio-se by Talend.
the class XmlmapTreeNodeFigure method createEntityItems.
/*
* (non-Javadoc)
*
* @see org.talend.designer.newabstractmap.figures.table.entity.TableEntityFigure#createEntityItems()
*/
@Override
protected void createEntityItems(TableEntityElement entityElement) {
this.treeNode = getEntityManager().getModel();
boolean isLookup = false;
if (treeNode instanceof OutputTreeNode) {
isLookup = true;
} else {
TreeNode inputTreeNodeRoot = XmlMapUtil.getTreeNodeRoot(treeNode);
if (inputTreeNodeRoot != null && inputTreeNodeRoot.eContainer() instanceof InputXmlTree) {
isLookup = ((InputXmlTree) inputTreeNodeRoot.eContainer()).isLookup();
}
}
if (isLookup) {
expression = new ExpressionFigure();
expression.setText(treeNode.getExpression());
if (!XmlMapUtil.isExpressionEditable(treeNode)) {
expression.setOpaque(true);
expression.setBackgroundColor(ColorProviderMapper.getColor(ColorInfo.COLOR_EXPREESION_DISABLE));
} else {
expression.setOpaque(false);
}
entityElement.add(expression);
}
branchContent = new XmlmapBranchContent(getEntityManager());
TreeBranch treeBranch = new TreeBranch(branchContent, !isRoot());
entityElement.add(treeBranch);
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree 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.InputXmlTree in project tdi-studio-se by Talend.
the class AutoMapper method map.
/**
* DOC amaumont Comment method "map".
*/
public void map() {
EList<InputXmlTree> inputTrees = xmlMapData.getInputTrees();
EList<OutputXmlTree> outputTrees = xmlMapData.getOutputTrees();
/*
* non-document node , if name is the same ,automap document node , check xpath first , if can't find ,check the
* name
*/
for (OutputXmlTree outputTree : outputTrees) {
List<TreeNode> outputEntries = getAllEntities(outputTree);
for (TreeNode outputEntry : outputEntries) {
if ((outputEntry.getExpression() == null || "".equals(outputEntry.getExpression())) && XmlMapUtil.isExpressionEditable(outputEntry)) {
String xpath = outputEntry.getXpath();
String outputNodePath = xpath.substring(outputTree.getName().length() + 1, xpath.length());
TreeNode inputSameXpath = null;
TreeNode inputSameName = null;
out: for (InputXmlTree inputTable : inputTrees) {
List<TreeNode> inputColumnEntries = getAllEntities(inputTable);
in: for (TreeNode inputEntry : inputColumnEntries) {
// check if input tree node can be mapped
if (XmlMapUtil.isExpressionEditable(inputEntry)) {
String inputXpath = inputEntry.getXpath();
String inputNodePath = inputXpath.substring(inputTable.getName().length() + 1, inputXpath.length());
if (outputNodePath.equals(inputNodePath)) {
inputSameXpath = inputEntry;
break out;
}
// if the same name , find the first matched node , don't overwrite
if (inputSameName == null && outputEntry.getName() != null && outputEntry.getName().equals(inputEntry.getName())) {
inputSameName = inputEntry;
}
}
}
}
TreeNode inputEntryToMap = null;
if (inputSameXpath != null) {
inputEntryToMap = inputSameXpath;
} else if (inputSameName != null) {
inputEntryToMap = inputSameName;
}
if (inputEntryToMap != null) {
String expression = outputEntry.getExpression();
String convertToExpression = XmlMapUtil.convertToExpression(inputEntryToMap.getXpath());
if (expression != null && expression.indexOf(convertToExpression) != -1) {
continue;
} else {
if (expression == null) {
expression = "";
}
expression = expression + convertToExpression;
}
outputEntry.setExpression(expression);
Connection conn = XmlmapFactory.eINSTANCE.createConnection();
conn.setSource(inputEntryToMap);
conn.setTarget(outputEntry);
outputEntry.getIncomingConnections().add(conn);
inputEntryToMap.getOutgoingConnections().add(conn);
xmlMapData.getConnections().add(conn);
}
}
}
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree in project tdi-studio-se by Talend.
the class SearchZoneMapper method search.
public void search(Map<Integer, Map<Integer, Figure>> searchMaps, String searchValue) {
if (searchValue.equals("") || searchValue == null) {
return;
}
List<InputXmlTree> inputTrees = mapperManager.getExternalData().getInputTrees();
List<VarTable> varTables = mapperManager.getExternalData().getVarTables();
List<OutputXmlTree> outputTrees = mapperManager.getExternalData().getOutputTrees();
matcher.setPattern("*" + searchValue.trim() + "*");
int index = -1;
// for the InputTables
for (InputXmlTree inputXmlTree : inputTrees) {
// ExpressionFilter
if (inputXmlTree.getExpressionFilter() != null && matcher.matches(inputXmlTree.getExpressionFilter())) {
EList<Adapter> adapter = inputXmlTree.eAdapters();
if (adapter.size() > 0) {
if (adapter.get(0) instanceof InputXmlTreeEditPart) {
InputXmlTreeEditPart inputXmlTreeEditPart = (InputXmlTreeEditPart) adapter.get(0);
if (inputXmlTreeEditPart != null && inputXmlTreeEditPart.getFigure() != null && inputXmlTreeEditPart.getFigure() instanceof InputXmlTreeFigure) {
InputXmlTreeFigure inputXmlTreeFigure = (InputXmlTreeFigure) inputXmlTreeEditPart.getFigure();
Map<Integer, Figure> map = new HashMap<Integer, Figure>();
map.put(0, inputXmlTreeFigure.getFilterContainer());
index++;
searchMaps.put(index, map);
}
}
}
}
// TreeNode
for (TreeNode node : inputXmlTree.getNodes()) {
// id_Document type
if (XmlMapUtil.DOCUMENT.equals(node.getType())) {
for (TreeNode nodeTemp : XmlMapUtil.getFlatChildrenList(node)) {
if (getMatcherNodeFigure(nodeTemp).size() > 0) {
index++;
searchMaps.put(index, getMatcherNodeFigure(nodeTemp));
}
}
}
if (getMatcherNodeFigure(node).size() > 0) {
index++;
searchMaps.put(index, getMatcherNodeFigure(node));
}
}
}
// for the VarsTables
for (VarTable varTable : varTables) {
for (VarNode node : varTable.getNodes()) {
if (getMatcherNodeFigure(node).size() > 0) {
index++;
searchMaps.put(index, getMatcherNodeFigure(node));
}
}
}
// for the OutputTables
for (OutputXmlTree outputXmlTree : outputTrees) {
// ExpressionFilter
if (outputXmlTree.getExpressionFilter() != null && matcher.matches(outputXmlTree.getExpressionFilter())) {
EList<Adapter> adapter = outputXmlTree.eAdapters();
if (adapter.size() > 0) {
if (adapter.get(0) instanceof OutputXmlTreeEditPart) {
OutputXmlTreeEditPart outputXmlTreeEditPart = (OutputXmlTreeEditPart) adapter.get(0);
if (outputXmlTreeEditPart != null && outputXmlTreeEditPart.getFigure() != null && outputXmlTreeEditPart.getFigure() instanceof OutputXmlTreeFigure) {
OutputXmlTreeFigure outputXmlTreeFigure = (OutputXmlTreeFigure) outputXmlTreeEditPart.getFigure();
Map<Integer, Figure> map = new HashMap<Integer, Figure>();
map.put(0, outputXmlTreeFigure.getFilterContainer());
index++;
searchMaps.put(index, map);
}
}
}
}
// OutputTreeNode
for (OutputTreeNode node : outputXmlTree.getNodes()) {
// id_Document type
if (XmlMapUtil.DOCUMENT.equals(node.getType())) {
for (TreeNode nodeTemp : XmlMapUtil.getFlatChildrenList(node)) {
if (getMatcherNodeFigure(nodeTemp).size() > 0) {
index++;
searchMaps.put(index, getMatcherNodeFigure(nodeTemp));
}
}
} else {
if (getMatcherNodeFigure(node).size() > 0) {
index++;
searchMaps.put(index, getMatcherNodeFigure(node));
}
}
}
}
}
Aggregations