001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
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.ExpandoColumn;
022    import com.liferay.portlet.expando.model.ExpandoColumnConstants;
023    import com.liferay.portlet.expando.model.ExpandoRow;
024    import com.liferay.portlet.expando.model.ExpandoTable;
025    import com.liferay.portlet.expando.model.ExpandoTableConstants;
026    import com.liferay.portlet.expando.model.ExpandoValue;
027    import com.liferay.portlet.expando.model.impl.ExpandoValueImpl;
028    import com.liferay.portlet.expando.service.base.ExpandoValueLocalServiceBaseImpl;
029    
030    import java.io.Serializable;
031    
032    import java.util.Collections;
033    import java.util.Date;
034    import java.util.List;
035    import java.util.Map;
036    
037    /**
038     * @author Raymond Augé
039     * @author Brian Wing Shun Chan
040     */
041    public class ExpandoValueLocalServiceImpl
042            extends ExpandoValueLocalServiceBaseImpl {
043    
044            public ExpandoValue addValue(
045                            long classNameId, long tableId, long columnId, long classPK,
046                            String data)
047                    throws PortalException, SystemException {
048    
049                    ExpandoTable table = expandoTablePersistence.findByPrimaryKey(tableId);
050    
051                    ExpandoRow row = expandoRowPersistence.fetchByT_C(tableId, classPK);
052    
053                    if (row == null) {
054                            long rowId = counterLocalService.increment();
055    
056                            row = expandoRowPersistence.create(rowId);
057    
058                            row.setCompanyId(table.getCompanyId());
059                            row.setTableId(tableId);
060                            row.setClassPK(classPK);
061    
062                            expandoRowPersistence.update(row, false);
063                    }
064    
065                    ExpandoValue value = expandoValuePersistence.fetchByC_R(
066                            columnId, row.getRowId());
067    
068                    if (value == null) {
069                            long valueId = counterLocalService.increment();
070    
071                            value = expandoValuePersistence.create(valueId);
072    
073                            value.setCompanyId(table.getCompanyId());
074                            value.setTableId(tableId);
075                            value.setColumnId(columnId);
076                            value.setRowId(row.getRowId());
077                            value.setClassNameId(classNameId);
078                            value.setClassPK(classPK);
079                    }
080    
081                    value.setData(data);
082    
083                    expandoValuePersistence.update(value, false);
084    
085                    return value;
086            }
087    
088            public ExpandoValue addValue(
089                            long companyId, String className, String tableName,
090                            String columnName, long classPK, boolean data)
091                    throws PortalException, SystemException {
092    
093                    ExpandoTable table = expandoTableLocalService.getTable(
094                            companyId, className, tableName);
095    
096                    ExpandoColumn column = expandoColumnLocalService.getColumn(
097                            table.getTableId(), columnName);
098    
099                    ExpandoValue value = new ExpandoValueImpl();
100    
101                    value.setCompanyId(table.getCompanyId());
102                    value.setColumnId(column.getColumnId());
103                    value.setBoolean(data);
104    
105                    return addValue(
106                            table.getClassNameId(), table.getTableId(), column.getColumnId(),
107                            classPK, value.getData());
108            }
109    
110            public ExpandoValue addValue(
111                            long companyId, String className, String tableName,
112                            String columnName, long classPK, boolean[] data)
113                    throws PortalException, SystemException {
114    
115                    ExpandoTable table = expandoTableLocalService.getTable(
116                            companyId, className, tableName);
117    
118                    ExpandoColumn column = expandoColumnLocalService.getColumn(
119                            table.getTableId(), columnName);
120    
121                    ExpandoValue value = new ExpandoValueImpl();
122    
123                    value.setCompanyId(table.getCompanyId());
124                    value.setColumnId(column.getColumnId());
125                    value.setBooleanArray(data);
126    
127                    return addValue(
128                            table.getClassNameId(), table.getTableId(), column.getColumnId(),
129                            classPK, value.getData());
130            }
131    
132            public ExpandoValue addValue(
133                            long companyId, String className, String tableName,
134                            String columnName, long classPK, Date data)
135                    throws PortalException, SystemException {
136    
137                    ExpandoTable table = expandoTableLocalService.getTable(
138                            companyId, className, tableName);
139    
140                    ExpandoColumn column = expandoColumnLocalService.getColumn(
141                            table.getTableId(), columnName);
142    
143                    ExpandoValue value = new ExpandoValueImpl();
144    
145                    value.setCompanyId(table.getCompanyId());
146                    value.setColumnId(column.getColumnId());
147                    value.setDate(data);
148    
149                    return addValue(
150                            table.getClassNameId(), table.getTableId(), column.getColumnId(),
151                            classPK, value.getData());
152            }
153    
154            public ExpandoValue addValue(
155                            long companyId, String className, String tableName,
156                            String columnName, long classPK, Date[] data)
157                    throws PortalException, SystemException {
158    
159                    ExpandoTable table = expandoTableLocalService.getTable(
160                            companyId, className, tableName);
161    
162                    ExpandoColumn column = expandoColumnLocalService.getColumn(
163                            table.getTableId(), columnName);
164    
165                    ExpandoValue value = new ExpandoValueImpl();
166    
167                    value.setCompanyId(table.getCompanyId());
168                    value.setColumnId(column.getColumnId());
169                    value.setDateArray(data);
170    
171                    return addValue(
172                            table.getClassNameId(), table.getTableId(), column.getColumnId(),
173                            classPK, value.getData());
174            }
175    
176            public ExpandoValue addValue(
177                            long companyId, String className, String tableName,
178                            String columnName, long classPK, double data)
179                    throws PortalException, SystemException {
180    
181                    ExpandoTable table = expandoTableLocalService.getTable(
182                            companyId, className, tableName);
183    
184                    ExpandoColumn column = expandoColumnLocalService.getColumn(
185                            table.getTableId(), columnName);
186    
187                    ExpandoValue value = new ExpandoValueImpl();
188    
189                    value.setCompanyId(table.getCompanyId());
190                    value.setColumnId(column.getColumnId());
191                    value.setDouble(data);
192    
193                    return addValue(
194                            table.getClassNameId(), table.getTableId(), column.getColumnId(),
195                            classPK, value.getData());
196            }
197    
198            public ExpandoValue addValue(
199                            long companyId, String className, String tableName,
200                            String columnName, long classPK, double[] data)
201                    throws PortalException, SystemException {
202    
203                    ExpandoTable table = expandoTableLocalService.getTable(
204                            companyId, className, tableName);
205    
206                    ExpandoColumn column = expandoColumnLocalService.getColumn(
207                            table.getTableId(), columnName);
208    
209                    ExpandoValue value = new ExpandoValueImpl();
210    
211                    value.setCompanyId(table.getCompanyId());
212                    value.setColumnId(column.getColumnId());
213                    value.setDoubleArray(data);
214    
215                    return addValue(
216                            table.getClassNameId(), table.getTableId(), column.getColumnId(),
217                            classPK, value.getData());
218            }
219    
220            public ExpandoValue addValue(
221                            long companyId, String className, String tableName,
222                            String columnName, long classPK, float data)
223                    throws PortalException, SystemException {
224    
225                    ExpandoTable table = expandoTableLocalService.getTable(
226                            companyId, className, tableName);
227    
228                    ExpandoColumn column = expandoColumnLocalService.getColumn(
229                            table.getTableId(), columnName);
230    
231                    ExpandoValue value = new ExpandoValueImpl();
232    
233                    value.setCompanyId(table.getCompanyId());
234                    value.setColumnId(column.getColumnId());
235                    value.setFloat(data);
236    
237                    return addValue(
238                            table.getClassNameId(), table.getTableId(), column.getColumnId(),
239                            classPK, value.getData());
240            }
241    
242            public ExpandoValue addValue(
243                            long companyId, String className, String tableName,
244                            String columnName, long classPK, float[] data)
245                    throws PortalException, SystemException {
246    
247                    ExpandoTable table = expandoTableLocalService.getTable(
248                            companyId, className, tableName);
249    
250                    ExpandoColumn column = expandoColumnLocalService.getColumn(
251                            table.getTableId(), columnName);
252    
253                    ExpandoValue value = new ExpandoValueImpl();
254    
255                    value.setCompanyId(table.getCompanyId());
256                    value.setColumnId(column.getColumnId());
257                    value.setFloatArray(data);
258    
259                    return addValue(
260                            table.getClassNameId(), table.getTableId(), column.getColumnId(),
261                            classPK, value.getData());
262            }
263    
264            public ExpandoValue addValue(
265                            long companyId, String className, String tableName,
266                            String columnName, long classPK, int data)
267                    throws PortalException, SystemException {
268    
269                    ExpandoTable table = expandoTableLocalService.getTable(
270                            companyId, className, tableName);
271    
272                    ExpandoColumn column = expandoColumnLocalService.getColumn(
273                            table.getTableId(), columnName);
274    
275                    ExpandoValue value = new ExpandoValueImpl();
276    
277                    value.setCompanyId(table.getCompanyId());
278                    value.setColumnId(column.getColumnId());
279                    value.setInteger(data);
280    
281                    return addValue(
282                            table.getClassNameId(), table.getTableId(), column.getColumnId(),
283                            classPK, value.getData());
284            }
285    
286            public ExpandoValue addValue(
287                            long companyId, String className, String tableName,
288                            String columnName, long classPK, int[] data)
289                    throws PortalException, SystemException {
290    
291                    ExpandoTable table = expandoTableLocalService.getTable(
292                            companyId, className, tableName);
293    
294                    ExpandoColumn column = expandoColumnLocalService.getColumn(
295                            table.getTableId(), columnName);
296    
297                    ExpandoValue value = new ExpandoValueImpl();
298    
299                    value.setCompanyId(table.getCompanyId());
300                    value.setColumnId(column.getColumnId());
301                    value.setIntegerArray(data);
302    
303                    return addValue(
304                            table.getClassNameId(), table.getTableId(), column.getColumnId(),
305                            classPK, value.getData());
306            }
307    
308            public ExpandoValue addValue(
309                            long companyId, String className, String tableName,
310                            String columnName, long classPK, long data)
311                    throws PortalException, SystemException {
312    
313                    ExpandoTable table = expandoTableLocalService.getTable(
314                            companyId, className, tableName);
315    
316                    ExpandoColumn column = expandoColumnLocalService.getColumn(
317                            table.getTableId(), columnName);
318    
319                    ExpandoValue value = new ExpandoValueImpl();
320    
321                    value.setCompanyId(table.getCompanyId());
322                    value.setColumnId(column.getColumnId());
323                    value.setLong(data);
324    
325                    return addValue(
326                            table.getClassNameId(), table.getTableId(), column.getColumnId(),
327                            classPK, value.getData());
328            }
329    
330            public ExpandoValue addValue(
331                            long companyId, String className, String tableName,
332                            String columnName, long classPK, long[] data)
333                    throws PortalException, SystemException {
334    
335                    ExpandoTable table = expandoTableLocalService.getTable(
336                            companyId, className, tableName);
337    
338                    ExpandoColumn column = expandoColumnLocalService.getColumn(
339                            table.getTableId(), columnName);
340    
341                    ExpandoValue value = new ExpandoValueImpl();
342    
343                    value.setCompanyId(table.getCompanyId());
344                    value.setColumnId(column.getColumnId());
345                    value.setLongArray(data);
346    
347                    return addValue(
348                            table.getClassNameId(), table.getTableId(), column.getColumnId(),
349                            classPK, value.getData());
350            }
351    
352            public ExpandoValue addValue(
353                            long companyId, String className, String tableName,
354                            String columnName, long classPK, Object data)
355                    throws PortalException, SystemException {
356    
357                    ExpandoColumn column = expandoColumnLocalService.getColumn(
358                            companyId, className, tableName, columnName);
359    
360                    int type = column.getType();
361    
362                    if (type == ExpandoColumnConstants.BOOLEAN) {
363                            return addValue(
364                                    companyId, className, tableName, columnName, classPK,
365                                    ((Boolean)data).booleanValue());
366                    }
367                    else if (type == ExpandoColumnConstants.BOOLEAN_ARRAY) {
368                            return addValue(
369                                    companyId, className, tableName, columnName, classPK,
370                                    (boolean[])data);
371                    }
372                    else if (type == ExpandoColumnConstants.DATE) {
373                            return addValue(
374                                    companyId, className, tableName, columnName, classPK,
375                                    (Date)data);
376                    }
377                    else if (type == ExpandoColumnConstants.DATE_ARRAY) {
378                            return addValue(
379                                    companyId, className, tableName, columnName, classPK,
380                                    (Date[])data);
381                    }
382                    else if (type == ExpandoColumnConstants.DOUBLE) {
383                            return addValue(
384                                    companyId, className, tableName, columnName, classPK,
385                                    ((Double)data).doubleValue());
386                    }
387                    else if (type == ExpandoColumnConstants.DOUBLE_ARRAY) {
388                            return addValue(
389                                    companyId, className, tableName, columnName, classPK,
390                                    (double[])data);
391                    }
392                    else if (type == ExpandoColumnConstants.FLOAT) {
393                            return addValue(
394                                    companyId, className, tableName, columnName, classPK,
395                                    ((Float)data).floatValue());
396                    }
397                    else if (type == ExpandoColumnConstants.FLOAT_ARRAY) {
398                            return addValue(
399                                    companyId, className, tableName, columnName, classPK,
400                                    (float[])data);
401                    }
402                    else if (type == ExpandoColumnConstants.INTEGER) {
403                            return addValue(
404                                    companyId, className, tableName, columnName, classPK,
405                                    ((Integer)data).intValue());
406                    }
407                    else if (type == ExpandoColumnConstants.INTEGER_ARRAY) {
408                            return addValue(
409                                    companyId, className, tableName, columnName, classPK,
410                                    (int[])data);
411                    }
412                    else if (type == ExpandoColumnConstants.LONG) {
413                            return addValue(
414                                    companyId, className, tableName, columnName, classPK,
415                                    ((Long)data).longValue());
416                    }
417                    else if (type == ExpandoColumnConstants.LONG_ARRAY) {
418                            return addValue(
419                                    companyId, className, tableName, columnName, classPK,
420                                    (long[])data);
421                    }
422                    else if (type == ExpandoColumnConstants.SHORT) {
423                            return addValue(
424                                    companyId, className, tableName, columnName, classPK,
425                                    ((Short)data).shortValue());
426                    }
427                    else if (type == ExpandoColumnConstants.SHORT_ARRAY) {
428                            return addValue(
429                                    companyId, className, tableName, columnName, classPK,
430                                    (short[])data);
431                    }
432                    else if (type == ExpandoColumnConstants.STRING_ARRAY) {
433                            return addValue(
434                                    companyId, className, tableName, columnName, classPK,
435                                    (String[])data);
436                    }
437                    else {
438                            return addValue(
439                                    companyId, className, tableName, columnName, classPK,
440                                    (String)data);
441                    }
442            }
443    
444            public ExpandoValue addValue(
445                            long companyId, String className, String tableName,
446                            String columnName, long classPK, short data)
447                    throws PortalException, SystemException {
448    
449                    ExpandoTable table = expandoTableLocalService.getTable(
450                            companyId, className, tableName);
451    
452                    ExpandoColumn column = expandoColumnLocalService.getColumn(
453                            table.getTableId(), columnName);
454    
455                    ExpandoValue value = new ExpandoValueImpl();
456    
457                    value.setCompanyId(table.getCompanyId());
458                    value.setColumnId(column.getColumnId());
459                    value.setShort(data);
460    
461                    return addValue(
462                            table.getClassNameId(), table.getTableId(), column.getColumnId(),
463                            classPK, value.getData());
464            }
465    
466            public ExpandoValue addValue(
467                            long companyId, String className, String tableName,
468                            String columnName, long classPK, short[] data)
469                    throws PortalException, SystemException {
470    
471                    ExpandoTable table = expandoTableLocalService.getTable(
472                            companyId, className, tableName);
473    
474                    ExpandoColumn column = expandoColumnLocalService.getColumn(
475                            table.getTableId(), columnName);
476    
477                    ExpandoValue value = new ExpandoValueImpl();
478    
479                    value.setCompanyId(table.getCompanyId());
480                    value.setColumnId(column.getColumnId());
481                    value.setShortArray(data);
482    
483                    return addValue(
484                            table.getClassNameId(), table.getTableId(), column.getColumnId(),
485                            classPK, value.getData());
486            }
487    
488            public ExpandoValue addValue(
489                            long companyId, String className, String tableName,
490                            String columnName, long classPK, String data)
491                    throws PortalException, SystemException {
492    
493                    ExpandoTable table = expandoTableLocalService.getTable(
494                            companyId, className, tableName);
495    
496                    ExpandoColumn column = expandoColumnLocalService.getColumn(
497                            table.getTableId(), columnName);
498    
499                    ExpandoValue value = new ExpandoValueImpl();
500    
501                    value.setCompanyId(table.getCompanyId());
502                    value.setColumnId(column.getColumnId());
503                    value.setString(data);
504    
505                    return addValue(
506                            table.getClassNameId(), table.getTableId(), column.getColumnId(),
507                            classPK, value.getData());
508            }
509    
510            public ExpandoValue addValue(
511                            long companyId, String className, String tableName,
512                            String columnName, long classPK, String[] data)
513                    throws PortalException, SystemException {
514    
515                    ExpandoTable table = expandoTableLocalService.getTable(
516                            companyId, className, tableName);
517    
518                    ExpandoColumn column = expandoColumnLocalService.getColumn(
519                            table.getTableId(), columnName);
520    
521                    ExpandoValue value = new ExpandoValueImpl();
522    
523                    value.setCompanyId(table.getCompanyId());
524                    value.setColumnId(column.getColumnId());
525                    value.setStringArray(data);
526    
527                    return addValue(
528                            table.getClassNameId(), table.getTableId(), column.getColumnId(),
529                            classPK, value.getData());
530            }
531    
532            /**
533             * @deprecated {@link #addValue(long, String, String, String, long,
534             *                         boolean[])}
535             */
536            public ExpandoValue addValue(
537                            String className, String tableName, String columnName, long classPK,
538                            boolean data)
539                    throws PortalException, SystemException {
540    
541                    long companyId = CompanyThreadLocal.getCompanyId();
542    
543                    return addValue(
544                            companyId, className, tableName, columnName, classPK, data);
545            }
546    
547            /**
548             * @deprecated {@link #addValue(long, String, String, String, long,
549             *                         boolean[])}
550             */
551            public ExpandoValue addValue(
552                            String className, String tableName, String columnName, long classPK,
553                            boolean[] data)
554                    throws PortalException, SystemException {
555    
556                    long companyId = CompanyThreadLocal.getCompanyId();
557    
558                    return addValue(
559                            companyId, className, tableName, columnName, classPK, data);
560            }
561    
562            /**
563             * @deprecated {@link #addValue(long, String, String, String, long, Date[])}
564             */
565            public ExpandoValue addValue(
566                            String className, String tableName, String columnName, long classPK,
567                            Date data)
568                    throws PortalException, SystemException {
569    
570                    long companyId = CompanyThreadLocal.getCompanyId();
571    
572                    return addValue(
573                            companyId, className, tableName, columnName, classPK, data);
574            }
575    
576            /**
577             * @deprecated {@link #addValue(long, String, String, String, long, Date[])}
578             */
579            public ExpandoValue addValue(
580                            String className, String tableName, String columnName, long classPK,
581                            Date[] data)
582                    throws PortalException, SystemException {
583    
584                    long companyId = CompanyThreadLocal.getCompanyId();
585    
586                    return addValue(
587                            companyId, className, tableName, columnName, classPK, data);
588            }
589    
590            /**
591             * @deprecated {@link #addValue(long, String, String, String, long,
592             *                         double[])}
593             */
594            public ExpandoValue addValue(
595                            String className, String tableName, String columnName, long classPK,
596                            double data)
597                    throws PortalException, SystemException {
598    
599                    long companyId = CompanyThreadLocal.getCompanyId();
600    
601                    return addValue(
602                            companyId, className, tableName, columnName, classPK, data);
603            }
604    
605            /**
606             * @deprecated {@link #addValue(long, String, String, String, long,
607             *                         double[])}
608             */
609            public ExpandoValue addValue(
610                            String className, String tableName, String columnName, long classPK,
611                            double[] data)
612                    throws PortalException, SystemException {
613    
614                    long companyId = CompanyThreadLocal.getCompanyId();
615    
616                    return addValue(
617                            companyId, className, tableName, columnName, classPK, data);
618            }
619    
620            /**
621             * @deprecated {@link #addValue(long, String, String, String, long,
622             *                         float[])}
623             */
624            public ExpandoValue addValue(
625                            String className, String tableName, String columnName, long classPK,
626                            float data)
627                    throws PortalException, SystemException {
628    
629                    long companyId = CompanyThreadLocal.getCompanyId();
630    
631                    return addValue(
632                            companyId, className, tableName, columnName, classPK, data);
633            }
634    
635            /**
636             * @deprecated {@link #addValue(long, String, String, String, long,
637             *                         float[])}
638             */
639            public ExpandoValue addValue(
640                            String className, String tableName, String columnName, long classPK,
641                            float[] data)
642                    throws PortalException, SystemException {
643    
644                    long companyId = CompanyThreadLocal.getCompanyId();
645    
646                    return addValue(
647                            companyId, className, tableName, columnName, classPK, data);
648            }
649    
650            /**
651             * @deprecated {@link #addValue(long, String, String, String, long, int[])}
652             */
653            public ExpandoValue addValue(
654                            String className, String tableName, String columnName, long classPK,
655                            int data)
656                    throws PortalException, SystemException {
657    
658                    long companyId = CompanyThreadLocal.getCompanyId();
659    
660                    return addValue(
661                            companyId, className, tableName, columnName, classPK, data);
662            }
663    
664            /**
665             * @deprecated {@link #addValue(long, String, String, String, long, int[])}
666             */
667            public ExpandoValue addValue(
668                            String className, String tableName, String columnName, long classPK,
669                            int[] data)
670                    throws PortalException, SystemException {
671    
672                    long companyId = CompanyThreadLocal.getCompanyId();
673    
674                    return addValue(
675                            companyId, className, tableName, columnName, classPK, data);
676            }
677    
678            /**
679             * @deprecated {@link #addValue(long, String, String, String, long, long[])}
680             */
681            public ExpandoValue addValue(
682                            String className, String tableName, String columnName, long classPK,
683                            long data)
684                    throws PortalException, SystemException {
685    
686                    long companyId = CompanyThreadLocal.getCompanyId();
687    
688                    return addValue(
689                            companyId, className, tableName, columnName, classPK, data);
690            }
691    
692            /**
693             * @deprecated {@link #addValue(long, String, String, String, long, long[])}
694             */
695            public ExpandoValue addValue(
696                            String className, String tableName, String columnName, long classPK,
697                            long[] data)
698                    throws PortalException, SystemException {
699    
700                    long companyId = CompanyThreadLocal.getCompanyId();
701    
702                    return addValue(
703                            companyId, className, tableName, columnName, classPK, data);
704            }
705    
706            /**
707             * @deprecated {@link #addValue(long, String, String, String, long, Object)}
708             */
709            public ExpandoValue addValue(
710                            String className, String tableName, String columnName, long classPK,
711                            Object data)
712                    throws PortalException, SystemException {
713    
714                    long companyId = CompanyThreadLocal.getCompanyId();
715    
716                    return addValue(
717                            companyId, className, tableName, columnName, classPK, data);
718            }
719    
720            /**
721             * @deprecated {@link #addValue(long, String, String, String, long,
722             *                         short[])}
723             */
724            public ExpandoValue addValue(
725                            String className, String tableName, String columnName, long classPK,
726                            short data)
727                    throws PortalException, SystemException {
728    
729                    long companyId = CompanyThreadLocal.getCompanyId();
730    
731                    return addValue(
732                            companyId, className, tableName, columnName, classPK, data);
733            }
734    
735            /**
736             * @deprecated {@link #addValue(long, String, String, String, long,
737             *                         short[])}
738             */
739            public ExpandoValue addValue(
740                            String className, String tableName, String columnName, long classPK,
741                            short[] data)
742                    throws PortalException, SystemException {
743    
744                    long companyId = CompanyThreadLocal.getCompanyId();
745    
746                    return addValue(
747                            companyId, className, tableName, columnName, classPK, data);
748            }
749    
750            /**
751             * @deprecated {@link #addValue(long, String, String, String, long,
752             *                         String[])}
753             */
754            public ExpandoValue addValue(
755                            String className, String tableName, String columnName, long classPK,
756                            String data)
757                    throws PortalException, SystemException {
758    
759                    long companyId = CompanyThreadLocal.getCompanyId();
760    
761                    return addValue(
762                            companyId, className, tableName, columnName, classPK, data);
763            }
764    
765            /**
766             * @deprecated {@link #addValue(long, String, String, String, long,
767             *                         String[])}
768             */
769            public ExpandoValue addValue(
770                            String className, String tableName, String columnName, long classPK,
771                            String[] data)
772                    throws PortalException, SystemException {
773    
774                    long companyId = CompanyThreadLocal.getCompanyId();
775    
776                    return addValue(
777                            companyId, className, tableName, columnName, classPK, data);
778            }
779    
780            public void addValues(
781                            long classNameId, long tableId, List<ExpandoColumn> columns,
782                            long classPK, Map<String, String> data)
783                    throws PortalException, SystemException {
784    
785                    ExpandoTable table = expandoTablePersistence.findByPrimaryKey(tableId);
786    
787                    ExpandoRow row = expandoRowPersistence.fetchByT_C(tableId, classPK);
788    
789                    if (row == null) {
790                            long rowId = counterLocalService.increment();
791    
792                            row = expandoRowPersistence.create(rowId);
793    
794                            row.setCompanyId(table.getCompanyId());
795                            row.setTableId(tableId);
796                            row.setClassPK(classPK);
797    
798                            expandoRowPersistence.update(row, false);
799                    }
800    
801                    for (ExpandoColumn column : columns) {
802                            if (data.containsKey(column.getName())) {
803                                    ExpandoValue value = expandoValuePersistence.fetchByC_R(
804                                            column.getColumnId(), row.getRowId());
805    
806                                    if (value == null) {
807                                            long valueId = counterLocalService.increment();
808    
809                                            value = expandoValuePersistence.create(valueId);
810    
811                                            value.setCompanyId(table.getCompanyId());
812                                            value.setTableId(tableId);
813                                            value.setColumnId(column.getColumnId());
814                                            value.setRowId(row.getRowId());
815                                            value.setClassNameId(classNameId);
816                                            value.setClassPK(classPK);
817                                    }
818    
819                                    value.setData(data.get(column.getName()));
820    
821                                    expandoValuePersistence.update(value, false);
822                            }
823                    }
824            }
825    
826            public void deleteColumnValues(long columnId) throws SystemException {
827                    expandoValuePersistence.removeByColumnId(columnId);
828            }
829    
830            public void deleteRowValues(long rowId) throws SystemException {
831                    expandoValuePersistence.removeByRowId(rowId);
832            }
833    
834            public void deleteTableValues(long tableId) throws SystemException {
835                    expandoValuePersistence.removeByTableId(tableId);
836            }
837    
838            public void deleteValue(long valueId)
839                    throws PortalException, SystemException {
840    
841                    expandoValuePersistence.remove(valueId);
842            }
843    
844            public void deleteValue(long columnId, long rowId)
845                    throws PortalException, SystemException {
846    
847                    expandoValuePersistence.removeByC_R(columnId, rowId);
848            }
849    
850            public void deleteValue(
851                            long companyId, long classNameId, String tableName,
852                            String columnName, long classPK)
853                    throws PortalException, SystemException {
854    
855                    ExpandoTable table = expandoTablePersistence.fetchByC_C_N(
856                            companyId, classNameId, tableName);
857    
858                    if (table == null) {
859                            return;
860                    }
861    
862                    ExpandoColumn column = expandoColumnPersistence.fetchByT_N(
863                            table.getTableId(), columnName);
864    
865                    if (column == null) {
866                            return;
867                    }
868    
869                    ExpandoValue value = expandoValuePersistence.fetchByT_C_C(
870                            table.getTableId(), column.getColumnId(), classPK);
871    
872                    if (value != null) {
873                            deleteValue(value.getValueId());
874                    }
875            }
876    
877            public void deleteValue(
878                            long companyId, String className, String tableName,
879                            String columnName, long classPK)
880                    throws PortalException, SystemException {
881    
882                    long classNameId = PortalUtil.getClassNameId(className);
883    
884                    deleteValue(companyId, classNameId, tableName, columnName, classPK);
885            }
886    
887            public void deleteValues(long classNameId, long classPK)
888                    throws SystemException {
889    
890                    expandoValuePersistence.removeByC_C(classNameId, classPK);
891            }
892    
893            public void deleteValues(String className, long classPK)
894                    throws SystemException {
895    
896                    long classNameId = PortalUtil.getClassNameId(className);
897    
898                    deleteValues(classNameId, classPK);
899            }
900    
901            public List<ExpandoValue> getColumnValues(long columnId, int start, int end)
902                    throws SystemException {
903    
904                    return expandoValuePersistence.findByColumnId(columnId, start, end);
905            }
906    
907            public List<ExpandoValue> getColumnValues(
908                            long companyId, long classNameId, String tableName,
909                            String columnName, int start, int end)
910                    throws SystemException {
911    
912                    ExpandoTable table = expandoTablePersistence.fetchByC_C_N(
913                            companyId, classNameId, tableName);
914    
915                    if (table == null) {
916                            return Collections.EMPTY_LIST;
917                    }
918    
919                    ExpandoColumn column = expandoColumnPersistence.fetchByT_N(
920                            table.getTableId(), columnName);
921    
922                    if (column == null) {
923                            return Collections.EMPTY_LIST;
924                    }
925    
926                    return expandoValuePersistence.findByT_C(
927                            table.getTableId(), column.getColumnId(), start, end);
928            }
929    
930            public List<ExpandoValue> getColumnValues(
931                            long companyId, long classNameId, String tableName,
932                            String columnName, String data, int start, int end)
933                    throws SystemException {
934    
935                    ExpandoTable table = expandoTablePersistence.fetchByC_C_N(
936                            companyId, classNameId, tableName);
937    
938                    if (table == null) {
939                            return Collections.EMPTY_LIST;
940                    }
941    
942                    ExpandoColumn column = expandoColumnPersistence.fetchByT_N(
943                            table.getTableId(), columnName);
944    
945                    if (column == null) {
946                            return Collections.EMPTY_LIST;
947                    }
948    
949                    return expandoValuePersistence.findByT_C_D(
950                            table.getTableId(), column.getColumnId(), data, start, end);
951            }
952    
953            public List<ExpandoValue> getColumnValues(
954                            long companyId, String className, String tableName,
955                            String columnName, int start, int end)
956                    throws SystemException {
957    
958                    long classNameId = PortalUtil.getClassNameId(className);
959    
960                    return getColumnValues(
961                            companyId, classNameId, tableName, columnName, start, end);
962            }
963    
964            public List<ExpandoValue> getColumnValues(
965                            String className, String tableName, String columnName, String data,
966                            int start, int end)
967                    throws SystemException {
968    
969                    long classNameId = PortalUtil.getClassNameId(className);
970    
971                    return getColumnValues(
972                            classNameId, tableName, columnName, data, start, end);
973            }
974    
975            public int getColumnValuesCount(long columnId) throws SystemException {
976                    return expandoValuePersistence.countByColumnId(columnId);
977            }
978    
979            public int getColumnValuesCount(
980                            long companyId, long classNameId, String tableName,
981                            String columnName)
982                    throws SystemException {
983    
984                    ExpandoTable table = expandoTablePersistence.fetchByC_C_N(
985                            companyId, classNameId, tableName);
986    
987                    if (table == null) {
988                            return 0;
989                    }
990    
991                    ExpandoColumn column = expandoColumnPersistence.fetchByT_N(
992                            table.getTableId(), columnName);
993    
994                    if (column == null) {
995                            return 0;
996                    }
997    
998                    return expandoValuePersistence.countByT_C(
999                            table.getTableId(), column.getColumnId());
1000            }
1001    
1002            public int getColumnValuesCount(
1003                            long companyId, long classNameId, String tableName,
1004                            String columnName, String data)
1005                    throws SystemException {
1006    
1007                    ExpandoTable table = expandoTablePersistence.fetchByC_C_N(
1008                            companyId, classNameId, tableName);
1009    
1010                    if (table == null) {
1011                            return 0;
1012                    }
1013    
1014                    ExpandoColumn column = expandoColumnPersistence.fetchByT_N(
1015                            table.getTableId(), columnName);
1016    
1017                    if (column == null) {
1018                            return 0;
1019                    }
1020    
1021                    return expandoValuePersistence.countByT_C_D(
1022                            table.getTableId(), column.getColumnId(), data);
1023            }
1024    
1025            public int getColumnValuesCount(
1026                            long companyId, String className, String tableName,
1027                            String columnName)
1028                    throws SystemException {
1029    
1030                    long classNameId = PortalUtil.getClassNameId(className);
1031    
1032                    return getColumnValuesCount(
1033                            companyId, classNameId, tableName, columnName);
1034            }
1035    
1036            public int getColumnValuesCount(
1037                            String className, String tableName, String columnName, String data)
1038                    throws SystemException {
1039    
1040                    long classNameId = PortalUtil.getClassNameId(className);
1041    
1042                    return getColumnValuesCount(classNameId, tableName, columnName, data);
1043            }
1044    
1045            public Serializable getData(
1046                            long companyId, String className, String tableName,
1047                            String columnName, long classPK)
1048                    throws PortalException, SystemException {
1049    
1050                    ExpandoColumn column = expandoColumnLocalService.getColumn(
1051                            companyId, className, tableName, columnName);
1052    
1053                    ExpandoValue value = new ExpandoValueImpl();
1054    
1055                    value.setColumnId(column.getColumnId());
1056                    value.setData(column.getDefaultData());
1057    
1058                    int type = column.getType();
1059    
1060                    if (type == ExpandoColumnConstants.BOOLEAN) {
1061                            return getData(
1062                                    companyId, className, tableName, columnName, classPK,
1063                                    value.getBoolean());
1064                    }
1065                    else if (type == ExpandoColumnConstants.BOOLEAN_ARRAY) {
1066                            return getData(
1067                                    companyId, className, tableName, columnName, classPK,
1068                                    value.getBooleanArray());
1069                    }
1070                    else if (type == ExpandoColumnConstants.DATE) {
1071                            return getData(
1072                                    companyId, className, tableName, columnName, classPK,
1073                                    value.getDate());
1074                    }
1075                    else if (type == ExpandoColumnConstants.DATE_ARRAY) {
1076                            return getData(
1077                                    companyId, className, tableName, columnName, classPK,
1078                                    value.getDateArray());
1079                    }
1080                    else if (type == ExpandoColumnConstants.DOUBLE) {
1081                            return getData(
1082                                    companyId, className, tableName, columnName, classPK,
1083                                    value.getDouble());
1084                    }
1085                    else if (type == ExpandoColumnConstants.DOUBLE_ARRAY) {
1086                            return getData(
1087                                    companyId, className, tableName, columnName, classPK,
1088                                    value.getDoubleArray());
1089                    }
1090                    else if (type == ExpandoColumnConstants.FLOAT) {
1091                            return getData(
1092                                    companyId, className, tableName, columnName, classPK,
1093                                    value.getFloat());
1094                    }
1095                    else if (type == ExpandoColumnConstants.FLOAT_ARRAY) {
1096                            return getData(
1097                                    companyId, className, tableName, columnName, classPK,
1098                                    value.getFloatArray());
1099                    }
1100                    else if (type == ExpandoColumnConstants.INTEGER) {
1101                            return getData(
1102                                    companyId, className, tableName, columnName, classPK,
1103                                    value.getInteger());
1104                    }
1105                    else if (type == ExpandoColumnConstants.INTEGER_ARRAY) {
1106                            return getData(
1107                                    companyId, className, tableName, columnName, classPK,
1108                                    value.getIntegerArray());
1109                    }
1110                    else if (type == ExpandoColumnConstants.LONG) {
1111                            return getData(
1112                                    companyId, className, tableName, columnName, classPK,
1113                                    value.getLong());
1114                    }
1115                    else if (type == ExpandoColumnConstants.LONG_ARRAY) {
1116                            return getData(
1117                                    companyId, className, tableName, columnName, classPK,
1118                                    value.getLongArray());
1119                    }
1120                    else if (type == ExpandoColumnConstants.SHORT) {
1121                            return getData(
1122                                    companyId, className, tableName, columnName, classPK,
1123                                    value.getShort());
1124                    }
1125                    else if (type == ExpandoColumnConstants.SHORT_ARRAY) {
1126                            return getData(
1127                                    companyId, className, tableName, columnName, classPK,
1128                                    value.getShortArray());
1129                    }
1130                    else if (type == ExpandoColumnConstants.STRING_ARRAY) {
1131                            return getData(
1132                                    companyId, className, tableName, columnName, classPK,
1133                                    value.getStringArray());
1134                    }
1135                    else {
1136                            return getData(
1137                                    companyId, className, tableName, columnName, classPK,
1138                                    value.getString());
1139                    }
1140            }
1141    
1142            public boolean getData(
1143                            long companyId, String className, String tableName,
1144                            String columnName, long classPK, boolean defaultData)
1145                    throws PortalException, SystemException {
1146    
1147                    ExpandoValue value = getValue(
1148                            companyId, className, tableName, columnName, classPK);
1149    
1150                    if (value == null) {
1151                            return defaultData;
1152                    }
1153                    else {
1154                            return value.getBoolean();
1155                    }
1156            }
1157    
1158            public boolean[] getData(
1159                            long companyId, String className, String tableName,
1160                            String columnName, long classPK, boolean[] defaultData)
1161                    throws PortalException, SystemException {
1162    
1163                    ExpandoValue value = getValue(
1164                            companyId, className, tableName, columnName, classPK);
1165    
1166                    if (value == null) {
1167                            return defaultData;
1168                    }
1169                    else {
1170                            return value.getBooleanArray();
1171                    }
1172            }
1173    
1174            public Date getData(
1175                            long companyId, String className, String tableName,
1176                            String columnName, long classPK, Date defaultData)
1177                    throws PortalException, SystemException {
1178    
1179                    ExpandoValue value = getValue(
1180                            companyId, className, tableName, columnName, classPK);
1181    
1182                    if (value == null) {
1183                            return defaultData;
1184                    }
1185                    else {
1186                            return value.getDate();
1187                    }
1188            }
1189    
1190            public Date[] getData(
1191                            long companyId, String className, String tableName,
1192                            String columnName, long classPK, Date[] defaultData)
1193                    throws PortalException, SystemException {
1194    
1195                    ExpandoValue value = getValue(
1196                            companyId, className, tableName, columnName, classPK);
1197    
1198                    if (value == null) {
1199                            return defaultData;
1200                    }
1201                    else {
1202                            return value.getDateArray();
1203                    }
1204            }
1205    
1206            public double getData(
1207                            long companyId, String className, String tableName,
1208                            String columnName, long classPK, double defaultData)
1209                    throws PortalException, SystemException {
1210    
1211                    ExpandoValue value = getValue(
1212                            companyId, className, tableName, columnName, classPK);
1213    
1214                    if (value == null) {
1215                            return defaultData;
1216                    }
1217                    else {
1218                            return value.getDouble();
1219                    }
1220            }
1221    
1222            public double[] getData(
1223                            long companyId, String className, String tableName,
1224                            String columnName, long classPK, double[] defaultData)
1225                    throws PortalException, SystemException {
1226    
1227                    ExpandoValue value = getValue(
1228                            companyId, className, tableName, columnName, classPK);
1229    
1230                    if (value == null) {
1231                            return defaultData;
1232                    }
1233                    else {
1234                            return value.getDoubleArray();
1235                    }
1236            }
1237    
1238            public float getData(
1239                            long companyId, String className, String tableName,
1240                            String columnName, long classPK, float defaultData)
1241                    throws PortalException, SystemException {
1242    
1243                    ExpandoValue value = getValue(
1244                            companyId, className, tableName, columnName, classPK);
1245    
1246                    if (value == null) {
1247                            return defaultData;
1248                    }
1249                    else {
1250                            return value.getFloat();
1251                    }
1252            }
1253    
1254            public float[] getData(
1255                            long companyId, String className, String tableName,
1256                            String columnName, long classPK, float[] defaultData)
1257                    throws PortalException, SystemException {
1258    
1259                    ExpandoValue value = getValue(
1260                            companyId, className, tableName, columnName, classPK);
1261    
1262                    if (value == null) {
1263                            return defaultData;
1264                    }
1265                    else {
1266                            return value.getFloatArray();
1267                    }
1268            }
1269    
1270            public int getData(
1271                            long companyId, String className, String tableName,
1272                            String columnName, long classPK, int defaultData)
1273                    throws PortalException, SystemException {
1274    
1275                    ExpandoValue value = getValue(
1276                            companyId, className, tableName, columnName, classPK);
1277    
1278                    if (value == null) {
1279                            return defaultData;
1280                    }
1281                    else {
1282                            return value.getInteger();
1283                    }
1284            }
1285    
1286            public int[] getData(
1287                            long companyId, String className, String tableName,
1288                            String columnName, long classPK, int[] defaultData)
1289                    throws PortalException, SystemException {
1290    
1291                    ExpandoValue value = getValue(
1292                            companyId, className, tableName, columnName, classPK);
1293    
1294                    if (value == null) {
1295                            return defaultData;
1296                    }
1297                    else {
1298                            return value.getIntegerArray();
1299                    }
1300            }
1301    
1302            public long getData(
1303                            long companyId, String className, String tableName,
1304                            String columnName, long classPK, long defaultData)
1305                    throws PortalException, SystemException {
1306    
1307                    ExpandoValue value = getValue(
1308                            companyId, className, tableName, columnName, classPK);
1309    
1310                    if (value == null) {
1311                            return defaultData;
1312                    }
1313                    else {
1314                            return value.getLong();
1315                    }
1316            }
1317    
1318            public long[] getData(
1319                            long companyId, String className, String tableName,
1320                            String columnName, long classPK, long[] defaultData)
1321                    throws PortalException, SystemException {
1322    
1323                    ExpandoValue value = getValue(
1324                            companyId, className, tableName, columnName, classPK);
1325    
1326                    if (value == null) {
1327                            return defaultData;
1328                    }
1329                    else {
1330                            return value.getLongArray();
1331                    }
1332            }
1333    
1334            public short getData(
1335                            long companyId, String className, String tableName,
1336                            String columnName, long classPK, short defaultData)
1337                    throws PortalException, SystemException {
1338    
1339                    ExpandoValue value = getValue(
1340                            companyId, className, tableName, columnName, classPK);
1341    
1342                    if (value == null) {
1343                            return defaultData;
1344                    }
1345                    else {
1346                            return value.getShort();
1347                    }
1348            }
1349    
1350            public short[] getData(
1351                            long companyId, String className, String tableName,
1352                            String columnName, long classPK, short[] defaultData)
1353                    throws PortalException, SystemException {
1354    
1355                    ExpandoValue value = getValue(
1356                            companyId, className, tableName, columnName, classPK);
1357    
1358                    if (value == null) {
1359                            return defaultData;
1360                    }
1361                    else {
1362                            return value.getShortArray();
1363                    }
1364            }
1365    
1366            public String getData(
1367                            long companyId, String className, String tableName,
1368                            String columnName, long classPK, String defaultData)
1369                    throws PortalException, SystemException {
1370    
1371                    ExpandoValue value = getValue(
1372                            companyId, className, tableName, columnName, classPK);
1373    
1374                    if (value == null) {
1375                            return defaultData;
1376                    }
1377                    else {
1378                            return value.getString();
1379                    }
1380            }
1381    
1382            public String[] getData(
1383                            long companyId, String className, String tableName,
1384                            String columnName, long classPK, String[] defaultData)
1385                    throws PortalException, SystemException {
1386    
1387                    ExpandoValue value = getValue(
1388                            companyId, className, tableName, columnName, classPK);
1389    
1390                    if (value == null) {
1391                            return defaultData;
1392                    }
1393                    else {
1394                            return value.getStringArray();
1395                    }
1396            }
1397    
1398            /**
1399             * @deprecated {@link #getData(long, String, String, String, long)}
1400             */
1401            public Serializable getData(
1402                            String className, String tableName, String columnName, long classPK)
1403                    throws PortalException, SystemException {
1404    
1405                    long companyId = CompanyThreadLocal.getCompanyId();
1406    
1407                    return getData(companyId, className, tableName, columnName, classPK);
1408            }
1409    
1410            /**
1411             * @deprecated {@link #getData(long, String, String, String, long,
1412             *                         boolean[])}
1413             */
1414            public boolean getData(
1415                            String className, String tableName, String columnName, long classPK,
1416                            boolean defaultData)
1417                    throws PortalException, SystemException {
1418    
1419                    long companyId = CompanyThreadLocal.getCompanyId();
1420    
1421                    return getData(
1422                            companyId, className, tableName, columnName, classPK, defaultData);
1423            }
1424    
1425            /**
1426             * @deprecated {@link #getData(long, String, String, String, long,
1427             *                         boolean[])}
1428             */
1429            public boolean[] getData(
1430                            String className, String tableName, String columnName, long classPK,
1431                            boolean[] defaultData)
1432                    throws PortalException, SystemException {
1433    
1434                    long companyId = CompanyThreadLocal.getCompanyId();
1435    
1436                    return getData(
1437                            companyId, className, tableName, columnName, classPK, defaultData);
1438            }
1439    
1440            /**
1441             * @deprecated {@link #getData(long, String, String, String, long, Date[])}
1442             */
1443            public Date getData(
1444                            String className, String tableName, String columnName, long classPK,
1445                            Date defaultData)
1446                    throws PortalException, SystemException {
1447    
1448                    long companyId = CompanyThreadLocal.getCompanyId();
1449    
1450                    return getData(
1451                            companyId, className, tableName, columnName, classPK, defaultData);
1452            }
1453    
1454            /**
1455             * @deprecated {@link #getData(long, String, String, String, long, Date[])}
1456             */
1457            public Date[] getData(
1458                            String className, String tableName, String columnName, long classPK,
1459                            Date[] defaultData)
1460                    throws PortalException, SystemException {
1461    
1462                    long companyId = CompanyThreadLocal.getCompanyId();
1463    
1464                    return getData(
1465                            companyId, className, tableName, columnName, classPK, defaultData);
1466            }
1467    
1468            /**
1469             * @deprecated {@link #getData(long, String, String, String, long,
1470             *                         double[])}
1471             */
1472            public double getData(
1473                            String className, String tableName, String columnName, long classPK,
1474                            double defaultData)
1475                    throws PortalException, SystemException {
1476    
1477                    long companyId = CompanyThreadLocal.getCompanyId();
1478    
1479                    return getData(
1480                            companyId, className, tableName, columnName, classPK, defaultData);
1481            }
1482    
1483            /**
1484             * @deprecated {@link #getData(long, String, String, String, long,
1485             *                         double[])}
1486             */
1487            public double[] getData(
1488                            String className, String tableName, String columnName, long classPK,
1489                            double[] defaultData)
1490                    throws PortalException, SystemException {
1491    
1492                    long companyId = CompanyThreadLocal.getCompanyId();
1493    
1494                    return getData(
1495                            companyId, className, tableName, columnName, classPK, defaultData);
1496            }
1497    
1498            /**
1499             * @deprecated {@link #getData(long, String, String, String, long, float[])}
1500             */
1501            public float getData(
1502                            String className, String tableName, String columnName, long classPK,
1503                            float defaultData)
1504                    throws PortalException, SystemException {
1505    
1506                    long companyId = CompanyThreadLocal.getCompanyId();
1507    
1508                    return getData(
1509                            companyId, className, tableName, columnName, classPK, defaultData);
1510            }
1511    
1512            /**
1513             * @deprecated {@link #getData(long, String, String, String, long, float[])}
1514             */
1515            public float[] getData(
1516                            String className, String tableName, String columnName, long classPK,
1517                            float[] defaultData)
1518                    throws PortalException, SystemException {
1519    
1520                    long companyId = CompanyThreadLocal.getCompanyId();
1521    
1522                    return getData(
1523                            companyId, className, tableName, columnName, classPK, defaultData);
1524            }
1525    
1526            /**
1527             * @deprecated {@link #getData(long, String, String, String, long, int[])}
1528             */
1529            public int getData(
1530                            String className, String tableName, String columnName, long classPK,
1531                            int defaultData)
1532                    throws PortalException, SystemException {
1533    
1534                    long companyId = CompanyThreadLocal.getCompanyId();
1535    
1536                    return getData(
1537                            companyId, className, tableName, columnName, classPK, defaultData);
1538            }
1539    
1540            /**
1541             * @deprecated {@link #getData(long, String, String, String, long, int[])}
1542             */
1543            public int[] getData(
1544                            String className, String tableName, String columnName, long classPK,
1545                            int[] defaultData)
1546                    throws PortalException, SystemException {
1547    
1548                    long companyId = CompanyThreadLocal.getCompanyId();
1549    
1550                    return getData(
1551                            companyId, className, tableName, columnName, classPK, defaultData);
1552            }
1553    
1554            /**
1555             * @deprecated {@link #getData(long, String, String, String, long, long[])}
1556             */
1557            public long getData(
1558                            String className, String tableName, String columnName, long classPK,
1559                            long defaultData)
1560                    throws PortalException, SystemException {
1561    
1562                    long companyId = CompanyThreadLocal.getCompanyId();
1563    
1564                    return getData(
1565                            companyId, className, tableName, columnName, classPK, defaultData);
1566            }
1567    
1568            /**
1569             * @deprecated {@link #getData(long, String, String, String, long, long[])}
1570             */
1571            public long[] getData(
1572                            String className, String tableName, String columnName, long classPK,
1573                            long[] defaultData)
1574                    throws PortalException, SystemException {
1575    
1576                    long companyId = CompanyThreadLocal.getCompanyId();
1577    
1578                    return getData(
1579                            companyId, className, tableName, columnName, classPK, defaultData);
1580            }
1581    
1582            /**
1583             * @deprecated {@link #getData(long, String, String, String, long, short[])}
1584             */
1585            public short getData(
1586                            String className, String tableName, String columnName, long classPK,
1587                            short defaultData)
1588                    throws PortalException, SystemException {
1589    
1590                    long companyId = CompanyThreadLocal.getCompanyId();
1591    
1592                    return getData(
1593                            companyId, className, tableName, columnName, classPK, defaultData);
1594            }
1595    
1596            /**
1597             * @deprecated {@link #getData(long, String, String, String, long, short[])}
1598             */
1599            public short[] getData(
1600                            String className, String tableName, String columnName, long classPK,
1601                            short[] defaultData)
1602                    throws PortalException, SystemException {
1603    
1604                    long companyId = CompanyThreadLocal.getCompanyId();
1605    
1606                    return getData(
1607                            companyId, className, tableName, columnName, classPK, defaultData);
1608            }
1609    
1610            /**
1611             * @deprecated {@link #getData(long, String, String, String, long,
1612             *                         String[])}
1613             */
1614            public String getData(
1615                            String className, String tableName, String columnName, long classPK,
1616                            String defaultData)
1617                    throws PortalException, SystemException {
1618    
1619                    long companyId = CompanyThreadLocal.getCompanyId();
1620    
1621                    return getData(
1622                            companyId, className, tableName, columnName, classPK, defaultData);
1623            }
1624    
1625            /**
1626             * @deprecated {@link #getData(long, String, String, String, long,
1627             *                         String[])}
1628             */
1629            public String[] getData(
1630                            String className, String tableName, String columnName, long classPK,
1631                            String[] defaultData)
1632                    throws PortalException, SystemException {
1633    
1634                    long companyId = CompanyThreadLocal.getCompanyId();
1635    
1636                    return getData(
1637                            companyId, className, tableName, columnName, classPK, defaultData);
1638            }
1639    
1640            public List<ExpandoValue> getDefaultTableColumnValues(
1641                            long companyId, long classNameId, String columnName, int start,
1642                            int end)
1643                    throws SystemException {
1644    
1645                    return getColumnValues(
1646                            companyId, classNameId, ExpandoTableConstants.DEFAULT_TABLE_NAME,
1647                            columnName, start, end);
1648            }
1649    
1650            public List<ExpandoValue> getDefaultTableColumnValues(
1651                            long companyId, String className, String columnName, int start,
1652                            int end)
1653                    throws SystemException {
1654    
1655                    long classNameId = PortalUtil.getClassNameId(className);
1656    
1657                    return getDefaultTableColumnValues(
1658                            companyId, classNameId, columnName, start, end);
1659            }
1660    
1661            public int getDefaultTableColumnValuesCount(
1662                            long companyId, long classNameId, String columnName)
1663                    throws SystemException {
1664    
1665                    return getColumnValuesCount(
1666                            companyId, classNameId, ExpandoTableConstants.DEFAULT_TABLE_NAME,
1667                            columnName);
1668            }
1669    
1670            public int getDefaultTableColumnValuesCount(
1671                            long companyId, String className, String columnName)
1672                    throws SystemException {
1673    
1674                    long classNameId = PortalUtil.getClassNameId(className);
1675    
1676                    return getDefaultTableColumnValuesCount(
1677                            companyId, classNameId, columnName);
1678            }
1679    
1680            public List<ExpandoValue> getRowValues(long rowId) throws SystemException {
1681                    return expandoValuePersistence.findByRowId(rowId);
1682            }
1683    
1684            public List<ExpandoValue> getRowValues(long rowId, int start, int end)
1685                    throws SystemException {
1686    
1687                    return expandoValuePersistence.findByRowId(rowId, start, end);
1688            }
1689    
1690            public List<ExpandoValue> getRowValues(
1691                            long companyId, long classNameId, String tableName, long classPK,
1692                            int start, int end)
1693                    throws SystemException {
1694    
1695                    ExpandoTable table = expandoTablePersistence.fetchByC_C_N(
1696                            companyId, classNameId, tableName);
1697    
1698                    if (table == null) {
1699                            return Collections.EMPTY_LIST;
1700                    }
1701    
1702                    return expandoValuePersistence.findByT_CPK(
1703                            table.getTableId(), classPK, start, end);
1704            }
1705    
1706            public List<ExpandoValue> getRowValues(
1707                            long companyId, String className, String tableName, long classPK,
1708                            int start, int end)
1709                    throws SystemException {
1710    
1711                    long classNameId = PortalUtil.getClassNameId(className);
1712    
1713                    return getRowValues(
1714                            companyId, classNameId, tableName, classPK, start, end);
1715            }
1716    
1717            public int getRowValuesCount(long rowId) throws SystemException {
1718                    return expandoValuePersistence.countByRowId(rowId);
1719            }
1720    
1721            public int getRowValuesCount(
1722                            long companyId, long classNameId, String tableName, long classPK)
1723                    throws SystemException {
1724    
1725                    ExpandoTable table = expandoTablePersistence.fetchByC_C_N(
1726                            companyId, classNameId, tableName);
1727    
1728                    if (table == null) {
1729                            return 0;
1730                    }
1731    
1732                    return expandoValuePersistence.countByT_CPK(
1733                            table.getTableId(), classPK);
1734            }
1735    
1736            public int getRowValuesCount(
1737                            long companyId, String className, String tableName, long classPK)
1738                    throws SystemException {
1739    
1740                    long classNameId = PortalUtil.getClassNameId(className);
1741    
1742                    return getRowValuesCount(companyId, classNameId, tableName, classPK);
1743            }
1744    
1745            public ExpandoValue getValue(long valueId)
1746                    throws PortalException, SystemException {
1747    
1748                    return expandoValuePersistence.findByPrimaryKey(valueId);
1749            }
1750    
1751            public ExpandoValue getValue(long columnId, long rowId)
1752                    throws PortalException, SystemException {
1753    
1754                    return expandoValuePersistence.findByC_R(columnId, rowId);
1755            }
1756    
1757            public ExpandoValue getValue(long tableId, long columnId, long classPK)
1758                    throws SystemException {
1759    
1760                    return expandoValuePersistence.fetchByT_C_C(
1761                            tableId, columnId, classPK);
1762            }
1763    
1764            public ExpandoValue getValue(
1765                            long companyId, long classNameId, String tableName,
1766                            String columnName, long classPK)
1767                    throws SystemException {
1768    
1769                    ExpandoTable table = expandoTablePersistence.fetchByC_C_N(
1770                            companyId, classNameId, tableName);
1771    
1772                    if (table == null) {
1773                            return null;
1774                    }
1775    
1776                    ExpandoColumn column = expandoColumnPersistence.fetchByT_N(
1777                            table.getTableId(), columnName);
1778    
1779                    if (column == null) {
1780                            return null;
1781                    }
1782    
1783                    return expandoValuePersistence.fetchByT_C_C(
1784                            table.getTableId(), column.getColumnId(), classPK);
1785            }
1786    
1787            public ExpandoValue getValue(
1788                            long companyId, String className, String tableName,
1789                            String columnName, long classPK)
1790                    throws SystemException {
1791    
1792                    long classNameId = PortalUtil.getClassNameId(className);
1793    
1794                    return getValue(companyId, classNameId, tableName, columnName, classPK);
1795            }
1796    
1797    }