Requirements
...
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;
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. Currently believing this is DDB.
...
ForwardCursorPagedResourceList<TemplateRevision> getTemplateRevisions(StudyIdentifier studyId, String guid,
String offsetKey, int pageSize);
/**
* Get a specific revision.
...
TemplateRevision getTemplateRevision(StudyIdentifier studyId, String guid, long createdOn);
/**
* Create a new revision (this fails if the createdOn timestamp already exists).
...
CreatedOnHolder createTemplateRevision(StudyIdentifier studyId, TemplateRevision templateRevision);
}