Skip to content

Commit d04a52f

Browse files
authored
Merge pull request #4302 from devgateway/feature/AMP-30858/Burkina-Data-Importer-v3
Feature/amp 30858/burkina data importer v3
2 parents eca9d6b + 61d3011 commit d04a52f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+3296
-244
lines changed

amp/.classpath

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
<classpath>
33
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
44
<attributes>
5-
<attribute name="owner.project.facets" value="java"/>
5+
<attribute name="maven.pomderived" value="true"/>
66
</attributes>
77
</classpathentry>
8-
<classpathentry kind="src" output="WEB-INF/classes" path="WEB-INF/src">
8+
<classpathentry including="**/*.java" kind="src" output="target/classes" path="WEB-INF/src">
99
<attributes>
1010
<attribute name="optional" value="true"/>
1111
<attribute name="maven.pomderived" value="true"/>
1212
</attributes>
1313
</classpathentry>
14-
<classpathentry kind="src" output="WEB-INF/classes" path="gen-src">
14+
<classpathentry kind="src" output="target/classes" path="gen-src">
1515
<attributes>
1616
<attribute name="optional" value="true"/>
1717
<attribute name="maven.pomderived" value="true"/>
@@ -27,8 +27,37 @@
2727
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
2828
<attributes>
2929
<attribute name="maven.pomderived" value="true"/>
30-
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
3130
</attributes>
3231
</classpathentry>
33-
<classpathentry kind="output" path="WEB-INF/classes"/>
32+
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
33+
<attributes>
34+
<attribute name="maven.pomderived" value="true"/>
35+
<attribute name="optional" value="true"/>
36+
</attributes>
37+
</classpathentry>
38+
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
39+
<attributes>
40+
<attribute name="maven.pomderived" value="true"/>
41+
<attribute name="test" value="true"/>
42+
<attribute name="optional" value="true"/>
43+
</attributes>
44+
</classpathentry>
45+
<classpathentry kind="src" path="target/generated-sources/annotations">
46+
<attributes>
47+
<attribute name="optional" value="true"/>
48+
<attribute name="maven.pomderived" value="true"/>
49+
<attribute name="ignore_optional_problems" value="true"/>
50+
<attribute name="m2e-apt" value="true"/>
51+
</attributes>
52+
</classpathentry>
53+
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
54+
<attributes>
55+
<attribute name="optional" value="true"/>
56+
<attribute name="maven.pomderived" value="true"/>
57+
<attribute name="ignore_optional_problems" value="true"/>
58+
<attribute name="m2e-apt" value="true"/>
59+
<attribute name="test" value="true"/>
60+
</attributes>
61+
</classpathentry>
62+
<classpathentry kind="output" path="target/classes"/>
3463
</classpath>

amp/.project

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,17 @@
5252
</arguments>
5353
</buildCommand>
5454
<buildCommand>
55-
<name>org.eclipse.m2e.core.maven2Builder</name>
55+
<name>org.springframework.ide.eclipse.core.springbuilder</name>
5656
<arguments>
5757
</arguments>
5858
</buildCommand>
5959
<buildCommand>
60-
<name>org.springframework.ide.eclipse.core.springbuilder</name>
60+
<name>org.zeroturnaround.eclipse.rebelXmlBuilder</name>
6161
<arguments>
6262
</arguments>
6363
</buildCommand>
6464
<buildCommand>
65-
<name>org.zeroturnaround.eclipse.rebelXmlBuilder</name>
65+
<name>org.eclipse.m2e.core.maven2Builder</name>
6666
<arguments>
6767
</arguments>
6868
</buildCommand>
@@ -89,5 +89,14 @@
8989
<arguments>1.0-name-matches-false-false-*.class</arguments>
9090
</matcher>
9191
</filter>
92+
<filter>
93+
<id>1715189241585</id>
94+
<name></name>
95+
<type>30</type>
96+
<matcher>
97+
<id>org.eclipse.core.resources.regexFilterMatcher</id>
98+
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
99+
</matcher>
100+
</filter>
92101
</filteredResources>
93102
</projectDescription>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
eclipse.preferences.version=1
2+
encoding//WEB-INF/src=UTF-8
3+
encoding//src/main/resources=UTF-8
4+
encoding//src/test/java=UTF-8
5+
encoding//src/test/resources=UTF-8
26
encoding/<project>=UTF-8
7+
encoding/gen-src=UTF-8

amp/.settings/org.eclipse.jdt.core.prefs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
2323
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
2424
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
2525
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
26+
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
2627
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
2728
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
2829
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
@@ -66,6 +67,7 @@ org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=igno
6667
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
6768
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
6869
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
70+
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
6971
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
7072
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
7173
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
@@ -97,4 +99,6 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
9799
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
98100
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
99101
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
102+
org.eclipse.jdt.core.compiler.processAnnotations=disabled
103+
org.eclipse.jdt.core.compiler.release=disabled
100104
org.eclipse.jdt.core.compiler.source=1.8

amp/Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ RUN --mount=type=cache,target=/root/.npm \
102102
npm ci \
103103
&& npm run build \
104104
&& rm -rf node_modules
105-
106105
FROM maven:3.8.4-jdk-8 as compile-mvn
107106
WORKDIR /tmp/amp
108107
COPY . .

amp/WEB-INF/c.tld

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
55
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-jsptaglibrary_2_0.xsd"
66
version="2.0">
7-
7+
88
<description>JSTL 1.1 core library</description>
99
<display-name>JSTL core</display-name>
1010
<tlib-version>1.1</tlib-version>
1111
<short-name>c</short-name>
1212
<uri>http://java.sun.com/jsp/jstl/core</uri>
13-
1413
<validator>
1514
<description>
1615
Provides core validation features for JSTL tags.
@@ -74,7 +73,7 @@ not the body content should be processed.
7473
<description>
7574
Name of the exported scoped variable for the
7675
resulting value of the test condition. The type
77-
of the scoped variable is Boolean.
76+
of the scoped variable is Boolean.
7877
</description>
7978
<name>var</name>
8079
<required>false</required>
@@ -322,7 +321,7 @@ visibility.
322321
<tag>
323322
<description>
324323
Like &lt;%= ... &gt;, but for expressions.
325-
</description>
324+
</description>
326325
<name>out</name>
327326
<tag-class>org.apache.taglibs.standard.tag.rt.core.OutTag</tag-class>
328327
<body-content>JSP</body-content>

amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpPIFormSectionFeature.java

Lines changed: 24 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@
2121
/**
2222
* Paris Indicators section
2323
24-
* @since Mar 29, 2011
24+
* @since Mar 29, 2011
2525
*/
2626
public class AmpPIFormSectionFeature extends AmpFormSectionFeaturePanel {
2727
private transient static final Comparator<AmpAhsurvey> SURVEY_COMPARATOR = new PIFormSectionSurveyComparator();
2828

2929
public AmpPIFormSectionFeature(String id, String fmName,
3030
final IModel<AmpActivityVersion> am) throws Exception {
3131
super(id, fmName, am);
32-
32+
3333
updateSurveySet(am);
3434
final AbstractReadOnlyModel<List<AmpAhsurvey>> listModel = OnePagerUtil
3535
.getReadOnlyListModelFromSetModel(new PropertyModel<Set<AmpAhsurvey>>(am, "survey"), SURVEY_COMPARATOR);
@@ -46,7 +46,7 @@ protected void populateItem(final ListItem<AmpAhsurvey> item) {
4646
//list.setReuseItems(true);
4747
list.setOutputMarkupId(true);
4848
add(list);
49-
49+
5050
AmpAjaxLinkField addButton = new AmpAjaxLinkField("updateSurveys", "Update Available Surveys", "Update Available Surveys") {
5151
@Override
5252
public void onClick(AjaxRequestTarget target) {
@@ -69,38 +69,30 @@ public int compare(Object o1, Object o2) {
6969
}
7070
};*/
7171
IModel<Set<AmpAhsurvey>> surveys = new PropertyModel<Set<AmpAhsurvey>>(am, "survey");
72-
72+
7373
if (surveys.getObject() == null)
74-
surveys.setObject(new TreeSet<AmpAhsurvey>());
75-
74+
surveys.setObject(new TreeSet<>());
75+
7676
if (am.getObject().getFunding() == null)
77-
am.getObject().setFunding(new HashSet());
77+
am.getObject().setFunding(new HashSet<>());
7878
Set<AmpFunding> fundingSet = am.getObject().getFunding();
79-
79+
8080
Set<AmpOrganisation> piCertOrgs = new HashSet<AmpOrganisation>();
81-
Iterator<AmpFunding> it = fundingSet.iterator();
82-
while (it.hasNext()) {
83-
AmpFunding fund = it.next();
81+
for (AmpFunding fund : fundingSet) {
8482
AmpOrganisation auxOrg = fund.getAmpDonorOrgId();
85-
86-
//check to see if funding org is Bilateral or Multilateral
87-
if(auxOrg!=null && auxOrg.getOrgGrpId()!=null &&auxOrg.getOrgGrpId().getOrgType()!=null)
88-
if("BIL".equalsIgnoreCase(auxOrg.getOrgGrpId().getOrgType().getOrgTypeCode()) ||
89-
"MUL".equalsIgnoreCase(auxOrg.getOrgGrpId().getOrgType().getOrgTypeCode()) ) {
90-
91-
//check to see if actual funding exist
92-
if (fund.getFundingDetails() != null && !fund.getFundingDetails().isEmpty()){
93-
94-
Iterator<AmpFundingDetail> it2 = fund.getFundingDetails().iterator();
95-
while (it2.hasNext()) {
96-
AmpFundingDetail fd = it2.next();
97-
if (fd.getTransactionType() == Constants.DISBURSEMENT){
98-
piCertOrgs.add(auxOrg);
99-
break;
100-
}
83+
84+
//check to see if funding org is Bilateral or Multilateral
85+
if (auxOrg != null && auxOrg.getOrgGrpId() != null && auxOrg.getOrgGrpId().getOrgType() != null && ("BIL".equalsIgnoreCase(auxOrg.getOrgGrpId().getOrgType().getOrgTypeCode()) ||
86+
"MUL".equalsIgnoreCase(auxOrg.getOrgGrpId().getOrgType().getOrgTypeCode()) && (fund.getFundingDetails() != null && !fund.getFundingDetails().isEmpty()))) {
87+
88+
for (AmpFundingDetail fd : fund.getFundingDetails()) {
89+
if (fd.getTransactionType() == Constants.DISBURSEMENT) {
90+
piCertOrgs.add(auxOrg);
91+
break;
10192
}
10293
}
103-
}
94+
95+
}
10496
}
10597

10698
//removing surveys that are not in the funding list any more
@@ -110,19 +102,19 @@ public int compare(Object o1, Object o2) {
110102
while (it2.hasNext()) {
111103
AmpAhsurvey survey = it2.next();
112104
AmpOrganisation org = survey.getAmpDonorOrgId();
113-
105+
114106
if (!piCertOrgs.contains(org))
115107
deleteSurveysList.add(survey);
116108
else
117109
existingSurveyOrgs.add(org);
118110
}
119111
surveys.getObject().removeAll(deleteSurveysList);
120-
112+
121113
//adding non-existing surveys to the list
122114
Iterator<AmpOrganisation> it3 = piCertOrgs.iterator();
123115
while (it3.hasNext()) {
124116
AmpOrganisation org = it3.next();
125-
117+
126118
if (!existingSurveyOrgs.contains(org)){
127119
AmpAhsurvey as = new AmpAhsurvey();
128120
as.setAmpActivityId(am.getObject());
@@ -131,5 +123,5 @@ public int compare(Object o1, Object o2) {
131123
}
132124
}
133125
}
134-
126+
135127
}

amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/sections/AmpSectorsFormSectionFeature.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
*/
55
package org.dgfoundation.amp.onepager.components.features.sections;
66

7-
import java.util.Arrays;
8-
import java.util.Comparator;
9-
import java.util.List;
10-
117
import org.apache.wicket.markup.repeater.RepeatingView;
128
import org.apache.wicket.model.IModel;
139
import org.dgfoundation.amp.onepager.components.features.tables.AmpSectorsFormTableFeature;
@@ -16,14 +12,16 @@
1612
import org.digijava.module.aim.dbentity.AmpClassificationConfiguration;
1713
import org.digijava.module.aim.util.SectorUtil;
1814

15+
import java.util.List;
16+
1917
/**
2018
2119
* since Oct 20, 2010
2220
*/
2321
public class AmpSectorsFormSectionFeature extends AmpFormSectionFeaturePanel {
2422

2523
/**
26-
*
24+
*
2725
*/
2826
private static final long serialVersionUID = -5601918041949098629L;
2927

@@ -36,7 +34,7 @@ public AmpSectorsFormSectionFeature(String id, String fmName,final IModel<AmpAct
3634
throws Exception {
3735
super(id, fmName, am);
3836
this.fmType = AmpFMTypes.MODULE;
39-
37+
4038
RepeatingView view = new RepeatingView("allSectorsTables");
4139
view.setOutputMarkupId(true);
4240
add(view);
@@ -45,9 +43,9 @@ public AmpSectorsFormSectionFeature(String id, String fmName,final IModel<AmpAct
4543

4644
for (AmpClassificationConfiguration sectorConf : allClassificationConfigs) {
4745
AmpSectorsFormTableFeature sectorsTable=new AmpSectorsFormTableFeature(view.newChildId(), sectorConf.getName()+" Sectors", am,sectorConf);
48-
view.add(sectorsTable);
46+
view.add(sectorsTable);
4947
}
50-
48+
5149
}
5250

5351
}

amp/WEB-INF/src/org/dgfoundation/amp/onepager/util/SessionUtil.java

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,20 @@
33
import java.sql.SQLException;
44

55
import javax.servlet.http.HttpServletRequest;
6+
import javax.servlet.http.HttpSession;
67

78
import org.apache.wicket.request.cycle.RequestCycle;
89
import org.digijava.kernel.persistence.PersistenceManager;
910
import org.digijava.module.aim.dbentity.AmpTeamMember;
1011
import org.hibernate.HibernateException;
1112
import org.hibernate.Session;
13+
import org.slf4j.Logger;
14+
import org.slf4j.LoggerFactory;
1215

1316
public class SessionUtil {
14-
15-
// /**
16-
// * Gets current user from session
17-
// * @return
18-
// */
19-
// public static AmpTeamMember getCurrentUser(){
20-
// AmpTeamMember m = null;
21-
// try {
22-
// Session session = PersistenceManager.getSession();
23-
// m = (AmpTeamMember) session.load(AmpTeamMember.class, (long)61);
24-
// } catch (HibernateException e) {
25-
// e.printStackTrace();
26-
// }
27-
// return m;
28-
// }
29-
17+
18+
private static final Logger logger = LoggerFactory.getLogger(SessionUtil.class);
19+
3020
/**
3121
* only available from within a Wicket cycle!
3222
* @return
@@ -35,4 +25,31 @@ public static HttpServletRequest getCurrentServletRequest()
3525
{
3626
return (HttpServletRequest) RequestCycle.get().getRequest().getContainerRequest();
3727
}
28+
29+
public static void extendSessionIfNeeded(HttpServletRequest request) {
30+
HttpSession session = request.getSession(false); // false to prevent creating a new session if it doesn't exist
31+
if (session != null) {
32+
// Get the maximum inactive interval (session timeout) in seconds
33+
int maxInactiveInterval = session.getMaxInactiveInterval();
34+
35+
// Get the creation time of the session
36+
long creationTime = session.getCreationTime();
37+
38+
// Calculate the expiration time of the session
39+
long expirationTime = creationTime + (maxInactiveInterval * 1000L); // Convert seconds to milliseconds
40+
41+
// Get the current time
42+
long currentTime = System.currentTimeMillis();
43+
44+
// Calculate the remaining time in milliseconds
45+
long remainingTime = expirationTime - currentTime;
46+
47+
// Extend session timeout if remaining time is 30 seconds or less
48+
if (remainingTime <= 30000) { // 30 seconds in milliseconds
49+
// Extend session timeout to 130 minutes
50+
session.setMaxInactiveInterval(1800); // 130 minutes * 60 seconds
51+
logger.info("Session timeout extended to "+session.getMaxInactiveInterval());
52+
}
53+
}
54+
}
3855
}

0 commit comments

Comments
 (0)