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

Add view context reference for entity views #202

Closed
Mobe91 opened this issue Apr 6, 2016 · 2 comments
Closed

Add view context reference for entity views #202

Mobe91 opened this issue Apr 6, 2016 · 2 comments
Assignees
Milestone

Comments

@Mobe91
Copy link
Contributor

@Mobe91 Mobe91 commented Apr 6, 2016

When dealing with subviews containing subqueries, it would be useful to be able to refer to the subview's context root. This fosters the independence of entity views from the view hierarchy they are used in as subquery providers can be implemented without knowing the view hierarchy. Consider the following example:

@EntityView(DocumentVersion.class)
public interface DocumentVersionView {
   DocumentView getDocument();
}

@EntityView(Document.class)
public interface DocumentView {
  @MappingSubquery(MyUselessSubqueryProvider.class)
  public List<UselessStuff> getMeUselessStuff();

  public static class MyUselessSubqueryProvider implements SubqueryProvider {
     createSubquery(SubqueryInitiator init) {
         init.from(UselessStuff.class, "useless")
              .where("useless.documentId").eqExpression("OUTER(document.id)"); // we have to know that we are nested in DocumentVersionView

//           .where("useless.documentId").eqExpression("VIEW_ROOT(id)");  -- VIEW_ROOT implicitely resolves to OUTER(document) context - the root of the DocumentView view.
     }
  }
}

The introduction of the VIEW_ROOT keyword for this purpose is a suggestion as it is quite intuitive in my opinion. Of course, we can decide for a different term as well.

@beikov beikov self-assigned this Aug 2, 2016
@beikov beikov added this to the 1.2.0 milestone Aug 2, 2016
@beikov
Copy link
Member

@beikov beikov commented Sep 6, 2016

Note that this is related to #218 as the VIEW_ROOT would have to resolve to the "custom root"

Loading

@beikov
Copy link
Member

@beikov beikov commented Sep 6, 2016

@Mobe91 Do you think we can dynamically add the additional functions to the parser?
I'd like to make the core independent of the entity view related functions.
I am imagining something like expressionFactory.createSimpleExpression("ABC(somePath)", Arrays.asList("ABC")) which would normally be illegal as ABC is not in the grammar.

This would allow us to properly parse the expression and then replace it with whatever we want.

Loading

@beikov beikov closed this in af0ee2e Sep 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants