Search in sources :

Example 11 with STGroupFile

use of org.stringtemplate.v4.STGroupFile in project archi by archimatetool.

the class HTMLReportExporter method createReport.

public File createReport(File targetFolder, String indexFileName) throws IOException {
    // Copy HTML skeleton to target
    copyHTMLSkeleton(targetFolder);
    // Copy hints files from the help plug-in
    copyHintsFiles(targetFolder);
    // Create sub-folders
    // $NON-NLS-1$
    File elementsFolder = new File(targetFolder, fModel.getId() + "/elements");
    // Make dir
    elementsFolder.mkdirs();
    // $NON-NLS-1$
    File viewsFolder = new File(targetFolder, fModel.getId() + "/views");
    // Make dir
    viewsFolder.mkdirs();
    // $NON-NLS-1$
    File imagesFolder = new File(targetFolder, fModel.getId() + "/images");
    // Make dir
    imagesFolder.mkdirs();
    // Instantiate templates files
    // $NON-NLS-1$
    File mainFile = new File(ArchiReportsPlugin.INSTANCE.getTemplatesFolder(), "st/main.stg");
    STGroupFile groupFile = new STGroupFile(mainFile.getAbsolutePath(), '^', '^');
    // $NON-NLS-1$
    ST stFrame = groupFile.getInstanceOf("frame");
    groupFile.registerRenderer(String.class, new StringRenderer());
    // Write model purpose and properties html
    // $NON-NLS-1$
    writeElement(new File(elementsFolder, "model.html"), stFrame, fModel);
    // Write all folders
    writeFolders(elementsFolder, stFrame, fModel.getFolders());
    // Write Diagrams and images
    writeDiagrams(imagesFolder, viewsFolder, stFrame);
    // Write root model.html frame
    File indexFile = new File(targetFolder, indexFileName);
    // $NON-NLS-1$
    OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(indexFile), "UTF8");
    // $NON-NLS-1$
    ST stModel = groupFile.getInstanceOf("modelreport");
    // $NON-NLS-1$
    stModel.add("model", fModel);
    // $NON-NLS-1$
    stModel.add("strategyFolder", fModel.getFolder(FolderType.STRATEGY));
    // $NON-NLS-1$
    stModel.add("businessFolder", fModel.getFolder(FolderType.BUSINESS));
    // $NON-NLS-1$
    stModel.add("applicationFolder", fModel.getFolder(FolderType.APPLICATION));
    // $NON-NLS-1$
    stModel.add("technologyFolder", fModel.getFolder(FolderType.TECHNOLOGY));
    // $NON-NLS-1$
    stModel.add("motivationFolder", fModel.getFolder(FolderType.MOTIVATION));
    // $NON-NLS-1$
    stModel.add("implementationFolder", fModel.getFolder(FolderType.IMPLEMENTATION_MIGRATION));
    // $NON-NLS-1$
    stModel.add("otherFolder", fModel.getFolder(FolderType.OTHER));
    // $NON-NLS-1$
    stModel.add("relationsFolder", fModel.getFolder(FolderType.RELATIONS));
    // $NON-NLS-1$
    stModel.add("viewsFolder", fModel.getFolder(FolderType.DIAGRAMS));
    writer.write(stModel.render());
    writer.close();
    return indexFile;
}
Also used : ST(org.stringtemplate.v4.ST) StringRenderer(org.stringtemplate.v4.StringRenderer) FileOutputStream(java.io.FileOutputStream) OutputStreamWriter(java.io.OutputStreamWriter) STGroupFile(org.stringtemplate.v4.STGroupFile) STGroupFile(org.stringtemplate.v4.STGroupFile) File(java.io.File)

Example 12 with STGroupFile

use of org.stringtemplate.v4.STGroupFile in project webcert by sklintyg.

the class ReceiveMedicalCertificateAnswerIT method setup.

@Before
public void setup() throws IOException {
    // Setup String template resource
    templateGroup = new STGroupFile("integrationtestTemplates/receiveMedicalCertificateAnswer.v1.stg");
    requestTemplate = templateGroup.getInstanceOf("request");
    xsdInputstream = ClasspathSchemaResourceResolver.load("interactions/ReceiveMedicalCertificateAnswerInteraction/ReceiveMedicalCertificateAnswerResponder_1.0.xsd");
    // We want to validate against the body of the response, and not the entire soap response. This filter will
    // extract that for us.
    responseBodyExtractorFilter = new BodyExtractorFilter(ImmutableMap.of("lc", "urn:riv:insuranceprocess:healthreporting:ReceiveMedicalCertificateAnswerResponder:1"), "soap:Envelope/soap:Body/lc:ReceiveMedicalCertificateAnswerResponse");
}
Also used : STGroupFile(org.stringtemplate.v4.STGroupFile) Before(org.junit.Before)

Example 13 with STGroupFile

use of org.stringtemplate.v4.STGroupFile in project webcert by sklintyg.

the class ReceiveMedicalCertificateQuestionIT method setup.

@Before
public void setup() throws IOException {
    // Setup String template resource
    templateGroup = new STGroupFile("integrationtestTemplates/receiveMedicalCertificateQuestion.v1.stg");
    requestTemplate = templateGroup.getInstanceOf("request");
    xsdInputstream = ClasspathSchemaResourceResolver.load("interactions/ReceiveMedicalCertificateQuestionInteraction/ReceiveMedicalCertificateQuestionResponder_1.0.xsd");
    // We want to validate against the body of the response, and not the entire soap response. This filter will
    // extract that for us.
    responseBodyExtractorFilter = new BodyExtractorFilter(ImmutableMap.of("lc", "urn:riv:insuranceprocess:healthreporting:ReceiveMedicalCertificateQuestionResponder:1"), "soap:Envelope/soap:Body/lc:ReceiveMedicalCertificateQuestionResponse");
}
Also used : STGroupFile(org.stringtemplate.v4.STGroupFile) Before(org.junit.Before)

Example 14 with STGroupFile

use of org.stringtemplate.v4.STGroupFile in project webcert by sklintyg.

the class CreateDraftCertificateV1IT method setup.

@Before
public void setup() throws IOException {
    // Setup String template resource
    templateGroup = new STGroupFile("integrationtestTemplates/createDraftCertificate.v1.stg");
    requestTemplate = templateGroup.getInstanceOf("request");
    xsdInputstream = ClasspathSchemaResourceResolver.load("interactions/CreateDraftCertificateInteraction/CreateDraftCertificateResponder_1.0.xsd");
    // We want to validate against the body of the response, and not the entire soap response. This filter will
    // extract that for us.
    responseBodyExtractorFilter = new BodyExtractorFilter(ImmutableMap.of("lc", "urn:riv:clinicalprocess:healthcond:certificate:CreateDraftCertificateResponder:1"), "soap:Envelope/soap:Body/lc:CreateDraftCertificateResponse");
    // Make a dummy request, ignore response...
    given().get("/services").then().statusCode(greaterThan(199));
}
Also used : STGroupFile(org.stringtemplate.v4.STGroupFile) BodyExtractorFilter(se.inera.intyg.webcert.web.integration.integrationtest.BodyExtractorFilter) Before(org.junit.Before)

Example 15 with STGroupFile

use of org.stringtemplate.v4.STGroupFile in project webcert by sklintyg.

the class CreateDraftCertificateV3IT method setup.

@Before
public void setup() throws IOException {
    // Setup String template resource
    templateGroup = new STGroupFile("integrationtestTemplates/createDraftCertificate.v3.stg");
    requestTemplate = templateGroup.getInstanceOf("request");
    xsdInputstream = ClasspathSchemaResourceResolver.load("interactions/CreateDraftCertificateInteraction/CreateDraftCertificateResponder_3.1.xsd");
    // We want to validate against the body of the response, and not the entire soap response. This filter will
    // extract that for us.
    responseBodyExtractorFilter = new BodyExtractorFilter(ImmutableMap.of("lc", "urn:riv:clinicalprocess:healthcond:certificate:CreateDraftCertificateResponder:3"), "soap:Envelope/soap:Body/lc:CreateDraftCertificateResponse");
}
Also used : STGroupFile(org.stringtemplate.v4.STGroupFile) BodyExtractorFilter(se.inera.intyg.webcert.web.integration.integrationtest.BodyExtractorFilter) Before(org.junit.Before)

Aggregations

STGroupFile (org.stringtemplate.v4.STGroupFile)26 STGroup (org.stringtemplate.v4.STGroup)12 StringRenderer (org.stringtemplate.v4.StringRenderer)7 URL (java.net.URL)6 Before (org.junit.Before)6 ST (org.stringtemplate.v4.ST)5 File (java.io.File)4 ArrayList (java.util.ArrayList)3 NumberRenderer (org.stringtemplate.v4.NumberRenderer)3 STErrorListener (org.stringtemplate.v4.STErrorListener)3 STMessage (org.stringtemplate.v4.misc.STMessage)3 IOException (java.io.IOException)2 CodeGenerator (org.antlr.v4.codegen.CodeGenerator)2 Pair (org.antlr.v4.runtime.misc.Pair)2 BodyExtractorFilter (se.inera.intyg.webcert.web.integration.integrationtest.BodyExtractorFilter)2 FileOutputStream (java.io.FileOutputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 MultiMap (org.antlr.v4.runtime.misc.MultiMap)1 NotNull (org.antlr.v4.runtime.misc.NotNull)1 Primitive (org.eclipse.collections.codegenerator.model.Primitive)1