Commit 07dc110f authored by Richard Bruskiewich's avatar Richard Bruskiewich Committed by Matija Obreza
Browse files

A special view for /descriptors/categories partially implemented

parent f6daa885
......@@ -26,10 +26,12 @@ import org.genesys2.spring.ResourceNotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.http.MediaType;
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;
import org.springframework.web.bind.annotation.RequestParam;
/**
......@@ -42,6 +44,12 @@ public class DescriptorController extends BaseController {
@Autowired
private TraitService traitService;
@RequestMapping(value = "/categories", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE })
public String viewCategories(ModelMap model) {
model.addAttribute("categories", traitService.listCategories());
return "/descr/categories";
}
@RequestMapping
public String index(ModelMap model, @RequestParam(value = "page", required = false, defaultValue = "1") int page) {
model.addAttribute("pagedData", traitService.listTraits(new PageRequest(page - 1, 50, new Sort("title"))));
......
......@@ -101,7 +101,14 @@ public class TraitsController extends RestController {
return OAuth2Cleanup.clean(methods);
}
@RequestMapping(value = "/categories", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE })
public @ResponseBody
Object listCategories() {
LOG.info("Listing parameter categories");
List<ParameterCategory> categories = traitService.listCategories();
return OAuth2Cleanup.clean(categories);
}
/**
* Create a new crop property category (ParameterCategory) to
* use with descriptors (property/method/scale) meta-data
......
<!DOCTYPE html>
<%@include file="/WEB-INF/jsp/init.jsp"%>
<html>
<head>
<title><spring:message code="descriptor.category" /></title>
</head>
<body>
<h1>
<spring:message code="descriptor.category" />
</h1>
<table>
<thead>
<tr>
<td><spring:message code="descriptor.category" /></td>
<td><spring:message code="ce.sameAs" /></td>
</tr>
</thead>
<tbody>
<c:forEach items="${categories}" var="category" varStatus="status">
<tr class="${status.count % 2 == 0 ? 'even' : 'odd'}">
<td><a href="<c:url value="/category/${category.id}" />"><c:out value="${category.getName(pageContext.response.locale)}" /></a></td>
<td>
<c:if test="${category.rdfUri ne null}">
<a href="<c:url value="${category.rdfUri}" />">
<c:out value="${category.getRdfUriId()}" />
</a>
</c:if>
</td>
</tr>
</c:forEach>
</tbody>
</table>
</body>
</html>
\ No newline at end of file
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