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.List;
34
35
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(String className, String tableName, long classPK)
79 throws PortalException, SystemException {
80
81 long classNameId = PortalUtil.getClassNameId(className);
82
83 deleteRow(classNameId, tableName, classPK);
84 }
85
86 public void deleteRow(long classNameId, String tableName, long classPK)
87 throws PortalException, SystemException {
88
89 ExpandoTable table = expandoTableLocalService.getTable(
90 classNameId, tableName);
91
92 deleteRow(table.getTableId(), classPK);
93 }
94
95 public List<ExpandoRow> getDefaultTableRows(
96 String className, int start, int end)
97 throws SystemException {
98
99 long classNameId = PortalUtil.getClassNameId(className);
100
101 return getDefaultTableRows(classNameId, start, end);
102 }
103
104 public List<ExpandoRow> getDefaultTableRows(
105 long classNameId, int start, int end)
106 throws SystemException {
107
108 return expandoRowFinder.findByTC_TN(
109 classNameId, ExpandoTableConstants.DEFAULT_TABLE_NAME, start, end);
110 }
111
112 public int getDefaultTableRowsCount(String className)
113 throws SystemException {
114
115 long classNameId = PortalUtil.getClassNameId(className);
116
117 return getDefaultTableRowsCount(classNameId);
118 }
119
120 public int getDefaultTableRowsCount(long classNameId)
121 throws SystemException {
122
123 return expandoRowFinder.countByTC_TN(
124 classNameId, ExpandoTableConstants.DEFAULT_TABLE_NAME);
125 }
126
127 public ExpandoRow getRow(long rowId)
128 throws PortalException, SystemException {
129
130 return expandoRowPersistence.findByPrimaryKey(rowId);
131 }
132
133 public ExpandoRow getRow(long tableId, long classPK)
134 throws PortalException, SystemException {
135
136 return expandoRowPersistence.findByT_C(tableId, classPK);
137 }
138
139 public ExpandoRow getRow(String className, String tableName, long classPK)
140 throws SystemException {
141
142 long classNameId = PortalUtil.getClassNameId(className);
143
144 return getRow(classNameId, tableName, classPK);
145 }
146
147 public ExpandoRow getRow(long classNameId, String tableName, long classPK)
148 throws SystemException {
149
150 return expandoRowFinder.fetchByTC_TN_C(classNameId, tableName, classPK);
151 }
152
153 public List<ExpandoRow> getRows(long tableId, int start, int end)
154 throws SystemException {
155
156 return expandoRowPersistence.findByTableId(tableId, start, end);
157 }
158
159 public List<ExpandoRow> getRows(
160 String className, String tableName, int start, int end)
161 throws SystemException {
162
163 long classNameId = PortalUtil.getClassNameId(className);
164
165 return getRows(classNameId, tableName, start, end);
166 }
167
168 public List<ExpandoRow> getRows(
169 long classNameId, String tableName, int start, int end)
170 throws SystemException {
171
172 return expandoRowFinder.findByTC_TN(
173 classNameId, tableName, start, end);
174 }
175
176 public int getRowsCount(long tableId) throws SystemException {
177 return expandoRowPersistence.countByTableId(tableId);
178 }
179
180 public int getRowsCount(String className, String tableName)
181 throws SystemException {
182
183 long classNameId = PortalUtil.getClassNameId(className);
184
185 return getRowsCount(classNameId, tableName);
186 }
187
188 public int getRowsCount(long classNameId, String tableName)
189 throws SystemException {
190
191 return expandoRowFinder.countByTC_TN(classNameId, tableName);
192 }
193
194 }