001
014
015 package com.liferay.portlet.expando.service.impl;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portal.security.auth.CompanyThreadLocal;
020 import com.liferay.portal.util.PortalUtil;
021 import com.liferay.portlet.expando.model.ExpandoRow;
022 import com.liferay.portlet.expando.model.ExpandoTable;
023 import com.liferay.portlet.expando.model.ExpandoTableConstants;
024 import com.liferay.portlet.expando.service.base.ExpandoRowLocalServiceBaseImpl;
025
026 import java.util.Collections;
027 import java.util.List;
028
029
033 public class ExpandoRowLocalServiceImpl extends ExpandoRowLocalServiceBaseImpl {
034
035 public ExpandoRow addRow(long tableId, long classPK)
036 throws PortalException, SystemException {
037
038 ExpandoTable table = expandoTablePersistence.findByPrimaryKey(tableId);
039
040 long rowId = counterLocalService.increment();
041
042 ExpandoRow row = expandoRowPersistence.create(rowId);
043
044 row.setCompanyId(table.getCompanyId());
045 row.setTableId(tableId);
046 row.setClassPK(classPK);
047
048 expandoRowPersistence.update(row, false);
049
050 return row;
051 }
052
053 public void deleteRow(ExpandoRow row) throws SystemException {
054
055
056
057 expandoRowPersistence.remove(row);
058
059
060
061 expandoValueLocalService.deleteRowValues(row.getRowId());
062 }
063
064 public void deleteRow(long rowId) throws PortalException, SystemException {
065 ExpandoRow row = expandoRowPersistence.findByPrimaryKey(rowId);
066
067 deleteRow(row);
068 }
069
070 public void deleteRow(long tableId, long classPK)
071 throws PortalException, SystemException {
072
073 ExpandoRow row = expandoRowPersistence.findByT_C(tableId, classPK);
074
075 deleteRow(row);
076 }
077
078 public void deleteRow(
079 long companyId, long classNameId, String tableName, long classPK)
080 throws PortalException, SystemException {
081
082 ExpandoTable table = expandoTableLocalService.getTable(
083 companyId, classNameId, tableName);
084
085 expandoRowLocalService.deleteRow(table.getTableId(), classPK);
086 }
087
088 public void deleteRow(
089 long companyId, String className, String tableName, long classPK)
090 throws PortalException, SystemException {
091
092 long classNameId = PortalUtil.getClassNameId(className);
093
094 expandoRowLocalService.deleteRow(
095 companyId, classNameId, tableName, classPK);
096 }
097
098 public List<ExpandoRow> getDefaultTableRows(
099 long companyId, long classNameId, int start, int end)
100 throws SystemException {
101
102 return expandoRowLocalService.getRows(
103 companyId, classNameId, ExpandoTableConstants.DEFAULT_TABLE_NAME,
104 start, end);
105 }
106
107 public List<ExpandoRow> getDefaultTableRows(
108 long companyId, String className, int start, int end)
109 throws SystemException {
110
111 long classNameId = PortalUtil.getClassNameId(className);
112
113 return expandoRowLocalService.getDefaultTableRows(
114 companyId, classNameId, start, end);
115 }
116
117 public int getDefaultTableRowsCount(long companyId, long classNameId)
118 throws SystemException {
119
120 return expandoRowLocalService.getRowsCount(
121 companyId, classNameId, ExpandoTableConstants.DEFAULT_TABLE_NAME);
122 }
123
124 public int getDefaultTableRowsCount(long companyId, String className)
125 throws SystemException {
126
127 long classNameId = PortalUtil.getClassNameId(className);
128
129 return expandoRowLocalService.getDefaultTableRowsCount(
130 companyId, classNameId);
131 }
132
133 public ExpandoRow getRow(long rowId)
134 throws PortalException, SystemException {
135
136 return expandoRowPersistence.findByPrimaryKey(rowId);
137 }
138
139 public ExpandoRow getRow(long tableId, long classPK)
140 throws PortalException, SystemException {
141
142 return expandoRowPersistence.findByT_C(tableId, classPK);
143 }
144
145 public ExpandoRow getRow(
146 long companyId, long classNameId, String tableName, long classPK)
147 throws SystemException {
148
149 ExpandoTable table = expandoTablePersistence.fetchByC_C_N(
150 companyId, classNameId, tableName);
151
152 if (table == null) {
153 return null;
154 }
155
156 return expandoRowPersistence.fetchByT_C(table.getTableId(), classPK);
157 }
158
159 public ExpandoRow getRow(
160 long companyId, String className, String tableName, long classPK)
161 throws SystemException {
162
163 long classNameId = PortalUtil.getClassNameId(className);
164
165 return expandoRowLocalService.getRow(
166 companyId, classNameId, tableName, classPK);
167 }
168
169 public List<ExpandoRow> getRows(long tableId, int start, int end)
170 throws SystemException {
171
172 return expandoRowPersistence.findByTableId(tableId, start, end);
173 }
174
175 public List<ExpandoRow> getRows(
176 long companyId, long classNameId, String tableName, int start,
177 int end)
178 throws SystemException {
179
180 ExpandoTable table = expandoTablePersistence.fetchByC_C_N(
181 companyId, classNameId, tableName);
182
183 if (table == null) {
184 return Collections.emptyList();
185 }
186
187 return expandoRowPersistence.findByTableId(
188 table.getTableId(), start, end);
189 }
190
191 public List<ExpandoRow> getRows(
192 long companyId, String className, String tableName, int start,
193 int end)
194 throws SystemException {
195
196 long classNameId = PortalUtil.getClassNameId(className);
197
198 return expandoRowLocalService.getRows(
199 companyId, classNameId, tableName, start, end);
200 }
201
202
205 public List<ExpandoRow> getRows(
206 String className, String tableName, int start, int end)
207 throws SystemException {
208
209 long companyId = CompanyThreadLocal.getCompanyId();
210
211 return expandoRowLocalService.getRows(
212 companyId, className, tableName, start, end);
213 }
214
215 public int getRowsCount(long tableId) throws SystemException {
216 return expandoRowPersistence.countByTableId(tableId);
217 }
218
219 public int getRowsCount(long companyId, long classNameId, String tableName)
220 throws SystemException {
221
222 ExpandoTable table = expandoTablePersistence.fetchByC_C_N(
223 companyId, classNameId, tableName);
224
225 if (table == null) {
226 return 0;
227 }
228
229 return expandoRowPersistence.countByTableId(table.getTableId());
230 }
231
232 public int getRowsCount(long companyId, String className, String tableName)
233 throws SystemException {
234
235 long classNameId = PortalUtil.getClassNameId(className);
236
237 return expandoRowLocalService.getRowsCount(
238 companyId, classNameId, tableName);
239 }
240
241
244 public int getRowsCount(String className, String tableName)
245 throws SystemException {
246
247 long companyId = CompanyThreadLocal.getCompanyId();
248
249 return expandoRowLocalService.getRowsCount(
250 companyId, className, tableName);
251 }
252
253 }