private String getParentUri(T instance) { return getParentResource().getUri(getParent(instance)); }
/** * @see SubResource#getAll(java.lang.String, RequestContext) */ @Override public SimpleObject getAll(String parentUniqueId, RequestContext context) throws ResponseException { P parent = getParentResource().getByUniqueId(parentUniqueId); PageableResult result = doGetAll(parent, context); return result.toSimpleObject(this); }
/** * Ensures that the uuid of the parent of delegate is the same as the passed in parentUniqueId * * @param delegate * @param parentUniqueId * @throws ObjectMismatchException */ private void testParent(T delegate, String parentUniqueId) throws ObjectMismatchException { P parent = getParent(delegate); String test = getParentResource().getUniqueId(parent); if (!OpenmrsUtil.nullSafeEquals(test, parentUniqueId)) throw new ObjectMismatchException(parentUniqueId + " does not match " + parent, null); }
/** * @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); }