Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(fix) RESTWS-908 Diagnosis resource should return formNamespace and formPath on core 2.5+ #577

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
10 changes: 5 additions & 5 deletions omod-2.5/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -148,37 +148,37 @@
<dependency>
<groupId>org.openmrs.api</groupId>
<artifactId>openmrs-api</artifactId>
<version>${openmrs.version.2.5.0}</version><!--$NO-MVN-MAN-VER$-->
<version>${openmrs.version.2.5.0}</version>
</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$-->
<version>${openmrs.version.2.5.0}</version>
</dependency>

<dependency>
<groupId>org.openmrs.web</groupId>
<artifactId>openmrs-web</artifactId>
<version>${openmrs.version.2.5.0}</version> <!-- $NO-MVN-MAN-VER$ -->
<version>${openmrs.version.2.5.0}</version>
</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$-->
<version>${openmrs.version.2.5.0}</version>
</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$ -->
<version>${openmrs.version.2.5.0}</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,81 +12,72 @@
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.*" })
@Resource(name = RestConstants.VERSION_1
+ "/patientdiagnoses", supportedClass = Diagnosis.class, supportedOpenmrsVersions = { "2.5.* - 9.*" })
public class DiagnosisResource2_5 extends DiagnosisResource2_2 {

/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#getRepresentationDescription(org.openmrs.module.webservices.rest.web.representation.Representation)
*/
@Override
public DelegatingResourceDescription getRepresentationDescription(Representation representation) {
if (representation instanceof DefaultRepresentation) {
DelegatingResourceDescription description = super.getRepresentationDescription(representation);
description.addProperty("formNamespaceAndPath");

return description;

} else if (representation instanceof FullRepresentation) {
DelegatingResourceDescription description = super.getRepresentationDescription(representation);
description.addProperty("formNamespaceAndPath");

return description;
}

return null;
}

/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getCreatableProperties()
*/
@Override
public DelegatingResourceDescription getCreatableProperties() throws ResourceDoesNotSupportOperationException {
DelegatingResourceDescription description = super.getCreatableProperties();

description.addRequiredProperty("formNamespaceAndPath");

return description;

}

/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getUpdatableProperties()
*/
@Override
public DelegatingResourceDescription getUpdatableProperties() throws ResourceDoesNotSupportOperationException {
DelegatingResourceDescription description = super.getUpdatableProperties();

description.addRequiredProperty("formNamespaceAndPath");

return description;
}

/**
* @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;
}
}
28 changes: 14 additions & 14 deletions pom.xml
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?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/maven-v4_0_0.xsd">
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.openmrs.module</groupId>
Expand Down Expand Up @@ -132,7 +133,7 @@
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>


</dependencies>

Expand Down Expand Up @@ -221,14 +222,14 @@
<useReleaseProfile>false</useReleaseProfile>
<autoVersionSubmodules>true</autoVersionSubmodules>
<arguments>-Prelease</arguments>
<tagNameFormat>@{project.version}</tagNameFormat>
<tagNameFormat>@{project.version}</tagNameFormat>
</configuration>
</plugin>

<plugin>
<groupId>com.googlecode.maven-java-formatter-plugin</groupId>
<artifactId>maven-java-formatter-plugin</artifactId>
<version>0.4</version>
<version>0.4</version>
<configuration>
<compilerSource>${java.version}</compilerSource>
<compilerCompliance>${java.version}</compilerCompliance>
Expand Down Expand Up @@ -388,12 +389,12 @@
<artifactId>license-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<configuration>
<argLine>@{argLine} -Djdk.net.URLClassPath.disableClassPathURLCheck=true</argLine>
</configuration>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<configuration>
<argLine>@{argLine} -Djdk.net.URLClassPath.disableClassPathURLCheck=true</argLine>
</configuration>
</plugin>
</plugins>
</build>
Expand Down Expand Up @@ -542,8 +543,8 @@
<goal>jar</goal>
</goals>
<configuration>
<failOnError>false</failOnError>
</configuration>
<failOnError>false</failOnError>
</configuration>
</execution>
</executions>
</plugin>
Expand All @@ -552,7 +553,7 @@
</profile>

</profiles>
<repositories>
<repositories>
<repository>
<id>openmrs-repo</id>
<name>OpenMRS Nexus Repository</name>
Expand All @@ -570,5 +571,4 @@
</snapshots>
</pluginRepository>
</pluginRepositories>

</project>
Loading