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