use of bind.feature.generichierarchy.case1.model.Message in project tdi-studio-se by Talend.
the class ImportHL7StructureAction method treeNodeAdapt.
private List treeNodeAdapt() {
List<HL7TreeNode> treeData = new ArrayList<HL7TreeNode>();
FileDialog f = null;
if (hl7ui != null) {
f = new FileDialog(hl7ui.getHl7UIParent().getShell());
} else if (form != null) {
f = new FileDialog(form.getShell());
}
String file = f.open();
if (file == null) {
return treeData;
}
HL7Parse hl7Parse = new HL7Parse();
List<String> msgContentList = new ArrayList<String>();
List<Message> messageList = hl7Parse.doParse(file, "'\\u000b'", "'\\u001c'");
List<HL7TreeNode> nodeList = hl7Util.getHL7TreeNodes(messageList);
if (!nodeList.isEmpty()) {
HL7TreeNode hl7TreeNode = nodeList.get(0);
List<HL7FileNode> table = new ArrayList<HL7FileNode>();
if (hl7Connection != null) {
EList root = hl7Connection.getRoot();
root.clear();
if (hl7TreeNode != null) {
hl7Util.initNodeOrder(hl7TreeNode, orderMap);
hl7Util.tableLoader((Element) hl7TreeNode, "", root, hl7TreeNode.getDefaultValue(), orderMap);
}
table.addAll(root);
} else {
if (hl7TreeNode != null) {
hl7Util.initNodeOrder(hl7TreeNode, orderMap);
hl7Util.tableLoader((Element) hl7TreeNode, "", table, hl7TreeNode.getDefaultValue(), orderMap);
}
}
List<String> schemaList = new ArrayList<String>();
for (HL7FileNode node : table) {
String columnName = node.getRelatedColumn();
if (columnName.contains(":")) {
columnName = columnName.substring(0, columnName.indexOf(":"));
}
if (!schemaList.contains(columnName) && !"".equals(columnName)) {
schemaList.add(columnName);
}
}
initXmlTreeData(schemaList, table, treeData);
}
return treeData;
}
use of bind.feature.generichierarchy.case1.model.Message 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 bind.feature.generichierarchy.case1.model.Message in project camel by apache.
the class HL7DataFormatTest method testUnmarshalWithImplicitBig5Charset.
@Test
public void testUnmarshalWithImplicitBig5Charset() throws Exception {
String charset = "Big5";
MockEndpoint mock = getMockEndpoint("mock:unmarshalBig5");
mock.expectedMessageCount(1);
mock.message(0).body().isInstanceOf(Message.class);
mock.expectedHeaderReceived(HL7Constants.HL7_CHARSET, null);
mock.expectedHeaderReceived(Exchange.CHARSET_NAME, charset);
// Message without explicit encoding in MSH-18, but the unmarshaller "guesses"
// this time that it is Big5
byte[] body = createHL7AsString().getBytes(Charset.forName(charset));
template.sendBody("direct:unmarshalBig5", new ByteArrayInputStream(body));
assertMockEndpointsSatisfied();
Message msg = mock.getExchanges().get(0).getIn().getBody(Message.class);
assertEquals("2.4", msg.getVersion());
QRD qrd = (QRD) msg.get("QRD");
assertEquals("0101701234", qrd.getWhoSubjectFilter(0).getIDNumber().getValue());
}
use of bind.feature.generichierarchy.case1.model.Message in project camel by apache.
the class HL7MLLPCodecStandAndEndBytesTest method createRouteBuilder.
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
public void configure() throws Exception {
from("mina2:tcp://127.0.0.1:" + getPort() + "?sync=true&codec=#hl7codec").process(new Processor() {
public void process(Exchange exchange) throws Exception {
Message input = exchange.getIn().getBody(Message.class);
assertEquals("2.4", input.getVersion());
QRD qrd = (QRD) input.get("QRD");
assertEquals("0101701234", qrd.getWhoSubjectFilter(0).getIDNumber().getValue());
Message response = createHL7AsMessage();
exchange.getOut().setBody(response);
}
}).to("mock:result");
}
};
}
use of bind.feature.generichierarchy.case1.model.Message in project camel by apache.
the class ValidationContextPredicate method matches.
@Override
public boolean matches(Exchange exchange) {
try {
Message message = exchange.getIn().getBody(Message.class);
ValidationContext context = validatorExpression != null ? validatorExpression.evaluate(exchange, ValidationContext.class) : dynamicValidationContext(message, exchange.getIn().getHeader(HL7Constants.HL7_CONTEXT, HapiContext.class));
MessageValidator validator = new MessageValidator(context, false);
return validator.validate(message);
} catch (HL7Exception e) {
throw ObjectHelper.wrapRuntimeCamelException(e);
}
}
Aggregations