fineract-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nazeer1100...@apache.org
Subject [1/6] fineract git commit: ReportRunFrequncy parameter was added
Date Mon, 11 Dec 2017 10:29:24 GMT
Repository: fineract
Updated Branches:
  refs/heads/develop 504f679c8 -> bf894732d


ReportRunFrequncy parameter was added


Project: http://git-wip-us.apache.org/repos/asf/fineract/repo
Commit: http://git-wip-us.apache.org/repos/asf/fineract/commit/5cfea884
Tree: http://git-wip-us.apache.org/repos/asf/fineract/tree/5cfea884
Diff: http://git-wip-us.apache.org/repos/asf/fineract/diff/5cfea884

Branch: refs/heads/develop
Commit: 5cfea884cee0e3545d3090e8f6c401aff82b54ae
Parents: d6accae
Author: Konstantin Golub <key.offecka@runbox.com>
Authored: Wed Oct 4 17:22:26 2017 -0300
Committer: Konstantin Golub <key.offecka@runbox.com>
Committed: Wed Oct 4 17:22:26 2017 -0300

----------------------------------------------------------------------
 .../adhocquery/api/AdHocJsonInputParams.java    |  5 ++-
 .../fineract/adhocquery/data/AdHocData.java     | 47 ++++++++++++++------
 .../fineract/adhocquery/domain/AdHoc.java       | 36 ++++++++++++---
 .../adhocquery/domain/ReportRunFrequency.java   | 43 ++++++++++++++++++
 .../adhocquery/service/AdHocDataValidator.java  | 26 ++++++++++-
 .../service/AdHocReadPlatformServiceImpl.java   |  9 ++--
 .../core_db/V336__report-run-frequency.sql      | 22 +++++++++
 7 files changed, 164 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/fineract/blob/5cfea884/fineract-provider/src/main/java/org/apache/fineract/adhocquery/api/AdHocJsonInputParams.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/adhocquery/api/AdHocJsonInputParams.java
b/fineract-provider/src/main/java/org/apache/fineract/adhocquery/api/AdHocJsonInputParams.java
index 0cb3384..e8c1420 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/adhocquery/api/AdHocJsonInputParams.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/adhocquery/api/AdHocJsonInputParams.java
@@ -25,7 +25,10 @@ import java.util.Set;
  * Enum of all parameters passed in while creating/updating a AdHocQuery 
  ***/
 public enum AdHocJsonInputParams {
-    ID("id"), NAME("name"),QUERY("query"),TABLENAME("tableName"),TABLEFIELD("tableFields"),
ISACTIVE("isActive"),EMAIL("email");
+    ID("id"), NAME("name"),QUERY("query"),TABLENAME("tableName"),TABLEFIELD("tableFields"),
ISACTIVE("isActive"),
+    REPORT_RUN_FREQUENCY("reportRunFrequency"),
+    REPORT_RUN_EVERY("reportRunEvery"),
+    EMAIL("email");
 
     private final String value;
 

http://git-wip-us.apache.org/repos/asf/fineract/blob/5cfea884/fineract-provider/src/main/java/org/apache/fineract/adhocquery/data/AdHocData.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/adhocquery/data/AdHocData.java
b/fineract-provider/src/main/java/org/apache/fineract/adhocquery/data/AdHocData.java
index f0fd7a8..bd5421d 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/adhocquery/data/AdHocData.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/adhocquery/data/AdHocData.java
@@ -18,13 +18,13 @@
  */
 package org.apache.fineract.adhocquery.data;
 
-import java.util.Collection;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
 
-import org.apache.fineract.organisation.office.data.OfficeData;
-import org.apache.fineract.useradministration.data.AppUserData;
-import org.apache.fineract.useradministration.data.RoleData;
+import org.apache.fineract.adhocquery.domain.ReportRunFrequency;
+import org.apache.fineract.infrastructure.core.data.EnumOptionData;
 import org.joda.time.DateTime;
-import org.joda.time.LocalDate;
 
 /**
  * Immutable data object represent note or case information AdHocData
@@ -32,8 +32,8 @@ import org.joda.time.LocalDate;
  */
 public class AdHocData {
 
-	
-    
+
+
 	@SuppressWarnings("unused")
     private final Long id;
     @SuppressWarnings("unused")
@@ -59,13 +59,16 @@ public class AdHocData {
 	@SuppressWarnings("unused")
 	private final String createdBy;
 	
-    
-	
+    private final List<EnumOptionData> reportRunFrequencies;
+
+    private final Long reportRunFrequency;
 
-    public AdHocData(final Long id, final String name,final String query, final String tableName,final
String tableFields, 
-    		final boolean isActive, final DateTime createdOn, final Long createdById,final Long
updatedById,
-    		final DateTime updatedOn,final String createdBy,final String email
-            ) {
+    private final Long reportRunEvery;
+
+    public AdHocData(final Long id, final String name, final String query, final String tableName,
final String tableFields,
+                     final boolean isActive, final DateTime createdOn, final Long createdById,
final Long updatedById,
+                     final DateTime updatedOn, final String createdBy, final String email,
+                     final List<EnumOptionData> reportRunFrequencies, final Long reportRunFrequency,
final Long reportRunEvery) {
         this.id = id;
         this.name=name;
         this.query=query;
@@ -78,9 +81,16 @@ public class AdHocData {
         this.updatedOn=updatedOn;
         this.createdBy=createdBy;
         this.email=email;
+	    this.reportRunFrequencies = reportRunFrequencies;
+	    this.reportRunFrequency = reportRunFrequency;
+	    this.reportRunEvery = reportRunEvery;
     }
     public static AdHocData template() {
-        AdHocData adHocData = new AdHocData(null,null,null,null,null,false,null,null,null,null,null,null);
+	    List<EnumOptionData> reportRunFrequencies = Arrays.stream(ReportRunFrequency.values()).map(rrf
-> new EnumOptionData(
+		    (long) rrf.getValue(), rrf.getCode(), rrf.getCode()
+	    )).collect(Collectors.toList());
+
+	    AdHocData adHocData = new AdHocData(null,null,null,null,null,false,null,null,null,null,null,null,
reportRunFrequencies, null, null);
 		return adHocData;
     }
     public Long getId() {
@@ -119,4 +129,13 @@ public class AdHocData {
 	public String getCreatedBy() {
 		return this.createdBy;
 	}
+	public List<EnumOptionData> getReportRunFrequencies() {
+		return this.reportRunFrequencies;
+	}
+	public Long getReportRunFrequency() {
+		return this.reportRunFrequency;
+	}
+	public Long getReportRunEvery() {
+		return this.reportRunEvery;
+	}
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/fineract/blob/5cfea884/fineract-provider/src/main/java/org/apache/fineract/adhocquery/domain/AdHoc.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/adhocquery/domain/AdHoc.java
b/fineract-provider/src/main/java/org/apache/fineract/adhocquery/domain/AdHoc.java
index be315ba..93fa73f 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/adhocquery/domain/AdHoc.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/adhocquery/domain/AdHoc.java
@@ -53,17 +53,24 @@ public class AdHoc extends AbstractAuditableCustom<AppUser, Long>
{
    	
     @Column(name = "email", length = 500)
     private  String email;
-    
-   
+
+    @Column(name = "report_run_frequency_code")
+    private Long reportRunFrequency;
+
+    @Column(name = "report_run_every")
+    private Long reportRunEvery;
+
 	@Column(name = "IsActive", nullable = false)
     private boolean isActive = false;
    	
-    private AdHoc(final String name, final String query,final String tableName,final String
tableFields ,final String email,final boolean isActive) {
+    private AdHoc(final String name, final String query,final String tableName,final String
tableFields ,final String email, final Long reportRunFrequency, final Long reportRunEvery,
final boolean isActive) {
         this.name = StringUtils.defaultIfEmpty(name, null);
         this.query=StringUtils.defaultIfEmpty(query,null);
         this.tableName=StringUtils.defaultIfEmpty(tableName,null);
         this.tableFields=StringUtils.defaultIfEmpty(tableFields,null);
         this.email=StringUtils.defaultIfEmpty(email,null);
+        this.reportRunFrequency = reportRunFrequency;
+        this.reportRunEvery = reportRunEvery;
         this.isActive = BooleanUtils.toBooleanDefaultIfNull(isActive, false);
        
     }
@@ -77,8 +84,10 @@ public class AdHoc extends AbstractAuditableCustom<AppUser, Long>
{
         final String tableName = command.stringValueOfParameterNamed(AdHocJsonInputParams.TABLENAME.getValue());
         final String tableFields = command.stringValueOfParameterNamed(AdHocJsonInputParams.TABLEFIELD.getValue());
         final String email = command.stringValueOfParameterNamed(AdHocJsonInputParams.EMAIL.getValue());
+        final Long reportRunFrequency = command.longValueOfParameterNamed(AdHocJsonInputParams.REPORT_RUN_FREQUENCY.getValue());
+        final Long reportRunEvery = command.longValueOfParameterNamed(AdHocJsonInputParams.REPORT_RUN_EVERY.getValue());
         final boolean isActive = command.booleanPrimitiveValueOfParameterNamed(AdHocJsonInputParams.ISACTIVE.getValue());
-        return new AdHoc(name,query,tableName,tableFields ,email,isActive);
+        return new AdHoc(name,query,tableName,tableFields, email, reportRunFrequency, reportRunEvery,
isActive);
     }
     
     public Map<String, Object> update(final JsonCommand command) {
@@ -116,6 +125,18 @@ public class AdHoc extends AbstractAuditableCustom<AppUser, Long>
{
             actualChanges.put(email, newValue);
             this.email = newValue;
         }
+        final String reportRunFrequency = "reportRunFrequency";
+        if (command.isChangeInLongParameterNamed(reportRunFrequency, this.getReportRunFrequency()))
{
+            final Long newValue = command.longValueOfParameterNamed(reportRunFrequency);
+            actualChanges.put(reportRunFrequency, newValue);
+            this.reportRunFrequency = newValue;
+        }
+        final String reportRunEvery = "reportRunEvery";
+        if (command.isChangeInLongParameterNamed(reportRunEvery, this.getReportRunEvery()))
{
+            final Long newValue = command.longValueOfParameterNamed(reportRunEvery);
+            actualChanges.put(reportRunEvery, newValue);
+            this.reportRunEvery = newValue;
+        }
         final String paramisActive = "isActive";
         if (command.isChangeInBooleanParameterNamed(paramisActive, this.isActive)) {
         	final Boolean newValue = command.booleanObjectValueOfParameterNamed(paramisActive);
@@ -149,5 +170,10 @@ public class AdHoc extends AbstractAuditableCustom<AppUser, Long>
{
     public void enableActive() {
     	this.isActive = false;
     }
-
+    public Long getReportRunFrequency() {
+        return this.reportRunFrequency;
+    }
+    public Long getReportRunEvery() {
+        return this.reportRunEvery;
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/fineract/blob/5cfea884/fineract-provider/src/main/java/org/apache/fineract/adhocquery/domain/ReportRunFrequency.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/adhocquery/domain/ReportRunFrequency.java
b/fineract-provider/src/main/java/org/apache/fineract/adhocquery/domain/ReportRunFrequency.java
new file mode 100644
index 0000000..78bd011
--- /dev/null
+++ b/fineract-provider/src/main/java/org/apache/fineract/adhocquery/domain/ReportRunFrequency.java
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.adhocquery.domain;
+
+public enum ReportRunFrequency {
+    DAILY(1, "reportRunFrequency.daily"),
+    WEEKLY(2, "reportRunFrequency.weekly"),
+    MONTHLY(3, "reportRunFrequency.monthly"),
+    YEARLY(4, "reportRunFrequency.yearly"),
+    CUSTOM(5, "reportRunFrequency.custom");
+
+    private final int value;
+    private final String code;
+
+    private ReportRunFrequency(final int value, final String code) {
+        this.value = value;
+        this.code = code;
+    }
+
+    public int getValue() {
+        return this.value;
+    }
+
+    public String getCode() {
+        return this.code;
+    }
+}

http://git-wip-us.apache.org/repos/asf/fineract/blob/5cfea884/fineract-provider/src/main/java/org/apache/fineract/adhocquery/service/AdHocDataValidator.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/adhocquery/service/AdHocDataValidator.java
b/fineract-provider/src/main/java/org/apache/fineract/adhocquery/service/AdHocDataValidator.java
index 2cdd294..b96cc10 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/adhocquery/service/AdHocDataValidator.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/adhocquery/service/AdHocDataValidator.java
@@ -27,6 +27,7 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.commons.lang.StringUtils;
+import org.apache.fineract.adhocquery.domain.ReportRunFrequency;
 import org.apache.fineract.infrastructure.core.data.ApiParameterError;
 import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder;
 import org.apache.fineract.infrastructure.core.exception.InvalidJsonException;
@@ -44,7 +45,9 @@ public final class AdHocDataValidator {
     /**
      * The parameters supported for this command.
      */
-    private final Set<String> supportedParameters = new HashSet<>(Arrays.asList("name","query","tableName","tableFields","email","isActive"));
+    private final Set<String> supportedParameters = new HashSet<>(Arrays.asList(
+        "name","query","tableName","tableFields","email","isActive", "reportRunFrequency",
"reportRunEvery"
+    ));
 
     private final FromJsonHelper fromApiJsonHelper;
 
@@ -78,6 +81,18 @@ public final class AdHocDataValidator {
 
         final String email = this.fromApiJsonHelper.extractStringNamed("email", element);
         baseDataValidator.reset().parameter("email").value(email).notBlank().notExceedingLengthOf(500);
+
+        final Long reportRunFrequencyCode = this.fromApiJsonHelper.extractLongNamed("reportRunFrequency",
element);
+        if (reportRunFrequencyCode != null) {
+            baseDataValidator.reset().parameter("reportRunFrequency").value(reportRunFrequencyCode)
+                .inMinMaxRange(ReportRunFrequency.DAILY.getValue(), ReportRunFrequency.CUSTOM.getValue());
+        }
+
+        final Long reportRunEvery = this.fromApiJsonHelper.extractLongNamed("reportRunEvery",
element);
+        if (reportRunEvery != null) {
+            baseDataValidator.reset().parameter("reportRunEvery").value(reportRunFrequencyCode).integerGreaterThanZero();
+        }
+
         throwExceptionIfValidationWarningsExist(dataValidationErrors);
     }
 
@@ -113,6 +128,15 @@ public final class AdHocDataValidator {
             final String email = this.fromApiJsonHelper.extractStringNamed("email", element);
             baseDataValidator.reset().parameter("email").value(email).notBlank().notExceedingLengthOf(500);
         }
+        if (this.fromApiJsonHelper.parameterExists("reportRunFrequency", element)) {
+            final Long reportRunFrequencyCode = this.fromApiJsonHelper.extractLongNamed("reportRunFrequency",
element);
+            baseDataValidator.reset().parameter("reportRunFrequency").value(reportRunFrequencyCode)
+                .inMinMaxRange(ReportRunFrequency.DAILY.getValue(), ReportRunFrequency.CUSTOM.getValue());
+        }
+        if (this.fromApiJsonHelper.parameterExists("reportRunEvery", element)) {
+            final Long reportRunEvery = this.fromApiJsonHelper.extractLongNamed("reportRunEvery",
element);
+            baseDataValidator.reset().parameter("reportRunEvery").value(reportRunEvery).integerGreaterThanZero();
+        }
         /*if (this.fromApiJsonHelper.parameterExists("isActive", element)) {
             final Integer isActive = this.fromApiJsonHelper.extractIntegerNamed("isActive",
element, Locale.getDefault());
             baseDataValidator.reset().parameter("isActive").value(isActive).notNull().inMinMaxRange(1,
2);

http://git-wip-us.apache.org/repos/asf/fineract/blob/5cfea884/fineract-provider/src/main/java/org/apache/fineract/adhocquery/service/AdHocReadPlatformServiceImpl.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/adhocquery/service/AdHocReadPlatformServiceImpl.java
b/fineract-provider/src/main/java/org/apache/fineract/adhocquery/service/AdHocReadPlatformServiceImpl.java
index eb1f633..2ea6cfd 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/adhocquery/service/AdHocReadPlatformServiceImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/adhocquery/service/AdHocReadPlatformServiceImpl.java
@@ -88,13 +88,16 @@ public class AdHocReadPlatformServiceImpl implements AdHocReadPlatformService
{
             final DateTime updatedOn=JdbcSupport.getDateTime(rs, "updatedOn");
             final String createdByUsername=rs.getString("createdBy");
             final String email=rs.getString("email");
-          
-            return new AdHocData(id,name,query, tableName,tableFields,isActive,createdDate,createdById,updatedById,updatedOn,createdByUsername,email);
+            final Long reportRunFrequency=JdbcSupport.getLong(rs, "report_run_frequency_code");
+            final Long reportRunEvery=JdbcSupport.getLong(rs, "report_run_every");
+
+            return new AdHocData(id,name,query, tableName,tableFields,isActive,createdDate,createdById,updatedById,updatedOn,createdByUsername,email,
AdHocData.template().getReportRunFrequencies(), reportRunFrequency, reportRunEvery);
         }
 
         public String schema() {
             return " r.id as id, r.name as name, r.query as query, r.table_name as tableName,r.table_fields
as tableField ,r.IsActive as isActive ,r.email as email ,"
-            		+" r.created_date as createdDate, r.createdby_id as createdById,cb.username
as createdBy,r.lastmodifiedby_id as updatedById ,r.lastmodified_date as updatedOn "
+                    + " r.report_run_frequency_code, r.report_run_every, "
+            		+ " r.created_date as createdDate, r.createdby_id as createdById,cb.username
as createdBy,r.lastmodifiedby_id as updatedById ,r.lastmodified_date as updatedOn "
                     + " from m_adhoc r left join m_appuser cb on cb.id=r.createdby_id left
join m_appuser mb on mb.id=r.lastmodifiedby_id";
             		        
         }

http://git-wip-us.apache.org/repos/asf/fineract/blob/5cfea884/fineract-provider/src/main/resources/sql/migrations/core_db/V336__report-run-frequency.sql
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/resources/sql/migrations/core_db/V336__report-run-frequency.sql
b/fineract-provider/src/main/resources/sql/migrations/core_db/V336__report-run-frequency.sql
new file mode 100644
index 0000000..3f593c4
--- /dev/null
+++ b/fineract-provider/src/main/resources/sql/migrations/core_db/V336__report-run-frequency.sql
@@ -0,0 +1,22 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership. The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing,
+-- software distributed under the License is distributed on an
+-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+-- KIND, either express or implied. See the License for the
+-- specific language governing permissions and limitations
+-- under the License.
+--
+
+ALTER TABLE m_adhoc ADD COLUMN report_run_frequency_code INT NULL DEFAULT NULL;
+ALTER TABLE m_adhoc ADD COLUMN report_run_every INT NULL DEFAULT NULL;
+ALTER TABLE m_adhoc ADD COLUMN last_run TIMESTAMP NULL DEFAULT NULL;
\ No newline at end of file


Mime
View raw message