1 package org.lsst.ccs.config;
2
3 import org.hibernate.annotations.Immutable;
4
5 import javax.persistence.Entity;
6 import javax.persistence.GeneratedValue;
7 import javax.persistence.Id;
8
9 /**
10 * Represents an actual parameterDescription. These objects are supposed to be immutable!
11 * When willing to change data create a new one using appropriate constructors.
12 * @author bamade
13 */
14 // Date: 10/04/12
15
16 @Entity
17 @Immutable
18 //@Table(name="ParmDescription")
19 class AParameterDescription extends ParameterDescription implements Cloneable{
20 private static final long serialVersionUID = 918323180559048934L;
21 @Id
22 @GeneratedValue
23 private long id ; //generated
24
25 /////////////////////////// CONSTRUCTORS
26
27 /**
28 * convenience constructor for POJO manipulating software, do not use!
29 */
30 AParameterDescription() {
31 }
32
33 /**
34 * to be used to create a new Actual ParameterDescription from scratch or from another Actual ParameterDescription
35 * (when changing level, or constraints, or simpleName, or description).
36 * @param parameterBase
37 * @param description
38 * @param simpleName
39 * @param constraints
40 * @param level
41 */
42 public AParameterDescription(ParameterBase parameterBase, String description, String simpleName, String constraints, int level) {
43 super(parameterBase);
44 setDescription(description);
45 setSimpleName(simpleName);
46 setConstraints(constraints);
47 setLevel(level);
48 }
49
50 /**
51 * Creates a new Object from a ParameterDescription but does not copy the id.
52 * The id will be generated when the new Object will be inserted in the Database.
53 * @param otherDesc
54 *
55 */
56 public AParameterDescription(ParameterDescription otherDesc) {
57 this(otherDesc.getParameterBase(), otherDesc.getDescription(), otherDesc.getSimpleName(), otherDesc.getConstraints(), otherDesc.getLevel());
58 }
59
60 ////////// ACCESSORS/MUTATORS
61
62 @Override
63 public long getId() {
64 return id;
65 }
66
67 @Override
68 protected void setId(long id) {
69 this.id = id ;
70 }
71
72 /**
73 *
74 * <P>
75 * TODO: no persistence for this for the moment! what for the ghost if modified?
76 * @param description
77 */
78 @Override
79 public void setDescription(String description) {
80 //TODO add a transient modification boolean checked by the persistence
81 super.setDescription(description);
82 }
83
84 public AParameterDescription clone() {
85 AParameterDescription res = null;
86 try {
87 res = (AParameterDescription) super.clone();
88 } catch (CloneNotSupportedException e) {/*IGNORE*/}
89 return res ;
90 }
91 }