use of org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode in project tdi-studio-se by Talend.
the class JSONFileOutputStep2Form method checkFieldsValue.
@Override
protected boolean checkFieldsValue() {
int num = 0, rootNum = 0;
StringBuffer msgError = new StringBuffer();
List<FOXTreeNode> onLoopNodes = new ArrayList<FOXTreeNode>();
for (FOXTreeNode node : treeData) {
FOXTreeNode rootFOXTreeNode = TreeUtil.getRootFOXTreeNode(node);
if (rootFOXTreeNode != null) {
if (existedLoopNode(rootFOXTreeNode)) {
num++;
} else {
onLoopNodes.add(rootFOXTreeNode);
}
rootNum++;
}
}
if (num != rootNum) {
msgError.append("Require set as loop\n");
}
if (linker.isNoLinker()) {
msgError.append("No source and target linked");
}
if ("".equals(msgError.toString())) {
updateStatus(IStatus.OK, null);
return true;
}
updateStatus(IStatus.ERROR, msgError.toString());
return false;
}
use of org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode in project tdi-studio-se by Talend.
the class JSONFileOutputStep2Form method orderNode.
private void orderNode(FOXTreeNode node) {
// reset the order.
if (node != null) {
List<FOXTreeNode> firstSubChildren = node.getChildren();
FOXTreeNode foundNode = null;
for (FOXTreeNode childen : firstSubChildren) {
if (childen.isLoop()) {
foundNode = childen;
sortOrder(foundNode, node);
break;
} else if (childen.isGroup()) {
foundNode = childen;
sortOrder(foundNode, node);
orderNode(childen);
} else {
orderNode(childen);
}
}
}
}
use of org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode in project tdi-studio-se by Talend.
the class JSONFileOutputStep2Form method initJSONTreeData.
private void initJSONTreeData() {
treeData.clear();
// metadataColumnList.clear();
EList root = getConnection().getRoot();
EList loop = getConnection().getLoop();
EList group = getConnection().getGroup();
// initialMetadataColumn();
FOXTreeNode rootNode = null;
FOXTreeNode current = null;
FOXTreeNode temp = null;
FOXTreeNode mainNode = null;
String mainPath = null;
String currentPath = null;
String defaultValue = null;
int nodeOrder = 0;
boolean haveOrder = true;
// build root tree
for (int i = 0; i < root.size(); i++) {
JSONFileNode node = (JSONFileNode) root.get(i);
String newPath = node.getJSONPath();
defaultValue = node.getDefaultValue();
String type = node.getType();
String orderValue = String.valueOf(node.getOrder());
if (orderValue == null || "".equals(orderValue)) {
haveOrder = false;
}
if (haveOrder) {
nodeOrder = node.getOrder();
}
if (node.getAttribute().equals("attri")) {
temp = new Attribute(newPath);
temp.setDefaultValue(defaultValue);
temp.setAttribute(true);
temp.setDataType(type);
current.addChild(temp);
} else if (node.getAttribute().equals("ns")) {
temp = new NameSpaceNode(newPath);
temp.setDefaultValue(defaultValue);
temp.setNameSpace(true);
temp.setDataType(type);
current.addChild(temp);
} else {
temp = this.addElement(current, currentPath, newPath, defaultValue);
temp.setDataType(type);
if (rootNode == null) {
rootNode = temp;
}
if (node.getAttribute().equals("main")) {
temp.setMain(true);
mainNode = temp;
mainPath = newPath;
}
current = temp;
currentPath = newPath;
}
if (haveOrder) {
temp.setOrder(nodeOrder);
}
String columnName = node.getRelatedColumn();
if (columnName != null && columnName.length() > 0) {
temp.setColumn(getColumn(columnName));
}
}
// build group tree
current = mainNode;
currentPath = mainPath;
boolean isFirst = true;
for (int i = 0; i < group.size(); i++) {
JSONFileNode node = (JSONFileNode) group.get(i);
String newPath = node.getJSONPath();
defaultValue = node.getDefaultValue();
String type = node.getType();
String orderValue = String.valueOf(node.getOrder());
if (orderValue == null || "".equals(orderValue)) {
haveOrder = false;
}
if (haveOrder) {
nodeOrder = node.getOrder();
}
if (node.getAttribute().equals("attri")) {
temp = new Attribute(newPath);
temp.setDefaultValue(defaultValue);
temp.setAttribute(true);
temp.setDataType(type);
current.addChild(temp);
} else if (node.getAttribute().equals("ns")) {
temp = new NameSpaceNode(newPath);
temp.setDefaultValue(defaultValue);
temp.setNameSpace(true);
temp.setDataType(type);
current.addChild(temp);
} else {
temp = this.addElement(current, currentPath, newPath, defaultValue);
temp.setDataType(type);
if (node.getAttribute().equals("main")) {
temp.setMain(true);
mainNode = temp;
mainPath = newPath;
}
if (isFirst) {
temp.setGroup(true);
isFirst = false;
}
current = temp;
currentPath = newPath;
}
if (haveOrder) {
temp.setOrder(nodeOrder);
}
String columnName = node.getRelatedColumn();
if (columnName != null && columnName.length() > 0) {
temp.setColumn(getColumn(columnName));
}
}
// build loop tree
current = mainNode;
currentPath = mainPath;
isFirst = true;
for (int i = 0; i < loop.size(); i++) {
JSONFileNode node = (JSONFileNode) loop.get(i);
String newPath = node.getJSONPath();
defaultValue = node.getDefaultValue();
String type = node.getType();
String orderValue = String.valueOf(node.getOrder());
if (orderValue == null || "".equals(orderValue)) {
haveOrder = false;
}
if (haveOrder) {
nodeOrder = node.getOrder();
}
if (node.getAttribute().equals("attri")) {
temp = new Attribute(newPath);
temp.setDefaultValue(defaultValue);
temp.setAttribute(true);
temp.setDataType(type);
temp.setDataType(type);
current.addChild(temp);
} else if (node.getAttribute().equals("ns")) {
temp = new NameSpaceNode(newPath);
temp.setDefaultValue(defaultValue);
temp.setNameSpace(true);
temp.setDataType(type);
current.addChild(temp);
} else {
temp = this.addElement(current, currentPath, newPath, defaultValue);
temp.setDataType(type);
// fix for TDI-18802 , if root node is loop
if (rootNode == null) {
rootNode = temp;
}
if (node.getAttribute().equals("main")) {
temp.setMain(true);
mainNode = temp;
mainPath = newPath;
}
if (isFirst) {
temp.setLoop(true);
isFirst = false;
}
current = temp;
currentPath = newPath;
}
if (haveOrder) {
temp.setOrder(nodeOrder);
}
String columnName = node.getRelatedColumn();
if (columnName != null && columnName.length() > 0) {
temp.setColumn(getColumn(columnName));
}
}
if (rootNode == null) {
rootNode = new Element("rootTag");
}
rootNode.setParent(null);
if (haveOrder) {
orderNode(rootNode);
}
treeData.add(rootNode);
}
Aggregations