001    /**
002     * Copyright (c) 2000-2010 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.portal.model.impl;
016    
017    import com.liferay.portal.kernel.plugin.PluginPackage;
018    import com.liferay.portal.model.Plugin;
019    import com.liferay.portal.model.PluginSetting;
020    
021    import java.util.HashMap;
022    import java.util.Map;
023    
024    /**
025     * @author Jorge Ferrer
026     */
027    public abstract class PluginBaseImpl implements Plugin {
028    
029            public PluginPackage getPluginPackage() {
030                    return _pluginPackage;
031            }
032    
033            public void setPluginPackage(PluginPackage pluginPackage) {
034                    _pluginPackage = pluginPackage;
035            }
036    
037            public PluginSetting getDefaultPluginSetting() {
038                    return _defaultPluginSetting;
039            }
040    
041            public PluginSetting getDefaultPluginSetting(long companyId) {
042                    PluginSetting setting = _defaultPluginSettings.get(companyId);
043    
044                    if (setting == null) {
045                            setting = new PluginSettingImpl(_defaultPluginSetting);
046    
047                            setting.setCompanyId(companyId);
048    
049                            _defaultPluginSettings.put(companyId, setting);
050                    }
051    
052                    return setting;
053            }
054    
055            public void setDefaultPluginSetting(PluginSetting pluginSetting) {
056                    _defaultPluginSetting = pluginSetting;
057            }
058    
059            private PluginPackage _pluginPackage;
060            private PluginSetting _defaultPluginSetting;
061            private Map<Long, PluginSetting> _defaultPluginSettings =
062                    new HashMap<Long, PluginSetting>();
063    
064    }