1
19
20 package com.liferay.portlet.expando.service.impl;
21
22 import com.liferay.portal.PortalException;
23 import com.liferay.portal.SystemException;
24 import com.liferay.portal.util.PortalUtil;
25 import com.liferay.portlet.expando.model.ExpandoRow;
26 import com.liferay.portlet.expando.model.ExpandoTable;
27 import com.liferay.portlet.expando.model.ExpandoTableConstants;
28 import com.liferay.portlet.expando.service.base.ExpandoRowLocalServiceBaseImpl;
29
30 import java.util.List;
31
32
38 public class ExpandoRowLocalServiceImpl extends ExpandoRowLocalServiceBaseImpl {
39
40 public ExpandoRow addRow(long tableId, long classPK)
41 throws SystemException {
42
43 long rowId = counterLocalService.increment();
44
45 ExpandoRow row = expandoRowPersistence.create(rowId);
46
47 row.setTableId(tableId);
48 row.setClassPK(classPK);
49
50 expandoRowPersistence.update(row, false);
51
52 return row;
53 }
54
55 public void deleteRow(long rowId)
56 throws PortalException, SystemException {
57
58
60 expandoValueLocalService.deleteRowValues(rowId);
61
62
64 expandoRowPersistence.remove(rowId);
65 }
66
67 public void deleteRow(long tableId, long classPK)
68 throws PortalException, SystemException {
69
70 ExpandoRow row = expandoRowPersistence.findByT_C(tableId, classPK);
71
72 deleteRow(row.getRowId());
73 }
74
75 public void deleteRow(String className, String tableName, long classPK)
76 throws PortalException, SystemException {
77
78 long classNameId = PortalUtil.getClassNameId(className);
79
80 deleteRow(classNameId, tableName, classPK);
81 }
82
83 public void deleteRow(long classNameId, String tableName, long classPK)
84 throws PortalException, SystemException {
85
86 ExpandoTable table = expandoTableLocalService.getTable(
87 classNameId, tableName);
88
89 deleteRow(table.getTableId(), classPK);
90 }
91
92 public List<ExpandoRow> getDefaultTableRows(
93 String className, int start, int end)
94 throws SystemException {
95
96 long classNameId = PortalUtil.getClassNameId(className);
97
98 return getDefaultTableRows(classNameId, start, end);
99 }
100
101 public List<ExpandoRow> getDefaultTableRows(
102 long classNameId, int start, int end)
103 throws SystemException {
104
105 return expandoRowFinder.findByTC_TN(
106 classNameId, ExpandoTableConstants.DEFAULT_TABLE_NAME, start, end);
107 }
108
109 public int getDefaultTableRowsCount(String className)
110 throws SystemException {
111
112 long classNameId = PortalUtil.getClassNameId(className);
113
114 return getDefaultTableRowsCount(classNameId);
115 }
116
117 public int getDefaultTableRowsCount(long classNameId)
118 throws SystemException {
119
120 return expandoRowFinder.countByTC_TN(
121 classNameId, ExpandoTableConstants.DEFAULT_TABLE_NAME);
122 }
123
124 public ExpandoRow getRow(long rowId)
125 throws PortalException, SystemException {
126
127 return expandoRowPersistence.findByPrimaryKey(rowId);
128 }
129
130 public ExpandoRow getRow(long tableId, long classPK)
131 throws PortalException, SystemException {
132
133 return expandoRowPersistence.findByT_C(tableId, classPK);
134 }
135
136 public ExpandoRow getRow(String className, String tableName, long classPK)
137 throws SystemException {
138
139 long classNameId = PortalUtil.getClassNameId(className);
140
141 return getRow(classNameId, tableName, classPK);
142 }
143
144 public ExpandoRow getRow(long classNameId, String tableName, long classPK)
145 throws SystemException {
146
147 return expandoRowFinder.fetchByTC_TN_C(classNameId, tableName, classPK);
148 }
149
150 public List<ExpandoRow> getRows(long tableId, int start, int end)
151 throws SystemException {
152
153 return expandoRowPersistence.findByTableId(tableId, start, end);
154 }
155
156 public List<ExpandoRow> getRows(
157 String className, String tableName, int start, int end)
158 throws SystemException {
159
160 long classNameId = PortalUtil.getClassNameId(className);
161
162 return getRows(classNameId, tableName, start, end);
163 }
164
165 public List<ExpandoRow> getRows(
166 long classNameId, String tableName, int start, int end)
167 throws SystemException {
168
169 return expandoRowFinder.findByTC_TN(
170 classNameId, tableName, start, end);
171 }
172
173 public int getRowsCount(long tableId) throws SystemException {
174 return expandoRowPersistence.countByTableId(tableId);
175 }
176
177 public int getRowsCount(String className, String tableName)
178 throws SystemException {
179
180 long classNameId = PortalUtil.getClassNameId(className);
181
182 return getRowsCount(classNameId, tableName);
183 }
184
185 public int getRowsCount(long classNameId, String tableName)
186 throws SystemException {
187
188 return expandoRowFinder.countByTC_TN(classNameId, tableName);
189 }
190
191 }