-
Notifications
You must be signed in to change notification settings - Fork 521
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
base: master
Are you sure you want to change the base?
Changes from 4 commits
90bfbe1
51e9927
fabd6ac
9f74240
9d87b93
5f1756a
48a8078
e77fb1a
540c59f
6cd7ba0
8bb76d2
67b90a2
c0e5447
949c59f
611ec39
14a16a4
ceff5c5
a1f0521
8ef2d27
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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> | ||
<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> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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"); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this dependency