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.dynamicdatalists.template;
016    
017    import com.liferay.portal.kernel.language.LanguageUtil;
018    import com.liferay.portal.kernel.template.TemplateVariableGroup;
019    import com.liferay.portal.kernel.util.StringPool;
020    import com.liferay.portal.util.PortalUtil;
021    import com.liferay.portal.util.PortletKeys;
022    import com.liferay.portlet.ddm.template.BaseDDMTemplateHandler;
023    import com.liferay.portlet.dynamicdatalists.model.DDLRecordSet;
024    import com.liferay.portlet.dynamicdatalists.service.DDLRecordLocalService;
025    import com.liferay.portlet.dynamicdatalists.service.DDLRecordService;
026    import com.liferay.portlet.dynamicdatalists.service.DDLRecordSetLocalService;
027    import com.liferay.portlet.dynamicdatalists.service.DDLRecordSetService;
028    import com.liferay.portlet.dynamicdatamapping.service.DDMStructureLocalService;
029    import com.liferay.portlet.dynamicdatamapping.service.DDMStructureService;
030    import com.liferay.portlet.dynamicdatamapping.service.DDMTemplateLocalService;
031    import com.liferay.portlet.dynamicdatamapping.service.DDMTemplateService;
032    
033    import java.util.Locale;
034    import java.util.Map;
035    
036    /**
037     * @author Jorge Ferrer
038     */
039    public class DDLTemplateHandler extends BaseDDMTemplateHandler {
040    
041            public String getClassName() {
042                    return DDLRecordSet.class.getName();
043            }
044    
045            public String getName(Locale locale) {
046                    String portletTitle = PortalUtil.getPortletTitle(
047                            PortletKeys.DYNAMIC_DATA_LISTS, locale);
048    
049                    return portletTitle.concat(StringPool.SPACE).concat(
050                            LanguageUtil.get(locale, "template"));
051            }
052    
053            public String getResourceName() {
054                    return "com.liferay.portlet.dynamicdatalists";
055            }
056    
057            @Override
058            public Map<String, TemplateVariableGroup> getTemplateVariableGroups(
059                            long classPK, Locale locale)
060                    throws Exception {
061    
062                    Map<String, TemplateVariableGroup> templateVariableGroups =
063                            super.getTemplateVariableGroups(classPK, locale);
064    
065                    TemplateVariableGroup ddlServicesTemplateVariableGroup =
066                            new TemplateVariableGroup("data-list-services");
067    
068                    ddlServicesTemplateVariableGroup.setAutocompleteEnabled(false);
069    
070                    ddlServicesTemplateVariableGroup.addServiceLocatorVariables(
071                            DDLRecordLocalService.class, DDLRecordService.class,
072                            DDLRecordSetLocalService.class, DDLRecordSetService.class,
073                            DDMStructureLocalService.class, DDMStructureService.class,
074                            DDMTemplateLocalService.class, DDMTemplateService.class);
075    
076                    templateVariableGroups.put(
077                            ddlServicesTemplateVariableGroup.getLabel(),
078                            ddlServicesTemplateVariableGroup);
079    
080                    return templateVariableGroups;
081            }
082    
083    }