diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/json/global/ProgressActiveValidationAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/json/global/ProgressActiveValidationAction.java
new file mode 100644
index 0000000000..4e208f02dc
--- /dev/null
+++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/json/global/ProgressActiveValidationAction.java
@@ -0,0 +1,74 @@
+/*****************************************************************
+ * This file is part of Managing Agricultural Research for Learning &
+ * Outcomes Platform (MARLO).
+ * MARLO is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * at your option) any later version.
+ * MARLO is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with MARLO. If not, see .
+ *****************************************************************/
+
+package org.cgiar.ccafs.marlo.action.json.global;
+
+import org.cgiar.ccafs.marlo.action.BaseAction;
+import org.cgiar.ccafs.marlo.utils.APConfig;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import org.apache.struts2.dispatcher.Parameter;
+
+
+public class ProgressActiveValidationAction extends BaseAction {
+
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 8027160696406597679L;
+ /**
+ *
+ */
+ private Map status;
+
+ @Inject
+ public ProgressActiveValidationAction(APConfig config) {
+ super(config);
+ }
+
+ @Override
+ public String execute() throws Exception {
+
+ status = new HashMap<>();
+
+ if (this.isUpKeepActive()) {
+ status.put("isProgress", "true");
+ } else {
+ status.put("isProgress", "false");
+ }
+
+ return SUCCESS;
+ }
+
+ public Map getStatus() {
+ return status;
+ }
+
+ @Override
+ public void prepare() throws Exception {
+ Map parameters = this.getParameters();
+ }
+
+
+ public void setStatus(Map keyOutputs) {
+ this.status = keyOutputs;
+ }
+}
+
diff --git a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/PartnersSaveAction.java b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/PartnersSaveAction.java
index c4e42f16e1..6c587e489d 100644
--- a/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/PartnersSaveAction.java
+++ b/marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/projects/PartnersSaveAction.java
@@ -46,17 +46,21 @@
import org.cgiar.ccafs.marlo.utils.SendMailS;
import java.util.Collection;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import java.util.logging.Level;
import java.util.stream.Collectors;
import javax.inject.Inject;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.lang3.StringUtils;
+import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.auth.BasicScheme;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -448,13 +452,6 @@ public String save() {
boolean postFailed = false;
if (this.isAiccra()) {
- Map request = new HashMap<>();
- request.put("name", partnerRequest.getPartnerName());
- request.put("acronym", partnerRequest.getAcronym());
- 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) {
@@ -464,30 +461,8 @@ public String save() {
} else {
requestSource = "Request made from AICCRA";
}
- request.put("requestSource", requestSource);
-
- request.put("misAcronym", "aiccra");
- request.put("userId", this.getCurrentUser().getId());
- request.put("externalUserMail", this.getCurrentUser().getEmail());
- request.put("externalUserName", this.getCurrentUser().getUsername());
- request.put("externalUserComments", "Request made from AICCRA");
-
- ObjectMapper mapper = new ObjectMapper();
-
- try {
- String requestStr = mapper.writeValueAsString(request);
- ExternalPostUtils epu = new ExternalPostUtils();
- epu.setUsername(config.getClarisaAPIUsername());
- epu.setPassword(config.getClarisaAPIPassword());
- String responseStr = epu.postJson(config.getClarisaAPIHost() + "/api/partner-requests/create", requestStr);
-
- if (responseStr.isEmpty()) {
- postFailed = true;
- }
- } catch (JsonProcessingException ex) {
- java.util.logging.Logger.getLogger(PartnersSaveAction.class.getName()).log(Level.SEVERE, null, ex);
- }
+ this.sendPartnerRequest(partnerRequestModifications, requestSource, postFailed);
} else {
partnerRequest = partnerRequestManager.savePartnerRequest(partnerRequest);
@@ -535,6 +510,60 @@ public String save() {
}
}
+ /**
+ * send request to CLARISA,to create a partner
+ *
+ * @param PartnerRequest partnerRequest
+ * @param String requestSource
+ * @param boolean postFailed
+ * @author IBD
+ */
+ public void sendPartnerRequest(PartnerRequest partnerRequest, String requestSource, boolean postFailed) {
+
+ try {
+
+ ExternalPostUtils epu = new ExternalPostUtils();
+ epu.setUsername(config.getClarisaAPIUsername());
+ epu.setPassword(config.getClarisaAPIPassword());
+ JSONObject jsonObject = new JSONObject();
+
+
+ jsonObject.put("name", partnerRequest.getPartnerName());
+ jsonObject.put("acronym", partnerRequest.getAcronym());
+ jsonObject.put("websiteLink", partnerRequest.getWebPage());
+ jsonObject.put("institutionTypeCode", partnerRequest.getInstitutionType().getId());
+ jsonObject.put("hqCountryIso", partnerRequest.getLocElement().getIsoAlpha2());
+
+ jsonObject.put("requestSource", requestSource);
+
+ jsonObject.put("misAcronym", "aiccra");
+ jsonObject.put("userId", this.getCurrentUser().getId());
+ jsonObject.put("externalUserMail", this.getCurrentUser().getEmail());
+ jsonObject.put("externalUserName", this.getCurrentUser().getUsername());
+ jsonObject.put("externalUserComments", "Request made from AICCRA");
+
+ HttpPost httpPost = new HttpPost(config.getClarisaAPIHost() + "/api/partner-requests/create");
+
+ httpPost.setEntity(new StringEntity(jsonObject.toString()));
+
+ httpPost.setHeader("Accept", "application/json");
+ httpPost.setHeader("Content-Type", "application/json");
+ httpPost.addHeader(BasicScheme.authenticate(new UsernamePasswordCredentials(epu.getUsername(), epu.getPassword()),
+ "UTF-8", false));
+
+ CloseableHttpClient httpClient = HttpClients.createDefault();
+
+ CloseableHttpResponse response = httpClient.execute(httpPost);
+
+ LOG.info(" Class [" + PartnersSaveAction.class.getName()
+ + "] - function [sendPartnerRequest] - variable [response] " + response);
+ } catch (Exception e) {
+ postFailed = true;
+ java.util.logging.Logger.getLogger(PartnersSaveAction.class.getName()).log(Level.SEVERE, null, e);
+ }
+
+ }
+
public void setActivityID(int activityID) {
this.activityID = activityID;
}
diff --git a/marlo-web/src/main/resources/struts-json.xml b/marlo-web/src/main/resources/struts-json.xml
index 8b50dad487..08efea6ba3 100644
--- a/marlo-web/src/main/resources/struts-json.xml
+++ b/marlo-web/src/main/resources/struts-json.xml
@@ -26,6 +26,14 @@
true
+
+
+
+ true
+ true
+
+
diff --git a/marlo-web/src/main/webapp/global/js/global.js b/marlo-web/src/main/webapp/global/js/global.js
index 8a6551feb6..0e67ad8cb0 100644
--- a/marlo-web/src/main/webapp/global/js/global.js
+++ b/marlo-web/src/main/webapp/global/js/global.js
@@ -4,6 +4,7 @@ $.widget.bridge('uitooltip', $.ui.tooltip);
// Global Vars
var yesnoEvent;
+var isProgress;
var notyDefaultOptions = {
text: '',
layout: 'bottomRight',
@@ -20,13 +21,17 @@ var notyDefaultOptions = {
]
};
+
/**
* Global javascript must be here.
*/
$(document).ready(function () {
- showNotificationMessages();
+
showHelpText();
+ validatePhase().then(function(isProgress){
+ showNotificationMessages();
+ }).catch(function(error){});
// Set elementsListComponent
setElementsListComponent();
@@ -176,6 +181,22 @@ $(document).ready(function () {
$buttons.find('.buttons-content').removeClass('positionFixedBot animated flipInX');
}
}
+
+ function validatePhase() {
+ return new Promise(function(resolve, reject) {
+ // Ajax
+ $.ajax({
+ url: baseURL + '/isProgressActive.do',
+ success: function(data) {
+ isProgress = data.status.isProgress;
+ resolve();
+ },
+ error: function(xhr, status, error) {
+ reject(error);
+ }
+ });
+ });
+ }
// Animate help text
function showHelpText() {
@@ -200,8 +221,11 @@ $(document).ready(function () {
} else if (messageSelector.length >= 1 && messageSelector.html().split(":")[0] != "message" && messageSelector.html().split(":")[1] === " deliverable.status.remaining") {
// SHOW CLUSTER SUBMITTED BASED ON THE DISABLED INPUT
var $clusterSubmitted = $(`.clusterSubmitted`);
+ var $clusterSubmittedFilter = $clusterSubmitted.filter((index, ele) => $(ele).attr("issubmit") === "true").get();
var message = "";
- if ($clusterSubmitted.length > 0) {
+ console.log("ClusterSubmitted Lenght",$clusterSubmitted.length);
+ console.log("ClusterSubmitted", $clusterSubmitted);
+ if ($clusterSubmittedFilter.length > 0) {
// $clusterSubmitted exists, do something
const $mapClusterSubmit = $clusterSubmitted.filter((index, ele) => $(ele).attr("issubmit") === "true").get();
const $stringClusterSubmit = $mapClusterSubmit.reduce((prev,curr) => prev +$(curr).attr("name")+",","");
@@ -223,9 +247,17 @@ $(document).ready(function () {
} else if (messageSelector.length >= 1 && messageSelector.html().split(":")[0] != "message") {
// WARNING MESSAGE
var message = ""
- message += "The Information was correctly saved.
";
- message += "Please keep in mind that the fields highlighted below are missing or incorrect.";
var messageType = "warning";
+ if(isProgress == 'true'){
+ message += "The Information was correctly saved.
";
+ message += "Some of the fields could be missing or incorrect.
";
+ message += "Don't worry! Some information is not necessary at this phase, but it will be required in the next phase.";
+ messageType = "info";
+ }else{
+ message += "The Information was correctly saved.
";
+ message += "Please keep in mind that the fields highlighted below are missing or incorrect.";
+ }
+
notifyErrorMessage(messageType, message);
}
} else if ($(messageSelector).hasClass("error")) {
@@ -262,6 +294,14 @@ $(document).ready(function () {
$(containerIcon).addClass("alertColorWarning");
$(messages).removeClass("displayNone");
break;
+ case "info":
+ $(element).find('.alertText').html(message);
+ $(iconAlert).attr("src", baseURL + '/global/images/icon-info.png');
+ $(containerAlert).addClass("alertColorBackgroundInfo");
+ $(containerLine).addClass("alertColorInfo");
+ $(containerIcon).addClass("alertColorInfo");
+ $(messages).removeClass("displayNone");
+ break;
case "error":
//Declaraciones ejecutadas cuando el resultado de expresión coincide con valorN
break;