View Javadoc
1   /*
2    * Licensed to The Apereo Foundation under one or more contributor license
3    * agreements. See the NOTICE file distributed with this work for additional
4    * information regarding copyright ownership.
5    *
6    *
7    * The Apereo Foundation licenses this file to you under the Educational
8    * Community License, Version 2.0 (the "License"); you may not use this file
9    * except in compliance with the License. You may obtain a copy of the License
10   * at:
11   *
12   *   http://opensource.org/licenses/ecl2.txt
13   *
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
17   * License for the specific language governing permissions and limitations under
18   * the License.
19   *
20   */
21  
22  package org.opencastproject.usertracking.impl;
23  
24  import org.opencastproject.usertracking.api.UserAction;
25  import org.opencastproject.usertracking.api.UserActionList;
26  
27  import java.util.ArrayList;
28  import java.util.Collection;
29  import java.util.LinkedList;
30  import java.util.List;
31  
32  import javax.xml.bind.annotation.XmlAccessType;
33  import javax.xml.bind.annotation.XmlAccessorType;
34  import javax.xml.bind.annotation.XmlAttribute;
35  import javax.xml.bind.annotation.XmlElement;
36  import javax.xml.bind.annotation.XmlRootElement;
37  import javax.xml.bind.annotation.XmlType;
38  
39  /**
40   * A {@link List} of {@link UserActionList}s
41   */
42  @XmlType(name = "actions", namespace = "http://usertracking.opencastproject.org")
43  @XmlRootElement(name = "actions", namespace = "http://usertracking.opencastproject.org")
44  @XmlAccessorType(XmlAccessType.FIELD)
45  public class UserActionListImpl implements UserActionList {
46  
47    @XmlAttribute(name = "total")
48    private int total;
49  
50    @XmlAttribute(name = "offset")
51    private int offset;
52  
53    @XmlAttribute(name = "limit")
54    private int limit;
55  
56    @XmlElement(name = "action", namespace = "http://usertracking.opencastproject.org")
57    private List<UserActionImpl> actions;
58  
59    public void add(UserAction annotation) {
60      actions.add((UserActionImpl) annotation);
61    }
62  
63    public void add(Collection<UserAction> userActions) {
64      for (UserAction userAction : userActions) {
65        add((UserActionImpl)userAction);
66      }
67    }
68  
69    /**
70     * A no-arg constructor needed by JAXB
71     */
72    public UserActionListImpl() {
73      this.actions = new ArrayList<UserActionImpl>();
74    }
75  
76    public void setTotal(int total) {
77      this.total = total;
78    }
79  
80    public void setLimit(int limit) {
81      this.limit = limit;
82    }
83  
84    public void setOffset(int offset) {
85      this.offset = offset;
86    }
87  
88    public int getTotal() {
89      return total;
90    }
91  
92    public int getLimit() {
93      return limit;
94    }
95  
96    public int getOffset() {
97      return offset;
98    }
99  
100   public List<UserAction> getUserActions() {
101     List<UserAction> userActions = new LinkedList<UserAction>();
102     for (UserActionImpl userActionImpl : actions) {
103       userActions.add(userActionImpl);
104     }
105     return userActions;
106   }
107 }