2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2016-2018 Ericsson. All rights reserved.
4 * Modifications Copyright (C) 2020 Nordix Foundation.
5 * ================================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.apex.core.engine;
24 import java.util.ArrayList;
25 import java.util.List;
27 import java.util.Map.Entry;
28 import java.util.TreeMap;
31 import org.onap.policy.apex.context.parameters.ContextParameters;
32 import org.onap.policy.common.parameters.GroupValidationResult;
33 import org.onap.policy.common.parameters.ParameterGroup;
34 import org.onap.policy.common.parameters.ValidationResult;
37 * This class holds the parameters for a single Apex engine. This parameter class holds parameters for context schemas
38 * and context albums for the engine and a map of the logic flavour executors defined for the engine and the parameters
39 * for each of those executors.
41 * <p>The context parameters for the engine are held in a {@link ContextParameters} instance. This instance holds the
42 * parameters for context schema handling that will be used by the engine as well as the context album distribution,
43 * locking, and persistence parameters.
45 * <p>In Apex, an engine can be configured to use many logic flavours. The executors for each logic flavour are
46 * identified by their name. Each logic flavour executor must have an instance of {@link ExecutorParameters} defined for
47 * it, which specifies the executor plugins to use for that logic flavour executor and specific parameters for those
50 * @author Liam Fallon (liam.fallon@ericsson.com)
54 public class EngineParameters implements ParameterGroup {
55 private ContextParameters contextParameters = new ContextParameters();
57 // Parameter group name
60 // A map of parameters for executors of various logic types
61 private Map<String, ExecutorParameters> executorParameterMap = new TreeMap<>();
63 // A list of parameters to be passed to the task, so that they can be used in the logic
64 private List<TaskParameters> taskParameters = new ArrayList<>();
67 * Constructor to create an engine parameters instance and register the instance with the parameter service.
69 public EngineParameters() {
72 // Set the name for the parameters
73 this.name = EngineParameterConstants.MAIN_GROUP_NAME;
77 public GroupValidationResult validate() {
78 final GroupValidationResult result = new GroupValidationResult(this);
80 result.setResult("contextParameters", contextParameters.validate());
82 for (Entry<String, ExecutorParameters> executorParEntry : executorParameterMap.entrySet()) {
83 result.setResult("executorParameterMap", executorParEntry.getKey(), executorParEntry.getValue().validate());
85 for (TaskParameters taskParam : taskParameters) {
86 ValidationResult taskParamValidationResult = taskParam.validate("taskParameters");
87 result.setResult(taskParamValidationResult.getName(), taskParamValidationResult.getStatus(),
88 taskParamValidationResult.getResult());