001    /**
002     * Copyright (c) 2000-2012 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.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(ddmStructureId, fieldNames);
064            }
065    
066            public static List<Fields> getFieldsList(
067                            long ddmStructureId, List<String> fieldNames,
068                            OrderByComparator orderByComparator)
069                    throws StorageException {
070    
071                    return getStorageEngine().getFieldsList(
072                            ddmStructureId, fieldNames, orderByComparator);
073            }
074    
075            public static List<Fields> getFieldsList(
076                            long ddmStructureId, long[] classPKs, List<String> fieldNames,
077                            OrderByComparator orderByComparator)
078                    throws StorageException {
079    
080                    return getStorageEngine().getFieldsList(
081                            ddmStructureId, classPKs, fieldNames, orderByComparator);
082            }
083    
084            public static List<Fields> getFieldsList(
085                            long ddmStructureId, long[] classPKs,
086                            OrderByComparator orderByComparator)
087                    throws StorageException {
088    
089                    return getStorageEngine().getFieldsList(
090                            ddmStructureId, classPKs, orderByComparator);
091            }
092    
093            public static Map<Long, Fields> getFieldsMap(
094                            long ddmStructureId, long[] classPKs)
095                    throws StorageException {
096    
097                    return getStorageEngine().getFieldsMap(ddmStructureId, classPKs);
098            }
099    
100            public static Map<Long, Fields> getFieldsMap(
101                            long ddmStructureId, long[] classPKs, List<String> fieldNames)
102                    throws StorageException {
103    
104                    return getStorageEngine().getFieldsMap(
105                            ddmStructureId, classPKs, fieldNames);
106            }
107    
108            public static StorageEngine getStorageEngine() {
109                    return _storageEngine;
110            }
111    
112            public static List<Fields> query(
113                            long ddmStructureId, List<String> fieldNames, Condition condition,
114                            OrderByComparator orderByComparator)
115                    throws StorageException {
116    
117                    return getStorageEngine().query(
118                            ddmStructureId, fieldNames, condition, orderByComparator);
119            }
120    
121            public static int queryCount(long ddmStructureId, Condition condition)
122                    throws StorageException {
123    
124                    return getStorageEngine().queryCount(ddmStructureId, condition);
125            }
126    
127            public static void update(
128                            long classPK, Fields fields, boolean mergeFields,
129                            ServiceContext serviceContext)
130                    throws StorageException {
131    
132                    getStorageEngine().update(classPK, fields, mergeFields, serviceContext);
133            }
134    
135            public static void update(
136                            long classPK, Fields fields, ServiceContext serviceContext)
137                    throws StorageException {
138    
139                    getStorageEngine().update(classPK, fields, serviceContext);
140            }
141    
142            public void setStorageEngine(StorageEngine storageEngine) {
143                    _storageEngine = storageEngine;
144            }
145    
146            private static StorageEngine _storageEngine;
147    
148    }