Search in sources :

Example 1 with CatalogueSiteMap

use of org.molgenis.emx2.web.service.CatalogueSiteMap in project molgenis-emx2 by molgenis.

the class SiteMapService method getSiteMapForSchema.

public static String getSiteMapForSchema(Request request, Response response) {
    response.type("text/xml, application/xml");
    Schema schema = getSchema(request);
    final String baseUrl = request.scheme() + "://" + request.host() + "/" + schema.getName();
    return new CatalogueSiteMap(schema, baseUrl).buildSiteMap();
}
Also used : CatalogueSiteMap(org.molgenis.emx2.web.service.CatalogueSiteMap) MolgenisWebservice.getSchema(org.molgenis.emx2.web.MolgenisWebservice.getSchema) Schema(org.molgenis.emx2.Schema)

Example 2 with CatalogueSiteMap

use of org.molgenis.emx2.web.service.CatalogueSiteMap in project molgenis-emx2 by molgenis.

the class CatalogueSiteMapTest method buildSiteMap.

@Test
public void buildSiteMap() {
    Schema schema = mock(Schema.class);
    Table table = mock(Table.class);
    Query query = mock(Query.class);
    List<Row> row = Collections.singletonList(new Row("pid", "my-cohort-pid"));
    when(schema.getTable("Cohorts")).thenReturn(table);
    when(table.select(any())).thenReturn(query);
    when(query.retrieveRows()).thenReturn(row);
    CatalogueSiteMap catalogueSiteMap = new CatalogueSiteMap(schema, "https://my/base/url");
    String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\" >\n" + "  <url>\n" + "    <loc>https://my/base/url/ssr-catalogue/Cohorts/my-cohort-pid</loc>\n" + "  </url>\n" + "</urlset>";
    assertEquals(expected, catalogueSiteMap.buildSiteMap());
}
Also used : Table(org.molgenis.emx2.Table) Query(org.molgenis.emx2.Query) Schema(org.molgenis.emx2.Schema) Row(org.molgenis.emx2.Row) Test(org.junit.Test)

Aggregations

Schema (org.molgenis.emx2.Schema)2 Test (org.junit.Test)1 Query (org.molgenis.emx2.Query)1 Row (org.molgenis.emx2.Row)1 Table (org.molgenis.emx2.Table)1 MolgenisWebservice.getSchema (org.molgenis.emx2.web.MolgenisWebservice.getSchema)1 CatalogueSiteMap (org.molgenis.emx2.web.service.CatalogueSiteMap)1