@Override public Object retrieve(String uuid, RequestContext context) throws ResponseException { T delegate = getByUniqueId(uuid); return asRepresentation(delegate, context.getRepresentation()); }
/** * @see org.openmrs.module.webservices.rest.web.resource.api.Searchable#search(org.openmrs.module.webservices.rest.web.RequestContext) */ public SimpleObject search(RequestContext context) throws ResponseException { PageableResult result = doSearch(context); return result.toSimpleObject(this); }
/** * @see org.openmrs.module.webservices.rest.web.resource.api.Listable#getAll(org.openmrs.module.webservices.rest.web.RequestContext) */ @Override public SimpleObject getAll(RequestContext context) throws ResponseException { if (context.getType() != null) { if (!hasTypesDefined()) throw new IllegalArgumentException(getClass() + " does not support " + RestConstants.REQUEST_PROPERTY_FOR_TYPE); if (context.getType().equals(getResourceName())) throw new IllegalArgumentException("You may not specify " + RestConstants.REQUEST_PROPERTY_FOR_TYPE + "=" + context.getType() + " because it is the default behavior for this resource"); DelegatingSubclassHandler<T, ? extends T> handler = getSubclassHandler(context.getType()); if (handler == null) throw new IllegalArgumentException("No handler is specified for " + RestConstants.REQUEST_PROPERTY_FOR_TYPE + "=" + context.getType()); PageableResult result = handler.getAllByType(context); return result.toSimpleObject(this); } else { PageableResult result = doGetAll(context); return result.toSimpleObject(this); } }
@Override public Model getGETModel(Representation rep) { ModelImpl model = (ModelImpl) super.getGETModel(rep); if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) { model .property("uuid", new StringProperty()) .property("display", new StringProperty()) .property("name", new StringProperty()) .property("description", new StringProperty()) .property("started", new BooleanProperty()) //FIXME check type .property("startupErrorMessage", new StringProperty()); //FIXME add-link: action } if (rep instanceof FullRepresentation) { model .property("packageName", new StringProperty()) .property("author", new StringProperty()) .property("version", new StringProperty()) .property("requireOpenmrsVersion", new StringProperty()) .property("awareOfModules", new ArrayProperty(new StringProperty())) //FIXME check type .property("requiredModules", new ArrayProperty(new StringProperty())); } else if (rep instanceof RefRepresentation) { model .property("uuid", new StringProperty()) .property("display", new StringProperty()); } return model; }