Skip to content

Commit bc7bb8a

Browse files
jfkonecndependabot[bot]zhx828bprize15calvinlu3
authored
Feature/company license (#1164)
* Modify company data schema to include licensing details (#1146) * Added termination warning email button (#1151) * Added endpoints to send company notification email (#1152) * Bump elliptic from 6.5.2 to 6.5.7 Bumps [elliptic](https://github.com/indutny/elliptic) from 6.5.2 to 6.5.7. - [Commits](indutny/elliptic@v6.5.2...v6.5.7) --- updated-dependencies: - dependency-name: elliptic dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> * allow keypress events for textareas * Fix data download (#1162) * User is granted API access on approval (#1163) * Added endpoints to send notification email * Data version is now displayed (#1165) * Addressed PR comments * Updated Setup Java in Git Actions (#1166) --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Hongxin <[email protected]> Co-authored-by: bprize15 <[email protected]> Co-authored-by: bprize15 <[email protected]> Co-authored-by: Calvin Lu <[email protected]> --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Hongxin <[email protected]> Co-authored-by: bprize15 <[email protected]> Co-authored-by: bprize15 <[email protected]> Co-authored-by: Calvin Lu <[email protected]>
1 parent 7f1512b commit bc7bb8a

34 files changed

+1609
-78
lines changed

.jhipster/Company.json

+5
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@
4242
{
4343
"fieldName": "legalContact",
4444
"fieldType": "String"
45+
},
46+
{
47+
"fieldName": "additionalInfo",
48+
"fieldType": "byte[]",
49+
"fieldTypeBlobContent": "text"
4550
}
4651
],
4752
"relationships": [

jhipster-jdl.jdl

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ entity Company {
4040
licenseStatus LicenseStatus required,
4141
businessContact String,
4242
legalContact String,
43+
additionalInfo TextBlob
4344
}
4445

4546
entity CompanyDomain {
Loading

screenshot-test/data/api-companies.json

+24-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,18 @@
1010
"businessContact": "Representative",
1111
"legalContact": "override orchid reboot",
1212
"companyDomains": ["oncokb.org"],
13-
"numberOfUsers": 0
13+
"numberOfUsers": 0,
14+
"additionalInfo": {
15+
"license": {
16+
"termination": {
17+
"date": "2025-09-21",
18+
"notes": "notes",
19+
"notificationDays": 3433
20+
},
21+
"autoRenewal": false,
22+
"activation": "2024-09-28"
23+
}
24+
}
1425
},
1526
{
1627
"id": 2,
@@ -23,6 +34,17 @@
2334
"businessContact": "Steel Configuration Designer",
2435
"legalContact": "system engine Australian Dollar",
2536
"companyDomains": ["mskcc.org"],
26-
"numberOfUsers": 3
37+
"numberOfUsers": 3,
38+
"additionalInfo": {
39+
"license": {
40+
"termination": {
41+
"date": "2025-09-21",
42+
"notes": "notes",
43+
"notificationDays": 3433
44+
},
45+
"autoRenewal": false,
46+
"activation": "2024-09-28"
47+
}
48+
}
2749
}
2850
]

screenshot-test/data/api-company-details.json

+12-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,16 @@
99
"businessContact": "Representative",
1010
"legalContact": "override orchid reboot",
1111
"companyDomains": ["oncokb.org"],
12-
"numberOfUsers": 0
12+
"numberOfUsers": 0,
13+
"additionalInfo": {
14+
"license": {
15+
"termination": {
16+
"date": "2024-09-21",
17+
"notes": "notes",
18+
"notificationDays": 3433
19+
},
20+
"autoRenewal": false,
21+
"activation": "2024-09-28"
22+
}
23+
}
1324
}

src/main/java/org/mskcc/cbio/oncokb/config/application/ApplicationProperties.java

-1
Original file line numberDiff line numberDiff line change
@@ -188,5 +188,4 @@ public RecaptchaProperties getRecaptcha() {
188188
public void setRecaptcha(RecaptchaProperties recaptcha) {
189189
this.recaptcha = recaptcha;
190190
}
191-
192191
}

src/main/java/org/mskcc/cbio/oncokb/domain/Company.java

+18
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ public class Company implements Serializable {
6666
@Column(name = "legal_contact", length = 255)
6767
private String legalContact;
6868

69+
@Lob
70+
@Column(name = "additional_info")
71+
private String additionalInfo;
72+
6973
@ManyToMany(fetch = FetchType.EAGER, cascade = {CascadeType.PERSIST, CascadeType.MERGE})
7074
@JoinTable(name = "company_company_domain",
7175
joinColumns = @JoinColumn(name = "company_id", referencedColumnName = "id"),
@@ -185,6 +189,19 @@ public void setLegalContact(String legalContact) {
185189
this.legalContact = legalContact;
186190
}
187191

192+
public String getAdditionalInfo() {
193+
return additionalInfo;
194+
}
195+
196+
public Company additionalInfo(String additionalInfo) {
197+
this.additionalInfo = additionalInfo;
198+
return this;
199+
}
200+
201+
public void setAdditionalInfo(String additionalInfo) {
202+
this.additionalInfo = additionalInfo;
203+
}
204+
188205
public Set<CompanyDomain> getCompanyDomains() {
189206
return companyDomains;
190207
}
@@ -240,6 +257,7 @@ public String toString() {
240257
", licenseStatus='" + getLicenseStatus() + "'" +
241258
", businessContact='" + getBusinessContact() + "'" +
242259
", legalContact='" + getLegalContact() + "'" +
260+
", additionalInfo='" + getAdditionalInfo() + "'" +
243261
"}";
244262
}
245263
}

src/main/java/org/mskcc/cbio/oncokb/domain/enumeration/MailType.java

+3
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ public enum MailType {
119119
, LIST_OF_UNAPPROVED_USERS(new MailTypeBuilder()
120120
.templateName("listOfUnapprovedUsers")
121121
.description("List of unapproved users"))
122+
, TERMINATION_NOTIFICATION_EMAIL(new MailTypeBuilder()
123+
.templateName("terminationNotificationEmail")
124+
.description("Notifies admins about companies with licenses about to expire"))
122125
, TEST(new MailTypeBuilder()
123126
.templateName("testEmail")
124127
.description("Test"))

src/main/java/org/mskcc/cbio/oncokb/repository/CompanyRepository.java

+3
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,7 @@ public interface CompanyRepository extends JpaRepository<Company, Long> {
2424

2525
@Cacheable(cacheResolver = "companyCacheResolver")
2626
Optional<Company> findOneByNameIgnoreCase(String name);
27+
28+
@Query("select c from Company c where c.id in ?1")
29+
List<Company> findCompaniesByIds(List<Long> ids);
2730
}

src/main/java/org/mskcc/cbio/oncokb/service/CompanyService.java

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.mskcc.cbio.oncokb.service;
22

3+
import org.mskcc.cbio.oncokb.domain.Company;
34
import org.mskcc.cbio.oncokb.domain.enumeration.LicenseStatus;
45
import org.mskcc.cbio.oncokb.service.dto.CompanyDTO;
56
import org.mskcc.cbio.oncokb.web.rest.vm.CompanyVM;
@@ -58,4 +59,7 @@ public interface CompanyService {
5859
* @param id the id of the entity.
5960
*/
6061
void delete(Long id);
62+
63+
64+
List<CompanyDTO> findCompaniesByIds(List<Long> ids);
6165
}

src/main/java/org/mskcc/cbio/oncokb/service/MailService.java

+30
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.mskcc.cbio.oncokb.domain.Company;
1111
import org.mskcc.cbio.oncokb.domain.UserMessagePair;
1212
import org.mskcc.cbio.oncokb.domain.enumeration.MailType;
13+
import org.mskcc.cbio.oncokb.service.dto.TerminationEmailDTO;
1314
import org.mskcc.cbio.oncokb.service.dto.UserDTO;
1415
import org.mskcc.cbio.oncokb.service.dto.UserMailsDTO;
1516
import org.mskcc.cbio.oncokb.web.rest.vm.ExposedToken;
@@ -85,6 +86,20 @@ private UnknownMailTypeException() {
8586
}
8687
}
8788

89+
public void sendEmail(TerminationEmailDTO dto) throws MessagingException {
90+
log.debug("Send email to company ID '{}' with subject '{}' and content={}",
91+
dto.getCompanyId(), dto.getSubject(), dto.getContent());
92+
93+
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
94+
MimeMessageHelper message = new MimeMessageHelper(mimeMessage, false, StandardCharsets.UTF_8.name());
95+
message.setFrom(dto.getFrom());
96+
message.setBcc(dto.getBcc().split(";"));
97+
message.setCc(dto.getCc().split(";"));
98+
message.setSubject(dto.getSubject());
99+
message.setText(dto.getContent(), false);
100+
javaMailSender.send(mimeMessage);
101+
}
102+
88103
@Async
89104
public void sendEmail(String to, String from, String cc, String subject, String content, List<String> attachmentFilesNames, boolean isMultipart, boolean isHtml) throws MessagingException {
90105
log.debug("Send email[multipart '{}' and html '{}'] to '{}' with subject '{}' and content={}",
@@ -236,6 +251,21 @@ public void sendEmailFromTemplate(UserDTO user, MailType mailType, String subjec
236251
}
237252
}
238253

254+
public void sendInternalEmailFromTemplate(MailType mailType, String subject, String to, Context additionalContext) {
255+
Context context = new Context(Locale.ENGLISH);
256+
257+
if (additionalContext != null)
258+
additionalContext.getVariableNames().forEach(name -> context.setVariable(name, additionalContext.getVariable(name)));
259+
260+
String from = jHipsterProperties.getMail().getFrom();
261+
String content = templateEngine.process("mail/" + mailType.getTemplateName(), context);
262+
try {
263+
sendEmail(to, from, null, subject, content, null, false, true);
264+
} catch (MailException | MessagingException e) {
265+
log.warn("Internal email could not be sent to '{}'", to, e);
266+
}
267+
}
268+
239269
@Async
240270
public void sendActivationEmail(UserDTO user) {
241271
log.debug("Sending activation email to '{}'", user.getEmail());

src/main/java/org/mskcc/cbio/oncokb/service/dto/CompanyDTO.java

+15-2
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
import javax.persistence.Lob;
88
import org.mskcc.cbio.oncokb.domain.enumeration.CompanyType;
99
import org.mskcc.cbio.oncokb.domain.enumeration.LicenseType;
10+
import org.mskcc.cbio.oncokb.service.dto.companyadditionalinfo.CompanyAdditionalInfoDTO;
1011
import org.mskcc.cbio.oncokb.domain.enumeration.LicenseModel;
1112
import org.mskcc.cbio.oncokb.domain.enumeration.LicenseStatus;
1213

1314
/**
1415
* A DTO for the {@link org.mskcc.cbio.oncokb.domain.Company} entity.
1516
*/
1617
public class CompanyDTO implements Serializable {
17-
18+
1819
private Long id;
1920

2021
@NotNull
@@ -42,8 +43,11 @@ public class CompanyDTO implements Serializable {
4243
@NotEmpty
4344
private Set<String> companyDomains = new HashSet<>();
4445

46+
@Lob
47+
private CompanyAdditionalInfoDTO additionalInfo;
48+
4549
private Integer numberOfUsers;
46-
50+
4751
public Long getId() {
4852
return id;
4953
}
@@ -124,6 +128,14 @@ public void setCompanyDomains(Set<String> companyDomains) {
124128
this.companyDomains = companyDomains;
125129
}
126130

131+
public CompanyAdditionalInfoDTO getAdditionalInfo() {
132+
return additionalInfo;
133+
}
134+
135+
public void setAdditionalInfo(CompanyAdditionalInfoDTO additionalInfo) {
136+
this.additionalInfo = additionalInfo;
137+
}
138+
127139
public Integer getNumberOfUsers() {
128140
return this.numberOfUsers;
129141
}
@@ -162,6 +174,7 @@ public String toString() {
162174
", licenseStatus='" + getLicenseStatus() + "'" +
163175
", businessContact='" + getBusinessContact() + "'" +
164176
", legalContact='" + getLegalContact() + "'" +
177+
", additionalInfo='" + getAdditionalInfo() + "'" +
165178
", companyDomains='" + getCompanyDomains() + "'" +
166179
", numberOfUsers='" + getNumberOfUsers() + "'" +
167180
"}";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package org.mskcc.cbio.oncokb.service.dto;
2+
3+
import java.io.Serializable;
4+
5+
public class TerminationEmailDTO implements Serializable {
6+
private String subject;
7+
private String from;
8+
private String bcc;
9+
private String cc;
10+
private String content;
11+
private Long companyId;
12+
13+
public String getSubject() {
14+
return subject;
15+
}
16+
17+
public void setSubject(String subject) {
18+
this.subject = subject;
19+
}
20+
21+
22+
public String getFrom() {
23+
return from;
24+
}
25+
26+
public void setFrom(String from) {
27+
this.from = from;
28+
}
29+
30+
public String getBcc() {
31+
return bcc;
32+
}
33+
34+
public void setBcc(String bcc) {
35+
this.bcc = bcc;
36+
}
37+
38+
public String getCc() {
39+
return cc;
40+
}
41+
42+
public void setCc(String cc) {
43+
this.cc = cc;
44+
}
45+
46+
public String getContent() {
47+
return content;
48+
}
49+
50+
public void setContent(String content) {
51+
this.content = content;
52+
}
53+
54+
public Long getCompanyId() {
55+
return companyId;
56+
}
57+
58+
public void setCompanyId(Long companyId) {
59+
this.companyId = companyId;
60+
}
61+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package org.mskcc.cbio.oncokb.service.dto.companyadditionalinfo;
2+
3+
import java.io.Serializable;
4+
5+
public class CompanyAdditionalInfoDTO implements Serializable {
6+
private CompanyLicense license;
7+
8+
public CompanyLicense getLicense() {
9+
return license;
10+
}
11+
12+
public void setLicense(CompanyLicense license) {
13+
this.license = license;
14+
}
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package org.mskcc.cbio.oncokb.service.dto.companyadditionalinfo;
2+
3+
import java.io.Serializable;
4+
import java.time.Instant;
5+
6+
public class CompanyLicense implements Serializable {
7+
private Instant activation;
8+
private boolean autoRenewal;
9+
private CompanyTermination termination;
10+
11+
public Instant getActivation() {
12+
return activation;
13+
}
14+
15+
public void setActivation(Instant activation) {
16+
this.activation = activation;
17+
}
18+
19+
public boolean isAutoRenewal() {
20+
return autoRenewal;
21+
}
22+
23+
public void setAutoRenewal(boolean autoRenewal) {
24+
this.autoRenewal = autoRenewal;
25+
}
26+
27+
public CompanyTermination getTermination() {
28+
return termination;
29+
}
30+
31+
public void setTermination(CompanyTermination termination) {
32+
this.termination = termination;
33+
}
34+
}

0 commit comments

Comments
 (0)