summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRishi Chail <rishi.chail@est.tech>2020-10-21 12:04:16 +0100
committerRishi Chail <rishi.chail@est.tech>2020-10-21 15:36:10 +0100
commit6f523dbc6659ff5793f6707a71f2c401e1148d83 (patch)
treec574c985d605e03d612706646c55be83313d5f95
parenta085206e0ab80d4179f766baa4d40c22f6c5283b (diff)
VSE: Introduce entities for fragment and dataspace
Issue-ID: CCSDK-2898 https://jira.onap.org/browse/CCSDK-2898 Signed-off-by: Rishi Chail <rishi.chail@est.tech> Change-Id: Iab733008021ea315707d4c4e6a6ec357f205ee05
-rw-r--r--cps/cps-ri/pom.xml6
-rw-r--r--cps/cps-ri/src/main/java/org/onap/cps/spi/entities/Dataspace.java52
-rw-r--r--cps/cps-ri/src/main/java/org/onap/cps/spi/entities/Fragment.java76
-rw-r--r--cps/cps-ri/src/main/resources/hibernate.properties1
-rw-r--r--cps/pom.xml274
5 files changed, 273 insertions, 136 deletions
diff --git a/cps/cps-ri/pom.xml b/cps/cps-ri/pom.xml
index 334e476624..77cb5f86ac 100644
--- a/cps/cps-ri/pom.xml
+++ b/cps/cps-ri/pom.xml
@@ -32,6 +32,12 @@
<artifactId>postgresql</artifactId>
</dependency>
+ <dependency>
+ <!-- Add Hibernate support for Postgres datatype JSONB -->
+ <groupId>com.vladmihalcea</groupId>
+ <artifactId>hibernate-types-52</artifactId>
+ <version>${hibernate-types.version}</version>
+ </dependency>
<dependency>
<groupId>org.projectlombok</groupId>
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 0000000000..8f37692b1d
--- /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 0000000000..12422dc5f6
--- /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 0000000000..a22fe63cfa
--- /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 c70af6be8a..4e9ca39db0 100644
--- a/cps/pom.xml
+++ b/cps/pom.xml
@@ -1,151 +1,153 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
- 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">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.onap.oparent</groupId>
- <artifactId>oparent</artifactId>
- <version>3.1.0</version>
- </parent>
- <groupId>org.onap.cps</groupId>
- <artifactId>cps</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- <packaging>pom</packaging>
- <name>cps</name>
- <description>ONAP Configuration and Persistency Service</description>
- <organization>
- <name>ONAP - CPS</name>
- <url>http://www.onap.org/</url>
- </organization>
+ 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">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.oparent</groupId>
+ <artifactId>oparent</artifactId>
+ <version>3.1.0</version>
+ </parent>
+ <groupId>org.onap.cps</groupId>
+ <artifactId>cps</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <packaging>pom</packaging>
+ <name>cps</name>
+ <description>ONAP Configuration and Persistency Service</description>
+ <organization>
+ <name>ONAP - CPS</name>
+ <url>http://www.onap.org/</url>
+ </organization>
- <properties>
- <java.version>11</java.version>
- <springboot.version>2.3.3.RELEASE</springboot.version>
- <oparent.version>3.1.0</oparent.version>
- <yangtools.version>5.0.6</yangtools.version>
- <swagger.version>2.1.4</swagger.version>
- <groovy.version>3.0.6</groovy.version>
- <spock-core.version>2.0-M2-groovy-3.0</spock-core.version>
- <maven-dependency-plugin.version>3.1.2</maven-dependency-plugin.version>
- <maven-resources-plugin.version>3.2.0</maven-resources-plugin.version>
- <maven-replacer-plugin.version>1.5.3</maven-replacer-plugin.version>
- <swagger-ui.version>3.35.0</swagger-ui.version>
- </properties>
+ <properties>
+ <java.version>11</java.version>
+ <springboot.version>2.3.3.RELEASE</springboot.version>
+ <oparent.version>3.1.0</oparent.version>
+ <yangtools.version>5.0.6</yangtools.version>
+ <swagger.version>2.1.4</swagger.version>
+ <groovy.version>3.0.6</groovy.version>
+ <spock-core.version>2.0-M2-groovy-3.0</spock-core.version>
+ <maven-dependency-plugin.version>3.1.2</maven-dependency-plugin.version>
+ <maven-resources-plugin.version>3.2.0</maven-resources-plugin.version>
+ <maven-replacer-plugin.version>1.5.3</maven-replacer-plugin.version>
+ <swagger-ui.version>3.35.0</swagger-ui.version>
+ <hibernate-types.version>2.10.0</hibernate-types.version>
+ </properties>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-dependencies</artifactId>
- <version>${springboot.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-dependencies</artifactId>
+ <version>${springboot.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
- <build>
- <resources>
- <resource>
- <directory>src/main/resources</directory>
- <filtering>true</filtering>
- </resource>
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ </resource>
- <resource>
- <directory>target/generated-sources/license</directory>
- <includes>
- <include>third-party-licenses.txt</include>
- </includes>
- </resource>
+ <resource>
+ <directory>target/generated-sources/license</directory>
+ <includes>
+ <include>third-party-licenses.txt</include>
+ </includes>
+ </resource>
- <resource>
- <directory>target/generated-resources/licenses</directory>
- <includes>
- <include>*.*</include>
- </includes>
- <targetPath>third-party-licenses</targetPath>
- </resource>
- </resources>
+ <resource>
+ <directory>target/generated-resources/licenses</directory>
+ <includes>
+ <include>*.*</include>
+ </includes>
+ <targetPath>third-party-licenses</targetPath>
+ </resource>
+ </resources>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>${java.version}</source>
- <target>${java.version}</target>
- </configuration>
- </plugin>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>${java.version}</source>
+ <target>${java.version}</target>
+ </configuration>
+ </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <executions>
- <execution>
- <id>onap-java-style</id>
- <goals>
- <goal>check</goal>
- </goals>
- <phase>process-sources</phase>
- <configuration>
- <configLocation>onap-checkstyle/onap-java-style.xml</configLocation>
- <sourceDirectories>${project.build.sourceDirectory}</sourceDirectories>
- <includeResources>true</includeResources>
- <includeTestSourceDirectory>true</includeTestSourceDirectory>
- <includeTestResources>true</includeTestResources>
- <consoleOutput>false</consoleOutput>
- <violationSeverity>warning</violationSeverity>
- <failOnViolation>true</failOnViolation>
- </configuration>
- </execution>
- </executions>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>onap-java-style</id>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ <phase>process-sources</phase>
+ <configuration>
+ <configLocation>onap-checkstyle/onap-java-style.xml</configLocation>
+ <sourceDirectories>${project.build.sourceDirectory}</sourceDirectories>
+ <includeResources>true</includeResources>
+ <includeTestSourceDirectory>true</includeTestSourceDirectory>
+ <includeTestResources>true</includeTestResources>
+ <consoleOutput>false</consoleOutput>
+ <violationSeverity>warning</violationSeverity>
+ <failOnViolation>true</failOnViolation>
+ </configuration>
+ </execution>
+ </executions>
- <dependencies>
- <dependency>
- <groupId>org.onap.oparent</groupId>
- <artifactId>checkstyle</artifactId>
- <version>${oparent.version}</version>
- </dependency>
- </dependencies>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.oparent</groupId>
+ <artifactId>checkstyle</artifactId>
+ <version>${oparent.version}</version>
+ </dependency>
+ </dependencies>
- </plugin>
+ </plugin>
- <!-- Mandatory plugins for using Spock -->
- <plugin>
- <!-- The gmavenplus plugin is used to compile Groovy code. To learn more about this plugin,
- visit https://github.com/groovy/GMavenPlus/wiki -->
- <groupId>org.codehaus.gmavenplus</groupId>
- <artifactId>gmavenplus-plugin</artifactId>
- <version>1.9.0</version>
- <executions>
- <execution>
- <goals>
- <goal>compileTests</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <!-- Required because names of spec classes don't match default Surefire patterns (`*Test` etc.) -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>3.0.0-M5</version>
- <configuration>
- <useFile>false</useFile>
- <includes>
- <include>**/*Spec.java</include>
- <include>**/*Test.java</include> <!-- Just in case of having also "normal" JUnit tests -->
- </includes>
- </configuration>
- </plugin>
+ <!-- Mandatory plugins for using Spock -->
+ <plugin>
+ <!-- The gmavenplus plugin is used to compile Groovy code.
+ To learn more about this plugin, visit https://github.com/groovy/GMavenPlus/wiki -->
+ <groupId>org.codehaus.gmavenplus</groupId>
+ <artifactId>gmavenplus-plugin</artifactId>
+ <version>1.9.0</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>compileTests</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <!-- Required because names of spec classes don't match default
+ Surefire patterns (`*Test` etc.) -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>3.0.0-M5</version>
+ <configuration>
+ <useFile>false</useFile>
+ <includes>
+ <include>**/*Spec.java</include>
+ <include>**/*Test.java</include> <!-- Just in case of having also "normal" JUnit tests -->
+ </includes>
+ </configuration>
+ </plugin>
- </plugins>
- </build>
+ </plugins>
+ </build>
- <modules>
- <module>cps-service</module>
- <module>cps-rest</module>
- <module>cps-ri</module>
- </modules>
+ <modules>
+ <module>cps-service</module>
+ <module>cps-rest</module>
+ <module>cps-ri</module>
+ </modules>
</project>