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
5 changes: 5 additions & 0 deletions pom.xml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@
<module>omod-2.2</module>
<module>omod-2.3</module>
<module>omod-2.4</module>
<module>omod-2.5</module>
<module>omod</module>
<module>integration-tests</module>
</modules>
Expand Down Expand Up @@ -501,6 +502,7 @@
<module>omod-2.2</module>
<module>omod-2.3</module>
<module>omod-2.4</module>
<module>omod-2.5</module>
<module>omod</module>
<module>integration-tests</module>
</modules>
Expand Down Expand Up @@ -569,4 +571,7 @@
</pluginRepository>
</pluginRepositories>

<modules>
<module>webservices.rest-omod-2.5</module>
</modules>
Copy link
Member

Choose a reason for hiding this comment

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

Just use the profiles:

Suggested change
<modules>
<module>webservices.rest-omod-2.5</module>
</modules>

</project>
219 changes: 219 additions & 0 deletions webservices.rest-omod-2.5/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<artifactId>webservices.rest</artifactId>
Copy link
Member

Choose a reason for hiding this comment

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

nit: indentation

Suggested change
<artifactId>webservices.rest</artifactId>
<artifactId>webservices.rest</artifactId>

Copy link
Author

Choose a reason for hiding this comment

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

It seems to be indented correctly locally in my IDE but when i push the changes that specific section is distorted.

<groupId>org.openmrs.module</groupId>
<version>2.40.0-SNAPSHOT</version>
</parent>

<artifactId>webservices.rest-omod-2.5</artifactId>
<name>Rest Web Services 2.5 OMOD</name>

<properties>
<openmrs.version.2.5.0>2.5.0</openmrs.version.2.5.0>
</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.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>${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>org.openmrs.api</groupId>
<artifactId>openmrs-api</artifactId>
<version>${openmrs.version.2.5.0}</version><!--$NO-MVN-MAN-VER$-->
suubi-joshua marked this conversation as resolved.
Show resolved Hide resolved
</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$ -->
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</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>6.0.18</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>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
</project>
</project>

Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/**
* 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 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.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", supportedClass = Diagnosis.class, supportedOpenmrsVersions = { "2.5.* - 9.*" })
public class DiagnosisResource2_5 extends DiagnosisResource2_2 {
Copy link
Member

Choose a reason for hiding this comment

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

We should also have a change to DiagnosisResource2_2 so that it's only supported up to 2.4.*

Copy link
Author

Choose a reason for hiding this comment

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

Should I create another ticket to resolve this?


/**
* @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("formNamespace");
description.addProperty("formPath");
return description;
} else if (representation instanceof FullRepresentation) {
DelegatingResourceDescription description = super.getRepresentationDescription(representation);
description.addProperty("formNamespace");
description.addProperty("formPath");
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("formNamespace");
description.addRequiredProperty("formPath");

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("formNamespace");
description.addRequiredProperty("formPath");

return description;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* 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 org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs2_2.DiagnosisResource2_2;
import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs2_2.DiagnosisResource2_2Test;

/**
* Tests functionality of {@link DiagnosisResource2_2}.
*/
public class DiagnosisResource2_5Test extends DiagnosisResource2_2Test {

@Override
public void validateDefaultRepresentation() throws Exception {
super.validateDefaultRepresentation();
assertPropPresent("formNamespace");
assertPropPresent("formPath");
}

@Override
public void validateFullRepresentation() throws Exception {
super.validateDefaultRepresentation();
assertPropPresent("formNamespace");
assertPropPresent("formPath");
}
}