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

Renamed DataSet to Dataset

parent 1bec9544
......@@ -29,7 +29,7 @@ import org.crophub.rest.common.model.BusinessModel;
@Entity
@Table(name = "dataset")
public class DataSet extends BusinessModel {
public class Dataset extends BusinessModel {
private static final long serialVersionUID = 4562288873039057125L;
@ManyToOne(cascade = {}, optional = true)
......@@ -119,6 +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);
}
}
......@@ -36,13 +36,13 @@ import org.hibernate.annotations.Index;
@org.hibernate.annotations.Table(appliesTo = "sparsedata", indexes = {
@Index(columnNames = { "descriptorId", "stringId" }, name = "descriptorstring_SPARSEDATA"),
@Index(columnNames = { "sparseEntryId" }, name = "entry_SPARSEDATA"),
@Index(columnNames = { "dataSetId", "descriptorId" }, name = "datasetdescriptor_SPARSEDATA"),
@Index(columnNames = { "datasetId", "descriptorId" }, name = "datasetdescriptor_SPARSEDATA"),
@Index(columnNames = { "descriptorId" }, name = "descriptor_SPARSEDATA") })
public class SparseData extends BusinessModel {
private static final long serialVersionUID = -2142036544458439223L;
@OrderColumn
private long dataSetId;
private long datasetId;
@OrderColumn
private long sparseEntryId;
......@@ -57,12 +57,12 @@ public class SparseData extends BusinessModel {
@JoinColumn(name = "stringId")
private SparseString sparseString;
public long getDataSetId() {
return dataSetId;
public long getDatasetId() {
return datasetId;
}
public void setDataSetId(long dataSetId) {
this.dataSetId = dataSetId;
public void setDatasetId(long datasetId) {
this.datasetId = datasetId;
}
public long getSparseEntryId() {
......
......@@ -24,7 +24,7 @@ import javax.persistence.Table;
import org.crophub.rest.common.model.BusinessModel;
/**
* Represents a sparse data vector, part of a {@link DataSet} in the system.
* Represents a sparse data vector, part of a {@link Dataset} in the system.
*
* @author mobreza
*/
......@@ -34,14 +34,14 @@ public class SparseEntry extends BusinessModel {
private static final long serialVersionUID = 2430418022616359050L;
@ManyToOne(cascade = {}, optional = false)
@JoinColumn(name = "dataSetId", nullable = false)
private DataSet dataSet;
@JoinColumn(name = "datasetId", nullable = false)
private Dataset dataset;
public DataSet getDataSet() {
return dataSet;
public Dataset getDataset() {
return dataset;
}
public void setDataSet(final DataSet dataSet) {
this.dataSet = dataSet;
public void setDataset(final Dataset dataset) {
this.dataset = dataset;
}
}
......@@ -16,8 +16,8 @@
package org.crophub.rest.common.persistence.domain;
import org.crophub.rest.common.model.impl.DataSet;
import org.crophub.rest.common.model.impl.Dataset;
import org.springframework.data.jpa.repository.JpaRepository;
public interface DataSetRepository extends JpaRepository<DataSet, Long> {
public interface DatasetRepository extends JpaRepository<Dataset, Long> {
}
......@@ -27,13 +27,13 @@ import org.springframework.data.jpa.repository.Query;
public interface SparseDataRepository extends JpaRepository<SparseData, Long> {
List<SparseData> findBySparseEntryId(long sparseEntryId);
@Query("select count(sd) from SparseData sd where sd.dataSetId=?1")
@Query("select count(sd) from SparseData sd where sd.datasetId=?1")
@Cacheable(value="sparsedata", key="#root.methodName+#a0")
long countByDataSetId(long dataSetId);
long countByDatasetId(long datasetId);
@Query("select distinct sd.descriptorId from SparseData sd where sd.dataSetId=?1")
@Query("select distinct sd.descriptorId from SparseData sd where sd.datasetId=?1")
@Cacheable(value="sparsedata", key="#root.methodName+#a0")
List<Long> getDescriptorIdsByDataSetId(long dataSetId);
List<Long> getDescriptorIdsByDatasetId(long datasetId);
@Query("select count(sd) from SparseData sd where sd.sparseEntryId=?1")
long countBySparseEntryId(long sparseEntryId);
......
......@@ -18,7 +18,7 @@ package org.crophub.rest.common.persistence.domain;
import java.util.List;
import org.crophub.rest.common.model.impl.DataSet;
import org.crophub.rest.common.model.impl.Dataset;
import org.crophub.rest.common.model.impl.SparseEntry;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.jpa.repository.JpaRepository;
......@@ -26,9 +26,9 @@ import org.springframework.data.jpa.repository.Query;
public interface SparseEntryRepository extends JpaRepository<SparseEntry, Long> {
List<SparseEntry> findByDataSet(DataSet dataSet);
List<SparseEntry> findByDataset(Dataset dataset);
@Query("select count(se) from SparseEntry se where se.dataSet=?1")
@Query("select count(se) from SparseEntry se where se.dataset=?1")
@Cacheable(value="sparseentry", key="#root.methodName+#a0.id")
long countByDataSet(DataSet dataSet);
long countByDataset(Dataset dataset);
}
......@@ -19,22 +19,22 @@ package org.crophub.rest.common.service;
import java.util.List;
import org.crophub.rest.common.model.impl.DataSet;
import org.crophub.rest.common.model.impl.Dataset;
import org.crophub.rest.common.model.impl.Descriptor;
public interface DataService {
List<DataSet> list();
List<Dataset> list();
DataSet getDataSet(long dataSetId);
Dataset getDataset(long datasetId);
void save(DataSet dataset);
void save(Dataset dataset);
void writeEntries(DataSet dataSet, Descriptor[] descriptors, List<String[]> data);
void writeEntries(Dataset dataset, Descriptor[] descriptors, List<String[]> data);
long countEntries(DataSet dataSet);
long countEntries(Dataset dataset);
long countData(DataSet dataSet);
long countData(Dataset dataset);
Iterable<Descriptor> getDescriptors(DataSet dataSet);
Iterable<Descriptor> getDescriptors(Dataset dataset);
}
......@@ -6,11 +6,11 @@ import java.util.List;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.crophub.rest.common.model.impl.DataSet;
import org.crophub.rest.common.model.impl.Dataset;
import org.crophub.rest.common.model.impl.Descriptor;
import org.crophub.rest.common.model.impl.SparseData;
import org.crophub.rest.common.model.impl.SparseEntry;
import org.crophub.rest.common.persistence.domain.DataSetRepository;
import org.crophub.rest.common.persistence.domain.DatasetRepository;
import org.crophub.rest.common.persistence.domain.DescriptorRepository;
import org.crophub.rest.common.persistence.domain.SparseDataRepository;
import org.crophub.rest.common.persistence.domain.SparseEntryRepository;
......@@ -40,45 +40,45 @@ public class DataServiceImpl implements DataService {
SparseStringService stringService;
@Autowired
private DataSetRepository dataSetRepository;
private DatasetRepository datasetRepository;
@Override
public List<DataSet> list() {
return dataSetRepository.findAll();
public List<Dataset> list() {
return datasetRepository.findAll();
}
@Override
public DataSet getDataSet(long dataSetId) {
return dataSetRepository.findOne(dataSetId);
public Dataset getDataset(long datasetId) {
return datasetRepository.findOne(datasetId);
}
@Override
@Transactional(readOnly=false)
public void save(DataSet dataset) {
dataSetRepository.save(dataset);
public void save(Dataset dataset) {
datasetRepository.save(dataset);
}
@Override
public long countEntries(DataSet dataSet) {
return entryRepository.countByDataSet(dataSet);
public long countEntries(Dataset dataset) {
return entryRepository.countByDataset(dataset);
}
@Override
public long countData(DataSet dataSet) {
return dataRepository.countByDataSetId(dataSet.getId());
public long countData(Dataset dataset) {
return dataRepository.countByDatasetId(dataset.getId());
}
@Override
public Iterable<Descriptor> getDescriptors(DataSet dataSet) {
return descriptorRepository.findAll(dataRepository.getDescriptorIdsByDataSetId(dataSet.getId()));
public Iterable<Descriptor> getDescriptors(Dataset dataset) {
return descriptorRepository.findAll(dataRepository.getDescriptorIdsByDatasetId(dataset.getId()));
}
// FIXME This code does not handle column grouping
@Override
@Transactional(readOnly = false)
@CacheEvict(value="methods", allEntries=true)
public void writeEntries(final DataSet dataSet, final Descriptor[] descriptors,
public void writeEntries(final Dataset dataset, final Descriptor[] descriptors,
final List<String[]> datas) {
final List<SparseEntry> sparseEntries = new ArrayList<SparseEntry>(
......@@ -89,7 +89,7 @@ public class DataServiceImpl implements DataService {
for (int j = 0; j < datas.size(); j++) {
// New entry
final SparseEntry sparseEntry = new SparseEntry();
sparseEntry.setDataSet(dataSet);
sparseEntry.setDataset(dataset);
sparseEntries.add(sparseEntry);
}
......
......@@ -18,7 +18,7 @@ package org.crophub.rest.servlet.controller;
import java.util.List;
import org.crophub.rest.common.model.impl.DataSet;
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;
......@@ -32,7 +32,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
*/
@Controller
@RequestMapping("/data")
public class DataSetController extends BaseController {
public class DatasetController extends BaseController {
@Autowired
private DataService dataService;
......@@ -42,19 +42,19 @@ public class DataSetController extends BaseController {
@RequestMapping
public String index(ModelMap model) {
List<DataSet> dataSets = dataService.list();
model.addAttribute("dataSets", dataSets);
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);
model.addAttribute("entrySize", dataService.countEntries(dataSet));
model.addAttribute("dataSize", dataService.countData(dataSet));
model.addAttribute("descriptors", dataService.getDescriptors(dataSet));
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);
model.addAttribute("entrySize", dataService.countEntries(dataset));
model.addAttribute("dataSize", dataService.countData(dataset));
model.addAttribute("descriptors", dataService.getDescriptors(dataset));
return "/dataset/view";
}
......
......@@ -55,9 +55,9 @@
<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 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>
......
......@@ -47,7 +47,7 @@
<a href="..">Go back!</a>
<h3>
<a href="/data/view/${dataSet.id}"><c:out value="${dataSet.name}" /></a>
<a href="/data/view/${dataset.id}"><c:out value="${dataset.name}" /></a>
</h3>
<p>
<fmt:formatNumber value="${entrySize}" /> Entries in this dataset.
......@@ -66,13 +66,13 @@
</c:forEach>
</table>
<p>
<c:out value="${dataSet.source}" />
<c:out value="${dataset.source}" />
</p>
<p>
<fmt:formatDate value="${dataSet.uploadDate}" />
<fmt:formatDate value="${dataset.uploadDate}" />
</p>
<div>
<c:out value="${dataSet.description}" escapeXml="false" />
<c:out value="${dataset.description}" escapeXml="false" />
</div>
</div>
</div>
......
......@@ -48,7 +48,7 @@ import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.crophub.rest.common.model.impl.ColumnGroups;
import org.crophub.rest.common.model.impl.DataMapping;
import org.crophub.rest.common.model.impl.DataSet;
import org.crophub.rest.common.model.impl.Dataset;
import org.crophub.rest.common.model.impl.Descriptor;
import org.crophub.rest.common.persistence.domain.DescriptorRepository;
import org.crophub.rest.common.service.DataService;
......@@ -183,7 +183,7 @@ public class SGSVUpdate extends RunnerTest {
}
}
final DataSet dataset = new DataSet();
final Dataset dataset = new Dataset();
dataset.setName("SGSV update");
dataset.setHeaders(mapper.writeValueAsString(headers));
......@@ -238,7 +238,7 @@ public class SGSVUpdate extends RunnerTest {
LOG.info("Done importing SGSV data. Imported: " + counter);
}
private void workIt(final DataSet dataset, final Descriptor[] descriptors, final List<String[]> bulk) {
private void workIt(final Dataset dataset, final Descriptor[] descriptors, final List<String[]> bulk) {
while (threadPool.getQueue().size() > nThreads) {
LOG.trace("Queue is too large, waiting...");
......@@ -271,12 +271,12 @@ public class SGSVUpdate extends RunnerTest {
private static class SparseDataUpdater implements Runnable {
private final DataSet dataset;
private final Dataset dataset;
private final Descriptor[] descriptors;
private final ArrayList<String[]> bulk;
private final DataService dataService;
public SparseDataUpdater(final DataService dataService, final DataSet dataset, final Descriptor[] descriptors, final ArrayList<String[]> bulk) {
public SparseDataUpdater(final DataService dataService, final Dataset dataset, final Descriptor[] descriptors, final ArrayList<String[]> bulk) {
this.dataService = dataService;
this.dataset = dataset;
this.descriptors = descriptors;
......
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