001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portlet.dynamicdatamapping.storage;
016    
017    import com.liferay.portal.kernel.util.OrderByComparator;
018    import com.liferay.portal.service.ServiceContext;
019    import com.liferay.portlet.dynamicdatamapping.StorageException;
020    import com.liferay.portlet.dynamicdatamapping.storage.query.Condition;
021    
022    import java.util.List;
023    import java.util.Map;
024    
025    /**
026     * @author Eduardo Lundgren
027     */
028    public class StorageEngineUtil {
029    
030            public static long create(
031                            long companyId, long ddmStructureId, Fields fields,
032                            ServiceContext serviceContext)
033                    throws StorageException {
034    
035                    return getStorageEngine().create(
036                            companyId, ddmStructureId, fields, serviceContext);
037            }
038    
039            public static void deleteByClass(long classPK) throws StorageException {
040                    getStorageEngine().deleteByClass(classPK);
041            }
042    
043            public static void deleteByDDMStructure(long ddmStructureId)
044                    throws StorageException {
045    
046                    getStorageEngine().deleteByDDMStructure(ddmStructureId);
047            }
048    
049            public static Fields getFields(long classPK) throws StorageException {
050                    return getStorageEngine().getFields(classPK);
051            }
052    
053            public static Fields getFields(long classPK, List<String> fieldNames)
054                    throws StorageException {
055    
056                    return getStorageEngine().getFields(classPK, fieldNames);
057            }
058    
059            public static List<Fields> getFieldsList(
060                            long ddmStructureId, List<String> fieldNames)
061                    throws StorageException {
062    
063                    return getStorageEngine().getFieldsList(
064                            ddmStructureId, fieldNames);
065            }
066    
067            public static List<Fields> getFieldsList(
068                            long ddmStructureId, List<String> fieldNames,
069                            OrderByComparator orderByComparator)
070                    throws StorageException {
071    
072                    return getStorageEngine().getFieldsList(
073                            ddmStructureId, fieldNames, orderByComparator);
074            }
075    
076            public static List<Fields> getFieldsList(
077                            long ddmStructureId, long[] classPKs, List<String> fieldNames,
078                            OrderByComparator orderByComparator)
079                    throws StorageException {
080    
081                    return getStorageEngine().getFieldsList(
082                            ddmStructureId, classPKs, fieldNames, orderByComparator);
083            }
084    
085            public static List<Fields> getFieldsList(
086                            long ddmStructureId, long[] classPKs,
087                            OrderByComparator orderByComparator)
088                    throws StorageException {
089    
090                    return getStorageEngine().getFieldsList(
091                            ddmStructureId, classPKs, orderByComparator);
092            }
093    
094            public static Map<Long, Fields> getFieldsMap(
095                            long ddmStructureId, long[] classPKs)
096                    throws StorageException {
097    
098                    return getStorageEngine().getFieldsMap(
099                            ddmStructureId, classPKs);
100            }
101    
102            public static Map<Long, Fields> getFieldsMap(
103                            long ddmStructureId, long[] classPKs, List<String> fieldNames)
104                    throws StorageException {
105    
106                    return getStorageEngine().getFieldsMap(
107                            ddmStructureId, classPKs, fieldNames);
108            }
109    
110            public static StorageEngine getStorageEngine() {
111                    return _storageEngine;
112            }
113    
114            public static List<Fields> query(
115                            long ddmStructureId, List<String> fieldNames, Condition condition,
116                            OrderByComparator orderByComparator)
117                    throws StorageException {
118    
119                    return getStorageEngine().query(
120                            ddmStructureId, fieldNames, condition, orderByComparator);
121            }
122    
123            public static int queryCount(long ddmStructureId, Condition condition)
124                    throws StorageException {
125    
126                    return getStorageEngine().queryCount(ddmStructureId, condition);
127            }
128    
129            public static void update(
130                            long classPK, Fields fields, boolean mergeFields,
131                            ServiceContext serviceContext)
132                    throws StorageException {
133    
134                    getStorageEngine().update(classPK, fields, mergeFields, serviceContext);
135            }
136    
137            public static void update(
138                            long classPK, Fields fields, ServiceContext serviceContext)
139                    throws StorageException {
140    
141                    getStorageEngine().update(classPK, fields, serviceContext);
142            }
143    
144            public void setStorageEngine(StorageEngine storageEngine) {
145                    _storageEngine = storageEngine;
146            }
147    
148            private static StorageEngine _storageEngine;
149    
150    }