Skip to content

Commit

Permalink
Added documentation
Browse files Browse the repository at this point in the history
added documentation to new enums and some other small changes
  • Loading branch information
benzuzu committed Jun 13, 2023
1 parent 7b852e7 commit 7c8d35c
Show file tree
Hide file tree
Showing 5 changed files with 151 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,20 @@

/**
* The EmailCategory enumeration.
*
* This enum is for the Slack integration. When team member
* opens the dropdown menu, each email option should be in
* a certain category with a certain category label.
*
* The order of the constants is nontrivial. Besides TRIAL,
* they are listed in order chronologically, based on when
* we would likely send them to the user (i.e. clarify before
* deny, etc.).
*/
public enum EmailCategory {
TRIAL("Trial"),
LICENSE("License"),
CLARIFY("Clarify"),
LICENSE("License"),
DENY("Deny");

String label;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@

/**
* The EmailSubject enumeration.
*
* This enum is for the Slack integration. When team member
* selects an email option, an input modal will pop up with
* one of the below options as a default subject. See
*
* SlackService.buildModalView()
*
* for more details.
*/
public enum EmailSubject {
DEFAULT,
COMPANY
DEFAULT // "License for " + userDTO.getLicenseType().getName() + " of OncoKB"
, COMPANY // "OncoKB - " + userDTO.getCompanyName() + " license options"
}
7 changes: 2 additions & 5 deletions src/main/java/org/mskcc/cbio/oncokb/service/SlackService.java
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ private LayoutBlock buildCollapsedBlock(UserDTO userDTO, boolean trialAccountAct
sentMails.add(mailOption);
}
if (!sentMails.isEmpty()) {
sentMails = sentMails.stream().sorted((mo1, mo2) -> mo1.getCategory() == EmailCategory.DENY ? 1 : 0).collect(Collectors.toList());
sentMails = sentMails.stream().sorted(Comparator.comparing(DropdownEmailOption::getCategory)).collect(Collectors.toList());
sb.append(sentMails.get(0).getCollapsedNote().orElse(""));
sentMails.remove(0);
for (DropdownEmailOption otherSentMail : sentMails) {
Expand Down Expand Up @@ -399,9 +399,6 @@ public String getOptionValueArgument(String value) {
}

public boolean withNote(DropdownEmailOption mailOption, UserDTO userDTO, ActionId actionId) {
if (mailOption.getExpandedNote() == null)
return false;

switch (mailOption) {
case GIVE_TRIAL_ACCESS:
if (
Expand Down Expand Up @@ -442,7 +439,7 @@ private boolean isReviewed(UserDTO userDTO, ActionId actionId) {
if (userDTO.isActivated())
return true;
for (DropdownEmailOption mailOption : DropdownEmailOption.values()) {
if (mailOption.getExpandedNote() != null && withNote(mailOption, userDTO, actionId))
if (withNote(mailOption, userDTO, actionId))
return true;
}
return false;
Expand Down
11 changes: 0 additions & 11 deletions src/main/java/org/mskcc/cbio/oncokb/web/rest/slack/ActionId.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,6 @@ public static boolean isModalEmailAction(ActionId actionId) {
return false;
}

public static boolean isConfirmEmailAction(ActionId actionId) {
if (actionId == null) {
return false;
}
for (DropdownEmailOption mailOption : DropdownEmailOption.values()) {
if (actionId.equals(mailOption.getConfirmActionId().orElse(null)))
return true;
}
return false;
}

public static boolean isDropdownAction(ActionId actionId) {
if (actionId == null) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,63 @@
import java.util.Optional;

/**
* The SlackOption enumeration. This enum is for all the options
* the team can select for a license request in the Slack channel.
*
* The DropdownEmailOption enumeration. This enum is for the email
* options in the Slack dropdown menu that the team can select.
* Approval is not included as the logic is complex and unique.
*
* To add a new email option, add the following fields:
*
* REQUIRED:
* - Block blockId (the corresponding BlockId enum constant
* associated with the additional info block after email sent)
* - ActionId actionId (the corresponding ActionId enum constant
* associated with the initial selection from the menu)
* - MailType mailType (the corresponding MailType associated
* with the dropdown option)
* - EmailCategory category (the EmailCategory enum constant,
* which is the group the option goes in)
* - String dropdownKey (the name of the option in the menu)
* - String expandedNote (the string that appears in the
* additional info block after email sent)
*
* OPTIONAL:
* - Optional<ActionId> confirmActionId (the corresponding ActionId
* associated with confirming the dispatch of email in input modal.
* This property is REQUIRED if the email uses an input modal.)
* - List<LicenseType> specificLicenses (the specific license(s)
* where the option should show up at all. Used if given email
* will only need to be sent to certain license(s).)
* - boolean notModalEmail (if the email option doesn't prompt an
* input modal. Is 'false' by default.)
* - Optional<String> modalTitle (the title of the input modal
* when option is selected. This property is encouraged if the
* email option uses an input modal.)
* - Optional<EmailSubject> modalSubject (the default subject of
* the input modal. Defaults to EmailSubject.DEFAULT if not defined.)
* - Optional<String> collapsedNote (the string that appears in the
* collapsed block after email sent. This property is REQUIRED if the
* email option does not grant a token to the user.)
*
* To add a new property to this enum, add a new variable to both the
* Builder and the enum, as well as a builder function in the static
* Builder class and a getter function in the enum.
*
*
* The following template can be used to add a new option:
*
, EMAIL_OPTION(new DropdownEmailOptionBuilder()
.blockId(BlockId)
.actionId(ActionId)
.confirmActionId(ActionId)
.mailType(MailType)
.category(EmailCategory)
.specificLicense(LicenseType)
.dropdownKey("")
.modalTitle("")
.modalSubject(EmailSubject)
.collapsedNote("")
.expandedNote(""))
*
*/
public enum DropdownEmailOption {
GIVE_TRIAL_ACCESS(new DropdownEmailOptionBuilder()
Expand Down Expand Up @@ -119,6 +172,79 @@ public enum DropdownEmailOption {
.expandedNote("The user has been rejected due to alumni email address."))
;

// blockId/actionId
private BlockId blockId;
private ActionId actionId;
private Optional<ActionId> confirmActionId;
// Email
private MailType mailType;
// Dropdown menu
private EmailCategory category;
private List<LicenseType> specificLicenses;
private String dropdownKey;
// View modal
private boolean notModalEmail;
private Optional<String> modalTitle;
private Optional<EmailSubject> modalSubject;
// Additional info block
private Optional<String> collapsedNote;
private String expandedNote;

DropdownEmailOption(DropdownEmailOptionBuilder builder) {
this.blockId = builder.blockId;
this.actionId = builder.actionId;
this.confirmActionId = builder.confirmActionId;
this.mailType = builder.mailType;
this.category = builder.category;
this.specificLicenses = builder.specificLicenses;
this.dropdownKey = builder.dropdownKey;
this.notModalEmail = builder.notModalEmail;
this.modalTitle = builder.modalTitle;
this.modalSubject = builder.modalSubject;
this.collapsedNote = builder.collapsedNote;
this.expandedNote = builder.expandedNote;
}

public BlockId getBlockId() {
return blockId;
}

public ActionId getActionId() {
return actionId;
}

public Optional<ActionId> getConfirmActionId() {
return confirmActionId;
}

public MailType getMailType() {
return mailType;
}

public EmailCategory getCategory() { return category; }

public List<LicenseType> getSpecificLicenses() { return specificLicenses; }

public String getDropdownKey() {
return dropdownKey;
}

public boolean isNotModalEmail() { return notModalEmail; }

public Optional<String> getModalTitle() {
return modalTitle;
}

public Optional<EmailSubject> getModalSubject() {
return modalSubject;
}

public Optional<String> getCollapsedNote() {
return collapsedNote;
}

public String getExpandedNote() { return expandedNote;}


private static class DropdownEmailOptionBuilder {
// blockId/actionId
Expand Down Expand Up @@ -199,77 +325,4 @@ public DropdownEmailOptionBuilder expandedNote(String expandedNote) {
return this;
}
}

// blockId/actionId
private BlockId blockId;
private ActionId actionId;
private Optional<ActionId> confirmActionId;
// Email
private MailType mailType;
// Dropdown menu
private EmailCategory category;
private List<LicenseType> specificLicenses;
private String dropdownKey;
// View modal
private boolean notModalEmail;
private Optional<String> modalTitle;
private Optional<EmailSubject> modalSubject;
// Additional info block
private Optional<String> collapsedNote;
private String expandedNote;

DropdownEmailOption(DropdownEmailOptionBuilder builder) {
this.blockId = builder.blockId;
this.actionId = builder.actionId;
this.confirmActionId = builder.confirmActionId;
this.mailType = builder.mailType;
this.category = builder.category;
this.specificLicenses = builder.specificLicenses;
this.dropdownKey = builder.dropdownKey;
this.notModalEmail = builder.notModalEmail;
this.modalTitle = builder.modalTitle;
this.modalSubject = builder.modalSubject;
this.collapsedNote = builder.collapsedNote;
this.expandedNote = builder.expandedNote;
}

public BlockId getBlockId() {
return blockId;
}

public ActionId getActionId() {
return actionId;
}

public Optional<ActionId> getConfirmActionId() {
return confirmActionId;
}

public MailType getMailType() {
return mailType;
}

public EmailCategory getCategory() { return category; }

public List<LicenseType> getSpecificLicenses() { return specificLicenses; }

public String getDropdownKey() {
return dropdownKey;
}

public boolean isNotModalEmail() { return notModalEmail; }

public Optional<String> getModalTitle() {
return modalTitle;
}

public Optional<EmailSubject> getModalSubject() {
return modalSubject;
}

public Optional<String> getCollapsedNote() {
return collapsedNote;
}

public String getExpandedNote() { return expandedNote;}
}

0 comments on commit 7c8d35c

Please sign in to comment.