Commit 45d06255 authored by Andrey Lugovskiy's avatar Andrey Lugovskiy

- added services for clear DOIs

parent d6d38cb5
......@@ -148,4 +148,8 @@ public interface AccessionRepository extends JpaRepository<Accession, Long>, Acc
public List<Object[]> lastUpdatedStatistics(FaoInstitute faoInstitute);
public Accession findByDoi(String doi);
@Query("update Accession accession set accession.doi = null where accession.doi is not null")
@Modifying
void removeDOIs();
}
......@@ -77,6 +77,11 @@ public interface GenesysService {
Accession getAccession(long accessionId);
/**
* Clear DOIs for accessions(set null in DOI field)
*/
void removeDOIs();
Accession getAccessionByDOI(String doi);
List<Accession> listAccessions(FaoInstitute faoInstitute, String accessionName);
......
......@@ -335,6 +335,15 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
return lazyLoadAccession(accession);
}
/**
* {@inheritDoc}
*/
@Transactional
@Override
public void removeDOIs() {
accessionRepository.removeDOIs();
}
@Override
public Accession getAccessionByDOI(final String doi) {
Accession accession = accessionRepository.findByDoi(doi);
......
......@@ -60,6 +60,7 @@ import org.springframework.jdbc.core.RowCallbackHandler;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.xml.sax.SAXException;
......@@ -478,4 +479,11 @@ public class AdminController {
LOG.info("Done assigning crops to accessions with CROPNAME.");
return "redirect:/admin/";
}
@PostMapping(value = "/clear-dois")
public String clearDois(){
LOG.info("Clear DOIs");
genesysService.removeDOIs();
return "redirect:/admin/";
}
}
......@@ -132,5 +132,12 @@
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" />
</form>
<h3>DOI</h3>
<form method="post" action="<c:url value="/admin/clear-dois" />">
<input type="submit" class="btn btn-default" value="Clear DOIs" />
<!-- CSRF protection -->
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" />
</form>
</body>
</html>
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