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.exportimport.lar;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.util.GetterUtil;
020    import com.liferay.portal.kernel.xml.Element;
021    
022    import java.io.Serializable;
023    
024    import java.util.HashMap;
025    import java.util.Map;
026    import java.util.Set;
027    
028    /**
029     * @author Zsolt Berentey
030     */
031    @ProviderType
032    public class MissingReference implements Serializable {
033    
034            public MissingReference(Element element) {
035                    _className = element.attributeValue("class-name");
036                    _classPK = element.attributeValue("class-pk");
037                    _displayName = GetterUtil.getString(
038                            element.attributeValue("display-name"));
039                    _referrerClassName = element.attributeValue("referrer-class-name");
040                    _type = GetterUtil.getString(element.attributeValue("type"));
041    
042                    String referrerDisplayName = GetterUtil.getString(
043                            element.attributeValue("referrer-display-name"));
044    
045                    addReferrer(_referrerClassName, referrerDisplayName);
046            }
047    
048            public void addReferrer(
049                    String referrerClassName, String referrerDisplayName) {
050    
051                    _referrers.put(referrerDisplayName, referrerClassName);
052            }
053    
054            public void addReferrers(Map<String, String> referrers) {
055                    _referrers.putAll(referrers);
056            }
057    
058            public String getClassName() {
059                    return _className;
060            }
061    
062            public String getClassPK() {
063                    return _classPK;
064            }
065    
066            public String getDisplayName() {
067                    return _displayName;
068            }
069    
070            public long getGroupId() {
071                    return _groupId;
072            }
073    
074            public String getReferrerClassName() {
075                    return _referrerClassName;
076            }
077    
078            public Set<String> getReferrerDisplayNames() {
079                    return _referrers.keySet();
080            }
081    
082            public Map<String, String> getReferrers() {
083                    return _referrers;
084            }
085    
086            public String getType() {
087                    return _type;
088            }
089    
090            public void setGroupId(long groupId) {
091                    _groupId = groupId;
092            }
093    
094            private final String _className;
095            private final String _classPK;
096            private final String _displayName;
097            private long _groupId;
098            private final String _referrerClassName;
099            private final Map<String, String> _referrers = new HashMap<>();
100            private final String _type;
101    
102    }