001    /**
002     * Copyright (c) 2000-2013 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.util;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
020    import com.liferay.portal.kernel.util.OrderByComparator;
021    import com.liferay.portal.service.ServiceContext;
022    import com.liferay.portal.theme.ThemeDisplay;
023    import com.liferay.portlet.dynamicdatamapping.storage.Field;
024    import com.liferay.portlet.dynamicdatamapping.storage.Fields;
025    
026    import java.io.Serializable;
027    
028    /**
029     * @author Eduardo Lundgren
030     * @author Marcellus Tavares
031     */
032    public class DDMUtil {
033    
034            public static DDM getDDM() {
035                    PortalRuntimePermission.checkGetBeanProperty(DDMUtil.class);
036    
037                    return _ddm;
038            }
039    
040            public static DDMDisplay getDDMDisplay(ServiceContext serviceContext) {
041                    return getDDM().getDDMDisplay(serviceContext);
042            }
043    
044            public static Serializable getDisplayFieldValue(
045                            ThemeDisplay themeDisplay, Serializable fieldValue, String type)
046                    throws Exception {
047    
048                    return getDDM().getDisplayFieldValue(themeDisplay, fieldValue, type);
049            }
050    
051            public static Fields getFields(
052                            long ddmStructureId, long ddmTemplateId,
053                            ServiceContext serviceContext)
054                    throws PortalException, SystemException {
055    
056                    return getDDM().getFields(
057                            ddmStructureId, ddmTemplateId, serviceContext);
058            }
059    
060            public static Fields getFields(
061                            long ddmStructureId, long ddmTemplateId, String fieldNamespace,
062                            ServiceContext serviceContext)
063                    throws PortalException, SystemException {
064    
065                    return getDDM().getFields(
066                            ddmStructureId, ddmTemplateId, fieldNamespace, serviceContext);
067            }
068    
069            public static Fields getFields(
070                            long ddmStructureId, ServiceContext serviceContext)
071                    throws PortalException, SystemException {
072    
073                    return getDDM().getFields(ddmStructureId, serviceContext);
074            }
075    
076            public static Fields getFields(
077                            long ddmStructureId, String fieldNamespace,
078                            ServiceContext serviceContext)
079                    throws PortalException, SystemException {
080    
081                    return getDDM().getFields(
082                            ddmStructureId, fieldNamespace, serviceContext);
083            }
084    
085            public static String[] getFieldsDisplayValues(Field fieldsDisplayField)
086                    throws Exception {
087    
088                    return getDDM().getFieldsDisplayValues(fieldsDisplayField);
089            }
090    
091            public static Serializable getIndexedFieldValue(
092                            Serializable fieldValue, String type)
093                    throws Exception {
094    
095                    return getDDM().getIndexedFieldValue(fieldValue, type);
096            }
097    
098            public static OrderByComparator getStructureOrderByComparator(
099                    String orderByCol, String orderByType) {
100    
101                    return getDDM().getStructureOrderByComparator(orderByCol, orderByType);
102            }
103    
104            public static OrderByComparator getTemplateOrderByComparator(
105                    String orderByCol, String orderByType) {
106    
107                    return getDDM().getTemplateOrderByComparator(orderByCol, orderByType);
108            }
109    
110            public static Fields mergeFields(Fields newFields, Fields existingFields) {
111                    return getDDM().mergeFields(newFields, existingFields);
112            }
113    
114            public void setDDM(DDM ddm) {
115                    PortalRuntimePermission.checkSetBeanProperty(getClass());
116    
117                    _ddm = ddm;
118            }
119    
120            private static DDM _ddm;
121    
122    }