1
22
23 package com.liferay.portal.spring.hibernate;
24
25 import com.liferay.portal.kernel.util.StringUtil;
26 import com.liferay.portal.model.Organization;
27 import com.liferay.portal.model.User;
28 import com.liferay.portal.model.UserGroup;
29 import com.liferay.portal.util.PortalUtil;
30 import com.liferay.portal.util.PropsUtil;
31 import com.liferay.portlet.blogs.model.BlogsEntry;
32 import com.liferay.portlet.bookmarks.model.BookmarksEntry;
33 import com.liferay.portlet.documentlibrary.model.DLFileEntry;
34 import com.liferay.portlet.imagegallery.model.IGImage;
35
36 import java.sql.SQLException;
37
38
44 public class PortalCustomSQLUtil
45 extends com.liferay.util.dao.hibernate.CustomSQLUtil {
46
47 public PortalCustomSQLUtil() throws SQLException {
48 super(HibernateUtil.getConnection(),
49 PropsUtil.get(PropsUtil.CUSTOM_SQL_FUNCTION_ISNULL),
50 PropsUtil.get(PropsUtil.CUSTOM_SQL_FUNCTION_ISNOTNULL));
51 }
52
53 protected String[] getConfigs() {
54 return PropsUtil.getArray(PropsUtil.CUSTOM_SQL_CONFIGS);
55 }
56
57 protected String transform(String sql) {
58 sql = super.transform(sql);
59
60 long organizationClassNameId = PortalUtil.getClassNameId(
61 Organization.class);
62 long userClassNameId = PortalUtil.getClassNameId(User.class);
63 long userGroupClassNameId = PortalUtil.getClassNameId(UserGroup.class);
64 long blogsEntryClassNameId = PortalUtil.getClassNameId(
65 BlogsEntry.class);
66 long bookmarksEntryClassNameId = PortalUtil.getClassNameId(
67 BookmarksEntry.class);
68 long dlFileEntryClassNameId = PortalUtil.getClassNameId(
69 DLFileEntry.class);
70 long igImageClassNameId = PortalUtil.getClassNameId(IGImage.class);
71
72 sql = StringUtil.replace(
73 sql,
74 new String[] {
75 "[$CLASS_NAME_ID_COM.LIFERAY.PORTAL.MODEL.ORGANIZATION$]",
76 "[$CLASS_NAME_ID_COM.LIFERAY.PORTAL.MODEL.USER$]",
77 "[$CLASS_NAME_ID_COM.LIFERAY.PORTAL.MODEL.USERGROUP$]",
78 "[$CLASS_NAME_ID_COM.LIFERAY.PORTLET.BLOGS.MODEL.BLOGSENTRY$]",
79 "[$CLASS_NAME_ID_COM.LIFERAY.PORTLET.BOOKMARKS.MODEL.BOOKMARKSENTRY$]",
80 "[$CLASS_NAME_ID_COM.LIFERAY.PORTLET.DOCUMENTLIBRARY.MODEL.DLFILEENTRY$]",
81 "[$CLASS_NAME_ID_COM.LIFERAY.PORTLET.IMAGEGALLERY.MODEL.IGIMAGE$]"
82 },
83 new String[] {
84 String.valueOf(organizationClassNameId),
85 String.valueOf(userClassNameId),
86 String.valueOf(userGroupClassNameId),
87 String.valueOf(blogsEntryClassNameId),
88 String.valueOf(bookmarksEntryClassNameId),
89 String.valueOf(dlFileEntryClassNameId),
90 String.valueOf(igImageClassNameId)
91 });
92
93 return sql;
94 }
95
96 }