summaryrefslogtreecommitdiffstats
path: root/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service
diff options
context:
space:
mode:
authorwaqas.ikram <waqas.ikram@est.tech>2023-01-20 15:13:37 +0000
committerwaqas.ikram <waqas.ikram@est.tech>2023-01-20 15:17:06 +0000
commit80d8598e1013ddee747957adf7d96ec7fb901f0b (patch)
tree22abb6785bff62898b596012decb777d467377bc /so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service
parent636794685ae4ff2a5f802fbffdffabbe6bcae164 (diff)
Adding so cnfm database module
Change-Id: I2eebd5ed356b879f485aad4dd5e6bf46df3ed69b Issue-ID: SO-4068 Signed-off-by: waqas.ikram <waqas.ikram@est.tech>
Diffstat (limited to 'so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service')
-rw-r--r--so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/pom.xml49
-rw-r--r--so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/AsDeploymentItem.java277
-rw-r--r--so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/AsInst.java381
-rw-r--r--so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/AsLcmOpOcc.java250
-rw-r--r--so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/AsLcmOpType.java28
-rw-r--r--so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/AsLifecycleParam.java134
-rw-r--r--so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/CancelModeType.java29
-rw-r--r--so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/Job.java262
-rw-r--r--so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/JobAction.java29
-rw-r--r--so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/JobStatus.java155
-rw-r--r--so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/JobStatusEnum.java29
-rw-r--r--so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/OperationStateEnum.java29
-rw-r--r--so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/State.java29
-rw-r--r--so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/utils/Utils.java59
-rw-r--r--so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/config/CnfmDatabaseConfiguration.java95
-rw-r--r--so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/repository/AsDeploymentItemRepository.java50
-rw-r--r--so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/repository/AsInstRepository.java46
-rw-r--r--so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/repository/AsLcmOpOccRepository.java43
-rw-r--r--so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/repository/AsLifecycleParamRepository.java38
-rw-r--r--so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/repository/JobRepository.java35
-rw-r--r--so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/repository/JobStatusRepository.java30
-rw-r--r--so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/repository/RefreshableRepository.java30
-rw-r--r--so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/repository/RefreshableRepositoryImpl.java42
-rw-r--r--so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/service/DatabaseServiceProvider.java201
-rw-r--r--so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/resources/db/migration/V1_1__create_cnfm_tables.sql90
-rw-r--r--so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/test/java/org/onap/so/cnfm/lcm/database/PojoClassesTests.java88
-rw-r--r--so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/test/java/org/onap/so/cnfm/lcm/database/TestApplication.java45
-rw-r--r--so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/test/java/org/onap/so/cnfm/lcm/database/beans/utils/UtilsTest.java71
-rw-r--r--so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/test/java/org/onap/so/cnfm/lcm/database/service/DatabaseServiceProviderTest.java214
-rw-r--r--so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/test/resources/application.yaml31
30 files changed, 2889 insertions, 0 deletions
diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/pom.xml b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/pom.xml
new file mode 100644
index 0000000..0a94e2e
--- /dev/null
+++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/pom.xml
@@ -0,0 +1,49 @@
+<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.so.adapters.so-cnf-adapter.so-cnfm.lcm</groupId>
+ <artifactId>so-cnfm-lcm</artifactId>
+ <version>1.9.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>so-cnfm-lcm-database-service</artifactId>
+ <name>SO CNFM LCM Database Service</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-data-jpa</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.mariadb.jdbc</groupId>
+ <artifactId>mariadb-java-client</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.flywaydb</groupId>
+ <artifactId>flyway-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>nl.jqno.equalsverifier</groupId>
+ <artifactId>equalsverifier</artifactId>
+ <version>${equalsverifier-version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.so</groupId>
+ <artifactId>common</artifactId>
+ <version>${so-core-version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project> \ No newline at end of file
diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/AsDeploymentItem.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/AsDeploymentItem.java
new file mode 100644
index 0000000..c27aaad
--- /dev/null
+++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/AsDeploymentItem.java
@@ -0,0 +1,277 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * 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.so.cnfm.lcm.database.beans;
+
+import static org.onap.so.cnfm.lcm.database.beans.utils.Utils.toIndentedString;
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+import java.util.UUID;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+
+
+/**
+ *
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+@Entity
+@Table(name = "AS_DEPLOYMENT_ITEM")
+public class AsDeploymentItem {
+
+ @Id
+ @Column(name = "AS_DEP_ITEM_INST_ID", nullable = false)
+ private String asDeploymentItemInstId;
+
+ @Column(name = "NAME")
+ private String name;
+
+ @Column(name = "ITEM_ID")
+ private String itemId;
+
+ @Column(name = "DEPLOYMENT_ORDER")
+ private Integer deploymentOrder;
+
+ @Column(name = "ARTIFACT_FILE_PATH")
+ private String artifactFilePath;
+
+ @Enumerated(EnumType.STRING)
+ @Column(name = "STATUS", nullable = false)
+ private State status;
+
+ @ManyToOne(fetch = FetchType.LAZY)
+ @JoinColumn(name = "AS_INST_ID", nullable = false)
+ private AsInst asInst;
+
+ @Column(name = "CREATE_TIME")
+ private LocalDateTime createTime;
+
+ @Column(name = "LAST_UPDATE_TIME")
+ private LocalDateTime lastUpdateTime;
+
+ @Column(name = "RELEASE_NAME", nullable = false)
+ private String releaseName;
+
+ @OneToMany(mappedBy = "asDeploymentItemInst", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
+ private List<AsLifecycleParam> asLifecycleParams = new ArrayList<>();
+
+ public AsDeploymentItem() {
+ this.asDeploymentItemInstId = UUID.randomUUID().toString();
+ }
+
+ public String getAsDeploymentItemInstId() {
+ return asDeploymentItemInstId;
+ }
+
+ public void setAsDeploymentItemInstId(final String asDeploymentItemInstId) {
+ this.asDeploymentItemInstId = asDeploymentItemInstId;
+ }
+
+ public AsDeploymentItem asDeploymentItemInstId(final String asDeploymentItemInstId) {
+ this.asDeploymentItemInstId = asDeploymentItemInstId;
+ return this;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ public AsDeploymentItem name(final String name) {
+ this.name = name;
+ return this;
+ }
+
+ public String getItemId() {
+ return itemId;
+ }
+
+ public void setItemId(final String itemId) {
+ this.itemId = itemId;
+ }
+
+ public AsDeploymentItem itemId(final String itemId) {
+ this.itemId = itemId;
+ return this;
+ }
+
+ public Integer getDeploymentOrder() {
+ return deploymentOrder;
+ }
+
+ public void setDeploymentOrder(final Integer deploymentOrder) {
+ this.deploymentOrder = deploymentOrder;
+ }
+
+ public AsDeploymentItem deploymentOrder(final Integer deploymentOrder) {
+ this.deploymentOrder = deploymentOrder;
+ return this;
+ }
+
+ public String getArtifactFilePath() {
+ return artifactFilePath;
+ }
+
+ public void setArtifactFilePath(final String artifactFilePath) {
+ this.artifactFilePath = artifactFilePath;
+ }
+
+ public AsDeploymentItem artifactFilePath(final String artifactFilePath) {
+ this.artifactFilePath = artifactFilePath;
+ return this;
+ }
+
+ public State getStatus() {
+ return status;
+ }
+
+ public void setStatus(final State status) {
+ this.status = status;
+ }
+
+ public AsDeploymentItem status(final State status) {
+ this.status = status;
+ return this;
+ }
+
+
+ public AsInst getAsInst() {
+ return asInst;
+ }
+
+ public void setAsInst(final AsInst asInst) {
+ this.asInst = asInst;
+ }
+
+ public AsDeploymentItem asInst(final AsInst asInst) {
+ this.asInst = asInst;
+ return this;
+ }
+
+ public LocalDateTime getCreateTime() {
+ return createTime;
+ }
+
+ public void setCreateTime(final LocalDateTime createTime) {
+ this.createTime = createTime;
+ }
+
+ public AsDeploymentItem createTime(final LocalDateTime createTime) {
+ this.createTime = createTime;
+ return this;
+ }
+
+ public LocalDateTime getLastUpdateTime() {
+ return lastUpdateTime;
+ }
+
+ public void setLastUpdateTime(final LocalDateTime lastUpdateTime) {
+ this.lastUpdateTime = lastUpdateTime;
+ }
+
+ public AsDeploymentItem lastUpdateTime(final LocalDateTime lastUpdateTime) {
+ this.lastUpdateTime = lastUpdateTime;
+ return this;
+ }
+
+ public String getReleaseName() {
+ return releaseName;
+ }
+
+ public void setReleaseName(final String releaseName) {
+ this.releaseName = releaseName;
+ }
+
+ public AsDeploymentItem releaseName(final String releaseName) {
+ this.releaseName = releaseName;
+ return this;
+ }
+
+ public List<AsLifecycleParam> getAsLifecycleParams() {
+ return asLifecycleParams;
+ }
+
+ public void setAsLifecycleParams(final List<AsLifecycleParam> asLifecycleParams) {
+ this.asLifecycleParams = asLifecycleParams;
+ }
+
+ public AsDeploymentItem asLifecycleParams(final AsLifecycleParam asLifecycleParam) {
+ asLifecycleParam.asDeploymentItemInst(this);
+ this.asLifecycleParams.add(asLifecycleParam);
+ return this;
+ }
+
+ @Override
+ public boolean equals(final Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+ final AsDeploymentItem that = (AsDeploymentItem) o;
+ return Objects.equals(asDeploymentItemInstId, that.asDeploymentItemInstId) && Objects.equals(name, that.name)
+ && Objects.equals(itemId, that.itemId) && Objects.equals(deploymentOrder, that.deploymentOrder)
+ && Objects.equals(artifactFilePath, that.artifactFilePath)
+ && (asInst == null ? that.asInst == null : that.asInst != null && Objects.equals(asInst, that.asInst))
+ && Objects.equals(status, that.status) && Objects.equals(createTime, that.createTime)
+ && Objects.equals(lastUpdateTime, that.lastUpdateTime) && Objects.equals(releaseName, that.releaseName)
+ && Objects.equals(asLifecycleParams, that.asLifecycleParams);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(asDeploymentItemInstId, name, itemId, deploymentOrder, artifactFilePath, status, asInst,
+ createTime, lastUpdateTime, releaseName, asLifecycleParams);
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("class AsdeploymentItem {\n");
+ sb.append(" asDeploymentItemInstId: ").append(toIndentedString(asDeploymentItemInstId)).append("\n");
+ sb.append(" name: ").append(toIndentedString(name)).append("\n");
+ sb.append(" itemId: ").append(toIndentedString(itemId)).append("\n");
+ sb.append(" deploymentOrder: ").append(toIndentedString(deploymentOrder)).append("\n");
+ sb.append(" artifactFilePath: ").append(toIndentedString(artifactFilePath)).append("\n");
+ sb.append(" asInst: ").append(asInst != null ? toIndentedString(asInst.getAsInstId()) : null).append("\n");
+ sb.append(" status: ").append(toIndentedString(status)).append("\n");
+ sb.append(" createTime: ").append(toIndentedString(createTime)).append("\n");
+ sb.append(" lastUpdateTime: ").append(toIndentedString(lastUpdateTime)).append("\n");
+ sb.append(" releaseName: ").append(toIndentedString(releaseName)).append("\n");
+ sb.append(" asLifecycleParams").append(toIndentedString(asLifecycleParams)).append("\n");
+ sb.append("}");
+ return sb.toString();
+ }
+
+
+}
diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/AsInst.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/AsInst.java
new file mode 100644
index 0000000..e6538bc
--- /dev/null
+++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/AsInst.java
@@ -0,0 +1,381 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * 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.so.cnfm.lcm.database.beans;
+
+import static org.onap.so.cnfm.lcm.database.beans.utils.Utils.toIndentedString;
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+import java.util.UUID;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+@Entity
+@Table(name = "AS_INST")
+public class AsInst {
+
+ @Id
+ @Column(name = "AS_INST_ID", nullable = false)
+ private String asInstId;
+
+ @Column(name = "NAME", nullable = false)
+ private String name;
+
+ @Column(name = "DESCRIPTION", columnDefinition = "LONGTEXT")
+ private String description;
+
+ @Column(name = "AS_PACKAGE_ID")
+ private String asPackageId;
+
+ @Column(name = "ASD_ID", nullable = false)
+ private String asdId;
+
+ @Column(name = "ASD_INVARIANT_ID", nullable = false)
+ private String asdInvariantId;
+
+ @Column(name = "AS_PROVIDER", nullable = false)
+ private String asProvider;
+
+ @Column(name = "AS_APPLICATION_NAME", nullable = false)
+ private String asApplicationName;
+
+ @Column(name = "AS_APPLICATION_VERSION", nullable = false)
+ private String asApplicationVersion;
+
+ @Column(name = "SERVICE_INSTANCE_ID", nullable = false)
+ private String serviceInstanceId;
+
+ @Column(name = "SERVICE_INSTANCE_NAME", nullable = false)
+ private String serviceInstanceName;
+
+ @Column(name = "CLOUD_OWNER", nullable = false)
+ private String cloudOwner;
+
+ @Column(name = "CLOUD_REGION", nullable = false)
+ private String cloudRegion;
+
+ @Column(name = "TENANT_ID", nullable = false)
+ private String tenantId;
+
+ @Enumerated(EnumType.STRING)
+ @Column(name = "STATUS", nullable = false)
+ private State status;
+
+ @Column(name = "STATUS_UPDATED_TIME", nullable = false)
+ private LocalDateTime statusUpdatedTime;
+
+ @OneToMany(mappedBy = "asInst", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
+ private List<AsDeploymentItem> asdeploymentItems = new ArrayList<>();
+
+ public AsInst() {
+ this.asInstId = UUID.randomUUID().toString();
+ }
+
+ public String getAsInstId() {
+ return asInstId;
+ }
+
+ public void setAsInstId(final String asInstId) {
+ this.asInstId = asInstId;
+ }
+
+ public AsInst asInstId(final String asInstId) {
+ this.asInstId = asInstId;
+ return this;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ public AsInst name(final String name) {
+ this.name = name;
+ return this;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(final String description) {
+ this.description = description;
+ }
+
+ public AsInst description(final String description) {
+ this.description = description;
+ return this;
+ }
+
+ public String getAsPackageId() {
+ return asPackageId;
+ }
+
+ public void setAsPackageId(final String asPackageId) {
+ this.asPackageId = asPackageId;
+ }
+
+ public AsInst asPackageId(final String asPackageId) {
+ this.asPackageId = asPackageId;
+ return this;
+ }
+
+ public String getAsdId() {
+ return asdId;
+ }
+
+ public void setAsdId(final String asdId) {
+ this.asdId = asdId;
+ }
+
+ public AsInst asdId(final String asdId) {
+ this.asdId = asdId;
+ return this;
+ }
+
+ public String getAsdInvariantId() {
+ return asdInvariantId;
+ }
+
+ public void setAsdInvariantId(final String asdInvariantId) {
+ this.asdInvariantId = asdInvariantId;
+ }
+
+ public AsInst asdInvariantId(final String nsdInvariantId) {
+ this.asdInvariantId = nsdInvariantId;
+ return this;
+ }
+
+ public String getAsProvider() {
+ return asProvider;
+ }
+
+ public void setAsProvider(final String asProvider) {
+ this.asProvider = asProvider;
+ }
+
+ public AsInst asProvider(final String asProvider) {
+ this.asProvider = asProvider;
+ return this;
+ }
+
+ public String getAsApplicationName() {
+ return asApplicationName;
+ }
+
+ public void setAsApplicationName(final String asApplicationName) {
+ this.asApplicationName = asApplicationName;
+ }
+
+ public AsInst asApplicationName(final String asApplicationName) {
+ this.asApplicationName = asApplicationName;
+ return this;
+ }
+
+ public String getAsApplicationVersion() {
+ return asApplicationVersion;
+ }
+
+ public void setAsApplicationVersion(final String asApplicationVersion) {
+ this.asApplicationVersion = asApplicationVersion;
+ }
+
+ public AsInst asApplicationVersion(final String asApplicationVersion) {
+ this.asApplicationVersion = asApplicationVersion;
+ return this;
+ }
+
+ public String getServiceInstanceId() {
+ return serviceInstanceId;
+ }
+
+ public void setServiceInstanceId(final String serviceInstanceId) {
+ this.serviceInstanceId = serviceInstanceId;
+ }
+
+ public AsInst serviceInstanceId(final String serviceInstanceId) {
+ this.serviceInstanceId = serviceInstanceId;
+ return this;
+ }
+
+ public String getServiceInstanceName() {
+ return serviceInstanceName;
+ }
+
+ public void setServiceInstanceName(final String serviceInstanceName) {
+ this.serviceInstanceName = serviceInstanceName;
+ }
+
+ public AsInst serviceInstanceName(final String serviceInstanceName) {
+ this.serviceInstanceName = serviceInstanceName;
+ return this;
+ }
+
+ public String getCloudOwner() {
+ return cloudOwner;
+ }
+
+ public void setCloudOwner(final String cloudOwner) {
+ this.cloudOwner = cloudOwner;
+ }
+
+ public AsInst cloudOwner(final String cloudOwner) {
+ this.cloudOwner = cloudOwner;
+ return this;
+ }
+
+ public String getCloudRegion() {
+ return cloudRegion;
+ }
+
+ public void setCloudRegion(final String cloudRegion) {
+ this.cloudRegion = cloudRegion;
+ }
+
+ public AsInst cloudRegion(final String cloudRegion) {
+ this.cloudRegion = cloudRegion;
+ return this;
+ }
+
+ public String getTenantId() {
+ return tenantId;
+ }
+
+ public void setTenantId(final String tenantId) {
+ this.tenantId = tenantId;
+ }
+
+ public AsInst tenantId(final String tenantId) {
+ this.tenantId = tenantId;
+ return this;
+ }
+
+ public State getStatus() {
+ return status;
+ }
+
+ public void setStatus(final State status) {
+ this.status = status;
+ }
+
+ public AsInst status(final State status) {
+ this.status = status;
+ return this;
+ }
+
+ public LocalDateTime getStatusUpdatedTime() {
+ return statusUpdatedTime;
+ }
+
+ public void setStatusUpdatedTime(final LocalDateTime statusUpdatedTime) {
+ this.statusUpdatedTime = statusUpdatedTime;
+ }
+
+ public AsInst statusUpdatedTime(final LocalDateTime statusUpdatedTime) {
+ this.statusUpdatedTime = statusUpdatedTime;
+ return this;
+ }
+
+ public List<AsDeploymentItem> getAsdeploymentItems() {
+ return asdeploymentItems;
+ }
+
+ public void setAsdeploymentItems(final List<AsDeploymentItem> asdeploymentItems) {
+ this.asdeploymentItems = asdeploymentItems;
+ }
+
+ public AsInst asdeploymentItems(final AsDeploymentItem asdeploymentItem) {
+ asdeploymentItem.asInst(this);
+ this.asdeploymentItems.add(asdeploymentItem);
+ return this;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(asInstId, name, description, asPackageId, asdId, asdInvariantId, asProvider,
+ asApplicationName, asApplicationVersion, serviceInstanceId, serviceInstanceName, cloudOwner,
+ cloudRegion, tenantId, status, statusUpdatedTime, asdeploymentItems);
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null || getClass() != obj.getClass())
+ return false;
+ if (obj instanceof AsInst) {
+ final AsInst other = (AsInst) obj;
+ return Objects.equals(asInstId, other.asInstId) && Objects.equals(name, other.name)
+ && Objects.equals(description, other.description) && Objects.equals(asPackageId, other.asPackageId)
+ && Objects.equals(asdId, other.asdId) && Objects.equals(asdInvariantId, other.asdInvariantId)
+ && Objects.equals(asProvider, other.asProvider)
+ && Objects.equals(asApplicationName, other.asApplicationName)
+ && Objects.equals(asApplicationVersion, other.asApplicationVersion)
+ && Objects.equals(serviceInstanceId, other.serviceInstanceId)
+ && Objects.equals(serviceInstanceName, other.serviceInstanceName)
+ && Objects.equals(cloudOwner, other.cloudOwner) && Objects.equals(cloudRegion, other.cloudRegion)
+ && Objects.equals(tenantId, other.tenantId) && Objects.equals(status, other.status)
+ && Objects.equals(statusUpdatedTime, other.statusUpdatedTime)
+ && Objects.equals(asdeploymentItems, other.asdeploymentItems);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("class AsInst {\n");
+ sb.append(" asInstId: ").append(toIndentedString(asInstId)).append("\n");
+ sb.append(" name: ").append(toIndentedString(name)).append("\n");
+ sb.append(" description: ").append(toIndentedString(description)).append("\n");
+ sb.append(" asPackageId: ").append(toIndentedString(asPackageId)).append("\n");
+ sb.append(" asdId: ").append(toIndentedString(asdId)).append("\n");
+ sb.append(" asProvider: ").append(toIndentedString(asProvider)).append("\n");
+ sb.append(" asApplicationName: ").append(toIndentedString(asApplicationName)).append("\n");
+ sb.append(" asApplicationVersion: ").append(toIndentedString(asApplicationVersion)).append("\n");
+ sb.append(" serviceInstanceId: ").append(toIndentedString(serviceInstanceId)).append("\n");
+ sb.append(" serviceInstanceName: ").append(toIndentedString(serviceInstanceName)).append("\n");
+ sb.append(" cloudOwner: ").append(toIndentedString(cloudOwner)).append("\n");
+ sb.append(" cloudRegion: ").append(toIndentedString(cloudRegion)).append("\n");
+ sb.append(" tenantId: ").append(toIndentedString(tenantId)).append("\n");
+ sb.append(" status: ").append(toIndentedString(status)).append("\n");
+ sb.append(" statusUpdatedTime: ").append(toIndentedString(statusUpdatedTime)).append("\n");
+ sb.append(" asdeploymentItems: ").append(toIndentedString(asdeploymentItems)).append("\n");
+
+ sb.append("}");
+ return sb.toString();
+ }
+
+}
diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/AsLcmOpOcc.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/AsLcmOpOcc.java
new file mode 100644
index 0000000..b064170
--- /dev/null
+++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/AsLcmOpOcc.java
@@ -0,0 +1,250 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * 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.so.cnfm.lcm.database.beans;
+
+import static org.onap.so.cnfm.lcm.database.beans.utils.Utils.toIndentedString;
+import java.time.LocalDateTime;
+import java.util.Objects;
+import java.util.UUID;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ */
+@Entity
+@Table(name = "AS_LCM_OP_OCCS")
+public class AsLcmOpOcc {
+
+ @Id
+ @Column(name = "ID", nullable = false)
+ private String id;
+
+ @Enumerated(EnumType.STRING)
+ @Column(name = "OPERATION_STATE", nullable = false)
+ private OperationStateEnum operationState;
+
+ @Column(name = "STATE_ENTERED_TIME")
+ private LocalDateTime stateEnteredTime;
+
+ @Column(name = "START_TIME")
+ private LocalDateTime startTime;
+
+ @ManyToOne(fetch = FetchType.LAZY)
+ @JoinColumn(name = "AS_INST_ID", nullable = false)
+ private AsInst asInst;
+
+ @Enumerated(EnumType.STRING)
+ @Column(name = "OPERATION", nullable = false)
+ private AsLcmOpType operation;
+
+ @Column(name = "IS_AUTO_INVOCATION", nullable = false)
+ private boolean isAutoInvocation;
+
+ @Column(name = "OPERATION_PARAMS", columnDefinition = "LONGTEXT", nullable = false)
+ private String operationParams;
+
+ @Column(name = "IS_CANCEL_PENDING", nullable = false)
+ private boolean isCancelPending;
+
+ @Enumerated(EnumType.STRING)
+ @Column(name = "CANCEL_MODE")
+ private CancelModeType cancelMode;
+
+ public AsLcmOpOcc() {
+ this.id = UUID.randomUUID().toString();
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(final String id) {
+ this.id = id;
+ }
+
+ public AsLcmOpOcc id(final String id) {
+ this.id = id;
+ return this;
+ }
+
+ public OperationStateEnum getOperationState() {
+ return operationState;
+ }
+
+ public void setOperationState(final OperationStateEnum operationState) {
+ this.operationState = operationState;
+ }
+
+ public AsLcmOpOcc operationState(final OperationStateEnum operationState) {
+ this.operationState = operationState;
+ return this;
+ }
+
+ public LocalDateTime getStateEnteredTime() {
+ return stateEnteredTime;
+ }
+
+ public void setStateEnteredTime(final LocalDateTime stateEnteredTime) {
+ this.stateEnteredTime = stateEnteredTime;
+ }
+
+ public AsLcmOpOcc stateEnteredTime(final LocalDateTime stateEnteredTime) {
+ this.stateEnteredTime = stateEnteredTime;
+ return this;
+ }
+
+ public LocalDateTime getStartTime() {
+ return startTime;
+ }
+
+ public void setStartTime(final LocalDateTime startTime) {
+ this.startTime = startTime;
+ }
+
+ public AsLcmOpOcc startTime(final LocalDateTime startTime) {
+ this.startTime = startTime;
+ return this;
+ }
+
+ public AsInst getAsInst() {
+ return asInst;
+ }
+
+ public void setAsInst(final AsInst asInst) {
+ this.asInst = asInst;
+ }
+
+ public AsLcmOpOcc asInst(final AsInst asInst) {
+ this.asInst = asInst;
+ return this;
+ }
+
+ public AsLcmOpType getOperation() {
+ return operation;
+ }
+
+ public void setOperation(final AsLcmOpType operation) {
+ this.operation = operation;
+ }
+
+ public AsLcmOpOcc operation(final AsLcmOpType operation) {
+ this.operation = operation;
+ return this;
+ }
+
+ public boolean getIsAutoInvocation() {
+ return isAutoInvocation;
+ }
+
+ public void setIsAutoInvocation(final boolean isAutoInvocation) {
+ this.isAutoInvocation = isAutoInvocation;
+ }
+
+ public AsLcmOpOcc isAutoInvocation(final boolean isAutoInvocation) {
+ this.isAutoInvocation = isAutoInvocation;
+ return this;
+ }
+
+ public CancelModeType getCancelMode() {
+ return cancelMode;
+ }
+
+ public void setCancelMode(final CancelModeType cancelMode) {
+ this.cancelMode = cancelMode;
+ }
+
+ public AsLcmOpOcc cancelMode(final CancelModeType cancelMode) {
+ this.cancelMode = cancelMode;
+ return this;
+ }
+
+ public String getOperationParams() {
+ return operationParams;
+ }
+
+ public void setOperationParams(final String operationParams) {
+ this.operationParams = operationParams;
+ }
+
+ public AsLcmOpOcc operationParams(final String operationParams) {
+ this.operationParams = operationParams;
+ return this;
+ }
+
+ public boolean getIsCancelPending() {
+ return isCancelPending;
+ }
+
+ public void setIsCancelPending(final boolean isCancelPending) {
+ this.isCancelPending = isCancelPending;
+ }
+
+ public AsLcmOpOcc isCancelPending(final boolean isCancelPending) {
+ this.isCancelPending = isCancelPending;
+ return this;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null || getClass() != obj.getClass())
+ return false;
+ final AsLcmOpOcc that = (AsLcmOpOcc) obj;
+ return Objects.equals(id, that.id) && Objects.equals(operationState, that.operationState)
+ && Objects.equals(stateEnteredTime, that.stateEnteredTime) && Objects.equals(startTime, that.startTime)
+ && (asInst == null ? that.asInst == null : that.asInst != null && Objects.equals(asInst, that.asInst))
+ && Objects.equals(operation, that.operation) && Objects.equals(isAutoInvocation, that.isAutoInvocation)
+ && Objects.equals(operationParams, that.operationParams)
+ && Objects.equals(isCancelPending, that.isCancelPending) && Objects.equals(cancelMode, that.cancelMode);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id, operationState, stateEnteredTime, startTime, asInst != null ? asInst.getAsInstId() : 0,
+ operation, isAutoInvocation, operationParams, isCancelPending, cancelMode);
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("class NsLcmOpOcc {\n");
+ sb.append(" id: ").append(toIndentedString(id)).append("\n");
+ sb.append(" operationState: ").append(toIndentedString(operationState)).append("\n");
+ sb.append(" stateEnteredTime: ").append(toIndentedString(stateEnteredTime)).append("\n");
+ sb.append(" startTime: ").append(toIndentedString(startTime)).append("\n");
+ sb.append(" asInstId: ").append(asInst != null ? toIndentedString(asInst.getAsInstId()) : null).append("\n");
+ sb.append(" operation: ").append(toIndentedString(operation)).append("\n");
+ sb.append(" isAutoInvocation: ").append(toIndentedString(isAutoInvocation)).append("\n");
+ sb.append(" operationParams: ").append(toIndentedString(operationParams)).append("\n");
+ sb.append(" isCancelPending: ").append(toIndentedString(isCancelPending)).append("\n");
+ sb.append(" cancelMode: ").append(toIndentedString(cancelMode)).append("\n");
+ sb.append("}");
+ return sb.toString();
+ }
+}
diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/AsLcmOpType.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/AsLcmOpType.java
new file mode 100644
index 0000000..2d242bb
--- /dev/null
+++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/AsLcmOpType.java
@@ -0,0 +1,28 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * 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.so.cnfm.lcm.database.beans;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public enum AsLcmOpType {
+ INSTANTIATE, TERMINATE, OPERATE;
+}
diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/AsLifecycleParam.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/AsLifecycleParam.java
new file mode 100644
index 0000000..607886c
--- /dev/null
+++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/AsLifecycleParam.java
@@ -0,0 +1,134 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * 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.so.cnfm.lcm.database.beans;
+
+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.Table;
+import java.util.Objects;
+import static org.onap.so.cnfm.lcm.database.beans.utils.Utils.toIndentedString;
+
+/**
+ *
+ * @author Gerard Nugent (gerard.nugent@est.tech)
+ *
+ */
+@Entity
+@Table(name = "AS_LIFECYCLE_PARAM")
+public class AsLifecycleParam {
+
+ @Id
+ @Column(name = "AS_LCP_ID", nullable = false)
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ private Integer asLifecycleParamId;
+
+ @ManyToOne(fetch = FetchType.LAZY)
+ @JoinColumn(name = "AS_DEP_ITEM_INST_ID", nullable = false)
+ private AsDeploymentItem asDeploymentItemInst;
+
+ @Column(name = "LIFECYCLE_PARAM")
+ private String lifecycleParam;
+
+ public AsLifecycleParam() {
+
+ }
+
+ public void setAsLifecycleParamId(final Integer asLifecycleParamId) {
+ this.asLifecycleParamId = asLifecycleParamId;
+ }
+
+ public Integer getAsLifecycleParamId() {
+ return asLifecycleParamId;
+ }
+
+ public AsLifecycleParam asLifecycleParamId(final Integer asLifecycleParamId) {
+ this.asLifecycleParamId = asLifecycleParamId;
+ return this;
+ }
+
+ public AsDeploymentItem getAsDeploymentItemInst() {
+ return asDeploymentItemInst;
+ }
+
+ public void setAsDeploymentItemInst(final AsDeploymentItem asDeploymentItemInst) {
+ this.asDeploymentItemInst = asDeploymentItemInst;
+ }
+
+ public AsLifecycleParam asDeploymentItemInst(final AsDeploymentItem asDeploymentItemInst) {
+ this.asDeploymentItemInst = asDeploymentItemInst;
+ return this;
+ }
+
+ public String getLifecycleParam() {
+ return lifecycleParam;
+ }
+
+ public void setLifecycleParam(final String lifecycleParam) {
+ this.lifecycleParam = lifecycleParam;
+ }
+
+ public AsLifecycleParam asLifecycleParam(final String lifecycleParam) {
+ this.lifecycleParam = lifecycleParam;
+ return this;
+ }
+
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("class AslifecycleParam {\n");
+ sb.append(" asLifecycleParamId: ").append(toIndentedString(asLifecycleParamId)).append("\n");
+ sb.append(" asDeploymentItemInstId: ")
+ .append(asDeploymentItemInst != null
+ ? toIndentedString(asDeploymentItemInst.getAsDeploymentItemInstId())
+ : null)
+ .append("\n");
+ sb.append(" lifecycleParam: ").append(toIndentedString(lifecycleParam)).append("\n");
+ sb.append("}");
+ return sb.toString();
+ }
+
+
+ @Override
+ public boolean equals(final Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+ final AsLifecycleParam that = (AsLifecycleParam) o;
+ return Objects.equals(asLifecycleParamId, that.asLifecycleParamId)
+ && Objects.equals(asDeploymentItemInst, that.asDeploymentItemInst)
+ && Objects.equals(lifecycleParam, that.lifecycleParam);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(asLifecycleParamId, asDeploymentItemInst, lifecycleParam);
+ }
+
+
+}
diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/CancelModeType.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/CancelModeType.java
new file mode 100644
index 0000000..2ada1af
--- /dev/null
+++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/CancelModeType.java
@@ -0,0 +1,29 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * 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.so.cnfm.lcm.database.beans;
+
+/**
+ *
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public enum CancelModeType {
+ GRACEFUL, FORCEFUL;
+}
diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/Job.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/Job.java
new file mode 100644
index 0000000..5be8711
--- /dev/null
+++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/Job.java
@@ -0,0 +1,262 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * 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.so.cnfm.lcm.database.beans;
+
+import static org.onap.so.cnfm.lcm.database.beans.utils.Utils.isEquals;
+import static org.onap.so.cnfm.lcm.database.beans.utils.Utils.toIndentedString;
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+import java.util.UUID;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+@Entity
+@Table(name = "JOB")
+public class Job {
+
+ @Id
+ @Column(name = "JOB_ID", nullable = false)
+ private String jobId;
+
+ @Column(name = "JOB_TYPE", nullable = false)
+ private String jobType;
+
+ @Enumerated(EnumType.STRING)
+ @Column(name = "JOB_ACTION", nullable = false)
+ private JobAction jobAction;
+
+ @Column(name = "RESOURCE_ID", nullable = false)
+ private String resourceId;
+
+ @Column(name = "RESOURCE_NAME")
+ private String resourceName;
+
+ @Enumerated(EnumType.STRING)
+ @Column(name = "STATUS", nullable = false)
+ private JobStatusEnum status;
+
+ @Column(name = "START_TIME")
+ private LocalDateTime startTime;
+
+ @Column(name = "END_TIME")
+ private LocalDateTime endTime;
+
+ @Column(name = "PROCESS_INSTANCE_ID")
+ private String processInstanceId;
+
+ @OneToMany(mappedBy = "job", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
+ private List<JobStatus> jobStatuses = new ArrayList<>();
+
+ public Job() {
+ this.jobId = UUID.randomUUID().toString();
+ }
+
+ public void setJobId(final String jobId) {
+ this.jobId = jobId;
+ }
+
+ public String getJobId() {
+ return jobId;
+ }
+
+ public Job jobId(final String jobId) {
+ this.jobId = jobId;
+ return this;
+ }
+
+ public String getJobType() {
+ return jobType;
+ }
+
+ public void setJobType(final String jobType) {
+ this.jobType = jobType;
+ }
+
+ public Job jobType(final String jobType) {
+ this.jobType = jobType;
+ return this;
+ }
+
+ public JobAction getJobAction() {
+ return jobAction;
+ }
+
+ public void setJobAction(final JobAction jobAction) {
+ this.jobAction = jobAction;
+ }
+
+ public Job jobAction(final JobAction jobAction) {
+ this.jobAction = jobAction;
+ return this;
+ }
+
+ public String getResourceId() {
+ return resourceId;
+ }
+
+ public void setResourceId(final String resourceId) {
+ this.resourceId = resourceId;
+ }
+
+ public Job resourceId(final String resourceId) {
+ this.resourceId = resourceId;
+ return this;
+ }
+
+ public JobStatusEnum getStatus() {
+ return status;
+ }
+
+ public void setStatus(final JobStatusEnum status) {
+ this.status = status;
+ }
+
+ public Job status(final JobStatusEnum status) {
+ this.status = status;
+ return this;
+ }
+
+ public LocalDateTime getStartTime() {
+ return startTime;
+ }
+
+ public void setStartTime(final LocalDateTime startTime) {
+ this.startTime = startTime;
+ }
+
+ public Job startTime(final LocalDateTime startTime) {
+ this.startTime = startTime;
+ return this;
+ }
+
+ public LocalDateTime getEndTime() {
+ return endTime;
+ }
+
+ public void setEndTime(final LocalDateTime endTime) {
+ this.endTime = endTime;
+ }
+
+ public Job endTime(final LocalDateTime endTime) {
+ this.endTime = endTime;
+ return this;
+ }
+
+ public String getProcessInstanceId() {
+ return processInstanceId;
+ }
+
+ public void setProcessInstanceId(final String processInstanceId) {
+ this.processInstanceId = processInstanceId;
+ }
+
+ public Job processInstanceId(final String processInstanceId) {
+ this.processInstanceId = processInstanceId;
+ return this;
+ }
+
+ public String getResourceName() {
+ return resourceName;
+ }
+
+ public void setResourceName(final String resourceName) {
+ this.resourceName = resourceName;
+ }
+
+ public Job resourceName(final String resourceName) {
+ this.resourceName = resourceName;
+ return this;
+ }
+
+ public List<JobStatus> getJobStatuses() {
+ return jobStatuses;
+ }
+
+ public void setJobStatuses(final List<JobStatus> jobStatuses) {
+ this.jobStatuses = jobStatuses;
+ }
+
+ public Job jobStatuses(final List<JobStatus> jobStatuses) {
+ this.jobStatuses = jobStatuses;
+ return this;
+ }
+
+ public Job jobStatus(final JobStatus jobStatus) {
+ jobStatus.setJob(this);
+ this.jobStatuses.add(jobStatus);
+ return this;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(jobId, processInstanceId, jobType, jobAction, startTime, endTime, status, resourceId,
+ resourceName, jobStatuses);
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null || getClass() != obj.getClass())
+ return false;
+ if (obj instanceof Job) {
+ final Job other = (Job) obj;
+ return Objects.equals(jobId, other.jobId) && Objects.equals(processInstanceId, other.processInstanceId)
+ && Objects.equals(jobType, other.jobType) && Objects.equals(jobAction, other.jobAction)
+ && Objects.equals(status, other.status) && Objects.equals(startTime, other.startTime)
+ && Objects.equals(endTime, other.endTime) && Objects.equals(resourceId, other.resourceId)
+ && Objects.equals(resourceName, other.resourceName) && isEquals(jobStatuses, other.jobStatuses);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("class Job {\n");
+ sb.append(" jobId: ").append(toIndentedString(jobId)).append("\n");
+ sb.append(" processInstanceId: ").append(toIndentedString(processInstanceId)).append("\n");
+ sb.append(" jobType: ").append(toIndentedString(jobType)).append("\n");
+ sb.append(" jobAction: ").append(toIndentedString(jobAction)).append("\n");
+ sb.append(" status: ").append(toIndentedString(status)).append("\n");
+ sb.append(" startTime: ").append(toIndentedString(startTime)).append("\n");
+ sb.append(" endTime: ").append(toIndentedString(endTime)).append("\n");
+ sb.append(" resId: ").append(toIndentedString(resourceId)).append("\n");
+ sb.append(" resName: ").append(toIndentedString(resourceName)).append("\n");
+ sb.append(" jobStatuses: ").append(toIndentedString(jobStatuses)).append("\n");
+
+ sb.append("}");
+ return sb.toString();
+ }
+
+}
diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/JobAction.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/JobAction.java
new file mode 100644
index 0000000..caa4b86
--- /dev/null
+++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/JobAction.java
@@ -0,0 +1,29 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * 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.so.cnfm.lcm.database.beans;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public enum JobAction {
+ CREATE, INSTANTIATE, TERMINATE, DELETE;
+
+}
diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/JobStatus.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/JobStatus.java
new file mode 100644
index 0000000..c3b78d7
--- /dev/null
+++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/JobStatus.java
@@ -0,0 +1,155 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * 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.so.cnfm.lcm.database.beans;
+
+import static org.onap.so.cnfm.lcm.database.beans.utils.Utils.toIndentedString;
+import java.time.LocalDateTime;
+import java.util.Objects;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+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.Table;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+@Entity
+@Table(name = "JOB_STATUS")
+public class JobStatus {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "ID")
+ private int id;
+
+ @Enumerated(EnumType.STRING)
+ @Column(name = "STATUS", nullable = false)
+ private JobStatusEnum status;
+
+ @Column(name = "DESCRIPTION", columnDefinition = "LONGTEXT")
+ private String description;
+
+ @Column(name = "UPDATED_TIME", nullable = false)
+ private LocalDateTime updatedTime;
+
+ @ManyToOne(fetch = FetchType.LAZY)
+ @JoinColumn(name = "JOB_ID", nullable = false)
+ private Job job;
+
+ public int getId() {
+ return id;
+ }
+
+ public JobStatusEnum getStatus() {
+ return status;
+ }
+
+ public void setStatus(final JobStatusEnum status) {
+ this.status = status;
+ }
+
+ public JobStatus status(final JobStatusEnum status) {
+ this.status = status;
+ return this;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(final String description) {
+ this.description = description;
+ }
+
+ public JobStatus description(final String description) {
+ this.description = description;
+ return this;
+ }
+
+ public LocalDateTime getUpdatedTime() {
+ return updatedTime;
+ }
+
+ public void setUpdatedTime(final LocalDateTime updatedTime) {
+ this.updatedTime = updatedTime;
+ }
+
+ public JobStatus updatedTime(final LocalDateTime addTime) {
+ this.updatedTime = addTime;
+ return this;
+ }
+
+ public Job getJob() {
+ return job;
+ }
+
+ public void setJob(final Job job) {
+ this.job = job;
+ }
+
+ public JobStatus job(final Job job) {
+ this.job = job;
+ return this;
+ }
+
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id, status, updatedTime, description, job != null ? job.getJobId() : 0);
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null || getClass() != obj.getClass())
+ return false;
+ if (obj instanceof JobStatus) {
+ final JobStatus other = (JobStatus) obj;
+ return Objects.equals(id, other.id) && Objects.equals(status, other.status)
+ && Objects.equals(updatedTime, other.updatedTime) && Objects.equals(description, other.description)
+ && (job == null ? other.job == null
+ : other.job != null && Objects.equals(job.getJobId(), other.job.getJobId()));
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("class JobStatus {\n");
+ sb.append(" Id: ").append(toIndentedString(id)).append("\n");
+ sb.append(" status: ").append(toIndentedString(status)).append("\n");
+ sb.append(" descp: ").append(toIndentedString(description)).append("\n");
+ sb.append(" updatedTime: ").append(toIndentedString(updatedTime)).append("\n");
+ sb.append(" jobId: ").append(job != null ? toIndentedString(job.getJobId()) : "").append("\n");
+ sb.append("}");
+ return sb.toString();
+ }
+
+}
diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/JobStatusEnum.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/JobStatusEnum.java
new file mode 100644
index 0000000..38fefb4
--- /dev/null
+++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/JobStatusEnum.java
@@ -0,0 +1,29 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * 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.so.cnfm.lcm.database.beans;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public enum JobStatusEnum {
+ STARTING, STARTED, IN_PROGRESS, ERROR, FINISHED, FINISHED_WITH_ERROR;
+
+}
diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/OperationStateEnum.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/OperationStateEnum.java
new file mode 100644
index 0000000..0e8f6b1
--- /dev/null
+++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/OperationStateEnum.java
@@ -0,0 +1,29 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * 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.so.cnfm.lcm.database.beans;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public enum OperationStateEnum {
+ PROCESSING, COMPLETED, PARTIALLY_COMPLETED, FAILED_TEMP, FAILED, ROLLING_BACK, ROLLED_BACK;
+
+}
diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/State.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/State.java
new file mode 100644
index 0000000..c49544e
--- /dev/null
+++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/State.java
@@ -0,0 +1,29 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * 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.so.cnfm.lcm.database.beans;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public enum State {
+ NOT_INSTANTIATED, INSTANTIATING, INSTANTIATED, FAILED, TERMINATING;
+
+}
diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/utils/Utils.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/utils/Utils.java
new file mode 100644
index 0000000..4d40087
--- /dev/null
+++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/beans/utils/Utils.java
@@ -0,0 +1,59 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * 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.so.cnfm.lcm.database.beans.utils;
+
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public class Utils {
+
+ private Utils() {}
+
+ public static final String toIndentedString(final Object object) {
+ return object == null ? "null" : object.toString().replace("\n", "\n ");
+ }
+
+
+ public static boolean isEquals(final List<?> first, final List<?> second) {
+ if (first == null) {
+ return second == null;
+ }
+
+ if (first.isEmpty()) {
+ return second.isEmpty();
+ }
+ if ((first != null && second != null) && (first.size() == second.size())) {
+ for (int index = 0; index < first.size(); index++) {
+ if (!Objects.equals(first.get(index), second.get(index))) {
+ return false;
+ }
+ }
+ return true;
+
+ }
+ return false;
+ }
+
+
+}
diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/config/CnfmDatabaseConfiguration.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/config/CnfmDatabaseConfiguration.java
new file mode 100644
index 0000000..62a90f8
--- /dev/null
+++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/config/CnfmDatabaseConfiguration.java
@@ -0,0 +1,95 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * 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.so.cnfm.lcm.database.config;
+
+import static org.slf4j.LoggerFactory.getLogger;
+import javax.persistence.EntityManagerFactory;
+import javax.sql.DataSource;
+import org.onap.so.cnfm.lcm.database.beans.Job;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.boot.autoconfigure.flyway.FlywayDataSource;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
+import org.springframework.jmx.export.MBeanExporter;
+import org.springframework.orm.jpa.JpaTransactionManager;
+import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
+import org.springframework.transaction.PlatformTransactionManager;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+import com.zaxxer.hikari.HikariConfig;
+import com.zaxxer.hikari.HikariDataSource;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+@Configuration
+@EnableTransactionManagement
+@EnableJpaRepositories(entityManagerFactoryRef = "entityManagerFactory",
+ basePackages = {"org.onap.so.cnfm.lcm.database.repository"})
+public class CnfmDatabaseConfiguration {
+ private static final Logger logger = getLogger(CnfmDatabaseConfiguration.class);
+
+ private static final String PERSISTENCE_UNIT = "cnfm";
+ private static final String CNFM_DATA_SOURCE_QUALIFIER = "cnfmDataSource";
+
+ @Autowired(required = false)
+ private MBeanExporter mBeanExporter;
+
+ @Bean
+ @ConfigurationProperties(prefix = "spring.datasource.hikari.cnfm")
+ public HikariConfig cnfmDbConfig() {
+ logger.debug("Creating CNFM HikariConfig bean ... ");
+ return new HikariConfig();
+ }
+
+ @Primary
+ @FlywayDataSource
+ @Bean(name = CNFM_DATA_SOURCE_QUALIFIER)
+ public DataSource dataSource() {
+ if (mBeanExporter != null) {
+ mBeanExporter.addExcludedBean(CNFM_DATA_SOURCE_QUALIFIER);
+ }
+ logger.debug("Creating CNFM HikariDataSource bean ... ");
+ final HikariConfig hikariConfig = this.cnfmDbConfig();
+ return new HikariDataSource(hikariConfig);
+ }
+
+ @Primary
+ @Bean(name = "entityManagerFactory")
+ public LocalContainerEntityManagerFactoryBean entityManagerFactory(final EntityManagerFactoryBuilder builder,
+ @Qualifier(CNFM_DATA_SOURCE_QUALIFIER) final DataSource dataSource) {
+ return builder.dataSource(dataSource).packages(Job.class.getPackage().getName())
+ .persistenceUnit(PERSISTENCE_UNIT).build();
+ }
+
+ @Primary
+ @Bean(name = "transactionManager")
+ public PlatformTransactionManager transactionManager(
+ @Qualifier("entityManagerFactory") final EntityManagerFactory entityManagerFactory) {
+ return new JpaTransactionManager(entityManagerFactory);
+ }
+
+}
diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/repository/AsDeploymentItemRepository.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/repository/AsDeploymentItemRepository.java
new file mode 100644
index 0000000..8fa88b5
--- /dev/null
+++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/repository/AsDeploymentItemRepository.java
@@ -0,0 +1,50 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * 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.so.cnfm.lcm.database.repository;
+
+import java.util.List;
+import java.util.Optional;
+import org.onap.so.cnfm.lcm.database.beans.AsDeploymentItem;
+import org.onap.so.cnfm.lcm.database.beans.State;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Modifying;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.Param;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ */
+public interface AsDeploymentItemRepository extends JpaRepository<AsDeploymentItem, String> {
+
+ Optional<AsDeploymentItem> findByAsDeploymentItemInstId(final String asDeploymentItemInstId);
+
+ List<AsDeploymentItem> findByAsInstAsInstId(final String asInstId);
+
+ List<AsDeploymentItem> findByAsInstAsInstIdAndName(final String asInstId, final String name);
+
+ @Modifying(clearAutomatically = true)
+ @Query("UPDATE AsDeploymentItem SET status = (:state) WHERE asDeploymentItemInstId = (:asDeploymentItemInstId)")
+ int updateAsDeploymentItemState(@Param("asDeploymentItemInstId") final String asInstId,
+ @Param("state") final State state);
+
+ @Modifying(clearAutomatically = true)
+ @Query("DELETE FROM AsDeploymentItem WHERE nfInstId = (:asInstId)")
+ void deleteAsDeploymentItemUsingAsInstId(@Param("asInstId") final String asInstId);
+}
diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/repository/AsInstRepository.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/repository/AsInstRepository.java
new file mode 100644
index 0000000..92e6ffd
--- /dev/null
+++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/repository/AsInstRepository.java
@@ -0,0 +1,46 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * 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.so.cnfm.lcm.database.repository;
+
+import java.util.Optional;
+import org.onap.so.cnfm.lcm.database.beans.AsInst;
+import org.onap.so.cnfm.lcm.database.beans.State;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Modifying;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.Param;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public interface AsInstRepository extends JpaRepository<AsInst, String> {
+
+ Optional<AsInst> findByName(final String name);
+
+ Optional<AsInst> findByAsInstId(final String asInstId);
+
+ boolean existsAsInstByName(final String name);
+
+ @Modifying(clearAutomatically = true)
+ @Query("UPDATE AsInst SET status = (:state) WHERE asInstId = (:asInstId)")
+ int updateAsInstState(@Param("asInstId") final String asInstId, @Param("state") final State state);
+
+}
diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/repository/AsLcmOpOccRepository.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/repository/AsLcmOpOccRepository.java
new file mode 100644
index 0000000..62db0c8
--- /dev/null
+++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/repository/AsLcmOpOccRepository.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * 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.so.cnfm.lcm.database.repository;
+
+import java.util.Optional;
+import org.onap.so.cnfm.lcm.database.beans.AsLcmOpOcc;
+import org.onap.so.cnfm.lcm.database.beans.OperationStateEnum;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Modifying;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.Param;
+
+/**
+ *
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public interface AsLcmOpOccRepository extends JpaRepository<AsLcmOpOcc, String> {
+
+ Optional<AsLcmOpOcc> findById(final String id);
+
+ @Modifying(clearAutomatically = true)
+ @Query("UPDATE AsLcmOpOcc SET operationState = (:operationState) WHERE id = (:id)")
+ int updateAsLcmOpOccOperationState(@Param("id") final String id,
+ @Param("operationState") final OperationStateEnum operationState);
+}
diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/repository/AsLifecycleParamRepository.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/repository/AsLifecycleParamRepository.java
new file mode 100644
index 0000000..b63343e
--- /dev/null
+++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/repository/AsLifecycleParamRepository.java
@@ -0,0 +1,38 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * 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.so.cnfm.lcm.database.repository;
+
+import org.onap.so.cnfm.lcm.database.beans.AsLifecycleParam;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+import java.util.List;
+import java.util.Optional;
+
+/**
+ *
+ * @author Gerard Nugent (gerard.nugent@est.tech)
+ *
+ */
+public interface AsLifecycleParamRepository extends JpaRepository<AsLifecycleParam, Integer> {
+
+ List<AsLifecycleParam> findByAsDeploymentItemInstAsDeploymentItemInstId(final String asDeploymentItemId);
+
+ Optional<AsLifecycleParam> findByAsLifecycleParamId(final Integer asLifecycleParamId);
+}
diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/repository/JobRepository.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/repository/JobRepository.java
new file mode 100644
index 0000000..4e254ce
--- /dev/null
+++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/repository/JobRepository.java
@@ -0,0 +1,35 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * 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.so.cnfm.lcm.database.repository;
+
+import java.util.Optional;
+import org.onap.so.cnfm.lcm.database.beans.Job;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public interface JobRepository extends JpaRepository<Job, String>, RefreshableRepository<Job> {
+
+ Optional<Job> findByResourceId(final String resourceId);
+
+
+}
diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/repository/JobStatusRepository.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/repository/JobStatusRepository.java
new file mode 100644
index 0000000..5b9be56
--- /dev/null
+++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/repository/JobStatusRepository.java
@@ -0,0 +1,30 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * 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.so.cnfm.lcm.database.repository;
+
+import org.onap.so.cnfm.lcm.database.beans.JobStatus;
+import org.springframework.data.repository.CrudRepository;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public interface JobStatusRepository extends CrudRepository<JobStatus, Integer> {
+}
diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/repository/RefreshableRepository.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/repository/RefreshableRepository.java
new file mode 100644
index 0000000..7bc4ac7
--- /dev/null
+++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/repository/RefreshableRepository.java
@@ -0,0 +1,30 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * 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.so.cnfm.lcm.database.repository;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public interface RefreshableRepository<T> {
+
+ void refreshEntity(T entity);
+
+}
diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/repository/RefreshableRepositoryImpl.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/repository/RefreshableRepositoryImpl.java
new file mode 100644
index 0000000..866cb1e
--- /dev/null
+++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/repository/RefreshableRepositoryImpl.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * 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.so.cnfm.lcm.database.repository;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import org.springframework.stereotype.Repository;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+@Repository
+public class RefreshableRepositoryImpl<T> implements RefreshableRepository<T> {
+
+ @PersistenceContext
+ private EntityManager entityManager;
+
+ @Override
+ public void refreshEntity(final T entity) {
+ entityManager.refresh(entity);
+
+ }
+
+}
diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/service/DatabaseServiceProvider.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/service/DatabaseServiceProvider.java
new file mode 100644
index 0000000..cfe14e8
--- /dev/null
+++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/java/org/onap/so/cnfm/lcm/database/service/DatabaseServiceProvider.java
@@ -0,0 +1,201 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * 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.so.cnfm.lcm.database.service;
+
+import org.onap.so.cnfm.lcm.database.beans.AsDeploymentItem;
+import org.onap.so.cnfm.lcm.database.beans.AsInst;
+import org.onap.so.cnfm.lcm.database.beans.AsLcmOpOcc;
+import org.onap.so.cnfm.lcm.database.beans.AsLifecycleParam;
+import org.onap.so.cnfm.lcm.database.beans.Job;
+import org.onap.so.cnfm.lcm.database.beans.OperationStateEnum;
+import org.onap.so.cnfm.lcm.database.beans.State;
+import org.onap.so.cnfm.lcm.database.repository.AsDeploymentItemRepository;
+import org.onap.so.cnfm.lcm.database.repository.AsInstRepository;
+import org.onap.so.cnfm.lcm.database.repository.AsLcmOpOccRepository;
+import org.onap.so.cnfm.lcm.database.repository.AsLifecycleParamRepository;
+import org.onap.so.cnfm.lcm.database.repository.JobRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Isolation;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+
+@Service
+public class DatabaseServiceProvider {
+ private static final Logger logger = LoggerFactory.getLogger(DatabaseServiceProvider.class);
+
+ private final JobRepository jobRepository;
+
+ private final AsInstRepository asInstRepository;
+
+ private final AsDeploymentItemRepository asdeploymentItemRepository;
+
+ private final AsLifecycleParamRepository aslifecyleParamRepository;
+
+ private final AsLcmOpOccRepository asLcmOpOccRepository;
+
+ @Autowired
+ public DatabaseServiceProvider(final JobRepository jobRepository, final AsInstRepository asInstRepository,
+ final AsDeploymentItemRepository asdeploymentItemRepository,
+ final AsLifecycleParamRepository aslifecyleParamRepository,
+ final AsLcmOpOccRepository asLcmOpOccRepository) {
+ this.jobRepository = jobRepository;
+ this.asInstRepository = asInstRepository;
+ this.asdeploymentItemRepository = asdeploymentItemRepository;
+ this.aslifecyleParamRepository = aslifecyleParamRepository;
+ this.asLcmOpOccRepository = asLcmOpOccRepository;
+ }
+
+ public boolean addJob(final Job job) {
+ logger.info("Adding Job: {} to database", job);
+ return jobRepository.saveAndFlush(job) != null;
+ }
+
+ public Optional<Job> getJob(final String jobId) {
+ logger.info("Querying database for Job using jobId: {}", jobId);
+ return jobRepository.findById(jobId);
+ }
+
+ @Transactional(propagation = Propagation.REQUIRES_NEW, isolation = Isolation.REPEATABLE_READ, readOnly = true)
+ public Optional<Job> getRefreshedJob(final String jobId) {
+ logger.info("Querying database for Job using jobId: {}", jobId);
+ final Optional<Job> optional = getJob(jobId);
+ if (optional.isPresent()) {
+ jobRepository.refreshEntity(optional.get());
+ }
+ return optional;
+ }
+
+ public Optional<Job> getJobByResourceId(final String resourceId) {
+ logger.info("Querying database for Job using resourceId: {}", resourceId);
+ return jobRepository.findByResourceId(resourceId);
+ }
+
+ public boolean isAsInstExists(final String name) {
+ logger.info("Checking if AsInst entry exists in database using name: {}", name);
+ return asInstRepository.existsAsInstByName(name);
+ }
+
+ public boolean saveAsInst(final AsInst asInstance) {
+ logger.info("Saving AsInst: {} to database", asInstance);
+ return asInstRepository.saveAndFlush(asInstance) != null;
+ }
+
+ @Transactional(propagation = Propagation.REQUIRES_NEW)
+ public boolean updateAsInstState(final String asInstId, final State state) {
+ logger.info("Updating AsInst: {} State to {}", asInstId, state);
+ return asInstRepository.updateAsInstState(asInstId, state) > 0;
+ }
+
+ public Optional<AsInst> getAsInst(final String asInstId) {
+ logger.info("Querying database for AsInst using nsInstId: {}", asInstId);
+ return asInstRepository.findById(asInstId);
+ }
+
+ public Optional<AsInst> getAsInstByName(final String name) {
+ logger.info("Querying database for AsInst using name: {}", name);
+ return asInstRepository.findByName(name);
+ }
+
+ public void deleteAsInst(final String asInstId) {
+ logger.info("Deleting AsInst with asInstId: {}", asInstId);
+ asInstRepository.deleteById(asInstId);
+ }
+
+ public boolean saveAsDeploymentItem(final AsDeploymentItem asdeploymentItem) {
+ logger.info("Saving AsDeploymentItem: {} to database", asdeploymentItem);
+ return asdeploymentItemRepository.saveAndFlush(asdeploymentItem) != null;
+ }
+
+ @Transactional(propagation = Propagation.REQUIRES_NEW)
+ public boolean updateAsDeploymentItemState(final String asDeploymentItemInstId, final State state) {
+ logger.info("Updating AsDeploymentItem: {} State to {}", asDeploymentItemInstId, state);
+ return asdeploymentItemRepository.updateAsDeploymentItemState(asDeploymentItemInstId, state) > 0;
+ }
+
+ public List<AsDeploymentItem> getAsDeploymentItemByAsInstId(final String asInstId) {
+ logger.info("Querying database for AsdeploymentItem using asInstId: {}", asInstId);
+ return asdeploymentItemRepository.findByAsInstAsInstId(asInstId);
+ }
+
+ public List<AsDeploymentItem> getAsDeploymentItemByAsInstIdAndName(final String asInstId, final String name) {
+ logger.info("Querying database for AsDeploymentItem using asInstId: {} and name : {} ", asInstId, name);
+ return asdeploymentItemRepository.findByAsInstAsInstIdAndName(asInstId, name);
+ }
+
+ public Optional<AsDeploymentItem> getAsDeploymentItem(final String asDeploymentItemInstId) {
+ logger.info("Querying database for AsdeploymentItem using asDeploymentItemInstId: {}", asDeploymentItemInstId);
+ return asdeploymentItemRepository.findByAsDeploymentItemInstId(asDeploymentItemInstId);
+ }
+
+ public boolean isAsDeploymentItemExists(final String asDeploymentItemInstId) {
+ logger.info("Checking if AsdeploymentItem entry exists in database using asDeploymentItemInstId: {}",
+ asDeploymentItemInstId);
+ return asdeploymentItemRepository.findByAsDeploymentItemInstId(asDeploymentItemInstId).isPresent();
+ }
+
+ @Transactional(propagation = Propagation.REQUIRES_NEW)
+ public void deleteAsDeploymentItem(final String asInstId) {
+ logger.info("Deleting AsdeploymentItem with asInstId: {} from database", asInstId);
+ asdeploymentItemRepository.deleteAsDeploymentItemUsingAsInstId(asInstId);
+ }
+
+ public boolean saveAsLifecycleParam(final AsLifecycleParam aslifecyleparam) {
+ logger.info("Saving AsLifecycleParam: {} to database", aslifecyleparam);
+ return aslifecyleParamRepository.saveAndFlush(aslifecyleparam) != null;
+ }
+
+ public List<AsLifecycleParam> getAsLifecycleParamByAsDeploymentItemId(final String asDeploymentItemId) {
+ logger.info("Querying database for Aslifecycleparam using asDeploymentItemId: {}", asDeploymentItemId);
+ // NEXT
+ return aslifecyleParamRepository.findByAsDeploymentItemInstAsDeploymentItemInstId(asDeploymentItemId);
+ }
+
+ public Optional<AsLifecycleParam> getAsLifecycleParam(final Integer asLifecycleParamId) {
+ logger.info("Querying database for Aslifecycleparam using AslifecycleParamId: {}", asLifecycleParamId);
+ return aslifecyleParamRepository.findByAsLifecycleParamId(asLifecycleParamId);
+ }
+
+ public boolean addAsLcmOpOcc(final AsLcmOpOcc asLcmOpOcc) {
+ logger.info("Adding AsLcmOpOcc: {} to database", asLcmOpOcc);
+ return asLcmOpOccRepository.saveAndFlush(asLcmOpOcc) != null;
+ }
+
+ @Transactional(propagation = Propagation.REQUIRES_NEW)
+ public boolean updateAsLcmOpOccOperationState(final String id, final OperationStateEnum operationState) {
+ logger.info("Updating AsLcmOpOcc: {} operationState to {}", id, operationState);
+ return asLcmOpOccRepository.updateAsLcmOpOccOperationState(id, operationState) > 0;
+ }
+
+ public Optional<AsLcmOpOcc> getAsLcmOpOcc(final String id) {
+ logger.info("Querying database for AsLcmOpOcc using id: {}", id);
+ return asLcmOpOccRepository.findById(id);
+ }
+}
diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/resources/db/migration/V1_1__create_cnfm_tables.sql b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/resources/db/migration/V1_1__create_cnfm_tables.sql
new file mode 100644
index 0000000..5e75171
--- /dev/null
+++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/main/resources/db/migration/V1_1__create_cnfm_tables.sql
@@ -0,0 +1,90 @@
+use cnfm;
+
+CREATE TABLE IF NOT EXISTS `JOB` (
+ `JOB_ID` varchar(255) NOT NULL,
+ `JOB_TYPE` varchar(255) NOT NULL,
+ `JOB_ACTION` varchar(255) NOT NULL,
+ `RESOURCE_ID` varchar(255) NOT NULL,
+ `RESOURCE_NAME` varchar(255) DEFAULT NULL,
+ `STATUS` varchar(255) NOT NULL,
+ `START_TIME` DATETIME DEFAULT NULL,
+ `END_TIME` DATETIME DEFAULT NULL,
+ `PROCESS_INSTANCE_ID` varchar(255) DEFAULT NULL,
+ PRIMARY KEY (`JOB_ID`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE IF NOT EXISTS `JOB_STATUS` (
+ `ID` INT NOT NULL AUTO_INCREMENT,
+ `UPDATED_TIME` DATETIME NOT NULL,
+ `DESCRIPTION` longtext DEFAULT NULL,
+ `STATUS` varchar(255) NOT NULL,
+ `JOB_ID` varchar(255) NOT NULL,
+ PRIMARY KEY (`ID`),
+ FOREIGN KEY (JOB_ID)
+ REFERENCES JOB(JOB_ID)
+ ON UPDATE CASCADE ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE IF NOT EXISTS `AS_INST` (
+ `AS_INST_ID` varchar(255) NOT NULL,
+ `NAME` varchar(255) NOT NULL,
+ `DESCRIPTION` longtext DEFAULT NULL,
+ `AS_PACKAGE_ID` varchar(255) DEFAULT NULL,
+ `ASD_ID` varchar(255) NOT NULL,
+ `ASD_INVARIANT_ID` varchar(255) NOT NULL,
+ `AS_PROVIDER` varchar(255) NOT NULL,
+ `AS_APPLICATION_NAME` varchar(255) NOT NULL,
+ `AS_APPLICATION_VERSION` varchar(255) NOT NULL,
+ `SERVICE_INSTANCE_ID` varchar(255) NOT NULL,
+ `SERVICE_INSTANCE_NAME` varchar(255) NOT NULL,
+ `CLOUD_OWNER` varchar(255) NOT NULL,
+ `CLOUD_REGION` varchar(255) NOT NULL,
+ `TENANT_ID` varchar(255) NOT NULL,
+ `STATUS` varchar(255) NOT NULL,
+ `STATUS_UPDATED_TIME` DATETIME NOT NULL,
+ PRIMARY KEY (`AS_INST_ID`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE IF NOT EXISTS `AS_DEPLOYMENT_ITEM` (
+ `AS_DEP_ITEM_INST_ID` varchar(255) NOT NULL,
+ `NAME` varchar(255) DEFAULT NULL,
+ `ITEM_ID` varchar(255) DEFAULT NULL,
+ `DEPLOYMENT_ORDER` int(11) DEFAULT NULL,
+ `ARTIFACT_FILE_PATH` varchar(255) DEFAULT NULL,
+ `STATUS` varchar(255) DEFAULT NULL,
+ `AS_INST_ID` varchar(255) NOT NULL,
+ `CREATE_TIME` DATETIME DEFAULT NULL,
+ `LAST_UPDATE_TIME` DATETIME DEFAULT NULL,
+ `RELEASE_NAME` varchar(255) NOT NULL,
+ PRIMARY KEY (`AS_DEP_ITEM_INST_ID`),
+ FOREIGN KEY (AS_INST_ID)
+ REFERENCES AS_INST(AS_INST_ID)
+ ON UPDATE CASCADE ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE IF NOT EXISTS `AS_LIFECYCLE_PARAM` (
+ `AS_LCP_ID` INT NOT NULL AUTO_INCREMENT,
+ `AS_DEP_ITEM_INST_ID` varchar(255) NOT NULL,
+ `LIFECYCLE_PARAM` varchar(255) DEFAULT NULL,
+ PRIMARY KEY (`AS_LCP_ID`),
+ FOREIGN KEY (AS_DEP_ITEM_INST_ID)
+ REFERENCES AS_DEPLOYMENT_ITEM(AS_DEP_ITEM_INST_ID)
+ ON UPDATE CASCADE ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE IF NOT EXISTS `AS_LCM_OP_OCCS` (
+ `ID` varchar(255) NOT NULL,
+ `OPERATION_STATE` varchar(255) NOT NULL,
+ `STATE_ENTERED_TIME` DATETIME DEFAULT NULL,
+ `START_TIME` DATETIME DEFAULT NULL,
+ `AS_INST_ID` varchar(255) NOT NULL,
+ `OPERATION` varchar(255) NOT NULL,
+ `IS_AUTO_INVOCATION` varchar(255) NOT NULL,
+ `OPERATION_PARAMS` longtext NOT NULL,
+ `IS_CANCEL_PENDING` varchar(255) NOT NULL,
+ `CANCEL_MODE` varchar(255) DEFAULT NULL,
+ PRIMARY KEY (`ID`),
+ FOREIGN KEY (AS_INST_ID)
+ REFERENCES AS_INST(AS_INST_ID)
+ ON UPDATE CASCADE ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/test/java/org/onap/so/cnfm/lcm/database/PojoClassesTests.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/test/java/org/onap/so/cnfm/lcm/database/PojoClassesTests.java
new file mode 100644
index 0000000..917e7de
--- /dev/null
+++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/test/java/org/onap/so/cnfm/lcm/database/PojoClassesTests.java
@@ -0,0 +1,88 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * 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.so.cnfm.lcm.database;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import org.junit.Test;
+import org.onap.so.cnfm.lcm.database.beans.AsDeploymentItem;
+import org.onap.so.cnfm.lcm.database.beans.AsInst;
+import org.onap.so.cnfm.lcm.database.beans.AsLcmOpOcc;
+import org.onap.so.cnfm.lcm.database.beans.AsLifecycleParam;
+import org.onap.so.cnfm.lcm.database.beans.Job;
+import org.onap.so.cnfm.lcm.database.beans.JobStatus;
+import nl.jqno.equalsverifier.EqualsVerifier;
+import nl.jqno.equalsverifier.Warning;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ */
+public class PojoClassesTests {
+
+ @Test
+ public void test_database_job_equalAndHashMethod() throws ClassNotFoundException {
+ EqualsVerifier.forClass(Job.class)
+ .suppress(Warning.STRICT_INHERITANCE, Warning.NONFINAL_FIELDS, Warning.INHERITED_DIRECTLY_FROM_OBJECT)
+ .withPrefabValues(JobStatus.class, new JobStatus().job(new Job()), new JobStatus().job(new Job()))
+ .withIgnoredAnnotations(Entity.class, Id.class).verify();
+ }
+
+ @Test
+ public void test_database_jobStatus_equalAndHashMethod() throws ClassNotFoundException {
+ EqualsVerifier.forClass(JobStatus.class)
+ .suppress(Warning.STRICT_INHERITANCE, Warning.NONFINAL_FIELDS, Warning.INHERITED_DIRECTLY_FROM_OBJECT)
+ .withPrefabValues(Job.class, new Job(), new Job()).withIgnoredAnnotations(Entity.class, Id.class)
+ .verify();
+ }
+
+ @Test
+ public void test_database_asInst_equalAndHashMethod() throws ClassNotFoundException {
+ EqualsVerifier.forClass(AsInst.class)
+ .suppress(Warning.STRICT_INHERITANCE, Warning.NONFINAL_FIELDS, Warning.INHERITED_DIRECTLY_FROM_OBJECT)
+ .withPrefabValues(AsDeploymentItem.class, new AsDeploymentItem(), new AsDeploymentItem())
+ .withIgnoredAnnotations(Entity.class, Id.class).verify();
+ }
+
+ @Test
+ public void test_database_asdeploymentItem_equalAndHashMethod() throws ClassNotFoundException {
+ EqualsVerifier.forClass(AsDeploymentItem.class)
+ .suppress(Warning.STRICT_INHERITANCE, Warning.NONFINAL_FIELDS, Warning.INHERITED_DIRECTLY_FROM_OBJECT)
+ .withPrefabValues(AsInst.class, new AsInst(), new AsInst())
+ .withPrefabValues(AsDeploymentItem.class, new AsDeploymentItem(), new AsDeploymentItem())
+ .withIgnoredAnnotations(Entity.class, Id.class).verify();
+ }
+
+ @Test
+ public void test_database_asLcmOpOcc_equalAndHashMethod() throws ClassNotFoundException {
+ EqualsVerifier.forClass(AsLcmOpOcc.class)
+ .suppress(Warning.STRICT_INHERITANCE, Warning.NONFINAL_FIELDS, Warning.INHERITED_DIRECTLY_FROM_OBJECT)
+ .withPrefabValues(AsInst.class, new AsInst(), new AsInst())
+ .withIgnoredAnnotations(Entity.class, Id.class).verify();
+ }
+
+ @Test
+ public void test_database_asLifecycleParam_equalAndHashMethod() throws ClassNotFoundException {
+ EqualsVerifier.forClass(AsLifecycleParam.class)
+ .suppress(Warning.STRICT_INHERITANCE, Warning.NONFINAL_FIELDS, Warning.INHERITED_DIRECTLY_FROM_OBJECT)
+ .withPrefabValues(AsDeploymentItem.class, new AsDeploymentItem(), new AsDeploymentItem())
+ .withIgnoredAnnotations(Entity.class, Id.class).verify();
+ }
+
+}
diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/test/java/org/onap/so/cnfm/lcm/database/TestApplication.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/test/java/org/onap/so/cnfm/lcm/database/TestApplication.java
new file mode 100644
index 0000000..1687458
--- /dev/null
+++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/test/java/org/onap/so/cnfm/lcm/database/TestApplication.java
@@ -0,0 +1,45 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * 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.so.cnfm.lcm.database;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.FilterType;
+import org.springframework.context.annotation.ComponentScan.Filter;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+@SpringBootApplication(scanBasePackages = {"org.onap.so"})
+@EnableAutoConfiguration(exclude = {JacksonAutoConfiguration.class})
+@ComponentScan(basePackages = {"org.onap"},
+ excludeFilters = {@Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class)})
+public class TestApplication {
+
+ public static void main(final String[] args) {
+ new SpringApplication(TestApplication.class).run(args);
+ }
+
+}
diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/test/java/org/onap/so/cnfm/lcm/database/beans/utils/UtilsTest.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/test/java/org/onap/so/cnfm/lcm/database/beans/utils/UtilsTest.java
new file mode 100644
index 0000000..ab24f94
--- /dev/null
+++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/test/java/org/onap/so/cnfm/lcm/database/beans/utils/UtilsTest.java
@@ -0,0 +1,71 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * 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.so.cnfm.lcm.database.beans.utils;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import java.util.Arrays;
+import java.util.Collections;
+import org.junit.Test;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public class UtilsTest {
+
+ @Test
+ public void testTwoEmptyLists_equal() {
+ assertTrue(Utils.isEquals(Collections.emptyList(), Collections.emptyList()));
+ }
+
+ @Test
+ public void testEmptyListAndNonEmpty_notEqual() {
+ assertFalse(Utils.isEquals(Collections.emptyList(), Arrays.asList("A")));
+ }
+
+ @Test
+ public void testTwoNullLists_equal() {
+ assertTrue(Utils.isEquals(null, null));
+ }
+
+ @Test
+ public void testNullListAndEmptyList_notEqual() {
+ assertFalse(Utils.isEquals(null, Collections.emptyList()));
+ }
+
+ @Test
+ public void testTwoNotEmptyListsContainSameObjects_equal() {
+ assertTrue(Utils.isEquals(Arrays.asList("A"), Arrays.asList("A")));
+ }
+
+ @Test
+ public void testTwoNotEmptyListsContainMoreThenTwoNotSameObjects_equal() {
+ assertFalse(Utils.isEquals(Arrays.asList("A", "B"), Arrays.asList("A", "C")));
+ }
+
+
+ @Test
+ public void testTwoNotEmptyListsContainsDifferentObjects_equal() {
+ assertFalse(Utils.isEquals(Arrays.asList("A"), Arrays.asList(1)));
+ }
+
+
+}
diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/test/java/org/onap/so/cnfm/lcm/database/service/DatabaseServiceProviderTest.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/test/java/org/onap/so/cnfm/lcm/database/service/DatabaseServiceProviderTest.java
new file mode 100644
index 0000000..d353ea6
--- /dev/null
+++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/test/java/org/onap/so/cnfm/lcm/database/service/DatabaseServiceProviderTest.java
@@ -0,0 +1,214 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 Nordix Foundation.
+ * ================================================================================
+ * 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.so.cnfm.lcm.database.service;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import java.time.LocalDateTime;
+import java.time.temporal.ChronoUnit;
+import java.util.List;
+import java.util.Optional;
+import java.util.UUID;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.so.cnfm.lcm.database.TestApplication;
+import org.onap.so.cnfm.lcm.database.beans.AsDeploymentItem;
+import org.onap.so.cnfm.lcm.database.beans.AsInst;
+import org.onap.so.cnfm.lcm.database.beans.AsLcmOpOcc;
+import org.onap.so.cnfm.lcm.database.beans.AsLcmOpType;
+import org.onap.so.cnfm.lcm.database.beans.AsLifecycleParam;
+import org.onap.so.cnfm.lcm.database.beans.Job;
+import org.onap.so.cnfm.lcm.database.beans.JobAction;
+import org.onap.so.cnfm.lcm.database.beans.JobStatus;
+import org.onap.so.cnfm.lcm.database.beans.JobStatusEnum;
+import org.onap.so.cnfm.lcm.database.beans.OperationStateEnum;
+import org.onap.so.cnfm.lcm.database.beans.State;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringRunner;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+@ActiveProfiles("test")
+public class DatabaseServiceProviderTest {
+
+ private static final String RANDOM_ID = UUID.randomUUID().toString();
+ private static final String DUMMY_NAME = "NAME";
+ private static final LocalDateTime CURRENT_DATE_TIME = LocalDateTime.now().truncatedTo(ChronoUnit.MILLIS);
+ @Autowired
+ private DatabaseServiceProvider databaseServiceProvider;
+
+ @Test
+ public void testAddJob_StoredInDatabase() {
+ final Job expected = new Job().jobType("TYPE").jobAction(JobAction.CREATE).resourceId(RANDOM_ID)
+ .resourceName(DUMMY_NAME).startTime(CURRENT_DATE_TIME).status(JobStatusEnum.STARTED);
+ databaseServiceProvider.addJob(expected);
+
+ Optional<Job> actual = databaseServiceProvider.getJob(expected.getJobId());
+ assertEquals(expected, actual.get());
+
+ actual = databaseServiceProvider.getRefreshedJob(expected.getJobId());
+ assertEquals(expected, actual.get());
+
+ }
+
+ @Test
+ public void testAddJobWithJobStatus_StoredInDatabase() {
+ final Job job = new Job().jobType("TYPE").jobAction(JobAction.CREATE).resourceId(RANDOM_ID)
+ .resourceName(DUMMY_NAME).startTime(CURRENT_DATE_TIME).status(JobStatusEnum.STARTED);
+ databaseServiceProvider.addJob(job);
+
+ final JobStatus jobStatus = new JobStatus().status(JobStatusEnum.STARTED)
+ .description("Create AS workflow process started").updatedTime(CURRENT_DATE_TIME);
+ databaseServiceProvider.addJob(job.jobStatus(jobStatus));
+
+ final Optional<Job> actual = databaseServiceProvider.getJob(job.getJobId());
+ final Job actualJob = actual.get();
+
+ assertEquals(job.getJobId(), actualJob.getJobId());
+ assertFalse(actualJob.getJobStatuses().isEmpty());
+ assertEquals(job.getJobId(), actualJob.getJobStatuses().get(0).getJob().getJobId());
+
+ }
+
+ @Test
+ public void testAddAsInst_StoredInDatabase_ableTofindByQuery() {
+
+ final String name = DUMMY_NAME + UUID.randomUUID().toString();
+ final AsInst asInst = new AsInst().name(name).asdId(RANDOM_ID).status(State.NOT_INSTANTIATED)
+ .asdInvariantId(RANDOM_ID).statusUpdatedTime(CURRENT_DATE_TIME).asApplicationName("asApplicationName")
+ .asApplicationVersion("asApplicationVersion").asProvider("asProvider").serviceInstanceId(RANDOM_ID)
+ .serviceInstanceName("serviceInstanceName").cloudOwner("cloudOwner").cloudRegion("cloudRegion")
+ .tenantId("tenantId");
+
+ databaseServiceProvider.saveAsInst(asInst);
+
+ Optional<AsInst> actual = databaseServiceProvider.getAsInst(asInst.getAsInstId());
+ AsInst actualAsInst = actual.get();
+ assertEquals(asInst.getAsInstId(), actualAsInst.getAsInstId());
+ assertEquals(RANDOM_ID, actualAsInst.getAsdId());
+ assertEquals(State.NOT_INSTANTIATED, actualAsInst.getStatus());
+ assertEquals(RANDOM_ID, actualAsInst.getAsdInvariantId());
+ assertEquals(CURRENT_DATE_TIME, actualAsInst.getStatusUpdatedTime());
+
+ actual = databaseServiceProvider.getAsInstByName(name);
+ actualAsInst = actual.get();
+
+ assertEquals(asInst.getAsInstId(), actualAsInst.getAsInstId());
+ assertEquals(RANDOM_ID, actualAsInst.getAsdId());
+ assertEquals(State.NOT_INSTANTIATED, actualAsInst.getStatus());
+ assertEquals(RANDOM_ID, actualAsInst.getAsdInvariantId());
+ assertEquals(CURRENT_DATE_TIME, actualAsInst.getStatusUpdatedTime());
+
+
+ assertTrue(databaseServiceProvider.isAsInstExists(name));
+ }
+
+ @Test
+ public void testAddAsdeploymentItem_StoredInDatabase_ableTofindByQuery() {
+
+ final String name = DUMMY_NAME + UUID.randomUUID().toString();
+ final AsInst asInst = new AsInst().name(name).asdId(RANDOM_ID).status(State.NOT_INSTANTIATED)
+ .asdInvariantId(RANDOM_ID).statusUpdatedTime(CURRENT_DATE_TIME).asApplicationName("asApplicationName")
+ .asApplicationVersion("asApplicationVersion").asProvider("asProvider").serviceInstanceId(RANDOM_ID)
+ .serviceInstanceName("serviceInstanceName").cloudOwner("cloudOwner").cloudRegion("cloudRegion")
+ .tenantId("tenantId");
+
+ databaseServiceProvider.saveAsInst(asInst);
+
+ final AsDeploymentItem asdeploymentItem =
+ new AsDeploymentItem().asInst(asInst).name(DUMMY_NAME).itemId(RANDOM_ID).status(State.NOT_INSTANTIATED)
+ .createTime(CURRENT_DATE_TIME).lastUpdateTime(CURRENT_DATE_TIME).releaseName("test");
+ databaseServiceProvider.saveAsDeploymentItem(asdeploymentItem);
+
+ final Optional<AsDeploymentItem> actual =
+ databaseServiceProvider.getAsDeploymentItem(asdeploymentItem.getAsDeploymentItemInstId());
+ final AsDeploymentItem actualAsdeploymentItem = actual.get();
+ assertEquals(asInst.getAsInstId(), actualAsdeploymentItem.getAsInst().getAsInstId());
+ assertEquals(asdeploymentItem.getAsDeploymentItemInstId(), actualAsdeploymentItem.getAsDeploymentItemInstId());
+ assertEquals(asdeploymentItem.getName(), actualAsdeploymentItem.getName());
+ assertEquals(asdeploymentItem.getItemId(), actualAsdeploymentItem.getItemId());
+ assertEquals(asdeploymentItem.getStatus(), actualAsdeploymentItem.getStatus());
+ assertEquals(asdeploymentItem.getCreateTime(), actualAsdeploymentItem.getCreateTime());
+ assertEquals(asdeploymentItem.getLastUpdateTime(), actualAsdeploymentItem.getLastUpdateTime());
+ assertEquals(asdeploymentItem.getReleaseName(), actualAsdeploymentItem.getReleaseName());
+
+
+ List<AsDeploymentItem> asdeploymentItemList =
+ databaseServiceProvider.getAsDeploymentItemByAsInstId(asInst.getAsInstId());
+ assertFalse(asdeploymentItemList.isEmpty());
+ assertEquals(asInst.getAsInstId(), asdeploymentItemList.get(0).getAsInst().getAsInstId());
+
+ asdeploymentItemList =
+ databaseServiceProvider.getAsDeploymentItemByAsInstIdAndName(asInst.getAsInstId(), DUMMY_NAME);
+
+ assertFalse(asdeploymentItemList.isEmpty());
+ assertEquals(asInst.getAsInstId(), asdeploymentItemList.get(0).getAsInst().getAsInstId());
+ assertEquals(DUMMY_NAME, asdeploymentItemList.get(0).getName());
+
+ final AsLifecycleParam aslifecycleparam =
+ new AsLifecycleParam().asDeploymentItemInst(asdeploymentItem).asLifecycleParam("TEST");
+ databaseServiceProvider.saveAsLifecycleParam(aslifecycleparam);
+
+ final Optional<AsLifecycleParam> actualLP =
+ databaseServiceProvider.getAsLifecycleParam(aslifecycleparam.getAsLifecycleParamId());
+ final AsLifecycleParam actualLifecycleParam = actualLP.get();
+ assertEquals(aslifecycleparam.getLifecycleParam(), actualLifecycleParam.getLifecycleParam());
+ assertEquals(asdeploymentItem.getAsDeploymentItemInstId(), actualLifecycleParam.getAsDeploymentItemInst().getAsDeploymentItemInstId());
+ assertEquals(aslifecycleparam.getAsLifecycleParamId(), actualLifecycleParam.getAsLifecycleParamId());
+
+ List<AsLifecycleParam> aslifecycleParamsList =
+ databaseServiceProvider.getAsLifecycleParamByAsDeploymentItemId(asdeploymentItem.getAsDeploymentItemInstId());
+ assertFalse(aslifecycleParamsList.isEmpty());
+ assertEquals(asdeploymentItem.getAsDeploymentItemInstId(), aslifecycleParamsList.get(0).getAsDeploymentItemInst().getAsDeploymentItemInstId());
+ }
+
+ @Test
+ public void testAddAsLcmOpOcc_StoredInDatabase_ableTofindByQuery() {
+ final String name = DUMMY_NAME + UUID.randomUUID().toString();
+ final AsInst asInst = new AsInst().name(name).asdId(RANDOM_ID).status(State.NOT_INSTANTIATED)
+ .asdInvariantId(RANDOM_ID).statusUpdatedTime(CURRENT_DATE_TIME).asApplicationName("asApplicationName")
+ .asApplicationVersion("asApplicationVersion").asProvider("asProvider").serviceInstanceId(RANDOM_ID)
+ .serviceInstanceName("serviceInstanceName").cloudOwner("cloudOwner").cloudRegion("cloudRegion")
+ .tenantId("tenantId");
+
+ databaseServiceProvider.saveAsInst(asInst);
+
+ final AsLcmOpOcc asLcmOpOcc = new AsLcmOpOcc().asInst(asInst).operationState(OperationStateEnum.PROCESSING)
+ .isCancelPending(false).isAutoInvocation(false).operation(AsLcmOpType.INSTANTIATE)
+ .startTime(CURRENT_DATE_TIME).stateEnteredTime(CURRENT_DATE_TIME).operationParams("");
+
+
+ databaseServiceProvider.addAsLcmOpOcc(asLcmOpOcc);
+
+ final Optional<AsLcmOpOcc> actual = databaseServiceProvider.getAsLcmOpOcc(asLcmOpOcc.getId());
+ final AsLcmOpOcc actualLcmOpOcc = actual.get();
+ assertEquals(asLcmOpOcc.getId(), actualLcmOpOcc.getId());
+
+ assertEquals(asInst.getAsInstId(), actualLcmOpOcc.getAsInst().getAsInstId());
+
+ }
+}
diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/test/resources/application.yaml b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/test/resources/application.yaml
new file mode 100644
index 0000000..5751dbc
--- /dev/null
+++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-database-service/src/test/resources/application.yaml
@@ -0,0 +1,31 @@
+# Copyright © 2022 Nordix Foundation
+#
+# 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.
+spring:
+ main:
+ web-application-type: none
+ datasource:
+ hikari:
+ cnfm:
+ jdbcUrl: jdbc:h2:mem:cnfm;DB_CLOSE_DELAY=-1;INIT=CREATE SCHEMA IF NOT EXISTS cnfm;MODE=MYSQL;DATABASE_TO_LOWER=TRUE;CASE_INSENSITIVE_IDENTIFIERS=TRUE
+ driver-class-name: org.h2.Driver
+ pool-name: cnfm-lcm-pool
+ registerMbeans: true
+ jpa:
+ generate-ddl: true
+ hibernate:
+ ddl-auto: create
+hibernate:
+ dialect: org.hibernate.dialect.H2Dialect
+ hbm2ddl:
+ auto: create \ No newline at end of file