Skip to content

Commit ac5c1e3

Browse files
author
Caitlin Bales (MSFT)
committed
Append implicit EntitySet for Java templates
1 parent 0a9059b commit ac5c1e3

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Templates/Java/requests_generated/BaseEntityCollectionReferenceRequest.java.tt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,24 @@
2424
<#
2525
var navigationProperty = c.AsOdcmProperty().GetServiceCollectionNavigationPropertyForPropertyType();
2626
if (navigationProperty != null) {
27+
28+
//Append the singleton's navigation type to the @odata.id if relevant
29+
var implicitNavigationProperty = string.Empty;
30+
if (navigationProperty.GetType() == typeof(OdcmSingleton))
31+
implicitNavigationProperty = c.AsOdcmProperty().Name + "/";
32+
2733
String prop = c.AsOdcmProperty().GetServiceCollectionNavigationPropertyForPropertyType().Name;
2834
#>
2935
final String requestUrl = getBaseRequest().getRequestUrl().toString();
30-
final ReferenceRequestBody body = new ReferenceRequestBody(getBaseRequest().getClient().getServiceRoot() + "/<#=prop#>/" + new<#=TypeName(c)#>.id);
36+
final ReferenceRequestBody body = new ReferenceRequestBody(getBaseRequest().getClient().getServiceRoot() + "/<#=prop#>/<#=implicitNavigationProperty#>" + new<#=TypeName(c)#>.id);
3137
new <#=TypeWithReferencesRequestBuilder(c)#>(requestUrl, getBaseRequest().getClient(), /* Options */ null)
3238
.buildRequest(getBaseRequest().getOptions())
3339
.post(new<#=TypeName(c)#>, body, callback);
3440
}
3541

3642
public <#=TypeName(c)#> post(final <#=TypeName(c)#> new<#=TypeName(c)#>) throws ClientException {
3743
final String requestUrl = getBaseRequest().getRequestUrl().toString();
38-
final ReferenceRequestBody body = new ReferenceRequestBody(getBaseRequest().getClient().getServiceRoot() + "/<#=prop#>/" + new<#=TypeName(c)#>.id);
44+
final ReferenceRequestBody body = new ReferenceRequestBody(getBaseRequest().getClient().getServiceRoot() + "/<#=prop#>/<#=implicitNavigationProperty#>" + new<#=TypeName(c)#>.id);
3945
return new <#=TypeWithReferencesRequestBuilder(c)#>(requestUrl,getBaseRequest().getClient(), /* Options */ null)
4046
.buildRequest(getBaseRequest().getOptions())
4147
.post(new<#=TypeName(c)#>, body);

0 commit comments

Comments
 (0)