Skip to content

Commit

Permalink
RESTWS-502 - Should be able to get display property in custom represe…
Browse files Browse the repository at this point in the history
…ntations
  • Loading branch information
djazayeri committed May 16, 2015
1 parent 1bbdc37 commit 49ddecc
Show file tree
Hide file tree
Showing 53 changed files with 175 additions and 106 deletions.
Expand Up @@ -49,7 +49,7 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
description.addProperty("description");
description.addProperty("retired");
description.addProperty("careSettingType");
description.addProperty("display", findMethod("getDisplayString"));
description.addProperty("display");
description.addSelfLink();
if (rep instanceof DefaultRepresentation) {
description.addLink("full", ".?v=" + RestConstants.REPRESENTATION_FULL);
Expand Down
Expand Up @@ -43,7 +43,7 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
if (rep instanceof DefaultRepresentation) {
DelegatingResourceDescription description = new DelegatingResourceDescription();
description.addProperty("uuid");
description.addProperty("display", findMethod("getDisplayString"));
description.addProperty("display");
description.addProperty("name");
description.addProperty("frequencyPerDay");
description.addProperty("retired");
Expand All @@ -54,7 +54,7 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
} else if (rep instanceof FullRepresentation) {
DelegatingResourceDescription description = new DelegatingResourceDescription();
description.addProperty("uuid");
description.addProperty("display", findMethod("getDisplayString"));
description.addProperty("display");
description.addProperty("name");
description.addProperty("frequencyPerDay");
description.addProperty("concept", Representation.DEFAULT);
Expand Down
Expand Up @@ -68,7 +68,7 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
description.addProperty("urgency");
description.addProperty("instructions");
description.addProperty("commentToFulfiller");
description.addProperty("display", findMethod("getDisplayString"));
description.addProperty("display");
description.addSelfLink();
description.addLink("full", ".?v=" + RestConstants.REPRESENTATION_FULL);
return description;
Expand All @@ -91,7 +91,7 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
description.addProperty("urgency");
description.addProperty("instructions");
description.addProperty("commentToFulfiller");
description.addProperty("display", findMethod("getDisplayString"));
description.addProperty("display");
description.addProperty("auditInfo", findMethod("getAuditInfo"));
description.addSelfLink();
return description;
Expand Down
Expand Up @@ -44,6 +44,7 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
DelegatingResourceDescription description = new DelegatingResourceDescription();
description.addProperty("uuid");
description.addProperty("display");
description.addProperty("name");
description.addProperty("javaClassName");
description.addProperty("retired");
Expand Down
Expand Up @@ -18,6 +18,7 @@
import org.openmrs.api.context.Context;
import org.openmrs.module.webservices.rest.web.RequestContext;
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.annotation.Resource;
import org.openmrs.module.webservices.rest.web.api.RestService;
Expand Down Expand Up @@ -86,6 +87,7 @@ public DelegatingResourceDescription getCreatableProperties() {
* @param allergy
* @return String ConceptName
*/
@PropertyGetter("display")
public String getDisplayString(Allergy allergy) {
if (allergy.getAllergen() == null)
return "";
Expand Down
Expand Up @@ -38,7 +38,7 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
if (rep instanceof DefaultRepresentation) {
DelegatingResourceDescription description = new DelegatingResourceDescription();
description.addProperty("uuid");
description.addProperty("display", findMethod("getDisplayString"));
description.addProperty("display");
description.addProperty("person", Representation.REF);
description.addProperty("activeListType", Representation.REF);
description.addProperty("startDate");
Expand All @@ -53,7 +53,7 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
} else if (rep instanceof FullRepresentation) {
DelegatingResourceDescription description = new DelegatingResourceDescription();
description.addProperty("uuid");
description.addProperty("display", findMethod("getDisplayString"));
description.addProperty("display");
description.addProperty("person", Representation.REF);
description.addProperty("activeListType", Representation.REF);
description.addProperty("startDate");
Expand Down
Expand Up @@ -20,6 +20,7 @@
import org.openmrs.module.webservices.rest.web.ConversionUtil;
import org.openmrs.module.webservices.rest.web.RequestContext;
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.SubResource;
import org.openmrs.module.webservices.rest.web.representation.DefaultRepresentation;
import org.openmrs.module.webservices.rest.web.representation.FullRepresentation;
Expand Down Expand Up @@ -96,19 +97,19 @@ public CohortMember1_8 getByUniqueId(String uniqueId) {
public DelegatingResourceDescription getRepresentationDescription(Representation rep) {
if (rep instanceof RefRepresentation) {
DelegatingResourceDescription description = new DelegatingResourceDescription();
description.addProperty("display", findMethod("getDisplayString"));
description.addProperty("display");
description.addSelfLink();
return description;
} else if (rep instanceof DefaultRepresentation) {
DelegatingResourceDescription description = new DelegatingResourceDescription();
description.addProperty("display", findMethod("getDisplayString"));
description.addProperty("display");
description.addProperty("patient");
description.addSelfLink();
description.addLink("full", ".?v=" + RestConstants.REPRESENTATION_FULL);
return description;
} else if (rep instanceof FullRepresentation) {
DelegatingResourceDescription description = new DelegatingResourceDescription();
description.addProperty("display", findMethod("getDisplayString"));
description.addProperty("display");
description.addProperty("patient");
//description.addProperty("auditInfo", findMethod("getAuditInfo"));
description.addSelfLink();
Expand Down Expand Up @@ -253,8 +254,9 @@ else if (context.getRepresentation().equals(Representation.FULL))
* @param member the patient
* @return string that contains cohort member's identifier and full name
*/
@PropertyGetter("display")
public String getDisplayString(CohortMember1_8 member) {

if (member.getPatient().getPatientIdentifier() == null)
return "";

Expand Down
Expand Up @@ -17,6 +17,7 @@
import org.openmrs.api.context.Context;
import org.openmrs.module.webservices.rest.web.RequestContext;
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.Resource;
import org.openmrs.module.webservices.rest.web.representation.DefaultRepresentation;
import org.openmrs.module.webservices.rest.web.representation.FullRepresentation;
Expand Down Expand Up @@ -66,7 +67,7 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
if (rep instanceof DefaultRepresentation) {
DelegatingResourceDescription description = new DelegatingResourceDescription();
description.addProperty("uuid");
description.addProperty("display", findMethod("getDisplayString"));
description.addProperty("display");
description.addProperty("name");
description.addProperty("description");
description.addProperty("voided");
Expand All @@ -77,7 +78,7 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
} else if (rep instanceof FullRepresentation) {
DelegatingResourceDescription description = new DelegatingResourceDescription();
description.addProperty("uuid");
description.addProperty("display", findMethod("getDisplayString"));
description.addProperty("display");
description.addProperty("name");
description.addProperty("description");
description.addProperty("memberIds");
Expand Down Expand Up @@ -149,6 +150,7 @@ public Cohort save(Cohort cohort) {
* @param cohort
* @return cohort's name
*/
@PropertyGetter("display")
public String getDisplayString(Cohort cohort) {
return cohort.getName();
}
Expand Down
Expand Up @@ -43,7 +43,7 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
if (rep instanceof DefaultRepresentation) {
DelegatingResourceDescription description = new DelegatingResourceDescription();
description.addProperty("uuid");
description.addProperty("display", findMethod("getDisplayString"));
description.addProperty("display");
description.addProperty("name");
description.addProperty("description");
description.addProperty("hl7Abbreviation");
Expand All @@ -54,7 +54,7 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
} else if (rep instanceof FullRepresentation) {
DelegatingResourceDescription description = new DelegatingResourceDescription();
description.addProperty("uuid");
description.addProperty("display", findMethod("getDisplayString"));
description.addProperty("display");
description.addProperty("name");
description.addProperty("description");
description.addProperty("hl7Abbreviation");
Expand Down
Expand Up @@ -46,12 +46,12 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
if (rep instanceof RefRepresentation) {
DelegatingResourceDescription description = new DelegatingResourceDescription();
description.addProperty("uuid");
description.addProperty("display", findMethod("getDisplayString"));
description.addProperty("display");
description.addSelfLink();
return description;
} else if (rep instanceof DefaultRepresentation) {
DelegatingResourceDescription description = new DelegatingResourceDescription();
description.addProperty("display", findMethod("getDisplayString"));
description.addProperty("display");
description.addProperty("uuid");
description.addProperty("description");
description.addProperty("locale");
Expand Down Expand Up @@ -167,6 +167,7 @@ public ConceptDescription newDelegate() {
* @param conceptDescription the concept description object.
* @return the display string.
*/
@PropertyGetter("display")
public String getDisplayString(ConceptDescription conceptDescription) {
return conceptDescription.getDescription();
}
Expand Down
Expand Up @@ -21,6 +21,7 @@
import org.openmrs.api.context.Context;
import org.openmrs.module.webservices.rest.web.RequestContext;
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.Resource;
import org.openmrs.module.webservices.rest.web.annotation.SubResource;
import org.openmrs.module.webservices.rest.web.api.RestHelperService;
Expand All @@ -44,7 +45,7 @@ public class ConceptMapResource1_8 extends DelegatingSubResource<ConceptMap, Con
public DelegatingResourceDescription getRepresentationDescription(Representation rep) {
if (rep instanceof DefaultRepresentation) {
DelegatingResourceDescription description = new DelegatingResourceDescription();
description.addProperty("display", findMethod("getDisplayString"));
description.addProperty("display");
description.addProperty("uuid");
description.addProperty("source", Representation.REF);
description.addProperty("sourceCode");
Expand All @@ -53,7 +54,7 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
return description;
} else if (rep instanceof FullRepresentation) {
DelegatingResourceDescription description = new DelegatingResourceDescription();
description.addProperty("display", findMethod("getDisplayString"));
description.addProperty("display");
description.addProperty("uuid");
description.addProperty("source", Representation.DEFAULT);
description.addProperty("sourceCode");
Expand Down Expand Up @@ -82,6 +83,7 @@ public DelegatingResourceDescription getCreatableProperties() {
* @param conceptMap the concept map object.
* @return the display string.
*/
@PropertyGetter("display")
public String getDisplayString(ConceptMap conceptMap) {
if (conceptMap.getSource() == null) {
return "";
Expand Down
Expand Up @@ -44,7 +44,7 @@ public class ConceptNameResource1_8 extends DelegatingSubResource<ConceptName, C
public DelegatingResourceDescription getRepresentationDescription(Representation rep) {
if (rep instanceof DefaultRepresentation) {
DelegatingResourceDescription description = new DelegatingResourceDescription();
description.addProperty("display", findMethod("getDisplayString"));
description.addProperty("display");
description.addProperty("uuid");
description.addProperty("name");
description.addProperty("locale");
Expand All @@ -55,7 +55,7 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
return description;
} else if (rep instanceof FullRepresentation) {
DelegatingResourceDescription description = new DelegatingResourceDescription();
description.addProperty("display", findMethod("getDisplayString"));
description.addProperty("display");
description.addProperty("uuid");
description.addProperty("name");
description.addProperty("locale");
Expand Down Expand Up @@ -179,6 +179,7 @@ public ConceptName newDelegate() {
* @param conceptName the concept name object.
* @return the display string.
*/
@PropertyGetter("display")
public String getDisplayString(ConceptName conceptName) {
return conceptName.getName();
}
Expand Down
Expand Up @@ -131,7 +131,7 @@ public List<Representation> getAvailableRepresentations() {
protected DelegatingResourceDescription fullRepresentationDescription(Concept delegate) {
DelegatingResourceDescription description = new DelegatingResourceDescription();
description.addProperty("uuid");
description.addProperty("display", findMethod("getDisplayName"));
description.addProperty("display");
description.addProperty("name", Representation.DEFAULT);
description.addProperty("datatype", Representation.DEFAULT);
description.addProperty("conceptClass", Representation.DEFAULT);
Expand Down Expand Up @@ -170,7 +170,7 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
if (rep instanceof DefaultRepresentation) {
DelegatingResourceDescription description = new DelegatingResourceDescription();
description.addProperty("uuid");
description.addProperty("display", findMethod("getDisplayName"));
description.addProperty("display");
description.addProperty("name", Representation.DEFAULT);
description.addProperty("datatype", Representation.REF);
description.addProperty("conceptClass", Representation.REF);
Expand Down Expand Up @@ -291,6 +291,7 @@ public static List<ConceptMap> getMappings(Concept instance) {
*
* @param instance the delegate instance to get the display name off
*/
@PropertyGetter("display")
public String getDisplayName(Concept instance) {
ConceptName cn = instance.getName();
return cn == null ? null : cn.getName();
Expand Down
Expand Up @@ -45,7 +45,7 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
if (rep instanceof DefaultRepresentation) {
DelegatingResourceDescription description = new DelegatingResourceDescription();
description.addProperty("uuid");
description.addProperty("display", findMethod("getDisplayString"));
description.addProperty("display");
description.addProperty("name");
description.addProperty("description");
description.addProperty("hl7Code");
Expand All @@ -56,7 +56,7 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
} else if (rep instanceof FullRepresentation) {
DelegatingResourceDescription description = new DelegatingResourceDescription();
description.addProperty("uuid");
description.addProperty("display", findMethod("getDisplayString"));
description.addProperty("display");
description.addProperty("name");
description.addProperty("description");
description.addProperty("hl7Code");
Expand Down
Expand Up @@ -78,7 +78,7 @@ public void purge(Drug delegate, RequestContext context) throws ResponseExceptio
public DelegatingResourceDescription getRepresentationDescription(Representation rep) {
if (rep instanceof DefaultRepresentation) {
DelegatingResourceDescription description = new DelegatingResourceDescription();
description.addProperty("display", findMethod("getDisplayString"));
description.addProperty("display");
description.addProperty("uuid");
description.addProperty("name");
description.addProperty("description");
Expand All @@ -96,7 +96,7 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
return description;
} else if (rep instanceof FullRepresentation) {
DelegatingResourceDescription description = new DelegatingResourceDescription();
description.addProperty("display", findMethod("getDisplayString"));
description.addProperty("display");
description.addProperty("uuid");
description.addProperty("name");
description.addProperty("description");
Expand Down
Expand Up @@ -55,7 +55,7 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
if (rep instanceof DefaultRepresentation) {
DelegatingResourceDescription description = new DelegatingResourceDescription();
description.addProperty("uuid");
description.addProperty("display", findMethod("getDisplayString"));
description.addProperty("display");
description.addProperty("encounterDatetime");
description.addProperty("patient", Representation.REF);
description.addProperty("location", Representation.REF);
Expand All @@ -71,7 +71,7 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
} else if (rep instanceof FullRepresentation) {
DelegatingResourceDescription description = new DelegatingResourceDescription();
description.addProperty("uuid");
description.addProperty("display", findMethod("getDisplayString"));
description.addProperty("display");
description.addProperty("encounterDatetime");
description.addProperty("patient", Representation.REF);
description.addProperty("location");
Expand Down Expand Up @@ -168,6 +168,7 @@ public void purge(Encounter enc, RequestContext context) throws ResponseExceptio
* @param encounter
* @return encounter type and date
*/
@PropertyGetter("display")
public String getDisplayString(Encounter encounter) {
String ret = encounter.getEncounterType() == null ? "?" : encounter.getEncounterType().getName();
ret += " ";
Expand Down

0 comments on commit 49ddecc

Please sign in to comment.