Requirements
- The ability to select templates (like the email address verification email) by criteria such as the user's language, or the version of the app;
- The ability to clearly specify the template that should be used if the criteria filtering is ambiguous (unlike app configurations where we just take the first one);
- The ability to audit changes to templates (like study consents, which create immutable revisions... just record who created the revision);
- The possibility later to create custom templates that can be used with scheduling or notifications (right now, you have to manage these outside the system and can't schedule anything);
- The possibility later to add additional documents (the privacy document has long been considered, because it's required to submit an app to the App Store);
- Should replace the templates on the study object; could conceivably replace the study consent documents as well;
...
GET /v3/templates?type=<type>
get documents of type (type parameter is required)POST /v3/templates
create new document with a single default revision with default contentGET /v3/templates/<guid>
get specific documentPOST /v3/templates/<guid>
update specific document (not revisioned, but optimistically locked)DELETE /v3/templates/<guid>?physical=true
delete specific document (logical or physical); probably just leaves revisions on S3GET /v3/templates/<guid>/revisions
get the revisions for a document (createdOn DESC) for history of editsPOST /v3/templates/<guid>/revisions
create a new revision of the given document (cannot update an existing revision)GET /v3/templates/<guid>/revisions/<createdOn>
get a specific revision of a documentPOST /v3/templates/<guid>/revisions/<createdOn>/publish
publish this revision as the revision to use when the document is selected
Notes
Selection
1) get all the documents of the required type and filter using criteria (note that this might be challenging, we'll have to add criteria filtering to a number of places...we might want to move Criteria and CriteriaContext into the RequestContext ThreadLocal);
2) if 1 and only one is filtered, return published revision of that document;
3) otherwise return the published revision for the default template specified for that type in the Study object;
We should also move the signature block into the consent template so it can be localized... although I don't think there's been a single study that has sent out a consent document in the last year or two (or three?).
TemplateService
Sorry the formatting here is difficult to read, due to Jira.
public interface TemplateService {
/**
* Given a criteria context and a template type, return all the templates that match. If one is found through a
...
TemplateService getTemplateForUser(CriteriaContext context, TemplateType type);
/** Get all the templates for a given type. (I am assuming this will not need to be paged). */
List<TemplateService> getTemplatesForType(StudyIdentifier studyId, TemplateType type);
/** Get a specific template. */
TemplateService getTemplate(StudyIdentifier studyId, String guid);
/** Create a new template. */
GuidVersionHolder createTemplate(StudyIdentifier studyId, TemplateService template);
/**
* Update a template. You can delete it logically, change the published revision of the associated document, and you
...
GuidVersionHolder updateTemplate(StudyIdentifier studyId, TemplateService template);
/** Delete a template. */
void deleteTemplate(StudyIdentifier studyId, String guid);
/** Physically delete the template (probably leaving the revisions). */
void deleteTemplatePermanently(StudyIdentifier studyId, String guid);
/** Get a page of revisions from a SQL-type data store. */
PagedResourceList<TemplateRevision> getTemplateRevisions(StudyIdentifier studyId, String guid,
int offsetBy, int pageSize);
/** Get a specific revision. */
TemplateRevision getTemplateRevision(StudyIdentifier studyId, String guid, long createdOn);
/** Create a new revision (this should fail if the createdOn timestamp for a given studyId and GUID already exists). */
CreatedOnHolder createTemplateRevision(StudyIdentifier studyId, TemplateRevision templateRevision);
}