From: Rishi Chail Date: Wed, 21 Oct 2020 11:04:16 +0000 (+0100) Subject: VSE: Introduce entities for fragment and dataspace X-Git-Tag: 0.0.1~120^2~9 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=6f523dbc6659ff5793f6707a71f2c401e1148d83;p=cps.git VSE: Introduce entities for fragment and dataspace Issue-ID: CCSDK-2898 https://jira.onap.org/browse/CCSDK-2898 Signed-off-by: Rishi Chail Change-Id: Iab733008021ea315707d4c4e6a6ec357f205ee05 --- diff --git a/cps/cps-ri/pom.xml b/cps/cps-ri/pom.xml index 334e47662..77cb5f86a 100644 --- a/cps/cps-ri/pom.xml +++ b/cps/cps-ri/pom.xml @@ -32,6 +32,12 @@ postgresql + + + com.vladmihalcea + hibernate-types-52 + ${hibernate-types.version} + org.projectlombok diff --git a/cps/cps-ri/src/main/java/org/onap/cps/spi/entities/Dataspace.java b/cps/cps-ri/src/main/java/org/onap/cps/spi/entities/Dataspace.java new file mode 100644 index 000000000..8f37692b1 --- /dev/null +++ b/cps/cps-ri/src/main/java/org/onap/cps/spi/entities/Dataspace.java @@ -0,0 +1,52 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.cps.spi.entities; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.validation.constraints.NotNull; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +/** + * Entity to store a dataspace. + */ +@Getter +@Setter +@Entity +@AllArgsConstructor +@NoArgsConstructor +@Table(name = "dataspace") +public class Dataspace { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + + @NotNull + @Column(columnDefinition = "text") + private String name; +} diff --git a/cps/cps-ri/src/main/java/org/onap/cps/spi/entities/Fragment.java b/cps/cps-ri/src/main/java/org/onap/cps/spi/entities/Fragment.java new file mode 100644 index 000000000..12422dc5f --- /dev/null +++ b/cps/cps-ri/src/main/java/org/onap/cps/spi/entities/Fragment.java @@ -0,0 +1,76 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.cps.spi.entities; + +import com.vladmihalcea.hibernate.type.json.JsonBinaryType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.OneToOne; +import javax.validation.constraints.NotNull; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import org.hibernate.annotations.Type; +import org.hibernate.annotations.TypeDef; +import org.hibernate.annotations.TypeDefs; + +/** + * Entity to store a fragment. + */ +@Getter +@Setter +@Entity +@AllArgsConstructor +@NoArgsConstructor +@TypeDefs({@TypeDef(name = "jsonb", typeClass = JsonBinaryType.class)}) +public class Fragment { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @NotNull + @Column(columnDefinition = "text") + private String xpath; + + @Type(type = "jsonb") + @Column(columnDefinition = "jsonb") + private String attributes; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "dataspace_id") + private Dataspace dataspace; + + @OneToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "anchor_id") + private Fragment anchorFragment; + + @OneToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "parent_id") + private Fragment parentFragment; +} diff --git a/cps/cps-ri/src/main/resources/hibernate.properties b/cps/cps-ri/src/main/resources/hibernate.properties new file mode 100644 index 000000000..a22fe63cf --- /dev/null +++ b/cps/cps-ri/src/main/resources/hibernate.properties @@ -0,0 +1 @@ +hibernate.types.print.banner=false \ No newline at end of file diff --git a/cps/pom.xml b/cps/pom.xml index c70af6be8..4e9ca39db 100644 --- a/cps/pom.xml +++ b/cps/pom.xml @@ -1,151 +1,153 @@ - 4.0.0 - - org.onap.oparent - oparent - 3.1.0 - - org.onap.cps - cps - 0.0.1-SNAPSHOT - pom - cps - ONAP Configuration and Persistency Service - - ONAP - CPS - http://www.onap.org/ - + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + + org.onap.oparent + oparent + 3.1.0 + + org.onap.cps + cps + 0.0.1-SNAPSHOT + pom + cps + ONAP Configuration and Persistency Service + + ONAP - CPS + http://www.onap.org/ + - - 11 - 2.3.3.RELEASE - 3.1.0 - 5.0.6 - 2.1.4 - 3.0.6 - 2.0-M2-groovy-3.0 - 3.1.2 - 3.2.0 - 1.5.3 - 3.35.0 - + + 11 + 2.3.3.RELEASE + 3.1.0 + 5.0.6 + 2.1.4 + 3.0.6 + 2.0-M2-groovy-3.0 + 3.1.2 + 3.2.0 + 1.5.3 + 3.35.0 + 2.10.0 + - - - - org.springframework.boot - spring-boot-dependencies - ${springboot.version} - pom - import - - - + + + + org.springframework.boot + spring-boot-dependencies + ${springboot.version} + pom + import + + + - - - - src/main/resources - true - + + + + src/main/resources + true + - - target/generated-sources/license - - third-party-licenses.txt - - + + target/generated-sources/license + + third-party-licenses.txt + + - - target/generated-resources/licenses - - *.* - - third-party-licenses - - + + target/generated-resources/licenses + + *.* + + third-party-licenses + + - - - org.apache.maven.plugins - maven-compiler-plugin - - ${java.version} - ${java.version} - - + + + org.apache.maven.plugins + maven-compiler-plugin + + ${java.version} + ${java.version} + + - - org.apache.maven.plugins - maven-checkstyle-plugin - - - onap-java-style - - check - - process-sources - - onap-checkstyle/onap-java-style.xml - ${project.build.sourceDirectory} - true - true - true - false - warning - true - - - + + org.apache.maven.plugins + maven-checkstyle-plugin + + + onap-java-style + + check + + process-sources + + onap-checkstyle/onap-java-style.xml + ${project.build.sourceDirectory} + true + true + true + false + warning + true + + + - - - org.onap.oparent - checkstyle - ${oparent.version} - - + + + org.onap.oparent + checkstyle + ${oparent.version} + + - + - - - - org.codehaus.gmavenplus - gmavenplus-plugin - 1.9.0 - - - - compileTests - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 3.0.0-M5 - - false - - **/*Spec.java - **/*Test.java - - - + + + + org.codehaus.gmavenplus + gmavenplus-plugin + 1.9.0 + + + + compileTests + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M5 + + false + + **/*Spec.java + **/*Test.java + + + - - + + - - cps-service - cps-rest - cps-ri - + + cps-service + cps-rest + cps-ri +