Skip to content
Draft
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions omod-2.4/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,24 @@
<header>${project.parent.basedir}/license-header.txt</header>
</configuration>
</plugin>
<plugin>
<groupId>org.openmrs.plugin</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>1.0.0-SNAPSHOT</version>
<configuration>
<scanPackages>
<scanPackage>org.openmrs.module.webservices.rest.web.v1_0.resource</scanPackage>
</scanPackages>
</configuration>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>openapi</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,14 @@
"2.2.* - 9.*" })
public class ConditionResource2_2 extends DataDelegatingCrudResource<Condition> {

private ConditionService conditionService = Context.getConditionService();
private ConditionService conditionService;

private ConditionService getConditionService() {
if (conditionService == null) {
conditionService = Context.getConditionService();
}
return conditionService;
}

/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#getRepresentationDescription(Representation)
Expand Down Expand Up @@ -180,7 +187,7 @@ public DelegatingResourceDescription getUpdatableProperties() {
*/
@Override
public Condition getByUniqueId(String uuid) {
return conditionService.getConditionByUuid(uuid);
return getConditionService().getConditionByUuid(uuid);
}

/**
Expand All @@ -189,7 +196,7 @@ public Condition getByUniqueId(String uuid) {
*/
@Override
protected void delete(Condition condition, String reason, RequestContext requestContext) throws ResponseException {
conditionService.voidCondition(condition, reason);
getConditionService().voidCondition(condition, reason);
}

/**
Expand All @@ -205,7 +212,7 @@ public Condition newDelegate() {
*/
@Override
public Condition save(Condition condition) {
return conditionService.saveCondition(condition);
return getConditionService().saveCondition(condition);
}

/**
Expand All @@ -214,7 +221,7 @@ public Condition save(Condition condition) {
*/
@Override
public void purge(Condition condition, RequestContext requestContext) throws ResponseException {
conditionService.purgeCondition(condition);
getConditionService().purgeCondition(condition);
}

/**
Expand All @@ -237,7 +244,6 @@ public String getDisplayString(Condition condition) {
protected PageableResult doSearch(RequestContext context) {
String patientUuid = context.getRequest().getParameter("patientUuid");
String includeInactive = context.getRequest().getParameter("includeInactive");
ConditionService conditionService = Context.getConditionService();
if (StringUtils.isBlank(patientUuid)) {
return new EmptySearchResult();
}
Expand All @@ -249,13 +255,13 @@ protected PageableResult doSearch(RequestContext context) {
if (StringUtils.isNotBlank(includeInactive)) {
boolean isIncludeInactive = BooleanUtils.toBoolean(includeInactive);
if (isIncludeInactive) {
return new NeedsPaging<Condition>(conditionService.getAllConditions(patient), context);
return new NeedsPaging<Condition>(getConditionService().getAllConditions(patient), context);
} else {
return new NeedsPaging<Condition>(conditionService.getActiveConditions(patient), context);
return new NeedsPaging<Condition>(getConditionService().getActiveConditions(patient), context);
}
}
else {
return new NeedsPaging<Condition>(conditionService.getActiveConditions(patient), context);
return new NeedsPaging<Condition>(getConditionService().getActiveConditions(patient), context);
}
}
}
6 changes: 3 additions & 3 deletions omod/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<executions>
<execution>
<id>Expand resources</id>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<phase>generate-resources</phase>
<phase>prepare-package</phase>
<configuration>
<includeGroupIds>${project.parent.groupId}</includeGroupIds>
<includeArtifactIds>${project.parent.artifactId}-omod-common</includeArtifactIds>
Expand All @@ -105,7 +105,7 @@
<configuration>
<header>${project.parent.basedir}/license-header.txt</header>
</configuration>
</plugin>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
Expand Down
156 changes: 156 additions & 0 deletions tools/openapi-generator-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <groupId>org.openmrs.plugin</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>maven-plugin</packaging>

<name>OpenAPI Generator Maven Plugin</name>
<description>A Maven plugin for generating OpenAPI specifications for OpenMRS modules.</description>
<url>https://example.com/openapi-generator-maven-plugin</url>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<!-- Maven Plugin API -->
<dependency>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see classLoader.loadClass used quite a bit to load classes from the rest module. Does it make sense to just make it a dependency so we can use those classes directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try this out and get back

<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.8.6</version>
<scope>provided</scope>
</dependency>

<!-- Maven Plugin Annotations -->
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.6.4</version>
<scope>provided</scope>
</dependency>

<!-- Maven Core -->
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>3.8.6</version>
<scope>provided</scope> </dependency>

<!-- JavaParser for extracting Javadoc -->
<dependency>
<groupId>com.github.javaparser</groupId>
<artifactId>javaparser-core</artifactId>
<version>3.25.5</version>
</dependency>

<!-- Swagger dependencies needed by OpenMRS webservices -->
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-core</artifactId>
<version>1.6.2</version>
</dependency>

<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
<version>1.6.2</version>
</dependency>

<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.6.2</version>
</dependency>

<!-- OpenAPI 3.0 dependencies for specification generation -->
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-core</artifactId>
<version>2.2.8</version>
</dependency>

<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-models</artifactId>
<version>2.2.8</version>
</dependency>

<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId>
<version>2.2.8</version>
</dependency>

<!-- JSON processing for OpenAPI output -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.15.2</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
<version>2.15.2</version>
</dependency>

<!-- OpenMRS dependencies needed for runtime reflection -->
<dependency>
<groupId>org.openmrs.api</groupId>
<artifactId>openmrs-api</artifactId>
<version>2.7.0</version>
</dependency>

<dependency>
<groupId>org.openmrs.module</groupId>
<artifactId>webservices.rest-omod-common</artifactId>
<version>2.50.0-SNAPSHOT</version>
</dependency>

<!-- Spring Web - needed by Swagger libraries and OpenMRS REST resources -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.3.30</version>
</dependency>

<!-- Servlet API - needed by Spring Web -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.6.4</version>
<executions>
<execution>
<id>default-descriptor</id>
<phase>process-classes</phase>
<goals>
<goal>descriptor</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Loading
Loading