Skip to content

Commit

Permalink
Merge branch 'aiccra-staging' into aiccra-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjitm committed Aug 9, 2023
2 parents ae04f6f + 6b30939 commit 7493f05
Show file tree
Hide file tree
Showing 13 changed files with 137 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ public interface ActivityTitleDAO {
*/
public List<ActivityTitle> findAll();

/**
* This method gets a list of activityTitle that are active
*
* @param year is a int object.
* @return a list from ActivityTitle null if no exist records
*/
public List<ActivityTitle> findByCurrentYear(int year);


/**
* This method saves the information of the given activityTitle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import javax.inject.Inject;
import javax.inject.Named;

import org.hibernate.Query;
import org.hibernate.SessionFactory;

@Named
Expand Down Expand Up @@ -68,6 +69,18 @@ public List<ActivityTitle> findAll() {

}

@Override
public List<ActivityTitle> findByCurrentYear(int year) {
String query = "select pat from ActivityTitle pat where pat.endYear >= :year and pat.startYear < :year";
Query createQuery = this.getSessionFactory().getCurrentSession().createQuery(query);
createQuery.setParameter("year", year);
List<ActivityTitle> list = super.findAll(createQuery);
if (!list.isEmpty()) {
return list;
}
return null;
}

@Override
public ActivityTitle save(ActivityTitle activityTitle) {
if (activityTitle.getId() == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ public interface ActivityTitleManager {
*/
public List<ActivityTitle> findAll();

/**
* This method gets a list of activityTitle that are active
*
* @param year is a int object.
* @return a list from ActivityTitle null if no exist records
*/
public List<ActivityTitle> findByCurrentYear(int year);


/**
* This method gets a activityTitle object by a given activityTitle identifier.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ public List<ActivityTitle> findAll() {

}

@Override
public List<ActivityTitle> findByCurrentYear(int year) {
return activityTitleDAO.findByCurrentYear(year);
}

@Override
public ActivityTitle getActivityTitleById(long activityTitleID) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ public class ActivityTitle extends MarloBaseEntity implements java.io.Serializab
private String title;

private Set<Activity> activities = new HashSet<Activity>(0);

@Expose
private int startYear;
@Expose
private int endYear;

@Override
public boolean equals(Object obj) {
Expand All @@ -58,6 +61,10 @@ public Set<Activity> getActivities() {
return activities;
}

public int getEndYear() {
return endYear;
}


@Override
public String getLogDeatil() {
Expand All @@ -80,12 +87,14 @@ public User getModifiedBy() {
return null;
}

public int getStartYear() {
return startYear;
}

public String getTitle() {
return title;
}


@Override
public int hashCode() {
final int prime = 31;
Expand All @@ -104,11 +113,19 @@ public void setActivities(Set<Activity> activities) {
this.activities = activities;
}

public void setEndYear(int endYear) {
this.endYear = endYear;
}

@Override
public void setModifiedBy(User modifiedBy) {
// TODO Auto-generated method stub
}

public void setStartYear(int startYear) {
this.startYear = startYear;
}

public void setTitle(String title) {
this.title = title;
}
Expand Down
6 changes: 6 additions & 0 deletions marlo-data/src/main/resources/xmls/ActivitiesTitles.hbm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
<property name="title" type="string">
<column name="title" not-null="true" />
</property>
<property name="startYear" type="int">
<column name="start_year" length="5" />
</property>
<property name="endYear" type="int">
<column name="end_year" length="5" />
</property>
<set name="activities" order-by="id" table="activities"
inverse="true" lazy="true" fetch="select">
<key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -934,48 +934,52 @@ public boolean canBeDeleted(long id, String className) {
if (clazz == ProjectOutcome.class) {
if (this.isAiccra()) {
boolean canDelete = true;
ProjectOutcome projectOutcome = this.projectOutcomeManager.getProjectOutcomeById(id);
ProjectOutcome projectOutcome = null;
try {
projectOutcome = this.projectOutcomeManager.getProjectOutcomeById(id);

for (Deliverable deliverable : projectOutcome.getProject().getCurrentDeliverables(this.getActualPhase())) {
if (deliverable.getDeliverableProjectOutcomes() != null) {
deliverable.setProjectOutcomes(new ArrayList<>(deliverable.getDeliverableProjectOutcomes().stream()
.filter(o -> o.getPhase().getId().equals(this.getActualPhase().getId())).collect(Collectors.toList())));
}
if (deliverable != null && deliverable.getProjectOutcomes() != null
&& !deliverable.getProjectOutcomes().isEmpty()) {
if (deliverable != null && deliverable.getProjectOutcomes() != null
&& !deliverable.getProjectOutcomes().isEmpty()) {
for (DeliverableProjectOutcome deliverableProjectOutcome : deliverable.getProjectOutcomes()) {
if (deliverableProjectOutcome != null && deliverableProjectOutcome.getProjectOutcome() != null
&& deliverableProjectOutcome.getProjectOutcome().getId() != null
&& deliverableProjectOutcome.getProjectOutcome().getId().compareTo(projectOutcome.getId()) == 0) {
for (Deliverable deliverable : projectOutcome.getProject().getCurrentDeliverables(this.getActualPhase())) {
if (deliverable.getDeliverableCrpOutcomes() != null) {
deliverable.setCrpOutcomes(new ArrayList<>(deliverable.getDeliverableCrpOutcomes().stream()
.filter(o -> o.getPhase().getId().equals(this.getActualPhase().getId()))
.collect(Collectors.toList())));
}

if (deliverable != null && deliverable.getCrpOutcomes() != null
&& !deliverable.getCrpOutcomes().isEmpty()) {

for (DeliverableCrpOutcome deliverableCrpOutcome : deliverable.getCrpOutcomes()) {
if (deliverableCrpOutcome != null && deliverableCrpOutcome.getCrpProgramOutcome() != null
&& deliverableCrpOutcome.getCrpProgramOutcome().getId() != null && deliverableCrpOutcome
.getCrpProgramOutcome().getId().compareTo(projectOutcome.getCrpProgramOutcome().getId()) == 0) {

canDelete = false;
break;
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}


try {
for (ProjectExpectedStudy expectedStudy : projectOutcome.getProject().getProjectExpectedStudies().stream()
.filter(ps -> ps.isActive() && ps.getProjectExpectedStudyInfo(this.getActualPhase()) != null
&& ps.getProjectExpectedStudyInfo(this.getActualPhase()).isActive())
.collect(Collectors.toList())) {
if (expectedStudy.getProjectExpectedStudyProjectOutcomes() != null) {
expectedStudy.setProjectOutcomes(new ArrayList<>(expectedStudy.getProjectExpectedStudyProjectOutcomes()
.stream().filter(o -> o.getPhase().getId().equals(this.getActualPhase().getId()))
if (expectedStudy.getProjectExpectedStudyCrpOutcomes() != null) {
expectedStudy.setCrpOutcomes(new ArrayList<>(expectedStudy.getProjectExpectedStudyCrpOutcomes().stream()
.filter(o -> o.getPhase().getId().equals(this.getActualPhase().getId()))
.collect(Collectors.toList())));
}
if (expectedStudy != null && expectedStudy.getProjectOutcomes() != null
&& !expectedStudy.getProjectOutcomes().isEmpty()) {
for (ProjectExpectedStudyProjectOutcome expectedStudyProjectOutcome : expectedStudy
.getProjectOutcomes()) {
if (expectedStudyProjectOutcome != null && expectedStudyProjectOutcome.getProjectOutcome() != null
&& expectedStudyProjectOutcome.getProjectOutcome().getId() != null
&& expectedStudyProjectOutcome.getProjectOutcome().getId().compareTo(projectOutcome.getId()) == 0) {
if (expectedStudy != null && expectedStudy.getCrpOutcomes() != null
&& !expectedStudy.getCrpOutcomes().isEmpty()) {
for (ProjectExpectedStudyCrpOutcome expectedStudyCrpOutcome : expectedStudy.getCrpOutcomes()) {
if (expectedStudyCrpOutcome != null && expectedStudyCrpOutcome.getCrpOutcome() != null
&& expectedStudyCrpOutcome.getCrpOutcome().getId() != null && projectOutcome != null
&& projectOutcome.getCrpProgramOutcome() != null && expectedStudyCrpOutcome.getCrpOutcome().getId()
.compareTo(projectOutcome.getCrpProgramOutcome().getId()) == 0) {
canDelete = false;
break;
}
Expand All @@ -991,18 +995,16 @@ public boolean canBeDeleted(long id, String className) {
.filter(ps -> ps.isActive() && ps.getProjectInnovationInfo(this.getActualPhase()) != null
&& ps.getProjectInnovationInfo(this.getActualPhase()).isActive())
.collect(Collectors.toList())) {
if (innovation.getProjectInnovationProjectOutcomes() != null) {
innovation.setProjectOutcomes(new ArrayList<>(innovation.getProjectInnovationProjectOutcomes().stream()
if (innovation.getProjectInnovationCrpOutcomes() != null) {
innovation.setCrpOutcomes(new ArrayList<>(innovation.getProjectInnovationCrpOutcomes().stream()
.filter(o -> o.getPhase().getId().equals(this.getActualPhase().getId()))
.collect(Collectors.toList())));
}
if (innovation != null && innovation.getProjectOutcomes() != null
&& !innovation.getProjectOutcomes().isEmpty()) {
for (ProjectInnovationProjectOutcome innovationStudyProjectOutcome : innovation.getProjectOutcomes()) {
if (innovationStudyProjectOutcome != null && innovationStudyProjectOutcome.getProjectOutcome() != null
&& innovationStudyProjectOutcome.getProjectOutcome().getId() != null
&& innovationStudyProjectOutcome.getProjectOutcome().getId()
.compareTo(projectOutcome.getId()) == 0) {
if (innovation != null && innovation.getCrpOutcomes() != null && !innovation.getCrpOutcomes().isEmpty()) {
for (ProjectInnovationCrpOutcome innovationStudyCrpOutcome : innovation.getCrpOutcomes()) {
if (innovationStudyCrpOutcome != null && innovationStudyCrpOutcome.getCrpOutcome() != null
&& innovationStudyCrpOutcome.getCrpOutcome().getId() != null && innovationStudyCrpOutcome
.getCrpOutcome().getId().compareTo(projectOutcome.getCrpProgramOutcome().getId()) == 0) {
canDelete = false;
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,33 @@ public void prepare() throws Exception {

if (this.isAiccra()) {
if (activityTitleManager.findAll() != null && !activityTitleManager.findAll().isEmpty()) {
activityTitles = activityTitleManager.findAll();


try {
activityTitles = activityTitleManager.findByCurrentYear(this.getActualPhase().getYear());
} catch (Exception e) {
logger.error("unable to get activity title by date", e);
}

if (activityTitles == null || (activityTitles != null && activityTitles.isEmpty())) {
activityTitles = activityTitleManager.findAll();
}
/*
* List<ActivityTitle> tempActivityTitles = new ArrayList<>();
* for (ActivityTitle activityTitle : activityTitles) {
* if (activityTitle != null && activityTitle.getStartDate() != null && activityTitle.getEndDate() != null) {
* if (activityTitle.getStartDate().before(this.getActualPhase().getStartDate())
* && activityTitle.getEndDate().after(this.getActualPhase().getEndDate())) {
* tempActivityTitles.add(activityTitle);
* }
* }
* }
*/
/*
* if (activityTitles != null && !activityTitles.isEmpty()) {
* activityTitles = tempActivityTitles;
* }
*/
if (activityTitles != null && activityTitles.isEmpty()) {
activityTitles.sort((a1, a2) -> a1.getTitle().compareTo(a2.getTitle()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,7 @@ public String execute() throws Exception {
indicatorsList.add("IPI 2.2");
indicatorsList.add("IPI 2.3");
indicatorsList.add("IPI 2.4");
indicatorsList.add("IPI 2.5");
indicatorsList.add("IPI 3.1");
indicatorsList.add("IPI 3.2");
indicatorsList.add("IPI 3.3");
Expand Down Expand Up @@ -920,6 +921,15 @@ public String execute() throws Exception {
.collect(Collectors.toList()));
} catch (Exception e) {
}
// IPI 2.5
try {
projectOutcomes.addAll(project.getProjectOutcomes().stream()
.filter(c -> c.isActive() && c.getPhase().equals(this.getSelectedPhase())
&& c.getCrpProgramOutcome() != null && c.getCrpProgramOutcome().getComposedName() != null
&& c.getCrpProgramOutcome().getComposedName().contains("IPI 2.5"))
.collect(Collectors.toList()));
} catch (Exception e) {
}

// IPI 3.1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ public void validateAiccraProjectOutcomeIndicator(BaseAction action, ProjectOutc
// IPI 2.1, 2.3, IPI 3.1, IPI 3.2, IPI 3.4, IPI 3.5
if (programOutcome.contains("IPI 2.1") || programOutcome.contains("IPI 2.3") || programOutcome.contains("IPI 3.1")
|| programOutcome.contains("IPI 3.2") || programOutcome.contains("IPI 3.4")
|| programOutcome.contains("IPI 2.4") || programOutcome.contains("IPI 2.5")
|| programOutcome.contains("IPI 3.5")) {
List<String> params = new ArrayList<>();
params.add(String.valueOf(i + 1));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE activities_titles ADD start_year int(4) NULL;
ALTER TABLE activities_titles ADD end_year int(4) NULL;
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 @@ -2552,6 +2552,7 @@ project.deliverable.notDuplicated=Not duplicated
project.deliverable.isDuplicated=Duplicated
project.deliverable.duplicated.legend=Deliverables identified as duplicates
project.deliverable.responsible.person=Responsible person
project.deliverable.activities.readText=Activities
# Deliverable MODEL
deliverable.crossCuttingDimensions=Does this deliverable have a cross-cutting dimension(s)?
deliverable.crossCuttingDimensions.readText=Deliverable cross-cutting dimension(s)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[#ftl]

<input type="hidden" name="deliverable.deliverableInfo.remainingPending" value="${(deliverable.deliverableInfo.remainingPending)?c}"/>
<input type="hidden" name="deliverable.deliverableInfo.remainingPending" value="${(deliverable.deliverableInfo.remainingPending!'')?c}"/>
<div class="simpleBox">
[#-- Title input --]
<div class="form-group">
Expand Down

0 comments on commit 7493f05

Please sign in to comment.