Skip to content

Commit

Permalink
Merge pull request #5 from EBISPOT/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
tudorgroza authored May 14, 2020
2 parents 116aa44 + cf41ff7 commit 78dd0dc
Show file tree
Hide file tree
Showing 92 changed files with 2,379 additions and 552 deletions.
5 changes: 5 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

docker build --force-rm=true -t gwas-deposition-backend:latest .
docker tag gwas-deposition-backend:latest ebispot/gwas-deposition-backend:latest-sandbox
docker push ebispot/gwas-deposition-backend:latest-sandbox
4 changes: 4 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

kubectl delete deploy gwas-deposition-backend -n gwas
kubectl apply -f /home/tudor/Desktop/_deployment_plans_/gwas-deposition-backend-deployment.yaml
8 changes: 6 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<parent>
<groupId>uk.ac.ebi.spot.gwasdepo</groupId>
<artifactId>gwasdepo-master</artifactId>
<version>1.0.0</version>
<version>1.0.1-SNAPSHOT</version>
</parent>

<properties>
Expand Down Expand Up @@ -66,7 +66,7 @@
<dependency>
<groupId>uk.ac.ebi.spot.gwasdepo</groupId>
<artifactId>gwasdepo-commons</artifactId>
<version>1.0.0</version>
<version>1.0.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>uk.ac.ebi.spot.gwasdepo</groupId>
Expand Down Expand Up @@ -136,6 +136,10 @@
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
</dependency>
<dependency>
<groupId>org.modelmapper</groupId>
<artifactId>modelmapper</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/uk/ac/ebi/spot/gwas/deposition/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import uk.ac.ebi.spot.gwas.deposition.config.SystemConfigProperties;
import uk.ac.ebi.spot.gwas.deposition.constants.GWASDepositionBackendConstants;
import uk.ac.ebi.spot.gwas.deposition.constants.GeneralCommon;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
Expand Down Expand Up @@ -40,7 +39,7 @@ public void destroy() {

public static void main(String[] args) throws UnknownHostException {
String hostAddress = InetAddress.getLocalHost().getHostAddress();
String logFileName = System.getenv(GWASDepositionBackendConstants.LOG_FILE_NAME);
String logFileName = System.getenv(GeneralCommon.LOG_FILE_NAME);
System.setProperty("log.file.name", logFileName + "-" + hostAddress);
SpringApplication.run(Application.class, args);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package uk.ac.ebi.spot.gwas.deposition.components;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import uk.ac.ebi.spot.gwas.deposition.domain.BodyOfWork;
import uk.ac.ebi.spot.gwas.deposition.domain.BodyOfWorkWatch;
import uk.ac.ebi.spot.gwas.deposition.domain.Submission;
import uk.ac.ebi.spot.gwas.deposition.repository.BodyOfWorkWatchRepository;

import java.util.Optional;

@Component
public class BodyOfWorkListener {

@Autowired
private BodyOfWorkWatchRepository bodyOfWorkWatchRepository;

@Async
public void update(BodyOfWork bodyOfWork) {
Optional<BodyOfWorkWatch> bodyOfWorkWatchOptional = bodyOfWorkWatchRepository.findByBowId(bodyOfWork.getBowId());
if (bodyOfWorkWatchOptional.isPresent()) {
BodyOfWorkWatch bodyOfWorkWatch = bodyOfWorkWatchOptional.get();
bodyOfWorkWatch.setVisited(false);
bodyOfWorkWatchRepository.save(bodyOfWorkWatch);
}
}

public void update(Submission submission) {
if (submission.getBodyOfWorks() != null) {
if (!submission.getBodyOfWorks().isEmpty()) {
String bowId = submission.getBodyOfWorks().get(0);
bodyOfWorkWatchRepository.insert(new BodyOfWorkWatch(bowId));
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package uk.ac.ebi.spot.gwas.deposition.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class BackendMailConfig {

@Value("${gwas-deposition.email-config.subject}")
private String subject;

@Value("${gwas-deposition.email-config.emails.success}")
private String successEmail;

@Value("${gwas-deposition.email-config.emails.fail}")
private String failEmail;

@Value("${gwas-deposition.email-config.base-url}")
private String submissionsBaseURL;

public String getSubmissionsBaseURL() {
return submissionsBaseURL;
}

public String getSubject() {
return subject;
}

public String getSuccessEmail() {
return successEmail;
}

public String getFailEmail() {
return failEmail;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ public class BackendQuartzConfig {
@Autowired(required = false)
private SOLRDocumentStatusCheckConfigSandbox solrDocumentStatusCheckConfigSandbox;

@Autowired(required = false)
private CompleteSubmissionsConfig completeSubmissionsConfig;

@PostConstruct
private void initialize() throws SchedulerException {
if (statsConfig != null) {
Expand All @@ -51,6 +54,9 @@ private void initialize() throws SchedulerException {
if (solrDocumentStatusCheckConfigSandbox != null) {
quartzSchedulerJobConfig.addJob(solrDocumentStatusCheckConfigSandbox);
}
if (completeSubmissionsConfig != null) {
quartzSchedulerJobConfig.addJob(completeSubmissionsConfig);
}
quartzSchedulerJobConfig.initializeJobs();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ public ResponseEntity<String> handleSubmissionOnUnacceptedPublicationTypeExcepti
return new ResponseEntity<>(e.getMessage(), headers, HttpStatus.BAD_REQUEST);
}

@ExceptionHandler(InvalidSubmissionTypeException.class)
public ResponseEntity<String> handleInvalidSubmissionTypeExceptionException(InvalidSubmissionTypeException e) {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.TEXT_PLAIN);
return new ResponseEntity<>(e.getMessage(), headers, HttpStatus.BAD_REQUEST);
}

@ExceptionHandler(SSGlobusFolderCreatioException.class)
public ResponseEntity<String> handleSSGlobusFolderCreatioException(SSGlobusFolderCreatioException e) {
HttpHeaders headers = new HttpHeaders();
Expand All @@ -55,6 +62,20 @@ public ResponseEntity<String> handleCannotDeleteSSTemplateFileException(CannotDe
return new ResponseEntity<>(e.getMessage(), headers, HttpStatus.BAD_REQUEST);
}

@ExceptionHandler(CannotDeleteBodyOfWorkException.class)
public ResponseEntity<String> handleCannotDeleteBodyOfWorkException(CannotDeleteBodyOfWorkException e) {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.TEXT_PLAIN);
return new ResponseEntity<>(e.getMessage(), headers, HttpStatus.BAD_REQUEST);
}

@ExceptionHandler(CannotCreateSubmissionOnExistingBodyOfWork.class)
public ResponseEntity<String> handleCannotCreateSubmissionOnExistingBodyOfWork(CannotCreateSubmissionOnExistingBodyOfWork e) {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.TEXT_PLAIN);
return new ResponseEntity<>(e.getMessage(), headers, HttpStatus.BAD_REQUEST);
}

@ExceptionHandler(DeleteOnSubmittedSubmissionNotAllowedException.class)
public ResponseEntity<String> handleDeleteOnSubmittedSubmissionNotAllowedException(DeleteOnSubmittedSubmissionNotAllowedException e) {
HttpHeaders headers = new HttpHeaders();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ public class GWASDepositionBackendConfig {
@Value("${gwas-deposition.proxy-prefix:#{NULL}}")
private String proxyPrefix;

@Value("${gwas-deposition.email-config.base-url}")
private String submissionsBaseURL;
@Value("${gwas-deposition.db:#{NULL}}")
private String dbName;

public String getSubmissionsBaseURL() {
return submissionsBaseURL;
public String getDbName() {
return dbName;
}

public boolean isAuthEnabled() {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.mongodb.MongoClientURI;
import com.mongodb.ServerAddress;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
Expand Down Expand Up @@ -61,9 +60,12 @@ public static class MongoConfigSandbox extends AbstractMongoConfiguration {
@Autowired
private SystemConfigProperties systemConfigProperties;

@Autowired
private GWASDepositionBackendConfig gwasDepositionBackendConfig;

@Override
protected String getDatabaseName() {
return systemConfigProperties.getDbName();
return gwasDepositionBackendConfig.getDbName();
}

@Bean
Expand All @@ -87,9 +89,12 @@ public static class MongoConfigProd extends AbstractMongoConfiguration {
@Autowired
private SystemConfigProperties systemConfigProperties;

@Autowired
private GWASDepositionBackendConfig gwasDepositionBackendConfig;

@Override
protected String getDatabaseName() {
return systemConfigProperties.getDbName();
return gwasDepositionBackendConfig.getDbName();
}

@Bean
Expand All @@ -115,4 +120,45 @@ public MongoClient mongoClient() {
return new MongoClient(new MongoClientURI("mongodb://" + credentials + mongoUri));
}
}

@Configuration
@EnableMongoRepositories(basePackages = {"uk.ac.ebi.spot.gwas.deposition.repository"})
@EnableTransactionManagement
@Profile({"gcp-sandbox"})
public static class MongoConfiGCPSandbox extends AbstractMongoConfiguration {

@Autowired
private SystemConfigProperties systemConfigProperties;

@Autowired
private GWASDepositionBackendConfig gwasDepositionBackendConfig;

@Override
protected String getDatabaseName() {
return gwasDepositionBackendConfig.getDbName();
}

@Bean
public GridFsTemplate gridFsTemplate() throws Exception {
return new GridFsTemplate(mongoDbFactory(), mappingMongoConverter());
}

@Override
public MongoClient mongoClient() {
String mongoUri = systemConfigProperties.getMongoUri();
String dbUser = systemConfigProperties.getDbUser();
String dbPassword = systemConfigProperties.getDbPassword();
String credentials = "";
if (dbUser != null && dbPassword != null) {
dbUser = dbUser.trim();
dbPassword = dbPassword.trim();
if (!dbUser.equalsIgnoreCase("") &&
!dbPassword.equalsIgnoreCase("")) {
credentials = dbUser + ":" + dbPassword + "@";
}
}

return new MongoClient(new MongoClientURI("mongodb+srv://" + credentials + mongoUri));
}
}
}
Loading

0 comments on commit 78dd0dc

Please sign in to comment.