21b3a5eafb8fd4ce5b90a1553e99315ecec1d1e2
[policy/apex-pdp.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2016-2018 Ericsson. All rights reserved.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.apex.context.parameters;
22
23 import org.onap.policy.common.parameters.GroupValidationResult;
24 import org.onap.policy.common.parameters.ParameterGroup;
25
26 // @formatter:off
27 /**
28  * Bean class to hold parameters for context handling in Apex. This class contains all the context parameters for schema
29  * handling, distribution, locking, and persistence of context albums.
30  *
31  * <p>The following parameters are defined:
32  * <ol>
33  * <li>flushPeriod: Context is flushed to any persistor plugin that is defined periodically, and the period for flushing
34  * is the flush period.
35  * <li>distributorParameters: The parameters (a {@link DistributorParameters} instance) for the distributor plugin that
36  * is being used for context album distribution
37  * <li>schemaParameters: The parameters (a {@link SchemaParameters} instance) for the schema plugin that is being used
38  * for context album schemas
39  * <li>lockManagerParameters: The parameters (a {@link LockManagerParameters} instance) for the locking mechanism plugin
40  * that is being used for context album locking
41  * <li>persistorParameters: The parameters (a {@link PersistorParameters} instance) for the persistence plugin that is
42  * being used for context album persistence
43  * </ol>
44  */
45 // @formatter:on
46 public class ContextParameters implements ParameterGroup {
47     // @formatter:off
48     // Plugin Parameters
49     private String                name;
50     private DistributorParameters distributorParameters = new DistributorParameters();
51     private SchemaParameters      schemaParameters      = new SchemaParameters();
52     private LockManagerParameters lockManagerParameters = new LockManagerParameters();
53     private PersistorParameters   persistorParameters   = new PersistorParameters();
54     // @formatter:on
55
56     /**
57      * Constructor to create a context parameters instance and register the instance with the parameter service.
58      */
59     public ContextParameters() {
60         super();
61
62         // Set the name for the parameters
63         this.name = ContextParameterConstants.MAIN_GROUP_NAME;
64     }
65
66     /**
67      * Gets the distributor parameters.
68      *
69      * @return the distributor parameters
70      */
71     public DistributorParameters getDistributorParameters() {
72         return distributorParameters;
73     }
74
75     /**
76      * Sets the distributor parameters.
77      *
78      * @param distributorParameters the distributor parameters
79      */
80     public void setDistributorParameters(final DistributorParameters distributorParameters) {
81         this.distributorParameters = distributorParameters;
82     }
83
84     /**
85      * Gets the schema parameters.
86      *
87      * @return the schema parameters
88      */
89     public SchemaParameters getSchemaParameters() {
90         return schemaParameters;
91     }
92
93     /**
94      * Sets the schema parameters.
95      *
96      * @param schemaParameters the schema parameters
97      */
98     public void setSchemaParameters(final SchemaParameters schemaParameters) {
99         this.schemaParameters = schemaParameters;
100     }
101
102     /**
103      * Gets the lock manager parameters.
104      *
105      * @return the lock manager parameters
106      */
107     public LockManagerParameters getLockManagerParameters() {
108         return lockManagerParameters;
109     }
110
111     /**
112      * Sets the lock manager parameters.
113      *
114      * @param lockManagerParameters the lock manager parameters
115      */
116     public void setLockManagerParameters(final LockManagerParameters lockManagerParameters) {
117         this.lockManagerParameters = lockManagerParameters;
118     }
119
120     /**
121      * Gets the persistor parameters.
122      *
123      * @return the persistor parameters
124      */
125     public PersistorParameters getPersistorParameters() {
126         return persistorParameters;
127     }
128
129     /**
130      * Sets the persistor parameters.
131      *
132      * @param persistorParameters the persistor parameters
133      */
134     public void setPersistorParameters(final PersistorParameters persistorParameters) {
135         this.persistorParameters = persistorParameters;
136     }
137
138     @Override
139     public String toString() {
140         return "ContextParameters [name=" + name + ", distributorParameters=" + distributorParameters
141                         + ", schemaParameters=" + schemaParameters + ", lockManagerParameters=" + lockManagerParameters
142                         + ", persistorParameters=" + persistorParameters + "]";
143     }
144
145     @Override
146     public String getName() {
147         return name;
148     }
149
150     @Override
151     public void setName(final String name) {
152         this.name = name;
153     }
154
155     @Override
156     public GroupValidationResult validate() {
157         GroupValidationResult result = new GroupValidationResult(this);
158
159         // @formatter:off
160         result.setResult("distributorParameters", distributorParameters.validate());
161         result.setResult("schemaParameters",      schemaParameters.validate());
162         result.setResult("lockManagerParameters", lockManagerParameters.validate());
163         result.setResult("persistorParameters",   persistorParameters.validate());
164         // @formatter:on
165
166         return result;
167     }
168 }