Commit c82d9bbb authored by Matija Obreza's avatar Matija Obreza
Browse files

Traits & Extras

parent 2a1025e5
eclipse.preferences.version=1
encoding//src/main/resources=UTF-8
encoding//src/main/resources/content/language.properties=UTF-8
encoding//src/main/webapp/WEB-INF/jsp/descr/index.jsp=UTF-8
encoding//src/main/webapp/WEB-INF/jsp/login.jsp=UTF-8
encoding//src/main/webapp/WEB-INF/jsp/metadata/index.jsp=UTF-8
encoding//src/main/webapp/WEB-INF/jsp/metadata/view.jsp=UTF-8
......
......@@ -21,8 +21,12 @@ import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.crophub.rest.common.model.impl.Crop;
@Entity
@Table(name = "parameters")
public class Parameter implements java.io.Serializable {
......@@ -33,7 +37,7 @@ public class Parameter implements java.io.Serializable {
private static final long serialVersionUID = -4831244149317371274L;
private Long id;
// private Language language;
// private Crop crop;
private Crop crop;
// private Category category;
private String title;
......@@ -60,17 +64,17 @@ public class Parameter implements java.io.Serializable {
// public void setLanguage(final Language language) {
// this.language = language;
// }
//
// @ManyToOne(cascade = {}, optional = false)
// @JoinColumn(name = "cropId")
// public Crop getCrop() {
// return this.crop;
// }
//
// public void setCrop(final Crop crop) {
// this.crop = crop;
// }
//
@ManyToOne(cascade = {}, optional = false)
@JoinColumn(name = "Crop_Id")
public Crop getCrop() {
return this.crop;
}
public void setCrop(final Crop crop) {
this.crop = crop;
}
// @ManyToOne(cascade = {}, optional = false)
// @JoinColumn(name = "categoryId", nullable = false)
// public Category getCategory() {
......
......@@ -33,4 +33,7 @@ public interface MetadataMethodRepository extends JpaRepository<MetadataMethod,
@Query("select distinct mm.method from MetadataMethod mm where mm.metadata = ?1")
List<Method> listMetadataMethods(Metadata metadata);
@Query("select distinct mm.metadata from MetadataMethod mm where mm.method = ?1")
List<Metadata> listMetadataByMethod(Method method);
}
......@@ -19,8 +19,13 @@ package org.crophub.rest.common.persistence.domain;
import java.util.List;
import org.crophub.rest.common.model.genesys.Method;
import org.crophub.rest.common.model.genesys.Parameter;
import org.springframework.data.jpa.repository.JpaRepository;
public interface MethodRepository extends JpaRepository<Method, Long> {
List<Method> findByFieldType(int fieldType);
List<Method> findByParameter(Parameter parameter);
Method findByIdAndParameter(long id, Parameter findOne);
}
package org.crophub.rest.common.service;
import java.util.List;
import org.crophub.rest.common.model.genesys.Metadata;
import org.crophub.rest.common.model.genesys.Method;
import org.crophub.rest.common.model.genesys.Parameter;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
public interface TraitService {
Page<Parameter> listTraits(Pageable pageable);
Parameter getTrait(long traitId);
List<Method> getTraitMethods(Parameter trait);
Method getMethod(long traitId);
List<Metadata> listMetadataByMethod(Method method);
}
......@@ -31,6 +31,7 @@ import org.crophub.rest.common.model.genesys.AllEnvironment;
import org.crophub.rest.common.model.genesys.ExperimentTrait;
import org.crophub.rest.common.model.genesys.Metadata;
import org.crophub.rest.common.model.genesys.Method;
import org.crophub.rest.common.model.genesys.Parameter;
import org.crophub.rest.common.model.genesys.Taxonomy;
import org.crophub.rest.common.model.impl.Country;
import org.crophub.rest.common.model.impl.Crop;
......@@ -46,8 +47,10 @@ import org.crophub.rest.common.persistence.domain.CropTaxonomyRepository;
import org.crophub.rest.common.persistence.domain.MetadataMethodRepository;
import org.crophub.rest.common.persistence.domain.MetadataRepository;
import org.crophub.rest.common.persistence.domain.MethodRepository;
import org.crophub.rest.common.persistence.domain.ParameterRepository;
import org.crophub.rest.common.persistence.domain.TraitValueRepository;
import org.crophub.rest.common.service.GenesysService;
import org.crophub.rest.common.service.TraitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
......@@ -57,7 +60,7 @@ import org.springframework.transaction.annotation.Transactional;
@Service
@Transactional(readOnly = true)
public class GenesysServiceImpl implements GenesysService {
public class GenesysServiceImpl implements GenesysService, TraitService {
public static final Log LOG = LogFactory.getLog(GenesysServiceImpl.class);
......@@ -89,6 +92,9 @@ public class GenesysServiceImpl implements GenesysService {
@Autowired
private MethodRepository methodRepository;
@Autowired
private ParameterRepository parameterRepository;
@Override
public long countByInstitute(FaoInstitute institute) {
return accessionRepository.countByInstitute(institute);
......@@ -228,4 +234,29 @@ public class GenesysServiceImpl implements GenesysService {
public Page<Accession> listAccessionsByCrop(Crop crop, Pageable pageable) {
return accessionRepository.findByTaxonomy(cropTaxonomyRepository.findTaxonomiesByCrop(crop), pageable);
}
@Override
public Page<Parameter> listTraits(Pageable pageable) {
return parameterRepository.findAll(pageable);
}
@Override
public Parameter getTrait(long traitId) {
return parameterRepository.findOne(traitId);
}
@Override
public List<Method> getTraitMethods(Parameter trait) {
return methodRepository.findByParameter(trait);
}
@Override
public Method getMethod(long methodId) {
return methodRepository.findOne(methodId);
}
@Override
public List<Metadata> listMetadataByMethod(Method method) {
return metadataMethodRepository.listMetadataByMethod(method);
}
}
......@@ -16,15 +16,18 @@
package org.crophub.rest.servlet.controller;
import java.util.List;
import org.crophub.rest.common.model.impl.Descriptor;
import org.crophub.rest.common.service.DescriptorService;
import org.crophub.rest.common.model.genesys.Method;
import org.crophub.rest.common.model.genesys.Parameter;
import org.crophub.rest.common.service.TraitService;
import org.crophub.spring.ResourceNotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.Validator;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
* Controller which simply handles *.html requests
......@@ -34,17 +37,46 @@ import org.springframework.web.bind.annotation.RequestMapping;
public class DescriptorController extends BaseController {
@Autowired
private DescriptorService descriptorService;
@Autowired
private Validator validator;
private TraitService traitService;
@RequestMapping
public String index(ModelMap model) {
List<Descriptor> descriptors = descriptorService.list();
_logger.info("Got " + descriptors.size() + " descriptors");
model.addAttribute("descriptors", descriptors);
public String index(ModelMap model, @RequestParam(value = "page", required = false, defaultValue = "1") int page) {
model.addAttribute("traits", traitService.listTraits(new PageRequest(page - 1, 50, new Sort("title"))));
return "/descr/index";
}
@RequestMapping("/{id}")
public String view(ModelMap model, @PathVariable("id") long traitId) {
Parameter trait = traitService.getTrait(traitId);
if (trait == null) {
throw new ResourceNotFoundException();
}
model.addAttribute("trait", trait);
model.addAttribute("traitMethods", traitService.getTraitMethods(trait));
return "/descr/details";
}
@RequestMapping("/{traitId}/{methodId}")
public String view(ModelMap model, @PathVariable("traitId") long traitId, @PathVariable("methodId") long methodId) {
Parameter trait = traitService.getTrait(traitId);
if (trait == null) {
throw new ResourceNotFoundException();
}
Method method = traitService.getMethod(methodId);
if (method == null) {
throw new ResourceNotFoundException();
}
if (!method.getParameter().getId().equals(trait.getId())) {
_logger.warn("Method does not belong to Param");
}
model.addAttribute("trait", trait);
model.addAttribute("method", method);
model.addAttribute("metadatas", traitService.listMetadataByMethod(method));
return "/descr/method";
}
}
......@@ -76,7 +76,8 @@ footer.copyright-statement=&copy; 2013 Data Providers and GCDT
menu.home=Home
menu.browse=Browse
menu.datasets=Datasets
menu.datasets=C&E Data
menu.descriptors=Descriptors
menu.countries=Countries
menu.institutes=Institutes
menu.my-list=My List
......@@ -97,6 +98,7 @@ user.create-new-account=Create an account
crop.croplist=Crop list
crop.page.profile.title={0} profile
crop.taxonomy-rules=Taxonomic rules
activity.recent-activity=Recent activity
......@@ -125,7 +127,7 @@ paged.pageOfPages=Page {0} of {1}
paged.totalElements={0} entries
accessions.number={0} accessions
accession.metadatas=Datasets
accession.metadatas=C&E Data
accession.methods=Characterization & Evaluation data
accession.accessionName=Accession
......@@ -160,6 +162,7 @@ accession.taxonomy-at-institute=View {0} at {1}
taxonomy.genus=Genus
taxonomy.species=Species
taxonomy.taxonName=Taxonomy
taxonomy-list=Taxonomy list
selection.page.title=Selected accessions
selection.add=Add {0} to list
......
......@@ -30,6 +30,11 @@
<property name="driverClassName" value="${db.driverClassName}" />
<property name="username" value="${db.username}" />
<property name="password" value="${db.password}" />
<!--
<property name="timeBetweenEvictionRunsMillis" value="5000" />
<property name="minEvictableIdleTimeMillis" value="5000" />
<property name="minIdle" value="0" />
-->
</bean>
<bean class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" id="entityManagerFactory">
......
......@@ -20,7 +20,7 @@
#db.username = sa
#db.password =
db.url=jdbc:mysql://localhost/pgrsys_genesys?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
db.url=jdbc:mysql://127.0.0.1/pgrsys_genesys?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
db.driverClassName = com.mysql.jdbc.Driver
db.username = root
db.password =
......
......@@ -97,6 +97,7 @@
<li><a href="<c:url value="/" />"><spring:message code="menu.home" /></a></li>
<li><a href="<c:url value="/acn/" />"><spring:message code="menu.browse" /></a></li>
<li><a href="<c:url value="/data/" />"><spring:message code="menu.datasets" /></a></li>
<li><a href="<c:url value="/descriptors/" />"><spring:message code="menu.descriptors" /></a></li>
<li><a href="<c:url value="/geo/" />"><spring:message code="menu.countries" /></a></li>
<li><a href="<c:url value="/wiews/active" />"><spring:message code="menu.institutes" /></a></li>
<li><a href="<c:url value="/sel/" />"><spring:message code="menu.my-list" /><div id="selcounter">${selection.size() gt 0 ? selection.size() : ''}</div></a></li>
......
......@@ -21,22 +21,25 @@
<c:out value="${crop.description}" />
</div>
<h4><spring:message code="crop.taxonomy-rules" /></h4>
<ul class="funny-list">
<c:forEach items="${crop.cropRules}" var="rule">
<li><c:out value="${rule.included}" /> <c:out value="${rule.genus}" /> <c:out value="${rule.species}" /></li>
<li class="${rule.included ? '' : 'excluded'}" /><b>${rule.included ? '+' : '-'}</b> <c:out value="${rule.genus}" /> <c:out value="${rule.species eq null ? '*' : rule.species}" /></li>
</c:forEach>
</ul>
<%--
<div class="free-text">
<c:out value="${crop.language}" />
</div>
--%>
<a href="<c:url value="/c/${crop.shortName}/data" />"><spring:message code="view.accessions" /></a>
<h3><spring:message code="taxonomy-list" /></h3>
<ul class="funny-list">
<c:forEach items="${cropTaxonomies}" var="cropTaxonomy">
<li><c:out value="${cropTaxonomy.taxonomy.taxonName}" /></li>
<li><a href="<c:url value="/acn/t/${cropTaxonomy.taxonomy.genus}/${cropTaxonomy.taxonomy.species}" />"><c:out value="${cropTaxonomy.taxonomy.taxonName}" /></a></li>
</c:forEach>
</ul>
......
<!DOCTYPE html>
<%@include file="/WEB-INF/jsp/init.jsp"%>
<html>
<head>
<title><spring:message code="metadata.page.title" /></title>
</head>
<body>
<h1><c:out value="${trait.title}" /></h1>
<div><a href="<c:url value="/c/${trait.crop.shortName}" />">${trait.crop.name}</a> trait</div>
<h4>Methods</h4>
<table>
<tbody>
<c:forEach items="${traitMethods}" var="method">
<tr>
<td><c:out value="${method.parameter.title}" /></td>
<td><a href="<c:url value="/descriptors/${trait.id}/${method.id}" />"><c:out value="${method.method}" /></a></td>
<td><c:out value="${method.fieldName}" /></td>
<td><c:out value="${method.unit}" /></td>
</tr>
</c:forEach>
</tbody>
</table>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<%@include file="../init.jsp"%>
<%@include file="/WEB-INF/jsp/init.jsp"%>
<html>
<head>
<%@include file="../head-init.jsp"%>
<title><spring:message code="sample.message.index.title"/></title>
<link type="text/css" href="/html/css/jquery-ui.css" rel="stylesheet"/>
<link type="text/css" href="/html/css/jquery.dataTables.css" rel="stylesheet"/>
<%--Fallback for older browsers--%>
<script type="text/javascript" src="/html/js/json2.js"></script>
<script type="text/javascript" src="/html/js/globalize.js"></script>
<script type="text/javascript" src="/html/js/jquery-ui.min.js"></script>
<script type="text/javascript" src="/html/js/jquery.dataTables.js"></script>
<script type="text/javascript" src="/html/js/handlebars.js"></script>
<script type="text/javascript" src="/html/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/html/js/main.js"></script>
<title><spring:message code="metadata.page.title" /></title>
</head>
<body>
<div class="container">
<div id="header">
<div class="page-header clearfix">
<h4 class="pull-left"><spring:message code="sample.message.welcome"/></h4>
<div class="navbar pull-right">
<div class="nav-collapse">
<ul class="nav">
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" title="<spring:message code="sample.message.change.locale"/>">
<spring:message code="sample.message.current.locale"/>
<b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li><a href="?lang=en"><spring:message code="sample.message.locale.en"/></a></li>
<li><a href="?lang=ru"><spring:message code="sample.message.locale.ru"/></a></li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</div>
<div id="content">
<div class="page-header">
<a id="show-users" href="#" class="btn">Users</a>
</div>
<div id="dialog"></div>
<c:forEach items="${descriptors}" var="descriptor" varStatus="status">
<h3><c:out value="${descriptor.name}" /></h3>
<p><c:out value="${descriptor.description}" /></p>
</c:forEach>
</div>
</div>
<div class="nav-header">
<spring:message code="paged.totalElements" arguments="${traits.totalElements}" />
<br />
<spring:message code="paged.pageOfPages" arguments="${traits.number+1},${traits.totalPages}" />
<a href="?page=${traits.number}">⇇ Previous</a> <a href="?page=${traits.number + 2}">Next ⇉</a>
</div>
<table class="accessions">
<thead>
<tr>
<td class="idx-col" />
<td>Trait</td>
<td>Crop</td>
</tr>
</thead>
<tbody>
<c:forEach items="${traits.content}" var="trait" varStatus="status">
<tr class="${status.count % 2 == 0 ? 'even' : 'odd'}">
<td class="idx-col">${status.count + traits.size * traits.number}</td>
<td><a href="<c:url value="/descriptors/${trait.id}" />">${trait.title}</a></td>
<td><a href="<c:url value="/c/${trait.crop.shortName}" />">${trait.crop.name}</a></td>
</tr>
</c:forEach>
</tbody>
</table>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<%@include file="/WEB-INF/jsp/init.jsp"%>
<html>
<head>
<title><spring:message code="metadata.page.title" /></title>
</head>
<body>
<h1>
<c:out value="${trait.title}" />
</h1>
<table>
<tbody>
<tr>
<td><a href="<c:url value="/descriptors/${trait.id}" />"><c:out value="${method.parameter.title}" /></a></td>
<td><a href="<c:url value="/descriptors/${trait.id}/${method.id}" />"><c:out value="${method.method}" /></a></td>
<td><c:out value="${method.fieldName}" /></td>
<td><c:out value="${method.unit}" /></td>
</tr>
</tbody>
</table>
<h3><spring:message code="accession.metadatas" /></h3>
<ul class="funny-list">
<c:forEach items="${metadatas}" var="metadata">
<li><a href="/data/view/${metadata.id}"><c:out value="${metadata.title}" /></a> <c:out value="${metadata.institute}" /></li>
</c:forEach>
</ul>
</body>
</html>
\ No newline at end of file
......@@ -16,8 +16,8 @@
<tbody>
<c:forEach items="${methods}" var="method">
<tr>
<td><c:out value="${method.parameter.title}" /></td>
<td><c:out value="${method.method}" /></td>
<td><a href="<c:url value="/descriptors/${method.parameter.id}" />"><c:out value="${method.parameter.title}" /></a></td>
<td><a href="<c:url value="/descriptors/${method.parameter.id}/${method.id}" />"><c:out value="${method.method}" /></a></td>
<td><c:out value="${method.fieldName}" /></td>
<td><c:out value="${method.unit}" /></td>
</tr>
......
......@@ -58,13 +58,16 @@ td {
padding: 0.2em 0.5em;
}
td.idx-col {
.idx-col {
font-size: 80%;
width: 4em;
/* background-color: #eaeaea; */
/* text-align: right; */
vertical-align: middle;
}
span.idx-col {
display: inline-block;
}
tr.odd td {
background-color: #f8f7f5;
......
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