use of org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData 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.XmlMapData in project tdi-studio-se by Talend.
the class FixValueAction method run.
@Override
public void run() {
if (selectedNode != null) {
NameSpaceDialog nsDialog = new NameSpaceDialog(null);
nsDialog.setCurrentNode(selectedNode);
nsDialog.setParentNode((TreeNode) selectedNode.eContainer());
int status = nsDialog.open();
if (status == nsDialog.OK) {
String defaultValue = nsDialog.getNSValue();
if (defaultValue != null) {
defaultValue = defaultValue.trim();
}
String prefix = nsDialog.getPrefix().trim();
selectedNode.setDefaultValue(defaultValue);
if (prefix == null || "".equals(prefix)) {
prefix = XmlMapUtil.DEFAULT_NAME_SPACE_PREFIX;
}
selectedNode.setName(prefix);
XmlMapData externalEmfData = (XmlMapData) mapperManager.getExternalData();
XmlMapUtil.updateXPathAndExpression(externalEmfData, mapperManager.getMapperComponent().getExpressionManager(), selectedNode, prefix, XmlMapUtil.getXPathLength(selectedNode.getXpath()), true);
}
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData in project tdi-studio-se by Talend.
the class RenameTreeNodeAction method run.
@Override
public void run() {
if (selectedNode != null) {
// validataor
IInputValidator validataor = new IInputValidator() {
public String isValid(String newText) {
String xpath = XmlMapUtil.getXPath(((TreeNode) selectedNode.eContainer()).getXpath(), newText, selectedNode.getNodeType());
EList<TreeNode> children = ((TreeNode) selectedNode.eContainer()).getChildren();
boolean exist = false;
for (TreeNode child : children) {
if (child.getNodeType().equals(selectedNode.getNodeType())) {
if (child.getXpath() != null && child.getXpath().equals(xpath) && !child.equals(selectedNode)) {
exist = true;
break;
}
}
}
if (exist) {
if (selectedNode.getNodeType().equals(NodeType.ATTRIBUT)) {
return "Atribute '" + newText + "' already exist !";
} else if (selectedNode.getNodeType().equals(NodeType.ELEMENT)) {
return "Element '" + newText + "' already exist !";
}
}
return null;
}
};
String name = selectedNode.getName();
if (selectedNode.isSubstitution()) {
name = name.substring(0, name.lastIndexOf(XSDPopulationUtil2.SUBS));
}
InputDialog dialog = new InputDialog(null, "Rename Tree Node", "", name, validataor);
if (dialog.open() == Window.OK) {
if (selectedNode.isSubstitution()) {
selectedNode.setName(dialog.getValue() + XSDPopulationUtil2.SUBS);
} else {
selectedNode.setName(dialog.getValue());
}
// refresh
if (selectedNode.isSubstitution()) {
TreeNode realParent = XmlMapUtil.getRealParentNode(selectedNode);
if (realParent != null) {
selectedNode.setXpath(XmlMapUtil.getXPath(realParent.getXpath(), selectedNode.getName(), selectedNode.getNodeType()));
}
} else {
XmlMapData externalEmfData = (XmlMapData) mapperManager.getExternalData();
XmlMapUtil.updateXPathAndExpression(externalEmfData, mapperManager.getMapperComponent().getExpressionManager(), selectedNode, dialog.getValue(), XmlMapUtil.getXPathLength(selectedNode.getXpath()), true);
}
TabFolderEditors tabFolderEditors = mapperManager.getMapperUI().getTabFolderEditors();
if (tabFolderEditors != null) {
if (selectedNode instanceof OutputTreeNode) {
tabFolderEditors.getOutputTreeSchemaEditor().refresh();
} else if (selectedNode instanceof TreeNode) {
tabFolderEditors.getInputTreeSchemaEditor().refresh();
}
}
}
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData in project tdi-studio-se by Talend.
the class XMLMapperHelper method hasDocumentInMainInput.
private static boolean hasDocumentInMainInput(final INode xmlMapperNode) {
boolean hasDocumentInMainInput = false;
List<? extends IConnection> inConnections = (List<? extends IConnection>) xmlMapperNode.getIncomingConnections();
XmlMapData xmlMapData = (XmlMapData) ElementParameterParser.getObjectValueXMLTree(xmlMapperNode);
if (xmlMapData != null && inConnections != null && inConnections.size() > 0) {
List<InputXmlTree> inputTables = xmlMapData.getInputTrees();
HashMap<String, IConnection> hNameToConnection = new HashMap<String, IConnection>();
for (IConnection connection : inConnections) {
hNameToConnection.put(connection.getName(), connection);
}
for (InputXmlTree inputTable : inputTables) {
String tableName = inputTable.getName();
IConnection connection = hNameToConnection.get(tableName);
if (connection == null) {
continue;
}
if (!(inputTable.isLookup())) {
for (TreeNode node : inputTable.getNodes()) {
if ("id_Document".equals(node.getType())) {
hasDocumentInMainInput = true;
break;
}
}
}
}
}
return hasDocumentInMainInput;
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData in project tdi-studio-se by Talend.
the class ProblemsAnalyser method checkProblems.
public List<Problem> checkProblems() {
treeAndProblems.clear();
final XmlMapData copyOfMapData = mapperManager.getExternalData();
if (copyOfMapData != null) {
// check problems for InputLoopTable in output
InputXmlTree mainInputTree = mapperManager.getMainInputTree();
for (OutputXmlTree outputTree : copyOfMapData.getOutputTrees()) {
checkInputLoopTablesProblem(outputTree, mainInputTree);
}
for (InputXmlTree inputTree : copyOfMapData.getInputTrees()) {
isMultipleDocType = false;
checkTreeNodesProblem(inputTree, inputTree.getNodes());
}
for (OutputXmlTree outputTree : copyOfMapData.getOutputTrees()) {
isMultipleDocType = false;
checkTreeNodesProblem(outputTree, outputTree.getNodes());
}
}
return getProblems();
}
Aggregations