Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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;

...

CREATE TABLE `Template` (
  `guid` VARCHAR(60) NOT NULL,
  `studyId` VARCHAR(255) NOT NULL,
  `type` ENUM('ACCOUNT_EXISTS', 'ACCOUNT_EXISTS_SMS', 'APP_INSTALL_LINK', 'APP_INSTALL_LINK_SMS', 'EMAIL_SIGN_IN',
    'PHONE_SIGN_IN_SMS', 'RESET_PASSWORD', 'RESET_PASSWORD_SMS', 'SIGNED_CONSENT', 'SIGNED_CONSENT_SMS',
    'VERIFY_EMAIL', 'VERIFY_PHONE_SMS') NOT NULL,
  `name` VARCHAR(255) NULL,
  `criteriaKey` VARCHAR(255) NULL,
  `createdOn` BIGINT UNSIGNED NULL,
  `modifiedOn` BIGINT UNSIGNED NULL,
  `publishedCreatedOn` BIGINT UNSIGNED NULL,
  `deleted` BOOLEAN NOT NULL DEFAULT FALSE,
  `version` INT UNSIGNED NOT NULL, /* optimistic locking */
  PRIMARY KEY (`studyId`, `guid`),
  INDEX `type_set_idx` (`studyId`, `type`)
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;

CREATE TABLE `TemplateRevision` (
  `studyId` VARCHAR(255) NOT NULL,
  `guid` `templateGuid` VARCHAR(60) NOT NULL,
  `createdOn` BIGINT UNSIGNED NULL,
  `createdBy` VARCHAR(255) NOT NULL,
  `storagePath` VARCHAR(255) NOT NULL,
  `subject` VARCHAR(255) NULL,
  `mimeType` ENUM('HTML', 'TEXT') NULL,
  PRIMARY_KEY (`guid`, `createdOn`)

) CHARACTER SET utf8 COLLATE utf8_unicode_ci;

...

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.     from a SQL-type data store. */

    ForwardCursorPagedResourceList<TemplateRevision> PagedResourceList<TemplateRevision> getTemplateRevisions(StudyIdentifier studyId, String guid,

            String offsetKey int offsetBy, int pageSize);


    /**     * Get a specific revision.      */

    TemplateRevision getTemplateRevision(StudyIdentifier studyId, String guid, long createdOn);


    /**      * Create a new revision (this fails should fail if the createdOn timestamp for a given studyId and GUID already exists).      */

    CreatedOnHolder createTemplateRevision(StudyIdentifier studyId, TemplateRevision templateRevision);

}