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.portal.kernel.systemevent;
016    
017    import com.liferay.portal.kernel.json.JSONFactoryUtil;
018    import com.liferay.portal.kernel.json.JSONObject;
019    import com.liferay.portal.kernel.util.StringPool;
020    import com.liferay.portal.util.PortalUtil;
021    
022    /**
023     * @author Zsolt Berentey
024     */
025    public class SystemEventHierarchyEntry {
026    
027            public SystemEventHierarchyEntry(
028                    long systemEventId, long classNameId, long classPK,
029                    long parentSystemEventId, long systemEventSetKey, int action) {
030    
031                    _systemEventId = systemEventId;
032                    _classNameId = classNameId;
033                    _classPK = classPK;
034                    _parentSystemEventId = parentSystemEventId;
035                    _systemEventSetKey = systemEventSetKey;
036                    _action = action;
037            }
038    
039            public int getAction() {
040                    return _action;
041            }
042    
043            public String getClassName() {
044                    return PortalUtil.getClassName(_classNameId);
045            }
046    
047            public long getClassNameId() {
048                    return _classNameId;
049            }
050    
051            public String getExtraData() {
052                    if (_extraDataJSONObject == null) {
053                            return StringPool.BLANK;
054                    }
055    
056                    return _extraDataJSONObject.toString();
057            }
058    
059            public long getParentSystemEventId() {
060                    return _parentSystemEventId;
061            }
062    
063            public long getSystemEventId() {
064                    return _systemEventId;
065            }
066    
067            public long getSystemEventSetKey() {
068                    return _systemEventSetKey;
069            }
070    
071            public String getUuid() {
072                    return _uuid;
073            }
074    
075            public boolean hasTypedModel(long classNameId, long classPK) {
076                    if ((_classNameId == classNameId) && (_classPK == classPK)) {
077                            return true;
078                    }
079    
080                    return false;
081            }
082    
083            public boolean hasTypedModel(String className, long classPK) {
084                    long classNameId = PortalUtil.getClassNameId(className);
085    
086                    return hasTypedModel(classNameId, classPK);
087            }
088    
089            public void setClassName(String className) {
090                    _classNameId = PortalUtil.getClassNameId(className);
091            }
092    
093            public void setClassNameId(long classNameId) {
094                    _classNameId = classNameId;
095            }
096    
097            public void setExtraDataValue(String key, String value) {
098                    if (_extraDataJSONObject == null) {
099                            _extraDataJSONObject = JSONFactoryUtil.createJSONObject();
100                    }
101    
102                    _extraDataJSONObject.put(key, value);
103            }
104    
105            public void setUuid(String uuid) {
106                    _uuid = uuid;
107            }
108    
109            private int _action;
110            private long _classNameId;
111            private long _classPK;
112            private JSONObject _extraDataJSONObject;
113            private long _parentSystemEventId;
114            private long _systemEventId;
115            private long _systemEventSetKey;
116            private String _uuid;
117    
118    }