Example usage for com.liferay.portal.kernel.util StringPool PERCENT

List of usage examples for com.liferay.portal.kernel.util StringPool PERCENT

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util StringPool PERCENT.

Prototype

String PERCENT

To view the source code for com.liferay.portal.kernel.util StringPool PERCENT.

Click Source Link

Usage

From source file:org.oep.cmon.report.portlet.action.ReportAdminAction.java

License:Apache License

/**
 * This is function search Danhmucbaocao
 * Version: 1.0//from  www.  j  a  va2 s.  c om
 *  
 * History: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  ------------------------------------------------- 
 *  3-March-2013  Nam Dinh    Create new
 * @param request
 * @param response
 * @throws Exception
 */
@SuppressWarnings("unchecked")
public void searchDanhmucbaocao(ActionRequest request, ActionResponse response) throws Exception {
    String keyword = ParamUtil.getString(request, "keyword");
    if (keyword.trim().length() > 0) {
        DynamicQuery query = DynamicQueryFactoryUtil.forClass(DanhMucBaoCao.class);
        query.add(
                RestrictionsFactoryUtil.ilike("TENBAOCAO", StringPool.PERCENT + keyword + StringPool.PERCENT));
        List<DanhMucBaoCao> listdmbaocao = DanhMucBaoCaoLocalServiceUtil.dynamicQuery(query);
        request.setAttribute("listdmbaocao", listdmbaocao);
        response.setRenderParameter("keyword", keyword);
    }
    response.setRenderParameter("jspPage", viewjsp);
}

From source file:org.oep.cmon.report.portlet.action.ReportAdminAction.java

License:Apache License

/**
 * This is function search DanhMuc role/*  w w  w.  ja va  2 s.c o m*/
 * Version: 1.0
 *  
 * History: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  ------------------------------------------------- 
 *  3-March-2013  Nam Dinh    Create new
 * @param request
 * @param response
 * @throws Exception
 */
@SuppressWarnings("unchecked")
public void searchDanhmucrole(ActionRequest request, ActionResponse response) throws Exception {
    String keyword = ParamUtil.getString(request, "keyword");
    if (keyword.trim().length() > 0) {
        DynamicQuery query = DynamicQueryFactoryUtil.forClass(DanhMucRole.class);
        query.add(RestrictionsFactoryUtil.ilike("NAME", StringPool.PERCENT + keyword + StringPool.PERCENT));
        List<DanhMucRole> listdmrole = DanhMucRoleLocalServiceUtil.dynamicQuery(query);
        request.setAttribute("listdmrole", listdmrole);
        response.setRenderParameter("keyword", keyword);
    }
    response.setRenderParameter("tab", "vaitro");
    response.setRenderParameter("jspPage", viewjsp);
}

From source file:org.oep.cmon.report.portlet.util.ActionAdminUtil.java

License:Apache License

/**
 * This is function get all TaiKhoanNguoiDung
 * Version: 1.0//from   w  w w.  ja v a2s .c om
 *  
 * History: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  ------------------------------------------------- 
 *  3-March-2013  Nam Dinh    Create new
 * @param daxoa
 * @param tennguoidung
 * @param id_donvi
 * @param trangthai
 * @throws Exception
 * @return List<TaiKhoanNguoiDung>
 */
@SuppressWarnings("unchecked")
public static List<TaiKhoanNguoiDung> getAllTaiKhoanNguoiDung(int daxoa, String tennguoidung, long id_donvi,
        String trangthai) throws Exception {
    List<Long> listidUser = new ArrayList<Long>();
    if (Validator.isNotNull(id_donvi) && id_donvi != 0) {
        DynamicQuery query = DynamicQueryFactoryUtil.forClass(CongChuc.class);
        query.add(PropertyFactoryUtil.forName("coQuanQuanLyId").eq(id_donvi));
        query.setProjection(ProjectionFactoryUtil.property("taiKhoanNguoiDungId"));
        listidUser = CongChucLocalServiceUtil.dynamicQuery(query);
    }
    DynamicQuery query = DynamicQueryFactoryUtil.forClass(TaiKhoanNguoiDung.class);
    if (daxoa != 2) {
        query.add(PropertyFactoryUtil.forName("daXoa").eq(daxoa));
    }
    if (!tennguoidung.equals("")) {
        Criterion creterion = RestrictionsFactoryUtil.ilike("tenNguoiDung",
                StringPool.PERCENT + tennguoidung + StringPool.PERCENT);
        creterion = RestrictionsFactoryUtil.or(creterion,
                RestrictionsFactoryUtil.ilike("email", StringPool.PERCENT + tennguoidung + StringPool.PERCENT));
        query.add(creterion);
        //         query.add(PropertyFactoryUtil.forName("tenNguoiDung").like(StringPool.PERCENT + tennguoidung + StringPool.PERCENT));
    }

    if (trangthai.equals("1")) {
        DynamicQuery query2 = DynamicQueryFactoryUtil.forClass(CongChuc2Role.class);
        query2.setProjection(ProjectionFactoryUtil.property("CONGCHUCID"));
        List<Long> idu = CongChuc2RoleLocalServiceUtil.dynamicQuery(query2);
        query.add(PropertyFactoryUtil.forName("id").in(idu.toArray()));
    } else if (trangthai.equals("0")) {
        DynamicQuery query2 = DynamicQueryFactoryUtil.forClass(CongChuc2Role.class);
        query2.setProjection(ProjectionFactoryUtil.property("CONGCHUCID"));
        query.add(PropertyFactoryUtil.forName("id").notIn(query2));
    }

    if (listidUser.size() > 0) {
        query.add(PropertyFactoryUtil.forName("id").in(listidUser.toArray()));
    }
    query.addOrder(OrderFactoryUtil.asc("id"));
    return TaiKhoanNguoiDungLocalServiceUtil.dynamicQuery(query);
}

From source file:org.opencps.accountmgt.service.persistence.BusinessFinderImpl.java

License:Open Source License

/**
 * @param groupId//from  w  w w  . j av a2s.  c om
 * @param keywords
 * @param accountStatus
 * @param andOperator
 * @param businessDomain
 * @param start
 * @param end
 * @return
 */
private List<Business> _searchBusiness(long groupId, String keywords, int accountStatus, String businessDomain,
        int start, int end) throws SystemException {

    Session session = null;

    try {

        session = openSession();

        String sql = CustomSQLUtil.get(SEARCH_BUSINESS);

        if (Validator.isNull(groupId)) {
            sql = sql.replace("AND (opencps_acc_business.groupId = ?)", StringPool.BLANK);
        }
        if (accountStatus == -1) {
            sql = sql.replace("AND (opencps_acc_business.accountStatus = ?)", StringPool.BLANK);
        }
        if (Validator.isNull(keywords)) {
            sql = sql.replace("AND ((lower(opencps_acc_business.name) LIKE ?)", StringPool.BLANK);
            sql = sql.replace("OR (lower(opencps_acc_business.shortName) LIKE ?)", StringPool.BLANK);
            sql = sql.replace("OR (lower(opencps_acc_business.enName) LIKE ?)", StringPool.BLANK);
            sql = sql.replace("OR (lower(opencps_acc_business.email) LIKE ?))", StringPool.BLANK);
        }
        if (Validator.isNull(businessDomain)) {
            sql = sql.replace(
                    "INNER JOIN " + "opencps_acc_businessdomain " + "ON "
                            + "opencps_acc_business.businessId = opencps_acc_businessdomain.businessId",
                    StringPool.BLANK);

            sql = sql.replace("AND (opencps_acc_businessdomain.businessDomainCode = ?)", StringPool.BLANK);
        }

        SQLQuery q = session.createSQLQuery(sql);
        q.setCacheable(false);
        q.addEntity("Business", BusinessImpl.class);

        QueryPos qPos = QueryPos.getInstance(q);

        if (Validator.isNotNull(groupId)) {
            qPos.add(groupId);
        }
        if (accountStatus != -1) {
            qPos.add(accountStatus);
        }
        if (Validator.isNotNull(keywords)) {
            qPos.add(StringPool.PERCENT + keywords + StringPool.PERCENT);
            qPos.add(StringPool.PERCENT + keywords + StringPool.PERCENT);
            qPos.add(StringPool.PERCENT + keywords + StringPool.PERCENT);
            qPos.add(StringPool.PERCENT + keywords + StringPool.PERCENT);
        }
        if (Validator.isNotNull(businessDomain)) {
            qPos.add(businessDomain);
        }

        return (List<Business>) QueryUtil.list(q, getDialect(), start, end);
    } catch (Exception e) {
        throw new SystemException();
    } finally {
        session.close();
    }
}

From source file:org.opencps.accountmgt.service.persistence.BusinessFinderImpl.java

License:Open Source License

/**
 * @param groupId//ww  w.  j av a2 s.  co  m
 * @param keywords
 * @param accountStatus
 * @param businessDomain
 * @param andOperator
 * @return
 */
private int _countBussiness(long groupId, String keywords, int accountStatus, String businessDomain)
        throws SystemException {

    Session session = null;

    try {
        session = openSession();

        String sql = CustomSQLUtil.get(COUNT_BUSINESS);

        if (Validator.isNull(groupId)) {
            sql = sql.replace("AND (opencps_acc_business.groupId = ?)", StringPool.BLANK);
        }
        if (accountStatus == -1) {
            sql = sql.replace("AND (opencps_acc_business.accountStatus = ?)", StringPool.BLANK);
        }
        if (Validator.isNull(keywords)) {
            sql = sql.replace("AND ((lower(opencps_acc_business.name) LIKE ?)", StringPool.BLANK);
            sql = sql.replace("OR (lower(opencps_acc_business.shortName) LIKE ?)", StringPool.BLANK);
            sql = sql.replace("OR (lower(opencps_acc_business.enName) LIKE ?)", StringPool.BLANK);
            sql = sql.replace("OR (lower(opencps_acc_business.email) LIKE ?))", StringPool.BLANK);
        }
        if (Validator.isNull(businessDomain)) {
            sql = sql.replace(
                    "INNER JOIN " + "opencps_acc_businessdomain " + "ON "
                            + "opencps_acc_business.businessId = opencps_acc_businessdomain.businessId",
                    StringPool.BLANK);

            sql = sql.replace("AND (opencps_acc_businessdomain.businessDomainCode = ?)", StringPool.BLANK);
        }

        SQLQuery q = session.createSQLQuery(sql);
        q.setCacheable(false);

        q.addScalar(COUNT_COLUMN_NAME, Type.INTEGER);

        QueryPos qPos = QueryPos.getInstance(q);

        if (Validator.isNotNull(groupId)) {
            qPos.add(groupId);
        }
        if (accountStatus != -1) {
            qPos.add(accountStatus);
        }
        if (Validator.isNotNull(keywords)) {
            qPos.add(StringPool.PERCENT + keywords + StringPool.PERCENT);
            qPos.add(StringPool.PERCENT + keywords + StringPool.PERCENT);
            qPos.add(StringPool.PERCENT + keywords + StringPool.PERCENT);
            qPos.add(StringPool.PERCENT + keywords + StringPool.PERCENT);
        }
        if (Validator.isNotNull(businessDomain)) {
            qPos.add(businessDomain);
        }

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

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

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

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

From source file:org.opencps.accountmgt.service.persistence.CitizenFinderImpl.java

License:Open Source License

/**
 * @param groupId//  ww  w  .j a  v a2  s. c  o m
 * @param keywords
 * @param accountStatus
 * @param andOperator
 * @param start
 * @param end
 * @return
 */
private List<Citizen> _searchCitizen(long groupId, String keywords, int accountStatus, int start, int end)
        throws SystemException {

    Session session = null;

    try {
        session = openSession();

        String sql = CustomSQLUtil.get(SEARCH_CITIZEN);

        if (Validator.isNull(groupId)) {
            sql = sql.replace("AND (opencps_acc_citizen.groupId = ?)", StringPool.BLANK);
        }
        if (accountStatus == -1) {
            sql = sql.replace("AND (opencps_acc_citizen.accountStatus = ?)", StringPool.BLANK);
        }
        if (Validator.isNull(keywords)) {
            sql = sql.replace("AND ((lower(opencps_acc_citizen.fullName) LIKE ?)", StringPool.BLANK);
            sql = sql.replace("OR (lower(opencps_acc_citizen.email) LIKE ?))", StringPool.BLANK);
        }

        SQLQuery q = session.createSQLQuery(sql);
        q.setCacheable(false);
        q.addEntity("Citizen", CitizenImpl.class);

        QueryPos qPos = QueryPos.getInstance(q);

        if (Validator.isNotNull(groupId)) {
            qPos.add(groupId);
        }
        if (accountStatus != -1) {
            qPos.add(accountStatus);
        }
        if (Validator.isNotNull(keywords)) {
            qPos.add(StringPool.PERCENT + keywords + StringPool.PERCENT);
            qPos.add(StringPool.PERCENT + keywords + StringPool.PERCENT);
        }

        return (List<Citizen>) QueryUtil.list(q, getDialect(), start, end);
    } catch (Exception e) {
        throw new SystemException();
    } finally {
        session.close();
    }
}

From source file:org.opencps.accountmgt.service.persistence.CitizenFinderImpl.java

License:Open Source License

/**
 * @param groupId// w ww  . j ava 2s.  com
 * @param keywords
 * @param accountStatus
 * @param andOperator
 * @return
 */
private int _countCitizen(long groupId, String keywords, int accountStatus) throws SystemException {

    Session session = null;

    try {
        session = openSession();

        String sql = CustomSQLUtil.get(COUNT_CITIZEN);

        if (Validator.isNull(groupId)) {
            sql = sql.replace("AND (opencps_acc_citizen.groupId = ?)", StringPool.BLANK);
        }
        if (accountStatus == -1) {
            sql = sql.replace("AND (opencps_acc_citizen.accountStatus = ?)", StringPool.BLANK);
        }
        if (Validator.isNull(keywords)) {
            sql = sql.replace("AND ((lower(opencps_acc_citizen.fullName) LIKE ?)", StringPool.BLANK);
            sql = sql.replace("OR (lower(opencps_acc_citizen.email) LIKE ?))", StringPool.BLANK);
        }

        SQLQuery q = session.createSQLQuery(sql);
        q.setCacheable(false);

        q.addScalar(COUNT_COLUMN_NAME, Type.INTEGER);

        QueryPos qPos = QueryPos.getInstance(q);

        if (Validator.isNotNull(groupId)) {
            qPos.add(groupId);
        }
        if (accountStatus != -1) {
            qPos.add(accountStatus);
        }
        if (Validator.isNotNull(keywords)) {
            qPos.add(StringPool.PERCENT + keywords + StringPool.PERCENT);
            qPos.add(StringPool.PERCENT + keywords + StringPool.PERCENT);
        }

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

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

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

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

From source file:org.opencps.datamgt.service.persistence.DictItemFinderImpl.java

License:Open Source License

/**
 * @param collectionCode/* w w w  .ja v  a  2s . com*/
 * @param itemCode
 * @param keyword
 * @param groupId
 * @param start
 * @param end
 * @param obc
 * @return
 * @throws SystemException 
 */
public List<DictItem> searchDictItemByName_like(String collectionCode, String itemCode, String keyword,
        long groupId, int start, int end, OrderByComparator obc) throws SystemException {

    String[] keywords = null;
    boolean andOperator = false;
    if (Validator.isNotNull(keyword)) {
        keywords = new String[] {
                StringUtil.quote(StringUtil.toLowerCase(keyword).trim(), StringPool.PERCENT) };
    } else {
        andOperator = true;
    }
    return searchDictItemByName_like(collectionCode, itemCode, keywords, groupId, andOperator, start, end, obc);
}

From source file:org.opencps.dossiermgt.service.impl.DossierTemplateLocalServiceImpl.java

License:Open Source License

public List<DossierTemplate> getDossierTemplates(String templateName, int start, int end,
        OrderByComparator orderByComparator) throws SystemException {
    String nameBuffer = Validator.isNotNull(templateName)
            ? StringPool.PERCENT + templateName + StringPool.PERCENT
            : StringPool.PERCENT + StringPool.PERCENT;
    return dossierTemplatePersistence.findByTemplateName(nameBuffer, start, end, orderByComparator);
}

From source file:org.opencps.dossiermgt.service.persistence.DossierFinderImpl.java

License:Open Source License

/**
 * @param groupId//from   ww  w .j av  a 2  s .c  om
 * @param userId
 * @param keywords
 * @param serviceDomainTreeIndex
 * @param dossierStatus
 * @param andOperator
 * @return
 */
private int countDossierByUser(long groupId, long userId, String[] keywords, String serviceDomainTreeIndex,
        String dossierStatus, boolean andOperator) {

    Session session = null;

    try {
        session = openSession();

        String sql = CustomSQLUtil.get(COUNT_DOSSIER_BY_USER);

        if (keywords != null && keywords.length > 0) {
            sql = CustomSQLUtil.replaceKeywords(sql, "lower(opencps_serviceinfo.serviceName)", StringPool.LIKE,
                    true, keywords);

            sql = CustomSQLUtil.replaceKeywords(sql, "lower(opencps_service_config.govAgencyName)",
                    StringPool.LIKE, true, keywords);

            sql = CustomSQLUtil.replaceKeywords(sql, "lower(opencps_dossier.subjectName)", StringPool.LIKE,
                    true, keywords);

            sql = CustomSQLUtil.replaceKeywords(sql, "lower(opencps_dossier.receptionNo)", StringPool.LIKE,
                    true, keywords);
        } else {
            sql = StringUtil.replace(sql,
                    "AND ((lower(opencps_serviceinfo.serviceName) LIKE ? [$AND_OR_NULL_CHECK$]) OR (lower(opencps_service_config.govAgencyName) LIKE ? [$AND_OR_NULL_CHECK$]) OR (lower(opencps_dossier.subjectName) LIKE ? [$AND_OR_NULL_CHECK$]) OR (lower(opencps_dossier.receptionNo) LIKE ? [$AND_OR_NULL_CHECK$]))",
                    StringPool.BLANK);
        }

        if (Validator.isNull(serviceDomainTreeIndex)) {

            sql = StringUtil.replace(sql,
                    "AND (opencps_dossier.serviceDomainIndex LIKE ? OR opencps_dossier.serviceDomainIndex = ?)",
                    StringPool.BLANK);
        } else {
            if (StringUtil.contains(serviceDomainTreeIndex, StringPool.PERIOD)) {
                sql = StringUtil.replace(sql,
                        "AND (opencps_dossier.serviceDomainIndex LIKE ? OR opencps_dossier.serviceDomainIndex = ?)",
                        "AND (opencps_dossier.serviceDomainIndex LIKE ?)");

                serviceDomainTreeIndex = serviceDomainTreeIndex.substring(0,
                        serviceDomainTreeIndex.indexOf(StringPool.PERIOD) + 1);

            }

        }

        if (Validator.isNull(dossierStatus)) {
            sql = StringUtil.replace(sql, "AND (opencps_dossier.dossierStatus = ?)", StringPool.BLANK);
        }

        sql = CustomSQLUtil.replaceAndOperator(sql, andOperator);

        SQLQuery q = session.createSQLQuery(sql);

        q.addScalar(COUNT_COLUMN_NAME, Type.INTEGER);

        QueryPos qPos = QueryPos.getInstance(q);

        qPos.add(groupId);

        qPos.add(userId);

        if (Validator.isNotNull(serviceDomainTreeIndex)
                && StringUtil.contains(serviceDomainTreeIndex, StringPool.PERIOD)) {
            qPos.add(serviceDomainTreeIndex + StringPool.PERCENT);

        } else if (Validator.isNotNull(serviceDomainTreeIndex)
                && !StringUtil.contains(serviceDomainTreeIndex, StringPool.PERIOD)) {
            qPos.add(serviceDomainTreeIndex + StringPool.PERIOD + StringPool.PERCENT);
            qPos.add(serviceDomainTreeIndex);
        }

        if (keywords != null && keywords.length > 0) {
            qPos.add(keywords, 2);
            qPos.add(keywords, 2);
            qPos.add(keywords, 2);
            qPos.add(keywords, 2);
        }

        if (Validator.isNotNull(dossierStatus)) {
            qPos.add(dossierStatus);
        }

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

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

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

        return 0;

    } catch (Exception e) {
        _log.error(e);
    } finally {
        closeSession(session);
    }

    return 0;
}