Boiler plate when iterating through collections
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 35/100
Piste de recherche
Commencez par l’implémentation de PageIterator dans com.microsoft.graph.core.tasks.PageIterator.java, en particulier extractEntityListFromParsable et le chemin d’itération interpages, puis examinez la section PageIterator de docs/upgrade-to-v6.md. Reproduisez l’exemple générique de delta de l’issue et déterminez si les requêtes de collections et de collections delta peuvent partager un itérateur concis ; le travail est terminé lorsque le comportement pris en charge et la modification d’API requise sont clairs.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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)
- Langage dominant
- Java
- Étoiles
- 444
- Forks
- 154
- Merge moyen
- 18 h 28 min
- PR mergées (30 j)
- 4
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de microsoftgraph/msgraph-sdk-java
-
status:waiting-for-triage type:bug
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
microsoftgraph/msgraph-sdk-java#2610 ·
-
status:waiting-for-triage type:bug
Difficulté 3/5 1-2 jours Accessibilité débutants 55/100
microsoftgraph/msgraph-sdk-java#2656 ·
-
status:waiting-for-triage type:bug
Difficulté 4/5 3-5 jours Accessibilité débutants 38/100
microsoftgraph/msgraph-sdk-java#2654 ·
-
status:waiting-for-triage
Difficulté 4/5 3-5 jours Accessibilité débutants 35/100
microsoftgraph/msgraph-sdk-java#2639 ·
-
Error in PATCH onlineMeeting Ouvertestatus:waiting-for-triage type:bug
Difficulté 3/5 1-2 jours Accessibilité débutants 35/100
microsoftgraph/msgraph-sdk-java#2589 · 1 commentaire ·
Toutes les issues de microsoftgraph/msgraph-sdk-java
Issues similaires
-
executions.Query — startDate and timeRange filters are sent with inverted comparison operators Ouvertearea/plugin
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
kestra-io/plugin-kestra#190 ·
-
litertlm-android AAR ships no consumer ProGuard rules → "mid == null" SIGABRT in minified apps Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
google-ai-edge/LiteRT-LM#3739 ·
-
Add canonical URLs and a sitemap Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
integra-team-red/meet-map#249 ·
-
[Studio][Bug] Cancelled create-user dialog keeps the password and admin switch for the next attempt Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
apache/rocketmq-dashboard#5064 ·
-
Consent portal: creating a duplicate Purpose shows a generic error instead of "already exists" Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
wso2/dpdp-accelerator#287 ·