use of bind.feature.generichierarchy.case1.model.Message in project kripton by xcesco.
the class MessageListResponseBindMap method serializeOnXml.
/**
* method for xml serialization
*/
@Override
public void serializeOnXml(MessageListResponse object, XMLSerializer xmlSerializer, int currentEventType) throws Exception {
if (currentEventType == 0) {
xmlSerializer.writeStartElement("messageListResponse");
}
// field detailMessage (mapped with "detailMessage")
if (object.getDetailMessage() != null) {
xmlSerializer.writeStartElement("detailMessage");
xmlSerializer.writeCharacters(StringEscapeUtils.escapeXml10(object.getDetailMessage()));
xmlSerializer.writeEndElement();
}
// field list (mapped with "list")
if (object.getList() != null) {
int n = object.getList().size();
Message item;
for (int i = 0; i < n; i++) {
item = object.getList().get(i);
if (item == null) {
xmlSerializer.writeEmptyElement("list");
} else {
xmlSerializer.writeStartElement("list");
messageBindMap.serializeOnXml(item, xmlSerializer, 2);
xmlSerializer.writeEndElement();
}
}
// to distinguish between first empty element and empty collection, we write an attribute emptyCollection
if (n == 0) {
xmlSerializer.writeStartElement("list");
xmlSerializer.writeAttribute("emptyCollection", "true");
xmlSerializer.writeEndElement();
}
}
// field status (mapped with "status")
if (object.getStatus() != null) {
xmlSerializer.writeStartElement("status");
xmlSerializer.writeCharacters(StringEscapeUtils.escapeXml10(object.getStatus().toString()));
xmlSerializer.writeEndElement();
}
if (currentEventType == 0) {
xmlSerializer.writeEndElement();
}
}
use of bind.feature.generichierarchy.case1.model.Message in project kripton by xcesco.
the class MessageListResponseBindMap method parseOnJacksonAsString.
/**
* parse with jackson
*/
@Override
public MessageListResponse parseOnJacksonAsString(JsonParser jacksonParser) throws Exception {
MessageListResponse instance = new MessageListResponse();
String fieldName;
if (jacksonParser.getCurrentToken() == null) {
jacksonParser.nextToken();
}
if (jacksonParser.getCurrentToken() != JsonToken.START_OBJECT) {
jacksonParser.skipChildren();
return instance;
}
while (jacksonParser.nextToken() != JsonToken.END_OBJECT) {
fieldName = jacksonParser.getCurrentName();
jacksonParser.nextToken();
// Parse fields:
switch(fieldName) {
case "detailMessage":
// field detailMessage (mapped with "detailMessage")
if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
instance.setDetailMessage(jacksonParser.getText());
}
break;
case "list":
// field list (mapped with "list")
if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
ArrayList<Message> collection = new ArrayList<>();
Message item = null;
String tempValue = null;
while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
tempValue = jacksonParser.getValueAsString();
if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && "null".equals(tempValue)) {
item = null;
} else {
item = messageBindMap.parseOnJacksonAsString(jacksonParser);
}
collection.add(item);
}
instance.setList(collection);
} else if (jacksonParser.currentToken() == JsonToken.VALUE_STRING && !StringUtils.hasText(jacksonParser.getValueAsString())) {
ArrayList<Message> collection = new ArrayList<>();
instance.setList(collection);
}
break;
case "status":
// field status (mapped with "status")
if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
String tempEnum = jacksonParser.getText();
instance.setStatus(StringUtils.hasText(tempEnum) ? ServiceStatusType.valueOf(tempEnum) : null);
}
break;
default:
jacksonParser.skipChildren();
break;
}
}
return instance;
}
use of bind.feature.generichierarchy.case1.model.Message in project kripton by xcesco.
the class MessageListResponseBindMap method parseOnJackson.
/**
* parse with jackson
*/
@Override
public MessageListResponse parseOnJackson(JsonParser jacksonParser) throws Exception {
MessageListResponse instance = new MessageListResponse();
String fieldName;
if (jacksonParser.currentToken() == null) {
jacksonParser.nextToken();
}
if (jacksonParser.currentToken() != JsonToken.START_OBJECT) {
jacksonParser.skipChildren();
return instance;
}
while (jacksonParser.nextToken() != JsonToken.END_OBJECT) {
fieldName = jacksonParser.getCurrentName();
jacksonParser.nextToken();
// Parse fields:
switch(fieldName) {
case "detailMessage":
// field detailMessage (mapped with "detailMessage")
if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
instance.setDetailMessage(jacksonParser.getText());
}
break;
case "list":
// field list (mapped with "list")
if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
ArrayList<Message> collection = new ArrayList<>();
Message item = null;
while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
if (jacksonParser.currentToken() == JsonToken.VALUE_NULL) {
item = null;
} else {
item = messageBindMap.parseOnJackson(jacksonParser);
}
collection.add(item);
}
instance.setList(collection);
}
break;
case "status":
// field status (mapped with "status")
if (jacksonParser.currentToken() != JsonToken.VALUE_NULL) {
String tempEnum = jacksonParser.getText();
instance.setStatus(StringUtils.hasText(tempEnum) ? ServiceStatusType.valueOf(tempEnum) : null);
}
break;
default:
jacksonParser.skipChildren();
break;
}
}
return instance;
}
use of bind.feature.generichierarchy.case1.model.Message in project kripton by xcesco.
the class MessageListResponseBindMap method serializeOnJackson.
@Override
public int serializeOnJackson(MessageListResponse object, JsonGenerator jacksonSerializer) throws Exception {
jacksonSerializer.writeStartObject();
int fieldCount = 0;
// field detailMessage (mapped with "detailMessage")
if (object.getDetailMessage() != null) {
fieldCount++;
jacksonSerializer.writeStringField("detailMessage", object.getDetailMessage());
}
// field list (mapped with "list")
if (object.getList() != null) {
fieldCount++;
int n = object.getList().size();
Message item;
// write wrapper tag
jacksonSerializer.writeFieldName("list");
jacksonSerializer.writeStartArray();
for (int i = 0; i < n; i++) {
item = object.getList().get(i);
if (item == null) {
jacksonSerializer.writeNull();
} else {
messageBindMap.serializeOnJackson(item, jacksonSerializer);
}
}
jacksonSerializer.writeEndArray();
}
// field status (mapped with "status")
if (object.getStatus() != null) {
fieldCount++;
jacksonSerializer.writeStringField("status", object.getStatus().toString());
}
jacksonSerializer.writeEndObject();
return fieldCount;
}
use of bind.feature.generichierarchy.case1.model.Message in project openmrs-core by openmrs.
the class HL7ServiceImpl method processHL7InQueue.
/**
* @see org.openmrs.hl7.HL7Service#processHL7InQueue(org.openmrs.hl7.HL7InQueue)
*/
@Override
public HL7InQueue processHL7InQueue(HL7InQueue hl7InQueue) throws HL7Exception {
if (hl7InQueue == null) {
throw new HL7Exception("hl7InQueue argument cannot be null");
}
// mark this queue object as processing so that it isn't processed twice
if (OpenmrsUtil.nullSafeEquals(HL7Constants.HL7_STATUS_PROCESSING, hl7InQueue.getMessageState())) {
throw new HL7Exception("The hl7InQueue message with id: " + hl7InQueue.getHL7InQueueId() + " is already processing. " + ",key=" + hl7InQueue.getHL7SourceKey() + ")");
} else {
hl7InQueue.setMessageState(HL7Constants.HL7_STATUS_PROCESSING);
}
if (log.isDebugEnabled()) {
log.debug("Processing HL7 inbound queue (id=" + hl7InQueue.getHL7InQueueId() + ",key=" + hl7InQueue.getHL7SourceKey() + ")");
}
// Parse the HL7 into an HL7Message or abort with failure
String hl7Message = hl7InQueue.getHL7Data();
try {
// Parse the inbound HL7 message using the parser
// NOT making a direct call here so that AOP can happen around this
// method
Message parsedMessage = Context.getHL7Service().parseHL7String(hl7Message);
// Send the parsed message to our receiver routine for processing
// into db
// NOT making a direct call here so that AOP can happen around this
// method
Context.getHL7Service().processHL7Message(parsedMessage);
// Move HL7 inbound queue entry into the archive before exiting
log.debug("Archiving HL7 inbound queue entry");
Context.getHL7Service().saveHL7InArchive(new HL7InArchive(hl7InQueue));
log.debug("Removing HL7 message from inbound queue");
Context.getHL7Service().purgeHL7InQueue(hl7InQueue);
} catch (HL7Exception e) {
boolean skipError = false;
log.debug("Unable to process hl7inqueue: " + hl7InQueue.getHL7InQueueId(), e);
log.debug("Hl7inqueue source: " + hl7InQueue.getHL7Source());
log.debug("hl7_processor.ignore_missing_patient_non_local? " + Context.getAdministrationService().getGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_IGNORE_MISSING_NONLOCAL_PATIENTS, "false"));
if (e.getCause() != null && "Could not resolve patient".equals(e.getCause().getMessage()) && !"local".equals(hl7InQueue.getHL7Source().getName()) && "true".equals(Context.getAdministrationService().getGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_IGNORE_MISSING_NONLOCAL_PATIENTS, "false"))) {
skipError = true;
}
if (!skipError) {
setFatalError(hl7InQueue, "Trouble parsing HL7 message (" + hl7InQueue.getHL7SourceKey() + ")", e);
}
} catch (Exception e) {
setFatalError(hl7InQueue, "Exception while attempting to process HL7 In Queue (" + hl7InQueue.getHL7SourceKey() + ")", e);
}
return hl7InQueue;
}
Aggregations