当前位置: 首页>>代码示例>>Java>>正文


Java CqlTranslator.fromFile方法代码示例

本文整理汇总了Java中org.cqframework.cql.cql2elm.CqlTranslator.fromFile方法的典型用法代码示例。如果您正苦于以下问题:Java CqlTranslator.fromFile方法的具体用法?Java CqlTranslator.fromFile怎么用?Java CqlTranslator.fromFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.cqframework.cql.cql2elm.CqlTranslator的用法示例。


在下文中一共展示了CqlTranslator.fromFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: beforeEachTestMethod

import org.cqframework.cql.cql2elm.CqlTranslator; //导入方法依赖的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);
    }
}
 
开发者ID:DBCG,项目名称:cql_engine,代码行数:45,代码来源:FhirExecutionTestBase.java

示例2: beforeEachTestMethod

import org.cqframework.cql.cql2elm.CqlTranslator; //导入方法依赖的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);
    }
}
 
开发者ID:DBCG,项目名称:cql_engine,代码行数:47,代码来源:CqlExecutionTestBase.java


注:本文中的org.cqframework.cql.cql2elm.CqlTranslator.fromFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。