Skip to content

Commit 966ed50

Browse files
committed
Fixes for RESTWS-980 (Plugin, ConditionResource, etc.)
1 parent 8cbf3f1 commit 966ed50

File tree

5 files changed

+255
-283
lines changed

5 files changed

+255
-283
lines changed

omod-2.4/pom.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,24 @@
9797
<header>${project.parent.basedir}/license-header.txt</header>
9898
</configuration>
9999
</plugin>
100+
<plugin>
101+
<groupId>org.openmrs.plugin</groupId>
102+
<artifactId>openapi-generator-maven-plugin</artifactId>
103+
<version>1.0.0-SNAPSHOT</version>
104+
<configuration>
105+
<scanPackages>
106+
<scanPackage>org.openmrs.module.webservices.rest.web.v1_0.resource</scanPackage>
107+
</scanPackages>
108+
</configuration>
109+
<executions>
110+
<execution>
111+
<phase>process-classes</phase>
112+
<goals>
113+
<goal>openapi</goal>
114+
</goals>
115+
</execution>
116+
</executions>
117+
</plugin>
100118
</plugins>
101119
</build>
102120
</project>

omod-2.4/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_2/ConditionResource2_2.java

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,14 @@
4242
"2.2.* - 9.*" })
4343
public class ConditionResource2_2 extends DataDelegatingCrudResource<Condition> {
4444

45-
private ConditionService conditionService = Context.getConditionService();
45+
private ConditionService conditionService;
46+
47+
private ConditionService getConditionService() {
48+
if (conditionService == null) {
49+
conditionService = Context.getConditionService();
50+
}
51+
return conditionService;
52+
}
4653

4754
/**
4855
* @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#getRepresentationDescription(Representation)
@@ -180,7 +187,7 @@ public DelegatingResourceDescription getUpdatableProperties() {
180187
*/
181188
@Override
182189
public Condition getByUniqueId(String uuid) {
183-
return conditionService.getConditionByUuid(uuid);
190+
return getConditionService().getConditionByUuid(uuid);
184191
}
185192

186193
/**
@@ -189,7 +196,7 @@ public Condition getByUniqueId(String uuid) {
189196
*/
190197
@Override
191198
protected void delete(Condition condition, String reason, RequestContext requestContext) throws ResponseException {
192-
conditionService.voidCondition(condition, reason);
199+
getConditionService().voidCondition(condition, reason);
193200
}
194201

195202
/**
@@ -205,7 +212,7 @@ public Condition newDelegate() {
205212
*/
206213
@Override
207214
public Condition save(Condition condition) {
208-
return conditionService.saveCondition(condition);
215+
return getConditionService().saveCondition(condition);
209216
}
210217

211218
/**
@@ -214,7 +221,7 @@ public Condition save(Condition condition) {
214221
*/
215222
@Override
216223
public void purge(Condition condition, RequestContext requestContext) throws ResponseException {
217-
conditionService.purgeCondition(condition);
224+
getConditionService().purgeCondition(condition);
218225
}
219226

220227
/**
@@ -237,7 +244,6 @@ public String getDisplayString(Condition condition) {
237244
protected PageableResult doSearch(RequestContext context) {
238245
String patientUuid = context.getRequest().getParameter("patientUuid");
239246
String includeInactive = context.getRequest().getParameter("includeInactive");
240-
ConditionService conditionService = Context.getConditionService();
241247
if (StringUtils.isBlank(patientUuid)) {
242248
return new EmptySearchResult();
243249
}
@@ -249,13 +255,13 @@ protected PageableResult doSearch(RequestContext context) {
249255
if (StringUtils.isNotBlank(includeInactive)) {
250256
boolean isIncludeInactive = BooleanUtils.toBoolean(includeInactive);
251257
if (isIncludeInactive) {
252-
return new NeedsPaging<Condition>(conditionService.getAllConditions(patient), context);
258+
return new NeedsPaging<Condition>(getConditionService().getAllConditions(patient), context);
253259
} else {
254-
return new NeedsPaging<Condition>(conditionService.getActiveConditions(patient), context);
260+
return new NeedsPaging<Condition>(getConditionService().getActiveConditions(patient), context);
255261
}
256262
}
257263
else {
258-
return new NeedsPaging<Condition>(conditionService.getActiveConditions(patient), context);
264+
return new NeedsPaging<Condition>(getConditionService().getActiveConditions(patient), context);
259265
}
260266
}
261267
}

omod/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@
8282
<plugin>
8383
<groupId>org.apache.maven.plugins</groupId>
8484
<artifactId>maven-dependency-plugin</artifactId>
85-
<executions> <execution>
85+
<executions>
86+
<execution>
8687
<id>Expand resources</id>
8788
<goals>
8889
<goal>unpack-dependencies</goal>

tools/openapi-generator-maven-plugin/README.md

Lines changed: 0 additions & 68 deletions
This file was deleted.

0 commit comments

Comments
 (0)