Skip to content

Commit

Permalink
Merge branch 'aiccra-staging' into AICCRA
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjitm committed Feb 7, 2025
2 parents 0ed9edf + 22618d7 commit 6381425
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ public List<String> getAnsweredCommentByPhase(long phase) {
query.append("SELECT parent_id as parent_id,count(*) as count ");
query.append("FROM feedback_qa_comments fqc");
query.append(" WHERE id_phase=" + phase);
query.append(" and status_id = 1 ");
query.append(" and (status_id = 1 || status_id = 2 || status_id = 5) ");
query.append(" and field_id in (select id from feedback_qa_commentable_fields fqcf ");
query.append(" where section_name = 'deliverable') ");
query.append(" and reply_id is not null ");
query.append(" AND (status_id = 1 OR reply_id IS NOT NULL) ");
query.append(" group by parent_id ");

List<Map<String, Object>> rList = super.findCustomQuery(query.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ public List<String> getAnsweredCommentByPhaseToStudy(long phase) {
query.append("SELECT parent_id as parent_id,count(*) as count ");
query.append("FROM feedback_qa_comments fqc");
query.append(" WHERE id_phase=" + phase);
query.append(" and status_id = 1 ");
query.append(" and (status_id = 1 || status_id = 2 || status_id = 5)");
query.append(" and field_id in (select id from feedback_qa_commentable_fields fqcf ");
query.append(" where section_name = 'study') ");
query.append(" and reply_id is not null ");
query.append(" AND (status_id = 1 OR reply_id IS NOT NULL) ");
query.append(" group by parent_id ");

List<Map<String, Object>> rList = super.findCustomQuery(query.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,25 @@ public String getComposedNameLoc() {
return this.getName();
}

public String getComposedNameType() {
if (this.getAcronym() != null) {
if (this.getAcronym().length() != 0) {
try {
String type = "";
if (this.getInstitutionType() != null && this.getInstitutionType().getName() != null) {
type = " (" + this.getInstitutionType().getName() + ")";
}
return this.getAcronym() + " - " + this.getName() + type;
} catch (Exception e) {
return this.getName();
}

}
}
return this.getName();

}

public Set<CrpPpaPartner> getCrpPpaPartners() {
return crpPpaPartners;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,46 +223,47 @@ public void getCommentStatuses() {
List<FeedbackQACommentableFields> commentableFields = new ArrayList<>();

// get the commentable fields by sectionName
if (feedbackQACommentableFieldsManager.findAll() != null) {
commentableFields = feedbackQACommentableFieldsManager.findAll().stream()
.filter(f -> f != null && f.getSectionName().equals("study")).collect(Collectors.toList());
}
commentableFields = feedbackQACommentableFieldsManager.findBySectionName("study");

if (projectStudies != null && !projectStudies.isEmpty() && commentableFields != null
&& !commentableFields.isEmpty()) {


// Set the comment status in each project outcome
for (ProjectExpectedStudy study : projectStudies) {
int answeredComments = 0, totalComments = 0;
try {


for (FeedbackQACommentableFields commentableField : commentableFields) {
if (commentableField != null && commentableField.getId() != null) {

if (study != null && study.getId() != null && commentableField != null
&& commentableField.getId() != null) {
List<FeedbackQAComment> comments = commentManager.findAll().stream()
.filter(f -> f != null && f.getParentId() == study.getId()

List<FeedbackQAComment> comments = commentManager
.getFeedbackQACommentsByPhaseAndParentId(this.getActualPhase().getId(), study.getId()).stream()
.filter(f -> f != null

&& (f.getFeedbackStatus() != null && f.getFeedbackStatus().getId() != null && (!f
.getFeedbackStatus().getId().equals(Long.parseLong(FeedbackStatusEnum.Dismissed.getStatusId()))
// &&
// !f.getFeedbackStatus().getId().equals(Long.parseLong(FeedbackStatusEnum.Draft.getStatusId()))
))

&& f.getField() != null && f.getField().getId().equals(commentableField.getId()))
)) && f.getField() != null && f.getField().getId().equals(commentableField.getId()))
.collect(Collectors.toList());

if (comments != null && !comments.isEmpty()) {
totalComments += comments.size();
comments = comments.stream()
.filter(f -> f != null && ((f.getFeedbackStatus() != null && f.getFeedbackStatus().getId()
.equals(Long.parseLong(FeedbackStatusEnum.Agreed.getStatusId())))
|| (f.getFeedbackStatus() != null && f.getReply() != null)))
.collect(Collectors.toList());
if (comments != null) {
answeredComments += comments.size();
}
List<FeedbackQAComment> filteredComments = comments.stream().filter(f -> {
Long statusId = f.getFeedbackStatus() != null ? f.getFeedbackStatus().getId() : null;
boolean isDisagreedOrClarificationNeeded =
statusId != null && (statusId.equals(Long.valueOf(FeedbackStatusEnum.Disagreed.getStatusId()))
|| statusId.equals(Long.valueOf(FeedbackStatusEnum.ClarificatioNeeded.getStatusId())));
boolean isAgreed =
statusId != null && statusId.equals(Long.valueOf(FeedbackStatusEnum.Agreed.getStatusId()));

return (isDisagreedOrClarificationNeeded && f.getReply() != null) || isAgreed;
}).collect(Collectors.toList());

answeredComments += filteredComments.size();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,47 +349,48 @@ public void getCommentStatuses() {
List<FeedbackQACommentableFields> commentableFields = new ArrayList<>();

// get the commentable fields by sectionName
if (feedbackQACommentableFieldsManager.findAll() != null) {
commentableFields = feedbackQACommentableFieldsManager.findAll().stream()
.filter(f -> f != null && f.getSectionName().equals("innovation")).collect(Collectors.toList());
}
commentableFields = feedbackQACommentableFieldsManager.findBySectionName("innovation");

if (projectInnovations != null && !projectInnovations.isEmpty() && commentableFields != null
&& !commentableFields.isEmpty()) {


// Set the comment status in each project outcome

for (ProjectInnovation study : projectInnovations) {
int answeredComments = 0, totalComments = 0;
try {


for (FeedbackQACommentableFields commentableField : commentableFields) {
if (commentableField != null && commentableField.getId() != null) {

if (study != null && study.getId() != null && commentableField != null
&& commentableField.getId() != null) {
List<FeedbackQAComment> comments = commentManager.findAll().stream()
.filter(f -> f != null && f.getParentId() == study.getId()

List<FeedbackQAComment> comments = commentManager
.getFeedbackQACommentsByPhaseAndParentId(this.getActualPhase().getId(), study.getId()).stream()
.filter(f -> f != null

&& (f.getFeedbackStatus() != null && f.getFeedbackStatus().getId() != null && (!f
.getFeedbackStatus().getId().equals(Long.parseLong(FeedbackStatusEnum.Dismissed.getStatusId()))
// &&
// !f.getFeedbackStatus().getId().equals(Long.parseLong(FeedbackStatusEnum.Draft.getStatusId()))
))

&& f.getField() != null && f.getField().getId().equals(commentableField.getId()))
)) && f.getField() != null && f.getField().getId().equals(commentableField.getId()))
.collect(Collectors.toList());

if (comments != null && !comments.isEmpty()) {
totalComments += comments.size();
comments = comments.stream()
.filter(f -> f != null && ((f.getFeedbackStatus() != null && f.getFeedbackStatus().getId()
.equals(Long.parseLong(FeedbackStatusEnum.Agreed.getStatusId())))
|| (f.getFeedbackStatus() != null && f.getReply() != null)))
.collect(Collectors.toList());
if (comments != null) {
answeredComments += comments.size();
}
List<FeedbackQAComment> filteredComments = comments.stream().filter(f -> {
Long statusId = f.getFeedbackStatus() != null ? f.getFeedbackStatus().getId() : null;
boolean isDisagreedOrClarificationNeeded =
statusId != null && (statusId.equals(Long.valueOf(FeedbackStatusEnum.Disagreed.getStatusId()))
|| statusId.equals(Long.valueOf(FeedbackStatusEnum.ClarificatioNeeded.getStatusId())));
boolean isAgreed =
statusId != null && statusId.equals(Long.valueOf(FeedbackStatusEnum.Agreed.getStatusId()));

return (isDisagreedOrClarificationNeeded && f.getReply() != null) || isAgreed;
}).collect(Collectors.toList());

answeredComments += filteredComments.size();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.cgiar.ccafs.marlo.data.model.Project;
import org.cgiar.ccafs.marlo.data.model.ProjectInnovation;
import org.cgiar.ccafs.marlo.data.model.ProjectInnovationActor;
import org.cgiar.ccafs.marlo.data.model.ProjectInnovationAllianceOrganization;
import org.cgiar.ccafs.marlo.data.model.ProjectInnovationCenter;
import org.cgiar.ccafs.marlo.data.model.ProjectInnovationGeographicScope;
import org.cgiar.ccafs.marlo.data.model.ProjectInnovationInfo;
Expand Down Expand Up @@ -637,20 +636,22 @@ public void validateGeneralInformation(BaseAction action, Project project, Proje
try {
if (projectInnovation.getAllianceOrganizations() != null
&& !projectInnovation.getAllianceOrganizations().isEmpty()) {
int count = 0;
for (ProjectInnovationAllianceOrganization allianceOrganizations : projectInnovation
.getAllianceOrganizations()) {
if (allianceOrganizations.getInstitutionType() == null
|| allianceOrganizations.getInstitutionType().getId() == null
|| allianceOrganizations.getInstitutionType().getId() == -1) {
action.addMessage(action.getText("innovation.allianceOrganizations[" + count + "].institutionType.id"));
action.addMissingField("innovation.allianceOrganizations[" + count + "].institutionType.id");
action.getInvalidFields().put("list-innovation.allianceOrganizations[" + count + "].institutionType.id",
action.getText(InvalidFieldsMessages.EMPTYLIST, new String[] {"actors"}));
}
count++;

}
// Removed 07/02/2025
/*
* int count = 0;
* for (ProjectInnovationAllianceOrganization allianceOrganizations : projectInnovation
* .getAllianceOrganizations()) {
* if (allianceOrganizations.getInstitutionType() == null
* || allianceOrganizations.getInstitutionType().getId() == null
* || allianceOrganizations.getInstitutionType().getId() == -1) {
* action.addMessage(action.getText("innovation.allianceOrganizations[" + count + "].institutionType.id"));
* action.addMissingField("innovation.allianceOrganizations[" + count + "].institutionType.id");
* action.getInvalidFields().put("list-innovation.allianceOrganizations[" + count + "].institutionType.id",
* action.getText(InvalidFieldsMessages.EMPTYLIST, new String[] {"actors"}));
* }
* count++;
* }
*/
}
} catch (Exception e) {
Log.error("error validating actors " + e);
Expand Down
1 change: 1 addition & 0 deletions marlo-web/src/main/resources/custom/aicrra.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4692,6 +4692,7 @@ projectInnovations.anticipatedUsers.actors=Actors
projectInnovations.anticipatedUsers.actors.readText=Actors
projectInnovations.anticipatedUsers.actors.help=In the context of One CGIAR, <b>youth</b> are those between 15 and 24 years old, considered key to innovation and transformation in agricultural systems.
projectInnovations.anticipatedUsers.actors.help.readText=In the context of One CGIAR, <b>youth</b> are those between 15 and 24 years old, considered key to innovation and transformation in agricultural systems.
projectInnovations.anticipatedUsers.actors.typeActor=Type of actor
projectInnovations.anticipatedUsers.actors.women=Women
projectInnovations.anticipatedUsers.actors.women.readText=Women
projectInnovations.anticipatedUsers.actors.men=Men
Expand Down
1 change: 1 addition & 0 deletions marlo-web/src/main/resources/global.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4786,6 +4786,7 @@ projectInnovations.anticipatedUsers.actors=Actors
projectInnovations.anticipatedUsers.actors.readText=Actors
projectInnovations.anticipatedUsers.actors.help=In the context of One CGIAR, <b>youth</b> are those between 15 and 24 years old, considered key to innovation and transformation in agricultural systems.
projectInnovations.anticipatedUsers.actors.help.readText=In the context of One CGIAR, <b>youth</b> are those between 15 and 24 years old, considered key to innovation and transformation in agricultural systems.
projectInnovations.anticipatedUsers.actors.typeActor=Type of actor
projectInnovations.anticipatedUsers.actors.women=Women
projectInnovations.anticipatedUsers.actors.women.readText=Women
projectInnovations.anticipatedUsers.actors.men=Men
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,9 @@
[#-- Organizations --]
<div class="col-md-6 organizationsBlock">
<label for="innovation.allianceOrganizations">[@s.text name="projectInnovations.anticipatedUsers.organizations" /]:[@customForm.req required=true /]</label>
<label class="note--2">
<p>[@s.text name="study.generalInformation.ppapartner.note"][@s.param] <a href="[@s.url namespace="/projects" action='${crpSession}/partners'][@s.param name='projectID']${(projectID)!}[/@s.param][#include "/WEB-INF/global/pages/urlGlobalParams.ftl" /][/@s.url]" target="__BLANK">&nbsp;clicking here</a>[/@][/@]</p>
</label>
[#-- list of items --]
<div class="organizationsList">
[#list (element.allianceOrganizations)![] as organization]
Expand Down Expand Up @@ -753,7 +756,7 @@
[@customForm.input name="${customName}.id" value=((element.id)?string)!"" editable=false display=false /]
[#-- Dropdown Actors - Type --]
<div class="col-md-12">
[@customForm.select name="${customName}.actor.id" showTitle=false i18nkey="projectInnovations.actors" listName="actorList" keyFieldName="id" displayFieldName="name" required=false editable=true /]
[@customForm.select name="${customName}.actor.id" i18nkey="projectInnovations.anticipatedUsers.actors.typeActor" listName="actorList" keyFieldName="id" displayFieldName="name" required=false editable=true /]
</div>

[#local sexAgeNotApply = ((element.sexAgeNotApply??) && (element.sexAgeNotApply == true))! /]
Expand Down Expand Up @@ -798,14 +801,15 @@
<div id="organizationsInnovation-${(template?string('template', ''))}" class="organizationsInnovation form-group grayBlueBox ${class}">
[#-- Hidden not saved - id --]
[@customForm.input name="${customName}.id" className="indexTag" value=((element.id)?string)!"" editable=false display=false /]
[#-- "Dropdown Organizations - Type --]
[#-- "Dropdown Organizations - Type
<div class="col-md-12">
[@customForm.select name="${customName}.institutionType.id" showTitle=false i18nkey="projectInnovations.organizations" listName="institutionTypeList" keyFieldName="id" displayFieldName="name" required=false editable=true /]
</div>
--]
[#-- Input Organization name --]
<div class="col-md-12">
<label>[@s.text name="projectInnovations.anticipatedUsers.organizations.name" /]:</label>
[@customForm.select name="${customName}.institution.id" showTitle=false i18nkey="projectInnovations.anticipatedUsers.organizations" listName="institutions" keyFieldName="id" displayFieldName="name" required=false editable=true /]
[@customForm.select name="${customName}.institution.id" showTitle=false i18nkey="projectInnovations.anticipatedUsers.organizations" listName="institutions" keyFieldName="id" displayFieldName="composedNameType" required=false editable=true /]
</div>
[#-- Checkbox - is a co-development --]
<div class="col-md-12">
Expand Down

0 comments on commit 6381425

Please sign in to comment.