Skip to content

Commit

Permalink
Release 1.14.0 (#602)
Browse files Browse the repository at this point in the history
  • Loading branch information
wivern authored and pavgra committed May 27, 2019
1 parent 553d863 commit 28791fe
Show file tree
Hide file tree
Showing 25 changed files with 167 additions and 256 deletions.
15 changes: 7 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<artifactId>portal</artifactId>
<groupId>com.odysseusinc.arachne</groupId>
<version>1.13.0</version>
<version>1.14.0</version>
<packaging>jar</packaging>

<parent>
Expand All @@ -25,7 +25,6 @@
<jjwt.version>0.6.0</jjwt.version>
<ehcache.version>1.3.0</ehcache.version>
<postgresql.version>42.2.1</postgresql.version>
<flyway.version>4.2.0</flyway.version>
<gson.version>2.7</gson.version>
<commons.lang3.version>3.5</commons.lang3.version>
<hikaricp.version>2.6.3</hikaricp.version>
Expand Down Expand Up @@ -107,6 +106,11 @@
<groupId>org.apache.solr</groupId>
<version>7.2.1</version>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<version>4.2.0</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down Expand Up @@ -195,11 +199,6 @@
<artifactId>postgresql</artifactId>
<version>${postgresql.version}</version>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<version>${flyway.version}</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
Expand Down Expand Up @@ -320,7 +319,7 @@
<dependency>
<groupId>org.ohdsi.sql</groupId>
<artifactId>SqlRender</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.6.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.cosium.spring.data</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ protected void attachIncidenceRatesFiles(List<MultipartFile> files) throws IOExc


@Override
protected void attachCohortCharacterizationFiles(List<MultipartFile> files) throws IOException, URISyntaxException {
protected void attachCohortHeraclesFiles(List<MultipartFile> files) throws IOException, URISyntaxException {

files.add(new MockMultipartFile(RUN_CC_REPORTS_FILE_NAME, RUN_CC_REPORTS_FILE_NAME, null,
readResource("r/" + RUN_CC_REPORTS_FILE_NAME)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import static org.springframework.web.bind.annotation.RequestMethod.POST;
import static org.springframework.web.bind.annotation.RequestMethod.PUT;

import com.google.common.collect.ImmutableMap;
import com.odysseusinc.arachne.commons.api.v1.dto.CommonAnalysisType;
import com.odysseusinc.arachne.commons.api.v1.dto.CommonEntityRequestDTO;
import com.odysseusinc.arachne.commons.api.v1.dto.OptionDTO;
Expand Down Expand Up @@ -146,6 +145,7 @@ public abstract class BaseAnalysisController<T extends Analysis,
= "'%s' with guid='%s' from DataNode with id='%d' is not available";
private static final String DEFAULT_EXTENSION = ".txt";
private static final String DEFAULT_MIMETYPE = "plain/text";
private static final String HYDRATED_ANALYSIS_RUNNER = "runAnalysis.R";
protected final BaseDataSourceService dataSourceService;
protected final BaseDataNodeService dataNodeService;
protected final BaseAnalysisService<T> analysisService;
Expand Down Expand Up @@ -699,21 +699,24 @@ protected List<MultipartFile> getEntityFiles(DataReferenceDTO entityReference, D
}
List<MultipartFile> files = new LinkedList<>();
final List<ImportedFile> importedFiles = (List<ImportedFile>) responseMessage.getObject();
if (entityType.equals(CommonAnalysisType.ESTIMATION)) {
boolean hasAnalysisRunner = hasAnalysisRunner(importedFiles);
if (entityType.equals(CommonAnalysisType.ESTIMATION) && !hasAnalysisRunner) {
files.addAll(importService.processEstimation(importedFiles));
} else {
files = importedFiles.stream()
.map(file -> conversionService.convert(file, MockMultipartFile.class))
.collect(Collectors.toList());
}
if (entityType.equals(CommonAnalysisType.PREDICTION)) {
attachPredictionFiles(files);
}
if (entityType.equals(CommonAnalysisType.COHORT_CHARACTERIZATION)) {
attachCohortCharacterizationFiles(files);
}
if (entityType.equals(CommonAnalysisType.INCIDENCE)) {
attachIncidenceRatesFiles(files);
if (!hasAnalysisRunner) {
if (entityType.equals(CommonAnalysisType.PREDICTION)) {
attachPredictionFiles(files);
}
if (entityType.equals(CommonAnalysisType.COHORT_HERACLES)) {
attachCohortHeraclesFiles(files);
}
if (entityType.equals(CommonAnalysisType.INCIDENCE)) {
attachIncidenceRatesFiles(files);
}
}
return files;
}
Expand All @@ -732,8 +735,13 @@ protected void afterCreate(T analysis, A_C_DTO analysisDTO) {

}

protected boolean hasAnalysisRunner(List<ImportedFile> files) {

return files.stream().anyMatch(file -> file.getOriginalFilename().equalsIgnoreCase(HYDRATED_ANALYSIS_RUNNER));
}

protected abstract void attachPredictionFiles(List<MultipartFile> files) throws IOException;

protected abstract void attachCohortCharacterizationFiles(List<MultipartFile> files) throws IOException, URISyntaxException;
protected abstract void attachCohortHeraclesFiles(List<MultipartFile> files) throws IOException, URISyntaxException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public BaseDataNodeCommonAnalysisController(BaseDataNodeService<DN> baseDataNode
analysisTypeMap.put("estimations", CommonAnalysisType.ESTIMATION);
analysisTypeMap.put("predictions", CommonAnalysisType.PREDICTION);
analysisTypeMap.put("incidence-rates", CommonAnalysisType.INCIDENCE);
analysisTypeMap.put("cohort-characterizations", CommonAnalysisType.COHORT_CHARACTERIZATION);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,17 @@ public JsonResult<List<StateProvinceDTO>> suggestStateProvince(
return result;
}

@ApiOperation("List DataNode users")
@RequestMapping(value = "/api/v1/user-management/datanodes/{dataNodeId}/users", method = GET)
public List<CommonUserDTO> listDataNodeUsers(@PathVariable("dataNodeId") Long dataNodeId) {

final DN dataNode = baseDataNodeService.getById(dataNodeId);
List<DataNodeUser> users = baseDataNodeService.listOwners(dataNode);
return users.stream()
.map(user -> conversionService.convert(user.getUser(), CommonUserDTO.class))
.collect(Collectors.toList());
}

@ApiOperation("Link U to DataNode")
@RequestMapping(value = "/api/v1/user-management/datanodes/{datanodeSid}/users", method = POST)
public JsonResult linkUserToDataNode(@PathVariable("datanodeSid") Long datanodeId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,19 @@
import com.odysseusinc.arachne.portal.exception.WrongFileFormatException;
import com.odysseusinc.arachne.portal.security.LoginRequestContext;
import java.io.IOException;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.function.Consumer;
import javax.servlet.http.Cookie;
import java.util.Collection;
import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.ConstraintViolationException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.DataAccessException;
Expand All @@ -78,6 +82,8 @@ public class ExceptionHandlingController extends BaseController {

private static final String ERROR_MESSAGE = "An error has occurred. Please contact system administrator";

private final Map<Class<? extends Throwable>, Method> exceptionHandlersMap = new HashMap<>();

private static final Consumer<HttpServletResponse> ADD_COOKIE_FUNCTION = response -> {

if (Objects.nonNull(LoginRequestContext.getUserName())) {
Expand All @@ -94,6 +100,19 @@ public ExceptionHandlingController(NoHandlerFoundExceptionUtils noHandlerFoundEx
this.noHandlerFoundExceptionUtils = noHandlerFoundExceptionUtils;
}

@PostConstruct
public void mapExceptionHandlers() {

Method[] methods = ExceptionHandlingController.class.getDeclaredMethods();
for(Method method : methods) {
if (method.isAnnotationPresent(ExceptionHandler.class)) {
ExceptionHandler annotation = method.getAnnotation(ExceptionHandler.class);
Arrays.stream(annotation.value())
.forEach(clz -> exceptionHandlersMap.put(clz, method));
}
}
}

@ExceptionHandler(Exception.class)
public ResponseEntity<JsonResult> exceptionHandler(Exception ex) {

Expand All @@ -103,6 +122,21 @@ public ResponseEntity<JsonResult> exceptionHandler(Exception ex) {
return new ResponseEntity<>(result, HttpStatus.OK);
}

@ExceptionHandler(RuntimeException.class)
public ResponseEntity<JsonResult> exceptionHandler(HttpServletRequest req, HttpServletResponse res, RuntimeException ex) throws Exception {

if (Objects.isNull(ex.getCause())) {
handleNotFoundError(req, res);
return null;
}
Method method = exceptionHandlersMap.get(ex.getCause().getClass());
if (Objects.nonNull(method)) {
return (ResponseEntity<JsonResult>) method.invoke(this, ex.getCause());
} else {
return exceptionHandler((Exception) ex.getCause());
}
}

@ExceptionHandler(ValidationException.class)
public ResponseEntity<JsonResult> exceptionHandler(ValidationException ex) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
package com.odysseusinc.arachne.portal.api.v1.dto.converters.study;

import com.odysseusinc.arachne.portal.api.v1.dto.ParticipantDTO;
import com.odysseusinc.arachne.portal.api.v1.dto.PermissionsDTO;
import com.odysseusinc.arachne.portal.api.v1.dto.StudyDTO;
import com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyStatusDTO;
import com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyTypeDTO;
Expand All @@ -33,6 +32,10 @@
import com.odysseusinc.arachne.portal.service.BaseStudyService;
import com.odysseusinc.arachne.portal.service.analysis.AnalysisService;
import com.odysseusinc.arachne.portal.util.ArachneConverterUtils;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;

public abstract class BaseStudyToStudyDTOConverter<S extends Study, DTO extends StudyDTO> extends BaseStudyToCommonStudyDTOConverter<S, DTO> {
Expand All @@ -48,7 +51,11 @@ public DTO convert(final S source) {

final DTO studyDTO = super.convert(source);
final Tenant studyTenant = source.getTenant();
for (final UserStudyExtended studyUserLink : source.getParticipants()) {
List<UserStudyExtended> sourceParticipants = new ArrayList<>(source.getParticipants());
Comparator<UserStudyExtended> comparator = Comparator.comparing(p -> p.getStatus().ordinal());
sourceParticipants.sort(comparator.thenComparing((p1, p2) -> StringUtils.compare(p1.getUser().getFullName(), p2.getUser().getFullName())));

for (final UserStudyExtended studyUserLink : sourceParticipants) {
final ParticipantDTO participantDTO = conversionService.convert(studyUserLink, ParticipantDTO.class);
if (!studyUserLink.getUser().getTenants().contains(studyTenant)) {
participantDTO.setCanBeRecreated(Boolean.FALSE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

package com.odysseusinc.arachne.portal.config;

import com.odysseusinc.arachne.portal.config.flyway.ApplicationContextAwareSpringJdbcMigrationResolver;
import com.odysseusinc.arachne.commons.config.flyway.ApplicationContextAwareSpringJdbcMigrationResolver;
import org.flywaydb.core.Flyway;
import org.springframework.boot.autoconfigure.flyway.FlywayMigrationInitializer;
import org.springframework.context.annotation.Bean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
import org.springframework.http.HttpMethod;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
Expand All @@ -73,7 +72,6 @@

@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

private static final Logger log = LoggerFactory.getLogger(WebSecurityConfig.class);
Expand Down Expand Up @@ -273,7 +271,6 @@ protected void configure(HttpSecurity http) throws Exception {
.antMatchers("/api/v1/auth/method**").permitAll()
.antMatchers("/api/v1/user-management/activation/**").permitAll()
.antMatchers("/api/v1/data-sources/dbms-types").permitAll()
.antMatchers("/api/v1/user-management/datanodes/**").hasRole(Roles.ROLE_DATA_NODE)
.antMatchers("/api/v1/user-management/professional-types**").permitAll()
.antMatchers("/api/v1/user-management/countries/**").permitAll()
.antMatchers("/api/v1/user-management/state-province/**").permitAll()
Expand Down

This file was deleted.

Loading

0 comments on commit 28791fe

Please sign in to comment.