Commit 8cf2df78 authored by Matija Obreza's avatar Matija Obreza
Browse files

Testing Spring content negotiation for "text/turtle"

parent c35f737c
/**
* Copyright 2013 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
package org.genesys2.server.servlet.controller;
import org.genesys2.server.model.genesys.Accession;
import org.genesys2.server.service.CropService;
import org.genesys2.server.service.GenesysService;
import org.genesys2.server.service.InstituteService;
import org.genesys2.server.service.TaxonomyService;
import org.genesys2.spring.ResourceNotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
@RequestMapping(value = "/acn", headers = "accept=text/turtle", produces = "text/turtle")
public class AccessionControllerRdf {
@Autowired
private InstituteService instituteService;
@Autowired
private GenesysService genesysService;
@Autowired
private TaxonomyService taxonomyService;
@Autowired
private CropService cropService;
@RequestMapping(value = "/id/{accessionId}", method = RequestMethod.GET)
public String viewTurtle(ModelMap model, @PathVariable(value = "accessionId") long accessionId) {
Accession accession = genesysService.getAccession(accessionId);
if (accession == null) {
throw new ResourceNotFoundException();
}
model.addAttribute("accession", accession);
model.addAttribute("accessionNames", genesysService.listAccessionNames(accession));
model.addAttribute("accessionExchange", genesysService.listAccessionExchange(accession));
model.addAttribute("accessionCollect", genesysService.listAccessionCollect(accession));
model.addAttribute("accessionBreeding", genesysService.listAccessionBreeding(accession));
model.addAttribute("accessionEnvironment", genesysService.listAccessionEnvironment(accession));
model.addAttribute("metadatas", genesysService.listMetadata(accession));
model.addAttribute("methods", genesysService.listMethods(accession));
model.addAttribute("methodValues", genesysService.getAccessionTraitValues(accession));
model.addAttribute("crops", cropService.getCrops(accession.getTaxonomy()));
return "/accession/details-turtle";
}
}
<%@ page contentType="text/turtle;charset=UTF-8" pageEncoding="UTF-8" language="java" session="false"%><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%><%@ taglib prefix="security" uri="http://www.springframework.org/security/tags"%><%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%><%@ taglib
prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
# This is a test.
# TODO FIXME This needs work.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix dc: <http: //purl.org/dc/elements/1.1/> .
@prefix ex: <http: //example.org/stuff/1.0/> .
<http://www.genesys-pgr.org/acn/id/${accession.id}>
dc:title "${accession.accessionName}" ;
ex:editor [
ex:fullname "${accession.accessionName}";
] .
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment