1
14
15 package com.liferay.portlet.expando.service.impl;
16
17 import com.liferay.portal.PortalException;
18 import com.liferay.portal.SystemException;
19 import com.liferay.portal.util.PortalUtil;
20 import com.liferay.portlet.expando.model.ExpandoRow;
21 import com.liferay.portlet.expando.model.ExpandoTable;
22 import com.liferay.portlet.expando.model.ExpandoTableConstants;
23 import com.liferay.portlet.expando.service.base.ExpandoRowLocalServiceBaseImpl;
24
25 import java.util.Collections;
26 import java.util.List;
27
28
33 public class ExpandoRowLocalServiceImpl extends ExpandoRowLocalServiceBaseImpl {
34
35 public ExpandoRow addRow(long tableId, long classPK)
36 throws SystemException {
37
38 long rowId = counterLocalService.increment();
39
40 ExpandoRow row = expandoRowPersistence.create(rowId);
41
42 row.setTableId(tableId);
43 row.setClassPK(classPK);
44
45 expandoRowPersistence.update(row, false);
46
47 return row;
48 }
49
50 public void deleteRow(long rowId)
51 throws PortalException, SystemException {
52
53
55 expandoRowPersistence.remove(rowId);
56
57
59 expandoValueLocalService.deleteRowValues(rowId);
60 }
61
62 public void deleteRow(long tableId, long classPK)
63 throws PortalException, SystemException {
64
65 ExpandoRow row = expandoRowPersistence.findByT_C(tableId, classPK);
66
67 deleteRow(row.getRowId());
68 }
69
70 public void deleteRow(long classNameId, String tableName, long classPK)
71 throws PortalException, SystemException {
72
73 ExpandoTable table = expandoTablePersistence.findByC_N(
74 classNameId, tableName);
75
76 deleteRow(table.getTableId(), classPK);
77 }
78
79 public void deleteRow(String className, String tableName, long classPK)
80 throws PortalException, SystemException {
81
82 long classNameId = PortalUtil.getClassNameId(className);
83
84 deleteRow(classNameId, tableName, classPK);
85 }
86
87 public List<ExpandoRow> getDefaultTableRows(
88 long classNameId, int start, int end)
89 throws SystemException {
90
91 ExpandoTable table = expandoTablePersistence.fetchByC_N(
92 classNameId, ExpandoTableConstants.DEFAULT_TABLE_NAME);
93
94 if (table == null) {
95 return Collections.EMPTY_LIST;
96 }
97
98 return expandoRowPersistence.findByTableId(
99 table.getTableId(), start, end);
100 }
101
102 public List<ExpandoRow> getDefaultTableRows(
103 String className, int start, int end)
104 throws SystemException {
105
106 long classNameId = PortalUtil.getClassNameId(className);
107
108 return getDefaultTableRows(classNameId, start, end);
109 }
110
111 public int getDefaultTableRowsCount(long classNameId)
112 throws SystemException {
113
114 ExpandoTable table = expandoTablePersistence.fetchByC_N(
115 classNameId, ExpandoTableConstants.DEFAULT_TABLE_NAME);
116
117 if (table == null) {
118 return 0;
119 }
120
121 return expandoRowPersistence.countByTableId(table.getTableId());
122 }
123
124 public int getDefaultTableRowsCount(String className)
125 throws SystemException {
126
127 long classNameId = PortalUtil.getClassNameId(className);
128
129 return getDefaultTableRowsCount(classNameId);
130 }
131
132 public ExpandoRow getRow(long rowId)
133 throws PortalException, SystemException {
134
135 return expandoRowPersistence.findByPrimaryKey(rowId);
136 }
137
138 public ExpandoRow getRow(long tableId, long classPK)
139 throws PortalException, SystemException {
140
141 return expandoRowPersistence.findByT_C(tableId, classPK);
142 }
143
144 public ExpandoRow getRow(long classNameId, String tableName, long classPK)
145 throws SystemException {
146
147 ExpandoTable table = expandoTablePersistence.fetchByC_N(
148 classNameId, tableName);
149
150 if (table == null) {
151 return null;
152 }
153
154 return expandoRowPersistence.fetchByT_C(table.getTableId(), classPK);
155 }
156
157 public ExpandoRow getRow(String className, String tableName, long classPK)
158 throws SystemException {
159
160 long classNameId = PortalUtil.getClassNameId(className);
161
162 return getRow(classNameId, tableName, classPK);
163 }
164
165 public List<ExpandoRow> getRows(long tableId, int start, int end)
166 throws SystemException {
167
168 return expandoRowPersistence.findByTableId(tableId, start, end);
169 }
170
171 public List<ExpandoRow> getRows(
172 long classNameId, String tableName, int start, int end)
173 throws SystemException {
174
175 ExpandoTable table = expandoTablePersistence.fetchByC_N(
176 classNameId, tableName);
177
178 if (table == null) {
179 return Collections.EMPTY_LIST;
180 }
181
182 return expandoRowPersistence.findByTableId(
183 table.getTableId(), start, end);
184 }
185
186 public List<ExpandoRow> getRows(
187 String className, String tableName, int start, int end)
188 throws SystemException {
189
190 long classNameId = PortalUtil.getClassNameId(className);
191
192 return getRows(classNameId, tableName, start, end);
193 }
194
195 public int getRowsCount(long tableId) throws SystemException {
196 return expandoRowPersistence.countByTableId(tableId);
197 }
198
199 public int getRowsCount(long classNameId, String tableName)
200 throws SystemException {
201
202 ExpandoTable table = expandoTablePersistence.fetchByC_N(
203 classNameId, tableName);
204
205 if (table == null) {
206 return 0;
207 }
208
209 return expandoRowPersistence.countByTableId(table.getTableId());
210 }
211
212 public int getRowsCount(String className, String tableName)
213 throws SystemException {
214
215 long classNameId = PortalUtil.getClassNameId(className);
216
217 return getRowsCount(classNameId, tableName);
218 }
219
220 }