aboutsummaryrefslogtreecommitdiffstats
path: root/models/src/main/java/org
diff options
context:
space:
mode:
authorsaul.gill <saul.gill@est.tech>2023-01-13 17:24:23 +0000
committersaul.gill <saul.gill@est.tech>2023-01-19 13:07:33 +0000
commit46964ab900060a560b9b41f7d34ab0e26ac7fd61 (patch)
treed4d15350f492cc19ee657df6cb926349bd724919 /models/src/main/java/org
parent48df549e1fd90c2768a78c0c88e87dc3834b6222 (diff)
Add supported ac elements to participants
Added new supported elements table Added supported element names and versions to participant application.yaml files Issue-ID: POLICY-4512 Change-Id: I97d7f571f2906846514ac0804b4827f0601177d7 Signed-off-by: saul.gill <saul.gill@est.tech>
Diffstat (limited to 'models/src/main/java/org')
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/concepts/Participant.java4
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantInformation.java2
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantSupportedElementType.java55
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantAckMessage.java2
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegister.java7
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatus.java4
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipant.java34
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantSupportedElementType.java176
8 files changed, 279 insertions, 5 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/Participant.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/Participant.java
index c6da3c3d1..56c01837f 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/Participant.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/Participant.java
@@ -20,6 +20,7 @@
package org.onap.policy.clamp.models.acm.concepts;
+import java.util.Map;
import java.util.UUID;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -48,6 +49,9 @@ public class Participant extends ToscaEntity implements Comparable<Participant>
@NonNull
private ToscaConceptIdentifier participantType = new ToscaConceptIdentifier();
+ @NonNull
+ private Map<UUID, ParticipantSupportedElementType> participantSupportedElementTypes;
+
@Override
public String getType() {
return definition.getName();
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantInformation.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantInformation.java
index c2f61aa74..a6a65fec5 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantInformation.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantInformation.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * 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.
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantSupportedElementType.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantSupportedElementType.java
new file mode 100644
index 000000000..310577167
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantSupportedElementType.java
@@ -0,0 +1,55 @@
+/*-
+ * ============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.policy.clamp.models.acm.concepts;
+
+import java.util.UUID;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import org.onap.policy.common.parameters.annotations.NotNull;
+import org.springframework.validation.annotation.Validated;
+
+@NoArgsConstructor
+@Getter
+@Setter
+@Validated
+public class ParticipantSupportedElementType {
+
+ @NotNull
+ private UUID id = UUID.randomUUID();
+
+ @NotNull
+ private String typeName;
+
+ @NotNull
+ private String typeVersion;
+
+ /**
+ * Copy constructor, does a deep copy but as all fields here are immutable, it's just a regular copy.
+ *
+ * @param otherParticipantSupportedElementType the other element to copy from
+ */
+ public ParticipantSupportedElementType(final ParticipantSupportedElementType otherParticipantSupportedElementType) {
+ this.id = otherParticipantSupportedElementType.getId();
+ this.typeName = otherParticipantSupportedElementType.getTypeName();
+ this.typeVersion = otherParticipantSupportedElementType.getTypeVersion();
+ }
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantAckMessage.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantAckMessage.java
index 8b33d3172..c6d56904d 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantAckMessage.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantAckMessage.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-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.
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegister.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegister.java
index 7b315dbe0..d8f9a4caf 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegister.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegister.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-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.
@@ -20,9 +20,11 @@
package org.onap.policy.clamp.models.acm.messages.dmaap.participant;
+import java.util.List;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantSupportedElementType;
/**
* Class to represent the PARTICIPANT_REGISTER message that all the participants send to the ACM runtime.
@@ -32,6 +34,8 @@ import lombok.ToString;
@ToString(callSuper = true)
public class ParticipantRegister extends ParticipantMessage {
+ private List<ParticipantSupportedElementType> participantSupportedElementType;
+
/**
* Constructor for instantiating ParticipantRegister class with message name.
*
@@ -47,5 +51,6 @@ public class ParticipantRegister extends ParticipantMessage {
*/
public ParticipantRegister(final ParticipantRegister source) {
super(source);
+ this.participantSupportedElementType = source.getParticipantSupportedElementType();
}
}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatus.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatus.java
index 31a42c548..2412bddcb 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatus.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatus.java
@@ -28,6 +28,7 @@ import lombok.ToString;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionInfo;
import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition;
import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantSupportedElementType;
import org.onap.policy.models.base.PfUtils;
/**
@@ -47,10 +48,12 @@ public class ParticipantStatus extends ParticipantMessage {
// List of AutomationCompositionInfo types with AutomationCompositionId and its state
private List<AutomationCompositionInfo> automationCompositionInfoList = new ArrayList<>();
+ private List<ParticipantSupportedElementType> participantSupportedElementType;
/**
* Constructor for instantiating ParticipantStatus class with message name.
*
*/
+
public ParticipantStatus() {
super(ParticipantMessageType.PARTICIPANT_STATUS);
}
@@ -68,5 +71,6 @@ public class ParticipantStatus extends ParticipantMessage {
PfUtils.mapList(source.participantDefinitionUpdates, ParticipantDefinition::new);
this.automationCompositionInfoList =
PfUtils.mapList(source.automationCompositionInfoList, AutomationCompositionInfo::new);
+ this.participantSupportedElementType = source.getParticipantSupportedElementType();
}
}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipant.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipant.java
index 398daa245..7d043ace0 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipant.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipant.java
@@ -21,14 +21,21 @@
package org.onap.policy.clamp.models.acm.persistence.concepts;
import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.UUID;
import javax.persistence.AttributeOverride;
+import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.ForeignKey;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
+import javax.persistence.JoinColumn;
+import javax.persistence.OneToMany;
import javax.persistence.Table;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -37,6 +44,7 @@ import org.apache.commons.lang3.ObjectUtils;
import org.onap.policy.clamp.models.acm.concepts.Participant;
import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
import org.onap.policy.common.parameters.annotations.NotNull;
+import org.onap.policy.common.parameters.annotations.Valid;
import org.onap.policy.models.base.PfAuthorative;
import org.onap.policy.models.base.PfConcept;
import org.onap.policy.models.base.PfConceptKey;
@@ -86,6 +94,12 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
@Column
private String description;
+ @NotNull
+ @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
+ @JoinColumn(name = "participantId", referencedColumnName = "participantId",
+ foreignKey = @ForeignKey(name = "supported_element_fk"))
+ private List<@NotNull @Valid JpaParticipantSupportedElementType> supportedElements;
+
/**
* The Default Constructor creates a {@link JpaParticipant} object with a null key.
*/
@@ -99,7 +113,7 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
* @param key the key
*/
public JpaParticipant(@NonNull final PfConceptKey key) {
- this(UUID.randomUUID().toString(), key, new PfConceptKey(), ParticipantState.ON_LINE);
+ this(UUID.randomUUID().toString(), key, new PfConceptKey(), ParticipantState.ON_LINE, new ArrayList<>());
}
/**
@@ -113,11 +127,13 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
public JpaParticipant(@NotNull String participantId,
@NonNull final PfConceptKey key,
@NonNull final PfConceptKey definition,
- @NonNull final ParticipantState participantState) {
+ @NonNull final ParticipantState participantState,
+ @NonNull final List<JpaParticipantSupportedElementType> supportedAcElementTypes) {
this.key = key;
this.definition = definition;
this.participantState = participantState;
this.participantId = participantId;
+ this.supportedElements = supportedAcElementTypes;
}
/**
@@ -133,6 +149,7 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
this.description = copyConcept.description;
this.participantType = copyConcept.participantType;
this.participantId = copyConcept.participantId;
+ this.supportedElements = copyConcept.supportedElements;
}
/**
@@ -155,6 +172,11 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
participant.setDescription(description);
participant.setParticipantType(new ToscaConceptIdentifier(participantType));
participant.setParticipantId(UUID.fromString(participantId));
+ participant.setParticipantSupportedElementTypes(new LinkedHashMap<>(this.supportedElements.size()));
+ for (var element : this.supportedElements) {
+ participant.getParticipantSupportedElementTypes()
+ .put(UUID.fromString(element.getId()), element.toAuthorative());
+ }
return participant;
}
@@ -170,6 +192,14 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
this.setDescription(participant.getDescription());
this.participantType = participant.getParticipantType().asConceptKey();
this.participantId = participant.getParticipantId().toString();
+ this.supportedElements = new ArrayList<>(participant.getParticipantSupportedElementTypes().size());
+
+ for (var elementEntry : participant.getParticipantSupportedElementTypes().entrySet()) {
+ var jpaParticipantSupportedElementType = new JpaParticipantSupportedElementType();
+ jpaParticipantSupportedElementType.setParticipantId(this.participantId);
+ jpaParticipantSupportedElementType.fromAuthorative(elementEntry.getValue());
+ this.supportedElements.add(jpaParticipantSupportedElementType);
+ }
}
@Override
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantSupportedElementType.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantSupportedElementType.java
new file mode 100644
index 000000000..906f66fa9
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantSupportedElementType.java
@@ -0,0 +1,176 @@
+/*-
+ * ============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.policy.clamp.models.acm.persistence.concepts;
+
+import java.util.UUID;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NonNull;
+import org.apache.commons.lang3.ObjectUtils;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantSupportedElementType;
+import org.onap.policy.common.parameters.annotations.NotNull;
+import org.onap.policy.models.base.PfAuthorative;
+import org.onap.policy.models.base.Validated;
+
+@Entity
+@Table(name = "ParticipantSupportedAcElements")
+@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
+@Data
+@EqualsAndHashCode(callSuper = false)
+public class JpaParticipantSupportedElementType extends Validated
+ implements PfAuthorative<ParticipantSupportedElementType>, Comparable<JpaParticipantSupportedElementType> {
+
+ @NotNull
+ @Column
+ @Id
+ private String id;
+ @NotNull
+ @Column
+ private String participantId;
+
+ @NotNull
+ @Column
+ private String typeName;
+
+ @NotNull
+ @Column
+ private String typeVersion;
+
+ /**
+ * The default Constructor creates a {@link JpaParticipantSupportedElementType} with a generated id.
+ *
+ */
+ public JpaParticipantSupportedElementType() {
+ this(UUID.randomUUID().toString());
+ }
+
+ /**
+ * The Key Constructor creates a {@link JpaParticipantSupportedElementType} with just a generated id parameter.
+ *
+ * @param id the main id of the element type
+ */
+ public JpaParticipantSupportedElementType(@NonNull String id) {
+ this(id, UUID.randomUUID().toString());
+ }
+
+ /**
+ * The Key Constructor creates a {@link JpaParticipantSupportedElementType} with id and participantId.
+ *
+ * @param id the main id of the element type
+ * @param participantId the participant id
+ */
+ public JpaParticipantSupportedElementType(@NonNull String id, @NonNull String participantId) {
+ this(id, participantId, "", "");
+ }
+
+ /**
+ * The Key Constructor creates a {@link JpaParticipantSupportedElementType} object with all mandatory fields.
+ *
+ * @param id the main id of the element type
+ * @param participantId the participant id
+ * @param typeName the type name of the supported element
+ * @param typeVersion the type version of the supported element
+ */
+ public JpaParticipantSupportedElementType(@NonNull String id,
+ @NonNull String participantId,
+ @NonNull String typeName,
+ @NonNull String typeVersion) {
+ this.id = id;
+ this.participantId = participantId;
+ this.typeName = typeName;
+ this.typeVersion = typeVersion;
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * @param copyConcept the concept to copy from
+ */
+ public JpaParticipantSupportedElementType(@NonNull final JpaParticipantSupportedElementType copyConcept) {
+ this.id = copyConcept.id;
+ this.participantId = copyConcept.participantId;
+ this.typeName = copyConcept.typeName;
+ this.typeVersion = copyConcept.typeVersion;
+ }
+
+ /**
+ * Authorative constructor.
+ *
+ * @param authorativeConcept the authorative concept to copy from
+ */
+ public JpaParticipantSupportedElementType(@NonNull final ParticipantSupportedElementType authorativeConcept) {
+ this.fromAuthorative(authorativeConcept);
+ }
+
+ @Override
+ public int compareTo(final JpaParticipantSupportedElementType other) {
+ if (other == null) {
+ return -1;
+ }
+ if (this == other) {
+ return 0;
+ }
+
+ var result = ObjectUtils.compare(participantId, other.participantId);
+ if (result != 0) {
+ return result;
+ }
+
+ result = ObjectUtils.compare(typeName, other.typeName);
+ if (result != 0) {
+ return result;
+ }
+
+ result = ObjectUtils.compare(id, other.id);
+ if (result != 0) {
+ return result;
+ }
+
+ result = typeVersion.compareTo(other.typeVersion);
+ if (result != 0) {
+ return result;
+ }
+
+ return 0;
+ }
+
+ @Override
+ public ParticipantSupportedElementType toAuthorative() {
+ var element = new ParticipantSupportedElementType();
+ element.setId(UUID.fromString(id));
+ element.setTypeName(typeName);
+ element.setTypeVersion(typeVersion);
+ return element;
+ }
+
+ @Override
+ public void fromAuthorative(@NonNull ParticipantSupportedElementType participantSupportedElementType) {
+ this.id = participantSupportedElementType.getId().toString();
+ this.typeName = participantSupportedElementType.getTypeName();
+ this.typeVersion = participantSupportedElementType.getTypeVersion();
+ }
+}