diff options
Diffstat (limited to 'so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java')
8 files changed, 116 insertions, 56 deletions
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/CancelModeType.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/CancelModeType.java new file mode 100644 index 0000000000..627250535e --- /dev/null +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/CancelModeType.java @@ -0,0 +1,28 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 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.etsi.nfvo.ns.lcm.database.beans; + +/** + * @author Andrew Lamb (andrew.a.lamb@est.tech) + * + */ +public enum CancelModeType { + GRACEFUL, FORCEFUL; +} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoJob.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoJob.java index 9453caac9e..60b06e1061 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoJob.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoJob.java @@ -42,24 +42,24 @@ import org.onap.so.etsi.nfvo.ns.lcm.database.beans.utils.Utils; public class NfvoJob { @Id - @Column(name = "JOB_ID") + @Column(name = "JOB_ID", nullable = false) private String jobId; - @Column(name = "JOB_TYPE") + @Column(name = "JOB_TYPE", nullable = false) private String jobType; @Enumerated(EnumType.STRING) - @Column(name = "JOB_ACTION") + @Column(name = "JOB_ACTION", nullable = false) private JobAction jobAction; - @Column(name = "RESOURCE_ID") + @Column(name = "RESOURCE_ID", nullable = false) private String resourceId; @Column(name = "RESOURCE_NAME") private String resourceName; @Enumerated(EnumType.STRING) - @Column(name = "STATUS") + @Column(name = "STATUS", nullable = false) private JobStatusEnum status; @Column(name = "START_TIME") @@ -238,14 +238,17 @@ public class NfvoJob { @Override public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null || getClass() != obj.getClass()) + return false; if (obj instanceof NfvoJob) { final NfvoJob other = (NfvoJob) obj; return Objects.equals(jobId, other.jobId) && Objects.equals(processInstanceId, other.processInstanceId) && Objects.equals(jobType, other.jobType) && Objects.equals(jobAction, other.jobAction) && Objects.equals(progress, other.progress) && Objects.equals(status, other.status) && Objects.equals(startTime, other.startTime) && Objects.equals(endTime, other.endTime) - && Objects.equals(status, other.status) && Objects.equals(resourceId, other.resourceId) - && Objects.equals(resourceName, other.resourceName) + && Objects.equals(resourceId, other.resourceId) && Objects.equals(resourceName, other.resourceName) && Utils.isEquals(nfvoJobStatuses, other.nfvoJobStatuses); } return false; diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoJobStatus.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoJobStatus.java index 89e07701ed..66ae0e503c 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoJobStatus.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoJobStatus.java @@ -44,17 +44,17 @@ public class NfvoJobStatus { private int id; @Enumerated(EnumType.STRING) - @Column(name = "STATUS") + @Column(name = "STATUS", nullable = false) private JobStatusEnum status; @Column(name = "DESCRIPTION", columnDefinition = "LONGTEXT") private String description; - @Column(name = "UPDATED_TIME") + @Column(name = "UPDATED_TIME", nullable = false) private LocalDateTime updatedTime; @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "JOB_ID") + @JoinColumn(name = "JOB_ID", nullable = false) private NfvoJob nfvoJob; public int getId() { @@ -116,17 +116,21 @@ public class NfvoJobStatus { @Override public int hashCode() { - return Objects.hash(id, status, updatedTime, description, nfvoJob.getJobId()); + return Objects.hash(id, status, updatedTime, description, nfvoJob != null ? nfvoJob.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 NfvoJobStatus) { final NfvoJobStatus other = (NfvoJobStatus) obj; return Objects.equals(id, other.id) && Objects.equals(status, other.status) && Objects.equals(updatedTime, other.updatedTime) && Objects.equals(description, other.description) - && Objects.equals(nfvoJob.getJobId(), other.nfvoJob.getJobId()); + && (nfvoJob == null ? other.nfvoJob == null + : other.nfvoJob != null && Objects.equals(nfvoJob.getJobId(), other.nfvoJob.getJobId())); } return false; } diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoNfInst.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoNfInst.java index e901e10596..570355fb37 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoNfInst.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoNfInst.java @@ -41,7 +41,7 @@ import javax.persistence.Table; public class NfvoNfInst { @Id - @Column(name = "NF_INST_ID") + @Column(name = "NF_INST_ID", nullable = false) private String nfInstId; @Column(name = "NAME") @@ -54,11 +54,11 @@ public class NfvoNfInst { private String packageId; @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "NS_INST_ID") + @JoinColumn(name = "NS_INST_ID", nullable = false) private NfvoNsInst nsInst; @Enumerated(EnumType.STRING) - @Column(name = "STATUS") + @Column(name = "STATUS", nullable = false) private State status; @Column(name = "CREATE_TIME") @@ -184,13 +184,15 @@ public class NfvoNfInst { final NfvoNfInst that = (NfvoNfInst) object; return Objects.equals(nfInstId, that.nfInstId) && Objects.equals(name, that.name) && Objects.equals(vnfdId, that.vnfdId) && Objects.equals(packageId, that.packageId) - && Objects.equals(nsInst, that.nsInst) && Objects.equals(status, that.status) - && Objects.equals(createTime, that.createTime) && Objects.equals(lastUpdateTime, that.lastUpdateTime); + && (nsInst == null ? that.nsInst == null : that.nsInst != null && Objects.equals(nsInst, that.nsInst)) + && Objects.equals(status, that.status) && Objects.equals(createTime, that.createTime) + && Objects.equals(lastUpdateTime, that.lastUpdateTime); } @Override public int hashCode() { - return Objects.hash(nfInstId, name, vnfdId, packageId, nsInst, status, createTime, lastUpdateTime); + return Objects.hash(nfInstId, name, vnfdId, packageId, nsInst != null ? nsInst.getNsInstId() : 0, status, + createTime, lastUpdateTime); } @Override diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoNsInst.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoNsInst.java index dd8448fe56..04f988c2fc 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoNsInst.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NfvoNsInst.java @@ -44,29 +44,29 @@ import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.utils.Utils.toIndented public class NfvoNsInst { @Id - @Column(name = "NS_INST_ID") + @Column(name = "NS_INST_ID", nullable = false) private String nsInstId; - @Column(name = "NAME") + @Column(name = "NAME", nullable = false) private String name; @Column(name = "NS_PACKAGE_ID") private String nsPackageId; - @Column(name = "NSD_ID") + @Column(name = "NSD_ID", nullable = false) private String nsdId; - @Column(name = "NSD_INVARIANT_ID") + @Column(name = "NSD_INVARIANT_ID", nullable = false) private String nsdInvariantId; @Column(name = "DESCRIPTION", columnDefinition = "LONGTEXT") private String description; @Enumerated(EnumType.STRING) - @Column(name = "STATUS") + @Column(name = "STATUS", nullable = false) private State status; - @Column(name = "STATUS_UPDATED_TIME") + @Column(name = "STATUS_UPDATED_TIME", nullable = false) private LocalDateTime statusUpdatedTime; @Column(name = "GLOBAL_CUSTOMER_ID") @@ -251,6 +251,10 @@ public class NfvoNsInst { @Override public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null || getClass() != obj.getClass()) + return false; if (obj instanceof NfvoNsInst) { final NfvoNsInst other = (NfvoNsInst) obj; return Objects.equals(nsInstId, other.nsInstId) && Objects.equals(name, other.name) diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NsLcmOpOcc.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NsLcmOpOcc.java index c47bbdbefb..4846e5a361 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NsLcmOpOcc.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/NsLcmOpOcc.java @@ -41,11 +41,11 @@ import javax.persistence.Table; public class NsLcmOpOcc { @Id - @Column(name = "ID") + @Column(name = "ID", nullable = false) private String id; @Enumerated(EnumType.STRING) - @Column(name = "OPERATION_STATE") + @Column(name = "OPERATION_STATE", nullable = false) private OperationStateEnum operationState; @Column(name = "STATE_ENTERED_TIME") @@ -55,22 +55,26 @@ public class NsLcmOpOcc { private LocalDateTime startTime; @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "NS_INST_ID") + @JoinColumn(name = "NS_INST_ID", nullable = false) private NfvoNsInst nfvoNsInst; @Enumerated(EnumType.STRING) - @Column(name = "OPERATION") + @Column(name = "OPERATION", nullable = false) private NsLcmOpType operation; - @Column(name = "IS_AUTO_INNOVATION") - private boolean isAutoInnovation; + @Column(name = "IS_AUTO_INVOCATION", nullable = false) + private boolean isAutoInvocation; - @Column(name = "OPERATION_PARAMS", columnDefinition = "LONGTEXT") + @Column(name = "OPERATION_PARAMS", columnDefinition = "LONGTEXT", nullable = false) private String operationParams; - @Column(name = "IS_CANCEL_PENDING") + @Column(name = "IS_CANCEL_PENDING", nullable = false) private boolean isCancelPending; + @Enumerated(EnumType.STRING) + @Column(name = "CANCEL_MODE") + private CancelModeType cancelMode; + public NsLcmOpOcc() { this.id = UUID.randomUUID().toString(); } @@ -153,16 +157,29 @@ public class NsLcmOpOcc { return this; } - public boolean getIsAutoInnovation() { - return isAutoInnovation; + public boolean getIsAutoInvocation() { + return isAutoInvocation; + } + + public void setIsAutoInvocation(final boolean isAutoInvocation) { + this.isAutoInvocation = isAutoInvocation; + } + + public NsLcmOpOcc isAutoInvocation(final boolean isAutoInvocation) { + this.isAutoInvocation = isAutoInvocation; + return this; + } + + public CancelModeType getCancelMode() { + return cancelMode; } - public void setIsAutoInnovation(final boolean isAutoInnovation) { - this.isAutoInnovation = isAutoInnovation; + public void setCancelMode(final CancelModeType cancelMode) { + this.cancelMode = cancelMode; } - public NsLcmOpOcc isAutoInnovation(final boolean isAutoInnovation) { - this.isAutoInnovation = isAutoInnovation; + public NsLcmOpOcc cancelMode(final CancelModeType cancelMode) { + this.cancelMode = cancelMode; return this; } @@ -193,24 +210,26 @@ public class NsLcmOpOcc { } @Override - public boolean equals(final Object object) { - if (this == object) + public boolean equals(final Object obj) { + if (this == obj) return true; - if (object == null || getClass() != object.getClass()) + if (obj == null || getClass() != obj.getClass()) return false; - final NsLcmOpOcc that = (NsLcmOpOcc) object; + final NsLcmOpOcc that = (NsLcmOpOcc) obj; return Objects.equals(id, that.id) && Objects.equals(operationState, that.operationState) && Objects.equals(stateEnteredTime, that.stateEnteredTime) && Objects.equals(startTime, that.startTime) - && Objects.equals(nfvoNsInst, that.nfvoNsInst) && Objects.equals(operation, that.operation) - && Objects.equals(isAutoInnovation, that.isAutoInnovation) + && (nfvoNsInst == null ? that.nfvoNsInst == null + : that.nfvoNsInst != null && Objects.equals(nfvoNsInst, that.nfvoNsInst)) + && Objects.equals(operation, that.operation) && Objects.equals(isAutoInvocation, that.isAutoInvocation) && Objects.equals(operationParams, that.operationParams) - && Objects.equals(isCancelPending, that.isCancelPending); + && Objects.equals(isCancelPending, that.isCancelPending) && Objects.equals(cancelMode, that.cancelMode); } @Override public int hashCode() { - return Objects.hash(id, operationState, stateEnteredTime, startTime, nfvoNsInst, operation, isAutoInnovation, - operationParams, isCancelPending); + return Objects.hash(id, operationState, stateEnteredTime, startTime, + nfvoNsInst != null ? nfvoNsInst.getNsInstId() : 0, operation, isAutoInvocation, operationParams, + isCancelPending, cancelMode); } @Override @@ -224,9 +243,10 @@ public class NsLcmOpOcc { sb.append(" nfvoNsInst: ").append(nfvoNsInst != null ? toIndentedString(nfvoNsInst.getNsInstId()) : null) .append("\n"); sb.append(" operation: ").append(toIndentedString(operation)).append("\n"); - sb.append(" isAutoInnovation: ").append(toIndentedString(isAutoInnovation)).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-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/utils/Utils.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/utils/Utils.java index c55ef5728e..b84f95aa50 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/utils/Utils.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/beans/utils/Utils.java @@ -39,10 +39,11 @@ public class Utils { if (first == null) { return second == null; } + if (first.isEmpty()) { return second.isEmpty(); } - if (first.size() == second.size()) { + 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; diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/service/DatabaseServiceProvider.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/service/DatabaseServiceProvider.java index 1aaddebc5e..1487b630c7 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/service/DatabaseServiceProvider.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/database/service/DatabaseServiceProvider.java @@ -120,11 +120,6 @@ public class DatabaseServiceProvider { return nfvoNfInstRepository.save(nfvoNfInst) != null; } - public Optional<NfvoNfInst> getNfvoNfInstByNfInstId(final String nfInstId) { - logger.info("Querying database for NfvoNfInst using nfInstId: {}", nfInstId); - return nfvoNfInstRepository.findByNfInstId(nfInstId); - } - public List<NfvoNfInst> getNfvoNfInstByNsInstId(final String nsInstId) { logger.info("Querying database for NfvoNfInst using nsInstId: {}", nsInstId); return nfvoNfInstRepository.findByNsInstNsInstId(nsInstId); @@ -160,5 +155,8 @@ public class DatabaseServiceProvider { return nsLcmOpOccRepository.findById(id); } - + public void deleteNfvoNsInst(final String nsInstId) { + logger.info("Deleting NfvoNsInst with nsInstId: {}", nsInstId); + nfvoNsInstRepository.deleteById(nsInstId); + } } |