use of gov.cms.qpp.conversion.encode.JsonWrapper in project qpp-conversion-tool by CMSgov.
the class DefaultEncoder method internalEncode.
@Override
protected void internalEncode(JsonWrapper wrapper, Node node) {
DEV_LOG.debug("Default JSON encoder {} is handling templateId {} and is described as '{}' ", getClass(), node.getType().name(), description);
JsonWrapper childWrapper = new JsonWrapper();
for (String name : node.getKeys()) {
String nameForEncode = name.replace("Decoder", "Encoder");
childWrapper.putString(nameForEncode, node.getValue(name));
}
wrapper.putObject(node.getType().name(), childWrapper);
for (Node child : node.getChildNodes()) {
childWrapper.putObject(child.getType().name(), childWrapper);
encode(childWrapper, child);
}
}
use of gov.cms.qpp.conversion.encode.JsonWrapper in project qpp-conversion-tool by CMSgov.
the class Converter method encode.
/**
* Place transformed content into an input stream
*
* @return content resulting from the transformation
*/
private JsonWrapper encode() {
JsonOutputEncoder encoder = getEncoder();
DEV_LOG.info("Encoding template ID {}", decoded.getType());
try {
encoder.setNodes(Collections.singletonList(decoded));
JsonWrapper qpp = encoder.encode();
details.addAll(encoder.getDetails());
return qpp;
} catch (EncodeException e) {
throw new XmlInputFileException("Issues decoding/encoding.", e);
}
}
use of gov.cms.qpp.conversion.encode.JsonWrapper in project qpp-conversion-tool by CMSgov.
the class PathCorrelator method prepPath.
/**
* Assemble an xpath using the given json path and json wrapper.
*
* @param jsonPath definite json path
* @param wrapper object representation of QPP json
* @return xpath that correlates to supplied json path
*/
public static String prepPath(String jsonPath, JsonWrapper wrapper) {
String base = "$";
String leaf = jsonPath;
int lastIndex = jsonPath.lastIndexOf('.');
JsonWrapper metaWrapper = new JsonWrapper(wrapper, false);
if (lastIndex > 0) {
base = jsonPath.substring(0, lastIndex);
leaf = jsonPath.substring(lastIndex + 1);
}
JsonPath compiledPath = JsonPath.compile(base);
Map<String, Object> jsonMap = compiledPath.read(metaWrapper.toString());
Map<String, String> metaMap = getMetaMap(jsonMap, leaf);
String preparedPath = "";
if (metaMap != null) {
preparedPath = makePath(metaMap, leaf);
}
return preparedPath;
}
use of gov.cms.qpp.conversion.encode.JsonWrapper in project qpp-conversion-tool by CMSgov.
the class AuditServiceImplTest method successfulEncodingPrep.
private void successfulEncodingPrep() {
prepOverlap();
JsonWrapper wrapper = new JsonWrapper();
wrapper.putString("meep", "mawp");
when(report.getQppSource()).thenReturn(wrapper.toSource());
}
use of gov.cms.qpp.conversion.encode.JsonWrapper in project qpp-conversion-tool by CMSgov.
the class ValidationServiceImplTest method setup.
@BeforeAll
static void setup() throws IOException {
service = new ValidationServiceImpl(null);
pathToSubmissionError = Paths.get("src/test/resources/submissionErrorFixture.json");
pathToSubmissionDuplicateEntryError = Paths.get("src/test/resources/submissionDuplicateEntryErrorFixture.json");
Path toConvert = Paths.get("../qrda-files/valid-QRDA-III-latest.xml");
qppWrapper = new JsonWrapper(new Converter(new PathSource(toConvert)).transform(), false);
prepAllErrors();
}
Aggregations