Skip to content

Commit

Permalink
Merge branch '2.x-dev' into 2.x-stable
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhayhurst committed Dec 18, 2020
2 parents 6163c5a + d325a93 commit f5d7e9e
Show file tree
Hide file tree
Showing 16 changed files with 366 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package uk.ac.ebi.spot.goci.model.deposition;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import org.joda.time.DateTime;
import org.joda.time.LocalDate;

@Data
Expand All @@ -22,6 +20,8 @@ public class Submission {
private String correspondingAuthor;

private SubmissionType submissionType;
private ImportStatus importStatus;

public enum SubmissionType {
METADATA("Metadata"),
METADATA_AND_SUM_STATS("Metadata and Summary Stats"),
Expand All @@ -31,9 +31,20 @@ public enum SubmissionType {
PRE_PUBLISHED("Pre-Publication"),
UNKNOWN("Unknown");
public final String label;
private SubmissionType(String label){

private SubmissionType(String label) {
this.label = label;
}
};
}

public enum ImportStatus {
READY("Ready"),
NOT_READY("Not ready");

public final String label;

private ImportStatus(String label) {
this.label = label;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package uk.ac.ebi.spot.goci.curation.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import uk.ac.ebi.spot.goci.curation.service.deposition.DepositionSubmissionService;
import uk.ac.ebi.spot.goci.curation.service.deposition.SubmissionImportProgressService;
import uk.ac.ebi.spot.goci.model.deposition.Submission;

import java.util.List;
import java.util.Map;

@Controller
public class SplitSubmissionController {

private final DepositionSubmissionService submissionService;

private final SubmissionImportProgressService submissionImportProgressService;

private Logger log = LoggerFactory.getLogger(getClass());

protected Logger getLog() {
return log;
}

@Value("${deposition.ingest.uri}")
private String depositionIngestURL;

public SplitSubmissionController(@Autowired DepositionSubmissionService submissionService,
SubmissionImportProgressService submissionImportProgressService) {
this.submissionService = submissionService;
this.submissionImportProgressService = submissionImportProgressService;
}

@RequestMapping(value = "/imported_submissions", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET)
public String importedSubmissionsPage(Model model) {
Map<String, Submission> submissionList = submissionService.getSubmissionsByStatus("CURATION_COMPLETE");
model.addAttribute("submissions", submissionList.values());
return "view_submissions";
}

@RequestMapping(value = "/in_progress_submissions", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET)
public String inProgressSubmissionsPage(Model model) {
List<String> submissionIds = submissionImportProgressService.getSubmissions();
Map<String, Submission> submissionList = submissionService.getSubmissionsById(submissionIds);
model.addAttribute("submissions", submissionList.values());
return "view_submissions";
}

@RequestMapping(value = "/failed_submissions", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET)
public String failedSubmissionsPage(Model model) {
Map<String, Submission> submissionList = submissionService.getSubmissionsByStatus("IMPORT_FAILED");
model.addAttribute("submissions", submissionList.values());
return "view_submissions";
}

@RequestMapping(value = "/other_submissions", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET)
public String otherSubmissionsPage(Model model) {
Map<String, Submission> submissionList = submissionService.getOtherSubmissions();
model.addAttribute("submissions", submissionList.values());
return "view_submissions";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public SubmissionController(@Autowired DepositionSubmissionService submissionSer

@RequestMapping(produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET)
public String allSubmissionsPage(Model model) {
Map<String, Submission> submissionList = submissionService.getSubmissions();
Map<String, Submission> submissionList = submissionService.getReadyToImportSubmissions();
model.addAttribute("submissions", submissionList.values());
return "view_submissions";
}
Expand All @@ -94,7 +94,8 @@ public String viewSubmission(Model model, @PathVariable String submissionId) {
private Submission buildSubmission(DepositionSubmission depositionSubmission) {
Submission testSub = new Submission();
testSub.setId(depositionSubmission.getSubmissionId());
if (depositionSubmission.getPublication() != null) {
testSub.setImportStatus(Submission.ImportStatus.NOT_READY);
if (depositionSubmission.getPublication() != null) {
testSub.setPubMedID(depositionSubmission.getPublication().getPmid());
testSub.setAuthor(depositionSubmission.getPublication().getFirstAuthor());
testSub.setCurator(depositionSubmission.getCreated().getUser().getName());
Expand Down Expand Up @@ -148,6 +149,11 @@ private Submission buildSubmission(DepositionSubmission depositionSubmission) {
if (importInProgress) {
testSub.setStatus("IMPORT_IN_PROGRESS");
}
if (testSub.getStatus().equalsIgnoreCase("SUBMITTED") &&
!testSub.getSubmissionType().equals(Submission.SubmissionType.PRE_PUBLISHED) &&
!testSub.getSubmissionType().equals(Submission.SubmissionType.UNKNOWN)) {
testSub.setImportStatus(Submission.ImportStatus.READY);
}
return testSub;
}

Expand All @@ -164,11 +170,11 @@ public String importSubmission(@PathVariable String submissionID, Model model, H

boolean importInProgress = submissionImportProgressService.importInProgress(depositionSubmission.getSubmissionId());
if (importInProgress) {
statusMessages = Arrays.asList(new String []{ "Import is already in progress. Please wait."});
statusMessages = Arrays.asList(new String[]{"Import is already in progress. Please wait."});
} else {
SubmissionImportProgress submissionImportProgress = submissionImportProgressService.createNewImport(currentUser.getEmail(), depositionSubmission.getSubmissionId());
depositionSubmissionImportService.importSubmission(depositionSubmission, currentUser, submissionImportProgress.getId());
statusMessages = Arrays.asList(new String []{ "Import task has been submitted. You will receive an email when it's done."});
statusMessages = Arrays.asList(new String[]{"Import task has been submitted. You will receive an email when it's done."});
}

model.addAttribute("submissions", submissionList.values());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,29 @@ public Map<String, Submission> getSubmissions() {
return getSubmissions(url);
}

public Map<String, Submission> getSubmissionsByStatus(String status) {
String url = "/submissions?status=" + status;
return getSubmissions(url);
}

public Map<String, Submission> getReadyToImportSubmissions() {
String url = "/submissions?status=READY_TO_IMPORT";
return getSubmissions(url);
}

public Map<String, Submission> getOtherSubmissions() {
String url = "/submissions?status=OTHER";
return getSubmissions(url);
}

public Map<String, Submission> getSubmissionsById(List<String> submissionIds) {
Map<String, Submission> submissionList = new TreeMap<>();
for (String sId : submissionIds) {
submissionList.put(sId, buildSubmission(getSubmission(sId)));
}
return submissionList;
}

private Map<String, Submission> getSubmissions(String url) {

Map<String, Submission> submissionList = new TreeMap<>();
Expand Down Expand Up @@ -115,6 +138,7 @@ public Submission buildSubmission(DepositionSubmission depositionSubmission) {
testSub.setCurator(depositionSubmission.getCreated().getUser().getName());
testSub.setStatus(depositionSubmission.getStatus());
testSub.setCreated(depositionSubmission.getCreated().getTimestamp().toString(DateTimeFormat.shortDateTime()));
testSub.setImportStatus(Submission.ImportStatus.NOT_READY);
testSub.setSubmissionType(DepositionUtil.getSubmissionType(depositionSubmission));
if (depositionSubmission.getBodyOfWork() != null) {
BodyOfWorkDto bodyOfWork = depositionSubmission.getBodyOfWork();
Expand Down Expand Up @@ -150,6 +174,11 @@ public Submission buildSubmission(DepositionSubmission depositionSubmission) {
if (importInProgress) {
testSub.setStatus("IMPORT_IN_PROGRESS");
}
if (testSub.getStatus().equalsIgnoreCase("SUBMITTED") &&
!testSub.getSubmissionType().equals(Submission.SubmissionType.PRE_PUBLISHED) &&
!testSub.getSubmissionType().equals(Submission.SubmissionType.UNKNOWN)) {
testSub.setImportStatus(Submission.ImportStatus.READY);
}
return testSub;
}

Expand Down Expand Up @@ -192,4 +221,5 @@ public String checkSubmissionErrors(DepositionSubmission submission) {
}
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
import uk.ac.ebi.spot.goci.model.deposition.SubmissionImportProgress;
import uk.ac.ebi.spot.goci.repository.SubmissionImportProgressRepository;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.Optional;

@Service
Expand Down Expand Up @@ -39,4 +41,13 @@ public void deleteImport(Long id) {
log.info("Removing id: {}", id);
submissionImportProgressRepository.delete(id);
}

public List<String> getSubmissions() {
List<SubmissionImportProgress> submissionImportProgresses = submissionImportProgressRepository.findAll();
List<String> ids = new ArrayList<>();
for (SubmissionImportProgress submissionImportProgress : submissionImportProgresses) {
ids.add(submissionImportProgress.getSubmissionId());
}
return ids;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
xmlns="http://www.w3.org/1999/xhtml">

<body th:fragment="tabs">
<div class="container-fluid">
<div class="row">
<ul class="nav nav-tabs">
<li><a th:href="@{/submissions}">Ready to import</a></li>
<li><a th:href="@{/in_progress_submissions}">In progress</a></li>
<li><a th:href="@{/failed_submissions}">Import failed</a></li>
<li><a th:href="@{/imported_submissions}">Imported</a></li>
<li><a th:href="@{/other_submissions}">Other</a></li>
</ul>

</div>
</div>
<br/>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
th:object="${submission}">
<button id="importButton" type="submit" class="btn btn-sm col-sm-1"
th:classappend="${submission.submissionType.toString().equals('UNKNOWN')} ? 'btn-warning' : 'btn-primary'"
th:disabled="${!submission.status.equals('SUBMITTED')}"
th:disabled="${!submission.importStatus.toString().equals('READY')}"
th:text="${submission.submissionType.toString().equals('IMPORT_IN_PROGRESS')} ? Processing : Import"></button>
</form>
<button class="btn btn-sm btn-primary col-sm-1" id="toggleSubmission">Show/Hide Submission</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@
<!--Include header-->
<div th:include="fragments/header :: navbar"></div>

<div class="container-fluid">
<div style="float: right"><h4><a th:href="@{{baseURL}/submissions(baseURL=${@environment.getProperty('deposition.ui.uri')})}" target="_blank">View Submissions in the Deposition App</a></h4>
</div>
</div>

<!--Include study navigation tabs-->
<div th:include="fragments/submission_navigation_tabs :: tabs"></div>

<div class="container-fluid">
<div class="container-fluid" th:if="${!#strings.isEmpty(result)}">
<div class="row">
Expand All @@ -51,10 +59,11 @@
</div>
</div>
</div>
<!--
<div><h4>
<a th:href="@{{baseURL}/submissions(baseURL=${@environment.getProperty('deposition.ui.uri')})}" target="_blank">View
All Submissions</a></h4>
<a th:href="@{{baseURL}/submissions(baseURL=${@environment.getProperty('deposition.ui.uri')})}" target="_blank">View Submissions in the Deposition App</a></h4>
</div>
-->
<div class="row">
<div class="col-md-12">
<table id="submissionDataTable" class="table table-striped table-bordered" cellspacing="0" width="100%">
Expand Down
Loading

0 comments on commit f5d7e9e

Please sign in to comment.