Versioned Subsets
We'd like to implement versioned subsets: subset may be updated by the data provider and (when published) both versions should be available through Genesys.
 Obsolete subsets should not be listed by default
 Obsolete subset must point to a new version of the subset
Simple approach
The very simple approach is to add private Subset nextVersion
to the Subset
entity and then we know that a subset has been replaced if nextVersion != null
. And we can display a link to the new version.
Problem: This would only work if the new subset would be immediately published. But it has to go through review, and until the updated version is in PUBLISHED
state we do not have any mechanism to say that the old version is "current" (the latest).
Dataset approach
We have this implemented for Dataset
in DatasetVersions
(but we are not using it at the moment). Subsets are much simpler than datasets, so I suggest we try it here. We will need to introduce SubsetVersions
(similar to DatasetVersions
) and implement service methods that allow for the following:
 The owner of a subset can create a new Subset based on an existing
PUBLISHED
Subset If the existing subset is not published, reject the request.
 A new
Subset
is created inDRAFT
mode and all data is copied to the new version  The old and the new
Subset
both link toSubsetVersions
entity  When the new
Subset
is published theSubsetVersions#currentVersion
is changed to point to this version.  Queries for listing Subsets must only return latest versions:

select s from Subset s where s.current = true and s.state = 'PUBLISHED'
.  Users can still access a subset that is not current, but it is published:
loadSubset
should only check thatstate = 'PUBLISHED'
.  We cannot inner join
SubsetVersions
because we will not store that in the Elasticsearch.  The service methods must update
subset.current
when the new version isPUBLISHED
.  Only one
Subset
of all versions ofSubsetVersions
can be current. This is best achieved with a unique key onsubset.versions + subset.current
, but we have to setsubset.current = null
when the subset is not the current version.  This means that
subset.current = true
means it is the currently published version andsubset.current = null
means it is not a current version.

New Subsets
 A new subset is created as it is created now, but a
SubsetVersions
is created for as well.  The new subset has
subset.current = null
andSubsetVersions#currentVersion = null
.  When the subset is published, both these values are updated:
subset.current = true
andSubsetVersions#currentVersion = ¤tSubset
.
Unpublishing Subsets
If a PUBLISHED
subset is unpublished (by an Administrator) we have the case when:
 The subset is not current and it must not be unpublished. Reject.
 The subset is current: we need to pick a subset that is published and that can replace the current version
 If there is no other version of a subset (this is the first published version): set
subset.current = null
andSubsetVersions#currentVersion = null
 If there are other published versions of the subset (in
SubsetVersions#allVersions
) then make the youngest (bycreatedDate
) the currently published version.
 If there is no other version of a subset (this is the first published version): set