Skip to content

Commit

Permalink
Merge pull request #20 from MeasureAuthoringTool/MAT-6911
Browse files Browse the repository at this point in the history
MAT-6911 data type template file reading failed in dev
  • Loading branch information
adongare authored Mar 12, 2024
2 parents 96e4995 + 919ead0 commit f312424
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
19 changes: 4 additions & 15 deletions src/main/java/gov/cms/madie/hqmf/QDMTemplateProcessorFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

import lombok.extern.slf4j.Slf4j;

import java.io.File;
import java.net.URISyntaxException;
import java.net.URL;
import java.io.InputStream;

/**
* DO NOT DELETE OLDER GENERATORS.
Expand All @@ -18,17 +16,8 @@ public class QDMTemplateProcessorFactory {

public static XmlProcessor getTemplateProcessor(double qdmVersion) {
String fileName = "templates/hqmf/qdm_v5_6_datatype_templates.xml";

URL templateFileUrl = QDMTemplateProcessorFactory.class.getClassLoader().getResource(fileName);
log.info("Template file path: " + templateFileUrl.getPath());
File templateFile = null;
try {
log.info("Template file uri: " + templateFileUrl.toURI());
templateFile = new File(templateFileUrl.toURI());
} catch (URISyntaxException e) {
e.printStackTrace();
}

return new XmlProcessor(templateFile);
InputStream inputStream =
QDMTemplateProcessorFactory.class.getClassLoader().getResourceAsStream(fileName);
return new XmlProcessor(inputStream);
}
}
8 changes: 4 additions & 4 deletions src/main/java/gov/cms/madie/hqmf/XmlProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.io.StringWriter;
import java.io.Writer;
Expand Down Expand Up @@ -168,14 +168,14 @@ public XmlProcessor(String originalXml) {
/**
* Instantiates a new xml processor for HQMFMeasureXml.
*
* @param file the file
* @param inputStream the file InputStream
*/
public XmlProcessor(File file) {
public XmlProcessor(InputStream inputStream) {
try {
DocumentBuilderFactory documentBuilderFactory =
XMLUtility.getInstance().buildDocumentBuilderFactory();
docBuilder = documentBuilderFactory.newDocumentBuilder();
originalDoc = docBuilder.parse(file);
originalDoc = docBuilder.parse(inputStream);
log.debug("Document Object created successfully for the XML String");
} catch (ParserConfigurationException e) {
log.error("Exception thrown on XmlProcessor() constructor", e);
Expand Down

0 comments on commit f312424

Please sign in to comment.