This project has retired. For details please refer to its
Attic page.
ObjectTypeHelper xref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.chemistry.opencmis.client.runtime.objecttype;
20
21 import java.io.Serializable;
22 import java.util.List;
23
24 import org.apache.chemistry.opencmis.client.api.ItemIterable;
25 import org.apache.chemistry.opencmis.client.api.ObjectType;
26 import org.apache.chemistry.opencmis.client.api.Session;
27 import org.apache.chemistry.opencmis.client.api.Tree;
28
29
30
31
32
33
34 public class ObjectTypeHelper implements Serializable {
35
36 private static final long serialVersionUID = 1L;
37
38 private final Session session;
39 private final ObjectType objectType;
40 private ObjectType baseType;
41 private ObjectType parentType;
42
43 public ObjectTypeHelper(Session session, ObjectType objectType) {
44 this.session = session;
45 this.objectType = objectType;
46 }
47
48 public Session getSession() {
49 return session;
50 }
51
52 public boolean isBaseType() {
53 return objectType.getParentTypeId() == null || objectType.getParentTypeId().length() == 0;
54 }
55
56 public ObjectType getBaseType() {
57 if (isBaseType()) {
58 return null;
59 }
60 if (baseType != null) {
61 return baseType;
62 }
63 if (objectType.getBaseTypeId() == null) {
64 return null;
65 }
66 baseType = session.getTypeDefinition(objectType.getBaseTypeId().value());
67 return baseType;
68 }
69
70 public ObjectType getParentType() {
71 if (parentType != null) {
72 return parentType;
73 }
74 if (objectType.getParentTypeId() == null || objectType.getParentTypeId().length() == 0) {
75 return null;
76 }
77 parentType = session.getTypeDefinition(objectType.getParentTypeId());
78 return parentType;
79 }
80
81 public ItemIterable<ObjectType> getChildren() {
82 return session.getTypeChildren(objectType.getId(), true);
83 }
84
85 public List<Tree<ObjectType>> getDescendants(int depth) {
86 return session.getTypeDescendants(objectType.getId(), depth, true);
87 }
88 }