1 17 package org.alfresco.repo.domain.hibernate; 18 19 import java.util.ArrayList ; 20 import java.util.Collection ; 21 import java.util.HashMap ; 22 import java.util.HashSet ; 23 import java.util.Map ; 24 import java.util.Set ; 25 26 import org.alfresco.repo.domain.ChildAssoc; 27 import org.alfresco.repo.domain.Node; 28 import org.alfresco.repo.domain.NodeAssoc; 29 import org.alfresco.repo.domain.NodeKey; 30 import org.alfresco.repo.domain.NodeStatus; 31 import org.alfresco.repo.domain.PropertyValue; 32 import org.alfresco.repo.domain.Store; 33 import org.alfresco.service.cmr.repository.NodeRef; 34 import org.alfresco.service.namespace.QName; 35 36 44 public class NodeImpl implements Node 45 { 46 private NodeKey key; 47 private Store store; 48 private QName typeQName; 49 private NodeStatus status; 50 private Set <QName> aspects; 51 private Collection <NodeAssoc> sourceNodeAssocs; 52 private Collection <NodeAssoc> targetNodeAssocs; 53 private Collection <ChildAssoc> parentAssocs; 54 private Collection <ChildAssoc> childAssocs; 55 private Map <QName, PropertyValue> properties; 56 private transient NodeRef nodeRef; 57 58 public NodeImpl() 59 { 60 aspects = new HashSet <QName>(5); 61 sourceNodeAssocs = new ArrayList <NodeAssoc>(3); 62 targetNodeAssocs = new ArrayList <NodeAssoc>(3); 63 parentAssocs = new ArrayList <ChildAssoc>(3); 64 childAssocs = new ArrayList <ChildAssoc>(3); 65 properties = new HashMap <QName, PropertyValue>(5); 66 } 67 68 public boolean equals(Object obj) 69 { 70 if (obj == null) 71 { 72 return false; 73 } 74 else if (obj == this) 75 { 76 return true; 77 } 78 else if (!(obj instanceof Node)) 79 { 80 return false; 81 } 82 Node that = (Node) obj; 83 return (this.getKey().equals(that.getKey())); 84 } 85 86 public int hashCode() 87 { 88 return getKey().hashCode(); 89 } 90 91 public NodeKey getKey() { 92 return key; 93 } 94 95 public void setKey(NodeKey key) { 96 this.key = key; 97 } 98 99 public Store getStore() 100 { 101 return store; 102 } 103 104 public synchronized void setStore(Store store) 105 { 106 this.store = store; 107 this.nodeRef = null; 108 } 109 110 public QName getTypeQName() 111 { 112 return typeQName; 113 } 114 115 public void setTypeQName(QName typeQName) 116 { 117 this.typeQName = typeQName; 118 } 119 120 public NodeStatus getStatus() 121 { 122 return status; 123 } 124 125 public void setStatus(NodeStatus status) 126 { 127 this.status = status; 128 } 129 130 public Set <QName> getAspects() 131 { 132 return aspects; 133 } 134 135 138 @SuppressWarnings ("unused") 139 private void setAspects(Set <QName> aspects) 140 { 141 this.aspects = aspects; 142 } 143 144 public Collection <NodeAssoc> getSourceNodeAssocs() 145 { 146 return sourceNodeAssocs; 147 } 148 149 152 @SuppressWarnings ("unused") 153 private void setSourceNodeAssocs(Collection <NodeAssoc> sourceNodeAssocs) 154 { 155 this.sourceNodeAssocs = sourceNodeAssocs; 156 } 157 158 public Collection <NodeAssoc> getTargetNodeAssocs() 159 { 160 return targetNodeAssocs; 161 } 162 163 166 @SuppressWarnings ("unused") 167 private void setTargetNodeAssocs(Collection <NodeAssoc> targetNodeAssocs) 168 { 169 this.targetNodeAssocs = targetNodeAssocs; 170 } 171 172 public Collection <ChildAssoc> getParentAssocs() 173 { 174 return parentAssocs; 175 } 176 177 180 @SuppressWarnings ("unused") 181 private void setParentAssocs(Collection <ChildAssoc> parentAssocs) 182 { 183 this.parentAssocs = parentAssocs; 184 } 185 186 public Collection <ChildAssoc> getChildAssocs() 187 { 188 return childAssocs; 189 } 190 191 194 @SuppressWarnings ("unused") 195 private void setChildAssocs(Collection <ChildAssoc> childAssocs) 196 { 197 this.childAssocs = childAssocs; 198 } 199 200 public Map <QName, PropertyValue> getProperties() 201 { 202 return properties; 203 } 204 205 208 @SuppressWarnings ("unused") 209 private void setProperties(Map <QName, PropertyValue> properties) 210 { 211 this.properties = properties; 212 } 213 214 217 public synchronized NodeRef getNodeRef() 218 { 219 if (nodeRef == null && key != null) 220 { 221 nodeRef = new NodeRef(getStore().getStoreRef(), getKey().getGuid()); 222 } 223 return nodeRef; 224 } 225 226 229 public String toString() 230 { 231 return getNodeRef().toString(); 232 } 233 } 234 | Popular Tags |