1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.opencastproject.job.api;
23
24 import static org.opencastproject.util.data.Monadics.mlist;
25
26 import org.opencastproject.serviceregistry.api.IncidentService;
27 import org.opencastproject.serviceregistry.api.IncidentServiceException;
28 import org.opencastproject.util.NotFoundException;
29 import org.opencastproject.util.data.Function;
30
31 import java.util.List;
32 import java.util.Locale;
33
34 import javax.xml.bind.annotation.XmlAccessType;
35 import javax.xml.bind.annotation.XmlAccessorType;
36 import javax.xml.bind.annotation.XmlElement;
37 import javax.xml.bind.annotation.XmlRootElement;
38 import javax.xml.bind.annotation.XmlType;
39
40 @XmlAccessorType(XmlAccessType.FIELD)
41 @XmlType(name = "incidentFullTree", namespace = "http://job.opencastproject.org")
42 @XmlRootElement(name = "incidentFullTree", namespace = "http://job.opencastproject.org")
43 public final class JaxbIncidentFullTree {
44 @XmlElement(name = JaxbIncidentUtil.ELEM_NESTED_INCIDENT)
45 private List<JaxbIncidentFull> incidents;
46
47 @XmlElement(name = JaxbIncidentUtil.ELEM_NESTED_TREE)
48 private List<JaxbIncidentFullTree> descendants;
49
50
51 public JaxbIncidentFullTree() {
52 }
53
54 public JaxbIncidentFullTree(IncidentService svc, Locale locale, IncidentTree tree) throws IncidentServiceException,
55 NotFoundException {
56 this.incidents = mlist(tree.getIncidents()).map(JaxbIncidentFull.mkFn(svc, locale)).value();
57 this.descendants = mlist(tree.getDescendants()).map(mkFn(svc, locale)).value();
58 }
59
60 public static Function<IncidentTree, JaxbIncidentFullTree> mkFn(final IncidentService svc, final Locale locale) {
61 return new Function.X<IncidentTree, JaxbIncidentFullTree>() {
62 @Override
63 public JaxbIncidentFullTree xapply(IncidentTree tree) throws Exception {
64 return new JaxbIncidentFullTree(svc, locale, tree);
65 }
66 };
67 }
68 }