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); }
// SAVE ARCHIVE MESSAGE IN CASSANDRA private void saveArchiveMessage( String rowKey, MessageVO messageVO, List<ArchiveIndexFieldsVO> indexFields) throws Exception { String messageXML = messageVO.getMessage(); HashMap<String, String> columnValueMap = new HashMap<String, String>(); String messageId = "", responsiblePartyName = "", program = ""; columnValueMap.put("ROWKEY", rowKey); columnValueMap.put("MESSAGE", messageXML); Iterator<ArchiveIndexFieldsVO> iterator = indexFields.iterator(); while (iterator.hasNext()) { ArchiveIndexFieldsVO indexFieldsVO = iterator.next(); if (indexFieldsVO.getName().equals("program")) { program = indexFieldsVO.getValue(); } else if (indexFieldsVO.getName().equals("responsiblePartyName")) { responsiblePartyName = indexFieldsVO.getValue(); } columnValueMap.put(indexFieldsVO.getName(), indexFieldsVO.getValue()); } cassandraConnector.saveStandardColumnFamily( columnValueMap, messageConfiguration.getMetaInfo().getArtifactID(), messageVO.getOrganizationId()); statisticsService.insertIntoIndex(messageXML, rowKey, program, responsiblePartyName); }