-
Notifications
You must be signed in to change notification settings - Fork 549
RESTWS-920: Endpoint for OrderAttribute and OrderAttributeType. #587
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
Open
slubwama
wants to merge
19
commits into
openmrs:master
Choose a base branch
from
slubwama:RESTWS-920
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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 51e9927
removing unnecessary tests and files
slubwama fabd6ac
Changing logging approach in OrderAttributeResource2_5Test
slubwama 9f74240
adding OrderAttributeController2_5Test and OrderAttributeTypeControll…
slubwama 9d87b93
Changing order to include order attribute
slubwama 5f1756a
changing test to focus on creation of order with attribute
slubwama 48a8078
Merge branch 'master' of github.com:openmrs/openmrs-module-webservice…
slubwama e77fb1a
change version in omod-2.5 to match other module poms
slubwama 540c59f
Merge branch 'master' of github.com:openmrs/openmrs-module-webservice…
slubwama 6cd7ba0
change version to 2.44.0-SNAPSHOT
slubwama 8bb76d2
change Dispensing Date order_attribute_type uuid to c0de4f5c-6626-4…
slubwama 67b90a2
make changes to test data
slubwama c0e5447
response to comments
slubwama 949c59f
response to comments
slubwama 611ec39
Merge branch 'master' of github.com:openmrs/openmrs-module-webservice…
slubwama 14a16a4
change to snapshot 2.45.0-SNAPSHOT
slubwama ceff5c5
add override for shouldGetAll() to one that throws an exception.
slubwama a1f0521
Merge branch 'master' of github.com:openmrs/openmrs-module-webservice…
slubwama 8ef2d27
clean pom
slubwama File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> | ||
| <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> | ||
162 changes: 162 additions & 0 deletions
162
...rs/module/webservices/rest/web/v1_0/resource/openmrs2_5/BaseAttributeCrudResource2_5.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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>> { | ||
|
||
|
|
||
| /** | ||
| * 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"); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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