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

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

Introduction

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

Prototype

String CLOSE_PARENTHESIS

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

Click Source Link

Usage

From source file:com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryTypePersistenceImpl.java

License:Open Source License

/**
 * Returns the number of document library file entry types that the user has permission to view where groupId = any ?.
 *
 * @param groupIds the group IDs/*from w ww  .  j a  v  a  2 s . co m*/
 * @return the number of matching document library file entry types that the user has permission to view
 * @throws SystemException if a system exception occurred
 */
public int filterCountByGroupId(long[] groupIds) throws SystemException {
    if (!InlineSQLHelperUtil.isEnabled(groupIds)) {
        return countByGroupId(groupIds);
    }

    StringBundler query = new StringBundler();

    query.append(_FILTER_SQL_COUNT_DLFILEENTRYTYPE_WHERE);

    boolean conjunctionable = false;

    if ((groupIds == null) || (groupIds.length > 0)) {
        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        query.append(StringPool.OPEN_PARENTHESIS);

        for (int i = 0; i < groupIds.length; i++) {
            query.append(_FINDER_COLUMN_GROUPID_GROUPID_5);

            if ((i + 1) < groupIds.length) {
                query.append(WHERE_OR);
            }
        }

        query.append(StringPool.CLOSE_PARENTHESIS);

        conjunctionable = true;
    }

    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), DLFileEntryType.class.getName(),
            _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupIds);

    Session session = null;

    try {
        session = openSession();

        SQLQuery q = session.createSQLQuery(sql);

        q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG);

        QueryPos qPos = QueryPos.getInstance(q);

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

        Long count = (Long) q.uniqueResult();

        return count.intValue();
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }
}

From source file:com.liferay.portlet.documentlibrary.service.persistence.DLFolderFinderImpl.java

License:Open Source License

protected int doCountF_FE_FS_ByG_F_S_M_M(long groupId, long folderId, int status, String[] mimeTypes,
        boolean includeMountFolders, boolean inlineSQLHelper) throws SystemException {

    Session session = null;//  w w w  .  java  2  s  . c  o  m

    try {
        session = openSession();

        StringBundler sb = new StringBundler(7);

        sb.append(StringPool.OPEN_PARENTHESIS);

        String sql = CustomSQLUtil.get(COUNT_F_BY_G_M_F);

        if (inlineSQLHelper) {
            sql = InlineSQLHelperUtil.replacePermissionCheck(sql, DLFolder.class.getName(), "DLFolder.folderId",
                    groupId);
        }

        sb.append(sql);
        sb.append(") UNION ALL (");
        sb.append(getFileEntriesSQL(groupId, status, mimeTypes, inlineSQLHelper));
        sb.append(") UNION ALL (");
        sb.append(getFileShortcutsSQL(groupId, status, mimeTypes, inlineSQLHelper));
        sb.append(StringPool.CLOSE_PARENTHESIS);

        sql = sb.toString();

        sql = updateSQL(sql, folderId, status, includeMountFolders);

        SQLQuery q = session.createSQLQuery(sql);

        q.addScalar(COUNT_COLUMN_NAME, Type.LONG);

        QueryPos qPos = QueryPos.getInstance(q);

        qPos.add(groupId);

        if (!includeMountFolders) {
            qPos.add(false);
        }

        qPos.add(folderId);
        qPos.add(groupId);

        if (status != WorkflowConstants.STATUS_ANY) {
            qPos.add(status);
        }

        qPos.add(folderId);
        qPos.add(groupId);
        qPos.add(folderId);

        int count = 0;

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

        while (itr.hasNext()) {
            Long l = itr.next();

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

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

From source file:com.liferay.portlet.documentlibrary.service.persistence.DLFolderFinderImpl.java

License:Open Source License

protected int doCountFE_FS_ByG_F_S_M(long groupId, long folderId, int status, String[] mimeTypes,
        boolean inlineSQLHelper) throws SystemException {

    Session session = null;//from   w  w w. j  a v a 2s  .c  o m

    try {
        session = openSession();

        StringBundler sb = new StringBundler(7);

        sb.append(StringPool.OPEN_PARENTHESIS);

        String sql = getFileEntriesSQL(groupId, status, mimeTypes, inlineSQLHelper);

        sb.append(sql);
        sb.append(") UNION ALL (");
        sb.append(getFileShortcutsSQL(groupId, status, mimeTypes, inlineSQLHelper));
        sb.append(StringPool.CLOSE_PARENTHESIS);

        sql = sb.toString();

        sql = updateSQL(sql, folderId, status, false);

        SQLQuery q = session.createSQLQuery(sql);

        q.addScalar(COUNT_COLUMN_NAME, Type.LONG);

        QueryPos qPos = QueryPos.getInstance(q);

        qPos.add(groupId);

        if (status != WorkflowConstants.STATUS_ANY) {
            qPos.add(status);
        }

        qPos.add(folderId);
        qPos.add(groupId);
        qPos.add(folderId);

        int count = 0;

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

        while (itr.hasNext()) {
            Long l = itr.next();

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

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

From source file:com.liferay.portlet.documentlibrary.service.persistence.DLFolderFinderImpl.java

License:Open Source License

protected List<Object> doFindF_FE_FS_ByG_F_S_M_M(long groupId, long folderId, int status, String[] mimeTypes,
        boolean includeMountFolders, int start, int end, OrderByComparator obc, boolean inlineSQLHelper)
        throws SystemException {

    Session session = null;/*  w  w w.  ja  va 2  s  .c om*/

    try {
        session = openSession();

        StringBundler sb = new StringBundler(7);

        sb.append("SELECT * FROM (");

        String sql = CustomSQLUtil.get(FIND_F_BY_G_M_F);

        if (inlineSQLHelper) {
            sql = InlineSQLHelperUtil.replacePermissionCheck(sql, DLFolder.class.getName(), "DLFolder.folderId",
                    groupId);
        }

        sb.append(sql);
        sb.append(" UNION ALL ");

        if (status == WorkflowConstants.STATUS_ANY) {
            sql = CustomSQLUtil.get(FIND_FE_BY_G_F);
        } else {
            sql = CustomSQLUtil.get(FIND_FE_BY_G_F_S);
        }

        if (inlineSQLHelper) {
            sql = InlineSQLHelperUtil.replacePermissionCheck(sql, DLFileEntry.class.getName(),
                    "DLFileEntry.fileEntryId", groupId);
        }

        sb.append(sql);

        if ((mimeTypes != null) && (mimeTypes.length > 0)) {
            for (int i = 0; i < mimeTypes.length; i++) {
                if (i == 0) {
                    sb.append(" AND (");
                } else {
                    sb.append(" OR");
                }

                sb.append(" DLFileEntry.mimeType = '");
                sb.append(mimeTypes[i]);
                sb.append("'");
            }

            sb.append(StringPool.CLOSE_PARENTHESIS);
        }

        sb.append(" UNION ALL ");

        sql = CustomSQLUtil.get(FIND_FS_BY_G_F_S);

        if (inlineSQLHelper) {
            sql = InlineSQLHelperUtil.replacePermissionCheck(sql, DLFileShortcut.class.getName(),
                    "DLFileShortcut.fileShortcutId", groupId);
        }

        sb.append(sql);

        if ((mimeTypes != null) && (mimeTypes.length > 0)) {
            for (int i = 0; i < mimeTypes.length; i++) {
                if (i == 0) {
                    sb.append(" AND (");
                } else {
                    sb.append(" OR");
                }

                sb.append(" mimeType = '");
                sb.append(mimeTypes[i]);
                sb.append("'");
            }

            sb.append(StringPool.CLOSE_PARENTHESIS);
        }

        sb.append(") TEMP_TABLE ORDER BY modelFolder DESC, title ASC");

        sql = sb.toString();

        if (includeMountFolders) {
            sql = StringUtil.replace(sql, "(DLFolder.mountPoint = ?) AND", "");
        }

        sql = StringUtil.replace(sql, "[$FOLDER_PARENT_FOLDER_ID$]", getFolderId(folderId, "DLFolder"));
        sql = StringUtil.replace(sql, "[$FILE_ENTRY_FOLDER_ID$]", getFolderId(folderId, "DLFileEntry"));
        sql = StringUtil.replace(sql, "[$FILE_SHORTCUT_FOLDER_ID$]", getFolderId(folderId, "DLFileShortcut"));
        sql = CustomSQLUtil.replaceOrderBy(sql, obc);

        SQLQuery q = session.createSQLQuery(sql);

        q.addScalar("modelFolderId", Type.LONG);
        q.addScalar("name", Type.STRING);
        q.addScalar("title", Type.STRING);
        q.addScalar("fileShortcutId", Type.LONG);
        q.addScalar("modelFolder", Type.LONG);

        QueryPos qPos = QueryPos.getInstance(q);

        qPos.add(groupId);

        if (!includeMountFolders) {
            qPos.add(false);
        }

        qPos.add(folderId);
        qPos.add(groupId);

        if (status != WorkflowConstants.STATUS_ANY) {
            qPos.add(status);
        }

        qPos.add(folderId);
        qPos.add(groupId);
        qPos.add(folderId);

        List<Object> models = new ArrayList<Object>();

        Iterator<Object[]> itr = (Iterator<Object[]>) QueryUtil.iterate(q, getDialect(), start, end);

        while (itr.hasNext()) {
            Object[] array = itr.next();

            long curFolderId = (Long) array[0];
            String name = (String) array[1];
            //String title = (String)array[2];
            long fileShortcutId = (Long) array[3];
            long modelFolder = (Long) array[4];

            Object obj = null;

            if (modelFolder == 1) {
                obj = DLFolderUtil.findByPrimaryKey(curFolderId);
            } else if (fileShortcutId > 0) {
                obj = DLFileShortcutUtil.findByPrimaryKey(fileShortcutId);
            } else {
                obj = DLFileEntryUtil.findByG_F_N(groupId, curFolderId, name);
            }

            models.add(obj);
        }

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

From source file:com.liferay.portlet.documentlibrary.service.persistence.DLFolderFinderImpl.java

License:Open Source License

protected String getFileEntriesSQL(long groupId, int status, String[] mimeTypes, boolean inlineSQLHelper) {

    StringBundler sb = new StringBundler();

    String sql = null;/*from   ww w  . j  ava  2s.  c  o m*/

    if (status == WorkflowConstants.STATUS_ANY) {
        sql = CustomSQLUtil.get(COUNT_FE_BY_G_F);
    } else {
        sql = CustomSQLUtil.get(COUNT_FE_BY_G_F_S);

        if ((inlineSQLHelper && InlineSQLHelperUtil.isEnabled(groupId))
                || ((mimeTypes != null) && (mimeTypes.length > 0))) {

            sql = StringUtil.replace(sql, "[$JOIN$]", CustomSQLUtil.get(JOIN_FV_BY_DL_FILE_ENTRY));
        } else {
            sql = StringUtil.replace(sql, "[$JOIN$]", "");
        }
    }

    if (inlineSQLHelper) {
        sql = InlineSQLHelperUtil.replacePermissionCheck(sql, DLFileEntry.class.getName(),
                "DLFileEntry.fileEntryId", groupId);
    }

    sb.append(sql);

    if ((mimeTypes != null) && (mimeTypes.length > 0)) {
        sb.append(WHERE_AND);
        sb.append(StringPool.OPEN_PARENTHESIS);
        sb.append(getMimeTypes(mimeTypes, "DLFileEntry"));
        sb.append(StringPool.CLOSE_PARENTHESIS);
    }

    return sb.toString();
}

From source file:com.liferay.portlet.documentlibrary.service.persistence.DLFolderFinderImpl.java

License:Open Source License

protected String getFileShortcutsSQL(long groupId, int status, String[] mimeTypes, boolean inlineSQLHelper) {

    String sql = CustomSQLUtil.get(COUNT_FS_BY_G_F_S);

    if ((inlineSQLHelper && InlineSQLHelperUtil.isEnabled(groupId))
            || ((mimeTypes != null) && (mimeTypes.length > 0))) {

        sql = StringUtil.replace(sql, "[$JOIN$]", CustomSQLUtil.get(JOIN_FS_BY_DL_FILE_ENTRY));
    } else {//from w w  w. j ava2  s  . c  o m
        sql = StringUtil.replace(sql, "[$JOIN$]", "");
    }

    if (inlineSQLHelper) {
        sql = InlineSQLHelperUtil.replacePermissionCheck(sql, DLFileShortcut.class.getName(),
                "DLFileShortcut.fileShortcutId", groupId);
    }

    StringBundler sb = new StringBundler(sql);

    if ((mimeTypes != null) && (mimeTypes.length > 0)) {
        sb.append(WHERE_AND);
        sb.append(StringPool.OPEN_PARENTHESIS);
        sb.append(getMimeTypes(mimeTypes, "DLFileEntry"));
        sb.append(StringPool.CLOSE_PARENTHESIS);
    }

    return sb.toString();
}

From source file:com.liferay.portlet.dynamicdatamapping.storage.ExpandoStorageAdapter.java

License:Open Source License

private String _toExpression(Condition condition) {
    if (condition.isJunction()) {
        Junction junction = (Junction) condition;

        return StringPool.OPEN_PARENTHESIS.concat(_toExpression(junction)).concat(StringPool.CLOSE_PARENTHESIS);
    } else {/*from   w w  w.java  2  s.  c  o m*/
        FieldCondition fieldCondition = (FieldCondition) condition;

        return _toExpression(fieldCondition);
    }
}

From source file:com.liferay.portlet.dynamicdatamapping.storage.ExpandoStorageAdapter.java

License:Open Source License

private String _toExpression(FieldCondition fieldCondition) {
    StringBundler sb = new StringBundler(5);

    sb.append("(@");
    sb.append(fieldCondition.getName());

    ComparisonOperator comparisonOperator = fieldCondition.getComparisonOperator();

    if (comparisonOperator.equals(ComparisonOperator.LIKE)) {
        sb.append(".data matches ");
    } else {//  w  w w  . j  av  a  2 s .c  o  m
        sb.append(".data == ");
    }

    String value = StringUtil.quote(String.valueOf(fieldCondition.getValue()));

    sb.append(value);
    sb.append(StringPool.CLOSE_PARENTHESIS);

    return sb.toString();
}

From source file:com.liferay.portlet.dynamicdatamapping.storage.XMLStorageAdapter.java

License:Open Source License

private String _toXPath(Condition condition) {
    StringBundler sb = new StringBundler();

    if (condition.isJunction()) {
        sb.append(StringPool.OPEN_PARENTHESIS);
        sb.append(_toXPath((Junction) condition));
        sb.append(StringPool.CLOSE_PARENTHESIS);
    } else {//w w w  .j  a  v  a  2s. c o m
        sb.append(_toXPath((FieldConditionImpl) condition));
    }

    return sb.toString();
}

From source file:com.liferay.portlet.dynamicdatamapping.storage.XMLStorageAdapter.java

License:Open Source License

private String _toXPath(FieldCondition fieldCondition) {
    StringBundler sb = new StringBundler(6);

    sb.append("(@name=");

    String name = StringUtil.quote(String.valueOf(fieldCondition.getName()));

    sb.append(name);//from   ww  w . j  a  v  a  2s .  c o m

    ComparisonOperator comparisonOperator = fieldCondition.getComparisonOperator();

    if (comparisonOperator.equals(ComparisonOperator.LIKE)) {
        sb.append(" and matches(dynamic-content, ");
    } else {
        sb.append(" and dynamic-content= ");
    }

    String value = StringUtil.quote(String.valueOf(fieldCondition.getValue()));

    sb.append(value);

    if (comparisonOperator.equals(ComparisonOperator.LIKE)) {
        sb.append(StringPool.CLOSE_PARENTHESIS);
    }

    sb.append(StringPool.CLOSE_PARENTHESIS);

    return sb.toString();
}