Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Any way to re-use query snippets from ds.xml?

    Hi Isomorphic,

    In our project, we create a lot of complex queries using ds.xml.
    We use a lot of variables within them (criteria, rawValue, etc.)
    However, many of the snippets have repeated section of query.

    Is there any way to create re-usable query snippets (akin to method extraction or re-usable components in programming languages)?
    I tried looking in the guide, and online, however, didn't find any info on this.

    --
    Thanks
    Pankaj

    #2
    There are a couple of ways to do this:

    1. calculate the recurring sections in Java code and use dsRequest.addToTemplateContext() to make them available to your SQL templates. Note that this means the recurring sections could not use variables, because evaluation of variables in templates is not recursive. For example, if you addToTemplateContext("recurringSnippet", someSQL) then when you use $recurringSnippet inside a SQL template, if someSQL contained eg $criteria.fieldName, that won't work. If that's an important capability, new APIs to make this possible could be added via Feature Sponsorship - it'd be a small one.

    2. pre-process your XML using whatever solution you prefer. The Dynamic DataSource Generator approach (see QuickStart Guide, beginning of Server Framework chapter) allows you to produce DataSource XML dynamically.

    Comment

    Working...
    X