1 package org.lsst.ccs.config;
2
3 import javax.persistence.*;
4 import java.util.Collection;
5 import java.util.Collections;
6 import java.util.HashSet;
7 import java.util.Set;
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 @Entity
24
25
26 class GhostSubsystemDescription extends SubsystemDescription{
27 private static final long serialVersionUID = -8567707918287105248L;
28 @Id
29 private long id ;
30
31
32
33
34
35 @OneToMany(cascade = CascadeType.ALL, fetch= FetchType.EAGER)
36 protected
37
38
39
40 GhostSubsystemDescription() {
41 }
42
43
44
45
46
47
48 public GhostSubsystemDescription(ASubsystemDescription other) {
49 super(other);
50 this.id = other.getId();
51
52 if(this.id == 0 ){
53 throw new IllegalArgumentException(
54 "cannot create ghost from non registered object (where id is not initialized by database)");
55 }
56 this.setStartTimestamp(other.getStartTimestamp());
57 Set<GhostParameterDescription> set = new HashSet<GhostParameterDescription>();
58
59 for(ParameterDescription parmDesc: other.getParamDescriptions()) {
60 AParameterDescription realDesc = (AParameterDescription) parmDesc ;
61 set.add(new GhostParameterDescription(realDesc)) ;
62 }
63 this.paramDescriptions = Collections.unmodifiableSet(set) ;
64 this.setPreviousDescriptionID(other.getPreviousDescriptionID());
65 }
66
67
68
69
70 @Override
71 public long getId() {
72 return id;
73 }
74
75 @Override
76 void setId(long id) {
77 this.id = id ;
78 }
79
80
81
82
83
84 @Override
85 public Set<? extends ParameterDescription> getParamDescriptionSet() {
86 return getParamDescriptions() ;
87 }
88
89
90
91
92
93
94 public Set<GhostParameterDescription> getParamDescriptions() {
95 return paramDescriptions;
96 }
97
98 void setParamDescriptions(Set<GhostParameterDescription> paramDescriptions) {
99 this.paramDescriptions = Collections.unmodifiableSet(paramDescriptions);
100 }
101
102 @Override
103 void setEndTimestamp(long endTimestamp) {
104 super.setEndTimestamp(endTimestamp);
105 }
106
107 @Override
108 public void addParameterDescriptions(ParameterDescription... descriptions) {
109 throw new UnsupportedOperationException("immutable description") ;
110 }
111
112 @Override
113 public void addParameterDescriptions(Collection<ParameterDescription> descriptions) {
114 throw new UnsupportedOperationException("immutable description") ;
115 }
116
117 @Override
118 public void removeParameterDescriptions(ParameterDescription... descriptions) {
119 throw new UnsupportedOperationException("immutable description") ;
120 }
121
122
123 }