001/* 002 * (C) Copyright 2006-2011 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Thomas Roger <troger@nuxeo.com> 018 */ 019 020package org.nuxeo.ecm.activity; 021 022import java.util.ArrayList; 023import java.util.Collections; 024import java.util.List; 025 026import org.nuxeo.common.xmap.annotation.XNode; 027import org.nuxeo.common.xmap.annotation.XNodeList; 028import org.nuxeo.common.xmap.annotation.XObject; 029 030/** 031 * @author <a href="mailto:troger@nuxeo.com">Thomas Roger</a> 032 * @since 5.5 033 */ 034@XObject("activityStream") 035public class ActivityStream { 036 037 @XNode("@name") 038 String name; 039 040 @XNode("verbs@append") 041 boolean appendVerbs; 042 043 @XNodeList(value = "verbs/verb", type = ArrayList.class, componentType = String.class) 044 List<String> verbs; 045 046 @XNode("relationshipKinds@append") 047 boolean appendRelationshipKinds; 048 049 @XNodeList(value = "relationshipKinds/relationshipKind", type = ArrayList.class, componentType = String.class) 050 List<String> relationshipKinds; 051 052 public String getName() { 053 return name; 054 } 055 056 public void setName(String name) { 057 this.name = name; 058 } 059 060 public boolean isAppendVerbs() { 061 return appendVerbs; 062 } 063 064 public void setAppendVerbs(boolean appendVerbs) { 065 this.appendVerbs = appendVerbs; 066 } 067 068 public List<String> getVerbs() { 069 if (verbs == null) { 070 return Collections.emptyList(); 071 } 072 return verbs; 073 } 074 075 public void setVerbs(List<String> verbs) { 076 this.verbs = verbs; 077 } 078 079 public boolean isAppendRelationshipKinds() { 080 return appendRelationshipKinds; 081 } 082 083 public void setAppendRelationshipKinds(boolean appendRelationshipKinds) { 084 this.appendRelationshipKinds = appendRelationshipKinds; 085 } 086 087 public List<String> getRelationshipKinds() { 088 if (relationshipKinds == null) { 089 return Collections.emptyList(); 090 } 091 return relationshipKinds; 092 } 093 094 public void setRelationshipKinds(List<String> relationshipKinds) { 095 this.relationshipKinds = relationshipKinds; 096 } 097 098 @Override 099 public ActivityStream clone() { 100 ActivityStream clone = new ActivityStream(); 101 clone.setName(getName()); 102 clone.setAppendVerbs(isAppendVerbs()); 103 List<String> verbs = getVerbs(); 104 if (verbs != null) { 105 List<String> newVerbs = new ArrayList<String>(); 106 for (String verb : verbs) { 107 newVerbs.add(verb); 108 } 109 clone.setVerbs(newVerbs); 110 } 111 clone.setAppendRelationshipKinds(isAppendRelationshipKinds()); 112 List<String> relationshipKinds = getRelationshipKinds(); 113 if (relationshipKinds != null) { 114 List<String> newRelationshipKinds = new ArrayList<String>(); 115 for (String kind : relationshipKinds) { 116 newRelationshipKinds.add(kind); 117 } 118 clone.setRelationshipKinds(newRelationshipKinds); 119 } 120 return clone; 121 } 122}