Commit 5b23bd60 authored by Matija Obreza's avatar Matija Obreza
Browse files

Descriptors, datasets

parent 52f924a0
......@@ -32,15 +32,25 @@ import org.crophub.rest.common.model.BusinessModel;
public class DataSet extends BusinessModel {
private static final long serialVersionUID = 4562288873039057125L;
@ManyToOne(cascade = {}, optional = true)
private License license;
@Column(nullable = false, length = 500)
private String name;
@Lob
private String description;
@Column(length = 500)
private String source;
@Lob
private String headers;
@Lob
private String mapping;
private Date uploadDate;
@ManyToOne(cascade = {}, optional = true)
public License getLicense() {
return license;
}
......@@ -49,7 +59,6 @@ public class DataSet extends BusinessModel {
this.license = license;
}
@Column(nullable = false, length = 500)
public String getName() {
return name;
}
......@@ -58,6 +67,14 @@ public class DataSet extends BusinessModel {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Date getUploadDate() {
return uploadDate;
}
......@@ -66,7 +83,6 @@ public class DataSet extends BusinessModel {
this.uploadDate = uploadDate;
}
@Column(length = 500)
public String getSource() {
return source;
}
......@@ -77,10 +93,9 @@ public class DataSet extends BusinessModel {
/**
* Gets list of headers in source file
*
*
* @return
*/
@Lob
public String getHeaders() {
return headers;
}
......@@ -91,10 +106,9 @@ public class DataSet extends BusinessModel {
/**
* Data mapping info
*
*
* @return
*/
@Lob
public String getMapping() {
return mapping;
}
......@@ -105,8 +119,6 @@ public class DataSet extends BusinessModel {
@Override
public String toString() {
return MessageFormat.format(
"DataSet id={0,number,#} date={1,date,dd/MM/yyyy} name={2}",
id, uploadDate, name);
return MessageFormat.format("DataSet id={0,number,#} date={1,date,dd/MM/yyyy} name={2}", id, uploadDate, name);
}
}
......@@ -34,10 +34,13 @@ import org.crophub.rest.common.model.BusinessModel;
@Table(name="descriptor")
public class Descriptor extends BusinessModel {
private static final long serialVersionUID = 3832200593904442940L;
@Column(nullable = false, length = 500)
private String name;
@Lob
private String description;
@Column(nullable = false, length = 500)
public String getName() {
return name;
}
......@@ -46,7 +49,6 @@ public class Descriptor extends BusinessModel {
this.name = name;
}
@Lob
public String getDescription() {
return description;
}
......
......@@ -39,12 +39,18 @@ import org.hibernate.annotations.Index;
@Index(columnNames = { "descriptorId" }, name = "descriptor_SPARSEDATA") })
public class SparseData extends BusinessModel {
private static final long serialVersionUID = -2142036544458439223L;
@OrderColumn
private long sparseEntryId;
@OrderColumn
private long descriptorId;
@Column(nullable = false, length = 500)
private String value;
@ManyToOne(cascade = {}, optional = true)
@JoinColumn(name = "stringId")
private SparseString sparseString;
@OrderColumn
public long getSparseEntryId() {
return sparseEntryId;
}
......@@ -53,7 +59,6 @@ public class SparseData extends BusinessModel {
this.sparseEntryId = sparseEntryId;
}
@OrderColumn
public long getDescriptorId() {
return descriptorId;
}
......@@ -62,7 +67,6 @@ public class SparseData extends BusinessModel {
this.descriptorId = descriptorId;
}
@Column(nullable = false, length = 500)
public String getValue() {
return value;
}
......@@ -71,8 +75,6 @@ public class SparseData extends BusinessModel {
this.value = value;
}
@ManyToOne(cascade = {}, optional = true)
@JoinColumn(name = "stringId")
public SparseString getSparseString() {
return sparseString;
}
......
......@@ -32,10 +32,11 @@ import org.crophub.rest.common.model.BusinessModel;
@Table(name = "sparseentry")
public class SparseEntry extends BusinessModel {
private static final long serialVersionUID = 2430418022616359050L;
private DataSet dataSet;
@ManyToOne(cascade = {}, optional = false)
@JoinColumn(name = "dataSetId", nullable = false)
private DataSet dataSet;
public DataSet getDataSet() {
return dataSet;
}
......
......@@ -33,6 +33,14 @@ import org.crophub.rest.common.model.BusinessModel;
@Table(name = "sparsestring")
public class SparseString extends BusinessModel {
private static final long serialVersionUID = 5896186555138979311L;
@Column
private String hash;
@Column
private int length;
@Column(length = 500, nullable = false, updatable = false, unique = true)
private String value;
public SparseString() {
......@@ -47,6 +55,7 @@ public class SparseString extends BusinessModel {
}
public void setHash(final int hash) {
}
public int getLength() {
......@@ -56,7 +65,6 @@ public class SparseString extends BusinessModel {
public void setLength(final int length) {
}
@Column(length = 500, nullable = false, updatable = false, unique = true)
public String getValue() {
return value;
}
......
/**
* 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.crophub.rest.common.service;
import java.util.List;
import org.crophub.rest.common.model.impl.DataSet;
public interface DataService {
List<DataSet> list();
DataSet getDataSet(long dataSetId);
}
/**
* 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.crophub.rest.common.service;
import java.util.List;
import org.crophub.rest.common.model.impl.Descriptor;
public interface DescriptorService {
List<Descriptor> list();
}
package org.crophub.rest.common.service.impl;
import java.util.List;
import org.crophub.rest.common.model.impl.DataSet;
import org.crophub.rest.common.persistence.domain.DataSetRepository;
import org.crophub.rest.common.service.DataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
@Transactional(readOnly = true)
public class DataServiceImpl implements DataService {
@Autowired
private DataSetRepository dataSetRepository;
@Override
public List<DataSet> list() {
return dataSetRepository.findAll();
}
@Override
public DataSet getDataSet(long dataSetId) {
return dataSetRepository.findOne(dataSetId);
}
}
package org.crophub.rest.common.service.impl;
import java.util.List;
import org.crophub.rest.common.model.impl.Descriptor;
import org.crophub.rest.common.persistence.domain.DescriptorRepository;
import org.crophub.rest.common.service.DescriptorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
@Transactional(readOnly = true)
public class DescriptorServiceImpl implements DescriptorService {
@Autowired
private DescriptorRepository descriptorRepository;
@Override
public List<Descriptor> list() {
return descriptorRepository.findAll();
}
}
/**
* 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.crophub.rest.servlet.controller;
import java.util.List;
import org.crophub.rest.common.model.impl.DataSet;
import org.crophub.rest.common.service.DataService;
import org.springframework.beans.factory.annotation.Autowired;
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;
/**
* Controller which simply handles *.html requests
*/
@Controller
@RequestMapping("/data")
public class DataSetController extends BaseController {
@Autowired
private DataService dataService;
@Autowired
private Validator validator;
@RequestMapping
public String index(ModelMap model) {
List<DataSet> dataSets = dataService.list();
model.addAttribute("dataSets", dataSets);
return "/dataset/index";
}
@RequestMapping("/view/{id}")
public String view(ModelMap model, @PathVariable(value = "id") long dataSetId) {
_logger.debug("Viewing data for " + dataSetId);
DataSet dataSet=dataService.getDataSet(dataSetId);
model.addAttribute("dataSet", dataSet);
return "/dataset/view";
}
}
/**
* 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.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.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.Validator;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* Controller which simply handles *.html requests
*/
@Controller
@RequestMapping("/descriptors")
public class DescriptorController extends BaseController {
@Autowired
private DescriptorService descriptorService;
@Autowired
private Validator validator;
@RequestMapping
public String index(ModelMap model) {
List<Descriptor> descriptors = descriptorService.list();
_logger.info("Got " + descriptors.size() + " descriptors");
model.addAttribute("descriptors", descriptors);
return "/descr/index";
}
}
<!DOCTYPE html>
<%@include file="../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>
</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="${dataSets}" var="dataSet" varStatus="status">
<h3><a href="/data/view/${dataSet.id}"><c:out value="${dataSet.name}" /></a></h3>
<p><c:out value="${dataSet.uploadDate}" /></p>
</c:forEach>
</div>
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<%@include file="../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>
</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>
<p>Showing data now!</p>
<a href="..">Go back!</a>
<h3>
<a href="/data/view/${dataSet.id}"><c:out value="${dataSet.name}" /></a>
</h3>
<p>
<c:out value="${dataSet.uploadDate}" />
</p>
<div>
<c:out value="${dataSet.description}" escapeXml="false" />
</div>
</div>
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<%@include file="../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>
</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"/>">