jaks80
(Yusuf Akhond)
July 14, 2017, 8:17am
1
Hi,
After creating or updating object, server returns default Representation of the object. I have tried to pass
v=full parameter, but it did not work.
Is it possible to get full representation of the object after updating or I have to make another “get” call for full representation.
Regards
raff
(Rafal Korytkowski)
July 14, 2017, 9:00am
2
At the moment you do have to make another get call, but it should be straightforward to add support for v=full for update/create. It should go somewhere around here
}
/**
* @see org.openmrs.module.webservices.rest.web.resource.api.Creatable#create(org.springframework.web.context.request.WebRequest)
*/
@Override
public Object create(SimpleObject propertiesToCreate, RequestContext context) throws ResponseException {
T delegate = convert(propertiesToCreate);
ValidateUtil.validate(delegate);
delegate = save(delegate);
SimpleObject ret = (SimpleObject) ConversionUtil.convertToRepresentation(delegate, context.getRepresentation());
// add the 'type' discriminator if we support subclasses
if (hasTypesDefined()) {
ret.add(RestConstants.PROPERTY_FOR_TYPE, getTypeName(delegate));
}
return ret;
}
public T convert(SimpleObject propertiesToCreate) {
and
if (isRetirable()) {
description.addProperty("retired");
} else if (isVoidable()) {
description.addProperty("voided");
}
setConvertedProperties(delegate, propertiesToUpdate, description, false);
ValidateUtil.validate(delegate);
delegate = save(delegate);
SimpleObject ret = (SimpleObject) ConversionUtil.convertToRepresentation(delegate, context.getRepresentation());
// add the 'type' discriminator if we support subclasses
if (hasTypesDefined()) {
ret.add(RestConstants.PROPERTY_FOR_TYPE, getTypeName(delegate));
}
return ret;
}
/**
jaks80
(Yusuf Akhond)
July 14, 2017, 1:11pm
3
Thanks a lot @raff , I will try to add it.
jaks80
(Yusuf Akhond)
July 14, 2017, 1:24pm
4
Shall I just hard code Representation.DEFAULT to Representation.FULL
or
It should be passed as a method parameter so that front end developer can decide.
darius
(Darius Jazayeri)
July 14, 2017, 5:48pm
5
Within the methods that @raff linked to you should have access to a RequestContext variable, and this should already include the representation in it.
jaks80
(Yusuf Akhond)
July 15, 2017, 8:25pm
6
I have created a jeera issue here.
https://issues.openmrs.org/browse/RESTWS-669?filter=-2
Please do the ASSESSMENT and I can commit my changes.
dkayiwa
(Daniel Kayiwa)
July 15, 2017, 8:35pm
7
Done. On the ticket, can you also add a link to this talk thread?
jaks80
(Yusuf Akhond)
July 16, 2017, 4:43pm
8
Hi @dkayiwa
I can not assign this issue to myself.
jaks80
(Yusuf Akhond)
July 16, 2017, 5:03pm
10
Hi @dkayiwa
I have created a pull request.
Thank you.
dkayiwa
(Daniel Kayiwa)
July 16, 2017, 5:26pm
11
1 Like