/*
 * Copyright (C) 2003-2010 eXo Platform SAS.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Affero General Public License
 * as published by the Free Software Foundation; either version 3
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see<http://www.gnu.org/licenses/>.
 */
package org.exoplatform.social.webui.activity.plugin;

import org.exoplatform.social.core.activity.model.Activity;
import org.exoplatform.social.core.application.RelationshipPublisher;
import org.exoplatform.social.core.application.RelationshipPublisher.TitleId;
import org.exoplatform.social.webui.activity.BaseUIActivity;
import org.exoplatform.social.webui.activity.BaseUIActivityBuilder;

/**
 *
 * @author    <a href="http://hoatle.net">hoatle (hoatlevan at gmail dot com)</a>
 * @since     Aug 31, 2010
 * @copyright eXo SAS
 */
public class RelationshipUIActivityBuilder extends BaseUIActivityBuilder {

  @Override
  protected void extendUIActivity(BaseUIActivity uiActivity, Activity activity) {
    UIRelationshipActivity uiRelationshipActivity = (UIRelationshipActivity) uiActivity;
    String titleId = activity.getTitleId();
    if (titleId.equals(TitleId.CONNECTION_CONFIRMED.toString())) {
      uiRelationshipActivity.setTitleId(TitleId.CONNECTION_CONFIRMED);
    } else if (titleId.equals(TitleId.CONNECTION_REQUESTED.toString())) {
      uiRelationshipActivity.setTitleId(TitleId.CONNECTION_REQUESTED);
    }
    String senderName = activity.getTemplateParams().get(RelationshipPublisher.SENDER_PARAM);
    String receiverName = activity.getTemplateParams().get(RelationshipPublisher.RECEIVER_PARAM);
    uiRelationshipActivity.setSenderName(senderName);
    uiRelationshipActivity.setReceiverName(receiverName);
  }

}
