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.nec.harvest.service.impl.BudgetPerformanceServiceImpl.java

/** {@inheritDoc} */
@Override/* ww  w  . jav a  2s .c o m*/
public boolean checkAvailableByOrgCodesAndMonthlyAndKmkCodeJs(List<String> orgCodes, String monthly,
        String... kmkCodeJs) throws ServiceException {
    if (CollectionUtils.isEmpty(orgCodes)) {
        throw new IllegalArgumentException(
                "Organization codes or current month in acton must not be null or empty");
    }
    if (StringUtils.isEmpty(monthly)) {
        throw new IllegalArgumentException("A month must not be null or empty");
    }
    if (ArrayUtils.isEmpty(kmkCodeJs)) {
        throw new IllegalArgumentException("KmkCodeJs must not be null");
    }

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

    boolean isAvailable = Boolean.FALSE;
    try {
        tx = session.beginTransaction();
        StringBuilder sql = new StringBuilder("SELECT count(strcode) ");
        sql.append(" FROM " + TblConstants.TBL_BUDGET_PERFORMANCE);
        sql.append(" WHERE strcode IN (:orgCodes) ");
        sql.append(" AND GetSudo = (:month) ");
        sql.append(" AND KmkCodeJ IN (:kmkCodeJs) ");
        sql.append(" AND DelKbn = 2 ");

        Query query = repository.getSQLQuery(session, sql.toString());
        query.setParameterList("orgCodes", orgCodes);
        query.setParameter("month", monthly);
        query.setParameterList("kmkCodeJs", kmkCodeJs);
        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 budgetperformance", ex);
    } finally {
        HibernateSessionManager.closeSession(session);
    }
    return isAvailable;
}

From source file:net.lmxm.ute.configuration.ConfigurationReader.java

/**
 * Parses the Maven artifacts.//from  w  w  w.  j a  v  a2  s. c om
 *
 * @param task the task
 * @param taskType the task type
 */
private void parseMavenArtifacts(final MavenRepositoryDownloadTask task,
        final MavenRepositoryDownloadTaskType taskType) {
    final String prefix = "parseMavenArtifacts() :";

    LOGGER.debug("{} entered", prefix);

    if (taskType == null) {
        LOGGER.debug("{} filesType is null, exiting", prefix);

        return;
    }

    final List<MavenArtifact> artifacts = task.getArtifacts();
    final MavenArtifactType[] mavenArtifactTypes = taskType.getArtifacts().getArtifactArray();

    if (ArrayUtils.isEmpty(mavenArtifactTypes)) {
        LOGGER.debug("{} fileArray is empty is null, exiting", prefix);

        return;
    }

    LOGGER.debug("{} parsing {} Maven artifact types", prefix, mavenArtifactTypes.length);

    for (final MavenArtifactType artifactType : mavenArtifactTypes) {
        final MavenArtifact artifact = parseMavenArtifact(artifactType);

        if (artifact != null) {
            artifacts.add(artifact);
        }
    }

    LOGGER.debug("{} exiting", prefix);
}

From source file:com.lyh.licenseworkflow.dao.EnhancedHibernateDaoSupport.java

/**
 * ??? from DeviceResource where type = 'ROUTER' and temp = false;
 *
 * @param propertyNames ???/*w w  w  .j a  v  a 2  s .  c  om*/
 * @param values        
 * @return ??
 */
@SuppressWarnings("unchecked")
public int countEntitiesByPropNames(final String[] propertyNames, final Object[] values) {
    if (ArrayUtils.isEmpty(propertyNames) || ArrayUtils.isEmpty(values)
            || propertyNames.length != values.length) {
        throw new IllegalArgumentException("arguments is invalid.");
    }
    return (Integer) getHibernateTemplate().execute(new HibernateCallback() {

        public Object doInHibernate(Session session) throws HibernateException, SQLException {
            Criteria c = session.createCriteria(getEntityName());
            for (int i = 0; i < propertyNames.length; i++) {
                String propertyName = propertyNames[i];
                if (propertyName.indexOf(".") != -1) {
                    Criteria subC = null;
                    String[] props = StringUtils.split(propertyName, ".");
                    for (int j = 0; j < props.length; j++) {
                        if (j != props.length - 1) {
                            subC = c.createCriteria(props[j]);
                        }
                    }
                    if (values[i] == null)
                        subC.add(Restrictions.isNull(propertyName.substring(propertyName.indexOf(".") + 1)));
                    else
                        subC.add(Restrictions.eq(propertyName.substring(propertyName.indexOf(".") + 1),
                                values[i]));
                } else {
                    if (values[i] == null)
                        c.add(Restrictions.isNull(propertyNames[i]));
                    else
                        c.add(Restrictions.eq(propertyNames[i], values[i]));
                }
            }
            int num = ((Integer) c.setProjection(Projections.rowCount()).uniqueResult()).intValue();// ???
            return new Integer(num);
        }
    });
}

From source file:at.ac.tuwien.infosys.jcloudscale.utility.ReflectionUtil.java

public static Class<?>[] getClassesFromObjects(Object... args) {
    if (ArrayUtils.isEmpty(args)) {
        return ArrayUtils.EMPTY_CLASS_ARRAY;
    }// www.ja v a  2s.c o m
    // At least one parameter was null
    Class<?>[] paramTypes = new Class<?>[args.length];
    for (int i = 0; i < args.length; i++) {
        paramTypes[i] = args[i] != null ? args[i].getClass() : null;
    }
    return paramTypes;
}

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

public PaymentResponse combinedPayment(long docId, String docType, String dbSessionId, String ipAddress,
        String loginId, BigDecimal transactionId, BigDecimal tagAmount, BigDecimal totalAmount, String dlState,
        String dlNumber, String email, boolean updatePmtInfo, String cardCode, String paymentType,
        String cardNumber, String expireMonth, String expireYear, String nameOnCard, String address,
        String address2, String city, String state, String zipCode, String plus4, String cardSecurityCode,
        Invoice[] invoices, Violation[] violations, boolean veaAccepted)
        throws EtccErrorMessageException, Exception {
    PaymentResponse paymentResponse = null;
    try {/*from w w w  .j a  va  2 s .c  o m*/

        setConnection(Util.getDbConnection());
        BigDecimal acctId = null;
        if ("AC".equals(docType)) {
            acctId = new BigDecimal(docId);
        }

        OLC_PAYMENT_INFO_REC olcPaymentInfoRec = new OLC_PAYMENT_INFO_REC();
        olcPaymentInfoRec.setPMT_TYPE(paymentType);
        olcPaymentInfoRec.setCARD_CODE(cardCode);
        olcPaymentInfoRec.setCARD_SEC_CODE(cardSecurityCode);
        olcPaymentInfoRec.setCARD_NBR(cardNumber);
        olcPaymentInfoRec.setCARD_EXPIRES(DateUtil.monthYearToTimestamp(expireMonth + "/" + expireYear));
        olcPaymentInfoRec.setNAME_ON_CARD(nameOnCard);
        olcPaymentInfoRec.setADDRESS1(address);
        olcPaymentInfoRec.setADDRESS2(address2);
        olcPaymentInfoRec.setCITY(city);
        olcPaymentInfoRec.setSTATE(state);
        olcPaymentInfoRec.setZIP_CODE(zipCode);
        olcPaymentInfoRec.setPLUS4(plus4);

        OLC_VPS_INV_PMT_ARR P_INV_PMT_ARR = new OLC_VPS_INV_PMT_ARR();
        OLC_VPS_INV_FEE_PMT_ARR P_INV_FEE_PMT_ARR = new OLC_VPS_INV_FEE_PMT_ARR();
        OLC_VPS_UNINV_PMT_ARR P_UNINV_VIOL_PMT_ARR = new OLC_VPS_UNINV_PMT_ARR();
        OLC_VPS_UNINV_FEE_PMT_ARR P_UNINV_FEE_PMT_ARR = new OLC_VPS_UNINV_FEE_PMT_ARR();

        P_INV_PMT_ARR.setArray(PaymentDetailUtil.invoicesToOLC_VPS_INV_PMT_RECs(invoices, veaAccepted));
        P_INV_FEE_PMT_ARR.setArray(PaymentDetailUtil.invoicesToOLC_VPS_INV_FEE_PMT_RECs(invoices, veaAccepted));
        P_UNINV_VIOL_PMT_ARR.setArray(PaymentDetailUtil.violationsToOLC_VPS_UNINV_PMT_RECs(violations));
        P_UNINV_FEE_PMT_ARR.setArray(PaymentDetailUtil.violationsToOLC_VPS_UNINV_FEE_PMT_RECs(violations));

        String[] P_POSTING_STATUS = new String[] { "" };
        BigDecimal[] P_PAYMENT_ID = new BigDecimal[] { new BigDecimal(0) };
        OLC_ERROR_MSG_ARR[] O_ERROR_MSG_ARR = new OLC_ERROR_MSG_ARR[] { new OLC_ERROR_MSG_ARR() };

        logger.debug("OraclePaymentDAO.java::::combinedPayment::: docType:" + docType + ":dbSessionId:"
                + dbSessionId + ":ipAddress:" + ipAddress + ":loginId:" + loginId + ":transactionId:"
                + transactionId + ":acctId:" + acctId + ":tagAmount:" + tagAmount + ":totalAmount:"
                + totalAmount + ":olcPaymentInfoRec.getNAME_ON_CARD():" + olcPaymentInfoRec.getNAME_ON_CARD()
                + ":olcPaymentInfoRec.getADDRESS1():" + olcPaymentInfoRec.getADDRESS1()
                + ":olcPaymentInfoRec.getADDRESS2():" + olcPaymentInfoRec.getADDRESS2()
                + ":olcPaymentInfoRec.getCITY():" + olcPaymentInfoRec.getCITY()
                + ":olcPaymentInfoRec.getSTATE():" + olcPaymentInfoRec.getSTATE()
                + ":olcPaymentInfoRec.getZIP_CODE():" + olcPaymentInfoRec.getZIP_CODE() + ":dlState:" + dlState
                + ":dlNumber:" + dlNumber + ":email:" + email + ":updatePmtInfo:" + updatePmtInfo + ":docId:"
                + docId);

        int result = new OLCSC_PAYMENT(conn)
                .MAKE_PAYMENT(new BigDecimal(docId), docType, dbSessionId, ipAddress, loginId, transactionId,
                        acctId, tagAmount, totalAmount, P_INV_PMT_ARR, P_INV_FEE_PMT_ARR, P_UNINV_VIOL_PMT_ARR,
                        P_UNINV_FEE_PMT_ARR, olcPaymentInfoRec, dlState, dlNumber, email, true,
                        updatePmtInfo ? "Y" : "N", P_POSTING_STATUS, P_PAYMENT_ID, O_ERROR_MSG_ARR)
                .intValue();

        if (result == 1) {
            if (!ArrayUtils.isEmpty(P_POSTING_STATUS) && !ArrayUtils.isEmpty(P_PAYMENT_ID)) {
                paymentResponse = new PaymentResponse();
                paymentResponse.setPostingStatus(P_POSTING_STATUS[0].trim());
                paymentResponse.setPaymentId(P_PAYMENT_ID[0]);
            }
        } else {
            if (O_ERROR_MSG_ARR[0] != null && O_ERROR_MSG_ARR[0].getArray() != null
                    && O_ERROR_MSG_ARR[0].getArray().length > 0) {
                OLC_ERROR_MSG_REC[] errorMsgRecs = O_ERROR_MSG_ARR[0].getArray();
                EtccErrorMessageException em = new EtccErrorMessageException(
                        "PaymentWS::combinedPayment error message");
                for (int i = 0; i < errorMsgRecs.length; i++) {
                    em.addRecoverable(errorMsgRecs[i].getERROR_MSG());
                }

                // Procedure to capture more logs
                logger.debug(
                        "Exception Occured in OraclePaymentDAO.java::combinedPayment.  More information : ");
                int tmpindex = 0;
                String tmperror = "";
                while (O_ERROR_MSG_ARR.length > tmpindex) {
                    if (O_ERROR_MSG_ARR[tmpindex].getArray() == null)
                        break;

                    OLC_ERROR_MSG_REC[] moreErrorMsgRecs = O_ERROR_MSG_ARR[tmpindex].getArray();
                    for (int i = 0; (i < moreErrorMsgRecs.length) && (i < 10); i++) {
                        tmperror = tmperror + "\n" + (moreErrorMsgRecs[i].getERROR_MSG());
                    }
                    tmpindex++;
                    if (tmpindex > 10)
                        break;
                }
                logger.debug(tmperror);

                throw em;
            } else {
                logger.debug("PaymentWS::combinedPayment fatal error");

                throw new EtccException("PaymentWS::combinedPayment fatal error");
            }
        }
    } finally {
        closeConnection();
    }
    return paymentResponse;
}

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

public List<Invoice> getAuthorizedSecondInvs() {
    List<Invoice> list = new ArrayList<Invoice>();
    if (!ArrayUtils.isEmpty(secondInvs)) {
        for (int i = 0; i < secondInvs.length; i++) {
            if (secondInvs[i].isAuthorized()) {
                list.add(secondInvs[i]);
            }//from w  w  w  .j av  a2s . co m
        }
    }
    return list;
}

From source file:gov.nih.nci.cabig.caaers.grid.CaaersStudyConsumer.java

/**
 * Populates study identifiers//from www.ja  v  a  2s  .  c  o  m
 * 
 * @param study
 * @param identifierTypes
 * @throws StudyCreationException
 */
void populateIdentifiers(gov.nih.nci.cabig.caaers.domain.Study study, IdentifierType[] identifierTypes)
        throws StudyCreationException {
    if (ArrayUtils.isEmpty(identifierTypes)) {
        logger.error("No identifiers are associated to this study");
        String message = "No identifiers are assigned to this study (grid Id : " + study.getGridId() + ")";
        throw getStudyCreationException(message);
    }

    //figure out the list of known identifiers
    List<Lov> identifierLovs = configurationProperty.getMap().get("identifiersType");
    List<String> knownIdentifierTypes = new ArrayList<String>();
    for (Lov lov : identifierLovs) {
        knownIdentifierTypes.add(lov.getCode());
    }

    List<SystemAssignedIdentifier> sysIdentifiers = new ArrayList<SystemAssignedIdentifier>();
    List<OrganizationAssignedIdentifier> orgIdentifiers = new ArrayList<OrganizationAssignedIdentifier>();

    OrganizationAssignedIdentifier ccIdentifier = null;
    OrganizationAssignedIdentifier sponsorIdentifier = null;

    for (IdentifierType identifierType : identifierTypes) {
        if (!knownIdentifierTypes.contains(identifierType.getType())) {
            logger.warn("The identifier type '" + identifierType.getType()
                    + "' is unknown to caAERS. So ignoring the identifier(" + identifierType.getValue() + ")");
            continue;
        }

        if (identifierType instanceof SystemAssignedIdentifierType) {

            SystemAssignedIdentifierType sysIdType = (SystemAssignedIdentifierType) identifierType;
            SystemAssignedIdentifier id = new SystemAssignedIdentifier();
            id.setGridId(identifierType.getGridId());
            id.setPrimaryIndicator(identifierType.getPrimaryIndicator());
            id.setType(sysIdType.getType());
            id.setValue(sysIdType.getValue());
            id.setSystemName(sysIdType.getSystemName());
            sysIdentifiers.add(id);

        } else if (identifierType instanceof OrganizationAssignedIdentifierType) {

            OrganizationAssignedIdentifierType orgIdType = (OrganizationAssignedIdentifierType) identifierType;
            OrganizationAssignedIdentifier id = new OrganizationAssignedIdentifier();
            id.setGridId(orgIdType.getGridId());
            id.setPrimaryIndicator(orgIdType.getPrimaryIndicator());
            id.setType(orgIdType.getType());
            id.setValue(orgIdType.getValue());
            id.setOrganization(fetchOrganization(orgIdType.getHealthcareSite()));

            if (StringUtils.equals(id.getType(),
                    OrganizationAssignedIdentifier.COORDINATING_CENTER_IDENTIFIER_TYPE)) {
                ccIdentifier = id;
            } else if (StringUtils.equals(id.getType(),
                    OrganizationAssignedIdentifier.SPONSOR_IDENTIFIER_TYPE)) {
                sponsorIdentifier = id;
            } else {
                orgIdentifiers.add(id);
            }
        }
    }

    //if the sponsor identifier is not supplied, use coordinating center instead. 
    if (sponsorIdentifier == null) {
        sponsorIdentifier = new OrganizationAssignedIdentifier();
        sponsorIdentifier.setType(OrganizationAssignedIdentifier.SPONSOR_IDENTIFIER_TYPE);
        sponsorIdentifier.setValue(ccIdentifier.getValue());
        sponsorIdentifier.setOrganization(study.getPrimaryFundingSponsorOrganization());
    }

    study.addIdentifier(sponsorIdentifier);
    study.addIdentifier(ccIdentifier);

    for (OrganizationAssignedIdentifier id : orgIdentifiers) {
        study.addIdentifier(id);
    }

    for (SystemAssignedIdentifier id : sysIdentifiers) {
        study.addIdentifier(id);
    }
}

From source file:cn.fastmc.core.utils.ReflectionUtils.java

/**
 * ?method?annotationClass/*w ww . j  av  a  2 s .  c om*/
 * 
 * @param methods
 *            method
 * @param annotationClass
 *            annotationClass
 * 
 * @return List
 */
public static <T extends Annotation> List<T> getAnnotations(Method[] methods, Class annotationClass) {

    if (ArrayUtils.isEmpty(methods)) {
        return null;
    }

    List<T> result = new ArrayList<T>();

    for (Method method : methods) {

        Annotation annotation = getAnnotation(method, annotationClass);
        if (annotation != null) {
            result.add((T) annotation);
        }
    }

    return result;
}

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

public boolean getOpenSecondInvExists() {
    if (!ArrayUtils.isEmpty(secondInvs)) {
        for (int i = 0; i < secondInvs.length; i++) {
            if ("N".equals(secondInvs[i].getPaidIndicator())) {
                return true;
            }/*ww w.  ja  va  2  s. co  m*/
        }
    }
    return false;
}

From source file:gnete.card.service.impl.MerchServiceImpl.java

public void addMerchGroup(MerchGroup merchGroup, String merchs, UserInfo userInfo) throws BizException {
    Assert.notNull(merchGroup, "?");

    String groupId = generateMerchGroupId();

    String[] merchArray = merchs.split(",");
    if (!ArrayUtils.isEmpty(merchArray)) {
        for (String merchId : merchArray) {
            MerchToGroup toGroup = new MerchToGroup();
            toGroup.setGroupId(groupId);
            toGroup.setMerchId(merchId);
            toGroup.setUpdateBy(userInfo.getUserId());
            toGroup.setUpdateTime(new Date());

            this.merchToGroupDAO.insert(toGroup);
        }/*from ww w  .  j av  a2 s.c  o m*/
    }

    merchGroup.setGroupId(groupId);
    merchGroup.setManageBranch(userInfo.getBranchNo());
    merchGroup.setStatus(CommonState.NORMAL.getValue());
    merchGroup.setUpdateBy(userInfo.getUserId());
    merchGroup.setInsertTime(new Date());

    this.merchGroupDAO.insert(merchGroup);
}