@Override public void setAsText(String uuid) throws IllegalArgumentException { OpenmrsService service = Context.getService(serviceClass); try { Object val = method.invoke(service, uuid); if (val == null) throw new RuntimeWrappedException(new ObjectNotFoundException()); setValue(val); } catch (IllegalAccessException ex) { throw new RuntimeException(ex); } catch (InvocationTargetException ex) { throw new RuntimeException(ex); } }
/** * @see org.openmrs.module.webservices.rest.web.resource.api.Deletable#delete(java.lang.String) */ @Override public void delete(String uuid, String reason, RequestContext context) throws ResponseException { T delegate = getByUniqueId(uuid); if (delegate == null) throw new ObjectNotFoundException(); delete(delegate, reason, context); }
private Location getLocation(String locationUniqueId) { Location location = ((LocationResource1_8) Context.getService(RestService.class).getResourceByName( RestConstants.VERSION_1 + "/location")).getByUniqueId(locationUniqueId); if (location == null) throw new ObjectNotFoundException(); return location; } }
private Patient getPatient(String patientUniqueId) { Patient patient = ((PatientResource1_8) Context.getService(RestService.class).getResourceByName( RestConstants.VERSION_1 + "/patient")).getByUniqueId(patientUniqueId); if (patient == null) throw new ObjectNotFoundException(); return patient; }
/** * @see org.openmrs.module.webservices.rest.web.resource.api.SubResource#delete(java.lang.String, * java.lang.String, java.lang.String, * org.openmrs.module.webservices.rest.web.RequestContext) */ @Override public void delete(String parentUniqueId, String uuid, String reason, RequestContext context) throws ResponseException { T delegate = getByUniqueId(uuid); if (delegate == null) throw new ObjectNotFoundException(); testParent(delegate, parentUniqueId); delete(delegate, reason, context); }
source = conceptService.getConceptSourceByUuid(sourceUuid); if (source == null) { throw new ObjectNotFoundException(); ConceptMapType mapType = conceptService.getConceptMapTypeByUuid(uuid.trim()); if (mapType == null) { throw new ObjectNotFoundException();
source = conceptService.getConceptSourceByUuid(sourceUuid); if (source == null) { throw new ObjectNotFoundException(); ConceptMapType mapType = conceptService.getConceptMapTypeByUuid(uuid.trim()); if (mapType == null) { throw new ObjectNotFoundException();
/** * TODO * * @param delegateUuid * @param subResourceName * @param rep * @return * @throws ResponseException */ public Object listSubResource(String delegateUuid, String subResourceName, Representation rep) throws ResponseException { // TODO SUBCLASSHANDLER List<String> legal = getPropertiesToExposeAsSubResources(); if (legal == null || !legal.contains(subResourceName)) throw new IllegalPropertyException(); T delegate = getByUniqueId(delegateUuid); if (delegate == null) throw new ObjectNotFoundException(); return ConversionUtil.getPropertyWithRepresentation(delegate, subResourceName, rep); }
/** * @see SubResource#retrieve(java.lang.String, java.lang.String, RequestContext) */ @Override public Object retrieve(String parentUniqueId, String uuid, RequestContext context) throws ResponseException { T delegate = getByUniqueId(uuid); if (delegate == null) throw new ObjectNotFoundException(); testParent(delegate, parentUniqueId); return asRepresentation(delegate, context.getRepresentation()); }
/** * @see org.openmrs.module.webservices.rest.web.resource.api.SubResource#doGetAll(java.lang.Object, * org.openmrs.module.webservices.rest.web.RequestContext) * @should return 404 status if Allergy Status is UNKNOWN * @should return empty list if Allergy Status is NO_KNOWN_ALLERGIES * @should throw new ResourceDoesNotSupportOperationException if patient is null */ @Override public NeedsPaging<Allergy> doGetAll(Patient parent, RequestContext context) throws ResponseException { List<Allergy> allergiesList = new ArrayList<Allergy>(); Allergies allergies = new Allergies(); if (parent != null) { allergies = Context.getPatientService().getAllergies(parent); if (allergies.getAllergyStatus().equals(Allergies.UNKNOWN)) { // return 404 status for a patient whoose allergy status is unknown throw new ObjectNotFoundException(); } else if (allergies.getAllergyStatus().equals(Allergies.NO_KNOWN_ALLERGIES)) { // empty list } else if (allergies.getAllergyStatus().equals(Allergies.SEE_LIST)) { // return list allergiesList.addAll(allergies); } } else { throw new ResourceDoesNotSupportOperationException(); } return new NeedsPaging<Allergy>(allergiesList, context); }
/** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingSubResource#delete(java.lang.String, * java.lang.String, java.lang.String, * org.openmrs.module.webservices.rest.web.RequestContext) */ @Override public void delete(String parentUniqueId, String uuid, String reason, RequestContext context) throws ResponseException { CohortMember1_8 delegate = getByUniqueId(uuid); if (delegate == null) throw new ObjectNotFoundException(); Cohort parent = Context.getCohortService().getCohortByUuid(parentUniqueId); setParent(delegate, parent); delete(delegate, reason, context); }
patient = patientService.getPatientByUuid(patientUuid); if (patient == null) { throw new ObjectNotFoundException(); careSetting = orderService.getCareSettingByUuid(careSettingUuid); if (careSetting == null) { throw new ObjectNotFoundException(); throw new ObjectNotFoundException(); throw new ObjectNotFoundException();
/** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingSubResource#retrieve(java.lang.String, * java.lang.String, org.openmrs.module.webservices.rest.web.RequestContext) */ @Override public Object retrieve(String parentUniqueId, String uuid, RequestContext context) throws ResponseException { CohortMember1_8 delegate = getByUniqueId(uuid); if (delegate == null) throw new ObjectNotFoundException(); delegate.setCohort(Context.getCohortService().getCohortByUuid(parentUniqueId)); return asRepresentation(delegate, context.getRepresentation()); }
throw new ObjectNotFoundException(); throw new ObjectNotFoundException();
/** * @see org.openmrs.module.webservices.rest.web.resource.api.Retrievable#retrieve(java.lang.String, * org.openmrs.module.webservices.rest.web.representation.Representation) */ @Override public Object retrieve(String uuid, RequestContext context) throws ResponseException { T delegate = getByUniqueId(uuid); if (delegate == null) throw new ObjectNotFoundException(); SimpleObject ret = asRepresentation(delegate, context.getRepresentation()); if (hasTypesDefined()) ret.add(RestConstants.PROPERTY_FOR_TYPE, getTypeName(delegate)); return ret; }
/** * @see SubResource#update(java.lang.String, java.lang.String, SimpleObject, RequestContext) */ @Override public Object update(String parentUniqueId, String uuid, SimpleObject propertiesToUpdate, RequestContext context) throws ResponseException { T delegate = getByUniqueId(uuid); if (delegate == null) throw new ObjectNotFoundException(); testParent(delegate, parentUniqueId); setConvertedProperties(delegate, propertiesToUpdate, getUpdatableProperties(), false); delegate = save(delegate); return ConversionUtil.convertToRepresentation(delegate, Representation.DEFAULT); }
obs.setValueDrug(valueDrug); } else { throw new ObjectNotFoundException();
Patient.class)).getByUniqueId(patientUuid); if (patient == null) { throw new ObjectNotFoundException(); CareSetting.class)).getByUniqueId(careSettingUuid); if (careSetting == null) { throw new ObjectNotFoundException(); OrderType.class)).getByUniqueId(orderTypeUuid); if (orderType == null) { throw new ObjectNotFoundException();
/** * @see SubResource#create(java.lang.String, SimpleObject, RequestContext) */ @Override public Object create(String parentUniqueId, SimpleObject post, RequestContext context) throws ResponseException { PR parentResource = getParentResource(); P parent = parentResource.getByUniqueId(parentUniqueId); if (parent == null) throw new ObjectNotFoundException(); T delegate = newDelegate(); setParent(delegate, parent); DelegatingResourceDescription description = getBuildCreatableProperties(post); setConvertedProperties(delegate, post, description, true); delegate = save(delegate); return ConversionUtil.convertToRepresentation(delegate, Representation.DEFAULT); }
T delegate = getByUniqueId(uuid); if (delegate == null) throw new ObjectNotFoundException();