本文整理汇总了Java中org.cqframework.cql.cql2elm.CqlTranslatorException类的典型用法代码示例。如果您正苦于以下问题:Java CqlTranslatorException类的具体用法?Java CqlTranslatorException怎么用?Java CqlTranslatorException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CqlTranslatorException类属于org.cqframework.cql.cql2elm包,在下文中一共展示了CqlTranslatorException类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: collect_errors
import org.cqframework.cql.cql2elm.CqlTranslatorException; //导入依赖的package包/类
public static void collect_errors(ArrayList<String> errors,
Iterable<CqlTranslatorException> exceptions)
{
errors.add("Translation of CQL to ELM failed due to errors:");
for (CqlTranslatorException error : exceptions)
{
TrackBack tb = error.getLocator();
String lines = tb == null ? "[n/a]" : String.format(
"%s[%d:%d, %d:%d]",
(tb.getLibrary() == null ? ""
: tb.getLibrary().getId()
+ (tb.getLibrary().getVersion() == null ? ""
: "-" + tb.getLibrary().getVersion()
)
),
tb.getStartLine(), tb.getStartChar(),
tb.getEndLine(), tb.getEndChar()
);
errors.add(lines + error.getMessage());
}
}
示例2: errorsToString
import org.cqframework.cql.cql2elm.CqlTranslatorException; //导入依赖的package包/类
public static String errorsToString(Iterable<CqlTranslatorException> exceptions) {
ArrayList<String> errors = new ArrayList<>();
for (CqlTranslatorException error : exceptions) {
TrackBack tb = error.getLocator();
String lines = tb == null ? "[n/a]" : String.format("%s[%d:%d, %d:%d]",
(tb.getLibrary() != null ? tb.getLibrary().getId() + (tb.getLibrary().getVersion() != null
? ("-" + tb.getLibrary().getVersion()) : "") : ""),
tb.getStartLine(), tb.getStartChar(), tb.getEndLine(), tb.getEndChar());
errors.add(lines + error.getMessage());
}
return errors.toString();
}
示例3: loadLibrary
import org.cqframework.cql.cql2elm.CqlTranslatorException; //导入依赖的package包/类
private Library loadLibrary(VersionedIdentifier libraryIdentifier) {
IdType id = new IdType(libraryIdentifier.getId());
org.hl7.fhir.dstu3.model.Library library = provider.getDao().read(id);
InputStream is = null;
for (org.hl7.fhir.dstu3.model.Attachment content : library.getContent()) {
is = new ByteArrayInputStream(content.getData());
if (content.getContentType().equals("application/elm+xml")) {
return readLibrary(is);
}
else if (content.getContentType().equals("text/cql")) {
return translateLibrary(is, libraryManager, modelManager);
}
}
org.hl7.elm.r1.VersionedIdentifier identifier = new org.hl7.elm.r1.VersionedIdentifier()
.withId(libraryIdentifier.getId())
.withSystem(libraryIdentifier.getSystem())
.withVersion(libraryIdentifier.getVersion());
ArrayList<CqlTranslatorException> errors = new ArrayList<>();
org.hl7.elm.r1.Library translatedLibrary = libraryManager.resolveLibrary(identifier, errors).getLibrary();
if (errors.size() > 0) {
throw new IllegalArgumentException(errorsToString(errors));
}
try {
return readLibrary(new ByteArrayInputStream(CqlTranslator.fromStream(is == null ? new ByteArrayInputStream(new byte[]{}) : is, modelManager, libraryManager).convertToXml(translatedLibrary).getBytes(StandardCharsets.UTF_8)));
} catch (JAXBException | IOException e) {
throw new IllegalArgumentException(String.format("Errors occurred translating library %s%s.",
identifier.getId(), identifier.getVersion() != null ? ("-" + identifier.getVersion()) : ""));
}
}
示例4: beforeEachTestMethod
import org.cqframework.cql.cql2elm.CqlTranslatorException; //导入依赖的package包/类
@BeforeMethod
public void beforeEachTestMethod() throws JAXBException, IOException {
String fileName = this.getClass().getSimpleName();
library = libraries.get(fileName);
if (library == null) {
ModelManager modelManager = new ModelManager();
LibraryManager libraryManager = new LibraryManager(modelManager);
try {
File cqlFile = new File(URLDecoder.decode(this.getClass().getResource(fileName + ".cql").getFile(), "UTF-8"));
ArrayList<CqlTranslator.Options> options = new ArrayList<>();
options.add(CqlTranslator.Options.EnableDateRangeOptimization);
CqlTranslator translator = CqlTranslator.fromFile(cqlFile, modelManager, libraryManager, options.toArray(new CqlTranslator.Options[options.size()]));
if (translator.getErrors().size() > 0) {
System.err.println("Translation failed due to errors:");
ArrayList<String> errors = new ArrayList<>();
for (CqlTranslatorException error : translator.getErrors()) {
TrackBack tb = error.getLocator();
String lines = tb == null ? "[n/a]" : String.format("[%d:%d, %d:%d]",
tb.getStartLine(), tb.getStartChar(), tb.getEndLine(), tb.getEndChar());
System.err.printf("%s %s%n", lines, error.getMessage());
errors.add(lines + error.getMessage());
}
throw new IllegalArgumentException(errors.toString());
}
assertThat(translator.getErrors().size(), is(0));
xmlFile = new File(cqlFile.getParent(), fileName + ".xml");
xmlFile.createNewFile();
PrintWriter pw = new PrintWriter(xmlFile, "UTF-8");
pw.println(translator.toXml());
pw.println();
pw.close();
} catch (IOException e) {
e.printStackTrace();
}
library = CqlLibraryReader.read(xmlFile);
libraries.put(fileName, library);
}
}
示例5: beforeEachTestMethod
import org.cqframework.cql.cql2elm.CqlTranslatorException; //导入依赖的package包/类
@BeforeMethod
public void beforeEachTestMethod() throws JAXBException, IOException {
String fileName = this.getClass().getSimpleName();
library = libraries.get(fileName);
if (library == null) {
ModelManager modelManager = new ModelManager();
LibraryManager libraryManager = new LibraryManager(modelManager);
try {
File cqlFile = new File(URLDecoder.decode(this.getClass().getResource(fileName + ".cql").getFile(), "UTF-8"));
ArrayList<CqlTranslator.Options> options = new ArrayList<>();
options.add(CqlTranslator.Options.EnableDateRangeOptimization);
CqlTranslator translator = CqlTranslator.fromFile(cqlFile, modelManager, libraryManager, options.toArray(new CqlTranslator.Options[options.size()]));
if (translator.getErrors().size() > 0) {
System.err.println("Translation failed due to errors:");
ArrayList<String> errors = new ArrayList<>();
for (CqlTranslatorException error : translator.getErrors()) {
TrackBack tb = error.getLocator();
String lines = tb == null ? "[n/a]" : String.format("[%d:%d, %d:%d]",
tb.getStartLine(), tb.getStartChar(), tb.getEndLine(), tb.getEndChar());
System.err.printf("%s %s%n", lines, error.getMessage());
errors.add(lines + error.getMessage());
}
throw new IllegalArgumentException(errors.toString());
}
assertThat(translator.getErrors().size(), is(0));
xmlFile = new File(cqlFile.getParent(), fileName + ".xml");
xmlFile.createNewFile();
String xml = translator.toXml();
PrintWriter pw = new PrintWriter(xmlFile, "UTF-8");
pw.println(xml);
pw.println();
pw.close();
} catch (IOException e) {
e.printStackTrace();
}
library = CqlLibraryReader.read(xmlFile);
libraries.put(fileName, library);
}
}