Migrate ccsdk/apps to ccsdk/cds
[ccsdk/cds.git] / ms / controllerblueprints / modules / service / src / main / java / org / onap / ccsdk / cds / controllerblueprints / service / domain / BlueprintModelContent.java
1 /*
2  * Copyright © 2017-2018 AT&T Intellectual Property.
3  * Modifications Copyright © 2019 Bell Canada.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 package org.onap.ccsdk.cds.controllerblueprints.service.domain;
19
20 import com.fasterxml.jackson.annotation.JsonFormat;
21 import io.swagger.annotations.ApiModelProperty;
22 import org.springframework.data.annotation.LastModifiedDate;
23 import org.springframework.data.jpa.domain.support.AuditingEntityListener;
24
25 import javax.persistence.*;
26 import java.io.Serializable;
27 import java.util.Date;
28 import java.util.Objects;
29
30 /**
31  * DataDictionary.java Purpose: Provide Configuration Generator DataDictionary Entity
32  *
33  * @author Brinda Santh
34  * @version 1.0
35  */
36 @EntityListeners({AuditingEntityListener.class})
37 @Entity
38 @Table(name = "CONFIG_MODEL_CONTENT")
39 public class BlueprintModelContent implements Serializable {
40
41     private static final long serialVersionUID = 1L;
42
43     @Id
44     @Column(name = "config_model_content_id")
45     private String id;
46
47     @Column(name = "name", nullable = false)
48     @ApiModelProperty(required=true)
49     private String name;
50
51     @Column(name = "content_type", nullable = false)
52     @ApiModelProperty(required=true)
53     private String contentType;
54
55     @OneToOne
56     @JoinColumn(name = "config_model_id")
57     private BlueprintModel blueprintModel;
58
59     @Lob
60     @Column(name = "description")
61     private String description;
62
63     @Lob
64     @Column(name = "content", nullable = false)
65     @ApiModelProperty(required=true)
66     private byte[]  content;
67
68     @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
69     @LastModifiedDate
70     @Temporal(TemporalType.TIMESTAMP)
71     @Column(name = "updated_date")
72     private Date creationDate = new Date();
73
74     @Override
75     public String toString() {
76         return "[" + "id = " + id +
77                 ", name = " + name +
78                 ", contentType = " + contentType +
79                 "]";
80     }
81
82     @Override
83     public boolean equals(Object o) {
84
85         if (o == this) {
86             return true;
87         }
88         if (!(o instanceof BlueprintModelContent)) {
89             return false;
90         }
91         BlueprintModelContent blueprintModelContent = (BlueprintModelContent) o;
92         return Objects.equals(id, blueprintModelContent.id) && Objects.equals(name, blueprintModelContent.name)
93                 && Objects.equals(contentType, blueprintModelContent.contentType);
94     }
95
96     @Override
97     public int hashCode() {
98         return Objects.hash(id, name, contentType);
99     }
100
101     public String getId() {
102         return id;
103     }
104
105
106     public void setId(String id) {
107         this.id = id;
108     }
109
110
111     public String getName() {
112         return name;
113     }
114
115
116     public void setName(String name) {
117         this.name = name;
118     }
119
120
121     public String getContentType() {
122         return contentType;
123     }
124
125
126     public void setContentType(String contentType) {
127         this.contentType = contentType;
128     }
129
130
131     public BlueprintModel getBlueprintModel() {
132         return blueprintModel;
133     }
134
135
136     public void setBlueprintModel(BlueprintModel blueprintModel) {
137         this.blueprintModel = blueprintModel;
138     }
139
140
141     public String getDescription() {
142         return description;
143     }
144
145
146     public void setDescription(String description) {
147         this.description = description;
148     }
149
150
151     public byte[] getContent() {
152         return content;
153     }
154
155
156     public void setContent(byte[] content) {
157         this.content = content;
158     }
159
160
161     public Date getCreationDate() {
162         return creationDate;
163     }
164
165
166     public void setCreationDate(Date creationDate) {
167         this.creationDate = creationDate;
168     }
169
170 }