Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id CB2A8200CE9 for ; Sat, 19 Aug 2017 09:12:52 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id C241C16422F; Sat, 19 Aug 2017 07:12:52 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 13F34163DD4 for ; Sat, 19 Aug 2017 09:12:51 +0200 (CEST) Received: (qmail 49481 invoked by uid 500); 19 Aug 2017 07:12:51 -0000 Mailing-List: contact issues-help@fineract.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@fineract.apache.org Delivered-To: mailing list issues@fineract.apache.org Received: (qmail 49472 invoked by uid 99); 19 Aug 2017 07:12:50 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 19 Aug 2017 07:12:50 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id AFEAADFA3B; Sat, 19 Aug 2017 07:12:49 +0000 (UTC) From: wkk91193 To: issues@fineract.apache.org Reply-To: issues@fineract.apache.org References: In-Reply-To: Subject: [GitHub] fineract pull request #401: Extend-mifos-data-import-tool-office populate & ... Content-Type: text/plain Message-Id: <20170819071249.AFEAADFA3B@git1-us-west.apache.org> Date: Sat, 19 Aug 2017 07:12:49 +0000 (UTC) archived-at: Sat, 19 Aug 2017 07:12:53 -0000 Github user wkk91193 commented on a diff in the pull request: https://github.com/apache/fineract/pull/401#discussion_r134085080 --- Diff: fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/importhandler/AbstractImportHandler.java --- @@ -0,0 +1,143 @@ +/** + * 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.infrastructure.bulkimport.importhandler; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import org.apache.poi.ss.usermodel.*; +import org.joda.time.LocalDate; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Iterator; + +public abstract class AbstractImportHandler implements ImportHandler { + + protected Integer getNumberOfRows(Sheet sheet, int primaryColumn) { + Integer noOfEntries = 1; + // getLastRowNum and getPhysicalNumberOfRows showing false values + // sometimes + while (sheet.getRow(noOfEntries) !=null && sheet.getRow(noOfEntries).getCell(primaryColumn) != null) { + noOfEntries++; + } + + return noOfEntries; + } + + protected boolean isNotImported(Row row, int statusColumn) { + return !readAsString(statusColumn, row).equals("Imported"); + } + + protected Long readAsLong(int colIndex, Row row) { + try { + Cell c = row.getCell(colIndex); + if (c == null || c.getCellType() == Cell.CELL_TYPE_BLANK) + return null; + FormulaEvaluator eval = row.getSheet().getWorkbook().getCreationHelper().createFormulaEvaluator(); + if(c.getCellType() == Cell.CELL_TYPE_FORMULA) { + CellValue val = null; + try { + val = eval.evaluate(c); + } catch (NullPointerException npe) { + return null; + } + return ((Double) val.getNumberValue()).longValue(); --- End diff -- @nazeer1100126 To get the Long value according to the API type casting is necessary here! --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. ---