Search in sources :

Example 6 with SeoTags

use of org.nextprot.api.web.seo.domain.SeoTags in project nextprot-api by calipho-sib.

the class SeoServiceIntegrationTest method testSeoTagsForTerm.

@Test
public void testSeoTagsForTerm() throws Exception {
    String baseTitle = "GO:0042802 - Identical protein binding - ";
    SeoTags tags;
    tags = seoTagsService.getTermSeoTags("/term/GO:0042802");
    Assert.assertTrue(tags != null);
    Assert.assertEquals(baseTitle + "Proteins", tags.getTitle());
    tags = seoTagsService.getTermSeoTags("/term/GO:0042802/");
    Assert.assertTrue(tags != null);
    Assert.assertEquals(baseTitle + "Proteins", tags.getTitle());
    tags = seoTagsService.getTermSeoTags("/term/GO:0042802/proteins");
    Assert.assertTrue(tags != null);
    Assert.assertEquals(baseTitle + "Proteins", tags.getTitle());
    tags = seoTagsService.getTermSeoTags("/term/GO:0042802/ancestors");
    Assert.assertTrue(tags != null);
    Assert.assertEquals(baseTitle + "Ancestors", tags.getTitle());
    tags = seoTagsService.getTermSeoTags("/term/GO:0042802/tree");
    Assert.assertTrue(tags != null);
    Assert.assertEquals(baseTitle + "Tree", tags.getTitle());
}
Also used : SeoTags(org.nextprot.api.web.seo.domain.SeoTags) WebIntegrationBaseTest(org.nextprot.api.web.dbunit.base.mvc.WebIntegrationBaseTest) Test(org.junit.Test)

Example 7 with SeoTags

use of org.nextprot.api.web.seo.domain.SeoTags in project nextprot-api by calipho-sib.

the class SeoServiceIntegrationTest method testSomeDefaultSeoTags.

@Test
public void testSomeDefaultSeoTags() throws Exception {
    SeoTags tags;
    tags = seoTagsService.getDefaultSeoTags("/toto");
    Assert.assertTrue(tags != null);
    Assert.assertEquals("Toto", tags.getTitle());
    tags = seoTagsService.getDefaultSeoTags("/toto/");
    Assert.assertTrue(tags != null);
    Assert.assertEquals("Toto", tags.getTitle());
    tags = seoTagsService.getDefaultSeoTags("/toto/tutu");
    Assert.assertTrue(tags != null);
    Assert.assertEquals("Toto - Tutu", tags.getTitle());
    tags = seoTagsService.getDefaultSeoTags("/toto/tutu?titi=content");
    Assert.assertTrue(tags != null);
    Assert.assertEquals("Toto - Tutu", tags.getTitle());
}
Also used : SeoTags(org.nextprot.api.web.seo.domain.SeoTags) WebIntegrationBaseTest(org.nextprot.api.web.dbunit.base.mvc.WebIntegrationBaseTest) Test(org.junit.Test)

Example 8 with SeoTags

use of org.nextprot.api.web.seo.domain.SeoTags in project nextprot-api by calipho-sib.

the class SeoTagsServiceImpl method getPublicationSeoTags.

@Override
public SeoTags getPublicationSeoTags(String url) {
    String[] urlElements = RelativeUrlUtils.getPathElements(url);
    int id = Integer.valueOf(urlElements[1]);
    // default subpage
    String subpage = "proteins";
    if (urlElements.length > 2)
        subpage = urlElements[2];
    String prettySubpage = getPrettyName(subpage);
    Publication pub = publicationService.findPublicationById(id);
    String title = pub.getTitle() + " - " + prettySubpage;
    String h1 = title;
    String descr = title;
    return new SeoTags(title, descr, h1);
}
Also used : SeoTags(org.nextprot.api.web.seo.domain.SeoTags) Publication(org.nextprot.api.core.domain.Publication)

Example 9 with SeoTags

use of org.nextprot.api.web.seo.domain.SeoTags in project nextprot-api by calipho-sib.

the class SeoTagsServiceImpl method getEntrySeoTags.

@Override
public SeoTags getEntrySeoTags(String url) {
    String[] urlElements = RelativeUrlUtils.getPathElements(url);
    String ac = urlElements[1];
    // default subpage
    String subpage = "function";
    if (urlElements.length > 2)
        subpage = urlElements[2];
    String prettySubpage = getPrettyName(subpage);
    Entry entry = entryBuilderService.build(EntryConfig.newConfig(ac).withOverview().with("function-info"));
    String protName = entry.getOverview().getMainProteinName();
    String geneName = entry.getOverview().getMainGeneName();
    // decision QC 18.08.2016
    if (geneName == null || geneName.isEmpty())
        geneName = ac;
    // decision NPC 15.08.2016
    String title = geneName + " - " + protName + " - " + prettySubpage;
    // decision NPC 15.08.2016
    String h1 = geneName + " - " + prettySubpage;
    // TODO: send something different for each subpage... see with amos
    String descr = ac + " - " + title + ". " + getFirstFunctionInfo(entry);
    return new SeoTags(title, descr, h1);
}
Also used : Entry(org.nextprot.api.core.domain.Entry) SeoTags(org.nextprot.api.web.seo.domain.SeoTags)

Example 10 with SeoTags

use of org.nextprot.api.web.seo.domain.SeoTags in project nextprot-api by calipho-sib.

the class SeoTagsServiceImpl method getTermSeoTags.

@Override
public SeoTags getTermSeoTags(String url) {
    String[] urlElements = RelativeUrlUtils.getPathElements(url);
    String ac = urlElements[1];
    // default subpage
    String subpage = "proteins";
    if (urlElements.length > 2)
        subpage = urlElements[2];
    String prettySubpage = getPrettyName(subpage);
    CvTerm term = terminologyService.findCvTermByAccession(ac);
    String title = term.getAccession() + " - " + getPrettyName(term.getName()) + " - " + prettySubpage;
    String h1 = title;
    // TODO: NullPointerException below
    String descr = term.getOntology() + " " + term.getAccession() + " - " + term.getName() + " - " + prettySubpage;
    return new SeoTags(title, descr, h1);
}
Also used : CvTerm(org.nextprot.api.core.domain.CvTerm) SeoTags(org.nextprot.api.web.seo.domain.SeoTags)

Aggregations

SeoTags (org.nextprot.api.web.seo.domain.SeoTags)11 Test (org.junit.Test)6 WebIntegrationBaseTest (org.nextprot.api.web.dbunit.base.mvc.WebIntegrationBaseTest)6 SimpleDateFormat (java.text.SimpleDateFormat)1 NextProtException (org.nextprot.api.commons.exception.NextProtException)1 CvTerm (org.nextprot.api.core.domain.CvTerm)1 Entry (org.nextprot.api.core.domain.Entry)1 Publication (org.nextprot.api.core.domain.Publication)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1