// FETCH FIELDS FROM MESSAGE TO BE INDEX IN LUCENE private List<ArchiveIndexFieldsVO> getArchiveIndexFields( Document messageDocument, File configureFile) { Document configureDocument = XMLHelper.getXMLDocument(configureFile); List<ArchiveIndexFieldsVO> indexFields = new ArrayList<ArchiveIndexFieldsVO>(); NodeList indexNodeList = (NodeList) XMLHelper.read( configureDocument, "//HL7MessageConfiguration/ArchiveConfiguration/Field", XPathConstants.NODESET); for (int i = 0; i < indexNodeList.getLength(); i++) { Node node = indexNodeList.item(i); Element element = (Element) node; String name = element.getAttribute("name"); String indexed = element.getAttribute("indexed"); String type = element.getAttribute("type"); String value = (String) XMLHelper.read(messageDocument, element.getAttribute("xpath"), XPathConstants.STRING); indexFields.add(new ArchiveIndexFieldsVO(name, indexed, "", value, type)); } return indexFields; }
public void archiveMessage(MessageVO messageVO, String programName) throws Exception { String rowKey = ""; String messageXML = messageVO.getMessage(); streamSerializer.processAnnotations(HL7MessageConfiguration.class); Document messageDocument = XMLHelper.getXMLDocument(messageXML); File configureFile = getConfigurationMessage(messageXML); createColumnFamily(configureFile, messageVO.getOrganizationId()); List<ArchiveIndexFieldsVO> indexFields = getArchiveIndexFields(messageDocument, configureFile); Iterator<ArchiveIndexFieldsVO> iterator = indexFields.iterator(); while (iterator.hasNext()) { ArchiveIndexFieldsVO indexFieldsVO = iterator.next(); if (indexFieldsVO.getType().equals("ROWKEY")) { rowKey = indexFieldsVO.getValue(); } } saveArchiveMessage(rowKey, messageVO, indexFields); }
private File getConfigurationMessage(String messageXML) { Document messageDocument = XMLHelper.getXMLDocument(messageXML); String documentType = messageDocument.getDocumentElement().getAttribute("config"); File configureFile = new File(messageConfigDirPath + File.separator + documentType + ".xml"); return configureFile; }