Example usage for com.liferay.portal.kernel.model GroupConstants GLOBAL_FRIENDLY_URL

List of usage examples for com.liferay.portal.kernel.model GroupConstants GLOBAL_FRIENDLY_URL

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.model GroupConstants GLOBAL_FRIENDLY_URL.

Prototype

String GLOBAL_FRIENDLY_URL

To view the source code for com.liferay.portal.kernel.model GroupConstants GLOBAL_FRIENDLY_URL.

Click Source Link

Usage

From source file:com.liferay.journal.internal.upgrade.v0_0_5.UpgradeJournal.java

License:Open Source License

protected void addDDMStorageLinks() throws Exception {
    try (LoggingTimer loggingTimer = new LoggingTimer()) {
        StringBundler sb = new StringBundler(8);

        sb.append("select DDMStructure.structureId, JournalArticle.id_ ");
        sb.append("from JournalArticle inner join DDMStructure on (");
        sb.append("DDMStructure.groupId in (select distinct Group_.");
        sb.append("groupId from Group_ where (Group_.groupId = ");
        sb.append("JournalArticle.groupId) or (Group_.companyId = ");
        sb.append("JournalArticle.companyId and Group_.friendlyURL = ?)) ");
        sb.append("and DDMStructure.structureKey = JournalArticle.");
        sb.append("DDMStructureKey and JournalArticle.classNameId != ?)");

        try (PreparedStatement ps = connection.prepareStatement(sb.toString())) {

            ps.setString(1, GroupConstants.GLOBAL_FRIENDLY_URL);
            ps.setLong(2, PortalUtil.getClassNameId(DDMStructure.class.getName()));

            try (ResultSet rs = ps.executeQuery()) {
                Map<Long, List<Long>> ddmStructureIdsMap = new HashMap<>();

                while (rs.next()) {
                    long structureId = rs.getLong("structureId");
                    long id = rs.getLong("id_");

                    List<Long> ddmStructureIds = ddmStructureIdsMap.get(id);

                    if (ddmStructureIds == null) {
                        ddmStructureIds = new ArrayList<>();
                    }/*from   w  w w.  ja v  a2 s .co  m*/

                    ddmStructureIds.add(structureId);

                    ddmStructureIdsMap.put(id, ddmStructureIds);
                }

                addDDMStorageLink(ddmStructureIdsMap);
            }
        }
    }
}