Skip to content

Commit 50a8137

Browse files
author
Caitlin Bales (MSFT)
authored
Merge pull request #87 from microsoftgraph/android-deltaLink
Android deltalink
2 parents 9bf267d + e890bfc commit 50a8137

File tree

4 files changed

+76
-0
lines changed

4 files changed

+76
-0
lines changed

Templates/Android/generated/BaseEntityCollectionRequestBuilder.java.tt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@ if (currentTypeProjection != null) {
5151
public <#=ITypeCollectionRequestBuilder(method)#> get<#=MethodName(method)#>(<#=parameterList#>) {
5252
return new <#=TypeCollectionRequestBuilder(method)#>(getRequestUrlWithAdditionalSegment("<#=MethodFullName(method)#>"), getClient(), null<#=MethodParametersValues(method)#>);
5353
}
54+
<#
55+
// Add a method to support delta query by string (opaque deltaLink)
56+
if (MethodName(method) == "Delta") {
57+
#>
58+
59+
public <#=ITypeCollectionRequestBuilder(method)#> get<#=MethodName(method)#>(final String deltaLink) {
60+
return new <#=TypeCollectionRequestBuilder(method)#>(deltaLink, getClient(), null<#=MethodParametersValues(method)#>);
61+
}
62+
<# } #>
5463
<#
5564
} else {
5665
#>

Templates/Android/generated/BaseMethodCollectionPage.java.tt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,33 @@
55
<#host.TemplateName = BaseTypeCollectionPage(c);#>
66
<#=writer.WriteHeader()#>
77
<#=CreatePackageDef(host)#>
8+
<#
9+
/**
10+
* Manual check for deltaLink
11+
* This allows for a user to get the delta link URL with which
12+
* to make future delta query calls to the service. Since it is
13+
* not surfaced in the additionalDataManager, we add it manually
14+
* to the object for easy access.
15+
*/
16+
var deltaPage = false;
17+
if (c.Name == "delta") {
18+
deltaPage = true;
19+
}
20+
#>
821

922
import com.google.gson.JsonObject;
1023
import com.google.gson.annotations.*;
1124

1225
<#=CreateClassDef(BaseTypeCollectionPage(c), "BaseCollectionPage" + CollectionPageGeneric(c), IBaseTypeCollectionPage(c))#>
1326

27+
<# if (deltaPage) { #>
28+
/**
29+
* The opaque link to query delta after the
30+
* initial request
31+
*/
32+
public String deltaLink;
33+
34+
<# } #>
1435
/**
1536
* A collection page for <#=TypeName(c)#>.
1637
*
@@ -19,5 +40,23 @@ import com.google.gson.annotations.*;
1940
*/
2041
public <#=BaseTypeCollectionPage(c)#>(final <#=BaseTypeCollectionResponse(c)#> response, final <#=ITypeCollectionRequestBuilder(c)#> builder) {
2142
super(response.value, builder);
43+
<# if (deltaPage) { #>
44+
45+
if (response.getRawObject().get("@odata.deltaLink") != null) {
46+
deltaLink = response.getRawObject().get("@odata.deltaLink").getAsString();
47+
} else {
48+
deltaLink = null;
49+
}
50+
<# } #>
51+
}
52+
<# if (deltaPage) { #>
53+
/**
54+
* The deltaLink to make future delta requests
55+
*
56+
* @return String The deltaLink URL
57+
*/
58+
public String getDeltaLink() {
59+
return deltaLink;
2260
}
61+
<# } #>
2362
}

Templates/Android/generated/IBaseEntityCollectionRequestBuilder.java.tt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ if (currentTypeProjection != null)
3636
#>
3737

3838
<#=ITypeCollectionRequestBuilder(method)#> get<#=MethodName(method)#>(<#=parameterList#>);
39+
<#
40+
// Add a method to support delta query by string (opaque deltaLink)
41+
if (MethodName(method) == "Delta") {
42+
#>
43+
44+
<#=ITypeCollectionRequestBuilder(method)#> get<#=MethodName(method)#>(final String deltaLink);
45+
<# } #>
3946
<# } else { #>
4047
<#=ITypeRequestBuilder(method)#> get<#=MethodName(method)#>(<#=parameterList#>);
4148
<#

Templates/Android/generated/IBaseMethodCollectionPage.java.tt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,29 @@
55
<#host.TemplateName = IBaseTypeCollectionPage(c);#>
66
<#=writer.WriteHeader()#>
77
<#=CreatePackageDef(host)#>
8+
<#
9+
/**
10+
* Manual check for deltaLink
11+
* This allows for a user to get the delta link URL with which
12+
* to make future delta query calls to the service. Since it is
13+
* not surfaced in the additionalDataManager, we add it manually
14+
* to the object for easy access.
15+
*/
16+
var deltaPage = false;
17+
if (c.Name == "delta") {
18+
deltaPage = true;
19+
}
20+
#>
821

922
import com.google.gson.JsonObject;
1023

1124
<#=CreateInterfaceDef(IBaseTypeCollectionPage(c), "IBaseCollectionPage" + CollectionPageGeneric(c))#>
25+
<# if (deltaPage) { #>
26+
/**
27+
* The deltaLink to make future delta requests
28+
*
29+
* @return String The deltaLink URL
30+
*/
31+
public String getDeltaLink();
32+
<# } #>
1233
}

0 commit comments

Comments
 (0)