Search in sources :

Example 1 with ReleaseInfoVersions

use of org.nextprot.api.core.domain.release.ReleaseInfoVersions in project nextprot-api by calipho-sib.

the class ReleaseInfoServiceImpl method findReleaseVersions.

@Override
@Cacheable("release-versions")
public ReleaseInfoVersions findReleaseVersions() {
    ReleaseInfoVersions ri = new ReleaseInfoVersions();
    ri.setDatabaseRelease(releaseInfoDao.findDatabaseRelease());
    ri.setApiRelease(this.getApiVersion());
    return ri;
}
Also used : ReleaseInfoVersions(org.nextprot.api.core.domain.release.ReleaseInfoVersions) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 2 with ReleaseInfoVersions

use of org.nextprot.api.core.domain.release.ReleaseInfoVersions in project nextprot-api by calipho-sib.

the class ExportXMLHeaderTest method testXMLExportHeaderRelease.

@Test
public void testXMLExportHeaderRelease() throws Exception {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    Writer writer = new PrintWriter(out);
    EntryVelocityBasedStreamWriter exporter = new EntryXMLStreamWriter(writer, "overview");
    ReleaseInfoVersions rc = new ReleaseInfoVersions();
    rc.setApiRelease("api-test-version");
    rc.setDatabaseRelease("database-test-version");
    Map<String, Object> infos = new HashMap<>();
    infos.put(EntryStreamWriter.getReleaseInfoKey(), rc);
    exporter.write(Collections.emptyList(), infos);
    NodeList dbReleaseNodes = XMLUnitUtils.getMatchingNodes(out.toString(), "//*[local-name()='database-release']");
    assertEquals("database-test-version", dbReleaseNodes.item(0).getTextContent());
    NodeList apiReleaseNodes = XMLUnitUtils.getMatchingNodes(out.toString(), "//*[local-name()='api-release']");
    assertEquals("api-test-version", apiReleaseNodes.item(0).getTextContent());
    NodeList entriesCountNode = XMLUnitUtils.getMatchingNodes(out.toString(), "//*[local-name()='number-of-entries']");
    assertEquals("0", entriesCountNode.item(0).getTextContent());
}
Also used : ReleaseInfoVersions(org.nextprot.api.core.domain.release.ReleaseInfoVersions) HashMap(java.util.HashMap) NodeList(org.w3c.dom.NodeList) EntryXMLStreamWriter(org.nextprot.api.web.service.impl.writer.EntryXMLStreamWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) EntryVelocityBasedStreamWriter(org.nextprot.api.web.service.impl.writer.EntryVelocityBasedStreamWriter) PrintWriter(java.io.PrintWriter) EntryVelocityBasedStreamWriter(org.nextprot.api.web.service.impl.writer.EntryVelocityBasedStreamWriter) EntryXMLStreamWriter(org.nextprot.api.web.service.impl.writer.EntryXMLStreamWriter) Writer(java.io.Writer) EntryStreamWriter(org.nextprot.api.web.service.impl.writer.EntryStreamWriter) PrintWriter(java.io.PrintWriter) WebUnitBaseTest(org.nextprot.api.web.dbunit.base.mvc.WebUnitBaseTest) Test(org.junit.Test)

Example 3 with ReleaseInfoVersions

use of org.nextprot.api.core.domain.release.ReleaseInfoVersions 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 ReleaseInfoVersions

use of org.nextprot.api.core.domain.release.ReleaseInfoVersions 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)

Aggregations

ReleaseInfoVersions (org.nextprot.api.core.domain.release.ReleaseInfoVersions)4 Template (org.apache.velocity.Template)2 NXVelocityContext (org.nextprot.api.web.NXVelocityContext)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 PrintWriter (java.io.PrintWriter)1 Writer (java.io.Writer)1 HashMap (java.util.HashMap)1 Test (org.junit.Test)1 ReleaseInfoDataSources (org.nextprot.api.core.domain.release.ReleaseInfoDataSources)1 WebUnitBaseTest (org.nextprot.api.web.dbunit.base.mvc.WebUnitBaseTest)1 EntryStreamWriter (org.nextprot.api.web.service.impl.writer.EntryStreamWriter)1 EntryVelocityBasedStreamWriter (org.nextprot.api.web.service.impl.writer.EntryVelocityBasedStreamWriter)1 EntryXMLStreamWriter (org.nextprot.api.web.service.impl.writer.EntryXMLStreamWriter)1 Cacheable (org.springframework.cache.annotation.Cacheable)1 NodeList (org.w3c.dom.NodeList)1