Example usage for com.liferay.portal.kernel.dao.orm Type LONG

List of usage examples for com.liferay.portal.kernel.dao.orm Type LONG

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.dao.orm Type LONG.

Prototype

Type LONG

To view the source code for com.liferay.portal.kernel.dao.orm Type LONG.

Click Source Link

Usage

From source file:com.amf.registration.service.persistence.AMFUserFinderImpl.java

License:Open Source License

public int countByZip(String zip) throws SystemException {
    Session session = null;/*  w ww  .  j av  a  2s  .c o  m*/

    try {
        session = openSession();

        String sql = CustomSQLUtil.get(COUNT_BY_ZIP);

        SQLQuery q = session.createSQLQuery(sql);

        q.addScalar(COUNT_COLUMN_NAME, Type.LONG);

        QueryPos qPos = QueryPos.getInstance(q);

        qPos.add(zip);

        Iterator<Long> itr = q.iterate();

        if (itr.hasNext()) {
            Long count = itr.next();

            if (count != null) {
                return count.intValue();
            }
        }

        return 0;
    } catch (Exception e) {
        throw new SystemException(e);
    } finally {
        closeSession(session);
    }
}

From source file:com.amf.registration.service.persistence.AMFUserFinderImpl.java

License:Open Source License

public List<User> findByZip(String zip, int start, int end) throws SystemException {

    Session session = null;/*from  www. j a  v  a2  s . com*/

    List<User> users = new ArrayList<User>();

    try {
        session = openSession();

        String sql = CustomSQLUtil.get(FIND_BY_ZIP);

        SQLQuery q = session.createSQLQuery(sql);

        q.addScalar("userId", Type.LONG);

        QueryPos qPos = QueryPos.getInstance(q);

        qPos.add(zip);

        List<Long> userIds = (List<Long>) QueryUtil.list(q, getDialect(), start, end);

        for (long userId : userIds) {
            User user = UserLocalServiceUtil.fetchUser(userId);

            users.add(user);
        }

        return users;
    } catch (Exception e) {
        throw new SystemException(e);
    } finally {
        closeSession(session);
    }
}

From source file:com.beorn.onlinepayment.service.persistence.PaymentMethodFinderImpl.java

License:Open Source License

public int countBySellerId(long sellerId, Boolean configured) throws SystemException {
    Session session = null;//from   w  w w.j  a  va  2 s  .com

    try {
        session = openSession();

        String sql = CustomSQLUtil.get(COUNT_BY_SELLERID);

        if (configured == null) {
            sql = StringUtil.replace(sql, "(Payment_PaymentPluginConfig.configured = ?) AND", "");
        }

        SQLQuery q = session.createSQLQuery(sql);

        q.addScalar(COUNT_COLUMN_NAME, Type.LONG);

        QueryPos qPos = QueryPos.getInstance(q);

        qPos.add(sellerId);
        if (configured != null)
            qPos.add(configured);

        Iterator<Long> itr = q.list().iterator();

        if (itr.hasNext()) {
            Long count = itr.next();

            if (count != null) {
                return count.intValue();
            }
        }

        return 0;

    } catch (Exception e) {
        throw new SystemException(e);

    } finally {
        closeSession(session);
    }
}

From source file:com.beorn.onlinepayment.service.persistence.PaymentMethodFinderImpl.java

License:Open Source License

private SQLQuery buildSearchQuery(Session session, long companyId, String keywords, OrderByComparator obc,
        boolean count, boolean withPermissionCheck) throws PortalException, SystemException {

    String sql = "SELECT " + (count ? "count(*) as COUNT_VALUE" : " {Payment_PaymentMethod.*}")
            + " FROM Payment_PaymentMethod";

    sql += " WHERE (Payment_PaymentMethod.companyId = ?)";

    if (Validator.isNotNull(keywords)) {
        sql += " AND (Payment_PaymentMethod.name LIKE ?)";
    }//  w ww.  j  a va  2s  .co  m

    if (!count)
        sql += " ORDER BY Payment_PaymentMethod.name ASC";

    sql = PortalUtil.transformCustomSQL(sql);
    sql = CustomSQLUtil.replaceIsNull(sql);
    if (!count)
        sql = CustomSQLUtil.replaceOrderBy(sql, obc);

    if (withPermissionCheck) {
        Group guestGroup = GroupLocalServiceUtil.getGroup(companyId, GroupConstants.GUEST);

        sql = InlineSQLHelperUtil.replacePermissionCheck(sql, PaymentMethod.class.getName(),
                "Payment_PaymentMethod.paymentMethodId", guestGroup.getGroupId());
    }

    SQLQuery q = session.createSQLQuery(sql);

    if (!count)
        q.addEntity("Payment_PaymentMethod", PaymentMethodImpl.class);
    else
        q.addScalar(COUNT_COLUMN_NAME, Type.LONG);

    QueryPos qPos = QueryPos.getInstance(q);

    qPos.add(companyId);

    if (Validator.isNotNull(keywords)) {
        qPos.add("%" + keywords + "%");
    }

    return q;
}

From source file:com.beorn.onlinepayment.service.persistence.PaymentPluginFinderImpl.java

License:Open Source License

public int countBySellerId(long sellerId, Boolean configured) throws SystemException {
    Session session = null;/*from  w  w w .  j a  v a  2s . c o m*/

    try {
        session = openSession();

        String sql = CustomSQLUtil.get(COUNT_BY_SELLERID);

        if (configured == null) {
            sql = StringUtil.replace(sql, "(Payment_PaymentPlugin.configured = ?) AND", "");
            sql = StringUtil.replace(sql, "(Payment_PaymentPluginConfig.configured = ?) AND", "");
        }

        SQLQuery q = session.createSQLQuery(sql);

        q.addScalar(COUNT_COLUMN_NAME, Type.LONG);

        QueryPos qPos = QueryPos.getInstance(q);

        qPos.add(sellerId);
        if (configured != null) {
            qPos.add(configured);
            qPos.add(configured);
        }

        Iterator<Long> itr = q.list().iterator();

        if (itr.hasNext()) {
            Long count = itr.next();

            if (count != null) {
                return count.intValue();
            }
        }

        return 0;

    } catch (Exception e) {
        throw new SystemException(e);

    } finally {
        closeSession(session);
    }
}

From source file:com.beorn.onlinepayment.service.persistence.PaymentPluginFinderImpl.java

License:Open Source License

public int countByTransactionAndPaymentMethod(long transactionId, long paymentMethodId, Boolean configured)
        throws SystemException {
    Session session = null;/*from  ww  w .  j av  a2s .  c o  m*/

    try {
        session = openSession();

        String sql = CustomSQLUtil.get(COUNT_BY_TRANSACTIONID_AND_PAYMENTMETHODID);

        if (configured == null) {
            sql = StringUtil.replace(sql, "(Payment_PaymentPlugin.configured = ?) AND", "");
            sql = StringUtil.replace(sql, "(Payment_PaymentPluginConfig.configured = ?) AND", "");
        }

        SQLQuery q = session.createSQLQuery(sql);

        q.addScalar(COUNT_COLUMN_NAME, Type.LONG);

        QueryPos qPos = QueryPos.getInstance(q);

        qPos.add(transactionId);
        qPos.add(paymentMethodId);
        if (configured != null) {
            qPos.add(configured);
            qPos.add(configured);
        }

        Iterator<Long> itr = q.list().iterator();

        if (itr.hasNext()) {
            Long count = itr.next();

            if (count != null) {
                return count.intValue();
            }
        }

        return 0;

    } catch (Exception e) {
        throw new SystemException(e);

    } finally {
        closeSession(session);
    }
}

From source file:com.beorn.onlinepayment.service.persistence.PaymentPluginFinderImpl.java

License:Open Source License

private SQLQuery buildSearchQuery(Session session, long companyId, String keywords, Boolean configured,
        Long paymentMethodId, OrderByComparator obc, boolean count, boolean withPermissionCheck)
        throws PortalException, SystemException {

    String sql = "SELECT " + (count ? "count(*) as COUNT_VALUE" : " {Payment_PaymentPlugin.*}")
            + " FROM Payment_PaymentPlugin";

    if (Validator.isNotNull(paymentMethodId))
        sql += " INNER JOIN Payment_PaymentPlugin_PaymentMethod ON (Payment_PaymentPlugin.paymentPluginId = Payment_PaymentPlugin_PaymentMethod.paymentPluginId)";

    sql += " WHERE (Payment_PaymentPlugin.companyId = ?)";

    if (Validator.isNotNull(keywords)) {
        sql += " AND (Payment_PaymentPlugin.name LIKE ?)";
    }// w  w w .ja v  a 2 s. com
    if (Validator.isNotNull(configured)) {
        sql += " AND (Payment_PaymentPlugin.configured = ?)";
    }
    if (Validator.isNotNull(paymentMethodId)) {
        sql += " AND (Payment_PaymentPlugin_PaymentMethod.paymentMethodId = ?)";
    }

    if (!count)
        sql += " ORDER BY Payment_PaymentPlugin.name ASC";

    sql = PortalUtil.transformCustomSQL(sql);
    sql = CustomSQLUtil.replaceIsNull(sql);
    if (!count)
        sql = CustomSQLUtil.replaceOrderBy(sql, obc);

    if (withPermissionCheck) {
        Group guestGroup = GroupLocalServiceUtil.getGroup(companyId, GroupConstants.GUEST);

        sql = InlineSQLHelperUtil.replacePermissionCheck(sql, PaymentPlugin.class.getName(),
                "Payment_PaymentPlugin.paymentPluginId", guestGroup.getGroupId());
    }

    SQLQuery q = session.createSQLQuery(sql);

    if (!count)
        q.addEntity("Payment_PaymentPlugin", PaymentPluginImpl.class);
    else
        q.addScalar(COUNT_COLUMN_NAME, Type.LONG);

    QueryPos qPos = QueryPos.getInstance(q);

    qPos.add(companyId);

    if (Validator.isNotNull(keywords)) {
        qPos.add("%" + keywords + "%");
    }
    if (Validator.isNotNull(configured)) {
        qPos.add(configured);
    }
    if (Validator.isNotNull(paymentMethodId)) {
        qPos.add(paymentMethodId);
    }

    return q;
}

From source file:com.beorn.onlinepayment.service.persistence.RuleFinderImpl.java

License:Open Source License

public int countBySellerId(long sellerId) throws SystemException {
    Session session = null;/*from  w w  w  .  java 2  s.c o  m*/

    try {
        session = openSession();

        String sql = CustomSQLUtil.get(COUNT_BY_SELLERID);

        SQLQuery q = session.createSQLQuery(sql);

        q.addScalar(COUNT_COLUMN_NAME, Type.LONG);

        QueryPos qPos = QueryPos.getInstance(q);

        qPos.add(sellerId);

        Iterator<Long> itr = q.list().iterator();

        if (itr.hasNext()) {
            Long count = itr.next();

            if (count != null) {
                return count.intValue();
            }
        }

        return 0;

    } catch (Exception e) {
        throw new SystemException(e);

    } finally {
        closeSession(session);
    }
}

From source file:com.beorn.onlinepayment.service.persistence.SellerFinderImpl.java

License:Open Source License

private SQLQuery buildSearchQuery(Session session, long companyId, String keywords, Boolean active,
        OrderByComparator obc, boolean count, boolean withPermissionCheck)
        throws PortalException, SystemException {

    String sql = "SELECT " + (count ? "count(*) as COUNT_VALUE" : " {Payment_Seller.*}")
            + " FROM Payment_Seller";
    sql += " WHERE (Payment_Seller.companyId = ?)";

    if (Validator.isNotNull(keywords)) {
        sql += " AND (Payment_Seller.name LIKE ?)";
    }/*from  w ww  . ja  v a  2s .  c om*/
    if (Validator.isNotNull(active)) {
        sql += " AND (Payment_Seller.active_ = ?)";
    }

    if (!count)
        sql += " ORDER BY Payment_Seller.name ASC";

    sql = PortalUtil.transformCustomSQL(sql);
    sql = CustomSQLUtil.replaceIsNull(sql);
    if (!count)
        sql = CustomSQLUtil.replaceOrderBy(sql, obc);

    if (withPermissionCheck) {
        Group guestGroup = GroupLocalServiceUtil.getGroup(companyId, GroupConstants.GUEST);

        sql = InlineSQLHelperUtil.replacePermissionCheck(sql, Seller.class.getName(), "Payment_Seller.sellerId",
                guestGroup.getGroupId());
    }

    SQLQuery q = session.createSQLQuery(sql);

    if (!count)
        q.addEntity("Payment_Seller", SellerImpl.class);
    else
        q.addScalar(COUNT_COLUMN_NAME, Type.LONG);

    QueryPos qPos = QueryPos.getInstance(q);

    qPos.add(companyId);

    if (Validator.isNotNull(keywords)) {
        qPos.add("%" + keywords + "%");
    }
    if (Validator.isNotNull(active)) {
        qPos.add(active);
    }

    return q;
}

From source file:com.beorn.onlinepayment.service.persistence.TransactionFinderImpl.java

License:Open Source License

private SQLQuery buildSearchQuery(Session session, long companyId, long groupId, Long userId, String keywords,
        Long sellerId, Long methodId, String applicationId, String paymentApplicationId, Long status,
        Double amountMin, Double amountMax, String currencyCode, Date dateMin, Date dateMax, String dateType,
        boolean isAndOperator, OrderByComparator obc, boolean count, boolean withPermissionCheck)
        throws PortalException, SystemException {

    String sql = "SELECT " + (count ? "count(*) as COUNT_VALUE" : " {Payment_Transaction.*}")
            + " FROM Payment_Transaction";

    if (Validator.isNotNull(methodId)) {
        sql += " INNER JOIN Payment_PaymentPlugin ON (Payment_Transaction.paymentApplicationId = Payment_PaymentPlugin.applicationId)";
        sql += " INNER JOIN Payment_PaymentPlugin_PaymentMethod ON (Payment_PaymentPlugin.paymentPluginId = Payment_PaymentPlugin_PaymentMethod.paymentPluginId)";
    }//from  w  ww.  j  a va2s.  c o m
    if (Validator.isNotNull(keywords)) {
        sql += " LEFT JOIN Payment_TransactionLog ON (Payment_Transaction.transactionId = Payment_TransactionLog.transactionId)";
    }

    sql += " WHERE (Payment_Transaction.companyId = ?)";
    if (groupId > 0) {
        sql += " AND (Payment_Transaction.groupId = ?)";
    }
    if (Validator.isNotNull(userId)) {
        sql += " AND (Payment_Transaction.userId = ?)";
    }
    if (Validator.isNotNull(keywords)) {
        sql += " AND ((Payment_Transaction.transactionId = ?) OR (Payment_TransactionLog.remoteId LIKE ?))";
    }
    if (Validator.isNotNull(sellerId)) {
        sql += " AND (Payment_Transaction.sellerId = ?)";
    }
    if (Validator.isNotNull(methodId)) {
        sql += " AND (Payment_PaymentPlugin_PaymentMethod.paymentMethodId = ?)";
    }
    if (Validator.isNotNull(applicationId)) {
        sql += " AND (Payment_Transaction.applicationId = ?)";
    }
    if (Validator.isNotNull(paymentApplicationId)) {
        sql += " AND (Payment_Transaction.paymentApplicationId = ?)";
    }
    if (Validator.isNotNull(status)) {
        sql += " AND (Payment_Transaction.status = ?)";
    }
    if (Validator.isNotNull(amountMin)) {
        sql += " AND (Payment_Transaction.amount >= ?)";
    }
    if (Validator.isNotNull(amountMax)) {
        sql += " AND (Payment_Transaction.amount <= ?)";
    }
    if (Validator.isNotNull(currencyCode)) {
        sql += " AND (Payment_Transaction.currencyCode = ?)";
    }
    if (isValidDateType(dateType)) {
        if (Validator.isNotNull(dateMin)) {
            sql += " AND (Payment_Transaction." + dateType + "Date >= ?)";
        }
        if (Validator.isNotNull(dateMax)) {
            sql += " AND (Payment_Transaction." + dateType + "Date <= ?)";
        }
    }

    if (!count)
        sql += " ORDER BY Payment_Transaction.modifiedDate DESC";

    sql = PortalUtil.transformCustomSQL(sql);
    sql = CustomSQLUtil.replaceIsNull(sql);
    if (!count)
        sql = CustomSQLUtil.replaceOrderBy(sql, obc);

    if (withPermissionCheck) {
        Group guestGroup = GroupLocalServiceUtil.getGroup(companyId, GroupConstants.GUEST);

        sql = InlineSQLHelperUtil.replacePermissionCheck(sql, Transaction.class.getName(),
                "Payment_Transaction.transactionId", guestGroup.getGroupId());
    }

    SQLQuery q = session.createSQLQuery(sql);

    if (!count)
        q.addEntity("Payment_Transaction", TransactionImpl.class);
    else
        q.addScalar(COUNT_COLUMN_NAME, Type.LONG);

    QueryPos qPos = QueryPos.getInstance(q);

    qPos.add(companyId);

    if (groupId > 0) {
        qPos.add(groupId);
    }
    if (Validator.isNotNull(userId)) {
        qPos.add(userId);
    }
    if (Validator.isNotNull(keywords)) {
        qPos.add(keywords);
        qPos.add("%" + keywords + "%");
    }
    if (Validator.isNotNull(sellerId)) {
        qPos.add(sellerId);
    }
    if (Validator.isNotNull(methodId)) {
        qPos.add(methodId);
    }
    if (Validator.isNotNull(applicationId)) {
        qPos.add(applicationId);
    }
    if (Validator.isNotNull(paymentApplicationId)) {
        qPos.add(paymentApplicationId);
    }
    if (Validator.isNotNull(status)) {
        qPos.add(status);
    }
    if (Validator.isNotNull(amountMin)) {
        qPos.add(amountMin);
    }
    if (Validator.isNotNull(amountMax)) {
        qPos.add(amountMax);
    }
    if (Validator.isNotNull(currencyCode)) {
        qPos.add(currencyCode);
    }
    if (isValidDateType(dateType)) {
        if (Validator.isNotNull(dateMin)) {
            qPos.add(CalendarUtil.getTimestamp(dateMin));
        }
        if (Validator.isNotNull(dateMax)) {
            qPos.add(CalendarUtil.getTimestamp(dateMax));
        }
    }

    return q;
}