What sort of things do we want to be able to search for? Documents for which translated variants are not up to date or are missing (and the inverse: are up to date and exist)
With the new attributes, we can do this. Suppose a reference variant EN and translated variant FR, than searching for out of date FR variants comes down to (logically):
FR.last_synced_with_version < EN.last_content_change_version
However, this does not mean that all the out-of-date documents require that translation should be performed: it is possible that the author of the EN variant is creating intermediate versions and does not yet consider his text ready to send to the translator. How could this intention be expressed? Maybe with another attribute on version: 'want_translation'?
From another point of view, we could assume that if any translations need to be performed, than workflows need to be created for them, and we can query the workflow engine to see the state of open translation workflows.
Once we have more clarity on the above, we can think about the concrete Daisy query language constructs to add.
Let's suppose we add a new predefined 'condition' (= sort-of-expression evaluating to true/false) to the query language, called outOfDate(). For the distinction of live or last versions which are out of date, we could either add a parameter or make two conditions: thus outOfDate('live/last') versus lliveOutOfDate() and lastOutOfDate().
Using outOfDate(), we can search for e.g. french language variants which are out of date:
select id, name where language = 'fr' and outOfDate()
Same but also include documents missing the french variant:
select id, name where ( branch = 'main' and language = 'fr' and outOfDate() ) or DoesNotHaveVariant('main', 'fr')
The implementation of the outOfDate() condition would be as follows:
- suppose current document_variants table join has alias 'dvc'
(codewise, this is obtained from SqlGenerationContext.getDocumentVariantsTable().getName())
- create new join with document_variants table (further refered to with alias 'dvx') where branch is dvc.branch_id and language is dvc.last_synced_with_variant
- add condition dvc.last_synced_with_version < dvx.last_content_change_version
- in all of the above, 'last' can also be switched by 'live'
A condition is an implementation of PredicateExpr, current examples are InCollection, LinksToOrFrom, HasPart, DoesNotHaveVariant. The queryparser.jj needs to be adjusted to support the new condition.
Similarly, it is possible to implement an "upToDate()" and an "DoesHaveVariant()" (currently, only DoesNotHaveVariant() exists).