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.messageboards.model.impl;
016    
017    import com.liferay.portlet.messageboards.model.MBCategory;
018    import com.liferay.portlet.messageboards.model.MBMessage;
019    import com.liferay.portlet.messageboards.model.MBMessageDisplay;
020    import com.liferay.portlet.messageboards.model.MBThread;
021    import com.liferay.portlet.messageboards.model.MBThreadConstants;
022    import com.liferay.portlet.messageboards.model.MBTreeWalker;
023    import com.liferay.portlet.messageboards.service.MBMessageLocalService;
024    
025    /**
026     * @author Brian Wing Shun Chan
027     * @author Shuyang Zhou
028     */
029    public class MBMessageDisplayImpl implements MBMessageDisplay {
030    
031            public MBMessageDisplayImpl(
032                    MBMessage message, MBMessage parentMessage, MBCategory category,
033                    MBThread thread, MBThread previousThread, MBThread nextThread,
034                    int status, String threadView,
035                    MBMessageLocalService messageLocalService) {
036    
037                    _message = message;
038                    _parentMessage = parentMessage;
039                    _category = category;
040                    _thread = thread;
041    
042                    if (!threadView.equals(MBThreadConstants.THREAD_VIEW_FLAT)) {
043                            _treeWalker = new MBTreeWalkerImpl(
044                                    message, status, messageLocalService);
045                    }
046                    else {
047                            _treeWalker = null;
048                    }
049    
050                    _previousThread = previousThread;
051                    _nextThread = nextThread;
052                    _threadView = threadView;
053            }
054    
055            @Override
056            public MBCategory getCategory() {
057                    return _category;
058            }
059    
060            @Override
061            public MBMessage getMessage() {
062                    return _message;
063            }
064    
065            @Override
066            public MBThread getNextThread() {
067                    return _nextThread;
068            }
069    
070            @Override
071            public MBMessage getParentMessage() {
072                    return _parentMessage;
073            }
074    
075            @Override
076            public MBThread getPreviousThread() {
077                    return _previousThread;
078            }
079    
080            @Override
081            public MBThread getThread() {
082                    return _thread;
083            }
084    
085            @Override
086            public String getThreadView() {
087                    return _threadView;
088            }
089    
090            @Override
091            public MBTreeWalker getTreeWalker() {
092                    return _treeWalker;
093            }
094    
095            private final MBCategory _category;
096            private final MBMessage _message;
097            private final MBThread _nextThread;
098            private final MBMessage _parentMessage;
099            private final MBThread _previousThread;
100            private final MBThread _thread;
101            private final String _threadView;
102            private final MBTreeWalker _treeWalker;
103    
104    }