Skip to content

Extending Web Client

Martynas Jusevičius edited this page Aug 5, 2016 · 4 revisions

For a sample Hello World kind of application using AtomGraph, check out sample blog app.

In Java

  • extend root resource class and add a constructor with JAX-RS annotations

      public class ResourceBase extends org.graphity.processor.model.impl.ResourceBase
      {
          public ResourceBase(@Context UriInfo uriInfo, @Context SPARQLEndpoint endpoint, @Context OntClass ontClass,
              @Context Request request, @Context ServletContext servletContext, @Context HttpHeaders httpHeaders, @Context ResourceContext resourceContext)
          {
              super(uriInfo, endpoint, ontClass,
                  request, servletContext, httpHeaders, resourceContext);
      
              // custom logic
          }
      }
    
  • override @Path class annotation only if you need a more specific URI template for the resource class

  • alternatively, you can extend the global resource class which includes Linked Data client functionality

  • extend Application from org.graphity.client.ApplicationBase

  • configure JAX-RS application class in web.xml

      <init-param>
          <param-name>javax.ws.rs.Application</param-name>
          <param-value>com.sample.Application</param-value>
      </init-param>
    
  • register your Resource class in your Application constructor and/or getClasses() method

In sitemap ontology

  • owl:import gc: (AtomGraph Client ontology) if you want XHTML mode configuration or gp: (AtomGraph Processor ontology) for Linked Data functionality only

      <http://graphity.org/gcs#> a owl:Ontology, gp:Sitemap ;
          owl:imports gc:, sp:, spin:, lda:, foaf:, sioc: .
    
  • create /src/main/resources/prefix-mapping.n3 to configure mappings to locally cached copies of vocabularies, if any

  • configure sitemap ontology location in web.xml

      <init-param>
          <param-name>http://graphity.org/gp#ontology</param-name>
          <param-value>http://graphity.org/gcs#</param-value>
      </init-param>
    

In XSLT

  • xsl:import local-xhtml.xsl to use default local webapp layout

      <xsl:import href="../../client/xsl/functions.xsl"/>
      <xsl:import href="../../client/xsl/group-sort-triples.xsl"/>
      <xsl:import href="../../client/xsl/local-xhtml.xsl"/>
    
  • xsl:import global-xhtml.xsl to use default layout with LD browser capabilities

  • make copies of local-xhtml.xsl and/or layout.xsl and remove/change the templates for custom layout

  • configure stylesheet location in web.xml

      <init-param>
          <param-name>http://graphity.org/gc#stylesheet</param-name>
          <param-value>static/org/graphity/blog/xsl/layout-xhtml.xsl</param-value>
      </init-param>
    
Clone this wiki locally