VSE: Upload modules (a model file) to a (new) dataspace
[cps.git] / cps / cps-ri / src / main / java / org / onap / cps / spi / entities / ModuleEntity.java
1 /*
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2020 Nordix Foundation
4  *  Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
5  *  ================================================================================
6  *  Licensed under the Apache License, Version 2.0 (the "License");
7  *  you may not use this file except in compliance with the License.
8  *  You may obtain a copy of the License at
9  *
10  *        http://www.apache.org/licenses/LICENSE-2.0
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  *  SPDX-License-Identifier: Apache-2.0
18  *  ============LICENSE_END=========================================================
19  */
20
21 package org.onap.cps.spi.entities;
22
23 import javax.persistence.Column;
24 import javax.persistence.Entity;
25 import javax.persistence.FetchType;
26 import javax.persistence.GeneratedValue;
27 import javax.persistence.GenerationType;
28 import javax.persistence.Id;
29 import javax.persistence.JoinColumn;
30 import javax.persistence.ManyToOne;
31 import javax.persistence.Table;
32 import javax.validation.constraints.NotNull;
33 import lombok.AllArgsConstructor;
34 import lombok.Getter;
35 import lombok.NoArgsConstructor;
36 import lombok.Setter;
37
38
39 /**
40  * Entity to store a yang module.
41  */
42 @Getter
43 @Setter
44 @Entity
45 @AllArgsConstructor
46 @NoArgsConstructor
47 @Table(name = "module")
48 public class ModuleEntity {
49
50     @Id
51     @GeneratedValue(strategy = GenerationType.IDENTITY)
52     private Integer id;
53
54     @NotNull
55     @Column
56     private String moduleContent;
57
58     @NotNull
59     @Column
60     private String revision;
61
62     @ManyToOne(fetch = FetchType.LAZY)
63     @JoinColumn(name = "dataspace_id", referencedColumnName = "ID")
64     private Dataspace dataspace;
65
66     @NotNull
67     @Column
68     private String namespace;
69
70     /**
71      * Initialize a module entity.
72      *
73      * @param namespace the module namespace.
74      * @param moduleContent the module content.
75      * @param revision the revision number of the module.
76      * @param dataspace the dataspace related to the module.
77      */
78     public ModuleEntity(String namespace, String moduleContent, String revision, Dataspace dataspace) {
79         this.namespace = namespace;
80         this.moduleContent = moduleContent;
81         this.revision = revision;
82         this.dataspace = dataspace;
83     }
84 }