From 6a340d32a8a7aead6fe3f785c1f5b157a7862423 Mon Sep 17 00:00:00 2001 From: Ernesto Soliani Date: Mon, 29 Aug 2016 12:51:17 -0300 Subject: [PATCH 001/204] AMP-23895 Removing duplicated property setter on pledge documents --- .../module/fundingpledges/action/SavePledge.java | 2 +- .../fundingpledges/action/SelectPledgeProgram.java | 2 +- .../digijava/module/fundingpledges/form/PledgeForm.java | 9 ++------- amp/repository/aim/view/pledgeform/pledgeDocuments.jsp | 6 +++--- .../aim/view/pledgeform/pledgeDocumentsView.jsp | 4 ++-- 5 files changed, 9 insertions(+), 14 deletions(-) diff --git a/amp/WEB-INF/src/org/digijava/module/fundingpledges/action/SavePledge.java b/amp/WEB-INF/src/org/digijava/module/fundingpledges/action/SavePledge.java index d7f1eddf25c..5a7627a8a29 100644 --- a/amp/WEB-INF/src/org/digijava/module/fundingpledges/action/SavePledge.java +++ b/amp/WEB-INF/src/org/digijava/module/fundingpledges/action/SavePledge.java @@ -141,7 +141,7 @@ protected List do_save(PledgeForm plForm) throws Exception // i res.addAll(do_save_programs(session, pledge, plForm.getSelectedProgs())); res.addAll(do_save_locations(session, pledge, plForm.getSelectedLocs())); res.addAll(do_save_funding(session, pledge, plForm.getSelectedFunding())); - res.addAll(do_save_documents(session, pledge, plForm.getSelectedDocsList(), plForm.getInitialDocuments())); + res.addAll(do_save_documents(session, pledge, plForm.getSelectedDocs(), plForm.getInitialDocuments())); session.saveOrUpdate(pledge); if (res.isEmpty()) { //save succeeded boolean newPledge = plForm.isNewPledge(); diff --git a/amp/WEB-INF/src/org/digijava/module/fundingpledges/action/SelectPledgeProgram.java b/amp/WEB-INF/src/org/digijava/module/fundingpledges/action/SelectPledgeProgram.java index 804fc227810..462c588fa1d 100644 --- a/amp/WEB-INF/src/org/digijava/module/fundingpledges/action/SelectPledgeProgram.java +++ b/amp/WEB-INF/src/org/digijava/module/fundingpledges/action/SelectPledgeProgram.java @@ -98,7 +98,7 @@ public ActionForward execute(ActionMapping mapping, ActionForm form, } if (extraAction.equals("pledge_document_delete")){ - pledgeForm.deleteUniquelyIdentifiable(pledgeForm.getSelectedDocsList(), Long.parseLong(request.getParameter("id"))); + pledgeForm.deleteUniquelyIdentifiable(pledgeForm.getSelectedDocs(), Long.parseLong(request.getParameter("id"))); return null; } diff --git a/amp/WEB-INF/src/org/digijava/module/fundingpledges/form/PledgeForm.java b/amp/WEB-INF/src/org/digijava/module/fundingpledges/form/PledgeForm.java index e1250b59e0d..197b0247516 100644 --- a/amp/WEB-INF/src/org/digijava/module/fundingpledges/form/PledgeForm.java +++ b/amp/WEB-INF/src/org/digijava/module/fundingpledges/form/PledgeForm.java @@ -644,15 +644,10 @@ public DocumentShim getSelectedDocs(int index) { public void setSelectedDocs(int index, DocumentShim entry) { this.selectedDocs.set(index, entry); } - - public List getSelectedDocsList() { + + public List getSelectedDocs() { return selectedDocs; } - - public void setSelectedDocsList(List selectedDocs) { - this.selectedDocs = selectedDocs; - } - // TRASH GETTERS AND SETTERS BELOW @java.lang.SuppressWarnings("all") public PledgeForm() { diff --git a/amp/repository/aim/view/pledgeform/pledgeDocuments.jsp b/amp/repository/aim/view/pledgeform/pledgeDocuments.jsp index 1038bc79cc0..f158cb02d82 100644 --- a/amp/repository/aim/view/pledgeform/pledgeDocuments.jsp +++ b/amp/repository/aim/view/pledgeform/pledgeDocuments.jsp @@ -8,10 +8,10 @@
- +

No Documents

- + @@ -21,7 +21,7 @@ - + - + From a439b42ae3649c118be2d5d867a67a5c13f0d312 Mon Sep 17 00:00:00 2001 From: Ernesto Soliani Date: Mon, 29 Aug 2016 15:19:13 -0300 Subject: [PATCH 002/204] AMP-23895 Removing duplicated property setter on pledge documents --- amp/repository/aim/view/pledgeform/pledgeDocumentsView.jsp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amp/repository/aim/view/pledgeform/pledgeDocumentsView.jsp b/amp/repository/aim/view/pledgeform/pledgeDocumentsView.jsp index f3f369f7761..24e7c959847 100644 --- a/amp/repository/aim/view/pledgeform/pledgeDocumentsView.jsp +++ b/amp/repository/aim/view/pledgeform/pledgeDocumentsView.jsp @@ -11,7 +11,7 @@

No Documents

- +
diff --git a/amp/repository/aim/view/pledgeform/pledgeDocumentsView.jsp b/amp/repository/aim/view/pledgeform/pledgeDocumentsView.jsp index b340f07bf46..f3f369f7761 100644 --- a/amp/repository/aim/view/pledgeform/pledgeDocumentsView.jsp +++ b/amp/repository/aim/view/pledgeform/pledgeDocumentsView.jsp @@ -8,7 +8,7 @@
- +

No Documents

@@ -20,7 +20,7 @@
From 7904502f6da8834a29fef0683b4a03b0a056b2a7 Mon Sep 17 00:00:00 2001 From: Ernesto Soliani Date: Wed, 31 Aug 2016 11:53:26 -0300 Subject: [PATCH 003/204] AMP-22962 add missing combination Add missing getter method. Create a work around to avoid exception on missing parameter --- .../org/dgfoundation/amp/nireports/amp/AmpReportsSchema.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/nireports/amp/AmpReportsSchema.java b/amp/WEB-INF/src/org/dgfoundation/amp/nireports/amp/AmpReportsSchema.java index 927995f7f02..c2609545430 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/nireports/amp/AmpReportsSchema.java +++ b/amp/WEB-INF/src/org/dgfoundation/amp/nireports/amp/AmpReportsSchema.java @@ -121,6 +121,11 @@ public class AmpReportsSchema extends AbstractReportsSchema { */ public boolean ENABLE_CACHING = true; + @Override + public Map> getColumns() { + return super.getColumns(); + } + /** * the hierarchies which are transaction-level. Please see here for more details */ From 3e74d3976dd2a890f20413bf0be6096bf3f9aeda Mon Sep 17 00:00:00 2001 From: Ernesto Soliani Date: Wed, 31 Aug 2016 14:22:21 -0300 Subject: [PATCH 004/204] AMP-22962 add missing combination Add missing getter method. Create a work around to avoid exception on missing parameter --- .../amp/nireports/amp/AmpReportsSchema.java | 5 -- .../aim/logic/FundingCalculationsHelper.java | 58 ++++++++++++++++--- 2 files changed, 50 insertions(+), 13 deletions(-) diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/nireports/amp/AmpReportsSchema.java b/amp/WEB-INF/src/org/dgfoundation/amp/nireports/amp/AmpReportsSchema.java index c2609545430..927995f7f02 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/nireports/amp/AmpReportsSchema.java +++ b/amp/WEB-INF/src/org/dgfoundation/amp/nireports/amp/AmpReportsSchema.java @@ -121,11 +121,6 @@ public class AmpReportsSchema extends AbstractReportsSchema { */ public boolean ENABLE_CACHING = true; - @Override - public Map> getColumns() { - return super.getColumns(); - } - /** * the hierarchies which are transaction-level. Please see here for more details */ diff --git a/amp/WEB-INF/src/org/digijava/module/aim/logic/FundingCalculationsHelper.java b/amp/WEB-INF/src/org/digijava/module/aim/logic/FundingCalculationsHelper.java index 4b877cbb7dd..73c1743b0ee 100644 --- a/amp/WEB-INF/src/org/digijava/module/aim/logic/FundingCalculationsHelper.java +++ b/amp/WEB-INF/src/org/digijava/module/aim/logic/FundingCalculationsHelper.java @@ -9,6 +9,7 @@ import java.util.Map; import java.util.function.Supplier; +import org.apache.log4j.Logger; import org.dgfoundation.amp.currencyconvertor.AmpCurrencyConvertor; import org.digijava.module.aim.dbentity.AmpCurrency; import org.digijava.module.aim.dbentity.AmpFunding; @@ -23,11 +24,9 @@ import org.digijava.module.aim.util.DecimalWraper; import org.digijava.module.aim.util.FeaturesUtil; import org.digijava.module.categorymanager.dbentity.AmpCategoryValue; -import org.digijava.module.categorymanager.exceptions.UsedCategoryException; import org.digijava.module.categorymanager.util.CategoryConstants; import org.digijava.module.categorymanager.util.CategoryConstants.HardCodedCategoryValue; -import com.sun.istack.logging.Logger; public class FundingCalculationsHelper { private static Logger logger = Logger.getLogger(FundingCalculationsHelper.class); @@ -70,6 +69,7 @@ public class FundingCalculationsHelper { DecimalWraper totTriangularSscDisbOrder = new DecimalWraper(); DecimalWraper totOfficialDevAidArrears = new DecimalWraper(); DecimalWraper totOdaSscComm = new DecimalWraper(); + DecimalWraper totBilateralSccEDD = new DecimalWraper(); @SuppressWarnings("serial") private static Map transactionTypeLabelMap = new HashMap(){{ @@ -105,6 +105,7 @@ private static String combineKeys(int transType, HardCodedCategoryValue adjKey) put(combineKeys(Constants.ESTIMATED_DONOR_DISBURSEMENT, CategoryConstants.ADJUSTMENT_TYPE_ACTUAL), () -> totActualEDD); put(combineKeys(Constants.ESTIMATED_DONOR_DISBURSEMENT, CategoryConstants.ADJUSTMENT_TYPE_PLANNED), () -> totPlannedEDD); put(combineKeys(Constants.ESTIMATED_DONOR_DISBURSEMENT, CategoryConstants.ADJUSTMENT_TYPE_PIPELINE), () -> totPipelineEDD); + put(combineKeys(Constants.ESTIMATED_DONOR_DISBURSEMENT, CategoryConstants.ADJUSTMENT_TYPE_BILATERAL_SSC), () -> totBilateralSccEDD); put(combineKeys(Constants.EXPENDITURE, CategoryConstants.ADJUSTMENT_TYPE_ACTUAL), () -> totActualExp); put(combineKeys(Constants.EXPENDITURE, CategoryConstants.ADJUSTMENT_TYPE_PLANNED), () -> totPlannedExp); put(combineKeys(Constants.EXPENDITURE, CategoryConstants.ADJUSTMENT_TYPE_PIPELINE), () -> totPipelineExp); @@ -135,8 +136,11 @@ public DecimalWraper getTotalByKey(String adjKey, String transTypeKey) { Supplier supplier = wrapperNames.get(String.format("%s %s", transTypeKey, adjKey)); if(supplier != null) { return supplier.get(); + } else { + logger.error("Unsupported transaction + adjustment combination: " + + String.format("transType: %s, adjType: %s", transTypeKey, adjKey)); } - return null; + return new DecimalWraper(); } /** @@ -277,13 +281,9 @@ protected void addToTotals(AmpCategoryValue adjType, FundingInformationItem fund totalPledged.add(amt); } else { DecimalWraper wrp = getTotalByKey(adjType.getLabel(), getTransactionTypeLabel(fundDet.getTransactionType())); - if (wrp != null){ + if (wrp != null) { wrp.add(amt); } - else { - throw new RuntimeException("Unsupported transaction + adjustment combination: " + - String.format("transType: %s, adjType: %s", fundDet.getTransactionType(), adjType.getLabel())); - } } } @@ -452,6 +452,46 @@ public DecimalWraper getTotOfficialDevAidArrears() { return totOfficialDevAidArrears; } + public DecimalWraper getTotBilaterlaSscExp() { + return totBilaterlaSscExp; + } + + public DecimalWraper getTotTriangularSscExp() { + return totTriangularSscExp; + } + + public DecimalWraper getTotOfficialDevelopmentAidDisb() { + return totOfficialDevelopmentAidDisb; + } + + public DecimalWraper getTotBilateralSscDisb() { + return totBilateralSscDisb; + } + + public DecimalWraper getTotTriangularSscDisb() { + return totTriangularSscDisb; + } + + public DecimalWraper getTotOfficialDevelopmentAidExp() { + return totOfficialDevelopmentAidExp; + } + + public DecimalWraper getTotTriangularSccExp() { + return totTriangularSccExp; + } + + public DecimalWraper getTotBilateralSScExp() { + return totBilateralSScExp; + } + + public DecimalWraper getTotOfficialDevelopmentAidComm() { + return totOfficialDevelopmentAidComm; + } + + public DecimalWraper getTotBilateralSccEDD() { + return totBilateralSccEDD; + } + public boolean isDebug() { return this.debug; } @@ -636,4 +676,6 @@ public void setTotBilateralSscArrears(DecimalWraper totBilateralSscArrears) { public void setTotTriangularSscArrears(DecimalWraper totTriangularSscArrears) { this.totTriangularSscArrears = totTriangularSscArrears; } + + } \ No newline at end of file From d183ea745a7397c51b762c1d79db3e28c391645d Mon Sep 17 00:00:00 2001 From: Gabriel Inchauspe Date: Wed, 31 Aug 2016 16:26:49 -0300 Subject: [PATCH 005/204] AMP-23925: Filters don't get saved in Tabs - WiP: Saving filters work now but not all available filters in the widget are being saved correctly. --- .../converters/AmpReportFiltersConverter.java | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java b/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java index 09b073e0f92..17d75684f5e 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java +++ b/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java @@ -15,7 +15,10 @@ import org.dgfoundation.amp.ar.ColumnConstants; import org.dgfoundation.amp.newreports.AmpReportFilters; import org.dgfoundation.amp.newreports.FilterRule; +import org.dgfoundation.amp.newreports.NamedTypedEntity; import org.dgfoundation.amp.newreports.ReportColumn; +import org.dgfoundation.amp.newreports.ReportElement; +import org.dgfoundation.amp.newreports.ReportElement.ElementType; import org.digijava.kernel.persistence.PersistenceManager; import org.digijava.module.aim.dbentity.AmpOrganisation; import org.digijava.module.aim.dbentity.AmpSector; @@ -57,13 +60,16 @@ public AmpARFilter buildFilters() { } // Donors section. - addFilter(ColumnConstants.DONOR_ID, AmpOrganisation.class, "donnorgAgency", true); + addFilter(ColumnConstants.DONOR_AGENCY, AmpOrganisation.class, "donnorgAgency", true); // Related organizations section. addFilter(ColumnConstants.BENEFICIARY_AGENCY, AmpOrganisation.class, "beneficiaryAgency", true); addFilter(ColumnConstants.EXECUTING_AGENCY, AmpOrganisation.class, "executingAgency", true); addFilter(ColumnConstants.CONTRACTING_AGENCY, AmpOrganisation.class, "contractingAgency", true); addFilter(ColumnConstants.IMPLEMENTING_AGENCY, AmpOrganisation.class, "implementingAgency", true); + //addFilter(ColumnConstants.REGIONAL_GROUP, AmpOrganisation.class, "", true); + addFilter(ColumnConstants.RESPONSIBLE_ORGANIZATION, AmpOrganisation.class, "responsibleorg", true); + //addFilter(ColumnConstants.SECTOR_GROUP, AmpOrganisation.class, "", true); // Sector´s section. addFilter(ColumnConstants.PRIMARY_SECTOR, AmpSector.class, "selectedSectors", true); @@ -80,15 +86,17 @@ public AmpARFilter buildFilters() { addFilter(ColumnConstants.PRIMARY_PROGRAM, AmpTheme.class, "selectedPrimaryPrograms", true); addFilter(ColumnConstants.SECONDARY_PROGRAM, AmpTheme.class, "selectedSecondaryPrograms", true); addFilter(ColumnConstants.NATIONAL_PLANNING_OBJECTIVES, AmpTheme.class, "selectedNatPlanObj", true); - + + // Activity section. + addFilter(ColumnConstants.STATUS, AmpCategoryValue.class, "statuses", true); + addFilter(ColumnConstants.APPROVAL_STATUS, String.class, "approvalStatusSelected", true); + // Other fields. addFilter(ColumnConstants.FINANCING_INSTRUMENT, AmpCategoryValue.class, "financingInstruments", true); addFilter(ColumnConstants.TYPE_OF_ASSISTANCE, AmpCategoryValue.class, "typeOfAssistance", true); addFilter(ColumnConstants.ON_OFF_TREASURY_BUDGET, AmpCategoryValue.class, "budget", true); addFilter(ColumnConstants.WORKSPACES, AmpTeam.class, "workspaces", true); - addFilter(ColumnConstants.STATUS, AmpCategoryValue.class, "statuses", true); - addFilter(ColumnConstants.APPROVAL_STATUS, String.class, "approvalStatusSelected", true); - + this.ampARFilter.setComputedYear(this.filters.getComputedYear()); // System.out.println(this.ampARFilter.toString()); @@ -119,7 +127,7 @@ private void addFilter(String mondrianFilterColumnName, Class ampARFilterFieldCl Method setterMethod = AmpARFilter.class.getDeclaredMethod(getSetterName(ampARFilterFieldName), param); // Get values from Reports API filters. - List filterRules = this.filters.getAllFilterRules().get(new ReportColumn(mondrianFilterColumnName)); + List filterRules = this.filters.getAllFilterRules().get(new ReportElement(new ReportColumn(mondrianFilterColumnName))); if (filterRules != null) { if (paramClass.getName().equals("java.util.Set") || paramClass.getName().equals("java.util.Collection")) { From 53ef64ec49be17b61f98b7b8ad8d3175ab040b1b Mon Sep 17 00:00:00 2001 From: Gabriel Inchauspe Date: Wed, 7 Sep 2016 18:14:38 -0300 Subject: [PATCH 006/204] AMP-23925: Filters don't get saved in Tabs - WiP: Fixed problem showing saved donors in Filter Widget (tabs and saiku). --- .../ampTemplate/script/common/CommonFilterUtils.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/amp/TEMPLATE/ampTemplate/script/common/CommonFilterUtils.js b/amp/TEMPLATE/ampTemplate/script/common/CommonFilterUtils.js index ba72c8dd5d8..89c483db3a8 100644 --- a/amp/TEMPLATE/ampTemplate/script/common/CommonFilterUtils.js +++ b/amp/TEMPLATE/ampTemplate/script/common/CommonFilterUtils.js @@ -66,6 +66,7 @@ CommonFilterUtils.convertJavaFiltersToJS = function(data) { case 'Humanitarian Aid': case 'Disaster Response Marker': case 'Expenditure Class': + case 'Donor Agency': blob.columnFilters[item.name] = _.map(item.values, function(item_) { return parseInt(item_.id); }); @@ -92,12 +93,6 @@ CommonFilterUtils.convertJavaFiltersToJS = function(data) { blob.columnFilters[item.name + ' Level 2'] = blob.columnFilters[item.name + ' Level 1']; break; - case 'Donor Agency': - blob.columnFilters['Donor Id'] = _.map(item.values, function(item_) { - return parseInt(item_.id); - }); - break; - case 'Funding Organization': blob.columnFilters['Donor Id'] = _.map(item.values, function(item_) { return parseInt(item_.id); From 1e8c6628fc3965a142cfdee2b82c6df220a9da06 Mon Sep 17 00:00:00 2001 From: Gabriel Inchauspe Date: Wed, 7 Sep 2016 18:35:34 -0300 Subject: [PATCH 007/204] AMP-23925: Filters don't get saved in Tabs - WiP: Fixed problem showing selected Secondary Sector on Filter Widget. --- amp/TEMPLATE/ampTemplate/script/common/CommonFilterUtils.js | 1 + 1 file changed, 1 insertion(+) diff --git a/amp/TEMPLATE/ampTemplate/script/common/CommonFilterUtils.js b/amp/TEMPLATE/ampTemplate/script/common/CommonFilterUtils.js index 89c483db3a8..2ed7d0953f8 100644 --- a/amp/TEMPLATE/ampTemplate/script/common/CommonFilterUtils.js +++ b/amp/TEMPLATE/ampTemplate/script/common/CommonFilterUtils.js @@ -104,6 +104,7 @@ CommonFilterUtils.convertJavaFiltersToJS = function(data) { blob.columnFilters[item.name] = _.map(item.values, function(item_) { return parseInt(item_.id); }); + blob.columnFilters[item.name + ' Id'] = blob.columnFilters[item.name]; blob.columnFilters[item.name + ' Sub-Sector'] = blob.columnFilters[item.name]; blob.columnFilters[item.name + ' Sub-Sub-Sector'] = blob.columnFilters[item.name]; break; From 8a5da8b66bc444c19c6b685c906bdb385259e185 Mon Sep 17 00:00:00 2001 From: Gabriel Inchauspe Date: Wed, 7 Sep 2016 19:00:30 -0300 Subject: [PATCH 008/204] AMP-23925: Filters don't get saved in Tabs - WiP: Fixed problem showing selected National Planning Objectives on Filter Widget. --- .../reports/converters/AmpReportFiltersConverter.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java b/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java index 17d75684f5e..8905e98b679 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java +++ b/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java @@ -86,6 +86,14 @@ public AmpARFilter buildFilters() { addFilter(ColumnConstants.PRIMARY_PROGRAM, AmpTheme.class, "selectedPrimaryPrograms", true); addFilter(ColumnConstants.SECONDARY_PROGRAM, AmpTheme.class, "selectedSecondaryPrograms", true); addFilter(ColumnConstants.NATIONAL_PLANNING_OBJECTIVES, AmpTheme.class, "selectedNatPlanObj", true); + addFilter(ColumnConstants.NATIONAL_PLANNING_OBJECTIVES_LEVEL_1, AmpTheme.class, "selectedNatPlanObj", false); + addFilter(ColumnConstants.NATIONAL_PLANNING_OBJECTIVES_LEVEL_2, AmpTheme.class, "selectedNatPlanObj", false); + addFilter(ColumnConstants.NATIONAL_PLANNING_OBJECTIVES_LEVEL_3, AmpTheme.class, "selectedNatPlanObj", false); + addFilter(ColumnConstants.NATIONAL_PLANNING_OBJECTIVES_LEVEL_4, AmpTheme.class, "selectedNatPlanObj", false); + addFilter(ColumnConstants.NATIONAL_PLANNING_OBJECTIVES_LEVEL_5, AmpTheme.class, "selectedNatPlanObj", false); + addFilter(ColumnConstants.NATIONAL_PLANNING_OBJECTIVES_LEVEL_6, AmpTheme.class, "selectedNatPlanObj", false); + addFilter(ColumnConstants.NATIONAL_PLANNING_OBJECTIVES_LEVEL_7, AmpTheme.class, "selectedNatPlanObj", false); + addFilter(ColumnConstants.NATIONAL_PLANNING_OBJECTIVES_LEVEL_8, AmpTheme.class, "selectedNatPlanObj", false); // Activity section. addFilter(ColumnConstants.STATUS, AmpCategoryValue.class, "statuses", true); @@ -173,7 +181,7 @@ private void addFilter(String mondrianFilterColumnName, Class ampARFilterFieldCl throw new RuntimeException(paramClass.getName()); } } else { - // logger.info("Not found filter: " + mondrianFilterColumnName); + logger.info("Not found filter: " + mondrianFilterColumnName); } } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { From 91a2dfb2f2a1ca54d2b5bb00904d7310ff0f1209 Mon Sep 17 00:00:00 2001 From: Gabriel Inchauspe Date: Wed, 7 Sep 2016 19:19:16 -0300 Subject: [PATCH 009/204] AMP-23925: Filters don't get saved in Tabs - WiP: Fixed problem showing selected Primary Program on Filter Widget. --- .../ampTemplate/script/common/CommonFilterUtils.js | 4 +++- .../amp/reports/converters/AmpReportFiltersConverter.java | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/amp/TEMPLATE/ampTemplate/script/common/CommonFilterUtils.js b/amp/TEMPLATE/ampTemplate/script/common/CommonFilterUtils.js index 2ed7d0953f8..454e7de540b 100644 --- a/amp/TEMPLATE/ampTemplate/script/common/CommonFilterUtils.js +++ b/amp/TEMPLATE/ampTemplate/script/common/CommonFilterUtils.js @@ -90,7 +90,9 @@ CommonFilterUtils.convertJavaFiltersToJS = function(data) { item_) { return parseInt(item_.id); }); - blob.columnFilters[item.name + ' Level 2'] = blob.columnFilters[item.name + ' Level 1']; + for (var i = 2; i < 9; i++) { + blob.columnFilters[item.name + ' Level ' + i] = blob.columnFilters[item.name + ' Level 1']; + } break; case 'Funding Organization': diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java b/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java index 8905e98b679..3b621db6ad5 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java +++ b/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java @@ -84,6 +84,14 @@ public AmpARFilter buildFilters() { // Programs and national objectives section. addFilter(ColumnConstants.PRIMARY_PROGRAM, AmpTheme.class, "selectedPrimaryPrograms", true); + addFilter(ColumnConstants.PRIMARY_PROGRAM_LEVEL_1, AmpTheme.class, "selectedPrimaryPrograms", false); + addFilter(ColumnConstants.PRIMARY_PROGRAM_LEVEL_2, AmpTheme.class, "selectedPrimaryPrograms", false); + addFilter(ColumnConstants.PRIMARY_PROGRAM_LEVEL_3, AmpTheme.class, "selectedPrimaryPrograms", false); + addFilter(ColumnConstants.PRIMARY_PROGRAM_LEVEL_4, AmpTheme.class, "selectedPrimaryPrograms", false); + addFilter(ColumnConstants.PRIMARY_PROGRAM_LEVEL_5, AmpTheme.class, "selectedPrimaryPrograms", false); + addFilter(ColumnConstants.PRIMARY_PROGRAM_LEVEL_6, AmpTheme.class, "selectedPrimaryPrograms", false); + addFilter(ColumnConstants.PRIMARY_PROGRAM_LEVEL_7, AmpTheme.class, "selectedPrimaryPrograms", false); + addFilter(ColumnConstants.PRIMARY_PROGRAM_LEVEL_8, AmpTheme.class, "selectedPrimaryPrograms", false); addFilter(ColumnConstants.SECONDARY_PROGRAM, AmpTheme.class, "selectedSecondaryPrograms", true); addFilter(ColumnConstants.NATIONAL_PLANNING_OBJECTIVES, AmpTheme.class, "selectedNatPlanObj", true); addFilter(ColumnConstants.NATIONAL_PLANNING_OBJECTIVES_LEVEL_1, AmpTheme.class, "selectedNatPlanObj", false); From 551238131d84ca2af03a110f19e3551943b337dc Mon Sep 17 00:00:00 2001 From: Gabriel Inchauspe Date: Wed, 7 Sep 2016 20:28:07 -0300 Subject: [PATCH 010/204] AMP-23925: Filters don't get saved in Tabs - WiP: Fixed problem showing selected Secondary Program on Filter Widget. --- .../reports/converters/AmpReportFiltersConverter.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java b/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java index 3b621db6ad5..b4fa2fc3604 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java +++ b/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java @@ -92,7 +92,17 @@ public AmpARFilter buildFilters() { addFilter(ColumnConstants.PRIMARY_PROGRAM_LEVEL_6, AmpTheme.class, "selectedPrimaryPrograms", false); addFilter(ColumnConstants.PRIMARY_PROGRAM_LEVEL_7, AmpTheme.class, "selectedPrimaryPrograms", false); addFilter(ColumnConstants.PRIMARY_PROGRAM_LEVEL_8, AmpTheme.class, "selectedPrimaryPrograms", false); + addFilter(ColumnConstants.SECONDARY_PROGRAM, AmpTheme.class, "selectedSecondaryPrograms", true); + addFilter(ColumnConstants.SECONDARY_PROGRAM_LEVEL_1, AmpTheme.class, "selectedSecondaryPrograms", false); + addFilter(ColumnConstants.SECONDARY_PROGRAM_LEVEL_2, AmpTheme.class, "selectedSecondaryPrograms", false); + addFilter(ColumnConstants.SECONDARY_PROGRAM_LEVEL_3, AmpTheme.class, "selectedSecondaryPrograms", false); + addFilter(ColumnConstants.SECONDARY_PROGRAM_LEVEL_4, AmpTheme.class, "selectedSecondaryPrograms", false); + addFilter(ColumnConstants.SECONDARY_PROGRAM_LEVEL_5, AmpTheme.class, "selectedSecondaryPrograms", false); + addFilter(ColumnConstants.SECONDARY_PROGRAM_LEVEL_6, AmpTheme.class, "selectedSecondaryPrograms", false); + addFilter(ColumnConstants.SECONDARY_PROGRAM_LEVEL_7, AmpTheme.class, "selectedSecondaryPrograms", false); + addFilter(ColumnConstants.SECONDARY_PROGRAM_LEVEL_8, AmpTheme.class, "selectedSecondaryPrograms", false); + addFilter(ColumnConstants.NATIONAL_PLANNING_OBJECTIVES, AmpTheme.class, "selectedNatPlanObj", true); addFilter(ColumnConstants.NATIONAL_PLANNING_OBJECTIVES_LEVEL_1, AmpTheme.class, "selectedNatPlanObj", false); addFilter(ColumnConstants.NATIONAL_PLANNING_OBJECTIVES_LEVEL_2, AmpTheme.class, "selectedNatPlanObj", false); From cc4a5b9a1986f6d18e18c432e7eda84fb0eb64d5 Mon Sep 17 00:00:00 2001 From: "apicca@developmentgateway.org" Date: Thu, 8 Sep 2016 09:02:33 -0300 Subject: [PATCH 011/204] AMP-21463 Tabs Default sorting - Items in Tabs are not displayed by alphabetical order --- .../tabs/js/business/filter/filterUtils.js | 11 ++++++++++- .../ampTemplate/tabs/js/business/tabEvents.js | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/amp/TEMPLATE/ampTemplate/tabs/js/business/filter/filterUtils.js b/amp/TEMPLATE/ampTemplate/tabs/js/business/filter/filterUtils.js index 26b3ff4fde8..74e97693f14 100644 --- a/amp/TEMPLATE/ampTemplate/tabs/js/business/filter/filterUtils.js +++ b/amp/TEMPLATE/ampTemplate/tabs/js/business/filter/filterUtils.js @@ -8,7 +8,7 @@ define([ 'models/filter', 'collections/filters', 'business/translations/translat } } - FilterUtils.extractSorters = function(content, columns, measures) { + FilterUtils.extractSorters = function(content, columns, measures, hierarchies) { var sorting = {}; if (content !== null && content.models !== null) { sorting.sord = content.models[0].get('ascending') ? "asc" : "desc"; @@ -19,6 +19,15 @@ define([ 'models/filter', 'collections/filters', 'business/translations/translat sorting.sidx = value; } } + } else { + sorting.sord = "asc"; + sorting.sidx = ""; + _.each(columns.models, function(column) { + if (_.find(hierarchies.models, function (item) {return item.get('entityName').trim() === column.get('entityName');}) === undefined) { + sorting.sidx += ( sorting.sidx == "" ? "" : ", " ) + column.get('entityName'); + } + }); + } // Added for AMP-22511: We need to cleanup the sorters if they are defined over a column no longer in the report. if (sorting.sidx !== undefined) { diff --git a/amp/TEMPLATE/ampTemplate/tabs/js/business/tabEvents.js b/amp/TEMPLATE/ampTemplate/tabs/js/business/tabEvents.js index c5b72010e1c..8eba53e6947 100644 --- a/amp/TEMPLATE/ampTemplate/tabs/js/business/tabEvents.js +++ b/amp/TEMPLATE/ampTemplate/tabs/js/business/tabEvents.js @@ -50,7 +50,8 @@ define([ 'marionette', 'models/content', 'models/legend', 'views/dynamicContentV // Save default sorters if any. app.TabsApp.currentSorting = FilterUtils.extractSorters(firstContent.get('reportMetadata').get('reportSpec').get('sorters'), firstContent.get('reportMetadata').get('reportSpec').get('columns'), - firstContent.get('reportMetadata').get('reportSpec').get('measures')); + firstContent.get('reportMetadata').get('reportSpec').get('measures'), + firstContent.get('reportMetadata').get('reportSpec').get('hierarchies')); // Define the views. var FilterItemView = Marionette.ItemView.extend({ tagName : 'div', From 254f8ce568cad2ec75468c2800c46b1275e5412e Mon Sep 17 00:00:00 2001 From: Octavian Ciubotaru Date: Thu, 8 Sep 2016 16:05:02 +0300 Subject: [PATCH 012/204] AMP-23930 - Exception when running regional reports --- amp/repository/aim/view/showTeamReports.jsp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/amp/repository/aim/view/showTeamReports.jsp b/amp/repository/aim/view/showTeamReports.jsp index 5900bcf23e2..e53637b449b 100644 --- a/amp/repository/aim/view/showTeamReports.jsp +++ b/amp/repository/aim/view/showTeamReports.jsp @@ -17,6 +17,7 @@ <%@ taglib uri="/taglib/category" prefix="category" %> <%@ page language="java" import="org.digijava.module.aim.helper.TeamMember" %> +<%@ page import="org.dgfoundation.amp.ar.ArConstants" %> @@ -477,9 +478,13 @@ $(document).ready(function() { diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/tables/AmpBudgetSectionFormTableFeature.java b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/tables/AmpBudgetSectionFormTableFeature.java index 6730eee2de6..d74c03e6a69 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/tables/AmpBudgetSectionFormTableFeature.java +++ b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/tables/AmpBudgetSectionFormTableFeature.java @@ -1,6 +1,5 @@ package org.dgfoundation.amp.onepager.components.features.tables; -import java.text.NumberFormat; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; @@ -8,9 +7,9 @@ import java.util.List; import java.util.Set; +import org.apache.wicket.AttributeModifier; import org.apache.wicket.MarkupContainer; import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.AttributeModifier; import org.apache.wicket.event.Broadcast; import org.apache.wicket.extensions.ajax.markup.html.AjaxIndicatorAppender; import org.apache.wicket.markup.html.WebMarkupContainer; @@ -22,28 +21,17 @@ import org.apache.wicket.model.Model; import org.apache.wicket.model.PropertyModel; import org.apache.wicket.util.convert.IConverter; -import org.apache.wicket.util.convert.converter.DoubleConverter; -import org.dgfoundation.amp.onepager.components.fields.*; +import org.dgfoundation.amp.onepager.components.fields.AmpMinSizeCollectionValidationField; +import org.dgfoundation.amp.onepager.components.fields.AmpPercentageCollectionValidatorField; +import org.dgfoundation.amp.onepager.components.fields.AmpPercentageTextField; +import org.dgfoundation.amp.onepager.components.fields.AmpTextFieldPanel; import org.dgfoundation.amp.onepager.converters.CustomDoubleConverter; import org.dgfoundation.amp.onepager.events.TotalBudgetStructureUpdateEvent; import org.dgfoundation.amp.onepager.events.UpdateEventBehavior; import org.dgfoundation.amp.onepager.models.AmpBudgetStructureModel; -import org.dgfoundation.amp.onepager.models.AmpThemeSearchModel; -import org.dgfoundation.amp.onepager.models.PersistentObjectModel; -import org.dgfoundation.amp.onepager.translation.TranslatorUtil; import org.dgfoundation.amp.onepager.util.AmpDividePercentageField; -import org.dgfoundation.amp.onepager.yui.AmpAutocompleteFieldPanel; -import org.digijava.kernel.exception.DgException; -import org.digijava.module.aim.dbentity.AmpActivityLocation; import org.digijava.module.aim.dbentity.AmpActivityBudgetStructure; -import org.digijava.module.aim.dbentity.AmpActivityProgramSettings; -import org.digijava.module.aim.dbentity.AmpActivitySector; import org.digijava.module.aim.dbentity.AmpActivityVersion; -import org.digijava.module.aim.dbentity.AmpTheme; -import org.digijava.module.aim.helper.FormatHelper; -import org.digijava.module.aim.util.AmpAutoCompleteDisplayable; -import org.digijava.module.aim.util.DbUtil; -import org.digijava.module.aim.util.ProgramUtil; import org.digijava.module.categorymanager.dbentity.AmpCategoryValue; import org.digijava.module.categorymanager.util.CategoryManagerUtil; @@ -90,29 +78,19 @@ public AmpBudgetSectionFormTableFeature(String id, String fmName, @Override public List getObject() { - Set allProgs = setModel.getObject(); - Set specificProgs = new HashSet(); + Set actBudgetItems = setModel.getObject(); + Set specificActBudgetItems = new HashSet(); - if (allProgs!=null){ - Iterator it = allProgs.iterator(); + if (actBudgetItems!=null){ + Iterator it = actBudgetItems.iterator(); while (it.hasNext()) { - AmpActivityBudgetStructure prog = it.next(); - if (prog != null ) - specificProgs.add(prog); + AmpActivityBudgetStructure actBugStruct = it.next(); + if (actBugStruct != null ) + specificActBudgetItems.add(actBugStruct); } } - /*Collection posVal = CategoryManagerUtil.getAmpCategoryValueCollectionByKey("budgetStructure"); - Iterator it = posVal.iterator(); - while(it.hasNext()){ - AmpCategoryValue acv = it.next(); - AmpActivityBudgetStructure abs = new AmpActivityBudgetStructure(); - abs.setActivity(am.getObject()); - abs.setBudgetStructureName(acv.getValue()); - abs.setBudgetStructurePercentage(new Float(0)); - if(!specificProgs.contains(abs)) - setModel.getObject().add(abs); - }*/ - return new ArrayList(specificProgs); + + return new ArrayList(specificActBudgetItems); } }; @@ -122,7 +100,7 @@ public List getObject() { wmc.add(iValidator); final AmpPercentageCollectionValidatorField percentageValidationField = new AmpPercentageCollectionValidatorField( - "programPercentageTotal", listModel, "programPercentageTotal") { + "budgetSectorPercentageTotal", listModel, "budgetSectorPercentageTotal") { @Override public Number getPercentage(AmpActivityBudgetStructure item) { return item.getBudgetStructurePercentage(); @@ -130,10 +108,11 @@ public Number getPercentage(AmpActivityBudgetStructure item) { }; percentageValidationField.setIndicatorAppender(iValidator); percentageValidationField.add(UpdateEventBehavior.of(TotalBudgetStructureUpdateEvent.class)); + percentageValidationField.setOutputMarkupId(true); add(percentageValidationField); final AmpMinSizeCollectionValidationField minSizeCollectionValidationField = new AmpMinSizeCollectionValidationField( - "minSizeProgramValidator", listModel, "minSizeProgramValidator"){ + "minSizeBudgetSectorValidator", listModel, "minSizeBudgetSectorValidator"){ @Override protected void onConfigure() { super.onConfigure(); @@ -146,59 +125,26 @@ protected void onConfigure() { minSizeCollectionValidationField.setIndicatorAppender(iValidator); add(minSizeCollectionValidationField); - final AmpUniqueCollectionValidatorField uniqueCollectionValidationField = new AmpUniqueCollectionValidatorField( - "uniqueProgramsValidator", listModel, "uniqueProgramsValidator") { - @Override - public Object getIdentifier(AmpActivityBudgetStructure t) { - return t.getBudgetStructureName(); - } - }; - uniqueCollectionValidationField.setIndicatorAppender(iValidator); - add(uniqueCollectionValidationField); - - /*AmpTextFieldPanel amount = new AmpTextFieldPanel("proposedAmount1", - null,"",true,true) { - public IConverter getInternalConverter(java.lang.Class type) { - DoubleConverter converter = (DoubleConverter) DoubleConverter.INSTANCE; - NumberFormat formatter = FormatHelper.getDecimalFormat(true); - converter.setNumberFormat(getLocale(), formatter); - return converter; - } - }; - amount.getTextContainer().add(new AttributeModifier("size", new Model("1"))); - add(amount);*/ - AmpTextFieldPanel amount = new AmpTextFieldPanel("totalBudgetAmount", new AmpBudgetStructureModel(new PropertyModel>(am, "actBudgetStructure")), "",true,true) { - public IConverter getInternalConverter(java.lang.Class type) { - return CustomDoubleConverter.INSTANCE; - } }; amount.add(UpdateEventBehavior.of(TotalBudgetStructureUpdateEvent.class)); amount.getTextContainer().add(new AttributeModifier("size", new Model("1"))); amount.getTextContainer().add(new AttributeModifier("readonly", new Model("readonly"))); add(amount); - /*final AmpTreeCollectionValidatorField treeCollectionValidatorField = new AmpTreeCollectionValidatorField("treeValidator", listModel, "Tree Validator") { - @Override - public AmpAutoCompleteDisplayable getItem(AmpActivityBudgetStructure t) { - return t.getProgram(); - } - }; - treeCollectionValidatorField.setIndicatorAppender(iValidator); - add(treeCollectionValidatorField); -*/ list = new ListView("listBudget", listModel) { private static final long serialVersionUID = 7218457979728871528L; @Override protected void populateItem(final ListItem item) { - final MarkupContainer listParent=this.getParent(); + final MarkupContainer listParent = this.getParent(); PropertyModel percModel = new PropertyModel( item.getModel(), "budgetStructurePercentage"); AmpPercentageTextField percentageField = new AmpPercentageTextField("percent", percModel, "budgetStructurePercentage",percentageValidationField,false){ @Override protected void onAjaxOnUpdate(final AjaxRequestTarget target) { + super.onAjaxOnUpdate(target); onBudgetSectionChanged(target); } }; @@ -222,19 +168,17 @@ public void setPercentage(AmpActivityBudgetStructure loc, int val) { } @Override public int getPercentage(AmpActivityBudgetStructure loc) { - return (int)((float)(loc.getBudgetStructurePercentage())); + return loc.getBudgetStructurePercentage().intValue(); } @Override public boolean itemInCollection(AmpActivityBudgetStructure item) { - /*if (item != null && item.getProgramSetting() != null && item.getProgramSetting().getAmpProgramSettingsId() == programSettings.getObject().getAmpProgramSettingsId()) - return true;*/ return true; } }); } - + protected void onBudgetSectionChanged(AjaxRequestTarget target) { send(AmpBudgetSectionFormTableFeature.this, Broadcast.BREADTH, new TotalBudgetStructureUpdateEvent(target)); } diff --git a/amp/xmlpatches/2.z12.05/AMP-23914-remove-budget-sector-validators.xml b/amp/xmlpatches/2.z12.05/AMP-23914-remove-budget-sector-validators.xml new file mode 100644 index 00000000000..0762bf96f60 --- /dev/null +++ b/amp/xmlpatches/2.z12.05/AMP-23914-remove-budget-sector-validators.xml @@ -0,0 +1,19 @@ + + + AMP-23914 + FM budget sectors validators + vchihai + Remove budget sectors validators FM path + + + + From 767795884be1a203ff459cc68398e140d72b6488 Mon Sep 17 00:00:00 2001 From: Gabriel Inchauspe Date: Thu, 8 Sep 2016 14:22:58 -0300 Subject: [PATCH 016/204] AMP-23925: Filters don't get saved in Tabs - WiP: Fixed problem showing selected Locations on Filter Widget. --- .../amp/reports/converters/AmpReportFiltersConverter.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java b/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java index b4fa2fc3604..863a36ec24a 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java +++ b/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java @@ -20,6 +20,7 @@ import org.dgfoundation.amp.newreports.ReportElement; import org.dgfoundation.amp.newreports.ReportElement.ElementType; import org.digijava.kernel.persistence.PersistenceManager; +import org.digijava.module.aim.dbentity.AmpCategoryValueLocations; import org.digijava.module.aim.dbentity.AmpOrganisation; import org.digijava.module.aim.dbentity.AmpSector; import org.digijava.module.aim.dbentity.AmpTeam; @@ -117,6 +118,12 @@ public AmpARFilter buildFilters() { addFilter(ColumnConstants.STATUS, AmpCategoryValue.class, "statuses", true); addFilter(ColumnConstants.APPROVAL_STATUS, String.class, "approvalStatusSelected", true); + // Location section. + addFilter(ColumnConstants.COUNTRY, AmpCategoryValueLocations.class, "locationSelected", true); + addFilter(ColumnConstants.DISTRICT, AmpCategoryValueLocations.class, "locationSelected", false); + addFilter(ColumnConstants.REGION, AmpCategoryValueLocations.class, "locationSelected", false); + addFilter(ColumnConstants.ZONE, AmpCategoryValueLocations.class, "locationSelected", false); + // Other fields. addFilter(ColumnConstants.FINANCING_INSTRUMENT, AmpCategoryValue.class, "financingInstruments", true); addFilter(ColumnConstants.TYPE_OF_ASSISTANCE, AmpCategoryValue.class, "typeOfAssistance", true); From 1fc858c03552968a217ed004478ff52bff42b3c7 Mon Sep 17 00:00:00 2001 From: Gabriel Inchauspe Date: Thu, 8 Sep 2016 20:06:06 -0300 Subject: [PATCH 017/204] AMP-23925: Filters don't get saved in Tabs - WiP: Fixed problem showing selected Humanitarian Aid on Filter Widget (still not visible in the Filter Widget after reload). --- .../converters/AmpReportFiltersConverter.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java b/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java index 863a36ec24a..3cd06a201f1 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java +++ b/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java @@ -124,11 +124,14 @@ public AmpARFilter buildFilters() { addFilter(ColumnConstants.REGION, AmpCategoryValueLocations.class, "locationSelected", false); addFilter(ColumnConstants.ZONE, AmpCategoryValueLocations.class, "locationSelected", false); - // Other fields. + // Financial section. addFilter(ColumnConstants.FINANCING_INSTRUMENT, AmpCategoryValue.class, "financingInstruments", true); addFilter(ColumnConstants.TYPE_OF_ASSISTANCE, AmpCategoryValue.class, "typeOfAssistance", true); addFilter(ColumnConstants.ON_OFF_TREASURY_BUDGET, AmpCategoryValue.class, "budget", true); addFilter(ColumnConstants.WORKSPACES, AmpTeam.class, "workspaces", true); + + // Other section. + addFilter(ColumnConstants.HUMANITARIAN_AID, Integer.class, "humanitarianAid", true); this.ampARFilter.setComputedYear(this.filters.getComputedYear()); @@ -173,11 +176,13 @@ private void addFilter(String mondrianFilterColumnName, Class ampARFilterFieldCl Iterator iValues = auxFilterRule.values.iterator(); while (iValues.hasNext()) { String auxValue = iValues.next(); - if (!ampARFilterFieldClass.toString().equals("class java.lang.String")) { - Object auxEntity = session.load(ampARFilterFieldClass, new Long(auxValue)); - values.add(auxEntity); - } else { + if (ampARFilterFieldClass.toString().equals("class java.lang.String")) { values.add(auxValue); + } else if (ampARFilterFieldClass.toString().equals("class java.lang.Integer")) { + values.add(Integer.valueOf(auxValue)); + } else { + Object auxEntity = session.load(ampARFilterFieldClass, new Long(auxValue)); + values.add(auxEntity); } } } From f933951edc1798f7fd2bdf31f429b711caaf2ceb Mon Sep 17 00:00:00 2001 From: Gabriel Inchauspe Date: Thu, 8 Sep 2016 20:09:24 -0300 Subject: [PATCH 018/204] AMP-23925: Filters don't get saved in Tabs - WiP: Fixed problem showing selected Disaster Response on Filter Widget (still not visible in the Filter Widget after reload). --- .../amp/reports/converters/AmpReportFiltersConverter.java | 1 + 1 file changed, 1 insertion(+) diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java b/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java index 3cd06a201f1..99fe320b1b7 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java +++ b/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java @@ -132,6 +132,7 @@ public AmpARFilter buildFilters() { // Other section. addFilter(ColumnConstants.HUMANITARIAN_AID, Integer.class, "humanitarianAid", true); + addFilter(ColumnConstants.DISASTER_RESPONSE_MARKER, Integer.class, "disasterResponse", true); this.ampARFilter.setComputedYear(this.filters.getComputedYear()); From 0ff512cad6f5acdeda2f36fd41a29eadbd5f7785 Mon Sep 17 00:00:00 2001 From: Viorel Chihai Date: Fri, 9 Sep 2016 10:52:44 +0300 Subject: [PATCH 019/204] AMP-23895: Fix pledge form tests --- .../java/org/dgfoundation/amp/ar/legacy/PledgesFormTests.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/amp/src/test/java/org/dgfoundation/amp/ar/legacy/PledgesFormTests.java b/amp/src/test/java/org/dgfoundation/amp/ar/legacy/PledgesFormTests.java index 85228cf6d6c..a8edd9701bf 100644 --- a/amp/src/test/java/org/dgfoundation/amp/ar/legacy/PledgesFormTests.java +++ b/amp/src/test/java/org/dgfoundation/amp/ar/legacy/PledgesFormTests.java @@ -13,7 +13,6 @@ import org.digijava.module.fundingpledges.action.DisableableKeyValue; import org.digijava.module.fundingpledges.dbentity.FundingPledges; import org.digijava.module.fundingpledges.dbentity.FundingPledgesLocation; -import org.digijava.module.fundingpledges.dbentity.FundingPledgesSector; import org.digijava.module.fundingpledges.dbentity.PledgesEntityHelper; import org.digijava.module.fundingpledges.form.DocumentShim; import org.digijava.module.fundingpledges.form.PledgeForm; @@ -58,7 +57,7 @@ public void testPledgeFormDocuments(){ PledgeForm pledgeForm = new PledgeForm(); pledgeForm.importPledgeData(PledgesEntityHelper.getPledgesById(3L)); - assertEquals(3, pledgeForm.getSelectedDocsList().size()); + assertEquals(3, pledgeForm.getSelectedDocs().size()); // assertShimEquals(pledgeForm.getSelectedDocsList().get(0), "aaaa.png", "документ проекта", "4e478d3e-41a4-4b35-b4de-52c07ecd9d5a", 480000); // assertShimEquals(pledgeForm.getSelectedDocsList().get(1), "AMP-17265-amp27.patch", "yahoo", "96e0a2be-53b0-4f16-bb02-a8bc7dc46778", 480000); // assertShimEquals(pledgeForm.getSelectedDocsList().get(2), "SSC Implementation Notes.doc", "some ssc implementation notes", "03b4ed7a-b4d7-4204-8a0b-613131edf9f0", 480000); From 0f4b2c019691ba4f1bc74a0a69b3c77cc785c8fb Mon Sep 17 00:00:00 2001 From: Octavian Ciubotaru Date: Fri, 9 Sep 2016 10:59:25 +0300 Subject: [PATCH 020/204] AMP-23905 - define correct formulas for measures "Percentage of total Commitments/Disbursements" --- .../amp/nireports/AbstractReportsSchema.java | 2 +- .../behaviours/TrivialMeasureBehaviour.java | 23 +++++++++++--- .../output/nicells/NiAmountCell.java | 8 ++++- .../amp/ar/amp212/BasicSanityChecks.java | 31 +++++++++++++++++++ 4 files changed, 58 insertions(+), 6 deletions(-) diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/nireports/AbstractReportsSchema.java b/amp/WEB-INF/src/org/dgfoundation/amp/nireports/AbstractReportsSchema.java index a483b375179..d7140766b3f 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/nireports/AbstractReportsSchema.java +++ b/amp/WEB-INF/src/org/dgfoundation/amp/nireports/AbstractReportsSchema.java @@ -178,7 +178,7 @@ public Map parseMap(String errPrefix, Object.. * @return */ public TrivialMeasureBehaviour byMeasureDividingBehaviour(TimeRange tr, String measureName) { - return new TrivialMeasureBehaviour(tr, TrivialMeasureBehaviour.buildMeasureTotalDivider(measureName)); + return new TrivialMeasureBehaviour(tr, TrivialMeasureBehaviour.buildMeasureTotalDivider(measureName), false); } /** diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/nireports/behaviours/TrivialMeasureBehaviour.java b/amp/WEB-INF/src/org/dgfoundation/amp/nireports/behaviours/TrivialMeasureBehaviour.java index 18d2a2f76e7..b89ab9775bd 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/nireports/behaviours/TrivialMeasureBehaviour.java +++ b/amp/WEB-INF/src/org/dgfoundation/amp/nireports/behaviours/TrivialMeasureBehaviour.java @@ -7,6 +7,7 @@ import java.util.function.BiFunction; import org.dgfoundation.amp.newreports.GroupingCriteria; +import org.dgfoundation.amp.newreports.ReportSettings; import org.dgfoundation.amp.newreports.ReportSpecification; import org.dgfoundation.amp.nireports.Cell; import org.dgfoundation.amp.nireports.ImmutablePair; @@ -37,6 +38,12 @@ public class TrivialMeasureBehaviour implements Behaviour { public static TrivialMeasureBehaviour getTotalsOnlyInstance() {return totalsOnlyInstance;} protected final TimeRange timeRange; + + /** + * Specified whenever cells produced by this behaviour are scalable by units. + * See also {@link ReportSettings#getUnitsOption()}. + */ + protected final boolean isScalableByUnits; /** * horizReductionResult = f(engine, doHorizResult) @@ -54,9 +61,17 @@ public TrivialMeasureBehaviour(TimeRange timeRange) { this(timeRange, null); } - public TrivialMeasureBehaviour(TimeRange timeRange, BiFunction horizResultPostprocessor) { + public TrivialMeasureBehaviour(TimeRange timeRange, + BiFunction horizResultPostprocessor) { + this(timeRange, horizResultPostprocessor, true); + } + + public TrivialMeasureBehaviour(TimeRange timeRange, + BiFunction horizResultPostprocessor, + boolean isScalableByUnits) { this.timeRange = timeRange; this.horizResultPostprocessor = horizResultPostprocessor; + this.isScalableByUnits = isScalableByUnits; } @Override @@ -73,7 +88,7 @@ public NiAmountCell doHorizontalReduce(List cells) { res = res.add(toAdd); } //System.err.format("reduced %d cells to %.2f: %s\n", cells.size(), res.doubleValue(), cells.toString()); - return new NiAmountCell(res, precision); + return new NiAmountCell(res, precision, isScalableByUnits); } @Override @@ -84,7 +99,7 @@ public NiAmountCell horizontalReduce(List cells, NiReportsEngine context BigDecimal zz = horizResultPostprocessor.apply(context, z.amount); if (zz == null) return NiFormulaicAmountCell.FORMULAIC_ZERO; - return new NiAmountCell(zz, z.precisionSetting); + return new NiAmountCell(zz, z.precisionSetting, isScalableByUnits); } return z; } @@ -107,7 +122,7 @@ public NiAmountCell doVerticalReduce(Collection cells) { while(it.hasNext()) res = res.add(it.next().amount); - return new NiAmountCell(res, precisionSetting); + return new NiAmountCell(res, precisionSetting, isScalableByUnits); } @Override diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/nireports/output/nicells/NiAmountCell.java b/amp/WEB-INF/src/org/dgfoundation/amp/nireports/output/nicells/NiAmountCell.java index ea6429292d0..7e0879dabe4 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/nireports/output/nicells/NiAmountCell.java +++ b/amp/WEB-INF/src/org/dgfoundation/amp/nireports/output/nicells/NiAmountCell.java @@ -15,10 +15,16 @@ public class NiAmountCell extends NiOutCell implements NumberedCell { public final BigDecimal amount; public final NiPrecisionSetting precisionSetting; + public final boolean isScalableByUnits; public NiAmountCell(BigDecimal amount, NiPrecisionSetting precisionSetting) { + this(amount, precisionSetting, true); + } + + public NiAmountCell(BigDecimal amount, NiPrecisionSetting precisionSetting, boolean isScalableByUnits) { this.amount = amount; this.precisionSetting = precisionSetting; + this.isScalableByUnits = isScalableByUnits; } @Override @@ -46,7 +52,7 @@ public K accept(CellVisitor visitor, CellColumn niCellColumn) { @Override public boolean isScalableByUnits() { - return true; + return isScalableByUnits; } } diff --git a/amp/src/test/java/org/dgfoundation/amp/ar/amp212/BasicSanityChecks.java b/amp/src/test/java/org/dgfoundation/amp/ar/amp212/BasicSanityChecks.java index f9f6ae6ae9f..f76bd23b222 100644 --- a/amp/src/test/java/org/dgfoundation/amp/ar/amp212/BasicSanityChecks.java +++ b/amp/src/test/java/org/dgfoundation/amp/ar/amp212/BasicSanityChecks.java @@ -1909,6 +1909,37 @@ public void testFetchedMeasureTotal() { runNiTestCase(spec, "en", executionRateActs, cor); } + + @Test + public void testFetchedMeasureTotalAndScaledByThousands() { + NiReportModel cor = new NiReportModel("testFetchedMeasureTotalAndScaledByThousands") + .withHeaders(Arrays.asList( + "(RAW: (startRow: 0, rowSpan: 1, totalRowSpan: 4, colStart: 0, colSpan: 12))", + "(Project Title: (startRow: 1, rowSpan: 3, totalRowSpan: 3, colStart: 0, colSpan: 1));(Primary Sector: (startRow: 1, rowSpan: 3, totalRowSpan: 3, colStart: 1, colSpan: 1));(Funding: (startRow: 1, rowSpan: 1, totalRowSpan: 3, colStart: 2, colSpan: 6));(Totals: (startRow: 1, rowSpan: 2, totalRowSpan: 3, colStart: 8, colSpan: 4))", + "(2013: (startRow: 2, rowSpan: 1, totalRowSpan: 2, colStart: 2, colSpan: 2));(2014: (startRow: 2, rowSpan: 1, totalRowSpan: 2, colStart: 4, colSpan: 2));(2015: (startRow: 2, rowSpan: 1, totalRowSpan: 2, colStart: 6, colSpan: 2))", + "(Actual Commitments: (startRow: 3, rowSpan: 1, totalRowSpan: 1, colStart: 2, colSpan: 1));(Actual Disbursements: (startRow: 3, rowSpan: 1, totalRowSpan: 1, colStart: 3, colSpan: 1));(Actual Commitments: (startRow: 3, rowSpan: 1, totalRowSpan: 1, colStart: 4, colSpan: 1));(Actual Disbursements: (startRow: 3, rowSpan: 1, totalRowSpan: 1, colStart: 5, colSpan: 1));(Actual Commitments: (startRow: 3, rowSpan: 1, totalRowSpan: 1, colStart: 6, colSpan: 1));(Actual Disbursements: (startRow: 3, rowSpan: 1, totalRowSpan: 1, colStart: 7, colSpan: 1));(Actual Commitments: (startRow: 3, rowSpan: 1, totalRowSpan: 1, colStart: 8, colSpan: 1));(Actual Disbursements: (startRow: 3, rowSpan: 1, totalRowSpan: 1, colStart: 9, colSpan: 1));(Percentage of Total Commitments: (startRow: 3, rowSpan: 1, totalRowSpan: 1, colStart: 10, colSpan: 1));(Percentage Of Total Disbursements: (startRow: 3, rowSpan: 1, totalRowSpan: 1, colStart: 11, colSpan: 1))")) + .withWarnings(Arrays.asList()) + .withBody( new ReportAreaForTests(null) + .withContents("Project Title", "", "Primary Sector", "", "Funding-2013-Actual Commitments", "333,33", "Funding-2013-Actual Disbursements", "0", "Funding-2014-Actual Commitments", "80,76", "Funding-2014-Actual Disbursements", "135,2", "Funding-2015-Actual Commitments", "123,46", "Funding-2015-Actual Disbursements", "35,57", "Totals-Actual Commitments", "537,55", "Totals-Actual Disbursements", "170,77", "Totals-Percentage of Total Commitments", "100", "Totals-Percentage Of Total Disbursements", "100") + .withChildren( + new ReportAreaForTests(new AreaOwner(32), "Project Title", "crazy funding 1", "Primary Sector", "110 - EDUCATION", "Funding-2013-Actual Commitments", "333,33", "Totals-Actual Commitments", "333,33", "Totals-Percentage of Total Commitments", "62,01"), + new ReportAreaForTests(new AreaOwner(45), "Project Title", "activity with tertiary_program", "Primary Sector", "110 - EDUCATION", "Funding-2014-Actual Commitments", "15", "Totals-Actual Commitments", "15", "Totals-Percentage of Total Commitments", "2,79"), + new ReportAreaForTests(new AreaOwner(50), "Project Title", "activity with capital spending", "Primary Sector", "110 - EDUCATION", "Funding-2014-Actual Commitments", "65,76", "Funding-2014-Actual Disbursements", "80", "Totals-Actual Commitments", "65,76", "Totals-Actual Disbursements", "80", "Totals-Percentage of Total Commitments", "12,23", "Totals-Percentage Of Total Disbursements", "46,85"), + new ReportAreaForTests(new AreaOwner(67), "Project Title", "third activity with agreements", "Primary Sector", "110 - EDUCATION", "Funding-2015-Actual Commitments", "123,46", "Totals-Actual Commitments", "123,46", "Totals-Percentage of Total Commitments", "22,97"), + new ReportAreaForTests(new AreaOwner(69), "Project Title", "Activity with planned disbursements", "Primary Sector", "112 - BASIC EDUCATION", "Funding-2014-Actual Disbursements", "0,2", "Funding-2015-Actual Disbursements", "0,57", "Totals-Actual Disbursements", "0,77", "Totals-Percentage Of Total Disbursements", "0,45"), + new ReportAreaForTests(new AreaOwner(77), "Project Title", "execution rate activity", "Primary Sector", "110 - EDUCATION", "Funding-2014-Actual Disbursements", "55", "Funding-2015-Actual Disbursements", "35", "Totals-Actual Disbursements", "90", "Totals-Percentage Of Total Disbursements", "52,7") )); + + ReportSpecificationImpl spec = buildSpecification("testFetchedMeasureTotalAndScaledByThousands", + Arrays.asList(ColumnConstants.PROJECT_TITLE, ColumnConstants.PRIMARY_SECTOR), + Arrays.asList(MeasureConstants.ACTUAL_COMMITMENTS, MeasureConstants.ACTUAL_DISBURSEMENTS, MeasureConstants.PERCENTAGE_OF_TOTAL_COMMITMENTS, MeasureConstants.PERCENTAGE_OF_TOTAL_DISBURSEMENTS), + null, + GroupingCriteria.GROUPING_YEARLY); + ReportSettingsImpl settings = new ReportSettingsImpl(); + settings.setUnitsOption(AmountsUnits.AMOUNTS_OPTION_THOUSANDS); + spec.setSettings(settings); + + runNiTestCase(spec, "en", executionRateActs, cor); + } @Test public void testFetchedMeasureTotalMissingPrecursor() { From 7fafa29e01641fe041c519b17c8faa7b0268215b Mon Sep 17 00:00:00 2001 From: Viorel Chihai Date: Fri, 9 Sep 2016 12:46:10 +0300 Subject: [PATCH 021/204] AMP-23849: Public Reports entry tie the code to the GFM entry --- .../module/aim/action/ShowTeamReports.java | 15 +++++---------- amp/repository/aim/view/showTeamReportsPublic.jsp | 4 ++-- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/amp/WEB-INF/src/org/digijava/module/aim/action/ShowTeamReports.java b/amp/WEB-INF/src/org/digijava/module/aim/action/ShowTeamReports.java index 6788beb5709..38cf5f7d6d0 100644 --- a/amp/WEB-INF/src/org/digijava/module/aim/action/ShowTeamReports.java +++ b/amp/WEB-INF/src/org/digijava/module/aim/action/ShowTeamReports.java @@ -8,8 +8,6 @@ import java.util.Iterator; import java.util.List; import java.util.Locale; -import java.util.Set; -import java.util.TreeSet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; @@ -21,20 +19,13 @@ import org.apache.struts.action.ActionMapping; import org.dgfoundation.amp.ar.ARUtil; import org.dgfoundation.amp.ar.AmpARFilter; -import org.dgfoundation.amp.ar.ArConstants; -import org.dgfoundation.amp.ar.ReportContextData; -import org.digijava.kernel.persistence.PersistenceManager; -import org.digijava.kernel.persistence.WorkerException; import org.digijava.kernel.request.TLSUtils; -import org.digijava.kernel.translator.TranslatorWorker; import org.digijava.kernel.util.RequestUtils; import org.digijava.module.aim.dbentity.AmpApplicationSettings; -import org.digijava.module.aim.dbentity.AmpReportHierarchy; import org.digijava.module.aim.dbentity.AmpReports; import org.digijava.module.aim.form.ReportsForm; import org.digijava.module.aim.form.ReportsForm.ReportSortBy; import org.digijava.module.aim.helper.ApplicationSettings; -import org.digijava.module.aim.helper.GlobalSettingsConstants; import org.digijava.module.aim.helper.TeamMember; import org.digijava.module.aim.util.AdvancedReportUtil; import org.digijava.module.aim.util.DbUtil; @@ -105,7 +96,11 @@ public ActionForward execute(ActionMapping mapping, ActionForm form, // if(arf==null) arf=new AmpARFilter(); // arf.setPublicView(true); // session.setAttribute(ArConstants.REPORTS_Z_FILTER, arf); - return mapping.findForward("forwardPublic"); + if(!FeaturesUtil.isVisibleModule("Public Reports")) { + return mapping.findForward("index"); + } else { + return mapping.findForward("forwardPublic"); + } } else return mapping.findForward( forwardName ); diff --git a/amp/repository/aim/view/showTeamReportsPublic.jsp b/amp/repository/aim/view/showTeamReportsPublic.jsp index f75f2f82cd7..80450d1df3d 100644 --- a/amp/repository/aim/view/showTeamReportsPublic.jsp +++ b/amp/repository/aim/view/showTeamReportsPublic.jsp @@ -15,7 +15,7 @@ <%@ taglib uri="/taglib/globalsettings" prefix="gs" %> <%@ page language="java" import="org.digijava.module.aim.helper.TeamMember" %> - +<%if(FeaturesUtil.isVisibleModule("Public Reports")){ %> @@ -630,7 +630,7 @@ function submitForm(action){
+ <% if (report.getType()!=null && report.getType().equals((long) ArConstants.REGIONAL_TYPE)){ %> + + <% } else { %> + <% } %> From de5f50e7f2a018027821882bd1887796079ad175 Mon Sep 17 00:00:00 2001 From: acartaleanu Date: Thu, 8 Sep 2016 18:12:08 +0300 Subject: [PATCH 013/204] AMP-23767: works --- .../saikuui_nireports/index_reports.html | 1 + .../saiku/plugins/AMPFilters/FilterUtils.js | 22 +-- .../js/saiku/plugins/AMPInfo/plugin.js | 16 ++- .../script/common/TranslationManager.js | 131 ++++++++++++++++++ amp/TEMPLATE/ampTemplate/tabs/js/app.js | 2 +- .../tabs/js/business/filter/filterUtils.js | 2 +- .../tabs/js/business/grid/gridManager.js | 2 +- .../js/business/settings/settingsManager.js | 2 +- .../ampTemplate/tabs/js/business/tabEvents.js | 3 +- .../tabs/js/business/tabManager.js | 2 +- .../translations/translationManager.js | 127 ----------------- .../widgets/documentsWidgetManager.js | 2 +- amp/TEMPLATE/ampTemplate/tabs/js/main.js | 9 +- .../ampTemplate/tabs/js/models/settings.js | 2 +- .../tabs/js/views/dynamicContentView.js | 2 +- .../common/TranslationsEndPoints.java | 1 - 16 files changed, 172 insertions(+), 154 deletions(-) create mode 100644 amp/TEMPLATE/ampTemplate/script/common/TranslationManager.js delete mode 100644 amp/TEMPLATE/ampTemplate/tabs/js/business/translations/translationManager.js diff --git a/amp/TEMPLATE/ampTemplate/saikuui_nireports/index_reports.html b/amp/TEMPLATE/ampTemplate/saikuui_nireports/index_reports.html index d0e71be8562..11f745ec4a3 100644 --- a/amp/TEMPLATE/ampTemplate/saikuui_nireports/index_reports.html +++ b/amp/TEMPLATE/ampTemplate/saikuui_nireports/index_reports.html @@ -122,6 +122,7 @@ + diff --git a/amp/TEMPLATE/ampTemplate/saikuui_nireports/js/saiku/plugins/AMPFilters/FilterUtils.js b/amp/TEMPLATE/ampTemplate/saikuui_nireports/js/saiku/plugins/AMPFilters/FilterUtils.js index 4717944780e..9c8dfe2d4cf 100644 --- a/amp/TEMPLATE/ampTemplate/saikuui_nireports/js/saiku/plugins/AMPFilters/FilterUtils.js +++ b/amp/TEMPLATE/ampTemplate/saikuui_nireports/js/saiku/plugins/AMPFilters/FilterUtils.js @@ -6,6 +6,8 @@ FilterUtils.parseValue = function(elem, v) { return {id: v, name: theName}; }; + + //TODO: move to CommonFilterUtils.js and merge with the same function on Tabs. FilterUtils.extractFilters = function(content) { Saiku.logger.log("FilterUtils.extractFilters"); @@ -53,15 +55,18 @@ FilterUtils.extractFilters = function(content) { _.each(content,function(item, i) { //for now only true or false were asked to be translated. //Avoid doing a ajax call for all values if we only need 2. - if (item.name === "true" || item.name === "false") { - item.trnName = item.name/*TranslationManager.getTranslated(item.name)*/; - } - else { - item.trnName = item.name; - } + item.trnName = TranslationManager.getTranslated(item.name); +// if (item.name === "true" || item.name === "false") { +// +// } +// else { +// item.trnName = item.name; +// } }); var auxFilter = { - trnName : item/*TranslationManager.getTranslated(item)*/, +// trnName : item/*TranslationManager.getTranslated(item)*/, + trnName : TranslationManager.getTranslated(item), +// trnName : Saiku.i18n.translate(item), name: item, values : content }; @@ -97,7 +102,8 @@ FilterUtils.extractFilters = function(content) { }); } var auxFilter = { - trnName : item/*TranslationManager.getTranslated(item)*/, +// trnName : item/*TranslationManager.getTranslated(item)*/, + trnName : TranslationManager.getTranslated(item), name: item, values : content }; diff --git a/amp/TEMPLATE/ampTemplate/saikuui_nireports/js/saiku/plugins/AMPInfo/plugin.js b/amp/TEMPLATE/ampTemplate/saikuui_nireports/js/saiku/plugins/AMPInfo/plugin.js index 60e81cd96dd..325a7f17e5d 100644 --- a/amp/TEMPLATE/ampTemplate/saikuui_nireports/js/saiku/plugins/AMPInfo/plugin.js +++ b/amp/TEMPLATE/ampTemplate/saikuui_nireports/js/saiku/plugins/AMPInfo/plugin.js @@ -27,7 +27,9 @@ var AMPInfo = Backbone.View.extend({ animate : "linear", activate: function (event, ui) { $("#amp_info_filters_block").empty(); - var modelFilters = window.currentFilter.serializeToModels(); + //llk + var modelFilters = window.currentFilter.serializeToModels(); +// FilterUtils.updateFiltersRegion(modelFilters); $("#amp_info_filters_block").html(filtersToHtml(modelFilters)); Saiku.i18n.translate(); } @@ -112,8 +114,8 @@ var filtersToHtml = function(filters) { auxItem.id = item.get('id'); auxItem.name = item.get('name'); if (item.get('name') === "true" || item.get('name') === "false") { - //auxItem.trnName = TranslationManager.getTranslated(item.get('name')); - auxItem.trnName = item.get('name'); + auxItem.trnName = TranslationManager.getTranslated(item.get('name')); + //auxItem.trnName = item.get('name'); } else { auxItem.trnName = item.get('name'); @@ -133,16 +135,16 @@ var filtersToHtml = function(filters) { var dateContent = filters.otherFilters[propertyName]; if (dateContent != undefined) { var filter = { - trnName : propertyName, /*TranslationManager.getTranslated(propertyName),*/ + trnName : TranslationManager.getTranslated(propertyName), name : propertyName, values:[] }; if (dateContent.modelType === 'DATE-RANGE-VALUES') { dateContent.start = dateContent.start || ""; dateContent.end = dateContent.end || ""; - - var startDatePrefix = (dateContent.start.length > 0 && dateContent.end.length === 0) ? "from " : ""; - var endDatePrefix = (dateContent.start.length === 0 && dateContent.end.length > 0) ? "until " : ""; + + var startDatePrefix = TranslationManager.getTranslated((dateContent.start.length > 0 && dateContent.end.length === 0) ? "from" : "") + ' '; + var endDatePrefix = TranslationManager.getTranslated((dateContent.start.length === 0 && dateContent.end.length > 0) ? "until" : "") + ' '; if(dateContent.start.length > 0){ filter.values.push({ diff --git a/amp/TEMPLATE/ampTemplate/script/common/TranslationManager.js b/amp/TEMPLATE/ampTemplate/script/common/TranslationManager.js new file mode 100644 index 00000000000..e3963d90a3d --- /dev/null +++ b/amp/TEMPLATE/ampTemplate/script/common/TranslationManager.js @@ -0,0 +1,131 @@ +var TranslationManager = { + globalTranslationCache : {} +}; +"use strict"; + +//var prefix = 'tabs.common:'; +var prefix = ''; +var availableLanguages = null; + +function TranslationManager() { + if (!(this instanceof TranslationManager)) { + throw new TypeError("TranslationManager constructor cannot be called as a function."); + } + getAvailableLanguages (); +} + +TranslationManager.prototype = { + constructor : TranslationManager +}; + +function initializeGlobalTranslationsCache() { +// if (app.TabsApp.globalTranslationCache === undefined || app.TabsApp.globalTranslationCache === null) { +// app.TabsApp.globalTranslationCache = {}; +// } +} + +function putTranslationValueInCache(key, value) { + TranslationManager.globalTranslationCache[key] = value; +} + + +function lookForTranslationByKey(key) { + var translation = TranslationManager.globalTranslationCache[key]; + if (translation) { + // console.log('found translation: ' + key); + return translation; + } else { + return null; + } +} + + +TranslationManager.getAvailableLanguages = function () { + var deferred = $.Deferred(); + if (availableLanguages) { + deferred.resolve(availableLanguages); + } else { + _fetchLanguages().then(function(languages) { + availableLanguages = _.pluck(languages, 'id'); + deferred.resolve(availableLanguages); + }); + } + + return deferred; + +} +function _fetchLanguages (){ +return jQuery.ajax({ + headers : { + 'Accept' : 'application/json', + 'Content-Type' : 'application/json' + }, + 'type' : 'GET', + 'url' : '/rest/translations/multilingual-languages' +}); +} + + +TranslationManager.searchAndTranslate = function() { + initializeGlobalTranslationsCache(); + + var postit = {}; + _.each($("*[data-i18n^='tabs.']"), function(i, val) { + var key = $(i).attr('data-i18n'); + var value = $(i).text(); + var translationFromCache = lookForTranslationByKey(key); + if (translationFromCache === null) { + postit[key] = value; + } + }); + // Do not call endpoint when there is nothing to translate to save some + // extra ms (500ms in Timor!). + if (!jQuery.isEmptyObject(postit)) { + TranslationManager.postJSON('/rest/translations/label-translations', postit, function(data) { + $.each(data, function(key, value) { + putTranslationValueInCache(key, value); + }); + $.each(TranslationManager.globalTranslationCache, function(key, value) { + $("*[data-i18n='" + key + "']").text(value); + }); + }); + } else { + $.each(TranslationManager.globalTranslationCache, function(key, value) { + $("*[data-i18n='" + key + "']").text(value); + }); + } +}; + + + +TranslationManager.getTranslated = function(text) { + initializeGlobalTranslationsCache(); + var translationFromCache = lookForTranslationByKey(prefix + text); + if (translationFromCache != null) { + return translationFromCache; + } else { + var textObject = {}; + var key = prefix + text; + textObject[key] = text; + var response = (TranslationManager.postJSON('/rest/translations/label-translations', textObject, function(data) { + //console.log(data); + })); + putTranslationValueInCache(key, response.responseJSON[key]); + return response.responseJSON[key]; + } +}; + +TranslationManager.postJSON = function (url, data, callback) { + return jQuery.ajax({ + headers : { + 'Accept' : 'application/json', + 'Content-Type' : 'application/json' + }, + 'type' : 'POST', + 'async' : false, + 'url' : url, + 'data' : JSON.stringify(data), + 'dataType' : 'json', + 'success' : callback + }); +} \ No newline at end of file diff --git a/amp/TEMPLATE/ampTemplate/tabs/js/app.js b/amp/TEMPLATE/ampTemplate/tabs/js/app.js index cb1de94030a..693117a9641 100644 --- a/amp/TEMPLATE/ampTemplate/tabs/js/app.js +++ b/amp/TEMPLATE/ampTemplate/tabs/js/app.js @@ -6,7 +6,7 @@ var app = app || {}; define( [ 'marionette', 'collections/tabs', 'models/tab', 'views/tabItemView', 'views/tabItemsView', 'views/tabBodyView', 'views/tabBodysView', 'business/tabEvents', 'util/tabUtils', - 'business/filter/filterManager', 'business/translations/translationManager', + 'business/filter/filterManager', 'translationManager', 'business/widgets/documentsWidgetManager', 'jquery', 'jqueryui' ], function(Marionette, Tabs, Tab, TabItemView, TabItemsView, TabBodyView, TabBodysView, TabEvents, TabUtils, FilterManager, TranslationManager, DocumentsWidgetManager, jQuery) { diff --git a/amp/TEMPLATE/ampTemplate/tabs/js/business/filter/filterUtils.js b/amp/TEMPLATE/ampTemplate/tabs/js/business/filter/filterUtils.js index 26b3ff4fde8..96b831807f7 100644 --- a/amp/TEMPLATE/ampTemplate/tabs/js/business/filter/filterUtils.js +++ b/amp/TEMPLATE/ampTemplate/tabs/js/business/filter/filterUtils.js @@ -1,4 +1,4 @@ -define([ 'models/filter', 'collections/filters', 'business/translations/translationManager', 'jquery' ], function(Filter, Filters, TranslationManager, jQuery) { +define([ 'models/filter', 'collections/filters', 'translationManager', 'jquery' ], function(Filter, Filters, TranslationManager, jQuery) { "use strict"; diff --git a/amp/TEMPLATE/ampTemplate/tabs/js/business/grid/gridManager.js b/amp/TEMPLATE/ampTemplate/tabs/js/business/grid/gridManager.js index 8d826225a56..daeca9e310a 100644 --- a/amp/TEMPLATE/ampTemplate/tabs/js/business/grid/gridManager.js +++ b/amp/TEMPLATE/ampTemplate/tabs/js/business/grid/gridManager.js @@ -1,4 +1,4 @@ -define([ 'business/grid/columnsMapping', 'business/translations/translationManager', 'util/tabUtils' ], function(columnsMapping, +define([ 'business/grid/columnsMapping', 'translationManager', 'util/tabUtils' ], function(columnsMapping, TranslationManager, TabUtils) { "use strict"; diff --git a/amp/TEMPLATE/ampTemplate/tabs/js/business/settings/settingsManager.js b/amp/TEMPLATE/ampTemplate/tabs/js/business/settings/settingsManager.js index a54fe685339..f833ade4ec9 100644 --- a/amp/TEMPLATE/ampTemplate/tabs/js/business/settings/settingsManager.js +++ b/amp/TEMPLATE/ampTemplate/tabs/js/business/settings/settingsManager.js @@ -1,4 +1,4 @@ -define([ 'marionette', 'text!views/html/settingsDialogTemplate.html', 'business/translations/translationManager', +define([ 'marionette', 'text!views/html/settingsDialogTemplate.html', 'translationManager', 'business/grid/gridManager', 'models/legend', 'jquery', 'jqueryui' ], function(Marionette, settingsDialogTemplate, TranslationManager, GridManager, Legend, jQuery) { diff --git a/amp/TEMPLATE/ampTemplate/tabs/js/business/tabEvents.js b/amp/TEMPLATE/ampTemplate/tabs/js/business/tabEvents.js index c5b72010e1c..6ba1f7482dc 100644 --- a/amp/TEMPLATE/ampTemplate/tabs/js/business/tabEvents.js +++ b/amp/TEMPLATE/ampTemplate/tabs/js/business/tabEvents.js @@ -3,7 +3,7 @@ define([ 'marionette', 'models/content', 'models/legend', 'views/dynamicContentView', 'text!views/html/filtersWrapperTemplate.html', 'text!views/html/filtersItemTemplate.html', 'models/tab', 'text!views/html/invisibleTabLinkTemplate.html', - 'text!views/html/legendsTemplate.html', 'business/grid/gridManager', 'business/translations/translationManager', + 'text!views/html/legendsTemplate.html', 'business/grid/gridManager', 'translationManager', 'business/filter/filterUtils', 'util/tabUtils', 'jquery', 'jqueryui' ,'models/settings'], function(Marionette, Content, Legend, DynamicContentView, filtersTemplate, filtersItemTemplate, Tab, invisibleTabLinkTemplate, legendsTemplate, gridManager, TranslationManager, FilterUtils, TabUtils, jQuery, Settings) { @@ -43,6 +43,7 @@ define([ 'marionette', 'models/content', 'models/legend', 'views/dynamicContentV // --------------------------------------------------------------------------------------// // TODO: Move filters section elsewhere. + //llk // Create collection of Filters used for legends. app.TabsApp.filters = FilterUtils.extractFilters(firstContent.get('reportMetadata').get('reportSpec').get('filters')); // Variable to save the current serialized filters from widget. diff --git a/amp/TEMPLATE/ampTemplate/tabs/js/business/tabManager.js b/amp/TEMPLATE/ampTemplate/tabs/js/business/tabManager.js index fbfe55de8d7..b69225e6c51 100644 --- a/amp/TEMPLATE/ampTemplate/tabs/js/business/tabManager.js +++ b/amp/TEMPLATE/ampTemplate/tabs/js/business/tabManager.js @@ -1,5 +1,5 @@ define([ 'marionette', 'text!views/html/saveTabDialogTemplate.html', 'models/tab', - 'business/translations/translationManager', 'business/filter/filterManager', 'jquery', 'jqueryui' ], function( + 'translationManager', 'business/filter/filterManager', 'jquery', 'jqueryui' ], function( Marionette, saveTabDialogTemplate, Tab, TranslationManager, FilterManager, jQuery) { "use strict"; diff --git a/amp/TEMPLATE/ampTemplate/tabs/js/business/translations/translationManager.js b/amp/TEMPLATE/ampTemplate/tabs/js/business/translations/translationManager.js deleted file mode 100644 index cdf6434e081..00000000000 --- a/amp/TEMPLATE/ampTemplate/tabs/js/business/translations/translationManager.js +++ /dev/null @@ -1,127 +0,0 @@ -define([ 'underscore', 'jquery', 'i18next' ], function(_, jQuery) { - - "use strict"; - - var prefix = 'tabs.common:'; - var availableLanguages = null; - - function TranslationManager() { - if (!(this instanceof TranslationManager)) { - throw new TypeError("TranslationManager constructor cannot be called as a function."); - } - getAvailableLanguages (); - } - - TranslationManager.prototype = { - constructor : TranslationManager - }; - TranslationManager.getAvailableLanguages = function () { - var deferred = $.Deferred(); - if (availableLanguages) { - deferred.resolve(availableLanguages); - } else { - _fetchLanguages().then(function(languages) { - availableLanguages = _.pluck(languages, 'id'); - deferred.resolve(availableLanguages); - }); - } - - return deferred; - - } - function _fetchLanguages (){ - return jQuery.ajax({ - headers : { - 'Accept' : 'application/json', - 'Content-Type' : 'application/json' - }, - 'type' : 'GET', - 'url' : '/rest/translations/multilingual-languages' - }); - } - - - TranslationManager.searchAndTranslate = function() { - initializeGlobalTranslationsCache(); - - var postit = {}; - _.each($("*[data-i18n^='tabs.']"), function(i, val) { - var key = $(i).attr('data-i18n'); - var value = $(i).text(); - var translationFromCache = lookForTranslationByKey(key); - if (translationFromCache === null) { - postit[key] = value; - } - }); - // Do not call endpoint when there is nothing to translate to save some - // extra ms (500ms in Timor!). - if (!jQuery.isEmptyObject(postit)) { - TranslationManager.postJSON('/rest/translations/label-translations', postit, function(data) { - $.each(data, function(key, value) { - putTranslationValueInCache(key, value); - }); - $.each(app.TabsApp.globalTranslationCache, function(key, value) { - $("*[data-i18n='" + key + "']").text(value); - }); - }); - } else { - $.each(app.TabsApp.globalTranslationCache, function(key, value) { - $("*[data-i18n='" + key + "']").text(value); - }); - } - }; - - TranslationManager.getTranslated = function(text) { - initializeGlobalTranslationsCache(); - var translationFromCache = lookForTranslationByKey(prefix + text); - if (translationFromCache != null) { - return translationFromCache; - } else { - var textObject = {}; - var key = prefix + text; - textObject[key] = text; - var response = (TranslationManager.postJSON('/rest/translations/label-translations', textObject, function(data) { - //console.log(data); - })); - putTranslationValueInCache(key, response.responseJSON[key]); - return response.responseJSON[key]; - } - }; - - TranslationManager.postJSON = function (url, data, callback) { - return jQuery.ajax({ - headers : { - 'Accept' : 'application/json', - 'Content-Type' : 'application/json' - }, - 'type' : 'POST', - 'async' : false, - 'url' : url, - 'data' : JSON.stringify(data), - 'dataType' : 'json', - 'success' : callback - }); - } - - function initializeGlobalTranslationsCache() { - if (app.TabsApp.globalTranslationCache === undefined || app.TabsApp.globalTranslationCache === null) { - app.TabsApp.globalTranslationCache = {}; - } - } - - function putTranslationValueInCache(key, value) { - app.TabsApp.globalTranslationCache[key] = value; - } - - function lookForTranslationByKey(key) { - var translation = app.TabsApp.globalTranslationCache[key]; - if (translation) { - // console.log('found translation: ' + key); - return translation; - } else { - return null; - } - } - - return TranslationManager; -}); \ No newline at end of file diff --git a/amp/TEMPLATE/ampTemplate/tabs/js/business/widgets/documentsWidgetManager.js b/amp/TEMPLATE/ampTemplate/tabs/js/business/widgets/documentsWidgetManager.js index f7a1a562f03..06e0c7f6f99 100644 --- a/amp/TEMPLATE/ampTemplate/tabs/js/business/widgets/documentsWidgetManager.js +++ b/amp/TEMPLATE/ampTemplate/tabs/js/business/widgets/documentsWidgetManager.js @@ -1,5 +1,5 @@ define([ 'marionette', 'models/document', 'collections/documents', - 'text!views/html/desktopResourcesContainerTemplate.html', 'business/translations/translationManager', + 'text!views/html/desktopResourcesContainerTemplate.html', 'translationManager', 'text!views/html/documentTemplate.html', 'jquery', 'jqueryui' ], function(Marionette, Document, Documents, desktopResourcesContainerTemplate, TranslationManager, documentTemplate, jQuery) { diff --git a/amp/TEMPLATE/ampTemplate/tabs/js/main.js b/amp/TEMPLATE/ampTemplate/tabs/js/main.js index ef6a1accb01..298762354b7 100644 --- a/amp/TEMPLATE/ampTemplate/tabs/js/main.js +++ b/amp/TEMPLATE/ampTemplate/tabs/js/main.js @@ -17,6 +17,7 @@ require.config({ */ jqgrid : 'lib/one_place/jqgrid-all', filtersWidget : '/TEMPLATE/ampTemplate/node_modules/amp-filter/dist/amp-filter', + translationManager: '/TEMPLATE/ampTemplate/script/common/TranslationManager', commonFilterUtils : '/TEMPLATE/ampTemplate/script/common/CommonFilterUtils', i18next : 'lib/i18next_1.6.3.min', numeral : 'lib/numeral_1.4.5.min' @@ -49,7 +50,7 @@ require.config({ exports : "jQuery.fn.jqGrid" }, filtersWidget : { - deps : [ 'backbone', 'commonFilterUtils' ], + deps : [ 'backbone', 'commonFilterUtils'], exports : 'filtersWidget' }, i18next : { @@ -57,11 +58,15 @@ require.config({ }, numeral : { exports : 'numeral' + } + , + translationManager: { + exports : 'TranslationManager' } } }); -require([ 'jquery', 'text!views/html/regions.html','business/translations/translationManager' ], function(jQuery, regionsTemplate,TranslationManager) { +require([ 'jquery', 'text!views/html/regions.html','translationManager' ], function(jQuery, regionsTemplate, TranslationManager) { var data = {}; data["tabs.common:loadingTabs"] = "Loading tabs..."; diff --git a/amp/TEMPLATE/ampTemplate/tabs/js/models/settings.js b/amp/TEMPLATE/ampTemplate/tabs/js/models/settings.js index 6ad0d7b7641..5050a528003 100644 --- a/amp/TEMPLATE/ampTemplate/tabs/js/models/settings.js +++ b/amp/TEMPLATE/ampTemplate/tabs/js/models/settings.js @@ -1,4 +1,4 @@ -define([ 'underscore', 'backbone', 'business/translations/translationManager' ], function(_, Backbone, TranslationManager) { +define([ 'underscore', 'backbone', 'translationManager' ], function(_, Backbone, TranslationManager) { var Settings = Backbone.Model.extend({ url : '/rest/amp/settings', diff --git a/amp/TEMPLATE/ampTemplate/tabs/js/views/dynamicContentView.js b/amp/TEMPLATE/ampTemplate/tabs/js/views/dynamicContentView.js index ecdcbfebbde..3d6f0960f3c 100644 --- a/amp/TEMPLATE/ampTemplate/tabs/js/views/dynamicContentView.js +++ b/amp/TEMPLATE/ampTemplate/tabs/js/views/dynamicContentView.js @@ -1,5 +1,5 @@ define([ 'marionette', 'text!views/html/dynamicContentTemplate.html', 'text!views/html/settingsDialogTemplate.html', 'models/settings', - 'business/settings/settingsManager', 'filtersWidget', 'business/filter/filterUtils', 'business/translations/translationManager', + 'business/settings/settingsManager', 'filtersWidget', 'business/filter/filterUtils', 'translationManager', 'business/tabManager', 'jquery', 'jqueryui' ], function(Marionette, dynamicContentTemplate, settingsDialogTemplate, Settings, SettingsManager, FiltersWidget, FilterUtils, TranslationManager, TabManager, jQuery) { diff --git a/amp/WEB-INF/src/org/digijava/kernel/ampapi/endpoints/common/TranslationsEndPoints.java b/amp/WEB-INF/src/org/digijava/kernel/ampapi/endpoints/common/TranslationsEndPoints.java index f065561e261..8d14ea5d06f 100644 --- a/amp/WEB-INF/src/org/digijava/kernel/ampapi/endpoints/common/TranslationsEndPoints.java +++ b/amp/WEB-INF/src/org/digijava/kernel/ampapi/endpoints/common/TranslationsEndPoints.java @@ -86,7 +86,6 @@ public List getLanguages(){ @Path("/languages/{langCode}") @ApiMethod(ui = false, id = "LanguageSwitch") public void switchLanguage(@PathParam("langCode") String langCode,@Context HttpServletResponse response){ - Locale locale = new Locale(); locale.setCode(langCode); DgUtil.switchLanguage(locale, TLSUtils.getRequest(), response); From c80658d51011f42e548d141f0ee27a9a37d0fdfd Mon Sep 17 00:00:00 2001 From: acartaleanu Date: Thu, 8 Sep 2016 18:17:52 +0300 Subject: [PATCH 014/204] AMP-23767: minor refactoring --- .../saiku/plugins/AMPFilters/FilterUtils.js | 35 ++++--------------- .../js/saiku/plugins/AMPFilters/plugin.js | 5 ++- .../js/saiku/plugins/AMPInfo/plugin.js | 1 - .../ampTemplate/tabs/js/business/tabEvents.js | 1 - 4 files changed, 8 insertions(+), 34 deletions(-) diff --git a/amp/TEMPLATE/ampTemplate/saikuui_nireports/js/saiku/plugins/AMPFilters/FilterUtils.js b/amp/TEMPLATE/ampTemplate/saikuui_nireports/js/saiku/plugins/AMPFilters/FilterUtils.js index 9c8dfe2d4cf..7ce31ad7872 100644 --- a/amp/TEMPLATE/ampTemplate/saikuui_nireports/js/saiku/plugins/AMPFilters/FilterUtils.js +++ b/amp/TEMPLATE/ampTemplate/saikuui_nireports/js/saiku/plugins/AMPFilters/FilterUtils.js @@ -6,8 +6,6 @@ FilterUtils.parseValue = function(elem, v) { return {id: v, name: theName}; }; - - //TODO: move to CommonFilterUtils.js and merge with the same function on Tabs. FilterUtils.extractFilters = function(content) { Saiku.logger.log("FilterUtils.extractFilters"); @@ -55,18 +53,15 @@ FilterUtils.extractFilters = function(content) { _.each(content,function(item, i) { //for now only true or false were asked to be translated. //Avoid doing a ajax call for all values if we only need 2. - item.trnName = TranslationManager.getTranslated(item.name); -// if (item.name === "true" || item.name === "false") { -// -// } -// else { -// item.trnName = item.name; -// } + if (item.name === "true" || item.name === "false") { + item.trnName = TranslationManager.getTranslated(item.name); + } + else { + item.trnName = item.name; + } }); var auxFilter = { -// trnName : item/*TranslationManager.getTranslated(item)*/, trnName : TranslationManager.getTranslated(item), -// trnName : Saiku.i18n.translate(item), name: item, values : content }; @@ -102,7 +97,6 @@ FilterUtils.extractFilters = function(content) { }); } var auxFilter = { -// trnName : item/*TranslationManager.getTranslated(item)*/, trnName : TranslationManager.getTranslated(item), name: item, values : content @@ -110,22 +104,5 @@ FilterUtils.extractFilters = function(content) { filters.push(auxFilter); } }); - - /* We dont need it for now, TODO: merge with tabs code because is the same logic. - //Process filters that dont come inside the previous categories (ie: computed year). - if (content.computedYear) { - var values = []; - values.push({ - id : content.computedYear, - name : content.computedYear - }); - var auxFilter = new Filter({ - trnName : TranslationManager.getTranslated('Computed Year'), - name: 'computedYear', - values : values - }); - filters.add(auxFilter); - }*/ - return filters; }; \ No newline at end of file diff --git a/amp/TEMPLATE/ampTemplate/saikuui_nireports/js/saiku/plugins/AMPFilters/plugin.js b/amp/TEMPLATE/ampTemplate/saikuui_nireports/js/saiku/plugins/AMPFilters/plugin.js index a2bc4d073fb..48d62f8c10d 100644 --- a/amp/TEMPLATE/ampTemplate/saikuui_nireports/js/saiku/plugins/AMPFilters/plugin.js +++ b/amp/TEMPLATE/ampTemplate/saikuui_nireports/js/saiku/plugins/AMPFilters/plugin.js @@ -58,7 +58,7 @@ var AMPFilters = Backbone.View.extend({ window.currentFilter.deserialize(auxFilters, { silent : true }); - }); + }); } }, @@ -99,12 +99,11 @@ var AMPFilters = Backbone.View.extend({ // AMP-18921: workaround to the filters until they will be properly initialized, // that should be done as part of filters widget improvement as a whole //this.workspace.query.initFilters(); - window.currentFilter.setStash(); + window.currentFilter.setStash(); $('#filter-popup').show(); } else { $('#filter-popup').hide(); } - }, render_menu : function() { diff --git a/amp/TEMPLATE/ampTemplate/saikuui_nireports/js/saiku/plugins/AMPInfo/plugin.js b/amp/TEMPLATE/ampTemplate/saikuui_nireports/js/saiku/plugins/AMPInfo/plugin.js index 325a7f17e5d..eae662a80f4 100644 --- a/amp/TEMPLATE/ampTemplate/saikuui_nireports/js/saiku/plugins/AMPInfo/plugin.js +++ b/amp/TEMPLATE/ampTemplate/saikuui_nireports/js/saiku/plugins/AMPInfo/plugin.js @@ -27,7 +27,6 @@ var AMPInfo = Backbone.View.extend({ animate : "linear", activate: function (event, ui) { $("#amp_info_filters_block").empty(); - //llk var modelFilters = window.currentFilter.serializeToModels(); // FilterUtils.updateFiltersRegion(modelFilters); $("#amp_info_filters_block").html(filtersToHtml(modelFilters)); diff --git a/amp/TEMPLATE/ampTemplate/tabs/js/business/tabEvents.js b/amp/TEMPLATE/ampTemplate/tabs/js/business/tabEvents.js index 6ba1f7482dc..d2b4531c10e 100644 --- a/amp/TEMPLATE/ampTemplate/tabs/js/business/tabEvents.js +++ b/amp/TEMPLATE/ampTemplate/tabs/js/business/tabEvents.js @@ -43,7 +43,6 @@ define([ 'marionette', 'models/content', 'models/legend', 'views/dynamicContentV // --------------------------------------------------------------------------------------// // TODO: Move filters section elsewhere. - //llk // Create collection of Filters used for legends. app.TabsApp.filters = FilterUtils.extractFilters(firstContent.get('reportMetadata').get('reportSpec').get('filters')); // Variable to save the current serialized filters from widget. From c8b2584c67edf7446118b1314aeb57770a7bdad1 Mon Sep 17 00:00:00 2001 From: Viorel Chihai Date: Thu, 8 Sep 2016 12:21:27 +0300 Subject: [PATCH 015/204] AMP-23914: Make Budget Structure items optional from the Activity Form --- .../AmpBudgetSectionFormTableFeature.html | 5 +- .../AmpBudgetSectionFormTableFeature.java | 98 ++++--------------- ...-23914-remove-budget-sector-validators.xml | 19 ++++ 3 files changed, 42 insertions(+), 80 deletions(-) create mode 100644 amp/xmlpatches/2.z12.05/AMP-23914-remove-budget-sector-validators.xml diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/tables/AmpBudgetSectionFormTableFeature.html b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/tables/AmpBudgetSectionFormTableFeature.html index 917bb5edf5a..79bcf6c4449 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/tables/AmpBudgetSectionFormTableFeature.html +++ b/amp/WEB-INF/src/org/dgfoundation/amp/onepager/components/features/tables/AmpBudgetSectionFormTableFeature.html @@ -10,9 +10,8 @@
- - - + +
- +<%}%> + + \ No newline at end of file diff --git a/amp/xmlpatches/general/views/v_activity_subprogram.xml b/amp/xmlpatches/general/views/v_activity_subprogram.xml new file mode 100644 index 00000000000..b10873122ae --- /dev/null +++ b/amp/xmlpatches/general/views/v_activity_subprogram.xml @@ -0,0 +1,28 @@ + + + AMP-23796 + Views + Octavian Ciubotaru + recreate view, this will always be the last version of the view + + + + val.equalsIgnoreCase("true") + + + + + + From 5c206c023a95da7f7b64cf7e9592989cf7e349b0 Mon Sep 17 00:00:00 2001 From: Gabriel Inchauspe Date: Fri, 9 Sep 2016 18:15:45 -0300 Subject: [PATCH 023/204] AMP-23925: Filters don't get saved in Tabs - WiP: Fixed problem showing selected dates on Filter Widget. --- .../converters/AmpReportFiltersConverter.java | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java b/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java index 99fe320b1b7..e220e2af27b 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java +++ b/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java @@ -3,7 +3,9 @@ import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.text.SimpleDateFormat; import java.util.Collection; +import java.util.Date; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -25,7 +27,10 @@ import org.digijava.module.aim.dbentity.AmpSector; import org.digijava.module.aim.dbentity.AmpTeam; import org.digijava.module.aim.dbentity.AmpTheme; +import org.digijava.module.aim.helper.GlobalSettingsConstants; +import org.digijava.module.aim.util.FeaturesUtil; import org.digijava.module.categorymanager.dbentity.AmpCategoryValue; +import org.digijava.module.common.util.DateTimeUtil; import org.hibernate.Session; /** @@ -133,10 +138,11 @@ public AmpARFilter buildFilters() { // Other section. addFilter(ColumnConstants.HUMANITARIAN_AID, Integer.class, "humanitarianAid", true); addFilter(ColumnConstants.DISASTER_RESPONSE_MARKER, Integer.class, "disasterResponse", true); - + addDateRangeFilter(ColumnConstants.ACTUAL_START_DATE, "fromActivityStartDate", "toActivityStartDate"); + addDateRangeFilter(ColumnConstants.PROPOSED_START_DATE, "fromProposedApprovalDate", "toProposedApprovalDate"); + addDateRangeFilter(ColumnConstants.ACTUAL_COMPLETION_DATE, "fromActivityActualCompletionDate", "toActivityActualCompletionDate"); this.ampARFilter.setComputedYear(this.filters.getComputedYear()); - // System.out.println(this.ampARFilter.toString()); return this.ampARFilter; } @@ -181,6 +187,8 @@ private void addFilter(String mondrianFilterColumnName, Class ampARFilterFieldCl values.add(auxValue); } else if (ampARFilterFieldClass.toString().equals("class java.lang.Integer")) { values.add(Integer.valueOf(auxValue)); + } else if (ampARFilterFieldClass.toString().equals("class java.lang.Double")) { + values.add(Double.valueOf(auxValue)); } else { Object auxEntity = session.load(ampARFilterFieldClass, new Long(auxValue)); values.add(auxEntity); @@ -220,6 +228,27 @@ private void addFilter(String mondrianFilterColumnName, Class ampARFilterFieldCl } } + private void addDateRangeFilter(String mondrianFilterColumnName, String fromMethod, String toMethod) { + try { + Method setterFromMethod = AmpARFilter.class.getDeclaredMethod(getSetterName(fromMethod), java.lang.String.class); + Method setterToMethod = AmpARFilter.class.getDeclaredMethod(getSetterName(toMethod), java.lang.String.class); + SimpleDateFormat originalFormat = new SimpleDateFormat(FeaturesUtil.getGlobalSettingValue(GlobalSettingsConstants.DEFAULT_DATE_FORMAT)); + List filterRules = this.filters.getAllFilterRules().get(new ReportElement(new ReportColumn(mondrianFilterColumnName))); + if (filterRules != null) { + FilterRule auxFilterRule = (FilterRule) filterRules.toArray()[0]; + String fromDate = originalFormat.format(DateTimeUtil.fromJulianNumberToDate(auxFilterRule.min)); + String toDate = originalFormat.format(DateTimeUtil.fromJulianNumberToDate(auxFilterRule.max)); + + // Use reflection to call the setter. + setterFromMethod.invoke(this.ampARFilter, fromDate); + setterToMethod.invoke(this.ampARFilter, toDate); + logger.info("Found filter: " + mondrianFilterColumnName + " with values: " + fromDate + " / " + toDate); + } + } catch (Exception e) { + logger.error(e, e); + } + } + /** * Merge all fields that have not been populated in the build process. * From db9fd24315d07c8790139ab2d688d76026d0857d Mon Sep 17 00:00:00 2001 From: Gabriel Inchauspe Date: Sat, 10 Sep 2016 14:18:39 -0300 Subject: [PATCH 024/204] AMP-23925: Filters don't get saved in Tabs - WiP: Added 2 more filters not used currently on DRC but on other countries. --- .../amp/reports/converters/AmpReportFiltersConverter.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java b/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java index e220e2af27b..f9570a20bc6 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java +++ b/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java @@ -125,15 +125,17 @@ public AmpARFilter buildFilters() { // Location section. addFilter(ColumnConstants.COUNTRY, AmpCategoryValueLocations.class, "locationSelected", true); - addFilter(ColumnConstants.DISTRICT, AmpCategoryValueLocations.class, "locationSelected", false); - addFilter(ColumnConstants.REGION, AmpCategoryValueLocations.class, "locationSelected", false); + addFilter(ColumnConstants.REGION, AmpCategoryValueLocations.class, "locationSelected", false); addFilter(ColumnConstants.ZONE, AmpCategoryValueLocations.class, "locationSelected", false); + addFilter(ColumnConstants.DISTRICT, AmpCategoryValueLocations.class, "locationSelected", false); // Financial section. addFilter(ColumnConstants.FINANCING_INSTRUMENT, AmpCategoryValue.class, "financingInstruments", true); addFilter(ColumnConstants.TYPE_OF_ASSISTANCE, AmpCategoryValue.class, "typeOfAssistance", true); addFilter(ColumnConstants.ON_OFF_TREASURY_BUDGET, AmpCategoryValue.class, "budget", true); addFilter(ColumnConstants.WORKSPACES, AmpTeam.class, "workspaces", true); + addFilter(ColumnConstants.FUNDING_STATUS, AmpCategoryValue.class, "fundingStatus", true); + addFilter(ColumnConstants.MODE_OF_PAYMENT, AmpCategoryValue.class, "modeOfPayment", true); // Other section. addFilter(ColumnConstants.HUMANITARIAN_AID, Integer.class, "humanitarianAid", true); From aa65a19f45ac836eaa7490d730b3502b3511a06a Mon Sep 17 00:00:00 2001 From: Gabriel Inchauspe Date: Sun, 11 Sep 2016 18:47:54 -0300 Subject: [PATCH 025/204] AMP-23925: Filters don't get saved in Tabs - WiP: Added 2 more boolean filters and all date filters found in AmpFiltersConverter. --- .../script/common/CommonFilterUtils.js | 12 ++++++++--- .../tabs/js/business/filter/filterUtils.js | 20 ++++++++++++++++++- .../js/views/html/filtersItemTemplate.html | 11 +++++++++- .../converters/AmpReportFiltersConverter.java | 5 ++++- 4 files changed, 42 insertions(+), 6 deletions(-) diff --git a/amp/TEMPLATE/ampTemplate/script/common/CommonFilterUtils.js b/amp/TEMPLATE/ampTemplate/script/common/CommonFilterUtils.js index 454e7de540b..e19400614c2 100644 --- a/amp/TEMPLATE/ampTemplate/script/common/CommonFilterUtils.js +++ b/amp/TEMPLATE/ampTemplate/script/common/CommonFilterUtils.js @@ -62,15 +62,21 @@ CommonFilterUtils.convertJavaFiltersToJS = function(data) { case 'On/Off/Treasury Budget': case 'Zone': case 'Region': - case 'District': - case 'Humanitarian Aid': - case 'Disaster Response Marker': + case 'District': case 'Expenditure Class': case 'Donor Agency': blob.columnFilters[item.name] = _.map(item.values, function(item_) { return parseInt(item_.id); }); break; + + // cases where the filter only accepts boolean values. + case 'Disaster Response Marker': + case 'Humanitarian Aid': + blob.columnFilters[item.name] = _.map(item.values, function(item_) { + return parseInt(item_); + }); + break; // cases where columnFilter matches item name + ' Id' case 'Contracting Agency': diff --git a/amp/TEMPLATE/ampTemplate/tabs/js/business/filter/filterUtils.js b/amp/TEMPLATE/ampTemplate/tabs/js/business/filter/filterUtils.js index 26b3ff4fde8..4eb1e0b30da 100644 --- a/amp/TEMPLATE/ampTemplate/tabs/js/business/filter/filterUtils.js +++ b/amp/TEMPLATE/ampTemplate/tabs/js/business/filter/filterUtils.js @@ -58,6 +58,7 @@ define([ 'models/filter', 'collections/filters', 'business/translations/translat } else if (element.get('valueToName') !== null) { // This should be .models but the way the endpoint returns // the data breaks backbone. + var foundValueToName = false; _.each(element.get('valueToName').attributes, function(item_, i) { // Need to do this because of how js parses these data // and adds an extra element. @@ -68,9 +69,21 @@ define([ 'models/filter', 'collections/filters', 'business/translations/translat if (dateIntervalType !== undefined) item.dateIntervalType = dateIntervalType; content.push(item); + foundValueToName = true; } }); + if (!foundValueToName) { + // This is a special case for usually for boolean filters with YES and/or NO answer. + _.each(element.get('values').models, function(item_, i) { + if (i !== undefined && item_ !== undefined) { + var item = {}; + item[i] = item_.get('value'); + content = item; + } + }); + } } + //translate filter values _.each(content,function(item, i) { //for now only true or false were asked to be translated. @@ -79,7 +92,12 @@ define([ 'models/filter', 'collections/filters', 'business/translations/translat item.trnName = TranslationManager.getTranslated(item.name); } else { - item.trnName = item.name; + if (item instanceof Array) { + item.trnName = item.name; + } else { + // This is a special case for boolean filters like Humanitarian Aid that have a different structure so we cant translate anything, just have 0/1. + // This forces us to translate 0/1 into Yes/No elsewhere because we cant do "1".trnName = 'Yes' + } } }); var auxFilter = new Filter({ diff --git a/amp/TEMPLATE/ampTemplate/tabs/js/views/html/filtersItemTemplate.html b/amp/TEMPLATE/ampTemplate/tabs/js/views/html/filtersItemTemplate.html index 6334dd480cf..9c2a564370f 100644 --- a/amp/TEMPLATE/ampTemplate/tabs/js/views/html/filtersItemTemplate.html +++ b/amp/TEMPLATE/ampTemplate/tabs/js/views/html/filtersItemTemplate.html @@ -6,7 +6,16 @@ <% if (item.trnName || item.name) { %>
<%= item.trnName || item.name %>
<% } else { %> -
-
+ <% if (name === 'Humanitarian Aid' || 'Disaster Response Marker') { %> + <% if (item === '1') { %> +
Yes
+ <% } %> + <% if (item === '2') { %> +
No
+ <% } %> + <% } else { %> +
-
+ <% } %> <% } %> <% }); %> diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java b/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java index f9570a20bc6..8fea082b5f2 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java +++ b/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java @@ -141,8 +141,11 @@ public AmpARFilter buildFilters() { addFilter(ColumnConstants.HUMANITARIAN_AID, Integer.class, "humanitarianAid", true); addFilter(ColumnConstants.DISASTER_RESPONSE_MARKER, Integer.class, "disasterResponse", true); addDateRangeFilter(ColumnConstants.ACTUAL_START_DATE, "fromActivityStartDate", "toActivityStartDate"); - addDateRangeFilter(ColumnConstants.PROPOSED_START_DATE, "fromProposedApprovalDate", "toProposedApprovalDate"); + addDateRangeFilter(ColumnConstants.PROPOSED_APPROVAL_DATE, "fromProposedApprovalDate", "toProposedApprovalDate"); addDateRangeFilter(ColumnConstants.ACTUAL_COMPLETION_DATE, "fromActivityActualCompletionDate", "toActivityActualCompletionDate"); + addDateRangeFilter(ColumnConstants.FINAL_DATE_FOR_CONTRACTING, "fromActivityFinalContractingDate", "toActivityFinalContractingDate"); + addDateRangeFilter(ColumnConstants.EFFECTIVE_FUNDING_DATE, "fromEffectiveFundingDate", "toEffectiveFundingDate"); + addDateRangeFilter(ColumnConstants.FUNDING_CLOSING_DATE, "fromFundingClosingDate", "toFundingClosingDate"); this.ampARFilter.setComputedYear(this.filters.getComputedYear()); return this.ampARFilter; From b9c0f54cac3acaae3bade8cac910f49101747cc9 Mon Sep 17 00:00:00 2001 From: Viorel Chihai Date: Mon, 12 Sep 2016 12:22:29 +0300 Subject: [PATCH 026/204] AMP-23869: Translation export creation date should be expressed as formatted string --- .../action/ImportExportTranslations.java | 89 ++++++++++++++----- .../translation/util/ImportExportUtil.java | 29 +++++- 2 files changed, 90 insertions(+), 28 deletions(-) diff --git a/amp/WEB-INF/src/org/digijava/module/translation/action/ImportExportTranslations.java b/amp/WEB-INF/src/org/digijava/module/translation/action/ImportExportTranslations.java index 5b6aa387afb..41e9d82a9e8 100644 --- a/amp/WEB-INF/src/org/digijava/module/translation/action/ImportExportTranslations.java +++ b/amp/WEB-INF/src/org/digijava/module/translation/action/ImportExportTranslations.java @@ -3,13 +3,14 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; -import java.sql.Timestamp; +import java.text.DateFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; @@ -20,6 +21,7 @@ import javax.xml.bind.Marshaller; import javax.xml.bind.Unmarshaller; +import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi.hssf.usermodel.HSSFRow; @@ -34,11 +36,13 @@ import org.apache.struts.action.ActionMessage; import org.apache.struts.action.ActionMessages; import org.apache.struts.upload.FormFile; +import org.dgfoundation.amp.ar.view.xls.IntWrapper; import org.digijava.kernel.entity.Message; import org.digijava.kernel.exception.DgException; import org.digijava.kernel.lucene.LangSupport; import org.digijava.kernel.lucene.LuceneWorker; import org.digijava.kernel.request.Site; +import org.digijava.kernel.text.LocalizationUtil; import org.digijava.kernel.translator.TranslatorWorker; import org.digijava.kernel.util.RequestUtils; import org.digijava.module.translation.entity.MessageGroup; @@ -64,6 +68,10 @@ public class ImportExportTranslations extends Action { public static final String SESSION_ROOT = "dgfoundation.amp.translation.import.xmlRoot"; public static final int XML_FORMAT=1; public static final int EXCEL_FORMAT=2; + + private final int charWidth = 300; + private final int defaultWidth = 15; + private static Logger logger = Logger.getLogger(ImportExportTranslations.class); @Override @@ -127,6 +135,8 @@ private ActionForward doExport(ActionMapping mapping, HttpServletRequest request } HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet = wb.createSheet(); + Map cachedWidths = new HashMap(); + int rownum=0,column=0; HSSFRow row=sheet.createRow(rownum++); row.createCell(column++, HSSFCell.CELL_TYPE_BLANK).setCellValue(TranslatorWorker.translateText("Key")); @@ -134,24 +144,25 @@ private ActionForward doExport(ActionMapping mapping, HttpServletRequest request row.createCell(column++,HSSFCell.CELL_TYPE_BLANK).setCellValue(targetLang); row.createCell(column++,HSSFCell.CELL_TYPE_BLANK).setCellValue(TranslatorWorker.translateText("Date of creation (en) ")); row.createCell(column++,HSSFCell.CELL_TYPE_BLANK).setCellValue(TranslatorWorker.translateText("Date of creation ("+targetLang+") ")); - if( messageGroups!=null){ + if( messageGroups!=null) { for(MessageGroup messageGrp: messageGroups){ - column=0; + IntWrapper columnIdx = new IntWrapper(); + if(rownum==65536){ - for (int i = 0; i < 3; i++) { - sheet.autoSizeColumn(i); // adjust width of - // the first - // column - } - sheet = wb.createSheet(); - rownum=0; + adjustColumnWidths(sheet, cachedWidths); + sheet = wb.createSheet(); + rownum=0; } + row=sheet.createRow(rownum++); - row.createCell(column++,HSSFCell.CELL_TYPE_BLANK).setCellValue(messageGrp.getKey()); + row.createCell(columnIdx.intValue(),HSSFCell.CELL_TYPE_BLANK).setCellValue(messageGrp.getKey()); + setMaxColWidth(messageGrp.getKey(), columnIdx.intValue(), cachedWidths); + String englishText=null; String targetText=null; Date englishCreationDate=null; Date targetCreationDate=null; + for(Message message :messageGrp.getAllMessages()){ if(message.getLocale().equals("en")){ englishText=message.getMessage(); @@ -175,22 +186,30 @@ private ActionForward doExport(ActionMapping mapping, HttpServletRequest request logger.error("Can not export key because text is too long: " + messageGrp.getKey()); continue; } - row.createCell(column++,HSSFCell.CELL_TYPE_BLANK).setCellValue(englishText); - row.createCell(column++,HSSFCell.CELL_TYPE_BLANK).setCellValue(targetText); - HSSFCell englishDateCell=row.createCell(column++,HSSFCell.CELL_TYPE_BLANK); - if(englishCreationDate!=null){ - englishDateCell.setCellValue(englishCreationDate); + row.createCell(columnIdx.inc().intValue(),HSSFCell.CELL_TYPE_BLANK).setCellValue(englishText); + setMaxColWidth(englishText, columnIdx.intValue(), cachedWidths); + row.createCell(columnIdx.inc().intValue(),HSSFCell.CELL_TYPE_BLANK).setCellValue(targetText); + setMaxColWidth(targetText, columnIdx.intValue(), cachedWidths); + + HSSFCell englishDateCell = row.createCell(columnIdx.inc().intValue(),HSSFCell.CELL_TYPE_BLANK); + if (englishCreationDate != null){ + String formattedEnglishCreationDate = LocalizationUtil.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Locale.ENGLISH). + format(englishCreationDate); + englishDateCell.setCellValue(formattedEnglishCreationDate); + setMaxColWidth(formattedEnglishCreationDate, columnIdx.intValue(), cachedWidths); } - HSSFCell targetDateCell=row.createCell(column++,HSSFCell.CELL_TYPE_BLANK); - if(targetCreationDate!=null){ - targetDateCell.setCellValue(targetCreationDate); + + HSSFCell targetDateCell = row.createCell(columnIdx.inc().intValue(),HSSFCell.CELL_TYPE_BLANK); + if (targetCreationDate != null) { + String formattedTargetCreationDate = LocalizationUtil.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Locale.ENGLISH). + format(targetCreationDate); + targetDateCell.setCellValue(formattedTargetCreationDate); + setMaxColWidth(formattedTargetCreationDate, columnIdx.intValue(), cachedWidths); } } } - for (int i = 0; i < 5; i++) { - sheet.autoSizeColumn(i); // adjust width of the first - // column - } + + adjustColumnWidths(sheet, cachedWidths); wb.write(response.getOutputStream()); return null; @@ -208,7 +227,29 @@ private ActionForward doExport(ActionMapping mapping, HttpServletRequest request } } - private void doImportLang(HttpServletRequest request, ImportExportForm ioForm, HttpSession session, Site site) throws DgException { + private void setMaxColWidth(String formattedTargetCreationDate, int column, Map cachedWidths) { + IntWrapper width = new IntWrapper().inc(10); + + if (StringUtils.isNotEmpty(formattedTargetCreationDate)) { + width.set(formattedTargetCreationDate.length()); + } + + cachedWidths.compute(column, (k, v) -> v == null ? width.value : v < width.value ? width.value : v); + } + + private void adjustColumnWidths(HSSFSheet sheet, Map cachedWidths) { + + for (int i=0; i < 5; i++) { + if (cachedWidths.containsKey(i)) { + int width = cachedWidths.get(i) < 100 ? cachedWidths.get(i) : 100; + sheet.setColumnWidth(i, width * charWidth); + } else { + sheet.setColumnWidth(i, defaultWidth * charWidth); + } + } + } + + private void doImportLang(HttpServletRequest request, ImportExportForm ioForm, HttpSession session, Site site) throws DgException { long startTime = System.currentTimeMillis(); String[] selectedLanguages = ioForm.getSelectedImportedLanguages(); Set languagesToImport = new HashSet(Arrays.asList(selectedLanguages)); diff --git a/amp/WEB-INF/src/org/digijava/module/translation/util/ImportExportUtil.java b/amp/WEB-INF/src/org/digijava/module/translation/util/ImportExportUtil.java index 42eaa217a1e..88cf5c62851 100644 --- a/amp/WEB-INF/src/org/digijava/module/translation/util/ImportExportUtil.java +++ b/amp/WEB-INF/src/org/digijava/module/translation/util/ImportExportUtil.java @@ -3,12 +3,14 @@ import java.io.File; import java.io.InputStream; import java.sql.Timestamp; +import java.text.DateFormat; import java.util.ArrayList; import java.util.Collection; import java.util.Date; import java.util.HashSet; import java.util.LinkedList; import java.util.List; +import java.util.Locale; import java.util.Set; import java.util.concurrent.BlockingQueue; import java.util.concurrent.ExecutorService; @@ -27,12 +29,12 @@ import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.ss.usermodel.Row; -import org.dgfoundation.amp.newreports.NumberedTypedEntity; import org.digijava.kernel.entity.Message; import org.digijava.kernel.exception.DgException; import org.digijava.kernel.persistence.PersistenceManager; import org.digijava.kernel.persistence.WorkerException; import org.digijava.kernel.request.Site; +import org.digijava.kernel.text.LocalizationUtil; import org.digijava.kernel.translator.CachedTranslatorWorker; import org.digijava.kernel.translator.TranslatorWorker; import org.digijava.kernel.translator.util.TrnAccesTimeSaver; @@ -47,8 +49,8 @@ import org.digijava.module.translation.jaxb.Language; import org.digijava.module.translation.jaxb.Translations; import org.digijava.module.translation.jaxb.Trn; +import org.h2.util.StringUtils; import org.hibernate.FlushMode; -import org.hibernate.HibernateException; import org.hibernate.Query; import org.hibernate.Session; import org.hibernate.Transaction; @@ -535,8 +537,27 @@ public static List importExcelFile(POIFSFileSystem fsFileSystem,ImportEx //so if its an error cell the target text is "" as if the cell would be empty String targetText = (hssfRow.getCell(2) == null || hssfRow.getCell(2).getCellType()==HSSFCell.CELL_TYPE_ERROR) ? "" : hssfRow.getCell(2).getStringCellValue(); - Date englishDate=(hssfRow.getCell(3) == null) ? null: hssfRow.getCell(3).getDateCellValue(); - Date targetDate=(hssfRow.getCell(4) == null) ? null: hssfRow.getCell(4).getDateCellValue(); + + Date englishDate = null; + if (hssfRow.getCell(3) != null) { + if(hssfRow.getCell(3).getCellType() == HSSFCell.CELL_TYPE_NUMERIC) { + englishDate = hssfRow.getCell(3).getDateCellValue(); + } else if (!StringUtils.isNullOrEmpty(hssfRow.getCell(3).getStringCellValue())) { + englishDate = LocalizationUtil.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Locale.ENGLISH) + .parse(hssfRow.getCell(3).getStringCellValue()); + } + } + + Date targetDate = null; + if (hssfRow.getCell(4) != null) { + if(hssfRow.getCell(4).getCellType() == HSSFCell.CELL_TYPE_NUMERIC) { + targetDate = hssfRow.getCell(4).getDateCellValue(); + } else if (!StringUtils.isNullOrEmpty(hssfRow.getCell(4).getStringCellValue())) { + targetDate = LocalizationUtil.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Locale.ENGLISH) + .parse(hssfRow.getCell(4).getStringCellValue()); + } + } + if(englishDate!=null){ Message message = new Message(); message.setKey(key); From 977beea6be5c9bc58967bc9b00255d0e39aba71a Mon Sep 17 00:00:00 2001 From: Gabriel Inchauspe Date: Mon, 12 Sep 2016 11:15:30 -0300 Subject: [PATCH 027/204] AMP-23925: Filters don't get saved in Tabs - WiP: Added support for transaction dates. --- .../reports/converters/AmpReportFiltersConverter.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java b/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java index 8fea082b5f2..0e0cee91a4e 100644 --- a/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java +++ b/amp/WEB-INF/src/org/dgfoundation/amp/reports/converters/AmpReportFiltersConverter.java @@ -43,6 +43,7 @@ public class AmpReportFiltersConverter { protected static final Logger logger = Logger.getLogger(AmpReportFiltersConverter.class); private AmpReportFilters filters; private AmpARFilter ampARFilter; + private static final String TRANSACTION_DATE = "DATE"; public AmpReportFiltersConverter(AmpReportFilters filters) { if (filters == null) { @@ -146,6 +147,7 @@ public AmpARFilter buildFilters() { addDateRangeFilter(ColumnConstants.FINAL_DATE_FOR_CONTRACTING, "fromActivityFinalContractingDate", "toActivityFinalContractingDate"); addDateRangeFilter(ColumnConstants.EFFECTIVE_FUNDING_DATE, "fromEffectiveFundingDate", "toEffectiveFundingDate"); addDateRangeFilter(ColumnConstants.FUNDING_CLOSING_DATE, "fromFundingClosingDate", "toFundingClosingDate"); + addDateRangeFilter(TRANSACTION_DATE, "fromDate", "toDate"); this.ampARFilter.setComputedYear(this.filters.getComputedYear()); return this.ampARFilter; @@ -238,7 +240,13 @@ private void addDateRangeFilter(String mondrianFilterColumnName, String fromMeth Method setterFromMethod = AmpARFilter.class.getDeclaredMethod(getSetterName(fromMethod), java.lang.String.class); Method setterToMethod = AmpARFilter.class.getDeclaredMethod(getSetterName(toMethod), java.lang.String.class); SimpleDateFormat originalFormat = new SimpleDateFormat(FeaturesUtil.getGlobalSettingValue(GlobalSettingsConstants.DEFAULT_DATE_FORMAT)); - List filterRules = this.filters.getAllFilterRules().get(new ReportElement(new ReportColumn(mondrianFilterColumnName))); + ReportElement filterElement = null; + if (mondrianFilterColumnName.equalsIgnoreCase(TRANSACTION_DATE)) { + filterElement = new ReportElement(ElementType.DATE); + } else { + filterElement = new ReportElement(new ReportColumn(mondrianFilterColumnName)); + } + List filterRules = this.filters.getAllFilterRules().get(filterElement); if (filterRules != null) { FilterRule auxFilterRule = (FilterRule) filterRules.toArray()[0]; String fromDate = originalFormat.format(DateTimeUtil.fromJulianNumberToDate(auxFilterRule.min)); From a5af15c8cf3a0a6e5ba8b3225f7bf1299f55a406 Mon Sep 17 00:00:00 2001 From: Gabriel Inchauspe Date: Mon, 12 Sep 2016 16:43:26 -0300 Subject: [PATCH 028/204] AMP-23925: Filters don't get saved in Tabs - WiP: Added support for transaction dates. --- .../script/common/CommonFilterUtils.js | 22 ++++++------- .../tabs/js/business/filter/filterUtils.js | 31 ++----------------- 2 files changed, 13 insertions(+), 40 deletions(-) diff --git a/amp/TEMPLATE/ampTemplate/script/common/CommonFilterUtils.js b/amp/TEMPLATE/ampTemplate/script/common/CommonFilterUtils.js index e19400614c2..eedc34ae422 100644 --- a/amp/TEMPLATE/ampTemplate/script/common/CommonFilterUtils.js +++ b/amp/TEMPLATE/ampTemplate/script/common/CommonFilterUtils.js @@ -2,22 +2,20 @@ var CommonFilterUtils = {}; CommonFilterUtils.getDateIntervalType = function(element) { console.log("CommonFilterUtils.getDateIntervalType"); - // Since this function now is common for Tabs and Saiku we need to transform - // backbone objects from tabs to plain js objects. - if (element.attributes !== undefined) { - element = _.pluck(element, 'attributes'); - } - - var min = element.min; - var max = element.max; + // element can be a simple object or a Backbone Model. + var isModel = (element.get !== undefined); + var min = isModel ? element.get('min') : element.min; + var max = isModel ? element.get('max') : element.max; if (min === undefined) return "max"; if (max === undefined) return "min"; - if (element.valueToName[min] === undefined) { + var valueToNameMin = isModel ? element.get('valueToName').attributes[min] : element.valueToName[min]; + var valueToNameMax = isModel ? element.get('valueToName').attributes[max] : element.valueToName[max]; + if (valueToNameMin === undefined) { return "max"; } - if (element.valueToName[max] === undefined) { + if (valueToNameMax === undefined) { return "min"; } return "both"; @@ -122,9 +120,9 @@ CommonFilterUtils.convertJavaFiltersToJS = function(data) { // item.attributes); var newDate = {}; _.map(item.values, function(item_, i) { - if (item_.type === "min") { + if (item_.dateIntervalType === "min") { newDate['start'] = item_.name; - } else if (item_.type === "max") { + } else if (item_.dateIntervalType === "max") { newDate['end'] = item_.name; } return newDate; diff --git a/amp/TEMPLATE/ampTemplate/tabs/js/business/filter/filterUtils.js b/amp/TEMPLATE/ampTemplate/tabs/js/business/filter/filterUtils.js index 4eb1e0b30da..535692ff3cd 100644 --- a/amp/TEMPLATE/ampTemplate/tabs/js/business/filter/filterUtils.js +++ b/amp/TEMPLATE/ampTemplate/tabs/js/business/filter/filterUtils.js @@ -47,9 +47,6 @@ define([ 'models/filter', 'collections/filters', 'business/translations/translat var element = subElement.models[0]; var content = []; - if (subElement.name === 'DATE') { - var dateIntervalType = CommonFilterUtils.getDateIntervalType(element, item, i); - } if (element.get('value') !== null) { var auxItem = {}; auxItem.id = element.get('value'); @@ -66,8 +63,9 @@ define([ 'models/filter', 'collections/filters', 'business/translations/translat var item = {}; item.id = i; item.name = item_; - if (dateIntervalType !== undefined) - item.dateIntervalType = dateIntervalType; + if (subElement.name === 'DATE') { + item.dateIntervalType = (element.get('max') === item.id ? 'max' : 'min'); + } content.push(item); foundValueToName = true; } @@ -267,29 +265,6 @@ define([ 'models/filter', 'collections/filters', 'business/translations/translat }; - FilterUtils.fillDateBlob = function(dateBlob, attributes){ - if (attributes.values.length === 1) { - if (attributes.values[0].dateIntervalType === "min") { - dateBlob.start = FilterUtils._dateConvert(attributes.values[0].name); - FilterUtils.pushDateLimit("Start Date", FilterUtils._dateConvert(attributes.values[0].name)); - } else { - dateBlob.end = FilterUtils._dateConvert(attributes.values[0].name); - FilterUtils.pushDateLimit("End Date", FilterUtils._dateConvert(attributes.values[0].name)); - } - } - else if (attributes.values.length === 2) { - dateBlob.start = FilterUtils._dateConvert(attributes.values[0].name); - FilterUtils.pushDateLimit("Start Date", FilterUtils._dateConvert(attributes.values[0].name)); - - dateBlob.end = FilterUtils._dateConvert(attributes.values[1].name); - FilterUtils.pushDateLimit("End Date", FilterUtils._dateConvert(attributes.values[1].name)); - } - else { - //error. why doesn't it have dates - } - - }; - FilterUtils.widgetFiltersToJavaFilters = function(originalFilters) { return originalFilters; }; From 7a6afa4b9d401419295e16397729d533d8b55ad7 Mon Sep 17 00:00:00 2001 From: "apicca@developmentgateway.org" Date: Tue, 13 Sep 2016 08:16:24 -0300 Subject: [PATCH 029/204] AMP-23945 Add tool tip next to Export Indicator Table in GIS Layers Manager --- .../src/lib/initial-translation-request.json | 3 +++ .../src/templates/wizard-template.html | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/amp/TEMPLATE/ampTemplate/node_modules/gis-layers-manager/src/lib/initial-translation-request.json b/amp/TEMPLATE/ampTemplate/node_modules/gis-layers-manager/src/lib/initial-translation-request.json index 8f715b43cf0..4f3317f7169 100644 --- a/amp/TEMPLATE/ampTemplate/node_modules/gis-layers-manager/src/lib/initial-translation-request.json +++ b/amp/TEMPLATE/ampTemplate/node_modules/gis-layers-manager/src/lib/initial-translation-request.json @@ -6,6 +6,9 @@ "amp.gis-layers-manager:nav-DefineColorScheme":"Color scheme", "amp.gis-layers-manager:nav-AddNotes":"Notes", "amp.gis-layers-manager:nav-ExportFile": "Export File", + "amp.gis-layers-manager:nav-exportFile-msg1": "Enter the measures for each location in the labeled column next to the respective location.", + "amp.gis-layers-manager:nav-exportFile-msg2": "If Indicator Layer Type is \"Ratio (% of Population)\" or \"Ratio (other)\" please enter either in decimal format or add % to the end of each measure.", + "amp.gis-layers-manager:nav-exportFile-msg3": "Save the spreadsheet and re-upload in the next step.", "amp.gis-layers-manager:nav-Re-importFile": "Re-import File", "amp.gis-layers-manager:nav-ReviewandSave": "Review and Save", "amp.gis-layers-manager:label-IndicatorName": "Indicator Name", diff --git a/amp/TEMPLATE/ampTemplate/node_modules/gis-layers-manager/src/templates/wizard-template.html b/amp/TEMPLATE/ampTemplate/node_modules/gis-layers-manager/src/templates/wizard-template.html index 7e589ca5bc6..160c3c56b6e 100644 --- a/amp/TEMPLATE/ampTemplate/node_modules/gis-layers-manager/src/templates/wizard-template.html +++ b/amp/TEMPLATE/ampTemplate/node_modules/gis-layers-manager/src/templates/wizard-template.html @@ -164,9 +164,12 @@
Export File
- -


- +
+ Enter the measures for each location in the labeled column next to the respective location. +

+ If Indicator Layer Type is "Ratio (% of Population)" or "Ratio (other)" please enter either in decimal format or add % to the end of each measure. +

+ Save the spreadsheet and re-upload in the next step.
<% } %> \ No newline at end of file diff --git a/amp/TEMPLATE/ampTemplate/gisModule/dev/app/js/amp/map/views/map-header-gap-analysis-view.js b/amp/TEMPLATE/ampTemplate/gisModule/dev/app/js/amp/map/views/map-header-gap-analysis-view.js index 4fa536d9997..c85aaeedc60 100644 --- a/amp/TEMPLATE/ampTemplate/gisModule/dev/app/js/amp/map/views/map-header-gap-analysis-view.js +++ b/amp/TEMPLATE/ampTemplate/gisModule/dev/app/js/amp/map/views/map-header-gap-analysis-view.js @@ -36,7 +36,8 @@ module.exports = Backbone.View.extend({ } else { $('.gap-analysis-bar').hide(); } - app.translator.translateDOM(this.$el); + app.translator.translateDOM(this.$el); + this.$el.find('[data-toggle="tooltip"]').tooltip(); return this; }, diff --git a/amp/TEMPLATE/ampTemplate/gisModule/dev/app/js/amp/services/initial-translation-request.json b/amp/TEMPLATE/ampTemplate/gisModule/dev/app/js/amp/services/initial-translation-request.json index a57ee1b6860..8d868c44ba5 100644 --- a/amp/TEMPLATE/ampTemplate/gisModule/dev/app/js/amp/services/initial-translation-request.json +++ b/amp/TEMPLATE/ampTemplate/gisModule/dev/app/js/amp/services/initial-translation-request.json @@ -100,5 +100,6 @@ "amp.gis:leaflet-button-zoom-in[title]":"Zoom in", "amp.gis:leaflet-button-zoom-out[title]":"Zoom out", "amp.gis:page-title":"Aid Management Platform - GIS", -"amp.gis:title-gap-analysis-selector":"Gap Analysis View Available" +"amp.gis:title-gap-analysis-selector":"Gap Analysis View Available", +"amp.gis:title-gap-analysis-tooltip[title]":"Gap analysis calculates the amount of funding by location spent per the selected indicator. Example: Amount spent for each person with no access to safe water in each district. Filters should be used to specify funding for the appropriate sector (e.g. water and sanitation), etc. Gap analysis is not available for layers that are the 'Ratio: other' type." } From 1bd69e0475282f961108453ee4d7f02f392f89e0 Mon Sep 17 00:00:00 2001 From: Viorel Chihai Date: Tue, 13 Sep 2016 18:48:38 +0300 Subject: [PATCH 035/204] AMP-24024: Fix calendar issue in donor scorecard. Fix activity statuses. --- .../scorecard/service/ScorecardService.java | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/amp/WEB-INF/src/org/digijava/kernel/ampapi/endpoints/scorecard/service/ScorecardService.java b/amp/WEB-INF/src/org/digijava/kernel/ampapi/endpoints/scorecard/service/ScorecardService.java index c5e36ebcf40..8458d784301 100644 --- a/amp/WEB-INF/src/org/digijava/kernel/ampapi/endpoints/scorecard/service/ScorecardService.java +++ b/amp/WEB-INF/src/org/digijava/kernel/ampapi/endpoints/scorecard/service/ScorecardService.java @@ -32,6 +32,7 @@ import org.digijava.module.aim.dbentity.AmpScorecardSettingsCategoryValue; import org.digijava.module.aim.helper.Constants; import org.digijava.module.aim.helper.GlobalSettingsConstants; +import org.digijava.module.aim.helper.fiscalcalendar.GregorianBasedWorker; import org.digijava.module.aim.helper.fiscalcalendar.ICalendarWorker; import org.digijava.module.aim.util.DbUtil; import org.digijava.module.aim.util.FeaturesUtil; @@ -384,16 +385,16 @@ public void execute(Connection conn) throws SQLException { if (threshold == null) { threshold = DEFAULT_THRESHOLD; } - String quarterEndDate = new SimpleDateFormat("yyyy-MM-dd").format(quarter.getQuarterEndDate()); + String quarterEndDate = new SimpleDateFormat("yyyy-MM-dd").format(getGregorianDate(quarter.getQuarterEndDate())); //Get total (not completed nor deleted) activities by donor at the end of a given quarter - Object [] activityIds = getLatestActivityIdsByDate(quarterEndDate,status); + Object [] activityIds = getLatestActivityIdsByDate(quarterEndDate, status); String query = "select count (distinct (a.amp_id)) as total_activities,r.organisation as donor_id " + "from amp_activity_version a, amp_org_role r,amp_organisation o,amp_activities_categoryvalues c,amp_category_value v "+ " WHERE r.activity=a.amp_activity_id AND a.amp_activity_id = c.amp_activity_id "+ "AND c.amp_categoryvalue_id = v.id "+ "AND v.amp_category_class_id = (select id from amp_category_class where keyname='activity_status') "; if (!status.equals("")) { - query += "AND c.amp_categoryvalue_id not in (" + status + " ) "; + query += "AND c.amp_categoryvalue_id in (" + status + " ) "; } query += "AND o.amp_org_id = r.organisation " + "AND ( o.deleted IS NULL OR o.deleted = false ) " + "AND (EXISTS (SELECT af.amp_donor_org_id " + " FROM amp_funding af,amp_activity_version v " @@ -504,7 +505,7 @@ public void execute(Connection conn) throws SQLException { + "AND v.amp_category_class_id = (select id from amp_category_class where " + " keyname='activity_status') "; if (!status.equals("")) { - query += "AND c.amp_categoryvalue_id not in (" + status + " ) "; + query += "AND c.amp_categoryvalue_id in (" + status + " ) "; } query += "group by amp_id"; try (RsInfo rsi = SQLUtils.rawRunQuery(conn, query, null)) { @@ -536,10 +537,8 @@ public void execute(Connection conn) throws SQLException { */ private Map> countActivityUpdates(List activityUpdates, Map> data) { - ICalendarWorker worker = fiscalCalendar.getworker(); for (ActivityUpdate activityUpdate : activityUpdates) { Long donorId = activityUpdate.getDonorId(); - worker.setTime(activityUpdate.getModifyDate()); Quarter quarter = new Quarter(fiscalCalendar, activityUpdate.getModifyDate()); ColoredCell cell = data.get(donorId).get(quarter.toString()); logger.info("Quarter" + quarter); @@ -577,7 +576,7 @@ private boolean isUpdateOnGracePeriod(Date updateDate) { if (settings != null && settings.getValidationPeriod() != null && settings.getValidationPeriod()) { Integer weekNumber = settings.getValidationTime(); Quarter quarter = new Quarter(fiscalCalendar, updateDate); - Date quarterStartDate = quarter.getQuarterStartDate(); + Date quarterStartDate = getGregorianDate(quarter.getQuarterStartDate()); Calendar calendarGracePeriod = Calendar.getInstance(); calendarGracePeriod.setTime(quarterStartDate); calendarGracePeriod.add(Calendar.WEEK_OF_YEAR, weekNumber); @@ -652,8 +651,8 @@ public int getPastQuarterOrganizationsCount() { final IntWrapper orgCount = new IntWrapper(); Quarter pastQuarter = getPastQuarter(); - Date startDate = pastQuarter == null ? new Date() : pastQuarter.getQuarterStartDate(); - Date endDate = pastQuarter == null ? new Date() : pastQuarter.getQuarterEndDate(); + Date startDate = pastQuarter == null ? new Date() : getGregorianDate(pastQuarter.getQuarterStartDate()); + Date endDate = pastQuarter == null ? new Date() : getGregorianDate(pastQuarter.getQuarterEndDate()); String pattern = "yyyy-MM-dd"; final String formattedStartDate = new SimpleDateFormat(pattern).format(startDate); final String formattedEndDate = new SimpleDateFormat(pattern).format(endDate); @@ -726,6 +725,7 @@ public int getPastQuarterProjectsCount() { private int getPastQuarterObjectsCount(String inputQuery, final String paramDate) { Quarter pastQuarter = getPastQuarter(); + Date startDate = pastQuarter == null ? new Date() : pastQuarter.getQuarterStartDate(); Date endDate = pastQuarter == null ? new Date() : pastQuarter.getQuarterEndDate(); @@ -756,4 +756,12 @@ public void execute(Connection conn) throws SQLException { return count.intValue(); } + + private Date getGregorianDate(Date sourceDate) { + if (!(fiscalCalendar.getworker() instanceof GregorianBasedWorker)) { + return FiscalCalendarUtil.toGregorianDate(sourceDate, fiscalCalendar); + } + + return sourceDate; + } } From dcd0e3fbaa0c2e14f0e40b6dbf9bbb7379fcd42f Mon Sep 17 00:00:00 2001 From: Nadejda Mandrescu Date: Thu, 15 Sep 2016 01:15:19 +0300 Subject: [PATCH 036/204] AMP-24103 deffer unique constraint check --- .../reamp/modules/admin/dashboard/dev.html | 8 +++----- .../dashboards/services/HeatMapConfigs.java | 1 - .../aim/dbentity/AmpColorThreshold.hbm.xml | 2 +- .../module/aim/dbentity/AmpColorThreshold.java | 4 ++++ .../AMP-24103-deffer-unique-constraint.xml | 17 +++++++++++++++++ 5 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 amp/xmlpatches/2.z12.7/AMP-24103-deffer-unique-constraint.xml diff --git a/amp/TEMPLATE/reamp/modules/admin/dashboard/dev.html b/amp/TEMPLATE/reamp/modules/admin/dashboard/dev.html index 0d1adb6ebb2..d9392f7d450 100644 --- a/amp/TEMPLATE/reamp/modules/admin/dashboard/dev.html +++ b/amp/TEMPLATE/reamp/modules/admin/dashboard/dev.html @@ -5,16 +5,15 @@ Aid Management Platform - Dashboard Manager - +
-
-
+
+

Dashboard Manager

Loading...

-

Dashboard Manager style="width: 100%">
-

diff --git a/amp/WEB-INF/src/org/digijava/kernel/ampapi/endpoints/dashboards/services/HeatMapConfigs.java b/amp/WEB-INF/src/org/digijava/kernel/ampapi/endpoints/dashboards/services/HeatMapConfigs.java index f67e257ad9b..a3491306e16 100644 --- a/amp/WEB-INF/src/org/digijava/kernel/ampapi/endpoints/dashboards/services/HeatMapConfigs.java +++ b/amp/WEB-INF/src/org/digijava/kernel/ampapi/endpoints/dashboards/services/HeatMapConfigs.java @@ -181,7 +181,6 @@ public JsonBean saveHeatMapAdminSettings(JsonBean config) throws Exception { EndpointUtils.setResponseStatusMarker(HttpServletResponse.SC_BAD_REQUEST); return ApiError.toError(errors.getAllErrors()); } - org.digijava.module.aim.util.DbUtil.saveOrUpdate(thresholds); return result; } diff --git a/amp/WEB-INF/src/org/digijava/module/aim/dbentity/AmpColorThreshold.hbm.xml b/amp/WEB-INF/src/org/digijava/module/aim/dbentity/AmpColorThreshold.hbm.xml index 9db6baf818b..e5e4acbcfe7 100644 --- a/amp/WEB-INF/src/org/digijava/module/aim/dbentity/AmpColorThreshold.hbm.xml +++ b/amp/WEB-INF/src/org/digijava/module/aim/dbentity/AmpColorThreshold.hbm.xml @@ -11,7 +11,7 @@ - + diff --git a/amp/WEB-INF/src/org/digijava/module/aim/dbentity/AmpColorThreshold.java b/amp/WEB-INF/src/org/digijava/module/aim/dbentity/AmpColorThreshold.java index a66cc596316..bd8548748e9 100644 --- a/amp/WEB-INF/src/org/digijava/module/aim/dbentity/AmpColorThreshold.java +++ b/amp/WEB-INF/src/org/digijava/module/aim/dbentity/AmpColorThreshold.java @@ -89,5 +89,9 @@ public void setIndex(Integer index) { this.index = index; } + public String toString() { + return String.format("[%d] %s (%s) from %s (idx = %d)", ampColorThresholdId, colorName, colorHash, + thresholdStart, index); + } } diff --git a/amp/xmlpatches/2.z12.7/AMP-24103-deffer-unique-constraint.xml b/amp/xmlpatches/2.z12.7/AMP-24103-deffer-unique-constraint.xml new file mode 100644 index 00000000000..04c307bd62f --- /dev/null +++ b/amp/xmlpatches/2.z12.7/AMP-24103-deffer-unique-constraint.xml @@ -0,0 +1,17 @@ + + + AMP-24103 + HeatMap + nmandrescu + Deffer unqieue constraint + + + + From c8a8e6806e01e7061670ddaf0cb91521cc87da1b Mon Sep 17 00:00:00 2001 From: Gerald Mutuhu Date: Thu, 15 Sep 2016 12:36:12 +0300 Subject: [PATCH 037/204] AMP-24017 Dates in applied filters show Chinese characters AMP-24017 Dates in applied filters show Chinese characters Enable $.datepicker.regional['en'] in jquery ui --- .../amp-filter/dist/amp-filter.js | 21 ++++---- .../amp-filter/src/compiled-js/amp-filter.js | 50 +++++++++---------- .../amp-filter/src/lib/jquery-ui-i18n.js | 49 +++++++++--------- 3 files changed, 61 insertions(+), 59 deletions(-) diff --git a/amp/TEMPLATE/ampTemplate/node_modules/amp-filter/dist/amp-filter.js b/amp/TEMPLATE/ampTemplate/node_modules/amp-filter/dist/amp-filter.js index c54da384eab..be5ea3262b0 100644 --- a/amp/TEMPLATE/ampTemplate/node_modules/amp-filter/dist/amp-filter.js +++ b/amp/TEMPLATE/ampTemplate/node_modules/amp-filter/dist/amp-filter.js @@ -1,15 +1,16 @@ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.ampFilter=e()}}(function(){var e;return function t(e,n,i){function r(s,o){if(!n[s]){if(!e[s]){var l="function"==typeof require&&require;if(!o&&l)return l(s,!0);if(a)return a(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var c=n[s]={exports:{}};e[s][0].call(c.exports,function(t){var n=e[s][1][t];return r(n?n:t)},c,c.exports,t,e,n,i)}return n[s].exports}for(var a="function"==typeof require&&require,s=0;sl;l++)if(e=o[l],s=this._events[e]){if(this._events[e]=r=[],t||i)for(d=0,h=s.length;h>d;d++)a=s[d],(t&&t!==a.callback&&t!==a.callback._callback||i&&i!==a.context)&&r.push(a);r.length||delete this._events[e]}return this},trigger:function(e){if(!this._events)return this;var t=s.call(arguments,1);if(!u(this,"trigger",e,t))return this;var n=this._events[e],i=this._events.all;return n&&c(n,t),i&&c(i,arguments),this},stopListening:function(e,t,i){var r=this._listeningTo;if(!r)return this;var a=!t&&!i;i||"object"!=typeof t||(i=this),e&&((r={})[e._listenId]=e);for(var s in r)e=r[s],e.off(t,i,this),(a||n.isEmpty(e._events))&&delete this._listeningTo[s];return this}},l=/\s+/,u=function(e,t,n,i){if(!n)return!0;if("object"==typeof n){for(var r in n)e[t].apply(e,[r,n[r]].concat(i));return!1}if(l.test(n)){for(var a=n.split(l),s=0,o=a.length;o>s;s++)e[t].apply(e,[a[s]].concat(i));return!1}return!0},c=function(e,t){var n,i=-1,r=e.length,a=t[0],s=t[1],o=t[2];switch(t.length){case 0:for(;++ih;h++)this.trigger("change:"+o[h],this,d[o[h]],i)}if(u)return this;if(!l)for(;this._pending;)i=this._pending,this._pending=!1,this.trigger("change",this,i);return this._pending=!1,this._changing=!1,this},unset:function(e,t){return this.set(e,void 0,n.extend({},t,{unset:!0}))},clear:function(e){var t={};for(var i in this.attributes)t[i]=void 0;return this.set(t,n.extend({},e,{unset:!0}))},hasChanged:function(e){return null==e?!n.isEmpty(this.changed):n.has(this.changed,e)},changedAttributes:function(e){if(!e)return this.hasChanged()?n.clone(this.changed):!1;var t,i=!1,r=this._changing?this._previousAttributes:this.attributes;for(var a in e)n.isEqual(r[a],t=e[a])||((i||(i={}))[a]=t);return i},previous:function(e){return null!=e&&this._previousAttributes?this._previousAttributes[e]:null},previousAttributes:function(){return n.clone(this._previousAttributes)},fetch:function(e){e=e?n.clone(e):{},void 0===e.parse&&(e.parse=!0);var t=this,i=e.success;return e.success=function(n){return t.set(t.parse(n,e),e)?(i&&i(t,n,e),void t.trigger("sync",t,n,e)):!1},L(this,e),this.sync("read",this,e)},save:function(e,t,i){var r,a,s,o=this.attributes;if(null==e||"object"==typeof e?(r=e,i=t):(r={})[e]=t,i=n.extend({validate:!0},i),r&&!i.wait){if(!this.set(r,i))return!1}else if(!this._validate(r,i))return!1;r&&i.wait&&(this.attributes=n.extend({},o,r)),void 0===i.parse&&(i.parse=!0);var l=this,u=i.success;return i.success=function(e){l.attributes=o;var t=l.parse(e,i);return i.wait&&(t=n.extend(r||{},t)),n.isObject(t)&&!l.set(t,i)?!1:(u&&u(l,e,i),void l.trigger("sync",l,e,i))},L(this,i),a=this.isNew()?"create":i.patch?"patch":"update","patch"===a&&(i.attrs=r),s=this.sync(a,this,i),r&&i.wait&&(this.attributes=o),s},destroy:function(e){e=e?n.clone(e):{};var t=this,i=e.success,r=function(){t.trigger("destroy",t,t.collection,e)};if(e.success=function(n){(e.wait||t.isNew())&&r(),i&&i(t,n,e),t.isNew()||t.trigger("sync",t,n,e)},this.isNew())return e.success(),!1;L(this,e);var a=this.sync("delete",this,e);return e.wait||r(),a},url:function(){var e=n.result(this,"urlRoot")||n.result(this.collection,"url")||P();return this.isNew()?e:e.replace(/([^\/])$/,"$1/")+encodeURIComponent(this.id)},parse:function(e,t){return e},clone:function(){return new this.constructor(this.attributes)},isNew:function(){return!this.has(this.idAttribute)},isValid:function(e){return this._validate({},n.extend(e||{},{validate:!0}))},_validate:function(e,t){if(!t.validate||!this.validate)return!0;e=n.extend({},this.attributes,e);var i=this.validationError=this.validate(e,t)||null;return i?(this.trigger("invalid",this,i,n.extend(t,{validationError:i})),!1):!0}});var p=["keys","values","pairs","invert","pick","omit"];n.each(p,function(e){h.prototype[e]=function(){var t=s.call(arguments);return t.unshift(this.attributes),n[e].apply(n,t)}});var f=t.Collection=function(e,t){t||(t={}),t.model&&(this.model=t.model),void 0!==t.comparator&&(this.comparator=t.comparator),this._reset(),this.initialize.apply(this,arguments),e&&this.reset(e,n.extend({silent:!0},t))},m={add:!0,remove:!0,merge:!0},g={add:!0,remove:!1};n.extend(f.prototype,o,{model:h,initialize:function(){},toJSON:function(e){return this.map(function(t){return t.toJSON(e)})},sync:function(){return t.sync.apply(this,arguments)},add:function(e,t){return this.set(e,n.extend({merge:!1},t,g))},remove:function(e,t){var i=!n.isArray(e);e=i?[e]:n.clone(e),t||(t={});var r,a,s,o;for(r=0,a=e.length;a>r;r++)o=e[r]=this.get(e[r]),o&&(delete this._byId[o.id],delete this._byId[o.cid],s=this.indexOf(o),this.models.splice(s,1),this.length--,t.silent||(t.index=s,o.trigger("remove",o,this,t)),this._removeReference(o,t));return i?e[0]:e},set:function(e,t){t=n.defaults({},t,m),t.parse&&(e=this.parse(e,t));var i=!n.isArray(e);e=i?e?[e]:[]:n.clone(e);var r,a,s,o,l,u,c,d=t.at,p=this.model,f=this.comparator&&null==d&&t.sort!==!1,g=n.isString(this.comparator)?this.comparator:null,v=[],y=[],b={},x=t.add,w=t.merge,k=t.remove,T=!f&&x&&k?[]:!1;for(r=0,a=e.length;a>r;r++){if(l=e[r]||{},s=l instanceof h?o=l:l[p.prototype.idAttribute||"id"],u=this.get(s))k&&(b[u.cid]=!0),w&&(l=l===o?o.attributes:l,t.parse&&(l=u.parse(l,t)),u.set(l,t),f&&!c&&u.hasChanged(g)&&(c=!0)),e[r]=u;else if(x){if(o=e[r]=this._prepareModel(l,t),!o)continue;v.push(o),this._addReference(o,t)}o=u||o,!T||!o.isNew()&&b[o.id]||T.push(o),b[o.id]=!0}if(k){for(r=0,a=this.length;a>r;++r)b[(o=this.models[r]).cid]||y.push(o);y.length&&this.remove(y,t)}if(v.length||T&&T.length)if(f&&(c=!0),this.length+=v.length,null!=d)for(r=0,a=v.length;a>r;r++)this.models.splice(d+r,0,v[r]);else{T&&(this.models.length=0);var S=T||v;for(r=0,a=S.length;a>r;r++)this.models.push(S[r])}if(c&&this.sort({silent:!0}),!t.silent){for(r=0,a=v.length;a>r;r++)(o=v[r]).trigger("add",o,this,t);(c||T&&T.length)&&this.trigger("sort",this,t)}return i?e[0]:e},reset:function(e,t){t||(t={});for(var i=0,r=this.models.length;r>i;i++)this._removeReference(this.models[i],t);return t.previousModels=this.models,this._reset(),e=this.add(e,n.extend({silent:!0},t)),t.silent||this.trigger("reset",this,t),e},push:function(e,t){return this.add(e,n.extend({at:this.length},t))},pop:function(e){var t=this.at(this.length-1);return this.remove(t,e),t},unshift:function(e,t){return this.add(e,n.extend({at:0},t))},shift:function(e){var t=this.at(0);return this.remove(t,e),t},slice:function(){return s.apply(this.models,arguments)},get:function(e){return null==e?void 0:this._byId[e]||this._byId[e.id]||this._byId[e.cid]},at:function(e){return this.models[e]},where:function(e,t){return n.isEmpty(e)?t?void 0:[]:this[t?"find":"filter"](function(t){for(var n in e)if(e[n]!==t.get(n))return!1;return!0})},findWhere:function(e){return this.where(e,!0)},sort:function(e){if(!this.comparator)throw new Error("Cannot sort a set without a comparator");return e||(e={}),n.isString(this.comparator)||1===this.comparator.length?this.models=this.sortBy(this.comparator,this):this.models.sort(n.bind(this.comparator,this)),e.silent||this.trigger("sort",this,e),this},pluck:function(e){return n.invoke(this.models,"get",e)},fetch:function(e){e=e?n.clone(e):{},void 0===e.parse&&(e.parse=!0);var t=e.success,i=this;return e.success=function(n){var r=e.reset?"reset":"set";i[r](n,e),t&&t(i,n,e),i.trigger("sync",i,n,e)},L(this,e),this.sync("read",this,e)},create:function(e,t){if(t=t?n.clone(t):{},!(e=this._prepareModel(e,t)))return!1;t.wait||this.add(e,t);var i=this,r=t.success;return t.success=function(e,n){t.wait&&i.add(e,t),r&&r(e,n,t)},e.save(null,t),e},parse:function(e,t){return e},clone:function(){return new this.constructor(this.models)},_reset:function(){this.length=0,this.models=[],this._byId={}},_prepareModel:function(e,t){if(e instanceof h)return e;t=t?n.clone(t):{},t.collection=this;var i=new this.model(e,t);return i.validationError?(this.trigger("invalid",this,i.validationError,t),!1):i},_addReference:function(e,t){this._byId[e.cid]=e,null!=e.id&&(this._byId[e.id]=e),e.collection||(e.collection=this),e.on("all",this._onModelEvent,this)},_removeReference:function(e,t){this===e.collection&&delete e.collection,e.off("all",this._onModelEvent,this)},_onModelEvent:function(e,t,n,i){("add"!==e&&"remove"!==e||n===this)&&("destroy"===e&&this.remove(t,i),t&&e==="change:"+t.idAttribute&&(delete this._byId[t.previous(t.idAttribute)],null!=t.id&&(this._byId[t.id]=t)),this.trigger.apply(this,arguments))}});var v=["forEach","each","map","collect","reduce","foldl","inject","reduceRight","foldr","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","max","min","toArray","size","first","head","take","initial","rest","tail","drop","last","without","difference","indexOf","shuffle","lastIndexOf","isEmpty","chain","sample"];n.each(v,function(e){f.prototype[e]=function(){var t=s.call(arguments);return t.unshift(this.models),n[e].apply(n,t)}});var y=["groupBy","countBy","sortBy","indexBy"];n.each(y,function(e){f.prototype[e]=function(t,i){var r=n.isFunction(t)?t:function(e){return e.get(t)};return n[e](this.models,r,i)}});var b=t.View=function(e){this.cid=n.uniqueId("view"),e||(e={}),n.extend(this,n.pick(e,w)),this._ensureElement(),this.initialize.apply(this,arguments),this.delegateEvents()},x=/^(\S+)\s*(.*)$/,w=["model","collection","el","id","attributes","className","tagName","events"];n.extend(b.prototype,o,{tagName:"div",$:function(e){return this.$el.find(e)},initialize:function(){},render:function(){return this},remove:function(){return this.$el.remove(),this.stopListening(),this},setElement:function(e,n){return this.$el&&this.undelegateEvents(),this.$el=e instanceof t.$?e:t.$(e),this.el=this.$el[0],n!==!1&&this.delegateEvents(),this},delegateEvents:function(e){if(!e&&!(e=n.result(this,"events")))return this;this.undelegateEvents();for(var t in e){var i=e[t];if(n.isFunction(i)||(i=this[e[t]]),i){var r=t.match(x),a=r[1],s=r[2];i=n.bind(i,this),a+=".delegateEvents"+this.cid,""===s?this.$el.on(a,i):this.$el.on(a,s,i)}}return this},undelegateEvents:function(){return this.$el.off(".delegateEvents"+this.cid),this},_ensureElement:function(){if(this.el)this.setElement(n.result(this,"el"),!1);else{var e=n.extend({},n.result(this,"attributes"));this.id&&(e.id=n.result(this,"id")),this.className&&(e["class"]=n.result(this,"className"));var i=t.$("<"+n.result(this,"tagName")+">").attr(e);this.setElement(i,!1)}}}),t.sync=function(e,i,r){var a=T[e];n.defaults(r||(r={}),{emulateHTTP:t.emulateHTTP,emulateJSON:t.emulateJSON});var s={type:a,dataType:"json"};if(r.url||(s.url=n.result(i,"url")||P()),null!=r.data||!i||"create"!==e&&"update"!==e&&"patch"!==e||(s.contentType="application/json",s.data=JSON.stringify(r.attrs||i.toJSON(r))),r.emulateJSON&&(s.contentType="application/x-www-form-urlencoded",s.data=s.data?{model:s.data}:{}),r.emulateHTTP&&("PUT"===a||"DELETE"===a||"PATCH"===a)){s.type="POST",r.emulateJSON&&(s.data._method=a);var o=r.beforeSend;r.beforeSend=function(e){return e.setRequestHeader("X-HTTP-Method-Override",a),o?o.apply(this,arguments):void 0}}"GET"===s.type||r.emulateJSON||(s.processData=!1),"PATCH"===s.type&&k&&(s.xhr=function(){return new ActiveXObject("Microsoft.XMLHTTP")});var l=r.xhr=t.ajax(n.extend(s,r));return i.trigger("request",i,l,r),l};var k=!("undefined"==typeof window||!window.ActiveXObject||window.XMLHttpRequest&&(new XMLHttpRequest).dispatchEvent),T={create:"POST",update:"PUT",patch:"PATCH","delete":"DELETE",read:"GET"};t.ajax=function(){return t.$.ajax.apply(t.$,arguments)};var S=t.Router=function(e){e||(e={}),e.routes&&(this.routes=e.routes),this._bindRoutes(),this.initialize.apply(this,arguments)},D=/\((.*?)\)/g,_=/(\(\?)?:\w+/g,N=/\*\w+/g,M=/[\-{}\[\]+?.,\\\^$|#\s]/g;n.extend(S.prototype,o,{initialize:function(){},route:function(e,i,r){n.isRegExp(e)||(e=this._routeToRegExp(e)),n.isFunction(i)&&(r=i,i=""),r||(r=this[i]);var a=this;return t.history.route(e,function(n){var s=a._extractParameters(e,n);a.execute(r,s),a.trigger.apply(a,["route:"+i].concat(s)),a.trigger("route",i,s),t.history.trigger("route",a,i,s)}),this},execute:function(e,t){e&&e.apply(this,t)},navigate:function(e,n){return t.history.navigate(e,n),this},_bindRoutes:function(){if(this.routes){this.routes=n.result(this,"routes");for(var e,t=n.keys(this.routes);null!=(e=t.pop());)this.route(e,this.routes[e])}},_routeToRegExp:function(e){return e=e.replace(M,"\\$&").replace(D,"(?:$1)?").replace(_,function(e,t){return t?e:"([^/?]+)"}).replace(N,"([^?]*?)"),new RegExp("^"+e+"(?:\\?([\\s\\S]*))?$")},_extractParameters:function(e,t){var i=e.exec(t).slice(1);return n.map(i,function(e,t){return t===i.length-1?e||null:e?decodeURIComponent(e):null})}});var C=t.History=function(){this.handlers=[],n.bindAll(this,"checkUrl"),"undefined"!=typeof window&&(this.location=window.location,this.history=window.history)},A=/^[#\/]|\s+$/g,E=/^\/+|\/+$/g,j=/msie [\w.]+/,F=/\/$/,I=/#.*$/;C.started=!1,n.extend(C.prototype,o,{interval:50,atRoot:function(){return this.location.pathname.replace(/[^\/]$/,"$&/")===this.root},getHash:function(e){var t=(e||this).location.href.match(/#(.*)$/);return t?t[1]:""},getFragment:function(e,t){if(null==e)if(this._hasPushState||!this._wantsHashChange||t){e=decodeURI(this.location.pathname+this.location.search);var n=this.root.replace(F,"");e.indexOf(n)||(e=e.slice(n.length))}else e=this.getHash();return e.replace(A,"")},start:function(e){if(C.started)throw new Error("Backbone.history has already been started");C.started=!0,this.options=n.extend({root:"/"},this.options,e),this.root=this.options.root,this._wantsHashChange=this.options.hashChange!==!1,this._wantsPushState=!!this.options.pushState,this._hasPushState=!!(this.options.pushState&&this.history&&this.history.pushState);var i=this.getFragment(),r=document.documentMode,a=j.exec(navigator.userAgent.toLowerCase())&&(!r||7>=r);if(this.root=("/"+this.root+"/").replace(E,"/"),a&&this._wantsHashChange){var s=t.$('