Skip to content

Commit

Permalink
Add Terminate company license Back (#1192)
Browse files Browse the repository at this point in the history
* fixed merge conflicts

* updated screenshots
  • Loading branch information
jfkonecn authored Jan 14, 2025
1 parent a8dd72c commit 93b7566
Show file tree
Hide file tree
Showing 74 changed files with 1,630 additions and 78 deletions.
5 changes: 5 additions & 0 deletions .jhipster/Company.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
{
"fieldName": "legalContact",
"fieldType": "String"
},
{
"fieldName": "additionalInfo",
"fieldType": "byte[]",
"fieldTypeBlobContent": "text"
}
],
"relationships": [
Expand Down
1 change: 1 addition & 0 deletions jhipster-jdl.jdl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ entity Company {
licenseStatus LicenseStatus required,
businessContact String,
legalContact String,
additionalInfo TextBlob
}

entity CompanyDomain {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshot-test/__baseline_snapshots__/Login Page-snap.png
Binary file modified screenshot-test/__baseline_snapshots__/User Details Page-snap.png
26 changes: 24 additions & 2 deletions screenshot-test/data/api-companies.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,18 @@
"businessContact": "Representative",
"legalContact": "override orchid reboot",
"companyDomains": ["oncokb.org"],
"numberOfUsers": 0
"numberOfUsers": 0,
"additionalInfo": {
"license": {
"termination": {
"date": "2025-09-21",
"notes": "notes",
"notificationDays": 3433
},
"autoRenewal": false,
"activation": "2024-09-28"
}
}
},
{
"id": 2,
Expand All @@ -23,6 +34,17 @@
"businessContact": "Steel Configuration Designer",
"legalContact": "system engine Australian Dollar",
"companyDomains": ["mskcc.org"],
"numberOfUsers": 3
"numberOfUsers": 3,
"additionalInfo": {
"license": {
"termination": {
"date": "2025-09-21",
"notes": "notes",
"notificationDays": 3433
},
"autoRenewal": false,
"activation": "2024-09-28"
}
}
}
]
13 changes: 12 additions & 1 deletion screenshot-test/data/api-company-details.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,16 @@
"businessContact": "Representative",
"legalContact": "override orchid reboot",
"companyDomains": ["oncokb.org"],
"numberOfUsers": 0
"numberOfUsers": 0,
"additionalInfo": {
"license": {
"termination": {
"date": "2024-09-21",
"notes": "notes",
"notificationDays": 3433
},
"autoRenewal": false,
"activation": "2024-09-28"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -197,5 +197,4 @@ public RecaptchaProperties getRecaptcha() {
public void setRecaptcha(RecaptchaProperties recaptcha) {
this.recaptcha = recaptcha;
}

}
18 changes: 18 additions & 0 deletions src/main/java/org/mskcc/cbio/oncokb/domain/Company.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ public class Company implements Serializable {
@Column(name = "legal_contact", length = 255)
private String legalContact;

@Lob
@Column(name = "additional_info")
private String additionalInfo;

@ManyToMany(fetch = FetchType.EAGER, cascade = {CascadeType.PERSIST, CascadeType.MERGE})
@JoinTable(name = "company_company_domain",
joinColumns = @JoinColumn(name = "company_id", referencedColumnName = "id"),
Expand Down Expand Up @@ -185,6 +189,19 @@ public void setLegalContact(String legalContact) {
this.legalContact = legalContact;
}

public String getAdditionalInfo() {
return additionalInfo;
}

public Company additionalInfo(String additionalInfo) {
this.additionalInfo = additionalInfo;
return this;
}

public void setAdditionalInfo(String additionalInfo) {
this.additionalInfo = additionalInfo;
}

public Set<CompanyDomain> getCompanyDomains() {
return companyDomains;
}
Expand Down Expand Up @@ -240,6 +257,7 @@ public String toString() {
", licenseStatus='" + getLicenseStatus() + "'" +
", businessContact='" + getBusinessContact() + "'" +
", legalContact='" + getLegalContact() + "'" +
", additionalInfo='" + getAdditionalInfo() + "'" +
"}";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ public enum MailType {
, LIST_OF_UNAPPROVED_USERS(new MailTypeBuilder()
.templateName("listOfUnapprovedUsers")
.description("List of unapproved users"))
, TERMINATION_NOTIFICATION_EMAIL(new MailTypeBuilder()
.templateName("terminationNotificationEmail")
.description("Notifies admins about companies with licenses about to expire"))
, TEST(new MailTypeBuilder()
.templateName("testEmail")
.description("Test"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ public interface CompanyRepository extends JpaRepository<Company, Long> {

@Cacheable(cacheResolver = "companyCacheResolver")
Optional<Company> findOneByNameIgnoreCase(String name);

@Query("select c from Company c where c.id in ?1")
List<Company> findCompaniesByIds(List<Long> ids);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.mskcc.cbio.oncokb.service;

import org.mskcc.cbio.oncokb.domain.Company;
import org.mskcc.cbio.oncokb.domain.Token;
import org.mskcc.cbio.oncokb.domain.User;
import org.mskcc.cbio.oncokb.domain.enumeration.LicenseStatus;
Expand Down Expand Up @@ -72,4 +73,7 @@ public interface CompanyService {
Optional<List<Token>> getServiceAccountTokensForCompany(Long id);

Optional<UserDTO> getServiceUserForCompany(Long companyId);


List<CompanyDTO> findCompaniesByIds(List<Long> ids);
}
30 changes: 30 additions & 0 deletions src/main/java/org/mskcc/cbio/oncokb/service/MailService.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.mskcc.cbio.oncokb.domain.Company;
import org.mskcc.cbio.oncokb.domain.UserMessagePair;
import org.mskcc.cbio.oncokb.domain.enumeration.MailType;
import org.mskcc.cbio.oncokb.service.dto.TerminationEmailDTO;
import org.mskcc.cbio.oncokb.service.dto.UserDTO;
import org.mskcc.cbio.oncokb.service.dto.UserMailsDTO;
import org.mskcc.cbio.oncokb.web.rest.vm.ExposedToken;
Expand Down Expand Up @@ -85,6 +86,20 @@ private UnknownMailTypeException() {
}
}

public void sendEmail(TerminationEmailDTO dto) throws MessagingException {
log.debug("Send email to company ID '{}' with subject '{}' and content={}",
dto.getCompanyId(), dto.getSubject(), dto.getContent());

MimeMessage mimeMessage = javaMailSender.createMimeMessage();
MimeMessageHelper message = new MimeMessageHelper(mimeMessage, false, StandardCharsets.UTF_8.name());
message.setFrom(dto.getFrom());
message.setBcc(dto.getBcc().split(";"));
message.setCc(dto.getCc().split(";"));
message.setSubject(dto.getSubject());
message.setText(dto.getContent(), false);
javaMailSender.send(mimeMessage);
}

@Async
public void sendEmail(String to, String from, String cc, String subject, String content, List<String> attachmentFilesNames, boolean isMultipart, boolean isHtml) throws MessagingException {
log.debug("Send email[multipart '{}' and html '{}'] to '{}' with subject '{}' and content={}",
Expand Down Expand Up @@ -236,6 +251,21 @@ public void sendEmailFromTemplate(UserDTO user, MailType mailType, String subjec
}
}

public void sendInternalEmailFromTemplate(MailType mailType, String subject, String to, Context additionalContext) {
Context context = new Context(Locale.ENGLISH);

if (additionalContext != null)
additionalContext.getVariableNames().forEach(name -> context.setVariable(name, additionalContext.getVariable(name)));

String from = jHipsterProperties.getMail().getFrom();
String content = templateEngine.process("mail/" + mailType.getTemplateName(), context);
try {
sendEmail(to, from, null, subject, content, null, false, true);
} catch (MailException | MessagingException e) {
log.warn("Internal email could not be sent to '{}'", to, e);
}
}

@Async
public void sendActivationEmail(UserDTO user) {
log.debug("Sending activation email to '{}'", user.getEmail());
Expand Down
17 changes: 15 additions & 2 deletions src/main/java/org/mskcc/cbio/oncokb/service/dto/CompanyDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
import javax.persistence.Lob;
import org.mskcc.cbio.oncokb.domain.enumeration.CompanyType;
import org.mskcc.cbio.oncokb.domain.enumeration.LicenseType;
import org.mskcc.cbio.oncokb.service.dto.companyadditionalinfo.CompanyAdditionalInfoDTO;
import org.mskcc.cbio.oncokb.domain.enumeration.LicenseModel;
import org.mskcc.cbio.oncokb.domain.enumeration.LicenseStatus;

/**
* A DTO for the {@link org.mskcc.cbio.oncokb.domain.Company} entity.
*/
public class CompanyDTO implements Serializable {

private Long id;

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

@Lob
private CompanyAdditionalInfoDTO additionalInfo;

private Integer numberOfUsers;

public Long getId() {
return id;
}
Expand Down Expand Up @@ -124,6 +128,14 @@ public void setCompanyDomains(Set<String> companyDomains) {
this.companyDomains = companyDomains;
}

public CompanyAdditionalInfoDTO getAdditionalInfo() {
return additionalInfo;
}

public void setAdditionalInfo(CompanyAdditionalInfoDTO additionalInfo) {
this.additionalInfo = additionalInfo;
}

public Integer getNumberOfUsers() {
return this.numberOfUsers;
}
Expand Down Expand Up @@ -162,6 +174,7 @@ public String toString() {
", licenseStatus='" + getLicenseStatus() + "'" +
", businessContact='" + getBusinessContact() + "'" +
", legalContact='" + getLegalContact() + "'" +
", additionalInfo='" + getAdditionalInfo() + "'" +
", companyDomains='" + getCompanyDomains() + "'" +
", numberOfUsers='" + getNumberOfUsers() + "'" +
"}";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package org.mskcc.cbio.oncokb.service.dto;

import java.io.Serializable;

public class TerminationEmailDTO implements Serializable {
private String subject;
private String from;
private String bcc;
private String cc;
private String content;
private Long companyId;

public String getSubject() {
return subject;
}

public void setSubject(String subject) {
this.subject = subject;
}


public String getFrom() {
return from;
}

public void setFrom(String from) {
this.from = from;
}

public String getBcc() {
return bcc;
}

public void setBcc(String bcc) {
this.bcc = bcc;
}

public String getCc() {
return cc;
}

public void setCc(String cc) {
this.cc = cc;
}

public String getContent() {
return content;
}

public void setContent(String content) {
this.content = content;
}

public Long getCompanyId() {
return companyId;
}

public void setCompanyId(Long companyId) {
this.companyId = companyId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.mskcc.cbio.oncokb.service.dto.companyadditionalinfo;

import java.io.Serializable;

public class CompanyAdditionalInfoDTO implements Serializable {
private CompanyLicense license;

public CompanyLicense getLicense() {
return license;
}

public void setLicense(CompanyLicense license) {
this.license = license;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.mskcc.cbio.oncokb.service.dto.companyadditionalinfo;

import java.io.Serializable;
import java.time.Instant;

public class CompanyLicense implements Serializable {
private Instant activation;
private boolean autoRenewal;
private CompanyTermination termination;

public Instant getActivation() {
return activation;
}

public void setActivation(Instant activation) {
this.activation = activation;
}

public boolean isAutoRenewal() {
return autoRenewal;
}

public void setAutoRenewal(boolean autoRenewal) {
this.autoRenewal = autoRenewal;
}

public CompanyTermination getTermination() {
return termination;
}

public void setTermination(CompanyTermination termination) {
this.termination = termination;
}
}
Loading

0 comments on commit 93b7566

Please sign in to comment.