Skip to content
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
90bfbe1
RESTWS-920 Create API endpoint for OrderAttribute and OrderAttributeType
slubwama Sep 8, 2023
51e9927
removing unnecessary tests and files
slubwama Sep 10, 2023
fabd6ac
Changing logging approach in OrderAttributeResource2_5Test
slubwama Sep 10, 2023
9f74240
adding OrderAttributeController2_5Test and OrderAttributeTypeControll…
slubwama Sep 11, 2023
9d87b93
Changing order to include order attribute
slubwama Sep 22, 2023
5f1756a
changing test to focus on creation of order with attribute
slubwama Mar 3, 2024
48a8078
Merge branch 'master' of github.com:openmrs/openmrs-module-webservice…
slubwama Mar 4, 2024
e77fb1a
change version in omod-2.5 to match other module poms
slubwama Mar 4, 2024
540c59f
Merge branch 'master' of github.com:openmrs/openmrs-module-webservice…
slubwama Jun 12, 2024
6cd7ba0
change version to 2.44.0-SNAPSHOT
slubwama Jun 12, 2024
8bb76d2
change Dispensing Date order_attribute_type uuid to c0de4f5c-6626-4…
slubwama Jun 12, 2024
67b90a2
make changes to test data
slubwama Jun 13, 2024
c0e5447
response to comments
slubwama Jun 13, 2024
949c59f
response to comments
slubwama Jul 20, 2024
611ec39
Merge branch 'master' of github.com:openmrs/openmrs-module-webservice…
slubwama Jul 20, 2024
14a16a4
change to snapshot 2.45.0-SNAPSHOT
slubwama Jul 20, 2024
ceff5c5
add override for shouldGetAll() to one that throws an exception.
slubwama Sep 20, 2024
a1f0521
Merge branch 'master' of github.com:openmrs/openmrs-module-webservice…
slubwama Sep 20, 2024
8ef2d27
clean pom
slubwama Sep 20, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription;
import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_10.OrderResource1_10;

@Resource(name = RestConstants.VERSION_1 + "/order", supportedClass = Order.class, supportedOpenmrsVersions = { "2.2.* - 9.*" })
@Resource(name = RestConstants.VERSION_1 + "/order", supportedClass = Order.class, supportedOpenmrsVersions = { "2.2.* - 2.4.*" })
public class OrderResource2_2 extends OrderResource1_10 {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class ServerLogResource2_4Test extends BaseModuleWebContextSensitiveTest
private final MockServerLogActionWrapper<ServerLogActionWrapper2_4> mockServerLogActionWrapper = new MockServerLogActionWrapper<>(
new ServerLogActionWrapper2_4());


@Autowired
RestService restService;

Expand Down
191 changes: 191 additions & 0 deletions omod-2.5/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
<?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">
<parent>
<artifactId>webservices.rest</artifactId>
<groupId>org.openmrs.module</groupId>
<version>2.44.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<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>
<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>
Copy link
Member

Choose a reason for hiding this comment

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

Remove this 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$-->
</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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
/**
* 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.BooleanProperty;
import io.swagger.models.properties.StringProperty;
import org.apache.commons.lang.StringUtils;
import org.openmrs.attribute.Attribute;
import org.openmrs.customdatatype.CustomDatatype;
import org.openmrs.customdatatype.CustomDatatypeUtil;
import org.openmrs.customdatatype.NotYetPersistedException;
import org.openmrs.module.webservices.rest.web.RestConstants;
import org.openmrs.module.webservices.rest.web.annotation.PropertyGetter;
import org.openmrs.module.webservices.rest.web.annotation.PropertySetter;
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.DelegatingCrudResource;
import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription;
import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingSubResource;

import java.util.Arrays;
import java.util.List;

/**
* Subclass of {@link DelegatingSubResource} with helper methods specific to {@link Attribute}
*
* @param <T> The type of the attribute this sub resource is associated to
* @param <P> The parent/owning type for the type T
* @param <PR> The Resource for the parent/owning type P
*/
public abstract class BaseAttributeCrudResource2_5<T extends Attribute<?, ?>, P, PR> extends DelegatingSubResource<T, P, DelegatingCrudResource<P>> {
Copy link
Member

Choose a reason for hiding this comment

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

Why doesn't this just extend BaseAttributeCrudResource1_9?

Copy link
Member

Choose a reason for hiding this comment

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

It's also not entirely clear to me what this is adding to that class...


/**
* Sets value on the given attribute.
*
* @param instance
* @param value
*/
@PropertySetter("value")
public static void setValue(Attribute<?, ?> instance, String value) throws Exception {
CustomDatatype<?> datatype = CustomDatatypeUtil.getDatatype(instance.getAttributeType().getDatatypeClassname(),
instance.getAttributeType().getDatatypeConfig());
if (StringUtils.isNotEmpty(value)) // check empty instead of blank, because " " is meaningful
instance.setValue(datatype.fromReferenceString(value));
}

/**
* Gets an attribute value, catching any {@link NotYetPersistedException} and returning null in
* that case
*
* @param instance
* @return
*/
@PropertyGetter("value")
public static Object getValue(Attribute<?, ?> instance) {
try {
return instance.getValue();
}
catch (NotYetPersistedException ex) {
return null;
}
}

/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getRepresentationDescription(Representation)
*/
@Override
public DelegatingResourceDescription getRepresentationDescription(Representation rep) {
if (rep instanceof DefaultRepresentation) {
DelegatingResourceDescription description = new DelegatingResourceDescription();
description.addProperty("display");
description.addProperty("uuid");
description.addProperty("attributeType", Representation.REF);
description.addProperty("value");
description.addProperty("voided");
description.addSelfLink();
description.addLink("full", ".?v=" + RestConstants.REPRESENTATION_FULL);
return description;
} else if (rep instanceof FullRepresentation) {
DelegatingResourceDescription description = new DelegatingResourceDescription();
description.addProperty("display");
description.addProperty("uuid");
description.addProperty("attributeType", Representation.REF);
description.addProperty("value");
description.addProperty("voided");
description.addProperty("auditInfo");
description.addSelfLink();
return description;
}
return null;
}

@Override
public DelegatingResourceDescription getCreatableProperties() {
DelegatingResourceDescription description = new DelegatingResourceDescription();
description.addRequiredProperty("attributeType");
description.addRequiredProperty("value");
return description;
}

@Override
public Model getCREATEModel(Representation rep) {
return new ModelImpl()
.property("attributeType", new StringProperty().example("uuid"))
.property("value", new StringProperty())

.required("attributeType").required("value");
}

@Override
public Model getGETModel(Representation rep) {
ModelImpl model = (ModelImpl) super.getGETModel(rep);
if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
model
.property("display", new StringProperty())
.property("uuid", new StringProperty())
.property("attributeType", new StringProperty()) //FIXME type
.property("value", new StringProperty()) //FIXME type
.property("voided", new BooleanProperty());
}
return model;
}

/**
* Gets the display string for an attribute.
*
* @param attr the attribute.
* @return attribute type: value (for concise display purposes)
*/
@PropertyGetter("display")
public String getDisplayString(T attr) {
if (attr.getAttributeType() == null)
return "";
return attr.getAttributeType().getName() + ": " + attr.getValue();
}

/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getResourceVersion()
*/
@Override
public String getResourceVersion() {
return RestConstants2_5.RESOURCE_VERSION;
}

/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getPropertiesToExposeAsSubResources()
*/
@Override
public List<String> getPropertiesToExposeAsSubResources() {
return Arrays.asList("attributes");
}
}
Loading