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

RESTWS-920: Endpoint for OrderAttribute and OrderAttributeType. #587

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 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 @@ -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
219 changes: 219 additions & 0 deletions 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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>webservices.rest</artifactId>
<groupId>org.openmrs.module</groupId>
<version>2.41.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.8</artifactId>
<version>${project.parent.version}</version>
</dependency>

<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}-omod-1.8</artifactId>
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

<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>
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

<version>${project.parent.version}</version>
</dependency>

<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}-omod-1.9</artifactId>
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

<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$-->
</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,137 @@
/**
* 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.Order;
import org.openmrs.OrderType;
import org.openmrs.OrderAttribute;
import org.openmrs.OrderAttributeType;
import org.openmrs.api.context.Context;
import org.openmrs.api.OrderContext;
import org.openmrs.module.webservices.rest.web.RequestContext;
import org.openmrs.module.webservices.rest.web.annotation.PropertySetter;
import org.openmrs.module.webservices.rest.web.annotation.Resource;
import org.openmrs.module.webservices.rest.web.annotation.SubResource;
import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging;
import org.openmrs.module.webservices.rest.web.response.ResponseException;
import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.BaseAttributeCrudResource1_9;
import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs2_2.OrderResource2_2;

import java.util.List;

/**
* {@link Resource} for OrderAttributes, supporting standard CRUD operations
*/
@SubResource(parent = OrderResource2_2.class, path = "attribute", supportedClass = OrderAttribute.class, supportedOpenmrsVersions = {
"2.5.* - 9.*"})
public class OrderAttributeResource2_5 extends BaseAttributeCrudResource1_9<OrderAttribute, Order, OrderResource2_2> {

/**
* Sets attributeType on the given OrderAttribute.
*
* @param instance
* @param attr
*/
@PropertySetter("attributeType")
public static void setAttributeType(OrderAttribute instance, OrderAttributeType attr) {
instance.setAttributeType(attr);
}

/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingSubResource#getParent(java.lang.Object)
*/
@Override
public Order getParent(OrderAttribute instance) {
return instance.getOrder();
}

/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#newDelegate()
*/
@Override
public OrderAttribute newDelegate() {
return new OrderAttribute();
}

/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingSubResource#setParent(java.lang.Object,
* java.lang.Object)
*/
@Override
public void setParent(OrderAttribute instance, Order order) {
instance.setOrder(order);
}

/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getByUniqueId(java.lang.String)
*/
@Override
public OrderAttribute getByUniqueId(String uniqueId) {
return Context.getOrderService().getOrderAttributeByUuid(uniqueId);
}

/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingSubResource#doGetAll(java.lang.Object,
* org.openmrs.module.webservices.rest.web.RequestContext)
*/
@Override
public NeedsPaging<OrderAttribute> doGetAll(Order parent, RequestContext context) throws ResponseException {
return new NeedsPaging<OrderAttribute>((List<OrderAttribute>) parent.getActiveAttributes(), context);
}

/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceHandler#save(java.lang.Object)
*/
@Override
public OrderAttribute save(OrderAttribute delegate) {
// make sure it has not already been added to the order
boolean needToAdd = true;
for (OrderAttribute pa : delegate.getOrder().getActiveAttributes()) {
if (pa.equals(delegate)) {
needToAdd = false;
break;
}
}
if (needToAdd) {
delegate.getOrder().addAttribute(delegate);
}
OrderContext orderContext = new OrderContext();
orderContext.setCareSetting(delegate.getOrder().getCareSetting());
orderContext.setOrderType(delegate.getOrder().getOrderType());
ibacher marked this conversation as resolved.
Show resolved Hide resolved

Context.getOrderService().saveOrder(delegate.getOrder(), orderContext);
return delegate;
}

/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#delete(java.lang.Object,
* java.lang.String, org.openmrs.module.webservices.rest.web.RequestContext)
*/
@Override
protected void delete(OrderAttribute delegate, String reason, RequestContext context) throws ResponseException {
delegate.setVoided(true);
delegate.setVoidReason(reason);

OrderContext orderContext = new OrderContext();
orderContext.setCareSetting(delegate.getOrder().getCareSetting());
orderContext.setOrderType(delegate.getOrder().getOrderType());

Context.getOrderService().saveOrder(delegate.getOrder(),orderContext);
}

/**
* @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#purge(java.lang.Object,
* org.openmrs.module.webservices.rest.web.RequestContext)
*/
@Override
public void purge(OrderAttribute delegate, RequestContext context) throws ResponseException {
throw new UnsupportedOperationException("Cannot purge OrderAttribute");
}
}
Loading
Loading