diff options
author | Jim Hahn <jrh3@att.com> | 2021-04-28 15:45:22 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2021-05-03 15:44:08 -0400 |
commit | e168ce2fad71650ad730519c772a9b093c0a8f43 (patch) | |
tree | 8d97f8823eb4f97916b2c19909c6b13e6a008e4a /core/core-engine/src/main/java/org/onap | |
parent | cb09008c4d252dbc9a62f3a1d0b463a74380aa77 (diff) |
Remove GroupValidationResult
Removed GroupValidationResult, replacing it with BeanValidationResult.
Modified the ParameterGroup subclasses to use BeanValidator, adding
annotations where needed to trigger the validations that had been
automatically performed by GroupValidationResult.
Issue-ID: POLICY-2059
Change-Id: I2c0c01fac355e6cde4d8d6998dc42f8a2e2ebb65
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'core/core-engine/src/main/java/org/onap')
-rw-r--r-- | core/core-engine/src/main/java/org/onap/policy/apex/core/engine/EngineParameters.java | 43 | ||||
-rw-r--r-- | core/core-engine/src/main/java/org/onap/policy/apex/core/engine/ExecutorParameters.java | 31 |
2 files changed, 15 insertions, 59 deletions
diff --git a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/EngineParameters.java b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/EngineParameters.java index 3ca74153e..3cf43c581 100644 --- a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/EngineParameters.java +++ b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/EngineParameters.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 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,14 +25,13 @@ package org.onap.policy.apex.core.engine; import java.util.ArrayList; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.TreeMap; import lombok.Getter; import lombok.Setter; import org.onap.policy.apex.context.parameters.ContextParameters; -import org.onap.policy.common.parameters.GroupValidationResult; -import org.onap.policy.common.parameters.ParameterGroup; -import org.onap.policy.common.parameters.ValidationResult; +import org.onap.policy.common.parameters.ParameterGroupImpl; +import org.onap.policy.common.parameters.annotations.NotNull; +import org.onap.policy.common.parameters.annotations.Valid; /** * This class holds the parameters for a single Apex engine. This parameter class holds parameters for context schemas @@ -51,44 +51,21 @@ import org.onap.policy.common.parameters.ValidationResult; */ @Getter @Setter -public class EngineParameters implements ParameterGroup { - private ContextParameters contextParameters = new ContextParameters(); +@NotNull +public class EngineParameters extends ParameterGroupImpl { + private @Valid ContextParameters contextParameters = new ContextParameters(); - // Parameter group name - private String name; // A map of parameters for executors of various logic types - private Map<String, ExecutorParameters> executorParameterMap = new TreeMap<>(); + private Map<String, @NotNull @Valid ExecutorParameters> executorParameterMap = new TreeMap<>(); // A list of parameters to be passed to the task, so that they can be used in the logic - private List<TaskParameters> taskParameters = new ArrayList<>(); + private List<@NotNull @Valid TaskParameters> taskParameters = new ArrayList<>(); /** * Constructor to create an engine parameters instance and register the instance with the parameter service. */ public EngineParameters() { - super(); - - // Set the name for the parameters - this.name = EngineParameterConstants.MAIN_GROUP_NAME; + super(EngineParameterConstants.MAIN_GROUP_NAME); } - - @Override - public GroupValidationResult validate() { - final GroupValidationResult result = new GroupValidationResult(this); - - result.setResult("contextParameters", contextParameters.validate()); - - for (Entry<String, ExecutorParameters> executorParEntry : executorParameterMap.entrySet()) { - result.setResult("executorParameterMap", executorParEntry.getKey(), executorParEntry.getValue().validate()); - } - for (TaskParameters taskParam : taskParameters) { - ValidationResult taskParamValidationResult = taskParam.validate("taskParameters"); - result.setResult(taskParamValidationResult.getName(), taskParamValidationResult.getStatus(), - taskParamValidationResult.getResult()); - } - return result; - } - - } diff --git a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/ExecutorParameters.java b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/ExecutorParameters.java index 7de121d66..7bff07d9a 100644 --- a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/ExecutorParameters.java +++ b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/ExecutorParameters.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,8 +21,7 @@ package org.onap.policy.apex.core.engine; -import org.onap.policy.common.parameters.GroupValidationResult; -import org.onap.policy.common.parameters.ParameterGroup; +import org.onap.policy.common.parameters.ParameterGroupImpl; /** * This class provides the executors for a logic flavour. Plugin classes for execution of task @@ -32,10 +32,7 @@ import org.onap.policy.common.parameters.ParameterGroup; * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public class ExecutorParameters implements ParameterGroup { - // Parameter group name - private String name; - +public class ExecutorParameters extends ParameterGroupImpl { // Executor Plugin classes for executors private String taskExecutorPluginClass; private String taskSelectionExecutorPluginClass; @@ -46,10 +43,7 @@ public class ExecutorParameters implements ParameterGroup { * parameter service. */ public ExecutorParameters() { - super(); - - // Set the name for the parameters - this.name = EngineParameterConstants.EXECUTOR_GROUP_NAME; + super(EngineParameterConstants.EXECUTOR_GROUP_NAME); } /** @@ -110,23 +104,8 @@ public class ExecutorParameters implements ParameterGroup { @Override public String toString() { - return "ExecutorParameters [name=" + name + ", taskExecutorPluginClass=" + taskExecutorPluginClass + return "ExecutorParameters [name=" + getName() + ", taskExecutorPluginClass=" + taskExecutorPluginClass + ", taskSelectionExecutorPluginClass=" + taskSelectionExecutorPluginClass + ", stateFinalizerExecutorPluginClass=" + stateFinalizerExecutorPluginClass + "]"; } - - @Override - public String getName() { - return name; - } - - @Override - public void setName(final String name) { - this.name = name; - } - - @Override - public GroupValidationResult validate() { - return new GroupValidationResult(this); - } } |