Skip to content

Commit bc530be

Browse files
author
Caitlin Bales (MSFT)
authored
Merge pull request #34 from microsoftgraph/planner-helpers
Planner helpers
2 parents 7677ace + 6d65b37 commit bc530be

16 files changed

+336
-119
lines changed

src/main/java/com/microsoft/graph/models/extensions/PlannerAppliedCategories.java

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,55 @@
44

55
package com.microsoft.graph.models.extensions;
66

7-
import com.microsoft.graph.concurrency.*;
8-
import com.microsoft.graph.core.*;
9-
import com.microsoft.graph.models.extensions.*;
10-
import com.microsoft.graph.models.generated.*;
11-
import com.microsoft.graph.http.*;
12-
import com.microsoft.graph.requests.extensions.*;
13-
import com.microsoft.graph.requests.generated.*;
14-
import com.microsoft.graph.options.*;
15-
import com.microsoft.graph.serializer.*;
16-
17-
import java.util.Arrays;
18-
import java.util.EnumSet;
7+
import com.google.gson.annotations.Expose;
8+
import com.google.gson.annotations.SerializedName;
9+
import com.microsoft.graph.models.generated.BasePlannerAppliedCategories;
1910

2011
// This file is available for extending, afterwards please submit a pull request.
2112

2213
/**
2314
* The class for the Planner Applied Categories.
2415
*/
2516
public class PlannerAppliedCategories extends BasePlannerAppliedCategories {
26-
17+
/**
18+
* The Category1
19+
*/
20+
@SerializedName("category1")
21+
@Expose
22+
public boolean category1;
23+
24+
/**
25+
* The Category1
26+
*/
27+
@SerializedName("category2")
28+
@Expose
29+
public boolean category2;
30+
31+
/**
32+
* The Category1
33+
*/
34+
@SerializedName("category3")
35+
@Expose
36+
public boolean category3;
37+
38+
/**
39+
* The Category1
40+
*/
41+
@SerializedName("category4")
42+
@Expose
43+
public boolean category4;
44+
45+
/**
46+
* The Category1
47+
*/
48+
@SerializedName("category5")
49+
@Expose
50+
public boolean category5;
51+
52+
/**
53+
* The Category1
54+
*/
55+
@SerializedName("category6")
56+
@Expose
57+
public boolean category6;
2758
}

src/main/java/com/microsoft/graph/models/extensions/PlannerAssignedToTaskBoardTaskFormat.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
package com.microsoft.graph.models.extensions;
66

7+
import com.google.gson.annotations.Expose;
8+
import com.google.gson.annotations.SerializedName;
79
import com.microsoft.graph.concurrency.*;
810
import com.microsoft.graph.core.*;
911
import com.microsoft.graph.models.extensions.*;
@@ -24,4 +26,19 @@
2426
*/
2527
public class PlannerAssignedToTaskBoardTaskFormat extends BasePlannerAssignedToTaskBoardTaskFormat {
2628

29+
/**
30+
* The Etag.
31+
*/
32+
@SerializedName("@odata.etag")
33+
@Expose
34+
public String etag;
35+
36+
/**
37+
* The GetOrderHintForAssignee
38+
*/
39+
public String orderHintForAssignee(String userId)
40+
{
41+
String orderHints = this.orderHintsByAssignee.get(userId);
42+
return (orderHints != null) ? orderHints : this.unassignedOrderHint;
43+
}
2744
}

src/main/java/com/microsoft/graph/models/extensions/PlannerBucket.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
package com.microsoft.graph.models.extensions;
66

7+
import com.google.gson.annotations.Expose;
8+
import com.google.gson.annotations.SerializedName;
79
import com.microsoft.graph.concurrency.*;
810
import com.microsoft.graph.core.*;
911
import com.microsoft.graph.models.extensions.*;
@@ -23,5 +25,10 @@
2325
* The class for the Planner Bucket.
2426
*/
2527
public class PlannerBucket extends BasePlannerBucket {
26-
28+
/**
29+
* The Etag.
30+
*/
31+
@SerializedName("@odata.etag")
32+
@Expose
33+
public String etag;
2734
}

src/main/java/com/microsoft/graph/models/extensions/PlannerBucketTaskBoardTaskFormat.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
package com.microsoft.graph.models.extensions;
66

7+
import com.google.gson.annotations.Expose;
8+
import com.google.gson.annotations.SerializedName;
79
import com.microsoft.graph.concurrency.*;
810
import com.microsoft.graph.core.*;
911
import com.microsoft.graph.models.extensions.*;
@@ -24,4 +26,10 @@
2426
*/
2527
public class PlannerBucketTaskBoardTaskFormat extends BasePlannerBucketTaskBoardTaskFormat {
2628

29+
/**
30+
* The Etag.
31+
*/
32+
@SerializedName("@odata.etag")
33+
@Expose
34+
public String etag;
2735
}

src/main/java/com/microsoft/graph/models/extensions/PlannerChecklistItems.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
package com.microsoft.graph.models.extensions;
66

7+
import com.google.gson.JsonPrimitive;
78
import com.microsoft.graph.concurrency.*;
89
import com.microsoft.graph.core.*;
910
import com.microsoft.graph.models.extensions.*;
@@ -16,12 +17,29 @@
1617

1718
import java.util.Arrays;
1819
import java.util.EnumSet;
20+
import java.util.UUID;
1921

2022
// This file is available for extending, afterwards please submit a pull request.
2123

2224
/**
2325
* The class for the Planner Checklist Items.
2426
*/
2527
public class PlannerChecklistItems extends BasePlannerChecklistItems {
28+
/**
29+
* Create a new checklist item with the given title
30+
* @param title Title of the checklist item
31+
* @return The ID of the checklist item
32+
*/
33+
public String addChecklistItem(String title) {
34+
PlannerChecklistItem plannerChecklistItem = new PlannerChecklistItem();
35+
plannerChecklistItem.title = title;
36+
String newChecklistItemId = UUID.randomUUID().toString();
37+
38+
ISerializer serializer = this.getSerializer();
39+
String serializedItem = serializer.serializeObject(plannerChecklistItem);
2640

41+
this.additionalDataManager().put(newChecklistItemId, new JsonPrimitive(serializedItem));
42+
43+
return newChecklistItemId;
44+
}
2745
}

src/main/java/com/microsoft/graph/models/extensions/PlannerExternalReferences.java

Lines changed: 80 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,93 @@
44

55
package com.microsoft.graph.models.extensions;
66

7-
import com.microsoft.graph.concurrency.*;
8-
import com.microsoft.graph.core.*;
9-
import com.microsoft.graph.models.extensions.*;
7+
import com.google.gson.JsonElement;
108
import com.microsoft.graph.models.generated.*;
11-
import com.microsoft.graph.http.*;
12-
import com.microsoft.graph.requests.extensions.*;
13-
import com.microsoft.graph.requests.generated.*;
14-
import com.microsoft.graph.options.*;
159
import com.microsoft.graph.serializer.*;
1610

17-
import java.util.Arrays;
18-
import java.util.EnumSet;
19-
11+
import java.security.InvalidParameterException;
2012
// This file is available for extending, afterwards please submit a pull request.
2113

2214
/**
2315
* The class for the Planner External References.
2416
*/
2517
public class PlannerExternalReferences extends BasePlannerExternalReferences {
26-
18+
/*
19+
* Specifies the character - encoding pairs to apply on the external reference URLs
20+
*/
21+
private static String[][] conversions = { { "%", "%25" }, { "@", "%40" }, { ".", "%2E" }, { ":", "%3A" } };
22+
23+
/**
24+
* Gets external reference data for a given reference URL
25+
* @param url The external reference URL
26+
* @return The external reference
27+
*/
28+
public PlannerExternalReference reference(String url) {
29+
if (url == null || url.isEmpty()) {
30+
throw new InvalidParameterException("URL cannot be empty");
31+
}
32+
if (this.additionalDataManager().containsKey(encode(url))) {
33+
JsonElement refObject = this.additionalDataManager().get(encode(url));
34+
ISerializer serializer = this.getSerializer();
35+
return serializer.deserializeObject(
36+
refObject.getAsString(),
37+
PlannerExternalReference.class
38+
);
39+
} else {
40+
return null;
41+
}
42+
}
43+
44+
/**
45+
* Adds a new external reference with the given URL and short name
46+
* @param url URL of the external reference
47+
* @param alias Short name for the external reference
48+
* @return The created external reference
49+
*/
50+
public PlannerExternalReference addReference(String url, String alias) {
51+
if (url == null || url.isEmpty()) {
52+
throw new InvalidParameterException("URL cannot be empty");
53+
}
54+
if (alias == null || alias.isEmpty()) {
55+
throw new InvalidParameterException("Alias cannot be empty");
56+
}
57+
58+
PlannerExternalReference plannerExternalReference = new PlannerExternalReference();
59+
plannerExternalReference.alias = alias;
60+
this.additionalDataManager().put(encode(url), plannerExternalReference.getRawObject());
61+
return plannerExternalReference;
62+
}
63+
64+
/**
65+
* Encodes the URL of an external reference to be compatible with OData property naming requirements
66+
* @param externalReferenceUrl URL to encode
67+
* @return Encoded URL
68+
*/
69+
private static String encode(String externalReferenceUrl) {
70+
if (externalReferenceUrl == null || externalReferenceUrl.isEmpty()) {
71+
throw new InvalidParameterException("URL cannot be empty");
72+
}
73+
74+
for (int i = 0; i < conversions.length; i++)
75+
{
76+
externalReferenceUrl = externalReferenceUrl.replace(conversions[i][0], conversions[i][1]);
77+
}
78+
return externalReferenceUrl;
79+
}
80+
81+
/**
82+
* Decodes an encoded URL of an external reference
83+
* @param externalReferenceUrl URL to encode
84+
* @return Decoded URL
85+
*/
86+
private static String decode(String externalReferenceUrl) {
87+
if (externalReferenceUrl == null || externalReferenceUrl.isEmpty()) {
88+
throw new InvalidParameterException("URL cannot be empty");
89+
}
90+
91+
for (int i = conversions.length - 1; i >= 0; i--) {
92+
externalReferenceUrl = externalReferenceUrl.replace(conversions[i][1], conversions[i][0]);
93+
}
94+
return externalReferenceUrl;
95+
}
2796
}

src/main/java/com/microsoft/graph/models/extensions/PlannerPlanDetails.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
package com.microsoft.graph.models.extensions;
66

7+
import com.google.gson.annotations.Expose;
8+
import com.google.gson.annotations.SerializedName;
79
import com.microsoft.graph.concurrency.*;
810
import com.microsoft.graph.core.*;
911
import com.microsoft.graph.models.extensions.*;
@@ -24,4 +26,10 @@
2426
*/
2527
public class PlannerPlanDetails extends BasePlannerPlanDetails {
2628

29+
/**
30+
* The Etag.
31+
*/
32+
@SerializedName("@odata.etag")
33+
@Expose
34+
public String etag;
2735
}

src/main/java/com/microsoft/graph/models/extensions/PlannerProgressTaskBoardTaskFormat.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
package com.microsoft.graph.models.extensions;
66

7+
import com.google.gson.annotations.Expose;
8+
import com.google.gson.annotations.SerializedName;
79
import com.microsoft.graph.concurrency.*;
810
import com.microsoft.graph.core.*;
911
import com.microsoft.graph.models.extensions.*;
@@ -24,4 +26,10 @@
2426
*/
2527
public class PlannerProgressTaskBoardTaskFormat extends BasePlannerProgressTaskBoardTaskFormat {
2628

29+
/**
30+
* The Etag.
31+
*/
32+
@SerializedName("@odata.etag")
33+
@Expose
34+
public String etag;
2735
}

src/main/java/com/microsoft/graph/models/extensions/PlannerTask.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
package com.microsoft.graph.models.extensions;
66

7+
import com.google.gson.annotations.Expose;
8+
import com.google.gson.annotations.SerializedName;
79
import com.microsoft.graph.concurrency.*;
810
import com.microsoft.graph.core.*;
911
import com.microsoft.graph.models.extensions.*;
@@ -24,4 +26,10 @@
2426
*/
2527
public class PlannerTask extends BasePlannerTask {
2628

29+
/**
30+
* The Etag.
31+
*/
32+
@SerializedName("@odata.etag")
33+
@Expose
34+
public String etag;
2735
}

src/main/java/com/microsoft/graph/models/extensions/PlannerTaskDetails.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
package com.microsoft.graph.models.extensions;
66

7+
import com.google.gson.annotations.Expose;
8+
import com.google.gson.annotations.SerializedName;
79
import com.microsoft.graph.concurrency.*;
810
import com.microsoft.graph.core.*;
911
import com.microsoft.graph.models.extensions.*;
@@ -24,4 +26,10 @@
2426
*/
2527
public class PlannerTaskDetails extends BasePlannerTaskDetails {
2628

29+
/**
30+
* The Etag.
31+
*/
32+
@SerializedName("@odata.etag")
33+
@Expose
34+
public String etag;
2735
}

0 commit comments

Comments
 (0)