Commit 66ba35fd authored by Matija Obreza's avatar Matija Obreza

Historic: C&E data

parent 266fb660
......@@ -38,7 +38,7 @@ public interface AccessionTraitRepository extends JpaRepository<AccessionTrait,
List<Long> listMethodIds(AccessionId accession);
@Query(value = "select distinct a from AccessionTrait at inner join at.accession a where at.metadataId = ?1", countQuery = "select count(ma.accessionId) from MetadataAccession ma where ma.metadata.id = ?1")
Page<Accession> listMetadataAccessions(long metadataId, Pageable pageable);
Page<AccessionId> listMetadataAccessions(long metadataId, Pageable pageable);
List<AccessionTrait> findByMetadataIdAndAccession(Long id, Accession accession);
......
......@@ -384,7 +384,7 @@ public class GenesysLowlevelRepositoryCustomImpl implements GenesysLowlevelRepos
@Override
public PreparedStatement createPreparedStatement(final Connection con) throws SQLException {
final PreparedStatement stmt = con
.prepareStatement("select distinct a.id, a.instCode, a.acceNumb, a.genus from accessiontrait at inner join accession a on a.id=at.accessionId where at.metadataId = ?");
.prepareStatement("select distinct a.id, a.instCode, a.acceNumb, t.genus from accessiontrait at inner join accession a on a.id=at.accessionId left outer join taxonomy2 t on t.id=a.taxonomyId2 where at.metadataId = ?");
stmt.setLong(1, id);
// Set mysql JConnector to stream results
stmt.setFetchSize(Integer.MIN_VALUE);
......
......@@ -19,7 +19,7 @@ package org.genesys2.server.persistence.domain;
import java.util.List;
import java.util.Map;
import org.genesys2.server.model.genesys.Accession;
import org.genesys2.server.model.genesys.AccessionData;
import org.genesys2.server.model.genesys.AccessionId;
import org.genesys2.server.model.genesys.AccessionTrait;
import org.genesys2.server.model.genesys.ExperimentAccessionTrait;
......@@ -37,7 +37,7 @@ public interface TraitValueRepository {
Map<Long, List<ExperimentTrait>> getValues(List<AccessionTrait> accessionTraits);
Map<Long, Map<Long, List<Object>>> getValues(Metadata metadata, List<Method> methods, List<Accession> accessions);
Map<Long, Map<Long, List<Object>>> getValues(Metadata metadata, List<Method> methods, List<AccessionData> accessions);
/**
* @return list of non-null trait values
......@@ -46,4 +46,5 @@ public interface TraitValueRepository {
Map<String, Long> getStatistics(Method method);
}
......@@ -32,7 +32,7 @@ import javax.sql.DataSource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.genesys2.server.model.genesys.Accession;
import org.genesys2.server.model.genesys.AccessionData;
import org.genesys2.server.model.genesys.AccessionId;
import org.genesys2.server.model.genesys.AccessionTrait;
import org.genesys2.server.model.genesys.ExperimentAccessionTrait;
......@@ -159,7 +159,7 @@ public class TraitValueRepositoryImpl implements TraitValueRepository {
}
@Override
public Map<Long, Map<Long, List<Object>>> getValues(Metadata metadata, List<Method> methods, List<Accession> accessions) {
public Map<Long, Map<Long, List<Object>>> getValues(Metadata metadata, List<Method> methods, List<AccessionData> accessions) {
final Map<Long, Map<Long, List<Object>>> accessionMetadataValues = new HashMap<Long, Map<Long, List<Object>>>();
if (accessions.size() == 0) {
......@@ -167,7 +167,7 @@ public class TraitValueRepositoryImpl implements TraitValueRepository {
}
final Set<Long> accessionIds = new HashSet<Long>(accessions.size());
for (final Accession accession : accessions) {
for (final AccessionData accession : accessions) {
// create lists
accessionMetadataValues.put(accession.getId(), new HashMap<Long, List<Object>>());
accessionIds.add(accession.getId());
......
......@@ -86,11 +86,11 @@ public interface GenesysService {
List<Method> listMethods(Metadata metadata);
Page<Accession> listMetadataAccessions(long metadataId, Pageable pageable);
Page<AccessionData> listMetadataAccessions(long metadataId, Pageable pageable);
Map<Long, List<ExperimentTrait>> getAccessionTraitValues(AccessionId accession);
Map<Long, Map<Long, List<Object>>> getMetadataTraitValues(Metadata metadata, List<Accession> content);
Map<Long, Map<Long, List<Object>>> getMetadataTraitValues(Metadata metadata, List<AccessionData> list);
Page<Accession> listAccessions(Collection<Long> accessionIds, Pageable pageable);
......
......@@ -135,7 +135,7 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
@Autowired
private AccessionRepository accessionRepository;
@Autowired
private AccessionHistoricRepository accessionHistoricRepository;
private AccessionHistoricRepository accessionHistoricRepository;
@Autowired
private AccessionIdRepository accessionIdRepository;
......@@ -563,8 +563,28 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
}
@Override
public Page<Accession> listMetadataAccessions(long metadataId, Pageable pageable) {
return accessionTraitRepository.listMetadataAccessions(metadataId, pageable);
public Page<AccessionData> listMetadataAccessions(long metadataId, Pageable pageable) {
Page<AccessionId> x = accessionTraitRepository.listMetadataAccessions(metadataId, pageable);
List<AccessionData> content = listAccessionData(x.getContent());
return new PageImpl<AccessionData>(content, pageable, x.getTotalElements());
}
private List<AccessionData> listAccessionData(List<AccessionId> accessionIds) {
List<AccessionData> result = new ArrayList<AccessionData>(accessionIds.size());
for (AccessionId accessionId : accessionIds) {
result.add(getAccessionData(accessionId));
}
return result;
}
private AccessionData getAccessionData(AccessionId accessionId) {
if (accessionId == null)
return null;
Accession a = accessionRepository.findOne(accessionId.getId());
if (a != null)
return a;
AccessionHistoric ah = accessionHistoricRepository.findOne(accessionId.getId());
return ah;
}
@Override
......@@ -575,7 +595,7 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
}
@Override
public Map<Long, Map<Long, List<Object>>> getMetadataTraitValues(Metadata metadata, List<Accession> accessions) {
public Map<Long, Map<Long, List<Object>>> getMetadataTraitValues(Metadata metadata, List<AccessionData> accessions) {
final List<Method> methods = methodRepository.findByIds(metadataMethodRepository.listMetadataMethods(metadata));
return traitValueRepository.getValues(metadata, methods, accessions);
}
......@@ -733,15 +753,15 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
AccessionHistoric hist = new AccessionHistoric();
SelfCopy.copy(accession, hist);
hist.setAccessionId(accessionIdRepository.findOne(accession.getId()));
// hist.setId(hist.getAccessionId().getId());
// hist.setId(hist.getAccessionId().getId());
deleted.add(hist);
}
LOG.info("Done deleting, now adding");
accessionHistoricRepository.save(deleted);
// for (Accession a : toDelete) {
// accessionRepository.deleteActive(a.getAccessionId().getId());
// }
// for (Accession a : toDelete) {
// accessionRepository.deleteActive(a.getAccessionId().getId());
// }
}
return deleted;
......
......@@ -21,7 +21,7 @@ import java.io.OutputStream;
import javax.servlet.http.HttpServletResponse;
import org.genesys2.server.model.genesys.Accession;
import org.genesys2.server.model.genesys.AccessionData;
import org.genesys2.server.model.genesys.Metadata;
import org.genesys2.server.model.impl.FaoInstitute;
import org.genesys2.server.service.DatasetService;
......@@ -78,7 +78,7 @@ public class DatasetController extends BaseController {
final FaoInstitute faoInstitute = instituteService.findInstitute(metadata.getInstituteCode());
model.addAttribute("faoInstitute", faoInstitute);
final Page<Accession> accessions = genesysService.listMetadataAccessions(metadata.getId(), new PageRequest(page - 1, 50));
final Page<AccessionData> accessions = genesysService.listMetadataAccessions(metadata.getId(), new PageRequest(page - 1, 50));
model.addAttribute("pagedData", accessions);
// Map[accession.id][method.id]
......
......@@ -113,7 +113,7 @@
<td><a href="<c:url value="/acn/id/${accession.id}" />"><b><c:out value="${accession.accessionName}" /></b></a></td>
<%-- <td><a href="<c:url value="/geo/${accession.origin}" />"><c:out value="${accession.countryOfOrigin.getName(pageContext.response.locale)}" /></a></td>
--%>
<td><c:out value="${accession.taxonomy.taxonName}" /></td>
<td><span dir="ltr" class="sci-name"><c:out value="${accession.taxonomy.taxonName}" /></span></td>
<%-- <td><a href="<c:url value="/wiews/${accession.institute.code}" />"><c:out value="${accession.institute.code}" /></a></td>
<td><a href="<c:url value="/geo/${accession.institute.country.code3}" />"><c:out value="${accession.institute.country.getName(pageContext.response.locale)}" /></a></td>
--%>
......
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