Skip to content

Commit 3c322d8

Browse files
alex-odysseuswiverngitfedor_glushchenkooleg-odysseus
authored
Packaging/publication services and analysis execution results data providers for Shiny applications (#2399)
--------- Co-authored-by: wivern <[email protected]> Co-authored-by: git <[email protected]> Co-authored-by: fedor_glushchenko <[email protected]> Co-authored-by: oleg-odysseus <[email protected]>
1 parent c256508 commit 3c322d8

File tree

54 files changed

+3062
-51
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+3062
-51
lines changed

pom.xml

+114
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,9 @@
303303
<audit.trail.log.file>/tmp/atlas/audit/audit.log</audit.trail.log.file>
304304
<audit.trail.log.file.pattern>/tmp/atlas/audit/audit-%d{yyyy-MM-dd}-%i.log</audit.trail.log.file.pattern>
305305
<audit.trail.log.extraFile>/tmp/atlas/audit/audit-extra.log</audit.trail.log.extraFile>
306+
307+
<!-- Shiny -->
308+
<shiny.enabled>false</shiny.enabled>
306309
</properties>
307310

308311
<build>
@@ -1257,6 +1260,15 @@
12571260
<version>2.0.1</version>
12581261
<scope>test</scope>
12591262
</dependency>
1263+
<dependency>
1264+
<groupId>com.squareup.okhttp3</groupId>
1265+
<artifactId>okhttp</artifactId>
1266+
<version>4.12.0</version>
1267+
</dependency>
1268+
<dependency>
1269+
<groupId>com.fasterxml.jackson.datatype</groupId>
1270+
<artifactId>jackson-datatype-jsr310</artifactId>
1271+
</dependency>
12601272
</dependencies>
12611273

12621274
<profiles>
@@ -1910,5 +1922,107 @@
19101922
</dependency>
19111923
</dependencies>
19121924
</profile>
1925+
<profile>
1926+
<id>webapi-shiny</id>
1927+
<properties>
1928+
<shiny.enabled>true</shiny.enabled>
1929+
<shiny.atlas.url>http://localhost/Atlas</shiny.atlas.url>
1930+
<shiny.output.directory>src/main/resources/shiny</shiny.output.directory>
1931+
<shiny.app.directory></shiny.app.directory>
1932+
<spring.profiles.active>default,shiny</spring.profiles.active>
1933+
</properties>
1934+
<build>
1935+
<plugins>
1936+
<plugin>
1937+
<groupId>org.apache.maven.plugins</groupId>
1938+
<artifactId>maven-clean-plugin</artifactId>
1939+
<version>3.3.2</version>
1940+
<configuration>
1941+
<filesets>
1942+
<fileset>
1943+
<directory>${shiny.output.directory}</directory>
1944+
<includes>
1945+
<include>shiny-cohortCounts.zip</include>
1946+
<include>shiny-incidenceRates.zip</include>
1947+
<include>shiny-cohortCharacterizations.zip</include>
1948+
</includes>
1949+
</fileset>
1950+
</filesets>
1951+
</configuration>
1952+
</plugin>
1953+
<plugin>
1954+
<groupId>org.apache.maven.plugins</groupId>
1955+
<artifactId>maven-assembly-plugin</artifactId>
1956+
<version>3.6.0</version>
1957+
<executions>
1958+
<execution>
1959+
<id>build-cohortCounts-archive</id>
1960+
<goals>
1961+
<goal>single</goal>
1962+
</goals>
1963+
<phase>generate-resources</phase>
1964+
<configuration>
1965+
<appendAssemblyId>false</appendAssemblyId>
1966+
<archiveBaseDirectory>${shiny.app.directory}</archiveBaseDirectory>
1967+
<outputDirectory>${shiny.output.directory}</outputDirectory>
1968+
<descriptors>
1969+
<descriptor>src/main/assembly/shiny-cohortCounts.xml</descriptor>
1970+
</descriptors>
1971+
<finalName>shiny-cohortCounts</finalName>
1972+
</configuration>
1973+
</execution>
1974+
<execution>
1975+
<id>build-incidenceRates-archive</id>
1976+
<goals>
1977+
<goal>single</goal>
1978+
</goals>
1979+
<phase>generate-resources</phase>
1980+
<configuration>
1981+
<appendAssemblyId>false</appendAssemblyId>
1982+
<archiveBaseDirectory>${shiny.app.directory}</archiveBaseDirectory>
1983+
<outputDirectory>${shiny.output.directory}</outputDirectory>
1984+
<descriptors>
1985+
<descriptor>src/main/assembly/shiny-incidenceRates.xml</descriptor>
1986+
</descriptors>
1987+
<finalName>shiny-incidenceRates</finalName>
1988+
</configuration>
1989+
</execution>
1990+
<execution>
1991+
<id>build-cohortCharacterizations-archive</id>
1992+
<goals>
1993+
<goal>single</goal>
1994+
</goals>
1995+
<phase>generate-resources</phase>
1996+
<configuration>
1997+
<appendAssemblyId>false</appendAssemblyId>
1998+
<archiveBaseDirectory>${shiny.app.directory}</archiveBaseDirectory>
1999+
<outputDirectory>${shiny.output.directory}</outputDirectory>
2000+
<descriptors>
2001+
<descriptor>src/main/assembly/shiny-cohortCharacterizations.xml</descriptor>
2002+
</descriptors>
2003+
<finalName>shiny-cohortCharacterizations</finalName>
2004+
</configuration>
2005+
</execution>
2006+
<execution>
2007+
<id>build-cohortPathways-archive</id>
2008+
<goals>
2009+
<goal>single</goal>
2010+
</goals>
2011+
<phase>generate-resources</phase>
2012+
<configuration>
2013+
<appendAssemblyId>false</appendAssemblyId>
2014+
<archiveBaseDirectory>${shiny.app.directory}</archiveBaseDirectory>
2015+
<outputDirectory>${shiny.output.directory}</outputDirectory>
2016+
<descriptors>
2017+
<descriptor>src/main/assembly/shiny-cohortPathways.xml</descriptor>
2018+
</descriptors>
2019+
<finalName>shiny-cohortPathways</finalName>
2020+
</configuration>
2021+
</execution>
2022+
</executions>
2023+
</plugin>
2024+
</plugins>
2025+
</build>
2026+
</profile>
19132027
</profiles>
19142028
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.2.0 https://maven.apache.org/xsd/assembly-2.2.0.xsd">
4+
<id>shiny-cohortCharacterizations</id>
5+
<formats>
6+
<format>zip</format>
7+
</formats>
8+
<includeBaseDirectory>false</includeBaseDirectory>
9+
<fileSets>
10+
<fileSet>
11+
<directory>./apps/cohortCharacterization</directory>
12+
<excludes>
13+
<exclude>data/**</exclude>
14+
</excludes>
15+
<outputDirectory>/</outputDirectory>
16+
</fileSet>
17+
</fileSets>
18+
</assembly>
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.2.0 https://maven.apache.org/xsd/assembly-2.2.0.xsd">
4+
<id>shiny-cohortCounts</id>
5+
<formats>
6+
<format>zip</format>
7+
</formats>
8+
<includeBaseDirectory>false</includeBaseDirectory>
9+
<fileSets>
10+
<fileSet>
11+
<directory>./apps/cohortCounts</directory>
12+
<excludes>
13+
<exclude>data/**</exclude>
14+
</excludes>
15+
<outputDirectory>/</outputDirectory>
16+
</fileSet>
17+
</fileSets>
18+
</assembly>
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.2.0 https://maven.apache.org/xsd/assembly-2.2.0.xsd">
4+
<id>shiny-incidenceRates</id>
5+
<formats>
6+
<format>zip</format>
7+
</formats>
8+
<includeBaseDirectory>false</includeBaseDirectory>
9+
<fileSets>
10+
<fileSet>
11+
<directory>./apps/cohortPathways</directory>
12+
<excludes>
13+
<exclude>data/**</exclude>
14+
</excludes>
15+
<outputDirectory>/</outputDirectory>
16+
</fileSet>
17+
</fileSets>
18+
</assembly>
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.2.0 https://maven.apache.org/xsd/assembly-2.2.0.xsd">
4+
<id>shiny-incidenceRates</id>
5+
<formats>
6+
<format>zip</format>
7+
</formats>
8+
<includeBaseDirectory>false</includeBaseDirectory>
9+
<fileSets>
10+
<fileSet>
11+
<directory>./apps/IncidenceRate</directory>
12+
<excludes>
13+
<exclude>data/**</exclude>
14+
</excludes>
15+
<outputDirectory>/</outputDirectory>
16+
</fileSet>
17+
</fileSets>
18+
</assembly>

src/main/java/org/ohdsi/webapi/Constants.java

+4
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,13 @@ interface Variables {
9090
}
9191

9292
interface Headers {
93+
String ACCESS_CONTROL_EXPOSE_HEADERS = "Access-Control-Expose-Headers";
9394
String AUTH_PROVIDER = "x-auth-provider";
9495
String USER_LANGAUGE = "User-Language";
9596
String ACTION_LOCATION = "action-location";
97+
String BEARER = "Bearer";
98+
String X_AUTH_ERROR = "x-auth-error";
99+
String CONTENT_DISPOSITION = "Content-Disposition";
96100
}
97101

98102
interface SecurityProviders {

src/main/java/org/ohdsi/webapi/JerseyConfig.java

+6
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.ohdsi.webapi.service.TherapyPathResultsService;
3131
import org.ohdsi.webapi.service.UserService;
3232
import org.ohdsi.webapi.service.VocabularyService;
33+
import org.ohdsi.webapi.shiny.ShinyController;
3334
import org.ohdsi.webapi.source.SourceController;
3435
import org.springframework.beans.factory.InitializingBean;
3536
import org.springframework.beans.factory.annotation.Value;
@@ -47,6 +48,8 @@ public class JerseyConfig extends ResourceConfig implements InitializingBean {
4748

4849
@Value("${jersey.resources.root.package}")
4950
private String rootPackage;
51+
@Value("${shiny.enabled:false}")
52+
private Boolean shinyEnabled;
5053

5154
public JerseyConfig() {
5255
RuntimeDelegate.setInstance(new org.glassfish.jersey.internal.RuntimeDelegateImpl());
@@ -94,5 +97,8 @@ protected void configure() {
9497
.in(Singleton.class);
9598
}
9699
});
100+
if (shinyEnabled) {
101+
register(ShinyController.class);
102+
}
97103
}
98104
}

src/main/java/org/ohdsi/webapi/pathway/PathwayController.java

+1-32
Original file line numberDiff line numberDiff line change
@@ -431,38 +431,7 @@ public String getGenerationDesign(
431431
public PathwayPopulationResultsDTO getGenerationResults(
432432
@PathParam("generationId") final Long generationId
433433
) {
434-
435-
PathwayAnalysisResult resultingPathways = pathwayService.getResultingPathways(generationId);
436-
437-
List<PathwayCodeDTO> eventCodeDtos = resultingPathways.getCodes()
438-
.stream()
439-
.map(entry -> {
440-
PathwayCodeDTO dto = new PathwayCodeDTO();
441-
dto.setCode(entry.getCode());
442-
dto.setName(entry.getName());
443-
dto.setIsCombo(entry.isCombo());
444-
return dto;
445-
})
446-
.collect(Collectors.toList());
447-
448-
List<TargetCohortPathwaysDTO> pathwayDtos = resultingPathways.getCohortPathwaysList()
449-
.stream()
450-
.map(cohortResults -> {
451-
if (cohortResults.getPathwaysCounts() == null) {
452-
return null;
453-
}
454-
455-
List<PathwayPopulationEventDTO> eventDTOs = cohortResults.getPathwaysCounts()
456-
.entrySet()
457-
.stream()
458-
.map(entry -> new PathwayPopulationEventDTO(entry.getKey(), entry.getValue()))
459-
.collect(Collectors.toList());
460-
return new TargetCohortPathwaysDTO(cohortResults.getCohortId(), cohortResults.getTargetCohortCount(), cohortResults.getTotalPathwaysCount(), eventDTOs);
461-
})
462-
.filter(Objects::nonNull)
463-
.collect(Collectors.toList());
464-
465-
return new PathwayPopulationResultsDTO(eventCodeDtos, pathwayDtos);
434+
return pathwayService.getGenerationResults(generationId);
466435
}
467436

468437
private PathwayAnalysisDTO reloadAndConvert(Integer id) {

src/main/java/org/ohdsi/webapi/pathway/PathwayService.java

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import org.ohdsi.webapi.pathway.domain.PathwayAnalysisEntity;
55
import org.ohdsi.webapi.pathway.domain.PathwayAnalysisGenerationEntity;
66
import org.ohdsi.webapi.pathway.dto.PathwayAnalysisDTO;
7+
import org.ohdsi.webapi.pathway.dto.PathwayPopulationResultsDTO;
78
import org.ohdsi.webapi.pathway.dto.PathwayVersionFullDTO;
89
import org.ohdsi.webapi.pathway.dto.internal.PathwayAnalysisResult;
910
import org.ohdsi.webapi.shiro.annotations.PathwayAnalysisGenerationId;
@@ -69,4 +70,8 @@ public interface PathwayService extends HasTags<Integer> {
6970
PathwayVersion saveVersion(int id);
7071

7172
List<PathwayAnalysisDTO> listByTags(TagNameListRequestDTO requestDTO);
73+
74+
PathwayAnalysisDTO getByGenerationId(Integer id);
75+
76+
PathwayPopulationResultsDTO getGenerationResults(Long generationId);
7277
}

0 commit comments

Comments
 (0)