use of org.talend.designer.hl7.ui.data.Element in project tdi-studio-se by Talend.
the class HL7PublicUtil method initTreeRoot.
public HL7TreeNode initTreeRoot(Object treeNode) {
HL7TreeNode node = new Element();
String nodeLabel = getLabel(treeNode, true);
node.setLabel(nodeLabel);
node.setMain(true);
List children = getFirstLevelChild(treeNode);
if (children != null) {
for (Object child : children) {
String label = getLabel(child, true);
HL7TreeNode childEle = cloneATreeNode(child, label);
childEle.setLabel(label);
if (!(child instanceof Group)) {
((Element) childEle).setRow(label);
}
node.addChild(childEle);
}
}
return node;
}
use of org.talend.designer.hl7.ui.data.Element in project tdi-studio-se by Talend.
the class HL7MultiSchemaUI method createCombo.
@Override
protected void createCombo(Composite parent) {
createLabel(parent);
metaTableViewer = new ComboViewer(parent, SWT.NONE);
metaTableViewer.setContentProvider(new ArrayContentProvider());
metaTableViewer.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof SegmentModel) {
return ((SegmentModel) element).getSeg().getName();
}
return super.getText(element);
}
});
final Combo combo = metaTableViewer.getCombo();
GridData data = new GridData();
data.widthHint = 60;
combo.setLayoutData(data);
combo.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
updateCurrentMetadataTable();
linker.removeAllLinks();
linker.getMainui().redrawLinkers();
linker.getBackgroundRefresher().refreshBackground();
}
});
}
use of org.talend.designer.hl7.ui.data.Element in project tdi-studio-se by Talend.
the class HL7OutputManager method tableLoader.
// public void initNodeOrder(HL7TreeNode node) {
// if (node == null) {
// return;
// }
// HL7TreeNode parent = node.getParent();
// if (parent == null) {
// node.setOrder(1);
// String path = TreeUtil.getPath(node);
// orderMap.put(path, order);
// order++;
// }
// List<HL7TreeNode> childNode = node.getChildren();
// for (HL7TreeNode child : childNode) {
// child.setOrder(order);
// String path = TreeUtil.getPath(child);
// orderMap.put(path, order);
// order++;
// if (child.getChildren().size() > 0) {
// initNodeOrder(child);
// }
// }
//
// }
protected void tableLoader(Element element, String parentPath, List<Map<String, String>> table, String defaultValue) {
Map<String, String> newMap = new HashMap<String, String>();
//$NON-NLS-1$
String currentPath = parentPath + "/" + element.getLabel();
newMap.put(HL7InputComponent.PATH, currentPath);
newMap.put(HL7InputComponent.COLUMN, element.getColumnLabel());
newMap.put(HL7InputComponent.ATTRIBUTE, element.isMain() ? "main" : "branch");
newMap.put(HL7InputComponent.VALUE, defaultValue);
newMap.put(HL7InputComponent.ORDER, String.valueOf(getNodeOrder(element)));
newMap.put("REPEATABLE", String.valueOf(element.isRepetable()));
table.add(newMap);
for (HL7TreeNode att : element.getAttributeChildren()) {
newMap = new HashMap<String, String>();
newMap.put(HL7InputComponent.PATH, att.getLabel());
newMap.put(HL7InputComponent.COLUMN, att.getColumnLabel());
//$NON-NLS-1$
newMap.put(HL7InputComponent.ATTRIBUTE, "attri");
newMap.put(HL7InputComponent.VALUE, att.getDefaultValue());
newMap.put(HL7InputComponent.ORDER, String.valueOf(getNodeOrder(att)));
newMap.put("REPEATABLE", String.valueOf(att.isRepetable()));
table.add(newMap);
}
for (HL7TreeNode att : element.getNameSpaceChildren()) {
newMap = new HashMap<String, String>();
newMap.put(HL7InputComponent.PATH, att.getLabel());
newMap.put(HL7InputComponent.COLUMN, att.getColumnLabel());
//$NON-NLS-1$
newMap.put(HL7InputComponent.ATTRIBUTE, "ns");
newMap.put(HL7InputComponent.VALUE, att.getDefaultValue());
newMap.put("REPEATABLE", String.valueOf(att.isRepetable()));
newMap.put(HL7InputComponent.ORDER, String.valueOf(getNodeOrder(att)));
table.add(newMap);
}
List<HL7TreeNode> children = element.getElementChildren();
for (HL7TreeNode child : children) {
// if (!child.isGroup() && !child.isRepetable()) {// && !child.isRepetable()
tableLoader((Element) child, currentPath, table, child.getDefaultValue());
// }
}
}
use of org.talend.designer.hl7.ui.data.Element in project tdi-studio-se by Talend.
the class HL7OutputManager method initModel.
public void initModel() {
List<? extends IConnection> incomingConnections = NodeUtil.getIncomingConnections(hl7Component, IConnectionCategory.FLOW);
// HL7Root root = new HL7Root("root");
List<Map<String, String>> maps = (List<Map<String, String>>) ElementParameterParser.getObjectValue(hl7Component, //$NON-NLS-1$
"__SCHEMAS__");
List<String> schemaList = new ArrayList<String>();
for (IMetadataTable table : hl7Component.getMetadataList()) {
if (table.getLabel() != null) {
schemaList.add(table.getLabel());
}
}
List<Map<String, String>> rootTable = hl7Component.getTableList(HL7InputComponent.ROOT);
Map<String, IMetadataTable> schemaNameToInputTable = new HashMap<String, IMetadataTable>();
if (!maps.isEmpty()) {
for (Map<String, String> map : maps) {
String schemaName = map.get("SCHEMA");
int first = schemaName.indexOf("_");
int second = schemaName.lastIndexOf("_");
if (first > 0 && first < second) {
schemaName = schemaName.substring(first + 1, second);
}
IMetadataTable metadataTable = null;
for (IConnection connection : incomingConnections) {
if (connection.getUniqueName().equals(map.get("PARENT_ROW"))) {
metadataTable = connection.getMetadataTable();
metadataTable.setLabel(connection.getUniqueName());
schemaNameToInputTable.put(schemaName, metadataTable);
break;
}
}
}
} else {
for (String schemaName : schemaList) {
IMetadataTable metadataTable = null;
for (IConnection connection : incomingConnections) {
if (connection.getUniqueName().equals(schemaName)) {
metadataTable = connection.getMetadataTable();
metadataTable.setLabel(connection.getUniqueName());
schemaNameToInputTable.put(schemaName, metadataTable);
}
}
}
}
Map<String, HL7TreeNode> mapNodes = new HashMap<String, HL7TreeNode>();
treeData = new ArrayList<HL7TreeNode>();
HL7TreeNode rootNode = null;
HL7TreeNode current = null;
HL7TreeNode temp = null;
String currentPath = null;
String defaultValue = null;
int nodeOrder = 0;
boolean haveOrder = true;
// build root tree
for (Map<String, String> rootMap : rootTable) {
String newPath = rootMap.get(HL7InputComponent.PATH);
String columnName = rootMap.get(HL7InputComponent.COLUMN);
defaultValue = rootMap.get(HL7InputComponent.VALUE);
String orderValue = rootMap.get(HL7InputComponent.ORDER);
boolean repeatable = Boolean.valueOf(rootMap.get("REPEATABLE"));
if (orderValue == null || "".equals(orderValue)) {
haveOrder = false;
}
String rowName = columnName;
if (columnName != null && columnName.contains(":")) {
String[] names = columnName.split(":");
rowName = names[0];
columnName = names[1];
} else {
columnName = null;
}
temp = this.addElement(current, currentPath, newPath, defaultValue, mapNodes);
if (temp == null) {
// should not happen
continue;
}
if (rootNode == null) {
rootNode = temp;
}
if (rootMap.get(HL7InputComponent.ATTRIBUTE).equals("main")) {
//$NON-NLS-1$
temp.setMain(true);
}
current = temp;
currentPath = newPath;
temp.setRepetable(repeatable);
if (haveOrder) {
temp.setOrder(nodeOrder);
}
if (rowName != null && rowName.length() > 0) {
temp.setRow(rowName);
}
if (columnName != null) {
IMetadataTable metadataTable = schemaNameToInputTable.get(rowName);
// group node can not get the metadata table
if (metadataTable == null) {
IMetadataTable metadataTableTemp = null;
for (IConnection connection : incomingConnections) {
metadataTableTemp = connection.getMetadataTable();
String connectionName = metadataTableTemp.getLabel();
if (connectionName == null) {
connectionName = connection.getUniqueName();
}
if (columnName.startsWith(connectionName)) {
break;
}
}
temp.setColumnName(columnName);
if (metadataTableTemp != null) {
temp.setColumn(metadataTableTemp.getColumn(columnName));
temp.setTable(metadataTableTemp);
}
} else {
temp.setColumnName(columnName);
temp.setColumn(metadataTable.getColumn(columnName));
temp.setTable(metadataTable);
}
}
}
if (rootNode == null) {
rootNode = new Element("rootTag");
}
if (haveOrder) {
orderNode(rootNode);
}
// the root node should not set the ColumnLabel
if (rootNode.getRow() != null) {
rootNode.setRow(null);
}
treeData.add(rootNode);
contents.put(rootNode.getColumnLabel(), treeData);
initCurrentSchema();
}
use of org.talend.designer.hl7.ui.data.Element in project tdi-studio-se by Talend.
the class SetRepetableAction method upsetMainNode.
public void upsetMainNode(HL7TreeNode node) {
if (node instanceof Element) {
HL7TreeNode parent = node;
while (parent != null) {
parent.setMain(true);
parent = parent.getParent();
}
}
}
Aggregations