Example usage for org.apache.commons.lang ArrayUtils isEmpty

List of usage examples for org.apache.commons.lang ArrayUtils isEmpty

Introduction

In this page you can find the example usage for org.apache.commons.lang ArrayUtils isEmpty.

Prototype

public static boolean isEmpty(boolean[] array) 

Source Link

Document

Checks if an array of primitive booleans is empty or null.

Usage

From source file:com.etcc.csc.presentation.datatype.PaymentContext.java

public BigDecimal getLegalInvTotalTXNAdminFee() {
    BigDecimal amount = BigDecimal.ZERO;
    if (!ArrayUtils.isEmpty(legalInvs)) {
        for (int i = 0; i < legalInvs.length; i++) {
            if ("N".equals(legalInvs[i].getPaidIndicator())) {
                amount = amount.add(legalInvs[i].getAdjustedTxnFees());
            }/*from w  w  w . ja v  a  2  s . c o  m*/
        }
    }
    return amount;
}

From source file:com.etcc.csc.presentation.datatype.PaymentContext.java

public BigDecimal getLegalInvTotalFNAdminFee() {
    BigDecimal amount = BigDecimal.ZERO;
    if (!ArrayUtils.isEmpty(legalInvs)) {
        for (int i = 0; i < legalInvs.length; i++) {
            if ("N".equals(legalInvs[i].getPaidIndicator())) {
                amount = amount.add(legalInvs[i].getInvoiceAdminFee());
            }//  w  ww. j  a  v a2 s  .  co  m
        }
    }
    return amount;
}

From source file:com.etcc.csc.datatype.PaymentDetailUtil.java

public static OLC_ST_INVOICES_REC[] invoicesToOLC_ST_INVOICES_RECs(Invoice[] invoices) throws Exception {
    if (ArrayUtils.isEmpty(invoices)) {
        return null;
    }//from   www. jav  a2 s .  c  om
    OLC_ST_INVOICES_REC[] P_OLC_ST_INVOICES_RECs = new OLC_ST_INVOICES_REC[invoices.length];
    for (int i = 0; i < invoices.length; i++) {

        OLC_ST_INVOICES_REC rec = new OLC_ST_INVOICES_REC();
        rec.setINVOICE_ID(new BigDecimal(invoices[i].getId()));
        rec.setVIOL_INVOICE_ID(new BigDecimal(invoices[i].getViolInvoiceId()));
        rec.setINVOICE_TYPE(invoices[i].getInvType());

        rec.setNTTA_TOLL_IND(invoices[i].getIsNTTAToll());
        rec.setHIGHWAY_TOLL_IND(invoices[i].getIsHighwayToll());
        rec.setINVOICE_AMOUNT(invoices[i].getAmount());
        rec.setTOLL_AMOUNT(invoices[i].getAdjustedTollAmount());
        rec.setTOTAL_TXN_FEES(invoices[i].getFeeAmount());

        rec.setINV_ADMIN_FEE(invoices[i].getInvoiceAdminFee());
        rec.setINV_SECOND_NOTICE_ADMIN_FEE(invoices[i].getInvSecondNoticeAdminFee());
        rec.setVIOL_INV_STATUS_DESC(invoices[i].getInvStatus());

        OLC_ST_VIOLATION_ARR P_OLC_ST_VIOLATION_ARR = new OLC_ST_VIOLATION_ARR();
        P_OLC_ST_VIOLATION_ARR.setArray(convertToStatementViolations(invoices[i].getViolations()));
        rec.setVIOLATIONS(P_OLC_ST_VIOLATION_ARR);

        rec.setVIOLATIONS_COUNT(new BigDecimal(invoices[i].getNoViolations()));
        rec.setVBI_INVOICE_STATUS_DESC(invoices[i].getVbInvStatus());

        rec.setTOTAL_TXN_FEES(invoices[i].getTotalTXNFees());
        rec.setCURR_DUE_DATE(new Timestamp(invoices[i].getDueDate().getTimeInMillis()));
        rec.setINVOICE_DATE(new Timestamp(invoices[i].getInvoiceDate().getTimeInMillis()));

        P_OLC_ST_INVOICES_RECs[i] = rec;
    }
    return P_OLC_ST_INVOICES_RECs;
}

From source file:com.etcc.csc.presentation.datatype.PaymentContext.java

public BigDecimal getLegalInvTotalSNAdminFee() {
    BigDecimal amount = BigDecimal.ZERO;
    if (!ArrayUtils.isEmpty(legalInvs)) {
        for (int i = 0; i < legalInvs.length; i++) {
            if ("N".equals(legalInvs[i].getPaidIndicator())) {
                amount = amount.add(legalInvs[i].getInvSecondNoticeAdminFee());
            }/*from ww  w  .j a v a 2 s.c om*/
        }
    }
    return amount;
}

From source file:com.photon.phresco.framework.rest.api.QualityService.java

/**
 * Test suites.//from  w w  w  .java2s . c  om
 *
 * @param appDirName the app dir name
 * @param moduleName the module name
 * @param testType the test type
 * @param module the module
 * @param techReport the tech report
 * @param testSuitePath the test suite path
 * @param testCasePath the test case path
 * @param testSuite the test suite
 * @return the list
 * @throws PhrescoException the phresco exception
 */
private List<TestSuite> testSuites(String appDirName, String moduleName, String testType, String techReport,
        String testSuitePath, String testCasePath, String testSuite, String rootModulePath, String subModule,
        String deviceid) throws PhrescoException {
    setTestSuite(testSuite);
    List<TestSuite> allSuites = new ArrayList<TestSuite>();
    try {
        String mapKey = constructMapKey(appDirName, moduleName);
        String testSuitesMapKey = mapKey + testType + moduleName + techReport;
        String testResultPath = getTestResultPath(appDirName, rootModulePath, subModule, testType, techReport);
        File[] testResultFiles = getTestResultFiles(testResultPath, "");

        if (ArrayUtils.isEmpty(testResultFiles)) {
            return null;
        }
        getTestSuiteNames(appDirName, testType, moduleName, techReport, testResultPath, testSuitePath,
                rootModulePath, subModule, deviceid);
        Map<String, List<NodeList>> testResultNameMap = testSuiteMap.get(testSuitesMapKey);
        if (MapUtils.isEmpty(testResultNameMap)) {
            return null;
        }

        List<NodeList> allTestNodes = new ArrayList<NodeList>();
        Set<String> keys = testResultNameMap.keySet();
        for (String key : keys) {
            List<NodeList> nodes = testResultNameMap.get(key);
            for (NodeList node : nodes) {
                allTestNodes.add(node);
            }
        }
        int indexOf = 0;
        for (NodeList allTestResultNodeList : allTestNodes) {
            if (allTestResultNodeList.getLength() > 0) {
                List<TestSuite> allTestSuites = getTestSuite(allTestResultNodeList);

                if (CollectionUtils.isNotEmpty(allTestSuites)) {
                    for (TestSuite tstSuite : allTestSuites) {
                        // testsuite values are set before calling
                        // getTestCases value
                        setTestSuite(tstSuite.getName());
                        float tests = 0;
                        float failures = 0;
                        float errors = 0;
                        float success = 0;

                        boolean entryAvailable = false;
                        TestSuite suite = new TestSuite();

                        //To check for previous existance
                        if (CollectionUtils.isNotEmpty(allSuites)) {
                            int i = 0;
                            for (TestSuite allSuite : allSuites) {
                                if (allSuite.getName().equals(tstSuite.getName())) {
                                    suite = allSuite;
                                    entryAvailable = true;
                                    indexOf = i;
                                    break;
                                }
                                i++;
                            }
                        }

                        if (entryAvailable) {
                            tests = Math.round(suite.getTotal()) + Math.round(tstSuite.getTests());
                            failures = Math.round(suite.getFailures()) + Math.round(tstSuite.getFailures());
                            errors = Math.round(suite.getErrors()) + Math.round(tstSuite.getErrors());
                        } else {
                            setNodeLength(Math.round(tstSuite.getTests()));
                            setSetFailureTestCases(Math.round(tstSuite.getFailures()));
                            setErrorTestCases(Math.round(tstSuite.getErrors()));

                            tests = Float.parseFloat(String.valueOf(getNodeLength()));
                            failures = Float.parseFloat(String.valueOf(getSetFailureTestCases()));
                            errors = Float.parseFloat(String.valueOf(getErrorTestCases()));
                        }

                        if (failures != 0 && errors == 0) {
                            if (failures > tests) {
                                success = failures - tests;
                            } else {
                                success = tests - failures;
                            }
                        } else if (failures == 0 && errors != 0) {
                            if (errors > tests) {
                                success = errors - tests;
                            } else {
                                success = tests - errors;
                            }
                        } else if (failures != 0 && errors != 0) {
                            float failTotal = (failures + errors);
                            if (failTotal > tests) {
                                success = failTotal - tests;
                            } else {
                                success = tests - failTotal;
                            }
                        } else {
                            success = tests;
                        }
                        suite.setName(tstSuite.getName());
                        suite.setSuccess(success);
                        suite.setErrors(errors);
                        suite.setFailures(failures);
                        suite.setTime(tstSuite.getTime());
                        suite.setTotal(tests);
                        suite.setTestCases(tstSuite.getTestCases());

                        if (entryAvailable) {
                            allSuites.remove(indexOf);
                            allSuites.add(indexOf, suite);
                        } else {
                            allSuites.add(suite);
                        }
                    }
                }
            }
        }
    } catch (PhrescoException e) {
        throw new PhrescoException(e);
    }
    return allSuites;
}

From source file:com.photon.phresco.framework.impl.ProjectAdministratorImpl.java

/**
 * This will search the given path and return list of projects
 *
 * @return List of projects which compliance with the framework
 *///from w w  w  . j a v  a2  s .  c  o  m
public List<Project> discover(List<File> paths) throws PhrescoException {

    S_LOGGER.debug("Entering Method ProjectAdministratorImpl.discover(List<File> paths)");

    //Use the FileNameFilter for filtering .phresco directories
    //Read the .project file and construct the Project object.

    S_LOGGER.debug("discover( )  paths = " + paths);

    if (CollectionUtils.isEmpty(paths)) {
        throw new PhrescoException(MSG_FILE_PATH_EMPTY);
    }

    List<Project> projects = new ArrayList<Project>();

    for (File path : paths) {
        File[] childFiles = path.listFiles();
        for (File childFile : childFiles) {
            File[] dotPhrescoFolders = childFile.listFiles(new PhrescoFileNameFilter(FOLDER_DOT_PHRESCO));
            if (ArrayUtils.isEmpty(dotPhrescoFolders)) {
                continue;
            }

            for (File dotPhrescoFolder : dotPhrescoFolders) {
                File[] dotProjectFiles = dotPhrescoFolder
                        .listFiles(new PhrescoFileNameFilter(PROJECT_INFO_FILE));
                fillProjects(dotProjectFiles, projects);
            }
        }
    }

    Collections.sort(projects, new ProjectComparator());
    return projects;
}

From source file:com.nec.harvest.service.impl.ActualViewServiceImpl.java

/** {@inheritDoc} */
@Override//  w ww. j a  v a2s.c  o m
public boolean checkAvailableByOrgCodesAndMonthlies(List<String> orgCode, String... monthlies)
        throws ServiceException {
    if (CollectionUtils.isEmpty(orgCode)) {
        throw new IllegalArgumentException("Can not check month available with organization code empty");
    }
    if (ArrayUtils.isEmpty(monthlies)) {
        throw new IllegalArgumentException("Can not check month available with monthlies empty");
    }

    final Session session = HibernateSessionManager.getSession();
    Transaction tx = null;

    boolean isAvailable = Boolean.FALSE;
    try {
        tx = session.beginTransaction();
        Query query = repository.getSQLQuery(session,
                "SELECT count(StrCode) FROM v_jiseki WHERE StrCode in (:orgCode) AND GetSudo in (:monthlies)");
        query.setParameterList("orgCode", orgCode);
        query.setParameterList("monthlies", monthlies);
        Object count = query.uniqueResult();
        if (count != null) {
            isAvailable = Long.parseLong(count.toString()) > 0;
        }
        tx.commit();
    } catch (SQLGrammarException | GenericJDBCException ex) {
        if (tx != null) {
            tx.rollback();
        }
        throw new ServiceException("An exception occured while checking data for the organization " + orgCode,
                ex);
    } finally {
        HibernateSessionManager.closeSession(session);
    }
    return isAvailable;
}

From source file:com.etcc.csc.dao.OraclePaymentDAO.java

public boolean veaExists(BigDecimal docId, String docType, String dbSessionId, String ipAddress, String loginId,
        String licPlate, String licState) throws Exception {

    try {/* w ww . java 2s . c  om*/

        setConnection(Util.getDbConnection());
        BigDecimal[] O_VEA_EXIST = new BigDecimal[] { new BigDecimal(0) };
        OLC_ERROR_MSG_ARR[] O_ERROR_MSG_ARR = new OLC_ERROR_MSG_ARR[] { new OLC_ERROR_MSG_ARR() };
        OLCSC_ACCT_MGMT pkg = new OLCSC_ACCT_MGMT(conn);

        int result = pkg.VEA_EXIST_INFO(docId.toPlainString(), docType, dbSessionId, ipAddress, loginId,
                licPlate, licState, O_VEA_EXIST, O_ERROR_MSG_ARR).intValue();

        if (result == 1) {
            if (!ArrayUtils.isEmpty(O_VEA_EXIST)) {
                return O_VEA_EXIST[0].intValue() == 1;
            }
        }
        throw new EtccException("PaymentWS::veaExists fatal error");
    } finally {
        closeConnection();
    }
}

From source file:com.etcc.csc.datatype.PaymentDetailUtil.java

public static OLC_ST_VIOLATION_REC[] convertToStatementViolations(Violation[] violationRecs) throws Exception {
    if (ArrayUtils.isEmpty(violationRecs)) {
        return null;
    }/*from  ww  w  .  ja  va 2  s.co m*/
    OLC_ST_VIOLATION_REC[] violations = new OLC_ST_VIOLATION_REC[violationRecs.length];

    for (int i = 0; i < violationRecs.length; i++) {
        violations[i] = convertToStatementViolation(violationRecs[i]);
    }
    return violations;
}

From source file:edu.cornell.med.icb.learning.CrossValidation.java

/**
 * Checks decisionValues and labels and determines if we
 * can short-circuit the value based on pre-defined rules.
 * Returns null if the decision cannot be short-circuited
 * or the value/*from  www. ja va2 s .c o  m*/
 *
 * @param decisionValues the decision values
 * @param labels         the label values
 * @return null or a Double value
 */
public static Double areaUnderRocCurvShortCircuit(final double[] decisionValues, final double[] labels) {
    Double shortCircuitValue = null;
    String debugStr = null;

    if (ArrayUtils.isEmpty(decisionValues) || ArrayUtils.isEmpty(labels)) {
        debugStr = "++SHORTCIRCUIT: No labels or decision values. This will fail ROC.";
    } else {
        final VectorDetails decisionValueDetails = new VectorDetails(decisionValues);
        final VectorDetails labelDetails = new VectorDetails(labels);

        if (labelDetails.isAllZeros()) {
            if (decisionValueDetails.isAllPositive()) {
                shortCircuitValue = 0.0;
                debugStr = "++SHORTCIRCUIT: Label all zeros, decision all positive. Returning 0";
            } else if (decisionValueDetails.isAllNegative()) {
                shortCircuitValue = 1.0;
                debugStr = "++SHORTCIRCUIT: Label all zeros, decision all negative. Returning 1";
            } else {
                debugStr = "++SHORTCIRCUIT: Label all zeros, decisions vary. This will fail ROC.";
            }
        } else if (labelDetails.isAllOnes()) {
            if (decisionValueDetails.isAllPositive()) {
                shortCircuitValue = 1.0;
                debugStr = "++SHORTCIRCUIT: Label all ones, decision all positive. Returning 1";
            } else if (decisionValueDetails.isAllNegative()) {
                shortCircuitValue = 0.0;
                debugStr = "++SHORTCIRCUIT: Label all ones, decision all negative. Returning 0";
            } else {
                debugStr = "++SHORTCIRCUIT: Label all ones, decisions vary. This will fail ROC.";
            }
        }
    }

    if (LOG.isDebugEnabled() && debugStr != null) {
        LOG.debug(debugStr);
    }
    return shortCircuitValue;
}