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