use of org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree in project tdi-studio-se by Talend.
the class TreeToolBarContainer method createToolbar.
@Override
protected void createToolbar() {
super.createToolbar();
condensedButton = new CondensedButton(ImageProviderMapper.getImage(ImageInfo.CONDENSED_TOOL_ICON));
condensedButton.setSelected(getTableManager().isActivateCondensedTool());
setTooltips(condensedButton, "tXmlMap settings");
expressionFilterButton = new ExpressionFilterButton(ImageProviderMapper.getImage(ImageInfo.ACTIVATE_FILTER_ICON));
expressionFilterButton.setSelected(getTableManager().isActivateExpressionFilter());
setTooltips(expressionFilterButton, "Enable/disable expression filter");
inputMainTable = ((MapperManager) getTableManager().getGraphicalViewer().getMapperManager()).getMainInputTree();
abstractTree = getTableManager().getModel();
if (abstractTree instanceof OutputXmlTree) {
ImageInfo info = ImageInfo.SETLOOPFUNCTION_BUTTON;
EList<InputLoopNodesTable> inputLoopNodesTables = ((OutputXmlTree) abstractTree).getInputLoopNodesTables();
if (!inputLoopNodesTables.isEmpty() && inputLoopNodesTables.get(0) != null) {
if (inputLoopNodesTables.get(0).getInputloopnodes().isEmpty()) {
info = ImageInfo.SETLOOPFUNCTION_BUTTON_ERROR;
}
}
setLoopFunctionButton = new SetLoopFunctionButton(ImageProviderMapper.getImage(info));
setTooltips(setLoopFunctionButton, "set Loop Function");
this.add(setLoopFunctionButton);
if (inputMainTable == null || !inputMainTable.isMultiLoops()) {
setLoopFunctionButton.setVisible(false);
}
}
// TDI-22087
if (abstractTree instanceof OutputXmlTree || (abstractTree instanceof InputXmlTree && ((InputXmlTree) abstractTree).isLookup())) {
this.add(condensedButton);
this.add(expressionFilterButton);
}
boolean isErrorReject = false;
if (abstractTree instanceof OutputXmlTree) {
isErrorReject = ((OutputXmlTree) abstractTree).isErrorReject();
}
if (isErrorReject) {
condensedButton.setEnabled(false);
expressionFilterButton.setEnabled(false);
}
this.add(min_size);
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree in project tdi-studio-se by Talend.
the class TXMLMapChangeAllInOneValueMigrationTask method execute.
/*
* (non-Javadoc)
*
* @see
* org.talend.core.model.migration.TXMLMapChangeAllInOneValueMigrationTask
* (org .talend.core.model.properties.Item)
*/
@Override
public ExecutionResult execute(Item item) {
IProxyRepositoryFactory factory = CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory();
ProcessType processType = getProcessType(item);
boolean modified = false;
if (processType != null) {
for (Object obj : processType.getNode()) {
NodeType nodeType = (NodeType) obj;
if (nodeType.getComponentName().startsWith("tXMLMap")) {
XmlMapData xmlMapdata = (XmlMapData) nodeType.getNodeData();
EList<OutputXmlTree> outputTables = xmlMapdata.getOutputTrees();
EList<InputXmlTree> inputTables = xmlMapdata.getInputTrees();
boolean hasDocumentInTheMainInputTable = false;
for (InputXmlTree inputTable : inputTables) {
if (!(inputTable.isLookup())) {
for (TreeNode inputEntry : inputTable.getNodes()) {
if ("id_Document".equals(inputEntry.getType())) {
hasDocumentInTheMainInputTable = true;
}
}
}
}
if (hasDocumentInTheMainInputTable) {
for (OutputXmlTree outputTable : outputTables) {
for (TreeNode outputEntry : outputTable.getNodes()) {
if ("id_Document".equals(outputEntry.getType())) {
if (!outputTable.isAllInOne()) {
outputTable.setAllInOne(true);
modified = true;
break;
}
}
}
}
}
}
}
}
try {
if (modified) {
factory.save(item, true);
return ExecutionResult.SUCCESS_WITH_ALERT;
} else {
return ExecutionResult.SUCCESS_NO_ALERT;
}
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree in project tdi-studio-se by Talend.
the class SetLoopAction method run.
@Override
public void run() {
TreeNode model = (TreeNode) nodePart.getModel();
TreeNode docRoot = XmlMapUtil.getTreeNodeRoot(model);
AbstractInOutTree abstractTree = (AbstractInOutTree) docRoot.eContainer();
boolean isLookup = abstractTree != mapperManager.getMainInputTree() && !(abstractTree instanceof OutputXmlTree);
// remove old group
if (model instanceof OutputTreeNode) {
OutputTreeNode outputNode = (OutputTreeNode) model;
if (docRoot != null) {
XmlMapUtil.cleanSubGroup(outputNode);
List<TreeNode> newLoopUpGroups = new ArrayList<TreeNode>();
findUpGroupNode(newLoopUpGroups, outputNode);
// clean all groups except the ancestor of new loop
XmlMapUtil.cleanSubGroup(docRoot, newLoopUpGroups);
// reset the group in case some element ancestor of loop element are not group but under the group
if (!newLoopUpGroups.isEmpty()) {
TreeNode rootGroup = newLoopUpGroups.get(newLoopUpGroups.size() - 1);
upsetGroup(outputNode, rootGroup);
}
}
}
if (!isLookup) {
// TDI-20147
List<TreeNode> loopNodes = new ArrayList<TreeNode>();
checkSubElementIsLoop(model, loopNodes);
checkParentElementIsLoop(model, loopNodes);
if (!loopNodes.isEmpty()) {
if (MessageDialog.openConfirm(Display.getDefault().getActiveShell(), Messages.getString("SetLoopAction.cleanSubLoopTitle"), Messages.getString("SetLoopAction.cleanSubLoopMessages"))) {
} else {
return;
}
}
for (TreeNode treeNode : loopNodes) {
treeNode.setLoop(false);
}
model.setLoop(true);
XmlMapUtil.clearMainNode(model);
XmlMapUtil.upsetMainNode(model);
abstractTree.setMultiLoops(XmlMapUtil.checkMultiLoopsStatus(abstractTree));
if (input) {
// check if child is mapped to output remove the old loop in output node
XmlMapUtil.removeloopInOutputTree(mapperManager, loopNodes);
// disable the function to add sourceloop into InputLoopNodesTable automatically
// add input loopNodes to InputLoopNodesTable
// addInputLoopNodesToOutput(model, model);
} else {
// clean the InputLoopNodesTable for the old loops
InputXmlTree mainInput = mapperManager.getMainInputTree();
XmlMapUtil.removeLoopTableForOutput((OutputXmlTree) abstractTree, loopNodes, mainInput == null ? false : mainInput.isMultiLoops());
}
} else {
if (docRoot != null) {
cleanSubLoop(docRoot);
}
model.setLoop(true);
XmlMapUtil.clearMainNode(docRoot);
XmlMapUtil.upsetMainNode(model);
}
if (abstractTree != null) {
mapperManager.getProblemsAnalyser().checkProblems(abstractTree);
mapperManager.getMapperUI().updateStatusBar();
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree in project tdi-studio-se by Talend.
the class ImportTreeFromRepository method run.
@Override
public void run() {
targetAbsolutePath = null;
loopNode = null;
xpathAndOrder.clear();
RepositoryXmlSelectionDialog reviewDialog = new RepositoryXmlSelectionDialog(shell, new String[] { "XML", "MDM" });
if (reviewDialog.open() == Window.OK) {
TreeNode treeNodeRoot = XmlMapUtil.getTreeNodeRoot(schemaNode);
XmlMapUtil.detachNodeConnections(treeNodeRoot, mapperManager.getExternalData(), true);
RepositoryNode repositoryNode = reviewDialog.getResult();
Item item = repositoryNode.getObject().getProperty().getItem();
String detailedMessage = "";
try {
if (item instanceof XmlFileConnectionItem) {
XmlFileConnectionItem xmlitem = (XmlFileConnectionItem) item;
XmlFileConnection connection = (XmlFileConnection) xmlitem.getConnection();
prepareEmfTreeFromXml(connection);
} else if (item instanceof MDMConnectionItem) {
String selectedSchema = (String) repositoryNode.getProperties(EProperties.LABEL);
MDMConnection connection = (MDMConnection) ((MDMConnectionItem) item).getConnection();
prepareEmfTreeFromMdm(connection, selectedSchema);
}
} catch (Exception e) {
ExceptionHandler.process(e);
StringBuffer sb = new StringBuffer();
sb.append(e.toString());
sb.append("\n");
if (e.getStackTrace() != null) {
for (StackTraceElement trace : e.getStackTrace()) {
sb.append(trace.toString());
sb.append("\n");
}
}
detailedMessage = sb.toString();
}
boolean childrenEmpty = false;
if (schemaNode.getChildren().isEmpty()) {
childrenEmpty = true;
TreeNode rootNode = createModel();
rootNode.setName("root");
rootNode.setNodeType(NodeType.ELEMENT);
rootNode.setType(XmlMapUtil.DEFAULT_DATA_TYPE);
rootNode.setXpath(XmlMapUtil.getXPath(schemaNode.getXpath(), "root", NodeType.ELEMENT));
schemaNode.getChildren().add(rootNode);
if (loopNode == null) {
schemaNode.getChildren().get(0).setLoop(true);
schemaNode.getChildren().get(0).setMain(true);
}
}
if (childrenEmpty || (detailedMessage != null && !"".equals(detailedMessage))) {
showError(detailedMessage);
}
AbstractInOutTree tree = null;
if (schemaNode.eContainer() instanceof InputXmlTree) {
XmlMapConnectionBuilder connectionBuilder = new XmlMapConnectionBuilder();
connectionBuilder.setCheckRootNodePrefix(true);
connectionBuilder.rebuildLinks(schemaNode, mapperManager.getExternalData());
mapperManager.refreshTreeSchemaEditor((InputXmlTree) schemaNode.eContainer());
// mapperManager.inputTreeSchemaBeanListModified();
tree = (InputXmlTree) schemaNode.eContainer();
} else if (schemaNode.eContainer() instanceof OutputXmlTree) {
// mapperManager.outputTreeSchemaBeanListModified();
mapperManager.refreshTreeSchemaEditor((OutputXmlTree) schemaNode.eContainer());
tree = (OutputXmlTree) schemaNode.eContainer();
}
if (tree != null) {
mapperManager.getProblemsAnalyser().checkProblems(tree);
mapperManager.getMapperUI().updateStatusBar();
}
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree in project tdi-studio-se by Talend.
the class TreeSettingDirectEditCommand method execute.
@Override
public void execute() {
try {
if (model instanceof InputXmlTree) {
InputXmlTree inputTree = (InputXmlTree) model;
if (type != null) {
switch(type) {
case LOOKUP_MODEL:
inputTree.setLookupMode(getLookupModelByLabel((String) newValue));
break;
case MATCH_MODEL:
inputTree.setMatchingMode(getMatchModelByLabel((String) newValue));
break;
case JOIN_MODEL:
if (TreeSettingsConstant.INNER_JOIN.equals(newValue)) {
inputTree.setInnerJoin(true);
} else {
inputTree.setInnerJoin(false);
}
break;
case PERSISTENT_MODEL:
inputTree.setPersistent(Boolean.valueOf((String) newValue));
break;
case EXPRESSION_FILTER:
calculateFilterConnections(inputTree, (String) newValue);
inputTree.setExpressionFilter((String) newValue);
break;
default:
break;
}
}
} else if (model instanceof OutputXmlTree) {
OutputXmlTree outputTree = (OutputXmlTree) model;
if (type != null) {
switch(type) {
case OUTPUT_REJECT:
outputTree.setReject(Boolean.valueOf((String) newValue));
break;
case LOOK_UP_INNER_JOIN_REJECT:
outputTree.setRejectInnerJoin(Boolean.valueOf((String) newValue));
break;
case EXPRESSION_FILTER:
calculateFilterConnections(outputTree, (String) newValue);
outputTree.setExpressionFilter((String) newValue);
break;
case ALL_IN_ONE:
outputTree.setAllInOne(Boolean.valueOf((String) newValue));
break;
case ENABLE_EMPTY_ELEMENT:
outputTree.setEnableEmptyElement(Boolean.valueOf((String) newValue));
}
}
}
} catch (PatternSyntaxException ex) {
// Syntax error in the regular expression
}
}
Aggregations