001    /**
002     * Copyright (c) 2000-present 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.dynamicdatamapping.storage;
016    
017    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
018    import com.liferay.portal.kernel.util.OrderByComparator;
019    import com.liferay.portal.service.ServiceContext;
020    import com.liferay.portlet.dynamicdatamapping.StorageException;
021    import com.liferay.portlet.dynamicdatamapping.storage.query.Condition;
022    
023    import java.util.List;
024    import java.util.Map;
025    
026    /**
027     * @author Eduardo Lundgren
028     */
029    public class StorageEngineUtil {
030    
031            public static long create(
032                            long companyId, long ddmStructureId, DDMFormValues ddmFormValues,
033                            ServiceContext serviceContext)
034                    throws StorageException {
035    
036                    return getStorageEngine().create(
037                            companyId, ddmStructureId, ddmFormValues, serviceContext);
038            }
039    
040            public static long create(
041                            long companyId, long ddmStructureId, Fields fields,
042                            ServiceContext serviceContext)
043                    throws StorageException {
044    
045                    return getStorageEngine().create(
046                            companyId, ddmStructureId, fields, serviceContext);
047            }
048    
049            public static void deleteByClass(long classPK) throws StorageException {
050                    getStorageEngine().deleteByClass(classPK);
051            }
052    
053            public static void deleteByDDMStructure(long ddmStructureId)
054                    throws StorageException {
055    
056                    getStorageEngine().deleteByDDMStructure(ddmStructureId);
057            }
058    
059            public static DDMFormValues getDDMFormValues(long classPK)
060                    throws StorageException {
061    
062                    return getStorageEngine().getDDMFormValues(classPK);
063            }
064    
065            public static Fields getFields(long classPK) throws StorageException {
066                    return getStorageEngine().getFields(classPK);
067            }
068    
069            public static Fields getFields(long classPK, List<String> fieldNames)
070                    throws StorageException {
071    
072                    return getStorageEngine().getFields(classPK, fieldNames);
073            }
074    
075            public static List<Fields> getFieldsList(
076                            long ddmStructureId, List<String> fieldNames)
077                    throws StorageException {
078    
079                    return getStorageEngine().getFieldsList(ddmStructureId, fieldNames);
080            }
081    
082            public static List<Fields> getFieldsList(
083                            long ddmStructureId, List<String> fieldNames,
084                            OrderByComparator<Fields> orderByComparator)
085                    throws StorageException {
086    
087                    return getStorageEngine().getFieldsList(
088                            ddmStructureId, fieldNames, orderByComparator);
089            }
090    
091            public static List<Fields> getFieldsList(
092                            long ddmStructureId, long[] classPKs, List<String> fieldNames,
093                            OrderByComparator<Fields> orderByComparator)
094                    throws StorageException {
095    
096                    return getStorageEngine().getFieldsList(
097                            ddmStructureId, classPKs, fieldNames, orderByComparator);
098            }
099    
100            public static List<Fields> getFieldsList(
101                            long ddmStructureId, long[] classPKs,
102                            OrderByComparator<Fields> orderByComparator)
103                    throws StorageException {
104    
105                    return getStorageEngine().getFieldsList(
106                            ddmStructureId, classPKs, orderByComparator);
107            }
108    
109            public static Map<Long, Fields> getFieldsMap(
110                            long ddmStructureId, long[] classPKs)
111                    throws StorageException {
112    
113                    return getStorageEngine().getFieldsMap(ddmStructureId, classPKs);
114            }
115    
116            public static Map<Long, Fields> getFieldsMap(
117                            long ddmStructureId, long[] classPKs, List<String> fieldNames)
118                    throws StorageException {
119    
120                    return getStorageEngine().getFieldsMap(
121                            ddmStructureId, classPKs, fieldNames);
122            }
123    
124            public static StorageEngine getStorageEngine() {
125                    PortalRuntimePermission.checkGetBeanProperty(StorageEngineUtil.class);
126    
127                    return _storageEngine;
128            }
129    
130            public static List<Fields> query(
131                            long ddmStructureId, List<String> fieldNames, Condition condition,
132                            OrderByComparator<Fields> orderByComparator)
133                    throws StorageException {
134    
135                    return getStorageEngine().query(
136                            ddmStructureId, fieldNames, condition, orderByComparator);
137            }
138    
139            public static int queryCount(long ddmStructureId, Condition condition)
140                    throws StorageException {
141    
142                    return getStorageEngine().queryCount(ddmStructureId, condition);
143            }
144    
145            public static void update(
146                            long classPK, DDMFormValues ddmFormValues,
147                            ServiceContext serviceContext)
148                    throws StorageException {
149    
150                    getStorageEngine().update(classPK, ddmFormValues, serviceContext);
151            }
152    
153            public static void update(
154                            long classPK, Fields fields, boolean mergeFields,
155                            ServiceContext serviceContext)
156                    throws StorageException {
157    
158                    getStorageEngine().update(classPK, fields, mergeFields, serviceContext);
159            }
160    
161            public static void update(
162                            long classPK, Fields fields, ServiceContext serviceContext)
163                    throws StorageException {
164    
165                    getStorageEngine().update(classPK, fields, serviceContext);
166            }
167    
168            public void setStorageEngine(StorageEngine storageEngine) {
169                    PortalRuntimePermission.checkSetBeanProperty(getClass());
170    
171                    _storageEngine = storageEngine;
172            }
173    
174            private static StorageEngine _storageEngine;
175    
176    }