Skip to content

Commit

Permalink
Merge branch 'aiccra-dev-partner-request-A2-296' into aiccra-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjitm committed Apr 23, 2024
2 parents bc98f43 + 16e231b commit ca41d9b
Showing 1 changed file with 30 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.cgiar.ccafs.marlo.data.model.LocElement;
import org.cgiar.ccafs.marlo.data.model.PartnerRequest;
import org.cgiar.ccafs.marlo.data.model.PowbSynthesis;
import org.cgiar.ccafs.marlo.data.model.Project;
import org.cgiar.ccafs.marlo.data.model.ProjectExpectedStudyInfo;
import org.cgiar.ccafs.marlo.data.model.ProjectInfo;
import org.cgiar.ccafs.marlo.data.model.ReportSynthesis;
Expand Down Expand Up @@ -111,6 +112,7 @@ public class PartnersSaveAction extends BaseAction {
private int activityID;
private int capdevID;
private String pageRequestName;
private ProjectInfo projectInfo;

@Inject
public PartnersSaveAction(APConfig config, LocElementManager locationManager,
Expand Down Expand Up @@ -165,7 +167,9 @@ public void addPowbSynthesisMessage(StringBuilder message, PartnerRequest partne

public void addProjectMessage(StringBuilder message, PartnerRequest partnerRequest,
PartnerRequest partnerRequestModifications) {
ProjectInfo projectInfo = projectManager.getProjectById(projectID).getProjecInfoPhase(this.getActualPhase());
if (projectInfo == null) {
projectInfo = projectManager.getProjectById(projectID).getProjecInfoPhase(this.getActualPhase());
}
String sourceMessage = "";
if (this.isAiccra()) {
sourceMessage = "" + context + " Cluster: (" + projectID + ") - " + projectInfo.getTitle();
Expand Down Expand Up @@ -342,6 +346,12 @@ public String save() {
countryId = String.valueOf(locationId);
partnerWebPage = activityPartner.getPartner().getWebsiteLink();

// Get project info
projectInfo = projectManager.getProjectById(projectID).getProjecInfoPhase(this.getActualPhase());

// Get project information
Project project = projectInfo != null ? projectInfo.getProject() : null;

// Get the partner type name
countryName = locationManager.getLocElementById(Long.parseLong(countryId)).getName();

Expand Down Expand Up @@ -444,6 +454,19 @@ public String save() {
request.put("websiteLink", partnerRequest.getWebPage());
request.put("institutionTypeCode", partnerRequest.getInstitutionType().getId());
request.put("hqCountryIso", partnerRequest.getLocElement().getIsoAlpha2());

// setting requestSource CLARISA parameter
String requestSource;
if (project != null && project.getAcronym() != null) {
requestSource = project.getAcronym();
} else if (project != null && project.getProjectInfo() != null && project.getProjectInfo().getTitle() != null) {
requestSource = project.getProjectInfo().getTitle();
} else {
requestSource = "Request made from AICCRA";
}
request.put("requestSource", requestSource);

request.put("misAcronym", "userId:" + this.getCurrentUser().getId());
request.put("externalUserMail", this.getCurrentUser().getEmail());
request.put("externalUserName", this.getCurrentUser().getUsername());
request.put("externalUserComments", "Request made from AICCRA");
Expand All @@ -456,8 +479,7 @@ public String save() {
ExternalPostUtils epu = new ExternalPostUtils();
epu.setUsername(config.getClarisaAPIUsername());
epu.setPassword(config.getClarisaAPIPassword());
String responseStr =
epu.postJson(config.getClarisaAPIHost() + "/api/CCAFS/institutions/institution-requests", requestStr);
String responseStr = epu.postJson(config.getClarisaAPIHost() + "/api/partner-requests/create", requestStr);

if (responseStr.isEmpty()) {
postFailed = true;
Expand All @@ -478,11 +500,11 @@ public String save() {

try {
/*
if (this.validateEmailNotification()) {
sendMail.send(config.getEmailNotification(), null, config.getEmailNotification(), subject, message.toString(),
null, null, null, true);
}
*/
* if (this.validateEmailNotification()) {
* sendMail.send(config.getEmailNotification(), null, config.getEmailNotification(), subject, message.toString(),
* null, null, null, true);
* }
*/
} catch (Exception e) {
LOG.error("unable to send mail", e);
/**
Expand Down

0 comments on commit ca41d9b

Please sign in to comment.