Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recursive EntityUpdate parser #634

Closed
andrus opened this issue Jun 24, 2023 · 0 comments
Closed

Recursive EntityUpdate parser #634

andrus opened this issue Jun 24, 2023 · 0 comments
Milestone

Comments

@andrus
Copy link
Contributor

andrus commented Jun 24, 2023

While Agrest still doesn't know how to process nested updates, let's enable the parser to parse them anyways into a separate map inside parent EntityUpdate. For now this will allow the users to implement manual processing, and in the future may become a foundation of Agrest's own nested merge algorithm.

An example of manual saving of relationships:

@POST
@Path("e3")
public DataResponse<E3> create(@Context UriInfo uriInfo, EntityUpdate<E3> update) {

    DataResponse<E3> e3Response = AgJaxrs.create(E3.class, config)
            .clientParams(uriInfo.getQueryParameters())
            .syncAndSelect(update);

    int e2Id = Cayenne.intPKForObject(e3Response.getData().get(0));

    EntityUpdate<E2> e2Update = update.getToOne(E3.E2.getName());
    if (e2Update != null) {
        AgJaxrs
                .create(E2.class, config)
                .parent(E3.class, e2Id, E3.E2.getName())
                .sync(e2Update);
    }

    return e3Response;
}
@andrus andrus changed the title Nested EntityUpdate parser Recursive EntityUpdate parser Jun 24, 2023
andrus added a commit that referenced this issue Jun 24, 2023
@andrus andrus added this to the 5.0.M17 milestone Jun 24, 2023
@andrus andrus closed this as completed Jun 24, 2023
andrus added a commit that referenced this issue Jun 26, 2023
fixing generics for related updates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant