fineract-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From my...@apache.org
Subject [fineract-cn-reporting] 22/24: LicenseFormat and clean up dead code
Date Mon, 22 Jan 2018 15:31:19 GMT
This is an automated email from the ASF dual-hosted git repository.

myrle pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract-cn-reporting.git

commit c35f4b963e317d78306e1b20a245ff4172ba608d
Author: Awasum Yannick <awasum.yannick@skylabase.com>
AuthorDate: Fri Sep 29 17:13:07 2017 +0100

    LicenseFormat and clean up dead code
---
 .../BalanceSheetReportSpecification.java           |   4 -
 .../EmployeeListReportSpecification.java           | 278 ---------------------
 .../IncomeStatementReportSpecification.java        |  11 +-
 .../specification/LoanListReportSpecification.java |   5 +-
 .../TellerListReportSpecification.java             |   4 +-
 .../TellerTransactionReportSpecification.java      |   2 +-
 6 files changed, 5 insertions(+), 299 deletions(-)

diff --git a/service/src/main/java/io/mifos/reporting/service/internal/specification/BalanceSheetReportSpecification.java
b/service/src/main/java/io/mifos/reporting/service/internal/specification/BalanceSheetReportSpecification.java
index d8a25d5..1c6810e 100644
--- a/service/src/main/java/io/mifos/reporting/service/internal/specification/BalanceSheetReportSpecification.java
+++ b/service/src/main/java/io/mifos/reporting/service/internal/specification/BalanceSheetReportSpecification.java
@@ -41,9 +41,7 @@ public class BalanceSheetReportSpecification implements ReportSpecification
{
     private static final String TYPE = "Type";
     private static final String IDENTIFIER = "Identifier";
     private static final String NAME = "Name";
-    private static final String HOLDER = "Holder";
     private static final String BALANCE = "Balance";
-    private static final String STATE = "State";
 
     private final Logger logger;
 
@@ -123,9 +121,7 @@ public class BalanceSheetReportSpecification implements ReportSpecification
{
         this.accountingColumnMapping.put(TYPE, "acc.a_type");
         this.accountingColumnMapping.put(IDENTIFIER, "acc.identifier");
         this.accountingColumnMapping.put(NAME, "acc.a_name");
-        this.accountingColumnMapping.put(HOLDER, "acc.holders");
         this.accountingColumnMapping.put(BALANCE, "acc.balance");
-        this.accountingColumnMapping.put(STATE, "acc.a_state");
 
         this.allColumnMapping.putAll(accountingColumnMapping);
     }
diff --git a/service/src/main/java/io/mifos/reporting/service/internal/specification/EmployeeListReportSpecification.java
b/service/src/main/java/io/mifos/reporting/service/internal/specification/EmployeeListReportSpecification.java
deleted file mode 100644
index be1a58b..0000000
--- a/service/src/main/java/io/mifos/reporting/service/internal/specification/EmployeeListReportSpecification.java
+++ /dev/null
@@ -1,278 +0,0 @@
-/*
- * Copyright 2017 The Mifos Initiative.
- *
- * Licensed 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 io.mifos.reporting.service.internal.specification;
-
-import io.mifos.core.api.util.UserContextHolder;
-import io.mifos.core.lang.DateConverter;
-import io.mifos.reporting.api.v1.domain.*;
-import io.mifos.reporting.service.ServiceConstants;
-import io.mifos.reporting.service.spi.*;
-import org.slf4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-import java.time.Clock;
-import java.time.LocalDateTime;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.stream.Collectors;
-
-@Report(category = "Organization", identifier = "Employee")
-public class EmployeeListReportSpecification implements ReportSpecification {
-
-    private static final String USERNAME = "Username";
-    private static final String FIRST_NAME = "First Name";
-    private static final String MIDDLE_NAME = "Middle Name";
-    private static final String LAST_NAME = "Last Name";
-    private static final String CREATED_BY = "Created By";
-
-    private static final String OFFICE = "Office Id";
-    private static final String OFFICE_NAME = "Office Name";
-
-    private final Logger logger;
-
-    private final EntityManager entityManager;
-
-    private final HashMap<String, String> employeeColumnMapping = new HashMap<>();
-    private final HashMap<String, String> officeColumnMapping = new HashMap<>();
-    private final HashMap<String, String> allColumnMapping = new HashMap<>();
-
-
-    @Autowired
-    public EmployeeListReportSpecification(@Qualifier(ServiceConstants.LOGGER_NAME) final
Logger logger,
-                                           final EntityManager entityManager) {
-        super();
-        this.logger = logger;
-        this.entityManager = entityManager;
-        this.initializeMapping();
-    }
-
-    @Override
-    public ReportDefinition getReportDefinition() {
-        final ReportDefinition reportDefinition = new ReportDefinition();
-        reportDefinition.setIdentifier("Employee");
-        reportDefinition.setName("Employee Listing");
-        reportDefinition.setDescription("List of all employees.");
-        reportDefinition.setQueryParameters(this.buildQueryParameters());
-        reportDefinition.setDisplayableFields(this.buildDisplayableFields());
-        return reportDefinition;
-    }
-
-    @Override
-    public ReportPage generateReport(final ReportRequest reportRequest, final int pageIndex,
final int size) {
-        final ReportDefinition reportDefinition = this.getReportDefinition();
-        this.logger.info("Generating report {0}.", reportDefinition.getIdentifier());
-
-        final ReportPage reportPage = new ReportPage();
-        reportPage.setName(reportDefinition.getName());
-        reportPage.setDescription(reportDefinition.getDescription());
-        reportPage.setHeader(this.createHeader(reportRequest.getDisplayableFields()));
-
-        final Query customerQuery = this.entityManager.createNativeQuery(this.buildEmployeeQuery(reportRequest,
pageIndex, size));
-        final List<?> customerResultList =  customerQuery.getResultList();
-        reportPage.setRows(this.buildRows(reportRequest, customerResultList));
-
-        reportPage.setHasMore(
-                !this.entityManager.createNativeQuery(this.buildEmployeeQuery(reportRequest,
pageIndex + 1, size))
-                        .getResultList().isEmpty()
-        );
-
-        reportPage.setGeneratedBy(UserContextHolder.checkedGetUser());
-        reportPage.setGeneratedOn(DateConverter.toIsoString(LocalDateTime.now(Clock.systemUTC())));
-        return reportPage;
-    }
-
-    @Override
-    public void validate(final ReportRequest reportRequest) throws IllegalArgumentException
{
-        final ArrayList<String> unknownFields =  new ArrayList<>();
-        reportRequest.getQueryParameters().forEach(queryParameter -> {
-            if (!this.allColumnMapping.keySet().contains(queryParameter.getName())) {
-                unknownFields.add(queryParameter.getName());
-            }
-        });
-
-        reportRequest.getDisplayableFields().forEach(displayableField -> {
-            if (!this.allColumnMapping.keySet().contains(displayableField.getName())) {
-                unknownFields.add(displayableField.getName());
-            }
-        });
-
-        if (!unknownFields.isEmpty()) {
-            throw new IllegalArgumentException(
-                    "Unspecified fields requested: " + unknownFields.stream().collect(Collectors.joining(",
"))
-            );
-        }
-    }
-
-    private void initializeMapping() {
-        this.employeeColumnMapping.put(USERNAME, "he.identifier");
-        this.employeeColumnMapping.put(FIRST_NAME, "he.given_name");
-        this.employeeColumnMapping.put(MIDDLE_NAME, "he.middle_name");
-        this.employeeColumnMapping.put(LAST_NAME, "he.surname");
-        this.employeeColumnMapping.put(CREATED_BY, "he.created_by");
-        this.employeeColumnMapping.put(OFFICE, "he.assigned_office_id");
-
-        this.officeColumnMapping.put(OFFICE_NAME, "ho.a_name");
-
-        this.allColumnMapping.putAll(employeeColumnMapping);
-        this.allColumnMapping.putAll(officeColumnMapping);
-    }
-
-    private Header createHeader(final List<DisplayableField> displayableFields) {
-        final Header header = new Header();
-        header.setColumnNames(
-                displayableFields
-                        .stream()
-                        .map(DisplayableField::getName)
-                        .collect(Collectors.toList())
-        );
-        return header;
-    }
-
-
-    private List<Row> buildRows(final ReportRequest reportRequest, final List<?>
employeeResultList) {
-        final ArrayList<Row> rows = new ArrayList<>();
-
-        employeeResultList.forEach(result -> {
-            final Row row = new Row();
-            row.setValues(new ArrayList<>());
-
-            final String officeIdentifier;
-
-            if (result instanceof Object[]) {
-                final Object[] resultValues = (Object[]) result;
-
-                officeIdentifier = resultValues[0].toString();
-
-                for (final Object resultValue : resultValues) {
-                    final Value value = new Value();
-                    if (resultValue != null) {
-                        value.setValues(new String[]{resultValue.toString()});
-                    } else {
-                        value.setValues(new String[]{});
-                    }
-
-                    row.getValues().add(value);
-                }
-            } else {
-                officeIdentifier = result.toString();
-
-                final Value value = new Value();
-                value.setValues(new String[]{result.toString()});
-                row.getValues().add(value);
-            }
-
-            final String officeQueryString = this.buildOfficeQuery(reportRequest, officeIdentifier);
-            if (officeQueryString != null) {
-                final Query officeQuery = this.entityManager.createNativeQuery(officeQueryString);
-                final List<?> resultList = officeQuery.getResultList();
-                final Value officeValue = new Value();
-                officeValue.setValues(new String[]{resultList.get(0).toString()});
-                row.getValues().add(officeValue);
-            }
-
-            rows.add(row);
-        });
-
-        return rows;
-    }
-
-    private List<QueryParameter> buildQueryParameters() {
-        return Arrays.asList(
-                //QueryParameterBuilder.create(DATE_RANGE, Type.DATE).operator(QueryParameter.Operator.BETWEEN).build(),
-                //QueryParameterBuilder.create(STATE, Type.TEXT).operator(QueryParameter.Operator.IN).build()
-        );
-    }
-
-    private List<DisplayableField> buildDisplayableFields() {
-        return Arrays.asList(
-                DisplayableFieldBuilder.create(OFFICE, Type.TEXT).mandatory().build(),
-                DisplayableFieldBuilder.create(USERNAME, Type.TEXT).mandatory().build(),
-                DisplayableFieldBuilder.create(FIRST_NAME, Type.TEXT).mandatory().build(),
-                DisplayableFieldBuilder.create(MIDDLE_NAME, Type.TEXT).build(),
-                DisplayableFieldBuilder.create(LAST_NAME, Type.TEXT).mandatory().build(),
-                DisplayableFieldBuilder.create(CREATED_BY, Type.TEXT).mandatory().build(),
-                DisplayableFieldBuilder.create(OFFICE_NAME, Type.TEXT).mandatory().build()
-        );
-    }
-
-    private String buildEmployeeQuery(final ReportRequest reportRequest, int pageIndex, int
size) {
-        final StringBuilder query = new StringBuilder("SELECT ");
-
-        final List<DisplayableField> displayableFields = reportRequest.getDisplayableFields();
-        final ArrayList<String> columns = new ArrayList<>();
-        displayableFields.forEach(displayableField -> {
-            final String column = this.employeeColumnMapping.get(displayableField.getName());
-            if (column != null) {
-                columns.add(column);
-            }
-        });
-
-        query.append(columns.stream().collect(Collectors.joining(", ")))
-                .append(" FROM ")
-                .append("horus_employees he ");
-
-        final List<QueryParameter> queryParameters = reportRequest.getQueryParameters();
-        if (!queryParameters.isEmpty()) {
-            final ArrayList<String> criteria = new ArrayList<>();
-            queryParameters.forEach(queryParameter -> {
-                if(queryParameter.getValue() != null && !queryParameter.getValue().isEmpty())
{
-                    criteria.add(
-                            CriteriaBuilder.buildCriteria(this.employeeColumnMapping.get(queryParameter.getName()),
queryParameter)
-                    );
-                }
-            });
-
-            if (!criteria.isEmpty()) {
-                query.append(" WHERE ");
-                query.append(criteria.stream().collect(Collectors.joining(" AND ")));
-            }
-
-        }
-        query.append(" ORDER BY he.identifier");
-
-        query.append(" LIMIT ");
-        query.append(size);
-        if (pageIndex > 0) {
-            query.append(" OFFSET ");
-            query.append(size * pageIndex);
-        }
-
-        return query.toString();
-    }
-
-    private String buildOfficeQuery(final ReportRequest reportRequest, final String officeIdentifier)
{
-        final List<DisplayableField> displayableFields = reportRequest.getDisplayableFields();
-        final ArrayList<String> columns = new ArrayList<>();
-        displayableFields.forEach(displayableField -> {
-            final String column = this.officeColumnMapping.get(displayableField.getName());
-            if (column != null) {
-                columns.add(column);
-            }
-        });
-        if (!columns.isEmpty()) {
-        return "SELECT DISTINCT " + columns.get(0).toString() + " " +
-                "FROM horus_offices ho " +
-                "LEFT JOIN horus_employees he on ho.id = he.assigned_office_id " +
-                "WHERE he.assigned_office_id ='" + officeIdentifier + "' ";
-        }
-        return null;
-    }
-}
diff --git a/service/src/main/java/io/mifos/reporting/service/internal/specification/IncomeStatementReportSpecification.java
b/service/src/main/java/io/mifos/reporting/service/internal/specification/IncomeStatementReportSpecification.java
index 00c6472..c535d22 100644
--- a/service/src/main/java/io/mifos/reporting/service/internal/specification/IncomeStatementReportSpecification.java
+++ b/service/src/main/java/io/mifos/reporting/service/internal/specification/IncomeStatementReportSpecification.java
@@ -41,9 +41,7 @@ public class IncomeStatementReportSpecification implements ReportSpecification
{
     private static final String TYPE = "Type";
     private static final String IDENTIFIER = "Identifier";
     private static final String NAME = "Name";
-    private static final String HOLDER = "Holder";
     private static final String BALANCE = "Balance";
-    private static final String STATE = "State";
 
     private final Logger logger;
 
@@ -123,9 +121,7 @@ public class IncomeStatementReportSpecification implements ReportSpecification
{
         this.accountColumnMapping.put(TYPE, "acc.a_type");
         this.accountColumnMapping.put(IDENTIFIER, "acc.identifier");
         this.accountColumnMapping.put(NAME, "acc.a_name");
-        this.accountColumnMapping.put(HOLDER, "acc.holders");
         this.accountColumnMapping.put(BALANCE, "acc.balance");
-        this.accountColumnMapping.put(STATE, "acc.a_state");
 
         this.allColumnMapping.putAll(accountColumnMapping);
     }
@@ -290,16 +286,11 @@ public class IncomeStatementReportSpecification implements ReportSpecification
{
                 DisplayableFieldBuilder.create(TYPE, Type.TEXT).mandatory().build(),
                 DisplayableFieldBuilder.create(IDENTIFIER, Type.TEXT).mandatory().build(),
                 DisplayableFieldBuilder.create(NAME, Type.TEXT).mandatory().build(),
-                //DisplayableFieldBuilder.create(HOLDER, Type.TEXT).build(),
                 DisplayableFieldBuilder.create(BALANCE, Type.TEXT).mandatory().build()
-               // DisplayableFieldBuilder.create(STATE, Type.TEXT).mandatory().build()
         );
     }
 
     private List<QueryParameter> buildQueryParameters() {
-        return Arrays.asList(
-               // QueryParameterBuilder.create(DATE_RANGE, Type.DATE).operator(QueryParameter.Operator.BETWEEN).build(),
-                //QueryParameterBuilder.create(STATE, Type.TEXT).operator(QueryParameter.Operator.IN).build()
-        );
+        return Arrays.asList();
     }
 }
diff --git a/service/src/main/java/io/mifos/reporting/service/internal/specification/LoanListReportSpecification.java
b/service/src/main/java/io/mifos/reporting/service/internal/specification/LoanListReportSpecification.java
index fcd6d8b..4c71929 100644
--- a/service/src/main/java/io/mifos/reporting/service/internal/specification/LoanListReportSpecification.java
+++ b/service/src/main/java/io/mifos/reporting/service/internal/specification/LoanListReportSpecification.java
@@ -274,10 +274,7 @@ public class LoanListReportSpecification implements ReportSpecification
{
     }
 
     private List<QueryParameter> buildQueryParameters() {
-        return Arrays.asList(
-                //QueryParameterBuilder.create(DATE_RANGE, Type.DATE).operator(QueryParameter.Operator.BETWEEN).build()
-                //QueryParameterBuilder.create(LOAN_STATE, Type.TEXT).operator(QueryParameter.Operator.IN).build()
-        );
+        return Arrays.asList();
     }
 
     private String buildCustomerQuery(final ReportRequest reportRequest, int pageIndex, int
size){
diff --git a/service/src/main/java/io/mifos/reporting/service/internal/specification/TellerListReportSpecification.java
b/service/src/main/java/io/mifos/reporting/service/internal/specification/TellerListReportSpecification.java
index 7f33edb..33cc53c 100644
--- a/service/src/main/java/io/mifos/reporting/service/internal/specification/TellerListReportSpecification.java
+++ b/service/src/main/java/io/mifos/reporting/service/internal/specification/TellerListReportSpecification.java
@@ -84,7 +84,7 @@ public class TellerListReportSpecification implements ReportSpecification
{
 
         final Query tellerQuery = this.entityManager.createNativeQuery(this.buildTellerQuery(reportRequest,
pageIndex, size));
         final List<?> tellerResultList =  tellerQuery.getResultList();
-        reportPage.setRows(this.buildRows(reportRequest, tellerResultList));
+        reportPage.setRows(this.buildRows(tellerResultList));
 
         reportPage.setHasMore(
                 !this.entityManager.createNativeQuery(this.buildTellerQuery(reportRequest,
pageIndex + 1, size))
@@ -140,7 +140,7 @@ public class TellerListReportSpecification implements ReportSpecification
{
         return header;
     }
 
-    private List<Row> buildRows(ReportRequest reportRequest, List<?> tellerResultList)
{
+    private List<Row> buildRows(final List<?> tellerResultList) {
         final ArrayList<Row> rows = new ArrayList<>();
         tellerResultList.forEach(result -> {
             final Row row = new Row();
diff --git a/service/src/main/java/io/mifos/reporting/service/internal/specification/TellerTransactionReportSpecification.java
b/service/src/main/java/io/mifos/reporting/service/internal/specification/TellerTransactionReportSpecification.java
index e24f622..245f3ad 100644
--- a/service/src/main/java/io/mifos/reporting/service/internal/specification/TellerTransactionReportSpecification.java
+++ b/service/src/main/java/io/mifos/reporting/service/internal/specification/TellerTransactionReportSpecification.java
@@ -154,7 +154,7 @@ public class TellerTransactionReportSpecification implements ReportSpecification
     }
 
 
-    private List<Row> buildRows(ReportRequest reportRequest, List<?> tellerResultList)
{
+    private List<Row> buildRows(final ReportRequest reportRequest, final List<?>
tellerResultList) {
         final ArrayList<Row> rows = new ArrayList<>();
 
         tellerResultList.forEach(result -> {

-- 
To stop receiving notification emails like this one, please contact
myrle@apache.org.

Mime
View raw message