-
Notifications
You must be signed in to change notification settings - Fork 521
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RESTWS-939: DiagnosisResource should support formFieldPath property (#…
…609)
- Loading branch information
1 parent
5564667
commit 96a8cb0
Showing
8 changed files
with
447 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,215 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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> | ||
<parent> | ||
<groupId>org.openmrs.module</groupId> | ||
<artifactId>webservices.rest</artifactId> | ||
<version>2.45.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>webservices.rest-omod-2.5</artifactId> | ||
<packaging>jar</packaging> | ||
<name>Rest Web Services 2.5 OMOD</name> | ||
<description>OpenMRS module project for Rest Web Services</description> | ||
|
||
<properties> | ||
<openmrs.version.2.5.0>2.5.0</openmrs.version.2.5.0> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>${project.parent.groupId}</groupId> | ||
<artifactId>${project.parent.artifactId}-omod-common</artifactId> | ||
<version>${project.parent.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>${project.parent.groupId}</groupId> | ||
<artifactId>${project.parent.artifactId}-omod-common</artifactId> | ||
<version>${project.parent.version}</version> | ||
<classifier>tests</classifier> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>${project.parent.groupId}</groupId> | ||
<artifactId>${project.parent.artifactId}-omod-1.8</artifactId> | ||
<version>${project.parent.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>${project.parent.groupId}</groupId> | ||
<artifactId>${project.parent.artifactId}-omod-1.8</artifactId> | ||
<version>${project.parent.version}</version> | ||
<classifier>tests</classifier> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>${project.parent.groupId}</groupId> | ||
<artifactId>${project.parent.artifactId}-omod-1.9</artifactId> | ||
<version>${project.parent.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>${project.parent.groupId}</groupId> | ||
<artifactId>${project.parent.artifactId}-omod-1.9</artifactId> | ||
<version>${project.parent.version}</version> | ||
<classifier>tests</classifier> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>${project.parent.groupId}</groupId> | ||
<artifactId>${project.parent.artifactId}-omod-1.10</artifactId> | ||
<version>${project.parent.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>${project.parent.groupId}</groupId> | ||
<artifactId>${project.parent.artifactId}-omod-1.10</artifactId> | ||
<version>${project.parent.version}</version> | ||
<classifier>tests</classifier> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>${project.parent.groupId}</groupId> | ||
<artifactId>${project.parent.artifactId}-omod-1.11</artifactId> | ||
<version>${project.parent.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>${project.parent.groupId}</groupId> | ||
<artifactId>${project.parent.artifactId}-omod-1.11</artifactId> | ||
<version>${project.parent.version}</version> | ||
<classifier>tests</classifier> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>${project.parent.groupId}</groupId> | ||
<artifactId>${project.parent.artifactId}-omod-2.0</artifactId> | ||
<version>${project.parent.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>${project.parent.groupId}</groupId> | ||
<artifactId>${project.parent.artifactId}-omod-2.0</artifactId> | ||
<version>${project.parent.version}</version> | ||
<classifier>tests</classifier> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>${project.parent.groupId}</groupId> | ||
<artifactId>${project.parent.artifactId}-omod-2.2</artifactId> | ||
<version>${project.parent.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>${project.parent.groupId}</groupId> | ||
<artifactId>${project.parent.artifactId}-omod-2.2</artifactId> | ||
<version>${project.parent.version}</version> | ||
<classifier>tests</classifier> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>${project.parent.groupId}</groupId> | ||
<artifactId>${project.parent.artifactId}-omod-2.3</artifactId> | ||
<version>${project.parent.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>${project.parent.groupId}</groupId> | ||
<artifactId>${project.parent.artifactId}-omod-2.3</artifactId> | ||
<version>${project.parent.version}</version> | ||
<classifier>tests</classifier> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>${project.parent.groupId}</groupId> | ||
<artifactId>${project.parent.artifactId}-omod-2.4</artifactId> | ||
<version>${project.parent.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>${project.parent.groupId}</groupId> | ||
<artifactId>${project.parent.artifactId}-omod-2.4</artifactId> | ||
<version>${project.parent.version}</version> | ||
<classifier>tests</classifier> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.openmrs.api</groupId> | ||
<artifactId>openmrs-api</artifactId> | ||
<version>${openmrs.version.2.5.0}</version><!--$NO-MVN-MAN-VER$--> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.openmrs.api</groupId> | ||
<artifactId>openmrs-api</artifactId> | ||
<type>test-jar</type> | ||
<scope>test</scope> | ||
<version>${openmrs.version.2.5.0}</version><!--$NO-MVN-MAN-VER$--> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.openmrs.web</groupId> | ||
<artifactId>openmrs-web</artifactId> | ||
<version>${openmrs.version.2.5.0}</version> <!-- $NO-MVN-MAN-VER$ --> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.openmrs.web</groupId> | ||
<artifactId>openmrs-web</artifactId> | ||
<type>test-jar</type> | ||
<scope>test</scope> | ||
<version>${openmrs.version.2.5.0}</version> <!-- $NO-MVN-MAN-VER$--> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.openmrs.test</groupId> | ||
<artifactId>openmrs-test</artifactId> | ||
<type>pom</type> | ||
<scope>test</scope> | ||
<version>${openmrs.version.2.5.0}</version> <!-- $NO-MVN-MAN-VER$ --> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>javax.servlet</groupId> | ||
<artifactId>javax.servlet-api</artifactId> | ||
<version>${javaxVersion}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.tomcat</groupId> | ||
<artifactId>jasper</artifactId> | ||
<version>${apacheTomcatVersion}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.jacoco</groupId> | ||
<artifactId>jacoco-maven-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>com.mycila</groupId> | ||
<artifactId>license-maven-plugin</artifactId> | ||
<configuration> | ||
<header>${project.parent.basedir}/license-header.txt</header> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
92 changes: 92 additions & 0 deletions
92
...rg/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_5/DiagnosisResource2_5.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/** | ||
* This Source Code Form is subject to the terms of the Mozilla Public License, | ||
* v. 2.0. If a copy of the MPL was not distributed with this file, You can | ||
* obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under | ||
* the terms of the Healthcare Disclaimer located at http://openmrs.org/license. | ||
* | ||
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS | ||
* graphic logo is a trademark of OpenMRS Inc. | ||
*/ | ||
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs2_5; | ||
|
||
import io.swagger.models.Model; | ||
import io.swagger.models.ModelImpl; | ||
import io.swagger.models.properties.StringProperty; | ||
import org.openmrs.Diagnosis; | ||
import org.openmrs.module.webservices.rest.web.RestConstants; | ||
import org.openmrs.module.webservices.rest.web.annotation.Resource; | ||
import org.openmrs.module.webservices.rest.web.representation.DefaultRepresentation; | ||
import org.openmrs.module.webservices.rest.web.representation.FullRepresentation; | ||
import org.openmrs.module.webservices.rest.web.representation.Representation; | ||
import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource; | ||
import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource; | ||
import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription; | ||
import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException; | ||
import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs2_2.DiagnosisResource2_2; | ||
|
||
/** | ||
* {@link Resource} for Diagnosis, supporting standard CRUD operations | ||
*/ | ||
@Resource(name = RestConstants.VERSION_1 + "/patientdiagnoses", order = 1, supportedClass = Diagnosis.class, supportedOpenmrsVersions = { | ||
"2.5.* - 9.*" }) | ||
public class DiagnosisResource2_5 extends DiagnosisResource2_2 { | ||
|
||
/** | ||
* @see DelegatingCrudResource#getRepresentationDescription(Representation) | ||
*/ | ||
@Override | ||
public DelegatingResourceDescription getRepresentationDescription(Representation rep) { | ||
DelegatingResourceDescription description = super.getRepresentationDescription(rep); | ||
if (description != null) { | ||
description.addProperty("formFieldNamespace"); | ||
description.addProperty("formFieldPath"); | ||
} | ||
return description; | ||
} | ||
|
||
/** | ||
* @see BaseDelegatingResource#getCreatableProperties() | ||
*/ | ||
@Override | ||
public DelegatingResourceDescription getCreatableProperties() { | ||
DelegatingResourceDescription description = super.getCreatableProperties(); | ||
description.addProperty("formFieldNamespace"); | ||
description.addProperty("formFieldPath"); | ||
return description; | ||
} | ||
|
||
/** | ||
* @see BaseDelegatingResource#getUpdatableProperties() | ||
*/ | ||
@Override | ||
public DelegatingResourceDescription getUpdatableProperties() throws ResourceDoesNotSupportOperationException { | ||
DelegatingResourceDescription description = super.getUpdatableProperties(); | ||
description.addProperty("formFieldNamespace"); | ||
description.addProperty("formFieldPath"); | ||
return description; | ||
} | ||
|
||
@Override | ||
public Model getGETModel(Representation rep) { | ||
return addNewProperties(super.getGETModel(rep), rep); | ||
} | ||
|
||
@Override | ||
public Model getCREATEModel(Representation rep) { | ||
return addNewProperties(super.getCREATEModel(rep), rep); | ||
} | ||
|
||
@Override | ||
public Model getUPDATEModel(Representation rep) { | ||
return addNewProperties(super.getUPDATEModel(rep), rep); | ||
} | ||
|
||
private Model addNewProperties(Model model, Representation rep) { | ||
if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) { | ||
((ModelImpl) model) | ||
.property("formFieldNamespace", new StringProperty()) | ||
.property("formFieldPath", new StringProperty()); | ||
} | ||
return model; | ||
} | ||
} |
Oops, something went wrong.