public Boolean processMessage(GenericMessageHeader gmh) {
Boolean result = false;
JDBQMInspection qmInspection = new JDBQMInspection(getHostID(), getSessionID());
JDBQMExtension qmExtension = new JDBQMExtension(getHostID(), getSessionID());
JDBQMActivity qmActivity = new JDBQMActivity(getHostID(), getSessionID());
JDBQMTest qmTest = new JDBQMTest(getHostID(), getSessionID());
JDBQMDictionary qmDictionary = new JDBQMDictionary(getHostID(), getSessionID());
JDBInterface inter = new JDBInterface(getHostID(), getSessionID());
JDBProcessOrder po = new JDBProcessOrder(getHostID(),getSessionID());
inter.getInterfaceProperties("QM Inspection Request", "Input");
// INSPECTION //
// Decode the Inspection Top Level ID //
inspectionID = gmh.getXMLDocument().findXPath("//message/messageData/inspectionDefinition/ID").trim();
inspectionDescription = gmh.getXMLDocument().findXPath("//message/messageData/inspectionDefinition/description").trim();
processOrder = JUtility.replaceNullStringwithBlank(gmh.getXMLDocument().findXPath("//message/messageData/inspectionDefinition/processOrder").trim());
if (processOrder.equals("")==false)
{
processOrder = processOrder.replaceAll("^0+", "");
po.setProcessOrder(processOrder);
if (po.isValidProcessOrder())
{
po.getProcessOrderProperties();
po.setInspectionID(inspectionID);
po.update();
}
}
qmInspection.setInspectionID(inspectionID);
// Create or update the Inspection record.
if (qmInspection.isValid()==false)
{
// New inspection record to be created.
qmInspection.create(inspectionID, inspectionDescription);
}
else
{
// Amend existing inspection record.
qmInspection.getProperties();
qmInspection.setDescription(inspectionDescription);
qmInspection.update();
}
Long inspectionExtensionID = (long) 0;
inspectionExtensionID=qmInspection.getExtensionID();
// INSPECTION - extended data //
// Scan through XML to process any 'extension' data which needs be stored against the top level Inspection record.
String extensionName = " ";
String extensionValue = "";
int extensionOccurence = 1;
while (extensionName.length() > 0)
{
extensionName = JUtility.replaceNullStringwithBlank(gmh.getXMLDocument().findXPath("//message/messageData/inspectionDefinition/extendedData/item[" + String.valueOf(extensionOccurence) + "]/name").trim());
if (extensionName.length() > 0)
{
extensionValue = JUtility.replaceNullStringwithBlank(gmh.getXMLDocument().findXPath("//message/messageData/inspectionDefinition/extendedData/item[" + String.valueOf(extensionOccurence) + "]/value").trim());
qmExtension.setExtensionID(inspectionExtensionID);
qmExtension.setFieldName(extensionName);
qmExtension.setTableName("APP_QM_INSPECTION");
if (qmExtension.isValid())
{
qmExtension.getProperties();
qmExtension.setValue(extensionValue);
qmExtension.update();
}
else
{
qmExtension.create(inspectionExtensionID,"APP_QM_INSPECTION", extensionName, extensionValue);
}
}
extensionOccurence++;
}
// ACTIVITY //
// Scan through XML to process any 'activity' records which needs be stored against the top level Inspection record.
String activityID = " ";
String activityDescription = "";
Long activityExtensionID = (long) 0;
int ActivityOccurence = 1;
while (activityID.length() > 0)
{
activityID = JUtility.replaceNullStringwithBlank(gmh.getXMLDocument().findXPath("//message/messageData/inspectionDefinition/activity[" + String.valueOf(ActivityOccurence) + "]/ID").trim());
if (activityID.length() > 0)
{
activityDescription = JUtility.replaceNullStringwithBlank(gmh.getXMLDocument().findXPath("//message/messageData/inspectionDefinition/activity[" + String.valueOf(ActivityOccurence) + "]/description").trim());
qmActivity.setInspectionID(inspectionID);
qmActivity.setActivityID(activityID);
if(qmActivity.isValid()==false)
{
// Create new Activity Record.
qmActivity.create(inspectionID, activityID, activityDescription);
}
else
{
// Update Activity Record.
qmActivity.getProperties();
qmActivity.setDescription(activityDescription);
qmActivity.update();
}
activityExtensionID = qmActivity.getExtensionID();
}
// ACTIVITY - extended data //
// Scan through XML to process any 'extension' data which needs be stored against the activity record.