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.tools.sql.DBUtil;
30 import com.liferay.portal.util.PortalUtil;
31 import com.liferay.portal.util.PropsUtil;
32 import com.liferay.portlet.blogs.model.BlogsEntry;
33 import com.liferay.portlet.bookmarks.model.BookmarksEntry;
34 import com.liferay.portlet.documentlibrary.model.DLFileEntry;
35 import com.liferay.portlet.imagegallery.model.IGImage;
36 import com.liferay.portlet.messageboards.model.MBMessage;
37 import com.liferay.portlet.wiki.model.WikiPage;
38
39 import java.sql.SQLException;
40
41
47 public class PortalCustomSQLUtil
48 extends com.liferay.util.dao.hibernate.CustomSQLUtil {
49
50 public PortalCustomSQLUtil() throws SQLException {
51 super(
52 HibernateUtil.getConnection(),
53 PropsUtil.get(PropsUtil.CUSTOM_SQL_FUNCTION_ISNULL),
54 PropsUtil.get(PropsUtil.CUSTOM_SQL_FUNCTION_ISNOTNULL));
55 }
56
57 protected String[] getConfigs() {
58 return PropsUtil.getArray(PropsUtil.CUSTOM_SQL_CONFIGS);
59 }
60
61 protected String transform(String sql) {
62 sql = super.transform(sql);
63
64 long organizationClassNameId = PortalUtil.getClassNameId(
65 Organization.class);
66 long userClassNameId = PortalUtil.getClassNameId(User.class);
67 long userGroupClassNameId = PortalUtil.getClassNameId(UserGroup.class);
68 long blogsEntryClassNameId = PortalUtil.getClassNameId(
69 BlogsEntry.class);
70 long bookmarksEntryClassNameId = PortalUtil.getClassNameId(
71 BookmarksEntry.class);
72 long dlFileEntryClassNameId = PortalUtil.getClassNameId(
73 DLFileEntry.class);
74 long igImageClassNameId = PortalUtil.getClassNameId(IGImage.class);
75 long mbMessageClassNameId = PortalUtil.getClassNameId(MBMessage.class);
76 long wikiPageClassNameId = PortalUtil.getClassNameId(WikiPage.class);
77
78 DBUtil dbUtil = DBUtil.getInstance();
79
80 sql = StringUtil.replace(
81 sql,
82 new String[] {
83 "[$CLASS_NAME_ID_COM.LIFERAY.PORTAL.MODEL.ORGANIZATION$]",
84 "[$CLASS_NAME_ID_COM.LIFERAY.PORTAL.MODEL.USER$]",
85 "[$CLASS_NAME_ID_COM.LIFERAY.PORTAL.MODEL.USERGROUP$]",
86 "[$CLASS_NAME_ID_COM.LIFERAY.PORTLET.BLOGS.MODEL.BLOGSENTRY$]",
87 "[$CLASS_NAME_ID_COM.LIFERAY.PORTLET.BOOKMARKS.MODEL.BOOKMARKSENTRY$]",
88 "[$CLASS_NAME_ID_COM.LIFERAY.PORTLET.DOCUMENTLIBRARY.MODEL.DLFILEENTRY$]",
89 "[$CLASS_NAME_ID_COM.LIFERAY.PORTLET.IMAGEGALLERY.MODEL.IGIMAGE$]",
90 "[$CLASS_NAME_ID_COM.LIFERAY.PORTLET.MESSAGEBOARDS.MODEL.MBMESSAGE$]",
91 "[$CLASS_NAME_ID_COM.LIFERAY.PORTLET.WIKI.MODEL.WIKIPAGE$]",
92 "[$FALSE$]",
93 "[$TRUE$]"
94 },
95 new String[] {
96 String.valueOf(organizationClassNameId),
97 String.valueOf(userClassNameId),
98 String.valueOf(userGroupClassNameId),
99 String.valueOf(blogsEntryClassNameId),
100 String.valueOf(bookmarksEntryClassNameId),
101 String.valueOf(dlFileEntryClassNameId),
102 String.valueOf(igImageClassNameId),
103 String.valueOf(mbMessageClassNameId),
104 String.valueOf(wikiPageClassNameId),
105 dbUtil.getTemplateFalse(),
106 dbUtil.getTemplateTrue()
107 });
108
109 return sql;
110 }
111
112 }