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-676: Improve resource definition properties #405

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -9,11 +9,12 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_10;

import io.swagger.models.Model;
import io.swagger.models.ModelImpl;
import io.swagger.models.properties.DateProperty;
import io.swagger.models.properties.RefProperty;
import io.swagger.models.properties.StringProperty;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.openmrs.CareSetting;
import org.openmrs.Order;
Expand All @@ -39,11 +40,11 @@
import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.OrderResource1_8;
import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.PatientResource1_8;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import io.swagger.models.Model;
import io.swagger.models.ModelImpl;
import io.swagger.models.properties.DateProperty;
import io.swagger.models.properties.RefProperty;
import io.swagger.models.properties.StringProperty;

/**
* {@link org.openmrs.module.webservices.rest.web.annotation.Resource} for {@link org.openmrs.Order}
Expand Down Expand Up @@ -145,9 +146,10 @@ public Model getCREATEModel(Representation rep) {
.property("concept", new RefProperty("#/definitions/ConceptCreate"))
.property("orderer", new RefProperty("#/definitions/UserCreate"))
.property("previousOrder", new RefProperty("#/definitions/OrderCreate"))
.property("orderReason", new RefProperty("#/definitions/ConceptCreate"));
.property("orderReason", new RefProperty("#/definitions/ConceptCreate"))
.property("careSetting", new RefProperty("#/definitions/CareSettingCreate"));
}
//FIXME missing prop: type

return model;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@
import java.util.List;
import java.util.regex.Pattern;

import io.swagger.models.Model;
import io.swagger.models.ModelImpl;
import io.swagger.models.properties.ArrayProperty;
import io.swagger.models.properties.RefProperty;
import io.swagger.models.properties.StringProperty;
import org.openmrs.OrderType;
import org.openmrs.api.context.Context;
import org.openmrs.module.webservices.rest.web.RequestContext;
Expand All @@ -32,6 +27,12 @@
import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging;
import org.openmrs.module.webservices.rest.web.response.ResponseException;

import io.swagger.models.Model;
import io.swagger.models.ModelImpl;
import io.swagger.models.properties.ArrayProperty;
import io.swagger.models.properties.RefProperty;
import io.swagger.models.properties.StringProperty;

/**
* {@link Resource} for {@link org.openmrs.OrderType}, supporting standard CRUD operations
*/
Expand Down Expand Up @@ -175,7 +176,7 @@ public Model getGETModel(Representation rep) {
public Model getCREATEModel(Representation rep) {
return ((ModelImpl) super.getCREATEModel(rep))
.property("javaClassName", new StringProperty())
.property("parent", new StringProperty().example("uuid")) //FIXME type
.property("parent", new StringProperty().example("uuid"))
.property("conceptClasses", new ArrayProperty(new StringProperty().example("uuid")))

.required("javaClassName");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_10;

import io.swagger.models.Model;
import io.swagger.models.ModelImpl;
import io.swagger.models.properties.ArrayProperty;
import io.swagger.models.properties.BooleanProperty;
import io.swagger.models.properties.DateProperty;
import io.swagger.models.properties.RefProperty;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.Set;

import org.openmrs.PatientProgram;
import org.openmrs.PatientState;
import org.openmrs.api.context.Context;
Expand All @@ -29,11 +29,12 @@
import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.ProgramEnrollmentResource1_8;
import org.openmrs.util.OpenmrsUtil;

import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.Set;
import io.swagger.models.Model;
import io.swagger.models.ModelImpl;
import io.swagger.models.properties.ArrayProperty;
import io.swagger.models.properties.BooleanProperty;
import io.swagger.models.properties.DateProperty;
import io.swagger.models.properties.RefProperty;

@Resource(name = RestConstants.VERSION_1 + "/programenrollment", supportedClass = PatientProgram.class, supportedOpenmrsVersions = {
"1.10.*", "1.11.*", "1.12.*", "2.0.*", "2.1.*", "2.2.*", "2.3.*" })
Expand Down Expand Up @@ -113,7 +114,7 @@ public Model getCREATEModel(Representation rep) {

@Override
public Model getUPDATEModel(Representation rep) {
return new ModelImpl() //FIXME use super.
return ((ModelImpl) super.getUPDATEModel(rep))
.property("dateEnrolled", new DateProperty())
.property("states", new ArrayProperty(new RefProperty("#/definitions/ProgramenrollmentStateCreate")))
.property("outcome", new RefProperty("#/definitions/ConceptCreate"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8;

import io.swagger.models.Model;
import io.swagger.models.ModelImpl;
import io.swagger.models.properties.BooleanProperty;
import io.swagger.models.properties.DateProperty;
import io.swagger.models.properties.RefProperty;
import io.swagger.models.properties.StringProperty;
import org.openmrs.activelist.ActiveListItem;
import org.openmrs.api.context.Context;
import org.openmrs.module.webservices.rest.web.RequestContext;
Expand All @@ -26,6 +20,13 @@
import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription;
import org.openmrs.module.webservices.rest.web.response.ResponseException;

import io.swagger.models.Model;
import io.swagger.models.ModelImpl;
import io.swagger.models.properties.BooleanProperty;
import io.swagger.models.properties.DateProperty;
import io.swagger.models.properties.RefProperty;
import io.swagger.models.properties.StringProperty;

/**
* Subclass of {@link DataDelegatingCrudResource} with helper methods specific to
* {@link ActiveListItem}
Expand Down Expand Up @@ -90,6 +91,7 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
return null;
}

@Override
public Model getGETModel(Representation rep) {
ModelImpl model = ((ModelImpl) super.getGETModel(rep))
.property("uuid", new StringProperty())
Expand All @@ -101,13 +103,13 @@ public Model getGETModel(Representation rep) {
if (rep instanceof DefaultRepresentation) {
model
.property("person", new RefProperty("#/definitions/PersonGet"))
.property("activeListType", new StringProperty()) //FIXME type
.property("activeListType", new RefProperty("#/definitionsActiveListType/Ref"))
.property("startObs", new RefProperty("#/definitions/ObsGet"))
.property("stopObs", new RefProperty("#/definitions/ObsGetRef"));
} else if (rep instanceof FullRepresentation) {
model
.property("person", new RefProperty("#/definitions/PersonGetRef"))
.property("activeListType", new StringProperty()) //FIXME type
.property("activeListType", new RefProperty("#/definitionsActiveListType/Ref"))
.property("startObs", new RefProperty("#/definitions/ObsGetRef"))
.property("stopObs", new RefProperty("#/definitions/ObsGetRef"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@

import java.util.List;

import io.swagger.models.Model;
import io.swagger.models.ModelImpl;
import io.swagger.models.properties.ArrayProperty;
import io.swagger.models.properties.IntegerProperty;
import io.swagger.models.properties.StringProperty;
import org.openmrs.Cohort;
import org.openmrs.api.context.Context;
import org.openmrs.module.webservices.rest.web.RequestContext;
Expand All @@ -30,6 +25,12 @@
import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging;
import org.openmrs.module.webservices.rest.web.response.ResponseException;

import io.swagger.models.Model;
import io.swagger.models.ModelImpl;
import io.swagger.models.properties.ArrayProperty;
import io.swagger.models.properties.IntegerProperty;
import io.swagger.models.properties.StringProperty;

/**
* {@link Resource} for Cohorts, supporting standard CRUD operations
*/
Expand Down Expand Up @@ -92,6 +93,7 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
return null;
}

@Override
public Model getGETModel(Representation rep) {
ModelImpl model = ((ModelImpl) super.getGETModel(rep));
if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
Expand All @@ -101,7 +103,7 @@ public Model getGETModel(Representation rep) {
.property("name", new StringProperty())
.property("description", new StringProperty())
.property("voided", new StringProperty())
.property("memberIds", new ArrayProperty(new IntegerProperty())); //FIXME
.property("memberIds", new ArrayProperty(new IntegerProperty()));
Copy link
Member

Choose a reason for hiding this comment

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

Here the code seems to look alike

}
return model;
}
Expand All @@ -111,7 +113,7 @@ public Model getCREATEModel(Representation rep) {
return new ModelImpl()
.property("name", new StringProperty())
.property("description", new StringProperty())
.property("memberIds", new ArrayProperty(new IntegerProperty())) //FIXME
.property("memberIds", new ArrayProperty(new IntegerProperty()))
.required("name").required("description").required("memberIds");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
import java.util.ArrayList;
import java.util.List;

import io.swagger.models.Model;
import io.swagger.models.ModelImpl;
import io.swagger.models.properties.StringProperty;
import org.openmrs.Concept;
import org.openmrs.ConceptMap;
import org.openmrs.api.context.Context;
Expand All @@ -34,6 +31,10 @@
import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException;
import org.openmrs.module.webservices.rest.web.response.ResponseException;

import io.swagger.models.Model;
import io.swagger.models.ModelImpl;
import io.swagger.models.properties.StringProperty;

/**
* {@link Resource} for ConceptMaps, supporting standard CRUD operations
*/
Expand Down Expand Up @@ -65,19 +66,20 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
return null;
}

@Override
public Model getGETModel(Representation rep) {
ModelImpl modelImpl = (ModelImpl) super.getGETModel(rep);
if (rep instanceof DefaultRepresentation) {
modelImpl
.property("display", new StringProperty())
.property("uuid", new StringProperty())
.property("source", new StringProperty()) //FIXME
.property("source", new StringProperty())
.property("sourceCode", new StringProperty());
} else if (rep instanceof FullRepresentation) {
modelImpl
.property("display", new StringProperty())
.property("uuid", new StringProperty())
.property("source", new StringProperty()) //FIXME
.property("source", new StringProperty())
.property("sourceCode", new StringProperty())
.property("comment", new StringProperty());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
import java.util.Date;
import java.util.List;

import io.swagger.models.Model;
import io.swagger.models.ModelImpl;
import io.swagger.models.properties.BooleanProperty;
import io.swagger.models.properties.StringProperty;
import org.openmrs.Concept;
import org.openmrs.ConceptName;
import org.openmrs.api.ConceptNameType;
Expand All @@ -35,6 +31,11 @@
import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging;
import org.openmrs.module.webservices.rest.web.response.ResponseException;

import io.swagger.models.Model;
import io.swagger.models.ModelImpl;
import io.swagger.models.properties.BooleanProperty;
import io.swagger.models.properties.StringProperty;

/**
* {@link Resource} for ConceptNames, supporting standard CRUD operations
*/
Expand Down Expand Up @@ -70,6 +71,7 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
return null;
}

@Override
public Model getGETModel(Representation rep) {
ModelImpl model = ((ModelImpl) super.getGETModel(rep))
.property("uuid", new StringProperty())
Expand Down Expand Up @@ -98,7 +100,11 @@ public Model getCREATEModel(Representation rep) {
@Override
public Model getUPDATEModel(Representation representation) {
return new ModelImpl()
.property("name", new StringProperty()); //FIXME missing props

Copy link

Choose a reason for hiding this comment

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

I think the extra spaces should be removed on lines 103-104.


.property("name", new StringProperty())
.property("localePreferred", new BooleanProperty())
.property("locale", new StringProperty().example("en"));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8;

import io.swagger.models.Model;
import io.swagger.models.ModelImpl;
import io.swagger.models.properties.ArrayProperty;
import io.swagger.models.properties.BooleanProperty;
import io.swagger.models.properties.ObjectProperty;
import io.swagger.models.properties.RefProperty;
import io.swagger.models.properties.StringProperty;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.Set;

import org.apache.commons.lang.StringUtils;
import org.openmrs.Concept;
import org.openmrs.ConceptAnswer;
Expand Down Expand Up @@ -53,18 +59,13 @@
import org.openmrs.module.webservices.rest.web.response.ResponseException;
import org.openmrs.util.LocaleUtility;

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.Set;
import io.swagger.models.Model;
import io.swagger.models.ModelImpl;
import io.swagger.models.properties.ArrayProperty;
import io.swagger.models.properties.BooleanProperty;
import io.swagger.models.properties.ObjectProperty;
import io.swagger.models.properties.RefProperty;
import io.swagger.models.properties.StringProperty;

/**
* {@link Resource} for {@link Concept}, supporting standard CRUD operations
Expand Down Expand Up @@ -216,6 +217,7 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
return null;
}

@Override
public Model getGETModel(Representation rep) {
ModelImpl modelImpl = ((ModelImpl) super.getGETModel(rep))
.property("uuid", new StringProperty())
Expand All @@ -228,11 +230,11 @@ public Model getGETModel(Representation rep) {
.property("set", new BooleanProperty())
.property("version", new StringProperty())
.property("retired", new BooleanProperty())
.property("names", new ArrayProperty(new RefProperty("#/definitions/ConceptNameGetRef"))) //FIXME
.property("descriptions", new ArrayProperty(new RefProperty("#/definitions/ConceptDescriptionGetRef"))) //FIXME
.property("mappings", new ArrayProperty(new RefProperty("#/definitions/ConceptMappingGetRef"))) //FIXME
.property("answers", new ArrayProperty(new ObjectProperty())) //FIXME
.property("setMembers", new ArrayProperty(new ObjectProperty())); //FIXME
.property("names", new ArrayProperty(new RefProperty("#/definitions/ConceptNameGetRef")))
.property("descriptions", new ArrayProperty(new RefProperty("#/definitions/ConceptDescriptionGetRef")))
.property("mappings", new ArrayProperty(new RefProperty("#/definitions/ConceptMappingGetRef")))
.property("answers", new ArrayProperty(new RefProperty("#/definitions/ConceptAnswersGetRef")))
.property("setMembers", new ArrayProperty(new ObjectProperty()));
}
return modelImpl;
}
Expand Down
Loading