summaryrefslogtreecommitdiffstats
path: root/model/policy-model/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'model/policy-model/src/main')
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicyModel.java9
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateOutput.java80
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTask.java180
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalyser.java3
4 files changed, 65 insertions, 207 deletions
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicyModel.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicyModel.java
index d55fbd329..4ee176d97 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicyModel.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicyModel.java
@@ -3,6 +3,7 @@
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
@@ -502,9 +503,9 @@ public class AxPolicyModel extends AxModel {
}
for (final AxStateOutput stateOutput : state.getStateOutputs().values()) {
- if (events.getEventMap().get(stateOutput.getOutgingEvent()) == null) {
+ if (events.getEventMap().get(stateOutput.getOutgoingEvent()) == null) {
result.addValidationMessage(new AxValidationMessage(stateOutput.getKey(), this.getClass(),
- ValidationResult.INVALID, "output event " + stateOutput.getOutgingEvent().getId()
+ ValidationResult.INVALID, "output event " + stateOutput.getOutgoingEvent().getId()
+ " for state output " + stateOutput.getId() + DOES_NOT_EXIST));
}
}
@@ -555,10 +556,10 @@ public class AxPolicyModel extends AxModel {
ValidationResult.INVALID, "state output on task reference for task " + task.getId() + " is null"));
} else {
- final AxEvent usedEvent = events.getEventMap().get(stateOutput.getOutgingEvent());
+ final AxEvent usedEvent = events.getEventMap().get(stateOutput.getOutgoingEvent());
if (usedEvent == null) {
result.addValidationMessage(new AxValidationMessage(stateOutput.getKey(), this.getClass(),
- ValidationResult.INVALID, "output event " + stateOutput.getOutgingEvent().getId()
+ ValidationResult.INVALID, "output event " + stateOutput.getOutgoingEvent().getId()
+ " for state output " + stateOutput.getId() + DOES_NOT_EXIST));
}
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateOutput.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateOutput.java
index 27c187356..1337e2417 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateOutput.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateOutput.java
@@ -3,6 +3,7 @@
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
@@ -23,17 +24,24 @@
package org.onap.policy.apex.model.policymodel.concepts;
import java.util.List;
+import java.util.Set;
import javax.persistence.AttributeOverride;
+import javax.persistence.CollectionTable;
import javax.persistence.Column;
+import javax.persistence.ElementCollection;
import javax.persistence.Embedded;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
+import javax.persistence.JoinColumn;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
+import lombok.Getter;
+import lombok.NonNull;
+import lombok.Setter;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
@@ -68,13 +76,15 @@ import org.onap.policy.common.utils.validation.Assertions;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "apexStateOutput", namespace = "http://www.onap.org/policy/apex-pdp")
@XmlType(name = "AxStateOutput", namespace = "http://www.onap.org/policy/apex-pdp",
- propOrder = {"key", "outgoingEvent", "nextState"})
-
+ propOrder = {"key", "outgoingEvent", "outgoingEventSet", "nextState"})
+@Getter
+@Setter
public class AxStateOutput extends AxConcept {
private static final long serialVersionUID = 8041771382337655535L;
@EmbeddedId
@XmlElement(name = "key", required = true)
+ @NonNull
private AxReferenceKey key;
// @formatter:off
@@ -83,8 +93,17 @@ public class AxStateOutput extends AxConcept {
@AttributeOverride(name = "version", column = @Column(name = "outgoingEventVersion"))
@Column(name = "outgoingEvent")
@XmlElement(required = true)
+ @NonNull
private AxArtifactKey outgoingEvent;
+ @ElementCollection
+ @CollectionTable(joinColumns = {@JoinColumn(name = "stateParentKeyName", referencedColumnName = "parentKeyName"),
+ @JoinColumn(name = "stateParentKeyVersion", referencedColumnName = "parentKeyVersion"),
+ @JoinColumn(name = "stateParentLocalName", referencedColumnName = "parentLocalName"),
+ @JoinColumn(name = "stateLocalName", referencedColumnName = "localName")})
+ @XmlElement(name = "outgoingEventReference", required = false)
+ private Set<AxArtifactKey> outgoingEventSet;
+
@Embedded
@AttributeOverride(name = "parentKeyName", column = @Column(name = "nextStateParentKeyName"))
@AttributeOverride(name = "parentKeyVersion", column = @Column(name = "nextStateParentKeyVersion"))
@@ -92,6 +111,7 @@ public class AxStateOutput extends AxConcept {
@AttributeOverride(name = "localName", column = @Column(name = "nextStateLocalName"))
@Column(name = "nextState")
@XmlElement(required = true)
+ @NonNull
private AxReferenceKey nextState;
// @formatter:on
@@ -164,14 +184,6 @@ public class AxStateOutput extends AxConcept {
* {@inheritDoc}.
*/
@Override
- public AxReferenceKey getKey() {
- return key;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
public List<AxKey> getKeys() {
final List<AxKey> keyList = key.getKeys();
keyList.add(new AxKeyUse(outgoingEvent));
@@ -184,54 +196,6 @@ public class AxStateOutput extends AxConcept {
}
/**
- * Sets the reference key for the state output.
- *
- * @param key the reference key for the state output
- */
- public void setKey(final AxReferenceKey key) {
- Assertions.argumentNotNull(key, "key may not be null");
- this.key = key;
- }
-
- /**
- * Gets the outgoing event emitted on use of this state output.
- *
- * @return the outgoing event emitted on use of this state output
- */
- public AxArtifactKey getOutgingEvent() {
- return outgoingEvent;
- }
-
- /**
- * Sets the outgoing event emitted on use of this state output.
- *
- * @param outgoingEvent the outgoing event emitted on use of this state output
- */
- public void setOutgoingEvent(final AxArtifactKey outgoingEvent) {
- Assertions.argumentNotNull(outgoingEvent, "outgoingEvent may not be null");
- this.outgoingEvent = outgoingEvent;
- }
-
- /**
- * Gets the next state to which execution will pass on use of this state output.
- *
- * @return the next state to which execution will pass on use of this state output
- */
- public AxReferenceKey getNextState() {
- return nextState;
- }
-
- /**
- * Sets the next state to which execution will pass on use of this state output.
- *
- * @param nextState the next state to which execution will pass on use of this state output
- */
- public void setNextState(final AxReferenceKey nextState) {
- Assertions.argumentNotNull(nextState, "nextState may not be null");
- this.nextState = nextState;
- }
-
- /**
* {@inheritDoc}.
*/
@Override
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTask.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTask.java
index 04b40e44b..a30a80acc 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTask.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTask.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
@@ -33,6 +34,7 @@ import javax.persistence.ElementCollection;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
@@ -42,6 +44,9 @@ import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
+import lombok.Getter;
+import lombok.NonNull;
+import lombok.Setter;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
@@ -50,6 +55,7 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationMessage;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
+import org.onap.policy.apex.model.eventmodel.concepts.AxEvent;
import org.onap.policy.apex.model.eventmodel.concepts.AxField;
import org.onap.policy.apex.model.eventmodel.concepts.AxInputField;
import org.onap.policy.apex.model.eventmodel.concepts.AxOutputField;
@@ -90,9 +96,13 @@ import org.onap.policy.common.utils.validation.Assertions;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "apexTask", namespace = "http://www.onap.org/policy/apex-pdp")
-@XmlType(name = "AxTask", namespace = "http://www.onap.org/policy/apex-pdp",
- propOrder = {"key", "inputFields", "outputFields", "taskParameters", "contextAlbumReferenceSet", "taskLogic"})
-
+@XmlType(
+ name = "AxTask",
+ namespace = "http://www.onap.org/policy/apex-pdp",
+ propOrder = {"key", "inputEvent", "outputEvents", "inputFields", "outputFields", "taskParameters",
+ "contextAlbumReferenceSet", "taskLogic"})
+@Getter
+@Setter
public class AxTask extends AxConcept {
private static final String DOES_NOT_EQUAL_TASK_KEY = " does not equal task key";
@@ -100,8 +110,25 @@ public class AxTask extends AxConcept {
@EmbeddedId
@XmlElement(name = "key", required = true)
+ @NonNull
private AxArtifactKey key;
+ @OneToOne(cascade = CascadeType.ALL)
+ @JoinTable(
+ name = "INPUT_EVENT_JT",
+ joinColumns = {@JoinColumn(name = "inEventTaskName", referencedColumnName = "name", updatable = false),
+ @JoinColumn(name = "inEventTaskVersion", referencedColumnName = "version", updatable = false)})
+ @XmlElement(name = "inputEvent", required = false)
+ private AxEvent inputEvent;
+
+ @OneToMany(cascade = CascadeType.ALL)
+ @JoinTable(
+ name = "OUTPUT_EVENT_JT",
+ joinColumns = {@JoinColumn(name = "outEventTaskName", referencedColumnName = "name", updatable = false),
+ @JoinColumn(name = "outEventTaskVersion", referencedColumnName = "version", updatable = false)})
+ @XmlElement(name = "outputEvents", required = false)
+ private Map<String, AxEvent> outputEvents;
+
@OneToMany(cascade = CascadeType.ALL)
@XmlElement(name = "inputFields", required = true)
private Map<String, AxInputField> inputFields;
@@ -119,11 +146,13 @@ public class AxTask extends AxConcept {
@CollectionTable(joinColumns = {@JoinColumn(name = "contextAlbumName", referencedColumnName = "name"),
@JoinColumn(name = "contextAlbumVersion", referencedColumnName = "version")})
@XmlElement(name = "contextAlbumReference")
+ @NonNull
private Set<AxArtifactKey> contextAlbumReferenceSet;
// @formatter:on
@OneToOne(cascade = CascadeType.ALL)
@XmlElement(required = true)
+ @NonNull
private AxTaskLogic taskLogic;
/**
@@ -219,14 +248,6 @@ public class AxTask extends AxConcept {
* {@inheritDoc}.
*/
@Override
- public AxArtifactKey getKey() {
- return key;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
public List<AxKey> getKeys() {
final List<AxKey> keyList = key.getKeys();
for (final AxInputField inputField : inputFields.values()) {
@@ -246,25 +267,6 @@ public class AxTask extends AxConcept {
}
/**
- * Sets the key of the task.
- *
- * @param key the key of the task
- */
- public void setKey(final AxArtifactKey key) {
- Assertions.argumentNotNull(key, "key may not be null");
- this.key = key;
- }
-
- /**
- * Gets the input fields that the task expects.
- *
- * @return the input fields that the task expects
- */
- public Map<String, AxInputField> getInputFields() {
- return inputFields;
- }
-
- /**
* Gets the raw input fields that the task expects as a tree map.
*
* @return the raw input fields that the task expects
@@ -287,16 +289,6 @@ public class AxTask extends AxConcept {
}
/**
- * Sets the input fields that the task expects.
- *
- * @param inputFields the input fields that the task expects
- */
- public void setInputFields(final Map<String, AxInputField> inputFields) {
- Assertions.argumentNotNull(inputFields, "inputFields may not be null");
- this.inputFields = inputFields;
- }
-
- /**
* Copy the input fields from the given map into the task. This method is used to get a copy of
* the input fields, which can be useful for unit testing of policies and tasks.
*
@@ -314,15 +306,6 @@ public class AxTask extends AxConcept {
}
/**
- * Gets the output fields that the task emits.
- *
- * @return the output fields that the task emits
- */
- public Map<String, AxOutputField> getOutputFields() {
- return outputFields;
- }
-
- /**
* Gets the raw output fields that the task emits as a tree map.
*
* @return the raw output fields as a tree map
@@ -345,16 +328,6 @@ public class AxTask extends AxConcept {
}
/**
- * Sets the output fields that the task emits.
- *
- * @param outputFields the output fields that the task emits
- */
- public void setOutputFields(final Map<String, AxOutputField> outputFields) {
- Assertions.argumentNotNull(outputFields, "outputFields may not be null");
- this.outputFields = outputFields;
- }
-
- /**
* Copy the output fields from the given map into the task. This method is used to get a copy of
* the output fields, which can be useful for unit testing of policies and tasks.
*
@@ -371,24 +344,6 @@ public class AxTask extends AxConcept {
}
}
- /**
- * Gets the task parameters that are used to initialize tasks of this type.
- *
- * @return the task parameters that are used to initialize tasks of this type
- */
- public Map<String, AxTaskParameter> getTaskParameters() {
- return taskParameters;
- }
-
- /**
- * Sets the task parameters that are used to initialize tasks of this type.
- *
- * @param taskParameters the task parameters that are used to initialize tasks of this type
- */
- public void setTaskParameters(final Map<String, AxTaskParameter> taskParameters) {
- Assertions.argumentNotNull(taskParameters, "taskParameters may not be null");
- this.taskParameters = taskParameters;
- }
/**
* Gets the context album reference set defines the context that may be used by Task Logic in
@@ -414,25 +369,6 @@ public class AxTask extends AxConcept {
}
/**
- * Gets the task logic that performs the domain specific work of the task.
- *
- * @return the task logic that performs the domain specific work of the task
- */
- public AxTaskLogic getTaskLogic() {
- return taskLogic;
- }
-
- /**
- * Sets the task logic that performs the domain specific work of the task.
- *
- * @param taskLogic the task logic that performs the domain specific work of the task
- */
- public void setTaskLogic(final AxTaskLogic taskLogic) {
- Assertions.argumentNotNull(taskLogic, "taskLogic may not be null");
- this.taskLogic = taskLogic;
- }
-
- /**
* {@inheritDoc}.
*/
@Override
@@ -446,30 +382,12 @@ public class AxTask extends AxConcept {
result = key.validate(result);
- if (inputFields.size() == 0) {
- result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "inputFields may not be empty"));
- } else {
- for (final Entry<String, AxInputField> inputFieldEntry : inputFields.entrySet()) {
- result = validateField(inputFieldEntry.getKey(), inputFieldEntry.getValue(), "input", result);
- }
- }
-
- if (outputFields.size() == 0) {
- result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "outputFields may not be empty"));
- } else {
- for (final Entry<String, AxOutputField> outputFieldEntry : outputFields.entrySet()) {
- result = validateField(outputFieldEntry.getKey(), outputFieldEntry.getValue(), "input", result);
- }
- }
-
for (final Entry<String, AxTaskParameter> taskParameterEntry : taskParameters.entrySet()) {
- result = vaildateTaskParameterEntry(taskParameterEntry, result);
+ result = validateTaskParameterEntry(taskParameterEntry, result);
}
for (final AxArtifactKey contextAlbumReference : contextAlbumReferenceSet) {
- result = vaildateContextAlbumReference(contextAlbumReference, result);
+ result = validateContextAlbumReference(contextAlbumReference, result);
}
if (!taskLogic.getKey().getParentArtifactKey().equals(key)) {
@@ -481,39 +399,13 @@ public class AxTask extends AxConcept {
}
/**
- * Validate a field.
- *
- * @param fieldKey the key of the field to validate
- * @param field the field to validate
- * @param direction The direction of the field
- * @param result The validation result to append to
- * @return The result of the validation
- */
- private AxValidationResult validateField(final String fieldKey, final AxField field, final String direction,
- AxValidationResult result) {
- if (field == null) {
- result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "null " + direction + " field value found on " + direction + " field " + fieldKey));
- } else {
- if (!field.getKey().getParentArtifactKey().equals(key)) {
- result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "parent key on " + direction + " field " + fieldKey + DOES_NOT_EQUAL_TASK_KEY));
- }
-
- result = field.validate(result);
- }
-
- return result;
- }
-
- /**
* Validate a task parameter entry.
*
* @param taskParameterEntry the task parameter entry to validate
* @param result The validation result to append to
* @return The result of the validation
*/
- private AxValidationResult vaildateTaskParameterEntry(final Entry<String, AxTaskParameter> taskParameterEntry,
+ private AxValidationResult validateTaskParameterEntry(final Entry<String, AxTaskParameter> taskParameterEntry,
AxValidationResult result) {
if (taskParameterEntry.getValue() == null) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
@@ -537,7 +429,7 @@ public class AxTask extends AxConcept {
* @param result The validation result to append to
* @return The result of the validation
*/
- private AxValidationResult vaildateContextAlbumReference(final AxArtifactKey contextAlbumReference,
+ private AxValidationResult validateContextAlbumReference(final AxArtifactKey contextAlbumReference,
AxValidationResult result) {
if (contextAlbumReference.equals(AxArtifactKey.getNullKey())) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalyser.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalyser.java
index 4d076cfda..3a4c36bc5 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalyser.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalyser.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
@@ -137,7 +138,7 @@ public class PolicyAnalyser {
// Event usage by state
result.getEventUsage().get(state.getTrigger()).add(state.getKey());
for (final AxStateOutput stateOutput : state.getStateOutputs().values()) {
- result.getEventUsage().get(stateOutput.getOutgingEvent()).add(state.getKey());
+ result.getEventUsage().get(stateOutput.getOutgoingEvent()).add(state.getKey());
}
// State Context Usage