Boiler plate when iterating through collections
まだ誰も着手していません。
評価
調査の方向性
com.microsoft.graph.core.tasks.PageIterator.java の PageIterator 実装から始め、特に extractEntityListFromParsable とページ間の反復処理パスを確認してから、docs/upgrade-to-v6.md の PageIterator セクションを確認してください。Issue にある汎用的な delta の例を再現し、コレクション要求と delta コレクション要求で簡潔なイテレーターを共有できるかどうかを判断してください。対応している動作と必要な API 変更が明確になれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Hello, i have a small question.
https://github.com/microsoftgraph/msgraph-sdk-java/blob/dev/docs/upgrade-to-v6.md#pageiterator
- With the new page iterator there is a boilerplate associated with each request and iterating through it. Since a new page iterator would need to be created for each request.
- I was wondering if there is a generic way to create an iterator to run on collection requests and delta collection requests.
So I created this code, from looking at the generated code in the msft graph sdk:
public static <T extends Parsable> void genericIterator(
GraphServiceClient graphClient,
BaseDeltaFunctionResponse res,
Consumer<T> processEntity,
Consumer<String> processDeltaLink) {
PageIterator<T, BaseDeltaFunctionResponse> pageIterator;
try {
pageIterator = new PageIterator.Builder<T, BaseDeltaFunctionResponse>()
.client(graphClient)
.collectionPage(res)
.collectionPageFactory(BaseDeltaFunctionResponse::createFromDiscriminatorValue)
.processPageItemCallback(entity -> {
processEntity.accept(entity);
return true;
}).build();
pageIterator.iterate();
processDeltaLink.accept(pageIterator.getDeltaLink());
} catch (ApiException | ReflectiveOperationException e) {
log.error("Error ", e);
}
}
public static <T extends Parsable> void genericIterator(
GraphServiceClient graphClient,
BaseCollectionPaginationCountResponse res,
Consumer<T> processGroupOwner) {
PageIterator<T, BaseCollectionPaginationCountResponse> pageIterator;
try {
pageIterator = new PageIterator.Builder<T, BaseCollectionPaginationCountResponse>()
.client(graphClient)
.collectionPage(res)
.collectionPageFactory(BaseCollectionPaginationCountResponse::createFromDiscriminatorValue)
.processPageItemCallback(entity -> {
processGroupOwner.accept(entity);
return true;
}).build();
pageIterator.iterate();
} catch (ApiException | ReflectiveOperationException e) {
log.error("Error ", e);
}
}
This second method works with general collectors, but not the first one for delta collections.
I was wondering if this is even recommending considering that the sdk is based on code generations and/or if there is a way to iterate over collections in a more concise manner than the current page iterator.
Error received from the generic delta collection iterator:
DeltaGetResponse res2 = graphServiceClient.groups().delta().get();
genericIterator(graphServiceClient, res2, (Group group) -> {
log.info("Group: {} {}", group.getId(), group.getDisplayName());
}, (String deltaLink) -> {
log.info("DeltaLink: {}", deltaLink);
});
java.lang.IllegalAccessException: NO_COLLECTION_PROPERTY_ERROR
at com.microsoft.graph.core.tasks.PageIterator.extractEntityListFromParsable(PageIterator.java:300)
at com.microsoft.graph.core.tasks.PageIterator.interpageIterate(PageIterator.java:250)
at com.microsoft.graph.core.tasks.PageIterator.iterate(PageIterator.java:272)
- 主要言語
- Java
- スター
- 444
- フォーク
- 154
- 平均マージ
- 18時間 28分
- マージ済み PR(30日)
- 4
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoftgraph/msgraph-sdk-java のほかの issue
-
status:waiting-for-triage type:bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
microsoftgraph/msgraph-sdk-java#2610 ·
-
status:waiting-for-triage type:bug
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
microsoftgraph/msgraph-sdk-java#2656 ·
-
status:waiting-for-triage type:bug
難易度 4/5 3〜5日 初心者へのやさしさ 38/100
microsoftgraph/msgraph-sdk-java#2654 ·
-
status:waiting-for-triage
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
microsoftgraph/msgraph-sdk-java#2639 ·
-
status:waiting-for-triage type:bug
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
microsoftgraph/msgraph-sdk-java#2589 · コメント 1 件 ·
microsoftgraph/msgraph-sdk-java の issue をすべて見る
似ている issue
-
certification
難易度 1/5 1時間未満 初心者へのやさしさ 80/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
[BUG] ECR GetAuthorizationToken returns a proxyEndpoint for the default region, not the request's オープンbug ecr
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
Needs: Triage Type: Feature request
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
AntennaPod/AntennaPod#8794 ·
-
agentic-workflows
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
github/copilot-sdk#2760 ·