use of org.talend.designer.hl7.model.SegmentModel in project tdi-studio-se by Talend.
the class HL7PublicUtil method getChildren.
public Set getChildren(Object parentElement) {
// List values = new ArrayList();
Set values = new HashSet();
if (parentElement instanceof Message) {
Message messParent = (Message) parentElement;
String[] childNames = messParent.getNames();
if (!values.isEmpty()) {
values.clear();
}
for (int i = 0; i < childNames.length; i++) {
try {
Structure[] childReps = messParent.getAll(childNames[i]);
for (int j = 0; j < childReps.length; j++) {
if (childReps[j] instanceof Message) {
values.add(childReps[j]);
if (getChildren(childReps[j]).size() > 0) {
values.addAll(getChildren(childReps[j]));
}
}
if (childReps[j] instanceof Group) {
values.add(childReps[j]);
allSegmentFromGroup.clear();
getAllSegmentsFromGroup((Group) childReps[j]);
}
if (childReps[j] instanceof Segment) {
SegmentModel sModel = new SegmentModel((Segment) childReps[j], messParent, i, j);
if (sModel.getTypes() != null && sModel.getTypes().length > 0) {
values.add(sModel);
if (getChildren(sModel).size() > 0) {
values.addAll(getChildren(sModel));
}
if (!allSegmentsForMessage.contains(sModel)) {
allSegmentsForMessage.add(sModel);
}
}
}
}
// values.addAll(Arrays.asList(childReps));
} catch (HL7Exception e) {
e.printStackTrace();
}
}
return values;
}
if (parentElement instanceof Segment) {
values.clear();
Segment segment = (Segment) parentElement;
SegmentModel sm = new SegmentModel(segment, segment, 0, 0);
TypeModel[] models = sm.getTypes();
for (TypeModel model : models) {
values.add(model);
if (getChildren(model).size() > 0) {
values.addAll(getChildren(model));
}
}
return values;
}
if (parentElement instanceof SegmentModel) {
SegmentModel sm = (SegmentModel) parentElement;
TypeModel[] models = sm.getTypes();
for (TypeModel model : models) {
values.add(model);
if (getChildren(model).size() > 0) {
values.addAll(getChildren(model));
}
}
return values;
}
if (parentElement instanceof TypeModel) {
TypeModel tm = (TypeModel) parentElement;
PrimitiveModel[] models = tm.getPrimitives();
for (PrimitiveModel model : models) {
values.add(model);
if (getChildren(model).size() > 0) {
values.addAll(getChildren(model));
}
}
return values;
// return tm.getPrimitives();
}
if (parentElement instanceof Group) {
values.clear();
Group group = (Group) parentElement;
String[] childNames = group.getNames();
for (int i = 0; i < childNames.length; i++) {
try {
Structure[] childReps = group.getAll(childNames[i]);
for (int j = 0; j < childReps.length; j++) {
if (childReps[j] instanceof Segment) {
SegmentModel sm = new SegmentModel((Segment) childReps[j], group, i, j);
if (sm.getTypes() != null && sm.getTypes().length > 0) {
values.add(sm);
if (getChildren(sm).size() > 0) {
values.addAll(getChildren(sm));
}
}
} else {
values.add(childReps[j]);
if (getChildren(childReps[j]).size() > 0) {
values.addAll(getChildren(childReps[j]));
}
}
}
// values.addAll(Arrays.asList(childReps));
} catch (HL7Exception e) {
e.printStackTrace();
}
}
return values;
}
return values;
}
use of org.talend.designer.hl7.model.SegmentModel 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.model.SegmentModel in project tdi-studio-se by Talend.
the class HL7PublicUtil method getFirstLevelChild.
public List getFirstLevelChild(Object parentElement) {
List values = new ArrayList();
if (parentElement instanceof Message) {
Message messParent = (Message) parentElement;
String[] childNames = messParent.getNames();
if (!values.isEmpty()) {
values.clear();
}
for (int i = 0; i < childNames.length; i++) {
try {
Structure[] childReps = messParent.getAll(childNames[i]);
for (int j = 0; j < childReps.length; j++) {
if (childReps[j] instanceof Message) {
values.add(childReps[j]);
}
if (childReps[j] instanceof Group) {
values.add(childReps[j]);
allSegmentFromGroup.clear();
getAllSegmentsFromGroup((Group) childReps[j]);
}
if (childReps[j] instanceof Segment) {
SegmentModel sModel = new SegmentModel((Segment) childReps[j], messParent, i, j);
if (sModel.getTypes() != null && sModel.getTypes().length > 0) {
values.add(sModel);
if (!allSegmentsForMessage.contains(sModel)) {
allSegmentsForMessage.add(sModel);
}
}
}
}
} catch (HL7Exception e) {
e.printStackTrace();
}
}
}
return values;
}
use of org.talend.designer.hl7.model.SegmentModel in project tdi-studio-se by Talend.
the class HL7PublicUtil method cloneATreeNode.
public HL7TreeNode cloneATreeNode(Object treeNode, String label) {
HL7TreeNode node = new Element();
String nodeLabel = getLabel(treeNode, true);
node.setLabel(nodeLabel);
String rowLabel = label;
if (treeNode instanceof SegmentModel) {
((Element) node).setRow(nodeLabel);
rowLabel = nodeLabel;
} else if (!(treeNode instanceof Group)) {
((Element) node).setRow(rowLabel);
}
node.setMain(true);
// treeNode.getChildren();
Object[] children = getChildList(treeNode);
if (children != null) {
for (Object element : children) {
if (getChildList(element).length > 0) {
String tlabel = getLabel(element, true);
String childLabel = rowLabel;
HL7TreeNode childEle = cloneATreeNode(element, rowLabel);
if (element instanceof SegmentModel) {
childLabel = tlabel;
}
childEle.setLabel(tlabel);
if (childEle instanceof Element) {
((Element) childEle).setRow(childLabel);
}
node.addChild(childEle);
} else {
HL7TreeNode childEle = new Element();
String tlabel = getLabel(element, false);
childEle.setLabel(tlabel);
if (childEle instanceof Element) {
((Element) childEle).setRow(label);
((Element) childEle).setColumnName(getLabel(element, true));
}
childEle.setMain(false);
node.addChild(childEle);
}
}
}
return node;
}
use of org.talend.designer.hl7.model.SegmentModel in project tdi-studio-se by Talend.
the class HL7MultiSchemaUI method initMappingMap.
private void initMappingMap(List<SegmentModel> segments) {
for (SegmentModel sm : segments) {
List<MetadataColumn> list = new ArrayList<MetadataColumn>();
hl7Manager.getSchemaRelationMap().put(sm.getDisplayName(), list);
}
}
Aggregations