Search in sources :

Example 1 with NXVelocityContext

use of org.nextprot.api.web.NXVelocityContext in project nextprot-api by calipho-sib.

the class WebUnitBaseTest method getVelocityOutput.

protected String getVelocityOutput(Entry entry) throws IOException {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    Writer writer = new PrintWriter(out);
    NXVelocityContext context = new NXVelocityContext(entry);
    Template template = velocityConfig.getVelocityEngine().getTemplate("entry.xml.vm");
    template.merge(context, writer);
    writer.flush();
    return out.toString();
}
Also used : NXVelocityContext(org.nextprot.api.web.NXVelocityContext) ByteArrayOutputStream(java.io.ByteArrayOutputStream) PrintWriter(java.io.PrintWriter) Writer(java.io.Writer) PrintWriter(java.io.PrintWriter) Template(org.apache.velocity.Template)

Example 2 with NXVelocityContext

use of org.nextprot.api.web.NXVelocityContext in project nextprot-api by calipho-sib.

the class EntryXMLStreamWriter method writeFooter.

@Override
protected void writeFooter() throws IOException {
    Template exportTemplate = velocityConfig.getVelocityEngine().getTemplate("export-footer.xml.vm");
    exportTemplate.merge(new NXVelocityContext(), getStream());
}
Also used : NXVelocityContext(org.nextprot.api.web.NXVelocityContext) Template(org.apache.velocity.Template)

Example 3 with NXVelocityContext

use of org.nextprot.api.web.NXVelocityContext in project nextprot-api by calipho-sib.

the class EntryTTLStreamWriter method writeHeader.

@Override
protected void writeHeader(Map<String, Object> infos) {
    int entryNum = (int) infos.get(EntryStreamWriter.getEntryCountKey());
    ReleaseInfoVersions releaseInfoVersions = (ReleaseInfoVersions) infos.get(EntryStreamWriter.getReleaseInfoKey());
    Template headerTemplate = velocityConfig.getVelocityEngine().getTemplate("turtle/prefix.ttl.vm");
    headerTemplate.merge(new NXVelocityContext(entryNum, releaseInfoVersions), getStream());
}
Also used : NXVelocityContext(org.nextprot.api.web.NXVelocityContext) ReleaseInfoVersions(org.nextprot.api.core.domain.release.ReleaseInfoVersions) Template(org.apache.velocity.Template)

Example 4 with NXVelocityContext

use of org.nextprot.api.web.NXVelocityContext in project nextprot-api by calipho-sib.

the class EntryXMLStreamWriter method writeHeader.

@Override
protected void writeHeader(Map<String, Object> infos) throws IOException {
    int entryNum = (int) infos.get(EntryStreamWriter.getEntryCountKey());
    ReleaseInfoVersions releaseInfoVersions = (ReleaseInfoVersions) infos.get(EntryStreamWriter.getReleaseInfoKey());
    ReleaseInfoDataSources releaseInfoDataSources = (ReleaseInfoDataSources) infos.get(EntryStreamWriter.getReleaseDataSourcesKey());
    Template headerTemplate = velocityConfig.getVelocityEngine().getTemplate("export-header.xml.vm");
    headerTemplate.merge(new NXVelocityContext(entryNum, releaseInfoVersions), getStream());
    Template releaseContentTemplate = velocityConfig.getVelocityEngine().getTemplate("release-contents.xml.vm");
    writePrettyXml(releaseContentTemplate, new NXVelocityContext(entryNum, releaseInfoVersions, releaseInfoDataSources), 2);
    getStream().write("    </header>\n");
    getStream().write("    <entry-list>\n");
}
Also used : NXVelocityContext(org.nextprot.api.web.NXVelocityContext) ReleaseInfoVersions(org.nextprot.api.core.domain.release.ReleaseInfoVersions) ReleaseInfoDataSources(org.nextprot.api.core.domain.release.ReleaseInfoDataSources) Template(org.apache.velocity.Template)

Example 5 with NXVelocityContext

use of org.nextprot.api.web.NXVelocityContext in project nextprot-api by calipho-sib.

the class EntryTTLValidationIntegrationTest method addTurtlePrefixes.

static void addTurtlePrefixes(Writer writer, VelocityConfig config) {
    Template headerTemplate = config.getVelocityEngine().getTemplate("turtle/prefix.ttl.vm");
    headerTemplate.merge(new NXVelocityContext(), writer);
}
Also used : NXVelocityContext(org.nextprot.api.web.NXVelocityContext) Template(org.apache.velocity.Template)

Aggregations

Template (org.apache.velocity.Template)5 NXVelocityContext (org.nextprot.api.web.NXVelocityContext)5 ReleaseInfoVersions (org.nextprot.api.core.domain.release.ReleaseInfoVersions)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 PrintWriter (java.io.PrintWriter)1 Writer (java.io.Writer)1 ReleaseInfoDataSources (org.nextprot.api.core.domain.release.ReleaseInfoDataSources)1