aboutsummaryrefslogtreecommitdiffstats
path: root/model
diff options
context:
space:
mode:
authora.sreekumar <ajith.sreekumar@bell.ca>2021-06-29 13:57:14 +0100
committera.sreekumar <ajith.sreekumar@bell.ca>2021-07-02 16:03:51 +0100
commit5f0ec1c2d95c377fbec428f11464e93fe442b5ef (patch)
tree4aef07097fa4d64550db116a1b1b4acd1aa42590 /model
parentba55109db1e5eea013dcffd1be29cf06fe2bbcb1 (diff)
Cleanup input & outputFields from Task definition
1) Remove the usage of inputField and outputField from Task definition. 2) Fix issues around populating events to task in case of State Finalizer Logic. Change-Id: Ief17f400729410b83c6b7c665980d443e0cf6f28 Issue-ID: POLICY-3336 Signed-off-by: a.sreekumar <ajith.sreekumar@bell.ca>
Diffstat (limited to 'model')
-rw-r--r--model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexEditorApi.java61
-rw-r--r--model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ApexModelImpl.java48
-rw-r--r--model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/PolicyFacade.java17
-rw-r--r--model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/TaskFacade.java276
-rw-r--r--model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiTaskTest.java122
-rw-r--r--model/model-api/src/test/resources/models/PolicyModel.xml64
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicyModel.java39
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTask.java165
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalyser.java10
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PolicyModelTest.java38
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TasksTest.java61
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java15
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalyserTest.java5
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/SupportApexPolicyModelCreator.java58
-rw-r--r--model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseValues.txt2
-rw-r--r--model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonIdenticalVerboseValues.txt3
16 files changed, 57 insertions, 927 deletions
diff --git a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexEditorApi.java b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexEditorApi.java
index 741fbdc90..fab6ba163 100644
--- a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexEditorApi.java
+++ b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexEditorApi.java
@@ -1,19 +1,20 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. 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.
* 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=========================================================
*/
@@ -456,7 +457,7 @@ public interface ApexEditorApi {
ApexApiResult deleteTaskLogic(final String name, final String version);
/**
- * Create a task input field.
+ * Create a task field.
*
* @param name name of the task
* @param version version of the task, set to null to use the latest version
@@ -467,11 +468,11 @@ public interface ApexEditorApi {
* @param optional true if the task field is optional, false otherwise
* @return result of the operation
*/
- ApexApiResult createTaskInputField(final String name, final String version, final String fieldName,
+ ApexApiResult createTaskField(final String name, final String version, final String fieldName,
final String contextSchemaName, final String contextSchemaVersion, boolean optional);
/**
- * List task input fields.
+ * Handle a task field.
*
* @param name name of the task
* @param version version of the task, set to null to use the latest version
@@ -479,53 +480,7 @@ public interface ApexEditorApi {
* task
* @return result of the operation
*/
- ApexApiResult listTaskInputField(final String name, final String version, final String fieldName);
-
- /**
- * Delete a task input field.
- *
- * @param name name of the task
- * @param version version of the task, set to null to use the latest version
- * @param fieldName of the input field, set to null to delete all input fields
- * @return result of the operation
- */
- ApexApiResult deleteTaskInputField(final String name, final String version, final String fieldName);
-
- /**
- * Create a task output field.
- *
- * @param name name of the task
- * @param version version of the task, set to null to use the latest version
- * @param fieldName of the output field
- * @param contextSchemaName name of the output field context schema
- * @param contextSchemaVersion version of the output field context schema, set to null to use
- * the latest version
- * @param optional true if the task field is optional, false otherwise
- * @return result of the operation
- */
- ApexApiResult createTaskOutputField(final String name, final String version, final String fieldName,
- final String contextSchemaName, final String contextSchemaVersion, boolean optional);
-
- /**
- * List task output fields.
- *
- * @param name name of the task
- * @param version version of the task, set to null to use the latest version
- * @param fieldName field name of the output field, set to null to list all output fields of the
- * task
- * @return result of the operation
- */
- ApexApiResult listTaskOutputField(final String name, final String version, final String fieldName);
-
- /**
- * Delete a task output field.
- *
- * @param name name of the task
- * @param version version of the task, set to null to use the latest version
- * @param fieldName of the output field, set to null to delete all output fields
- * @return result of the operation
- */
- ApexApiResult deleteTaskOutputField(final String name, final String version, final String fieldName);
+ ApexApiResult handleTaskField(final String name, final String version, final String fieldName);
/**
* Create a task parameter.
diff --git a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ApexModelImpl.java b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ApexModelImpl.java
index 5e8d1a5c7..67083bfe8 100644
--- a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ApexModelImpl.java
+++ b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ApexModelImpl.java
@@ -26,6 +26,7 @@ package org.onap.policy.apex.model.modelapi.impl;
import java.util.Properties;
import org.onap.policy.apex.model.basicmodel.dao.DaoParameters;
import org.onap.policy.apex.model.modelapi.ApexApiResult;
+import org.onap.policy.apex.model.modelapi.ApexApiResult.Result;
import org.onap.policy.apex.model.modelapi.ApexModel;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
import org.slf4j.Logger;
@@ -38,7 +39,7 @@ import org.slf4j.LoggerFactory;
*/
public final class ApexModelImpl implements ApexModel {
- private static final String FIELDS_DEPRECATED_WARN_MSG =
+ public static final String FIELDS_DEPRECATED_WARN_MSG =
"inputFields and outputFields are deprecated from Task definition and will be removed. "
+ "Instead, inputEvent and outputEvents are automatically populated to Tasks based on State definition";
@@ -444,56 +445,19 @@ public final class ApexModelImpl implements ApexModel {
* {@inheritDoc}.
*/
@Override
- public ApexApiResult createTaskInputField(final String name, final String version, final String fieldName,
+ public ApexApiResult createTaskField(final String name, final String version, final String fieldName,
final String dataTypeName, final String dataTypeVersion, final boolean optional) {
LOGGER.warn(FIELDS_DEPRECATED_WARN_MSG);
- return taskFacade.createTaskInputField(name, version, fieldName, dataTypeName, dataTypeVersion, optional);
+ return new ApexApiResult(Result.SUCCESS, FIELDS_DEPRECATED_WARN_MSG);
}
/**
* {@inheritDoc}.
*/
@Override
- public ApexApiResult listTaskInputField(final String name, final String version, final String fieldName) {
+ public ApexApiResult handleTaskField(final String name, final String version, final String fieldName) {
LOGGER.warn(FIELDS_DEPRECATED_WARN_MSG);
- return taskFacade.listTaskInputField(name, version, fieldName);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public ApexApiResult deleteTaskInputField(final String name, final String version, final String fieldName) {
- LOGGER.warn(FIELDS_DEPRECATED_WARN_MSG);
- return taskFacade.deleteTaskInputField(name, version, fieldName);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public ApexApiResult createTaskOutputField(final String name, final String version, final String fieldName,
- final String dataTypeName, final String dataTypeVersion, final boolean optional) {
- LOGGER.warn(FIELDS_DEPRECATED_WARN_MSG);
- return taskFacade.createTaskOutputField(name, version, fieldName, dataTypeName, dataTypeVersion, optional);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public ApexApiResult listTaskOutputField(final String name, final String version, final String fieldName) {
- LOGGER.warn(FIELDS_DEPRECATED_WARN_MSG);
- return taskFacade.listTaskOutputField(name, version, fieldName);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public ApexApiResult deleteTaskOutputField(final String name, final String version, final String fieldName) {
- LOGGER.warn(FIELDS_DEPRECATED_WARN_MSG);
- return taskFacade.deleteTaskOutputField(name, version, fieldName);
+ return new ApexApiResult(Result.SUCCESS, FIELDS_DEPRECATED_WARN_MSG);
}
/**
diff --git a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/PolicyFacade.java b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/PolicyFacade.java
index 9480702ac..c36e7e8a5 100644
--- a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/PolicyFacade.java
+++ b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/PolicyFacade.java
@@ -1112,10 +1112,17 @@ public class PolicyFacade {
ApexApiResult.Result.FAILED, "output type " + builder.getOutputType() + " invalid");
}
+ String outputRefName = outputRefKey.getLocalName();
+ // in case of SFL, outgoing event will be same for all state outputs that are part of SFL.So, take any entry
+ if (AxStateTaskOutputType.LOGIC.equals(stateTaskOutputType)) {
+ outputRefName = state.getStateOutputs().keySet().iterator().next();
+ }
+
// add input and output events to the task based on state definition
- if (state.getStateOutputs().containsKey(outputRefKey.getLocalName())) {
- populateIoEventsToTask(state, task, outputRefKey);
+ if (state.getStateOutputs().containsKey(outputRefName)) {
+ populateIoEventsToTask(state, task, outputRefName);
}
+
state.getTaskReferences().put(task.getKey(),
new AxStateTaskReference(refKey, stateTaskOutputType, outputRefKey));
return new ApexApiResult();
@@ -1124,18 +1131,18 @@ public class PolicyFacade {
}
}
- private void populateIoEventsToTask(final AxState state, final AxTask task, final AxReferenceKey outputRefKey) {
+ private void populateIoEventsToTask(final AxState state, final AxTask task, final String outputRefName) {
AxEvent triggerEvent = apexModel.getPolicyModel().getEvents().get(state.getTrigger());
task.setInputEvent(triggerEvent);
Map<String, AxEvent> outputEvents = new TreeMap<>();
if (state.getNextStateSet().isEmpty()
|| state.getNextStateSet().contains(AxReferenceKey.getNullKey().getLocalName())) {
- state.getStateOutputs().get(outputRefKey.getLocalName()).getOutgoingEventSet()
+ state.getStateOutputs().get(outputRefName).getOutgoingEventSet()
.forEach(outgoingEventKey -> outputEvents.put(outgoingEventKey.getName(),
apexModel.getPolicyModel().getEvents().get(outgoingEventKey)));
} else {
AxArtifactKey outgoingEventKey =
- state.getStateOutputs().get(outputRefKey.getLocalName()).getOutgoingEvent();
+ state.getStateOutputs().get(outputRefName).getOutgoingEvent();
outputEvents.put(outgoingEventKey.getName(),
apexModel.getPolicyModel().getEvents().get(outgoingEventKey));
}
diff --git a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/TaskFacade.java b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/TaskFacade.java
index a6f4a87cb..ad1edd72e 100644
--- a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/TaskFacade.java
+++ b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/TaskFacade.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.
@@ -30,9 +31,6 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelStringWriter;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum;
-import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
-import org.onap.policy.apex.model.eventmodel.concepts.AxInputField;
-import org.onap.policy.apex.model.eventmodel.concepts.AxOutputField;
import org.onap.policy.apex.model.modelapi.ApexApiResult;
import org.onap.policy.apex.model.modelapi.ApexModel;
import org.onap.policy.apex.model.policymodel.concepts.AxTask;
@@ -356,278 +354,6 @@ public class TaskFacade {
}
/**
- * Create a task input field.
- *
- * @param name name of the task
- * @param version version of the task, set to null to use the latest version
- * @param fieldName of the input field
- * @param contextSchemaName name of the input field context schema
- * @param contextSchemaVersion version of the input field context schema, set to null to use the
- * latest version
- * @param optional true if the task field is optional, false otherwise
- * @return result of the operation
- */
- public ApexApiResult createTaskInputField(final String name, final String version, final String fieldName,
- final String contextSchemaName, final String contextSchemaVersion, final boolean optional) {
- try {
- Assertions.argumentNotNull(fieldName, "fieldName may not be null");
-
- final AxTask task = apexModel.getPolicyModel().getTasks().get(name, version);
- if (task == null) {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
- }
-
- final AxReferenceKey refKey =
- new AxReferenceKey(task.getKey().getName(), task.getKey().getVersion(), "inputFields", fieldName);
-
- if (task.getInputFields().containsKey(refKey.getLocalName())) {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_EXISTS,
- CONCEPT + refKey.getId() + ALREADY_EXISTS);
- }
-
- final AxContextSchema schema =
- apexModel.getPolicyModel().getSchemas().get(contextSchemaName, contextSchemaVersion);
- if (schema == null) {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + contextSchemaName + ':' + contextSchemaVersion + DOES_NOT_EXIST);
- }
-
- task.getInputFields().put(refKey.getLocalName(), new AxInputField(refKey, schema.getKey(), optional));
- return new ApexApiResult();
- } catch (final Exception e) {
- return new ApexApiResult(ApexApiResult.Result.FAILED, e);
- }
- }
-
- /**
- * List task input fields.
- *
- * @param name name of the task
- * @param version version of the task, set to null to use the latest version
- * @param fieldName field name of the input field, set to null to list all input fields of the
- * task
- * @return result of the operation
- */
- public ApexApiResult listTaskInputField(final String name, final String version, final String fieldName) {
- try {
- final AxTask task = apexModel.getPolicyModel().getTasks().get(name, version);
- if (task == null) {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
- }
-
- if (fieldName != null) {
- final AxInputField inputField = task.getInputFields().get(fieldName);
- if (inputField != null) {
- return new ApexApiResult(ApexApiResult.Result.SUCCESS,
- new ApexModelStringWriter<AxInputField>(false).writeString(inputField, AxInputField.class,
- jsonMode));
- } else {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + ':' + inputField + DOES_NOT_EXIST);
- }
- } else {
- if (task.getInputFields().size() == 0) {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- "no input fields defined on task " + task.getKey().getId());
- }
-
- final ApexApiResult result = new ApexApiResult();
- for (final AxInputField field : task.getInputFields().values()) {
- result.addMessage(new ApexModelStringWriter<AxInputField>(false).writeString(field,
- AxInputField.class, jsonMode));
- }
- return result;
- }
- } catch (final Exception e) {
- return new ApexApiResult(ApexApiResult.Result.FAILED, e);
- }
-
- }
-
- /**
- * Delete a task input field.
- *
- * @param name name of the task
- * @param version version of the task, set to null to use the latest version
- * @param fieldName of the input field, set to null to delete all input fields
- * @return result of the operation
- */
- public ApexApiResult deleteTaskInputField(final String name, final String version, final String fieldName) {
- try {
- final AxTask task = apexModel.getPolicyModel().getTasks().get(name, version);
- if (task == null) {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
- }
-
- final ApexApiResult result = new ApexApiResult();
- if (fieldName != null) {
- if (task.getInputFields().containsKey(fieldName)) {
- result.addMessage(new ApexModelStringWriter<AxInputField>(false)
- .writeString(task.getInputFields().get(fieldName), AxInputField.class, jsonMode));
- task.getInputFields().remove(fieldName);
- return result;
- } else {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + ':' + fieldName + DOES_NOT_EXIST);
- }
- } else {
- if (task.getInputFields().size() == 0) {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- "no input fields defined on task " + task.getKey().getId());
- }
-
- for (final AxInputField field : task.getInputFields().values()) {
- result.addMessage(new ApexModelStringWriter<AxInputField>(false).writeString(field,
- AxInputField.class, jsonMode));
- }
- task.getInputFields().clear();
- return result;
- }
- } catch (final Exception e) {
- return new ApexApiResult(ApexApiResult.Result.FAILED, e);
- }
-
- }
-
- /**
- * Create a task output field.
- *
- * @param name name of the task
- * @param version version of the task, set to null to use the latest version
- * @param fieldName of the output field
- * @param contextSchemaName name of the output field context schema
- * @param contextSchemaVersion version of the output field context schema, set to null to use
- * the latest version
- * @param optional true if the task field is optional, false otherwise
- * @return result of the operation
- */
- public ApexApiResult createTaskOutputField(final String name, final String version, final String fieldName,
- final String contextSchemaName, final String contextSchemaVersion, final boolean optional) {
- try {
- Assertions.argumentNotNull(fieldName, "fieldName may not be null");
-
- final AxTask task = apexModel.getPolicyModel().getTasks().get(name, version);
- if (task == null) {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
- }
-
- final AxReferenceKey refKey =
- new AxReferenceKey(task.getKey().getName(), task.getKey().getVersion(), "outputFields", fieldName);
-
- if (task.getOutputFields().containsKey(refKey.getLocalName())) {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_EXISTS,
- CONCEPT + refKey.getId() + ALREADY_EXISTS);
- }
-
- final AxContextSchema schema =
- apexModel.getPolicyModel().getSchemas().get(contextSchemaName, contextSchemaVersion);
- if (schema == null) {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + contextSchemaName + ':' + contextSchemaVersion + DOES_NOT_EXIST);
- }
-
- task.getOutputFields().put(refKey.getLocalName(), new AxOutputField(refKey, schema.getKey(), optional));
- return new ApexApiResult();
- } catch (final Exception e) {
- return new ApexApiResult(ApexApiResult.Result.FAILED, e);
- }
- }
-
- /**
- * List task output fields.
- *
- * @param name name of the task
- * @param version version of the task, set to null to use the latest version
- * @param fieldName field name of the output field, set to null to list all output fields of the
- * task
- * @return result of the operation
- */
- public ApexApiResult listTaskOutputField(final String name, final String version, final String fieldName) {
- try {
- final AxTask task = apexModel.getPolicyModel().getTasks().get(name, version);
- if (task == null) {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
- }
-
- if (fieldName != null) {
- final AxOutputField outputField = task.getOutputFields().get(fieldName);
- if (outputField != null) {
- return new ApexApiResult(ApexApiResult.Result.SUCCESS,
- new ApexModelStringWriter<AxOutputField>(false).writeString(outputField,
- AxOutputField.class, jsonMode));
- } else {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + ':' + outputField + DOES_NOT_EXIST);
- }
- } else {
- if (task.getOutputFields().size() == 0) {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- "no output fields defined on task " + task.getKey().getId());
- }
-
- final ApexApiResult result = new ApexApiResult();
- for (final AxOutputField field : task.getOutputFields().values()) {
- result.addMessage(new ApexModelStringWriter<AxOutputField>(false).writeString(field,
- AxOutputField.class, jsonMode));
- }
- return result;
- }
- } catch (final Exception e) {
- return new ApexApiResult(ApexApiResult.Result.FAILED, e);
- }
- }
-
- /**
- * Delete a task output field.
- *
- * @param name name of the task
- * @param version version of the task, set to null to use the latest version
- * @param fieldName of the output field, set to null to delete all output fields
- * @return result of the operation
- */
- public ApexApiResult deleteTaskOutputField(final String name, final String version, final String fieldName) {
- try {
- final AxTask task = apexModel.getPolicyModel().getTasks().get(name, version);
- if (task == null) {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
- }
-
- final ApexApiResult result = new ApexApiResult();
- if (fieldName != null) {
- if (task.getOutputFields().containsKey(fieldName)) {
- result.addMessage(new ApexModelStringWriter<AxOutputField>(false)
- .writeString(task.getOutputFields().get(fieldName), AxOutputField.class, jsonMode));
- task.getOutputFields().remove(fieldName);
- return result;
- } else {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + ':' + fieldName + DOES_NOT_EXIST);
- }
- } else {
- if (task.getOutputFields().size() == 0) {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- "no output fields defined on task " + task.getKey().getId());
- }
-
- for (final AxOutputField field : task.getOutputFields().values()) {
- result.addMessage(new ApexModelStringWriter<AxOutputField>(false).writeString(field,
- AxOutputField.class, jsonMode));
- }
- task.getOutputFields().clear();
- return result;
- }
- } catch (final Exception e) {
- return new ApexApiResult(ApexApiResult.Result.FAILED, e);
- }
- }
-
- /**
* Create a task parameter.
*
* @param name name of the task
diff --git a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiTaskTest.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiTaskTest.java
index f2c41318c..026f67c29 100644
--- a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiTaskTest.java
+++ b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiTaskTest.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 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.
@@ -24,6 +25,7 @@ package org.onap.policy.apex.model.modelapi;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
+import org.onap.policy.apex.model.modelapi.impl.ApexModelImpl;
/**
* Test tasks for API tests.
@@ -214,124 +216,12 @@ public class ApexEditorApiTaskTest {
result = apexModel.deleteTaskLogic("MyTask002", "0.0.2");
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
- result = apexModel.createTaskInputField("MyTask123", null, "NewField00", null, null, false);
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
-
- result = apexModel.createTaskInputField("MyTask002", "4.5.6", "NewField00", null, null, true);
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
-
- result = apexModel.createTaskInputField("MyTask002", "0.1.4", "NewField00", null, null, false);
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
-
- result = apexModel.createTaskInputField("MyTask002", "0.0.2", "NewField00", null, null, true);
- assertEquals(ApexApiResult.Result.FAILED, result.getResult());
-
- result = apexModel.createTaskInputField("MyTask002", "0.0.2", "NewField00", "eventContextItem0", null, false);
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.createTaskInputField("MyTask002", "0.0.2", "NewField00", "eventContextItem0", null, true);
- assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult());
- result = apexModel.createTaskInputField("MyTask002", "0.0.2", "NewField01", "eventContextItem0", "0.0.1",
- false);
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.createTaskInputField("MyTask002", "0.0.2", "NewField02", "eventContextItem0", "0.0.2", true);
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
- result = apexModel.createTaskInputField("MyTask002", null, "NewField02", "eventContextItem0", null, false);
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.createTaskInputField("MyTask002", null, "NewField03", "eventContextItem0", null, true);
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
-
- result = apexModel.listTaskInputField("@£$%", null, null);
- assertEquals(ApexApiResult.Result.FAILED, result.getResult());
- result = apexModel.listTaskInputField("MyTask002", null, null);
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.listTaskInputField("MyTask002", "0.0.1", null);
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
- result = apexModel.listTaskInputField("MyTask002", "0.0.2", null);
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.listTaskInputField("MyTask002", "0.0.2", "NewField01");
+ result = apexModel.createTaskField("MyTask002", "0.0.2", "NewField00", "eventContextItem0", null, false);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.listTaskInputField("MyTask002", "0.0.2", "NewField02");
+ assertEquals(ApexModelImpl.FIELDS_DEPRECATED_WARN_MSG, result.getMessage().trim());
+ result = apexModel.handleTaskField("MyTask002", "0.0.2", "NewField01");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.listTaskInputField("MyTask002", "0.0.2", "NewField04");
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
-
- result = apexModel.deleteTaskInputField("@£$%", "0.0.2", "NewField04");
- assertEquals(ApexApiResult.Result.FAILED, result.getResult());
- result = apexModel.deleteTaskInputField("NonExistantTask", "0.0.2", "NewField04");
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
- assertEquals(4, apexModel.listTaskInputField("MyTask002", null, null).getMessages().size());
- result = apexModel.deleteTaskInputField("MyTask002", "0.0.2", "NewField04");
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
- assertEquals(4, apexModel.listTaskInputField("MyTask002", null, null).getMessages().size());
- result = apexModel.deleteTaskInputField("MyTask002", null, "NewField02");
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- assertEquals(3, apexModel.listTaskInputField("MyTask002", null, null).getMessages().size());
- result = apexModel.deleteTaskInputField("MyTask002", null, null);
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.listTaskInputField("MyTask002", null, null);
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
- result = apexModel.deleteTaskInputField("MyTask002", null, null);
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
-
- result = apexModel.createTaskOutputField("MyTask123", null, "NewField00", null, null, false);
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
-
- result = apexModel.createTaskOutputField("MyTask002", "4.5.6", "NewField00", null, null, false);
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
-
- result = apexModel.createTaskOutputField("MyTask002", "0.1.4", "NewField00", null, null, false);
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
-
- result = apexModel.createTaskOutputField("MyTask002", "0.0.2", "NewField00", null, null, false);
- assertEquals(ApexApiResult.Result.FAILED, result.getResult());
-
- result = apexModel.createTaskOutputField("MyTask002", "0.0.2", "NewField00", "eventContextItem0", null, false);
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.createTaskOutputField("MyTask002", "0.0.2", "NewField00", "eventContextItem0", null, false);
- assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult());
- result = apexModel.createTaskOutputField("MyTask002", "0.0.2", "NewField01", "eventContextItem0", "0.0.1",
- false);
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.createTaskOutputField("MyTask002", "0.0.2", "NewField02", "eventContextItem0", "0.0.2",
- false);
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
- result = apexModel.createTaskOutputField("MyTask002", null, "NewField02", "eventContextItem0", null, false);
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.createTaskOutputField("MyTask002", null, "NewField03", "eventContextItem0", null, false);
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
-
- result = apexModel.listTaskOutputField("@£$%", null, null);
- assertEquals(ApexApiResult.Result.FAILED, result.getResult());
- result = apexModel.listTaskOutputField("MyTask002", null, null);
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.listTaskOutputField("MyTask002", "0.0.1", null);
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
- result = apexModel.listTaskOutputField("MyTask002", "0.0.2", null);
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.listTaskOutputField("MyTask002", "0.0.2", "NewField01");
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.listTaskOutputField("MyTask002", "0.0.2", "NewField02");
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.listTaskOutputField("MyTask002", "0.0.2", "NewField04");
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
-
- result = apexModel.deleteTaskOutputField("@£$%", "0.0.2", "NewField04");
- assertEquals(ApexApiResult.Result.FAILED, result.getResult());
- result = apexModel.deleteTaskOutputField("NonExistantTask", "0.0.2", "NewField04");
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
- assertEquals(4, apexModel.listTaskOutputField("MyTask002", null, null).getMessages().size());
- result = apexModel.deleteTaskOutputField("MyTask002", "0.0.2", "NewField04");
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
- assertEquals(4, apexModel.listTaskOutputField("MyTask002", null, null).getMessages().size());
- result = apexModel.deleteTaskOutputField("MyTask002", null, "NewField02");
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- assertEquals(3, apexModel.listTaskOutputField("MyTask002", null, null).getMessages().size());
- result = apexModel.deleteTaskOutputField("MyTask002", null, null);
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.listTaskOutputField("MyTask002", null, null);
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
- result = apexModel.deleteTaskOutputField("MyTask002", null, null);
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
+ assertEquals(ApexModelImpl.FIELDS_DEPRECATED_WARN_MSG, result.getMessage().trim());
result = apexModel.createTaskParameter("MyTask123", null, "NewPar00", null);
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
diff --git a/model/model-api/src/test/resources/models/PolicyModel.xml b/model/model-api/src/test/resources/models/PolicyModel.xml
index e3bf59f29..e47e21afc 100644
--- a/model/model-api/src/test/resources/models/PolicyModel.xml
+++ b/model/model-api/src/test/resources/models/PolicyModel.xml
@@ -402,70 +402,6 @@
<name>task</name>
<version>0.0.1</version>
</key>
- <inputFields>
- <entry>
- <key>IEPAR0</key>
- <value>
- <key>IEPAR0</key>
- <fieldSchemaKey>
- <name>eventContextItem0</name>
- <version>0.0.1</version>
- </fieldSchemaKey>
- </value>
- </entry>
- <entry>
- <key>IEPAR1</key>
- <value>
- <key>IEPAR1</key>
- <fieldSchemaKey>
- <name>eventContextItem1</name>
- <version>0.0.1</version>
- </fieldSchemaKey>
- </value>
- </entry>
- </inputFields>
- <outputFields>
- <entry>
- <key>OE0PAR0</key>
- <value>
- <key>OE0PAR0</key>
- <fieldSchemaKey>
- <name>eventContextItem0</name>
- <version>0.0.1</version>
- </fieldSchemaKey>
- </value>
- </entry>
- <entry>
- <key>OE0PAR1</key>
- <value>
- <key>OE0PAR1</key>
- <fieldSchemaKey>
- <name>eventContextItem1</name>
- <version>0.0.1</version>
- </fieldSchemaKey>
- </value>
- </entry>
- <entry>
- <key>OE1PAR0</key>
- <value>
- <key>OE1PAR0</key>
- <fieldSchemaKey>
- <name>eventContextItem0</name>
- <version>0.0.1</version>
- </fieldSchemaKey>
- </value>
- </entry>
- <entry>
- <key>OE1PAR1</key>
- <value>
- <key>OE1PAR1</key>
- <fieldSchemaKey>
- <name>eventContextItem1</name>
- <version>0.0.1</version>
- </fieldSchemaKey>
- </value>
- </entry>
- </outputFields>
<taskParameters>
<entry>
<key>taskParameter0</key>
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 4ee176d97..aec144a46 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
@@ -25,8 +25,6 @@ package org.onap.policy.apex.model.policymodel.concepts;
import java.util.List;
import java.util.Map.Entry;
-import java.util.Set;
-import java.util.TreeSet;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
@@ -45,7 +43,6 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation;
import org.onap.policy.apex.model.basicmodel.concepts.AxModel;
-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;
@@ -425,19 +422,6 @@ public class AxPolicyModel extends AxModel {
* @return the result
*/
private AxValidationResult validateTaskKeys(final AxTask task, AxValidationResult result) {
- for (final AxField field : task.getInputFieldSet()) {
- if (getSchemas().get(field.getSchema()) == null) {
- result.addValidationMessage(new AxValidationMessage(task.getKey(), this.getClass(),
- ValidationResult.INVALID, "task input field schema " + field.getSchema().getId() + DOES_NOT_EXIST));
- }
- }
- for (final AxField field : task.getOutputFieldSet()) {
- if (getSchemas().get(field.getSchema()) == null) {
- result.addValidationMessage(
- new AxValidationMessage(task.getKey(), this.getClass(), ValidationResult.INVALID,
- "task output field schema " + field.getSchema().getId() + DOES_NOT_EXIST));
- }
- }
for (final AxArtifactKey contextAlbumKey : task.getContextAlbumReferences()) {
if (albums.get(contextAlbumKey) == null) {
result.addValidationMessage(new AxValidationMessage(task.getKey(), this.getClass(),
@@ -489,19 +473,6 @@ public class AxPolicyModel extends AxModel {
ValidationResult.INVALID, "state default task " + state.getDefaultTask().getId() + DOES_NOT_EXIST));
}
- // Check task input fields and event fields are compatible for default tasks with no task
- // selection logic
- if (state.getTaskSelectionLogic().getKey().equals(AxReferenceKey.getNullKey())
- && triggerEvent != null && defaultTask != null) {
- final Set<AxField> unhandledTaskInputFields = new TreeSet<>(defaultTask.getInputFieldSet());
- unhandledTaskInputFields.removeAll(triggerEvent.getFields());
- for (final AxField unhandledTaskInputField : unhandledTaskInputFields) {
- result.addValidationMessage(new AxValidationMessage(state.getKey(), this.getClass(),
- ValidationResult.INVALID, "task input field " + unhandledTaskInputField + " for task "
- + defaultTask.getId() + " not in trigger event " + triggerEvent.getId()));
- }
- }
-
for (final AxStateOutput stateOutput : state.getStateOutputs().values()) {
if (events.getEventMap().get(stateOutput.getOutgoingEvent()) == null) {
result.addValidationMessage(new AxValidationMessage(stateOutput.getKey(), this.getClass(),
@@ -562,16 +533,6 @@ public class AxPolicyModel extends AxModel {
ValidationResult.INVALID, "output event " + stateOutput.getOutgoingEvent().getId()
+ " for state output " + stateOutput.getId() + DOES_NOT_EXIST));
}
-
- if (task != null && usedEvent != null) {
- final Set<AxField> unhandledTaskOutputFields = new TreeSet<>(task.getOutputFieldSet());
- unhandledTaskOutputFields.removeAll(usedEvent.getFields());
- for (final AxField unhandledTaskOutputField : unhandledTaskOutputFields) {
- result.addValidationMessage(new AxValidationMessage(state.getKey(), this.getClass(),
- ValidationResult.INVALID, "task output field " + unhandledTaskOutputField + " for task "
- + task.getId() + " not in output event " + usedEvent.getId()));
- }
- }
}
}
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 a30a80acc..7eba99af0 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
@@ -56,9 +56,6 @@ 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;
import org.onap.policy.common.utils.validation.Assertions;
/**
@@ -78,12 +75,6 @@ import org.onap.policy.common.utils.validation.Assertions;
* <ol>
* <li>The task key must not be a null key and must be valid, see validation in
* {@link AxArtifactKey}
- * <li>The task must have at least one input field
- * <li>The parent of each input field of a task must be that task
- * <li>Each input field must be valid, see validation in {@link AxInputField}
- * <li>The task must have at least one output field
- * <li>The parent of each output field of a task must be that task
- * <li>Each output field must be valid, see validation in {@link AxOutputField}
* <li>The parent of each task parameter of a task must be that task
* <li>Each task parameter must be valid, see validation in {@link AxTaskParameter}
* <li>The parent of the task logic in a task must be that task
@@ -99,7 +90,7 @@ import org.onap.policy.common.utils.validation.Assertions;
@XmlType(
name = "AxTask",
namespace = "http://www.onap.org/policy/apex-pdp",
- propOrder = {"key", "inputEvent", "outputEvents", "inputFields", "outputFields", "taskParameters",
+ propOrder = {"key", "inputEvent", "outputEvents", "taskParameters",
"contextAlbumReferenceSet", "taskLogic"})
@Getter
@Setter
@@ -130,14 +121,6 @@ public class AxTask extends AxConcept {
private Map<String, AxEvent> outputEvents;
@OneToMany(cascade = CascadeType.ALL)
- @XmlElement(name = "inputFields", required = true)
- private Map<String, AxInputField> inputFields;
-
- @OneToMany(cascade = CascadeType.ALL)
- @XmlElement(name = "outputFields", required = true)
- private Map<String, AxOutputField> outputFields;
-
- @OneToMany(cascade = CascadeType.ALL)
@XmlElement(name = "taskParameters", required = true)
private Map<String, AxTaskParameter> taskParameters;
@@ -181,8 +164,6 @@ public class AxTask extends AxConcept {
*/
public AxTask(final AxArtifactKey key) {
this(key, // Task Key
- new TreeMap<>(), // Input fields
- new TreeMap<>(), // Output Fields
new TreeMap<>(), // Task Parameters
new TreeSet<>(), // Context Album References
new AxTaskLogic(new AxReferenceKey(key)) // Task Logic
@@ -193,27 +174,20 @@ public class AxTask extends AxConcept {
* This Constructor defines all the fields of the task.
*
* @param key the key of the task
- * @param inputFields the input fields that the task expects
- * @param outputFields the output fields that the task emits
* @param taskParameters the task parameters that are used to initialize tasks of this type
* @param contextAlbumReferenceSet the context album reference set defines the context that may
* be used by Task Logic in the state
* @param taskLogic the task logic that performs the domain specific work of the task
*/
- public AxTask(final AxArtifactKey key, final Map<String, AxInputField> inputFields,
- final Map<String, AxOutputField> outputFields, final Map<String, AxTaskParameter> taskParameters,
- final Set<AxArtifactKey> contextAlbumReferenceSet, final AxTaskLogic taskLogic) {
+ public AxTask(final AxArtifactKey key, final Map<String, AxTaskParameter> taskParameters,
+ final Set<AxArtifactKey> contextAlbumReferenceSet, final AxTaskLogic taskLogic) {
super();
Assertions.argumentNotNull(key, "key may not be null");
- Assertions.argumentNotNull(inputFields, "inputFields may not be null");
- Assertions.argumentNotNull(outputFields, "outputFields may not be null");
Assertions.argumentNotNull(taskParameters, "taskParameters may not be null");
Assertions.argumentNotNull(contextAlbumReferenceSet, "contextAlbumReferenceSet may not be null");
Assertions.argumentNotNull(taskLogic, "taskLogic may not be null");
this.key = key;
- this.inputFields = inputFields;
- this.outputFields = outputFields;
this.taskParameters = taskParameters;
this.contextAlbumReferenceSet = contextAlbumReferenceSet;
this.taskLogic = taskLogic;
@@ -222,23 +196,13 @@ public class AxTask extends AxConcept {
/**
* When a task is unmarshalled from disk or from the database, the parent of contained objects
* is not defined. This method is called by JAXB after unmarshaling and is used to set the
- * parent keys of all {@link AxInputField}, {@link AxOutputField}, and {@link AxTaskParameter}
- * instance in the task.
+ * parent keys of all {@link AxTaskParameter} instance in the task.
*
* @param unmarshaler the unmarshaler that is unmarshaling the model
* @param parent the parent object of this object in the unmarshaler
*/
public void afterUnmarshal(final Unmarshaller unmarshaler, final Object parent) {
taskLogic.getKey().setParentArtifactKey(key);
-
- for (final AxInputField inputField : inputFields.values()) {
- inputField.getKey().setParentArtifactKey(key);
- inputField.getKey().setParentLocalName("InField");
- }
- for (final AxOutputField outputField : outputFields.values()) {
- outputField.getKey().setParentArtifactKey(key);
- outputField.getKey().setParentLocalName("OutField");
- }
for (final AxTaskParameter parameter : taskParameters.values()) {
parameter.getKey().setParentArtifactKey(key);
}
@@ -250,12 +214,6 @@ public class AxTask extends AxConcept {
@Override
public List<AxKey> getKeys() {
final List<AxKey> keyList = key.getKeys();
- for (final AxInputField inputField : inputFields.values()) {
- keyList.addAll(inputField.getKeys());
- }
- for (final AxOutputField outputField : outputFields.values()) {
- keyList.addAll(outputField.getKeys());
- }
for (final AxTaskParameter taskParameter : taskParameters.values()) {
keyList.addAll(taskParameter.getKeys());
}
@@ -267,85 +225,6 @@ public class AxTask extends AxConcept {
}
/**
- * Gets the raw input fields that the task expects as a tree map.
- *
- * @return the raw input fields that the task expects
- */
- public Map<String, AxField> getRawInputFields() {
- return new TreeMap<>(inputFields);
- }
-
- /**
- * Convenience method to get the input fields as a set.
- *
- * @return the input fields as a set
- */
- public Set<AxField> getInputFieldSet() {
- final Set<AxField> inputFieldSet = new TreeSet<>();
- for (final AxInputField field : inputFields.values()) {
- inputFieldSet.add(field);
- }
- return inputFieldSet;
- }
-
- /**
- * 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.
- *
- * @param fields the fields to copy into the task
- */
- public void duplicateInputFields(final Map<String, AxField> fields) {
- Assertions.argumentNotNull(fields, "fields may not be null");
-
- for (final AxField field : fields.values()) {
- final AxReferenceKey fieldKey = new AxReferenceKey(this.getKey().getName(), this.getKey().getVersion(),
- "inputFields", field.getKey().getLocalName());
- final AxInputField inputField = new AxInputField(fieldKey, field.getSchema());
- inputFields.put(inputField.getKey().getLocalName(), inputField);
- }
- }
-
- /**
- * Gets the raw output fields that the task emits as a tree map.
- *
- * @return the raw output fields as a tree map
- */
- public Map<String, AxField> getRawOutputFields() {
- return new TreeMap<>(outputFields);
- }
-
- /**
- * Gets the output fields that the task emits as a set.
- *
- * @return the output fields as a set
- */
- public Set<AxField> getOutputFieldSet() {
- final Set<AxField> outputFieldSet = new TreeSet<>();
- for (final AxOutputField field : outputFields.values()) {
- outputFieldSet.add(field);
- }
- return outputFieldSet;
- }
-
- /**
- * 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.
- *
- * @param fields the fields to copy into the task
- */
- public void duplicateOutputFields(final Map<String, AxField> fields) {
- Assertions.argumentNotNull(fields, "fields may not be null");
-
- for (final AxField field : fields.values()) {
- final AxReferenceKey fieldKey = new AxReferenceKey(this.getKey().getName(), this.getKey().getVersion(),
- "outputFields", field.getKey().getLocalName());
- final AxOutputField outputField = new AxOutputField(fieldKey, field.getSchema());
- outputFields.put(outputField.getKey().getLocalName(), outputField);
- }
- }
-
-
- /**
* Gets the context album reference set defines the context that may be used by Task Logic in
* the state.
*
@@ -446,12 +325,6 @@ public class AxTask extends AxConcept {
@Override
public void clean() {
key.clean();
- for (final AxInputField inputField : inputFields.values()) {
- inputField.clean();
- }
- for (final AxOutputField outputField : outputFields.values()) {
- outputField.clean();
- }
for (final AxTaskParameter parameter : taskParameters.values()) {
parameter.clean();
}
@@ -471,10 +344,6 @@ public class AxTask extends AxConcept {
builder.append(":(");
builder.append("key=");
builder.append(key);
- builder.append(",inputFields=");
- builder.append(inputFields);
- builder.append(",outputFields=");
- builder.append(outputFields);
builder.append(",taskParameters=");
builder.append(taskParameters);
builder.append(",contextAlbumReferenceSet=");
@@ -498,18 +367,6 @@ public class AxTask extends AxConcept {
final AxTask copy = ((AxTask) copyObject);
copy.setKey(key);
- final Map<String, AxInputField> newInputFields = new TreeMap<>();
- for (final Entry<String, AxInputField> inputFieldEntry : inputFields.entrySet()) {
- newInputFields.put(inputFieldEntry.getKey(), new AxInputField(inputFieldEntry.getValue()));
- }
- copy.setInputFields(newInputFields);
-
- final Map<String, AxOutputField> newOutputFields = new TreeMap<>();
- for (final Entry<String, AxOutputField> outputFieldEntry : outputFields.entrySet()) {
- newOutputFields.put(outputFieldEntry.getKey(), new AxOutputField(outputFieldEntry.getValue()));
- }
- copy.setOutputFields(newOutputFields);
-
final Map<String, AxTaskParameter> newTaskParameter = new TreeMap<>();
for (final Entry<String, AxTaskParameter> taskParameterEntry : taskParameters.entrySet()) {
newTaskParameter.put(taskParameterEntry.getKey(), new AxTaskParameter(taskParameterEntry.getValue()));
@@ -535,8 +392,6 @@ public class AxTask extends AxConcept {
final int prime = 31;
int result = 1;
result = prime * result + key.hashCode();
- result = prime * result + inputFields.hashCode();
- result = prime * result + outputFields.hashCode();
result = prime * result + taskParameters.hashCode();
result = prime * result + contextAlbumReferenceSet.hashCode();
result = prime * result + taskLogic.hashCode();
@@ -563,12 +418,6 @@ public class AxTask extends AxConcept {
if (!key.equals(other.key)) {
return false;
}
- if (!inputFields.equals(other.inputFields)) {
- return false;
- }
- if (!outputFields.equals(other.outputFields)) {
- return false;
- }
if (!taskParameters.equals(other.taskParameters)) {
return false;
}
@@ -597,12 +446,6 @@ public class AxTask extends AxConcept {
if (!key.equals(other.key)) {
return key.compareTo(other.key);
}
- if (!inputFields.equals(other.inputFields)) {
- return (inputFields.hashCode() - other.inputFields.hashCode());
- }
- if (!outputFields.equals(other.outputFields)) {
- return (outputFields.hashCode() - other.outputFields.hashCode());
- }
if (!taskParameters.equals(other.taskParameters)) {
return (taskParameters.hashCode() - other.taskParameters.hashCode());
}
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 3a4c36bc5..6731caf30 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
@@ -29,8 +29,6 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum;
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;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicy;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
import org.onap.policy.apex.model.policymodel.concepts.AxState;
@@ -163,14 +161,6 @@ public class PolicyAnalyser {
for (final AxArtifactKey contextAlbumKey : task.getContextAlbumReferences()) {
result.getContextAlbumUsage().get(contextAlbumKey).add(task.getKey());
}
-
- // Task data type usage
- for (final AxInputField inputField : task.getInputFields().values()) {
- result.getContextSchemaUsage().get(inputField.getSchema()).add(task.getKey());
- }
- for (final AxOutputField outputField : task.getOutputFields().values()) {
- result.getContextSchemaUsage().get(outputField.getSchema()).add(task.getKey());
- }
}
/**
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PolicyModelTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PolicyModelTest.java
index 48022e878..b699b5d48 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PolicyModelTest.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PolicyModelTest.java
@@ -37,8 +37,6 @@ import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
import org.onap.policy.apex.model.eventmodel.concepts.AxEvents;
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;
import org.onap.policy.apex.model.policymodel.handling.SupportApexPolicyModelCreator;
/**
@@ -183,32 +181,6 @@ public class PolicyModelTest {
result = model.validate(result);
assertEquals(ValidationResult.VALID, result.getValidationResult());
- final AxInputField badInField = new AxInputField(
- new AxReferenceKey(model.getTasks().get("task").getKey(), "BadInField"),
- new AxArtifactKey("NonExistantSchema", "0.0.1"));
- model.getTasks().get("task").getInputFields().put(badInField.getKey().getLocalName(), badInField);
- result = new AxValidationResult();
- result = model.validate(result);
- assertEquals(ValidationResult.INVALID, result.getValidationResult());
-
- model.getTasks().get("task").getInputFields().remove(badInField.getKey().getLocalName());
- result = new AxValidationResult();
- result = model.validate(result);
- assertEquals(ValidationResult.VALID, result.getValidationResult());
-
- final AxOutputField badOutField = new AxOutputField(
- new AxReferenceKey(model.getTasks().get("task").getKey(), "BadOutField"),
- new AxArtifactKey("NonExistantSchema", "0.0.1"));
- model.getTasks().get("task").getOutputFields().put(badOutField.getKey().getLocalName(), badOutField);
- result = new AxValidationResult();
- result = model.validate(result);
- assertEquals(ValidationResult.INVALID, result.getValidationResult());
-
- model.getTasks().get("task").getOutputFields().remove(badOutField.getKey().getLocalName());
- result = new AxValidationResult();
- result = model.validate(result);
- assertEquals(ValidationResult.VALID, result.getValidationResult());
-
model.getTasks().get("task").getContextAlbumReferences()
.add(new AxArtifactKey("NonExistantContextAlbum", "0.0.1"));
result = new AxValidationResult();
@@ -267,16 +239,6 @@ public class PolicyModelTest {
result = model.validate(result);
assertEquals(ValidationResult.VALID, result.getValidationResult());
- model.getTasks().get("task").getInputFields().put(badInField.getKey().getLocalName(), badInField);
- result = new AxValidationResult();
- result = model.validate(result);
- assertEquals(ValidationResult.INVALID, result.getValidationResult());
-
- model.getTasks().get("task").getInputFields().remove(badInField.getKey().getLocalName());
- result = new AxValidationResult();
- result = model.validate(result);
- assertEquals(ValidationResult.VALID, result.getValidationResult());
-
model.getPolicies().get("policy").getStateMap().get("state").setTaskSelectionLogic(savedTaskSelectionLogic);
result = new AxValidationResult();
result = model.validate(result);
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TasksTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TasksTest.java
index 95266acc8..89dc9a048 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TasksTest.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TasksTest.java
@@ -25,7 +25,6 @@ package org.onap.policy.apex.model.policymodel.concepts;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
import java.util.Map;
import java.util.TreeMap;
@@ -36,9 +35,6 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
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;
/**
* Test policy tasks.
@@ -49,19 +45,15 @@ public class TasksTest {
@Test
public void testTasks() {
- final TreeMap<String, AxInputField> ifEmptyMap = new TreeMap<>();
- final TreeMap<String, AxOutputField> ofEmptyMap = new TreeMap<>();
final TreeMap<String, AxTaskParameter> tpEmptyMap = new TreeMap<>();
final TreeSet<AxArtifactKey> ctxtEmptySet = new TreeSet<>();
- final TreeMap<String, AxInputField> ifMap = new TreeMap<>();
- final TreeMap<String, AxOutputField> ofMap = new TreeMap<>();
final TreeMap<String, AxTaskParameter> tpMap = new TreeMap<>();
final TreeSet<AxArtifactKey> ctxtSet = new TreeSet<>();
assertNotNull(new AxTask());
assertNotNull(new AxTask(new AxArtifactKey()));
- assertNotNull(new AxTask(new AxArtifactKey(), ifMap, ofMap, tpMap, ctxtSet, new AxTaskLogic()));
+ assertNotNull(new AxTask(new AxArtifactKey(), tpMap, ctxtSet, new AxTaskLogic()));
final AxTask task = new AxTask();
@@ -70,40 +62,15 @@ public class TasksTest {
assertEquals("TaskName:0.0.1", task.getKey().getId());
assertEquals("TaskName:0.0.1", task.getKeys().get(0).getId());
- final AxArtifactKey f0SchemaKey = new AxArtifactKey("FS0", "0.0.1");
-
- final AxInputField if0 = new AxInputField(new AxReferenceKey(taskKey, "IF0"), f0SchemaKey, false);
- final AxInputField if1 = new AxInputField(new AxReferenceKey(taskKey, "IF1"), f0SchemaKey, false);
- final AxOutputField of0 = new AxOutputField(new AxReferenceKey(taskKey, "OF0"), f0SchemaKey, false);
- final AxOutputField of1 = new AxOutputField(new AxReferenceKey(taskKey, "OF1"), f0SchemaKey, false);
final AxTaskParameter tp0 = new AxTaskParameter(new AxReferenceKey(taskKey, "TP0"), "DefaultValue");
final AxArtifactKey cr0 = new AxArtifactKey("ContextReference", "0.0.1");
final AxTaskLogic tl = new AxTaskLogic(taskKey, "LogicName", "LogicFlavour", "Logic");
- ifMap.put(if0.getKey().getLocalName(), if0);
- ofMap.put(of0.getKey().getLocalName(), of0);
tpMap.put(tp0.getKey().getLocalName(), tp0);
ctxtSet.add(cr0);
- task.setInputFields(ifMap);
- assertEquals(ifMap, task.getInputFields());
- assertTrue(task.getInputFieldSet().contains(if0));
- assertTrue(task.getRawInputFields().keySet().contains(if0.getKey().getLocalName()));
-
- task.setOutputFields(ofMap);
- assertEquals(ofMap, task.getOutputFields());
- assertTrue(task.getOutputFieldSet().contains(of0));
- assertTrue(task.getRawOutputFields().keySet().contains(of0.getKey().getLocalName()));
task.setInputEvent(new AxEvent());
task.setOutputEvents(Map.of("Event", new AxEvent()));
- final TreeMap<String, AxField> ifDupMap = new TreeMap<>();
- final TreeMap<String, AxField> ofDupMap = new TreeMap<>();
- ifDupMap.put(if1.getKey().getLocalName(), if1);
- ofDupMap.put(of1.getKey().getLocalName(), of1);
- task.duplicateInputFields(ifDupMap);
- task.duplicateOutputFields(ofDupMap);
- assertTrue(ifMap.containsKey("IF1"));
- assertTrue(ofMap.containsKey("OF1"));
task.setTaskParameters(tpMap);
assertEquals(tpMap, task.getTaskParameters());
@@ -188,25 +155,23 @@ public class TasksTest {
assertEquals(task, clonedTask);
assertNotNull(task);
assertNotEquals(task, (Object) "Hello");
- assertNotEquals(task, new AxTask(new AxArtifactKey(), ifMap, ofMap, tpMap, ctxtSet, tl));
- assertNotEquals(task, new AxTask(taskKey, ifEmptyMap, ofMap, tpMap, ctxtSet, tl));
- assertNotEquals(task, new AxTask(taskKey, ifMap, ofEmptyMap, tpMap, ctxtSet, tl));
- assertNotEquals(task, new AxTask(taskKey, ifMap, ofMap, tpEmptyMap, ctxtSet, tl));
- assertNotEquals(task, new AxTask(taskKey, ifMap, ofMap, tpMap, ctxtEmptySet, tl));
- assertNotEquals(task, new AxTask(taskKey, ifMap, ofMap, tpMap, ctxtSet, new AxTaskLogic()));
- assertEquals(task, new AxTask(taskKey, ifMap, ofMap, tpMap, ctxtSet, tl));
+ assertNotEquals(task, new AxTask(new AxArtifactKey(), tpMap, ctxtSet, tl));
+ assertEquals(task, new AxTask(taskKey, tpMap, ctxtSet, tl));
+ assertNotEquals(task, new AxTask(taskKey, tpEmptyMap, ctxtSet, tl));
+ assertNotEquals(task, new AxTask(taskKey, tpMap, ctxtEmptySet, tl));
+ assertNotEquals(task, new AxTask(taskKey, tpMap, ctxtSet, new AxTaskLogic()));
+ assertEquals(task, new AxTask(taskKey, tpMap, ctxtSet, tl));
assertEquals(0, task.compareTo(task));
assertEquals(0, task.compareTo(clonedTask));
assertNotEquals(0, task.compareTo(new AxArtifactKey()));
assertNotEquals(0, task.compareTo(null));
- assertNotEquals(0, task.compareTo(new AxTask(new AxArtifactKey(), ifMap, ofMap, tpMap, ctxtSet, tl)));
- assertNotEquals(0, task.compareTo(new AxTask(taskKey, ifEmptyMap, ofMap, tpMap, ctxtSet, tl)));
- assertNotEquals(0, task.compareTo(new AxTask(taskKey, ifMap, ofEmptyMap, tpMap, ctxtSet, tl)));
- assertNotEquals(0, task.compareTo(new AxTask(taskKey, ifMap, ofMap, tpEmptyMap, ctxtSet, tl)));
- assertNotEquals(0, task.compareTo(new AxTask(taskKey, ifMap, ofMap, tpMap, ctxtEmptySet, tl)));
- assertNotEquals(0, task.compareTo(new AxTask(taskKey, ifMap, ofMap, tpMap, ctxtSet, new AxTaskLogic())));
- assertEquals(0, task.compareTo(new AxTask(taskKey, ifMap, ofMap, tpMap, ctxtSet, tl)));
+ assertNotEquals(0, task.compareTo(new AxTask(new AxArtifactKey(), tpMap, ctxtSet, tl)));
+ assertEquals(0, task.compareTo(new AxTask(taskKey, tpMap, ctxtSet, tl)));
+ assertNotEquals(0, task.compareTo(new AxTask(taskKey, tpEmptyMap, ctxtSet, tl)));
+ assertNotEquals(0, task.compareTo(new AxTask(taskKey, tpMap, ctxtEmptySet, tl)));
+ assertNotEquals(0, task.compareTo(new AxTask(taskKey, tpMap, ctxtSet, new AxTaskLogic())));
+ assertEquals(0, task.compareTo(new AxTask(taskKey, tpMap, ctxtSet, tl)));
assertNotNull(task.getKeys());
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java
index 3192079d7..3e3051021 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 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.
@@ -112,19 +113,7 @@ public class ApexPolicyModelTest {
+ "org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum:INVALID:scope is not defined\n"
+ "AxArtifactKey:(name=contextAlbum1,version=0.0.1):"
+ "org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum:INVALID:scope is not defined\n"
- + "AxReferenceKey:"
- + "(parentKeyName=policy,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=state):"
- + "org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel:INVALID:"
- + "task output field AxOutputField:(key=AxReferenceKey:"
- + "(parentKeyName=task,parentKeyVersion=0.0.1,parentLocalName=outputFields,localName=OE1PAR0),"
- + "fieldSchemaKey=AxArtifactKey:(name=eventContextItem0,version=0.0.1),optional=false) for task "
- + "task:0.0.1 not in output event outEvent0:0.0.1\n" + "AxReferenceKey:"
- + "(parentKeyName=policy,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=state):"
- + "org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel:INVALID:"
- + "task output field AxOutputField:(key=AxReferenceKey:"
- + "(parentKeyName=task,parentKeyVersion=0.0.1,parentLocalName=outputFields,localName=OE1PAR1),"
- + "fieldSchemaKey=AxArtifactKey:(name=eventContextItem1,version=0.0.1),optional=false) for task "
- + "task:0.0.1 not in output event outEvent0:0.0.1\n" + "********************************";
+ + "********************************";
private static final String INVALID_MODEL_MALSTRUCTURED_STRING = "\n" + "***validation of model failed***\n"
+ "AxArtifactKey:(name=policyModel_KeyInfo,version=0.0.1):"
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalyserTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalyserTest.java
index 3ff85c898..b1e2d5cbd 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalyserTest.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalyserTest.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 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.
@@ -50,8 +51,8 @@ public class PolicyAnalyserTest {
private static final String EXPECTED_ANALYSIS_RESULT = "" + "Context Schema usage\n" + " MapType:0.0.1\n"
+ " contextAlbum0:0.0.1\n" + " StringType:0.0.1\n" + " contextAlbum1:0.0.1\n"
+ " eventContextItem0:0.0.1\n" + " inEvent:0.0.1\n" + " outEvent0:0.0.1\n" + " outEvent1:0.0.1\n"
- + " task:0.0.1\n" + " eventContextItem1:0.0.1\n" + " inEvent:0.0.1\n" + " outEvent0:0.0.1\n"
- + " outEvent1:0.0.1\n" + " task:0.0.1\n" + "Context Album usage\n" + " contextAlbum0:0.0.1\n"
+ + " eventContextItem1:0.0.1\n" + " inEvent:0.0.1\n" + " outEvent0:0.0.1\n"
+ + " outEvent1:0.0.1\n" + "Context Album usage\n" + " contextAlbum0:0.0.1\n"
+ " task:0.0.1\n" + " policy:0.0.1:NULL:state\n" + " contextAlbum1:0.0.1\n" + " task:0.0.1\n"
+ " policy:0.0.1:NULL:state\n" + "Event usage\n" + " inEvent:0.0.1\n" + " policy:0.0.1:NULL:state\n"
+ " outEvent0:0.0.1\n" + " policy:0.0.1:NULL:state\n" + " outEvent1:0.0.1 (unused)\n" + "Task usage\n"
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/SupportApexPolicyModelCreator.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/SupportApexPolicyModelCreator.java
index ea2de8603..85040221a 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/SupportApexPolicyModelCreator.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/SupportApexPolicyModelCreator.java
@@ -36,8 +36,6 @@ import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
import org.onap.policy.apex.model.eventmodel.concepts.AxEvent;
import org.onap.policy.apex.model.eventmodel.concepts.AxEvents;
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;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicies;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicy;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
@@ -117,27 +115,6 @@ public class SupportApexPolicyModelCreator implements TestApexModelCreator<AxPol
final AxTask task = new AxTask(new AxArtifactKey("task", "0.0.1"));
- for (final AxField field : inEvent.getFields()) {
- final AxReferenceKey fieldkey = new AxReferenceKey(task.getKey().getName(), task.getKey().getVersion(),
- "inputFields", field.getKey().getLocalName());
- final AxInputField inputField = new AxInputField(fieldkey, field.getSchema());
- task.getInputFields().put(inputField.getKey().getLocalName(), inputField);
- }
-
- for (final AxField field : outEvent0.getFields()) {
- final AxReferenceKey fieldkey = new AxReferenceKey(task.getKey().getName(), task.getKey().getVersion(),
- "outputFields", field.getKey().getLocalName());
- final AxOutputField outputField = new AxOutputField(fieldkey, field.getSchema());
- task.getOutputFields().put(outputField.getKey().getLocalName(), outputField);
- }
-
- for (final AxField field : outEvent1.getFields()) {
- final AxReferenceKey fieldkey = new AxReferenceKey(task.getKey().getName(), task.getKey().getVersion(),
- "outputFields", field.getKey().getLocalName());
- final AxOutputField outputField = new AxOutputField(fieldkey, field.getSchema());
- task.getOutputFields().put(outputField.getKey().getLocalName(), outputField);
- }
-
task.setInputEvent(inEvent);
task.setOutputEvents(Map.of(outEvent0.getId(), outEvent0, outEvent1.getId(), outEvent1));
@@ -271,27 +248,6 @@ public class SupportApexPolicyModelCreator implements TestApexModelCreator<AxPol
final AxTask task = new AxTask(new AxArtifactKey("taskA", "0.0.1"));
- for (final AxField field : inEvent.getFields()) {
- final AxReferenceKey fieldkey = new AxReferenceKey(task.getKey().getName(), task.getKey().getVersion(),
- "inputFieldsA", field.getKey().getLocalName());
- final AxInputField inputField = new AxInputField(fieldkey, field.getSchema());
- task.getInputFields().put(inputField.getKey().getLocalName(), inputField);
- }
-
- for (final AxField field : outEvent0.getFields()) {
- final AxReferenceKey fieldkey = new AxReferenceKey(task.getKey().getName(), task.getKey().getVersion(),
- "outputFieldsA", field.getKey().getLocalName());
- final AxOutputField outputField = new AxOutputField(fieldkey, field.getSchema());
- task.getOutputFields().put(outputField.getKey().getLocalName(), outputField);
- }
-
- for (final AxField field : outEvent1.getFields()) {
- final AxReferenceKey fieldkey = new AxReferenceKey(task.getKey().getName(), task.getKey().getVersion(),
- "outputFieldsA", field.getKey().getLocalName());
- final AxOutputField outputField = new AxOutputField(fieldkey, field.getSchema());
- task.getOutputFields().put(outputField.getKey().getLocalName(), outputField);
- }
-
task.setInputEvent(inEvent);
task.setOutputEvents(Map.of(outEvent0.getId(), outEvent0, outEvent1.getId(), outEvent1));
@@ -400,20 +356,6 @@ public class SupportApexPolicyModelCreator implements TestApexModelCreator<AxPol
final AxTask anotherTask = new AxTask(new AxArtifactKey("anotherTask", "0.0.1"));
- for (final AxField field : inEvent.getFields()) {
- final AxReferenceKey fieldkey = new AxReferenceKey(anotherTask.getKey().getName(),
- anotherTask.getKey().getVersion(), "inputFields", field.getKey().getLocalName());
- final AxInputField inputField = new AxInputField(fieldkey, field.getSchema());
- anotherTask.getInputFields().put(inputField.getKey().getLocalName(), inputField);
- }
-
- for (final AxField field : outEvent0.getFields()) {
- final AxReferenceKey fieldkey = new AxReferenceKey(anotherTask.getKey().getName(),
- anotherTask.getKey().getVersion(), "outputFields", field.getKey().getLocalName());
- final AxOutputField outputField = new AxOutputField(fieldkey, field.getSchema());
- anotherTask.getOutputFields().put(outputField.getKey().getLocalName(), outputField);
- }
-
anotherTask.setInputEvent(inEvent);
anotherTask.setOutputEvents(Map.of(outEvent0.getId(), outEvent0));
final AxTaskParameter taskPar0 = new AxTaskParameter(new AxReferenceKey(anotherTask.getKey(), "taskParameter0"),
diff --git a/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseValues.txt b/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseValues.txt
index d3aad785e..7dd0b3955 100644
--- a/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseValues.txt
+++ b/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseValues.txt
@@ -33,7 +33,7 @@ left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtif
*** all right keys in left
*** all values in left and right are identical
*** list of identical entries in left and right
-key=AxArtifactKey:(name=task,version=0.0.1),value=AxTask:(key=AxArtifactKey:(name=task,version=0.0.1),inputFields={IEPAR0=AxInputField:(key=AxReferenceKey:(parentKeyName=task,parentKeyVersion=0.0.1,parentLocalName=inputFields,localName=IEPAR0),fieldSchemaKey=AxArtifactKey:(name=eventContextItem0,version=0.0.1),optional=false), IEPAR1=AxInputField:(key=AxReferenceKey:(parentKeyName=task,parentKeyVersion=0.0.1,parentLocalName=inputFields,localName=IEPAR1),fieldSchemaKey=AxArtifactKey:(name=eventContextItem1,version=0.0.1),optional=false)},outputFields={OE0PAR0=AxOutputField:(key=AxReferenceKey:(parentKeyName=task,parentKeyVersion=0.0.1,parentLocalName=outputFields,localName=OE0PAR0),fieldSchemaKey=AxArtifactKey:(name=eventContextItem0,version=0.0.1),optional=false), OE0PAR1=AxOutputField:(key=AxReferenceKey:(parentKeyName=task,parentKeyVersion=0.0.1,parentLocalName=outputFields,localName=OE0PAR1),fieldSchemaKey=AxArtifactKey:(name=eventContextItem1,version=0.0.1),optional=false), OE1PAR0=AxOutputField:(key=AxReferenceKey:(parentKeyName=task,parentKeyVersion=0.0.1,parentLocalName=outputFields,localName=OE1PAR0),fieldSchemaKey=AxArtifactKey:(name=eventContextItem0,version=0.0.1),optional=false), OE1PAR1=AxOutputField:(key=AxReferenceKey:(parentKeyName=task,parentKeyVersion=0.0.1,parentLocalName=outputFields,localName=OE1PAR1),fieldSchemaKey=AxArtifactKey:(name=eventContextItem1,version=0.0.1),optional=false)},taskParameters={taskParameter0=AxTaskParameter:(key=AxReferenceKey:(parentKeyName=task,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=taskParameter0),defaultValue=Task parameter 0 value), taskParameter1=AxTaskParameter:(key=AxReferenceKey:(parentKeyName=task,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=taskParameter1),defaultValue=Task parameter 1 value)},contextAlbumReferenceSet=[AxArtifactKey:(name=contextAlbum0,version=0.0.1), AxArtifactKey:(name=contextAlbum1,version=0.0.1)],taskLogic=AxTaskLogic:(key=AxReferenceKey:(parentKeyName=task,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=taskLogic),logicFlavour=MVEL,logic=Some task logic))
+key=AxArtifactKey:(name=task,version=0.0.1),value=AxTask:(key=AxArtifactKey:(name=task,version=0.0.1),taskParameters={taskParameter0=AxTaskParameter:(key=AxReferenceKey:(parentKeyName=task,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=taskParameter0),defaultValue=Task parameter 0 value), taskParameter1=AxTaskParameter:(key=AxReferenceKey:(parentKeyName=task,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=taskParameter1),defaultValue=Task parameter 1 value)},contextAlbumReferenceSet=[AxArtifactKey:(name=contextAlbum0,version=0.0.1), AxArtifactKey:(name=contextAlbum1,version=0.0.1)],taskLogic=AxTaskLogic:(key=AxReferenceKey:(parentKeyName=task,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=taskLogic),logicFlavour=MVEL,logic=Some task logic))
*** policy differences ***
left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtifactKey:(name=PolicyModel,version=0.0.1)
*** all left keys in right
diff --git a/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonIdenticalVerboseValues.txt b/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonIdenticalVerboseValues.txt
index f566a7e5f..149bec002 100644
--- a/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonIdenticalVerboseValues.txt
+++ b/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonIdenticalVerboseValues.txt
@@ -33,7 +33,7 @@ left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtif
*** all right keys in left
*** all values in left and right are identical
*** list of identical entries in left and right
-key=AxArtifactKey:(name=task,version=0.0.1),value=AxTask:(key=AxArtifactKey:(name=task,version=0.0.1),inputFields={IEPAR0=AxInputField:(key=AxReferenceKey:(parentKeyName=task,parentKeyVersion=0.0.1,parentLocalName=inputFields,localName=IEPAR0),fieldSchemaKey=AxArtifactKey:(name=eventContextItem0,version=0.0.1),optional=false), IEPAR1=AxInputField:(key=AxReferenceKey:(parentKeyName=task,parentKeyVersion=0.0.1,parentLocalName=inputFields,localName=IEPAR1),fieldSchemaKey=AxArtifactKey:(name=eventContextItem1,version=0.0.1),optional=false)},outputFields={OE0PAR0=AxOutputField:(key=AxReferenceKey:(parentKeyName=task,parentKeyVersion=0.0.1,parentLocalName=outputFields,localName=OE0PAR0),fieldSchemaKey=AxArtifactKey:(name=eventContextItem0,version=0.0.1),optional=false), OE0PAR1=AxOutputField:(key=AxReferenceKey:(parentKeyName=task,parentKeyVersion=0.0.1,parentLocalName=outputFields,localName=OE0PAR1),fieldSchemaKey=AxArtifactKey:(name=eventContextItem1,version=0.0.1),optional=false), OE1PAR0=AxOutputField:(key=AxReferenceKey:(parentKeyName=task,parentKeyVersion=0.0.1,parentLocalName=outputFields,localName=OE1PAR0),fieldSchemaKey=AxArtifactKey:(name=eventContextItem0,version=0.0.1),optional=false), OE1PAR1=AxOutputField:(key=AxReferenceKey:(parentKeyName=task,parentKeyVersion=0.0.1,parentLocalName=outputFields,localName=OE1PAR1),fieldSchemaKey=AxArtifactKey:(name=eventContextItem1,version=0.0.1),optional=false)},taskParameters={taskParameter0=AxTaskParameter:(key=AxReferenceKey:(parentKeyName=task,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=taskParameter0),defaultValue=Task parameter 0 value), taskParameter1=AxTaskParameter:(key=AxReferenceKey:(parentKeyName=task,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=taskParameter1),defaultValue=Task parameter 1 value)},contextAlbumReferenceSet=[AxArtifactKey:(name=contextAlbum0,version=0.0.1), AxArtifactKey:(name=contextAlbum1,version=0.0.1)],taskLogic=AxTaskLogic:(key=AxReferenceKey:(parentKeyName=task,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=taskLogic),logicFlavour=MVEL,logic=Some task logic))
+key=AxArtifactKey:(name=task,version=0.0.1),value=AxTask:(key=AxArtifactKey:(name=task,version=0.0.1),taskParameters={taskParameter0=AxTaskParameter:(key=AxReferenceKey:(parentKeyName=task,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=taskParameter0),defaultValue=Task parameter 0 value), taskParameter1=AxTaskParameter:(key=AxReferenceKey:(parentKeyName=task,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=taskParameter1),defaultValue=Task parameter 1 value)},contextAlbumReferenceSet=[AxArtifactKey:(name=contextAlbum0,version=0.0.1), AxArtifactKey:(name=contextAlbum1,version=0.0.1)],taskLogic=AxTaskLogic:(key=AxReferenceKey:(parentKeyName=task,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=taskLogic),logicFlavour=MVEL,logic=Some task logic))
*** policy differences ***
left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtifactKey:(name=PolicyModel,version=0.0.1)
*** all left keys in right
@@ -66,4 +66,3 @@ key=AxArtifactKey:(name=policy,version=0.0.1),value=AxKeyInfo:(artifactId=AxArti
key=AxArtifactKey:(name=task,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=task,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e016,description=Generated description for concept referred to by key "task:0.0.1")
key=AxArtifactKey:(name=tasks,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=tasks,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e017,description=Generated description for concept referred to by key "tasks:0.0.1")
***********************************
-