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

Generate missing PDCI from /admin

parent 2df764af
......@@ -28,4 +28,7 @@ public interface AccessionIdRepository extends JpaRepository<AccessionId, Long>
@Query("select aid from AccessionId aid where aid.uuid is null")
List<AccessionId> findMissingUuid(Pageable pageable);
@Query("select aid from AccessionId aid left join aid.pdci pdci where pdci.score is null")
List<AccessionId> findMissingPDCI(Pageable pageable);
}
......@@ -239,4 +239,6 @@ public interface GenesysService {
List<PDCI> loadPDCI(List<Long> batch);
int generateMissingPDCI(int count);
}
......@@ -1560,6 +1560,23 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
public List<PDCI> loadPDCI(List<Long> accessionIds) {
return repoPdci.findByAccessionId(accessionIds);
}
@Override
@Transactional
@CacheEvict(value = "statistics", allEntries = true)
public int generateMissingPDCI(int count) {
List<AccessionId> accessionIds = accessionIdRepository.findMissingPDCI(new PageRequest(0, count));
List<PDCI> pdcis = new ArrayList<PDCI>();
for (AccessionId accessionId : accessionIds) {
PDCI pdci = new PDCI();
pdci.setAccession(accessionId);
pdciCalculator.updatePdci(pdci, accessionId.getId());
pdcis.add(pdci);
}
LOG.info("Generated " + accessionIds.size() + " new PDCIs");
repoPdci.save(pdcis);
return pdcis.size();
}
@Override
@Transactional
......@@ -1590,7 +1607,8 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
accessionIds.add(accessionDetails.getId());
}
}
List<PDCI> pdcis = repoPdci.findByAccessionId(accessionIds);
List<PDCI> pdcis = new ArrayList<PDCI>();
pdcis.addAll(repoPdci.findByAccessionId(accessionIds));
for (AccessionDetails accessionDetails : ads) {
if (accessionDetails==null) {
......@@ -1607,6 +1625,7 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
if (pdci == null) {
pdci = new PDCI();
pdci.setAccession(accessionIdRepository.findOne(accessionDetails.getId()));
pdcis.add(pdci);
}
pdciCalculator.updatePdci(pdci, accessionDetails);
}
......
......@@ -354,10 +354,18 @@ public class AdminController {
}
return "redirect:/admin/";
}
@RequestMapping("/assign-uuid")
@RequestMapping(value = "/assign-uuid", method = RequestMethod.POST)
public String assignUuid() {
while (genesysService.assignMissingUuid(100)>0) {
while (genesysService.assignMissingUuid(100) > 0) {
}
return "redirect:/admin/";
}
@RequestMapping(value = "/pdci", method = RequestMethod.POST)
public String generatePDCI() {
while (genesysService.generateMissingPDCI(100) > 0) {
}
return "redirect:/admin/";
......
......@@ -19,6 +19,11 @@
<!-- CSRF protection -->
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" />
</form>
<form method="post" action="<c:url value="/admin/pdci" />">
<input type="submit" class="btn btn-default" value="Calculate missing PDCI" />
<!-- CSRF protection -->
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" />
</form>
<h3>Full-text Search</h3>
......
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