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.graphql.series;
23  
24  import org.opencastproject.elasticsearch.index.objects.series.Series;
25  import org.opencastproject.graphql.datafetcher.event.EventOffsetDataFetcher;
26  import org.opencastproject.graphql.datafetcher.series.CommonSeriesMetadataV2DataFetcher;
27  import org.opencastproject.graphql.event.GqlEventList;
28  import org.opencastproject.graphql.type.input.EventOrderByInput;
29  import org.opencastproject.graphql.type.output.GqlCommonSeriesMetadataV2;
30  
31  import java.util.List;
32  
33  import graphql.annotations.annotationTypes.GraphQLDataFetcher;
34  import graphql.annotations.annotationTypes.GraphQLDescription;
35  import graphql.annotations.annotationTypes.GraphQLField;
36  import graphql.annotations.annotationTypes.GraphQLID;
37  import graphql.annotations.annotationTypes.GraphQLName;
38  import graphql.annotations.annotationTypes.GraphQLNonNull;
39  import graphql.schema.DataFetchingEnvironment;
40  
41  @GraphQLName(GqlSeries.TYPE_NAME)
42  @GraphQLDescription("A series of episodes.")
43  public class GqlSeries {
44  
45    public static final String TYPE_NAME = "Series";
46  
47    private final Series series;
48  
49    public GqlSeries(Series series) {
50      this.series = series;
51    }
52  
53    @GraphQLID
54    @GraphQLField
55    @GraphQLNonNull
56    public String id() {
57      return series.getIdentifier();
58    }
59  
60    @GraphQLField
61    @GraphQLNonNull
62    public String title() {
63      return series.getTitle();
64    }
65  
66    @GraphQLField
67    public String description() {
68      return series.getDescription();
69    }
70  
71    @GraphQLField
72    public List<String> organizers() {
73      return series.getOrganizers();
74    }
75  
76    @GraphQLField
77    public List<String> contributors() {
78      return series.getContributors();
79    }
80  
81    @GraphQLField
82    public String creator() {
83      return series.getCreator();
84    }
85  
86    @GraphQLField
87    public String license() {
88      return series.getLicense();
89    }
90  
91    @GraphQLField
92    public String created() {
93      return series.getCreatedDateTime().toInstant().toString();
94    }
95  
96    @GraphQLField
97    public List<String> publishers() {
98      return series.getPublishers();
99    }
100 
101   @GraphQLField
102   public String rightsHolder() {
103     return series.getRightsHolder();
104   }
105 
106   public Series getSeries() {
107     return series;
108   }
109 
110   @GraphQLField
111   @GraphQLNonNull
112   @GraphQLDescription("A list of events under the owner.")
113   public GqlEventList events(
114       @GraphQLName("limit") Integer limit,
115       @GraphQLName("offset") Integer offset,
116       @GraphQLName("query") String query,
117       @GraphQLName("orderBy") EventOrderByInput orderBy,
118       final DataFetchingEnvironment environment) {
119     return new EventOffsetDataFetcher().withSeriesId(series.getIdentifier()).get(environment);
120   }
121 
122   @GraphQLField
123   @GraphQLNonNull
124   @GraphQLDescription("Common metadata of the series.")
125   @GraphQLDataFetcher(CommonSeriesMetadataV2DataFetcher.class)
126   public GqlCommonSeriesMetadataV2 commonMetadataV2(final DataFetchingEnvironment environment) {
127     return null;
128   }
129 
130 }