1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package eu.ehri.project.models.cvoc;
21
22 import com.tinkerpop.blueprints.Direction;
23 import com.tinkerpop.blueprints.Vertex;
24 import com.tinkerpop.frames.Adjacency;
25 import com.tinkerpop.frames.modules.javahandler.JavaHandler;
26 import com.tinkerpop.frames.modules.javahandler.JavaHandlerContext;
27 import eu.ehri.project.definitions.Ontology;
28 import eu.ehri.project.models.EntityClass;
29 import eu.ehri.project.models.annotations.EntityType;
30 import eu.ehri.project.models.base.Accessible;
31 import eu.ehri.project.models.base.ItemHolder;
32 import eu.ehri.project.models.base.Named;
33 import eu.ehri.project.models.base.PermissionScope;
34 import eu.ehri.project.models.utils.JavaHandlerUtils;
35
36
37
38
39
40
41 @EntityType(EntityClass.AUTHORITATIVE_SET)
42 public interface AuthoritativeSet extends Accessible,
43 PermissionScope, ItemHolder, Named {
44
45
46
47
48
49
50 @Adjacency(label = Ontology.ITEM_IN_AUTHORITATIVE_SET, direction = Direction.IN)
51 Iterable<AuthoritativeItem> getAuthoritativeItems();
52
53
54
55
56
57
58 @JavaHandler
59 void addItem(AuthoritativeItem item);
60
61
62
63
64 abstract class Impl implements JavaHandlerContext<Vertex>, AuthoritativeSet {
65
66 @Override
67 public int getChildCount() {
68 return Math.toIntExact(gremlin().inE(Ontology.ITEM_IN_AUTHORITATIVE_SET).count());
69 }
70
71 @Override
72 public void addItem(AuthoritativeItem item) {
73 JavaHandlerUtils.addSingleRelationship(item.asVertex(), it(),
74 Ontology.ITEM_IN_AUTHORITATIVE_SET);
75 }
76 }
77 }