summaryrefslogtreecommitdiffstats
path: root/mso-catalog-db/src/main/java/org
diff options
context:
space:
mode:
authorKuleshov, Elena <evn@att.com>2020-04-16 11:02:28 -0400
committerBenjamin, Max (mb388a) <mb388a@att.com>2020-04-16 11:02:29 -0400
commitd255e437b624bb88eab336b1c0b74372e821e99c (patch)
tree2c76c81fb8d87a8b5ea5265bff1f451a82a73e50 /mso-catalog-db/src/main/java/org
parentb0f5ac59c297f81b7f17c1f367e64257ef7be2d2 (diff)
Implement processing_flags table and corresponding
Implement processing_flags table and corresponding interfaces. Implement rest interface for processingFlags table to toggle the value. Correct hashcode calculation for ProcessingFlags bean. Use newFabricConfigurationApi flag for managing FabricConfiguration BB logic. Remove readOnly specification from updating the processing_flags table Make sure update_timestamp field updates automatically. Issue-ID: SO-2814 Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com> Change-Id: I00697f8edf62c2d3d725daa710c17f03595eac51
Diffstat (limited to 'mso-catalog-db/src/main/java/org')
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ProcessingFlags.java187
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java15
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ProcessingFlagsRepository.java33
3 files changed, 235 insertions, 0 deletions
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ProcessingFlags.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ProcessingFlags.java
new file mode 100644
index 0000000000..211da5d90b
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ProcessingFlags.java
@@ -0,0 +1,187 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.db.catalog.beans;
+
+import java.util.Date;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Lob;
+import javax.persistence.PrePersist;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import org.hibernate.annotations.UpdateTimestamp;
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.openpojo.business.annotation.BusinessKey;
+import uk.co.blackpepper.bowman.annotation.RemoteResource;
+
+
+/**
+ * EntityBean class for ProcessingFlags. This bean represents a set of flags governing request processing.
+ *
+ */
+@RemoteResource("/processingFlags")
+@Entity
+@Table(name = "processing_flags")
+@JsonAutoDetect(fieldVisibility = Visibility.ANY)
+public class ProcessingFlags {
+
+ @Id
+ @Column(name = "ID", nullable = false, updatable = false)
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ private Integer id;
+
+ @JsonProperty("flag")
+ @BusinessKey
+ @Column(name = "FLAG")
+ private String flag;
+
+ @JsonProperty("value")
+ @BusinessKey
+ @Column(name = "VALUE")
+ private String value;
+
+ @JsonProperty("endpoint")
+ @BusinessKey
+ @Column(name = "ENDPOINT")
+ private String endpoint;
+
+ @JsonProperty("description")
+ @Lob
+ @Column(name = "DESCRIPTION", columnDefinition = "LONGTEXT")
+ private String description = null;
+
+ @JsonProperty("creation_timestamp")
+ @BusinessKey
+ @Column(name = "CREATION_TIMESTAMP", updatable = false)
+ @Temporal(TemporalType.TIMESTAMP)
+ private Date created;
+
+ @JsonProperty("update_timestamp")
+ @BusinessKey
+ @Column(name = "UPDATE_TIMESTAMP")
+ @Temporal(TemporalType.TIMESTAMP)
+ @UpdateTimestamp
+ private Date updated;
+
+ public ProcessingFlags() {
+
+ }
+
+ @PrePersist
+ protected void onCreate() {
+ this.created = new Date();
+ // this.updated = new Date();
+ }
+
+ public ProcessingFlags(ProcessingFlags flags) {
+ this.flag = flags.getFlag();
+ this.value = flags.getValue();
+ this.endpoint = flags.getEndpoint();
+ this.description = flags.getDescription();
+ }
+
+ public Integer getId() {
+ return this.id;
+ }
+
+ public String getFlag() {
+ return flag;
+ }
+
+ public void setFlag(String flag) {
+ this.flag = flag;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public String getEndpoint() {
+ return endpoint;
+ }
+
+ public void setEndpoint(String endpoint) {
+ this.endpoint = endpoint;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public Date getCreated() {
+ return created;
+ }
+
+ public void setCreated(Date created) {
+ this.created = created;
+ }
+
+ public Date getUpdated() {
+ return updated;
+ }
+
+ public void setUpdated(Date updated) {
+ this.updated = updated;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("flag", getFlag())
+ .append("value", getValue()).append("endpoint", getEndpoint()).append("description", getDescription())
+ .toString();
+ }
+
+ @Override
+ public boolean equals(final Object other) {
+ if (other == null) {
+ return false;
+ }
+ if (!getClass().equals(other.getClass())) {
+ return false;
+ }
+ ProcessingFlags castOther = (ProcessingFlags) other;
+ return new EqualsBuilder().append(getFlag(), castOther.getFlag()).append(getValue(), castOther.getValue())
+ .isEquals();
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder(1, 31).append(getFlag()).append(getValue()).append(getEndpoint()).toHashCode();
+ }
+}
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java
index 4c5bbaf7ec..a68ed44ee7 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java
@@ -52,6 +52,7 @@ import org.onap.so.db.catalog.beans.OrchestrationStatus;
import org.onap.so.db.catalog.beans.OrchestrationStatusStateTransitionDirective;
import org.onap.so.db.catalog.beans.PnfResource;
import org.onap.so.db.catalog.beans.PnfResourceCustomization;
+import org.onap.so.db.catalog.beans.ProcessingFlags;
import org.onap.so.db.catalog.beans.ResourceType;
import org.onap.so.db.catalog.beans.Service;
import org.onap.so.db.catalog.beans.ServiceRecipe;
@@ -121,6 +122,7 @@ public class CatalogDbClient {
private static final String PNF_RESOURCE_CUSTOMIZATION = "/pnfResourceCustomization";
private static final String WORKFLOW = "/workflow";
private static final String BB_NAME_SELECTION_REFERENCE = "/bbNameSelectionReference";
+ private static final String PROCESSING_FLAGS = "/processingFlags";
private static final String SEARCH = "/search";
@@ -159,6 +161,7 @@ public class CatalogDbClient {
protected static final String ARTIFACT_UUID = "artifactUUID";
protected static final String SOURCE = "source";
protected static final String RESOURCE_TARGET = "resourceTarget";
+ protected static final String FLAG = "flag";
private static final String TARGET_ENTITY = "SO:CatalogDB";
private static final String ASTERISK = "*";
@@ -211,6 +214,7 @@ public class CatalogDbClient {
private String findBBNameSelectionReferenceByControllerActorAndScopeAndAction =
"/findBBNameSelectionReferenceByControllerActorAndScopeAndAction";
private String findWorkflowByResourceTarget = "/findByResourceTarget";
+ private String findProcessingFlagsByFlag = "/findByFlag";
private String serviceURI;
private String vfModuleURI;
@@ -285,6 +289,8 @@ public class CatalogDbClient {
private final Client<BBNameSelectionReference> bbNameSelectionReferenceClient;
+ private final Client<ProcessingFlags> processingFlagsClient;
+
@Value("${mso.catalog.db.spring.endpoint:#{null}}")
private String endpoint;
@@ -358,6 +364,8 @@ public class CatalogDbClient {
findBBNameSelectionReferenceByControllerActorAndScopeAndAction = endpoint + BB_NAME_SELECTION_REFERENCE + SEARCH
+ findBBNameSelectionReferenceByControllerActorAndScopeAndAction;
+ findProcessingFlagsByFlag = endpoint + PROCESSING_FLAGS + SEARCH + findProcessingFlagsByFlag;
+
serviceURI = endpoint + SERVICE + URI_SEPARATOR;
vfModuleURI = endpoint + VFMODULE + URI_SEPARATOR;
vnfResourceURI = endpoint + VNF_RESOURCE + URI_SEPARATOR;
@@ -425,6 +433,7 @@ public class CatalogDbClient {
pnfResourceCustomizationClient = clientFactory.create(PnfResourceCustomization.class);
workflowClient = clientFactory.create(Workflow.class);
bbNameSelectionReferenceClient = clientFactory.create(BBNameSelectionReference.class);
+ processingFlagsClient = clientFactory.create(ProcessingFlags.class);
}
@@ -477,6 +486,7 @@ public class CatalogDbClient {
pnfResourceCustomizationClient = clientFactory.create(PnfResourceCustomization.class);
workflowClient = clientFactory.create(Workflow.class);
bbNameSelectionReferenceClient = clientFactory.create(BBNameSelectionReference.class);
+ processingFlagsClient = clientFactory.create(ProcessingFlags.class);
}
public NetworkCollectionResourceCustomization getNetworkCollectionResourceCustomizationByID(
@@ -1091,6 +1101,11 @@ public class CatalogDbClient {
.queryParam(RESOURCE_TARGET, resourceTarget).build().toString()));
}
+ public ProcessingFlags findProcessingFlagsByFlag(String flag) {
+ return this.getSingleResource(processingFlagsClient,
+ getUri(UriBuilder.fromUri(findProcessingFlagsByFlag).queryParam(FLAG, flag).build().toString()));
+ }
+
public String getEndpoint() {
return endpoint;
}
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ProcessingFlagsRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ProcessingFlagsRepository.java
new file mode 100644
index 0000000000..b6583035df
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ProcessingFlagsRepository.java
@@ -0,0 +1,33 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.db.catalog.data.repository;
+
+import org.onap.so.db.catalog.beans.ProcessingFlags;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.rest.core.annotation.RepositoryRestResource;
+import javax.transaction.Transactional;
+
+@RepositoryRestResource(collectionResourceRel = "processingFlags", path = "processingFlags")
+@Transactional
+public interface ProcessingFlagsRepository extends JpaRepository<ProcessingFlags, String> {
+
+ ProcessingFlags findByFlag(String flag);
+}