diff options
author | liamfallon <liam.fallon@ericsson.com> | 2018-09-13 23:48:50 +0100 |
---|---|---|
committer | liamfallon <liam.fallon@ericsson.com> | 2018-09-13 23:49:32 +0100 |
commit | cd68fc9bae7d6258f77ff59c1431e4f925f61a4c (patch) | |
tree | 53054a7c8e8738644785039c3a200c6b23d4b3ed /examples/examples-adaptive/src/main/java | |
parent | 4cfa2e2d98f6877d54da304ef17f096284430908 (diff) |
Address sonar/Checkstyle Issues
Sweep through Apex codebase to fix most ceheckstyle and
straightforward sonar issues.
Issue-ID: POLICY-1034
Change-Id: I149d9a94ad893affc93573e8de5e3304b6bdde2d
Signed-off-by: liamfallon <liam.fallon@ericsson.com>
Diffstat (limited to 'examples/examples-adaptive/src/main/java')
6 files changed, 330 insertions, 278 deletions
diff --git a/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/concepts/AnomalyDetection.java b/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/concepts/AnomalyDetection.java index f574c74ec..c70c9feb6 100644 --- a/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/concepts/AnomalyDetection.java +++ b/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/concepts/AnomalyDetection.java @@ -120,7 +120,7 @@ public class AnomalyDetection implements Serializable { * * @param anomalyScores the anomaly score values of the algorithm */ - public void setAnomalyScores(final LinkedList<Double> anomalyScores) { + public void setAnomalyScores(final List<Double> anomalyScores) { this.anomalyScores = anomalyScores; } diff --git a/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/concepts/AutoLearn.java b/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/concepts/AutoLearn.java index f2e27725b..d935af5f0 100644 --- a/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/concepts/AutoLearn.java +++ b/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/concepts/AutoLearn.java @@ -36,11 +36,6 @@ public class AutoLearn implements Serializable { private List<Long> counts = null; /** - * The Constructor creates an AutoLearn concept. - */ - public AutoLearn() {} - - /** * Checks if the Autolearn instance is initialized. * * @return true, if the Autolearn instance is initialized @@ -55,14 +50,14 @@ public class AutoLearn implements Serializable { * @param size the number of convergent variables to use */ public void init(final int size) { - if (avDiffs == null || avDiffs.size() == 0) { + if (avDiffs == null || avDiffs.isEmpty()) { avDiffs = new ArrayList<>(size); for (int i = 0; i < size; i++) { avDiffs.add(i, Double.NaN); } } - if (counts == null || counts.size() == 0) { + if (counts == null || counts.isEmpty()) { counts = new ArrayList<>(size); for (int i = 0; i < size; i++) { counts.add(i, 0L); diff --git a/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/AdaptiveDomainModelFactory.java b/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/AdaptiveDomainModelFactory.java index 6b71468d9..d13f93099 100644 --- a/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/AdaptiveDomainModelFactory.java +++ b/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/AdaptiveDomainModelFactory.java @@ -50,6 +50,19 @@ import org.onap.policy.apex.model.policymodel.handling.PolicyLogicReader; * The Class AdaptiveDomainModelFactory. */ public class AdaptiveDomainModelFactory { + // Recurring string constants + private static final String LAST_MONITORED_VALUE = "LastMonitoredValue"; + private static final String TASK_SELECTION_LOGIC = "TaskSelectionLogic"; + private static final String DEFAULT_STATE_LOGIC = "DefaultState_Logic"; + private static final String TASK_LOGIC = "TaskLogic"; + private static final String DECIDE = "Decide"; + private static final String ESTABLISH = "Establish"; + private static final String MATCH = "Match"; + private static final String EXTERNAL = "External"; + private static final String DEFAULT_NAMESPACE = "org.onap.policy.apex.examples.adaptive.events"; + private static final String ITERATION2 = "Iteration"; + private static final String DEFAULT_VERSION = "0.0.1"; + private static final String MONITORED_VALUE = "MonitoredValue"; /** * Gets the anomaly detection policy model. @@ -60,130 +73,142 @@ public class AdaptiveDomainModelFactory { public AxPolicyModel getAnomalyDetectionPolicyModel() { // CHECKSTYLE:ON: checkstyle:maximumMethodLength // Data types for event parameters - final AxContextSchema monitoredValue = - new AxContextSchema(new AxArtifactKey("MonitoredValue", "0.0.1"), "Java", "java.lang.Double"); - final AxContextSchema iteration = - new AxContextSchema(new AxArtifactKey("Iteration", "0.0.1"), "Java", "java.lang.Integer"); + final AxContextSchema monitoredValue = new AxContextSchema(new AxArtifactKey(MONITORED_VALUE, DEFAULT_VERSION), + "Java", "java.lang.Double"); + final AxContextSchema iteration = new AxContextSchema(new AxArtifactKey(ITERATION2, DEFAULT_VERSION), "Java", + "java.lang.Integer"); - final AxContextSchemas adContextSchemas = new AxContextSchemas(new AxArtifactKey("AADMDatatypes", "0.0.1")); + final AxContextSchemas adContextSchemas = new AxContextSchemas( + new AxArtifactKey("AADMDatatypes", DEFAULT_VERSION)); adContextSchemas.getSchemasMap().put(monitoredValue.getKey(), monitoredValue); adContextSchemas.getSchemasMap().put(iteration.getKey(), iteration); - final AxEvent anomalyDetectionTriggerEvent = - new AxEvent(new AxArtifactKey("AnomalyDetectionTriggerEvent", "0.0.1"), - "org.onap.policy.apex.examples.adaptive.events"); - anomalyDetectionTriggerEvent.setSource("External"); - anomalyDetectionTriggerEvent.setTarget("Match"); - anomalyDetectionTriggerEvent.getParameterMap().put("MonitoredValue", new AxField( - new AxReferenceKey(anomalyDetectionTriggerEvent.getKey(), "MonitoredValue"), monitoredValue.getKey())); - anomalyDetectionTriggerEvent.getParameterMap().put("Iteration", new AxField( - new AxReferenceKey(anomalyDetectionTriggerEvent.getKey(), "Iteration"), iteration.getKey())); - - final AxEvent anomalyDetectionMatchEvent = new AxEvent(new AxArtifactKey("AnomalyDetectionMatchEvent", "0.0.1"), - "org.onap.policy.apex.examples.adaptive.events"); - anomalyDetectionMatchEvent.setSource("Match"); - anomalyDetectionMatchEvent.setTarget("Establish"); - anomalyDetectionMatchEvent.getParameterMap().put("MonitoredValue", new AxField( - new AxReferenceKey(anomalyDetectionMatchEvent.getKey(), "MonitoredValue"), monitoredValue.getKey())); - anomalyDetectionMatchEvent.getParameterMap().put("Iteration", - new AxField(new AxReferenceKey(anomalyDetectionMatchEvent.getKey(), "Iteration"), iteration.getKey())); - - final AxEvent anomalyDetectionEstablishEvent = - new AxEvent(new AxArtifactKey("AnomalyDetectionEstablishEvent", "0.0.1"), - "org.onap.policy.apex.examples.adaptive.events"); - anomalyDetectionEstablishEvent.setSource("Establish"); - anomalyDetectionEstablishEvent.setTarget("Decide"); - anomalyDetectionEstablishEvent.getParameterMap().put("MonitoredValue", - new AxField(new AxReferenceKey(anomalyDetectionEstablishEvent.getKey(), "MonitoredValue"), - monitoredValue.getKey())); - anomalyDetectionEstablishEvent.getParameterMap().put("Iteration", new AxField( - new AxReferenceKey(anomalyDetectionEstablishEvent.getKey(), "Iteration"), iteration.getKey())); - - final AxEvent anomalyDetectionDecideEvent = - new AxEvent(new AxArtifactKey("AnomalyDetectionDecideEvent", "0.0.1"), - "org.onap.policy.apex.examples.adaptive.events"); - anomalyDetectionDecideEvent.setSource("Decide"); + final AxEvent anomalyDetectionTriggerEvent = new AxEvent( + new AxArtifactKey("AnomalyDetectionTriggerEvent", DEFAULT_VERSION), + DEFAULT_NAMESPACE); + anomalyDetectionTriggerEvent.setSource(EXTERNAL); + anomalyDetectionTriggerEvent.setTarget(MATCH); + anomalyDetectionTriggerEvent.getParameterMap().put(MONITORED_VALUE, + new AxField(new AxReferenceKey(anomalyDetectionTriggerEvent.getKey(), MONITORED_VALUE), + monitoredValue.getKey())); + anomalyDetectionTriggerEvent.getParameterMap().put(ITERATION2, new AxField( + new AxReferenceKey(anomalyDetectionTriggerEvent.getKey(), ITERATION2), iteration.getKey())); + + final AxEvent anomalyDetectionMatchEvent = new AxEvent( + new AxArtifactKey("AnomalyDetectionMatchEvent", DEFAULT_VERSION), + DEFAULT_NAMESPACE); + anomalyDetectionMatchEvent.setSource(MATCH); + anomalyDetectionMatchEvent.setTarget(ESTABLISH); + anomalyDetectionMatchEvent.getParameterMap().put(MONITORED_VALUE, + new AxField(new AxReferenceKey(anomalyDetectionMatchEvent.getKey(), MONITORED_VALUE), + monitoredValue.getKey())); + anomalyDetectionMatchEvent.getParameterMap().put(ITERATION2, new AxField( + new AxReferenceKey(anomalyDetectionMatchEvent.getKey(), ITERATION2), iteration.getKey())); + + final AxEvent anomalyDetectionEstablishEvent = new AxEvent( + new AxArtifactKey("AnomalyDetectionEstablishEvent", DEFAULT_VERSION), + DEFAULT_NAMESPACE); + anomalyDetectionEstablishEvent.setSource(ESTABLISH); + anomalyDetectionEstablishEvent.setTarget(DECIDE); + anomalyDetectionEstablishEvent.getParameterMap().put(MONITORED_VALUE, + new AxField(new AxReferenceKey(anomalyDetectionEstablishEvent.getKey(), MONITORED_VALUE), + monitoredValue.getKey())); + anomalyDetectionEstablishEvent.getParameterMap().put(ITERATION2, new AxField( + new AxReferenceKey(anomalyDetectionEstablishEvent.getKey(), ITERATION2), iteration.getKey())); + + final AxEvent anomalyDetectionDecideEvent = new AxEvent( + new AxArtifactKey("AnomalyDetectionDecideEvent", DEFAULT_VERSION), + DEFAULT_NAMESPACE); + anomalyDetectionDecideEvent.setSource(DECIDE); anomalyDetectionDecideEvent.setTarget("Act"); - anomalyDetectionDecideEvent.getParameterMap().put("MonitoredValue", new AxField( - new AxReferenceKey(anomalyDetectionDecideEvent.getKey(), "MonitoredValue"), monitoredValue.getKey())); - anomalyDetectionDecideEvent.getParameterMap().put("Iteration", - new AxField(new AxReferenceKey(anomalyDetectionDecideEvent.getKey(), "Iteration"), iteration.getKey())); - - final AxEvent anomalyDetectionActEvent = new AxEvent(new AxArtifactKey("AnomalyDetectionActEvent", "0.0.1"), - "org.onap.policy.apex.examples.adaptive.events"); + anomalyDetectionDecideEvent.getParameterMap().put(MONITORED_VALUE, + new AxField(new AxReferenceKey(anomalyDetectionDecideEvent.getKey(), MONITORED_VALUE), + monitoredValue.getKey())); + anomalyDetectionDecideEvent.getParameterMap().put(ITERATION2, new AxField( + new AxReferenceKey(anomalyDetectionDecideEvent.getKey(), ITERATION2), iteration.getKey())); + + final AxEvent anomalyDetectionActEvent = new AxEvent( + new AxArtifactKey("AnomalyDetectionActEvent", DEFAULT_VERSION), + DEFAULT_NAMESPACE); anomalyDetectionActEvent.setSource("Act"); - anomalyDetectionActEvent.setTarget("External"); - anomalyDetectionActEvent.getParameterMap().put("MonitoredValue", new AxField( - new AxReferenceKey(anomalyDetectionActEvent.getKey(), "MonitoredValue"), monitoredValue.getKey())); - anomalyDetectionActEvent.getParameterMap().put("Iteration", - new AxField(new AxReferenceKey(anomalyDetectionActEvent.getKey(), "Iteration"), iteration.getKey())); - - final AxEvents anomalyDetectionEvents = new AxEvents(new AxArtifactKey("AnomalyDetectionEvents", "0.0.1")); + anomalyDetectionActEvent.setTarget(EXTERNAL); + anomalyDetectionActEvent.getParameterMap().put(MONITORED_VALUE, + new AxField(new AxReferenceKey(anomalyDetectionActEvent.getKey(), MONITORED_VALUE), + monitoredValue.getKey())); + anomalyDetectionActEvent.getParameterMap().put(ITERATION2, new AxField( + new AxReferenceKey(anomalyDetectionActEvent.getKey(), ITERATION2), iteration.getKey())); + + final AxEvents anomalyDetectionEvents = new AxEvents( + new AxArtifactKey("AnomalyDetectionEvents", DEFAULT_VERSION)); anomalyDetectionEvents.getEventMap().put(anomalyDetectionTriggerEvent.getKey(), anomalyDetectionTriggerEvent); anomalyDetectionEvents.getEventMap().put(anomalyDetectionMatchEvent.getKey(), anomalyDetectionMatchEvent); anomalyDetectionEvents.getEventMap().put(anomalyDetectionEstablishEvent.getKey(), - anomalyDetectionEstablishEvent); + anomalyDetectionEstablishEvent); anomalyDetectionEvents.getEventMap().put(anomalyDetectionDecideEvent.getKey(), anomalyDetectionDecideEvent); anomalyDetectionEvents.getEventMap().put(anomalyDetectionActEvent.getKey(), anomalyDetectionActEvent); // Data types for context - final AxContextSchema anomalyDetection = new AxContextSchema(new AxArtifactKey("AnomalyDetection", "0.0.1"), - "Java", "org.onap.policy.apex.examples.adaptive.concepts.AnomalyDetection"); + final AxContextSchema anomalyDetection = new AxContextSchema( + new AxArtifactKey("AnomalyDetection", DEFAULT_VERSION), "Java", + "org.onap.policy.apex.examples.adaptive.concepts.AnomalyDetection"); adContextSchemas.getSchemasMap().put(anomalyDetection.getKey(), anomalyDetection); // One context map final AxContextAlbum anomalyDetectionAlbum = new AxContextAlbum( - new AxArtifactKey("AnomalyDetectionAlbum", "0.0.1"), "APPLICATION", true, anomalyDetection.getKey()); - final AxContextAlbums anomalyDetectionAlbums = - new AxContextAlbums(new AxArtifactKey("AnomalyDetectionAlbums", "0.0.1")); + new AxArtifactKey("AnomalyDetectionAlbum", DEFAULT_VERSION), "APPLICATION", true, + anomalyDetection.getKey()); + final AxContextAlbums anomalyDetectionAlbums = new AxContextAlbums( + new AxArtifactKey("AnomalyDetectionAlbums", DEFAULT_VERSION)); anomalyDetectionAlbums.getAlbumsMap().put(anomalyDetectionAlbum.getKey(), anomalyDetectionAlbum); // Tasks - final AxLogicReader logicReader = - new PolicyLogicReader().setLogicPackage(this.getClass().getPackage().getName()) + final AxLogicReader logicReader = new PolicyLogicReader() + .setLogicPackage(this.getClass().getPackage().getName()) .setDefaultLogic("DefaultAnomalyDetectionTask_Logic"); - final AxTask anomalyDetectionMatchTask = new AxTask(new AxArtifactKey("AnomalyDetectionMatchTask", "0.0.1")); + final AxTask anomalyDetectionMatchTask = new AxTask( + new AxArtifactKey("AnomalyDetectionMatchTask", DEFAULT_VERSION)); anomalyDetectionMatchTask.duplicateInputFields(anomalyDetectionTriggerEvent.getParameterMap()); anomalyDetectionMatchTask.duplicateOutputFields(anomalyDetectionMatchEvent.getParameterMap()); - anomalyDetectionMatchTask - .setTaskLogic(new AxTaskLogic(anomalyDetectionMatchTask.getKey(), "TaskLogic", "MVEL", logicReader)); + anomalyDetectionMatchTask.setTaskLogic( + new AxTaskLogic(anomalyDetectionMatchTask.getKey(), TASK_LOGIC, "MVEL", logicReader)); - final AxTask anomalyDetectionEstablishTask = - new AxTask(new AxArtifactKey("AnomalyDetectionEstablishTask", "0.0.1")); + final AxTask anomalyDetectionEstablishTask = new AxTask( + new AxArtifactKey("AnomalyDetectionEstablishTask", DEFAULT_VERSION)); anomalyDetectionEstablishTask.duplicateInputFields(anomalyDetectionMatchEvent.getParameterMap()); anomalyDetectionEstablishTask.duplicateOutputFields(anomalyDetectionEstablishEvent.getParameterMap()); anomalyDetectionEstablishTask.setTaskLogic( - new AxTaskLogic(anomalyDetectionEstablishTask.getKey(), "TaskLogic", "MVEL", logicReader)); + new AxTaskLogic(anomalyDetectionEstablishTask.getKey(), TASK_LOGIC, "MVEL", logicReader)); - final AxTask anomalyDetectionDecideTask0 = - new AxTask(new AxArtifactKey("AnomalyDetectionDecideTask0", "0.0.1")); + final AxTask anomalyDetectionDecideTask0 = new AxTask( + new AxArtifactKey("AnomalyDetectionDecideTask0", DEFAULT_VERSION)); anomalyDetectionDecideTask0.duplicateInputFields(anomalyDetectionEstablishEvent.getParameterMap()); anomalyDetectionDecideTask0.duplicateOutputFields(anomalyDetectionDecideEvent.getParameterMap()); - anomalyDetectionDecideTask0 - .setTaskLogic(new AxTaskLogic(anomalyDetectionDecideTask0.getKey(), "TaskLogic", "MVEL", logicReader)); + anomalyDetectionDecideTask0.setTaskLogic( + new AxTaskLogic(anomalyDetectionDecideTask0.getKey(), TASK_LOGIC, "MVEL", logicReader)); - final AxTask anomalyDetectionDecideTask1 = - new AxTask(new AxArtifactKey("AnomalyDetectionDecideTask1", "0.0.1")); + final AxTask anomalyDetectionDecideTask1 = new AxTask( + new AxArtifactKey("AnomalyDetectionDecideTask1", DEFAULT_VERSION)); anomalyDetectionDecideTask1.duplicateInputFields(anomalyDetectionEstablishEvent.getParameterMap()); anomalyDetectionDecideTask1.duplicateOutputFields(anomalyDetectionDecideEvent.getParameterMap()); - anomalyDetectionDecideTask1 - .setTaskLogic(new AxTaskLogic(anomalyDetectionDecideTask1.getKey(), "TaskLogic", "MVEL", logicReader)); + anomalyDetectionDecideTask1.setTaskLogic( + new AxTaskLogic(anomalyDetectionDecideTask1.getKey(), TASK_LOGIC, "MVEL", logicReader)); - final AxTask anomalyDetectionDecideTask2 = - new AxTask(new AxArtifactKey("AnomalyDetectionDecideTask2", "0.0.1")); + final AxTask anomalyDetectionDecideTask2 = new AxTask( + new AxArtifactKey("AnomalyDetectionDecideTask2", DEFAULT_VERSION)); anomalyDetectionDecideTask2.duplicateInputFields(anomalyDetectionEstablishEvent.getParameterMap()); anomalyDetectionDecideTask2.duplicateOutputFields(anomalyDetectionDecideEvent.getParameterMap()); - anomalyDetectionDecideTask2 - .setTaskLogic(new AxTaskLogic(anomalyDetectionDecideTask2.getKey(), "TaskLogic", "MVEL", logicReader)); + anomalyDetectionDecideTask2.setTaskLogic( + new AxTaskLogic(anomalyDetectionDecideTask2.getKey(), TASK_LOGIC, "MVEL", logicReader)); - final AxTask anomalyDetectionActTask = new AxTask(new AxArtifactKey("AnomalyDetectionActTask", "0.0.1")); + final AxTask anomalyDetectionActTask = new AxTask( + new AxArtifactKey("AnomalyDetectionActTask", DEFAULT_VERSION)); anomalyDetectionActTask.duplicateInputFields(anomalyDetectionDecideEvent.getParameterMap()); anomalyDetectionActTask.duplicateOutputFields(anomalyDetectionActEvent.getParameterMap()); - anomalyDetectionActTask - .setTaskLogic(new AxTaskLogic(anomalyDetectionActTask.getKey(), "TaskLogic", "MVEL", logicReader)); + anomalyDetectionActTask.setTaskLogic( + new AxTaskLogic(anomalyDetectionActTask.getKey(), TASK_LOGIC, "MVEL", logicReader)); - final AxTasks anomalyDetectionTasks = new AxTasks(new AxArtifactKey("AnomalyDetectionTasks", "0.0.1")); + final AxTasks anomalyDetectionTasks = new AxTasks(new AxArtifactKey("AnomalyDetectionTasks", DEFAULT_VERSION)); anomalyDetectionTasks.getTaskMap().put(anomalyDetectionMatchTask.getKey(), anomalyDetectionMatchTask); anomalyDetectionTasks.getTaskMap().put(anomalyDetectionEstablishTask.getKey(), anomalyDetectionEstablishTask); anomalyDetectionTasks.getTaskMap().put(anomalyDetectionDecideTask0.getKey(), anomalyDetectionDecideTask0); @@ -192,92 +217,98 @@ public class AdaptiveDomainModelFactory { anomalyDetectionTasks.getTaskMap().put(anomalyDetectionActTask.getKey(), anomalyDetectionActTask); // Policies - logicReader.setDefaultLogic("DefaultState_Logic"); + logicReader.setDefaultLogic(DEFAULT_STATE_LOGIC); - final AxPolicy anomalyDetectionPolicy = new AxPolicy(new AxArtifactKey("AnomalyDetectionPolicy", "0.0.1")); + final AxPolicy anomalyDetectionPolicy = new AxPolicy( + new AxArtifactKey("AnomalyDetectionPolicy", DEFAULT_VERSION)); anomalyDetectionPolicy.setTemplate("MEDA"); - final AxState anomalyDetectionActState = - new AxState(new AxReferenceKey(anomalyDetectionPolicy.getKey(), "Act")); + final AxState anomalyDetectionActState = new AxState( + new AxReferenceKey(anomalyDetectionPolicy.getKey(), "Act")); anomalyDetectionActState.setTrigger(anomalyDetectionDecideEvent.getKey()); final AxStateOutput adAct2Out = new AxStateOutput(anomalyDetectionActState.getKey(), - AxReferenceKey.getNullKey(), anomalyDetectionActEvent.getKey()); + AxReferenceKey.getNullKey(), anomalyDetectionActEvent.getKey()); anomalyDetectionActState.getStateOutputs().put(adAct2Out.getKey().getLocalName(), adAct2Out); - anomalyDetectionActState.setTaskSelectionLogic( - new AxTaskSelectionLogic(anomalyDetectionActState.getKey(), "TaskSelectionLogic", "MVEL", logicReader)); + anomalyDetectionActState.setTaskSelectionLogic(new AxTaskSelectionLogic(anomalyDetectionActState.getKey(), + TASK_SELECTION_LOGIC, "MVEL", logicReader)); anomalyDetectionActState.setDefaultTask(anomalyDetectionActTask.getKey()); anomalyDetectionActState.getTaskReferences().put(anomalyDetectionActTask.getKey(), - new AxStateTaskReference(anomalyDetectionActState.getKey(), anomalyDetectionActTask.getKey(), - AxStateTaskOutputType.DIRECT, adAct2Out.getKey())); + new AxStateTaskReference(anomalyDetectionActState.getKey(), anomalyDetectionActTask.getKey(), + AxStateTaskOutputType.DIRECT, adAct2Out.getKey())); logicReader.setDefaultLogic(null); - final AxState anomalyDetectionDecideState = - new AxState(new AxReferenceKey(anomalyDetectionPolicy.getKey(), "Decide")); + final AxState anomalyDetectionDecideState = new AxState( + new AxReferenceKey(anomalyDetectionPolicy.getKey(), DECIDE)); anomalyDetectionDecideState.setTrigger(anomalyDetectionEstablishEvent.getKey()); final AxStateOutput adDec2Act = new AxStateOutput(anomalyDetectionDecideState.getKey(), - anomalyDetectionActState.getKey(), anomalyDetectionDecideEvent.getKey()); + anomalyDetectionActState.getKey(), anomalyDetectionDecideEvent.getKey()); anomalyDetectionDecideState.getStateOutputs().put(adDec2Act.getKey().getLocalName(), adDec2Act); anomalyDetectionDecideState.setTaskSelectionLogic(new AxTaskSelectionLogic(anomalyDetectionDecideState.getKey(), - "TaskSelectionLogic", "JAVA", logicReader)); + TASK_SELECTION_LOGIC, "JAVA", logicReader)); anomalyDetectionDecideState.setDefaultTask(anomalyDetectionDecideTask0.getKey()); anomalyDetectionDecideState.getContextAlbumReferences().add(anomalyDetectionAlbum.getKey()); anomalyDetectionDecideState.getTaskReferences().put(anomalyDetectionDecideTask0.getKey(), - new AxStateTaskReference(anomalyDetectionDecideState.getKey(), anomalyDetectionDecideTask0.getKey(), - AxStateTaskOutputType.DIRECT, adDec2Act.getKey())); + new AxStateTaskReference(anomalyDetectionDecideState.getKey(), + anomalyDetectionDecideTask0.getKey(), AxStateTaskOutputType.DIRECT, + adDec2Act.getKey())); anomalyDetectionDecideState.getTaskReferences().put(anomalyDetectionDecideTask1.getKey(), - new AxStateTaskReference(anomalyDetectionDecideState.getKey(), anomalyDetectionDecideTask1.getKey(), - AxStateTaskOutputType.DIRECT, adDec2Act.getKey())); + new AxStateTaskReference(anomalyDetectionDecideState.getKey(), + anomalyDetectionDecideTask1.getKey(), AxStateTaskOutputType.DIRECT, + adDec2Act.getKey())); anomalyDetectionDecideState.getTaskReferences().put(anomalyDetectionDecideTask2.getKey(), - new AxStateTaskReference(anomalyDetectionDecideState.getKey(), anomalyDetectionDecideTask2.getKey(), - AxStateTaskOutputType.DIRECT, adDec2Act.getKey())); + new AxStateTaskReference(anomalyDetectionDecideState.getKey(), + anomalyDetectionDecideTask2.getKey(), AxStateTaskOutputType.DIRECT, + adDec2Act.getKey())); - logicReader.setDefaultLogic("DefaultState_Logic"); + logicReader.setDefaultLogic(DEFAULT_STATE_LOGIC); - final AxState anomalyDetectionEstablishState = - new AxState(new AxReferenceKey(anomalyDetectionPolicy.getKey(), "Establish")); + final AxState anomalyDetectionEstablishState = new AxState( + new AxReferenceKey(anomalyDetectionPolicy.getKey(), ESTABLISH)); anomalyDetectionEstablishState.setTrigger(anomalyDetectionMatchEvent.getKey()); final AxStateOutput adEst2Dec = new AxStateOutput(anomalyDetectionEstablishState.getKey(), - anomalyDetectionDecideState.getKey(), anomalyDetectionEstablishEvent.getKey()); + anomalyDetectionDecideState.getKey(), anomalyDetectionEstablishEvent.getKey()); anomalyDetectionEstablishState.getStateOutputs().put(adEst2Dec.getKey().getLocalName(), adEst2Dec); anomalyDetectionEstablishState.setTaskSelectionLogic(new AxTaskSelectionLogic( - anomalyDetectionEstablishState.getKey(), "TaskSelectionLogic", "MVEL", logicReader)); + anomalyDetectionEstablishState.getKey(), TASK_SELECTION_LOGIC, "MVEL", logicReader)); anomalyDetectionEstablishState.setDefaultTask(anomalyDetectionEstablishTask.getKey()); anomalyDetectionEstablishState.getTaskReferences().put(anomalyDetectionEstablishTask.getKey(), - new AxStateTaskReference(anomalyDetectionEstablishState.getKey(), - anomalyDetectionEstablishTask.getKey(), AxStateTaskOutputType.DIRECT, adEst2Dec.getKey())); + new AxStateTaskReference(anomalyDetectionEstablishState.getKey(), + anomalyDetectionEstablishTask.getKey(), AxStateTaskOutputType.DIRECT, + adEst2Dec.getKey())); - final AxState anomalyDetectionMatchState = - new AxState(new AxReferenceKey(anomalyDetectionPolicy.getKey(), "Match")); + final AxState anomalyDetectionMatchState = new AxState( + new AxReferenceKey(anomalyDetectionPolicy.getKey(), MATCH)); anomalyDetectionMatchState.setTrigger(anomalyDetectionTriggerEvent.getKey()); final AxStateOutput adMat2Est = new AxStateOutput(anomalyDetectionMatchState.getKey(), - anomalyDetectionEstablishState.getKey(), anomalyDetectionMatchEvent.getKey()); + anomalyDetectionEstablishState.getKey(), anomalyDetectionMatchEvent.getKey()); anomalyDetectionMatchState.getStateOutputs().put(adMat2Est.getKey().getLocalName(), adMat2Est); anomalyDetectionMatchState.setTaskSelectionLogic(new AxTaskSelectionLogic(anomalyDetectionMatchState.getKey(), - "TaskSelectionLogic", "MVEL", logicReader)); + TASK_SELECTION_LOGIC, "MVEL", logicReader)); anomalyDetectionMatchState.setDefaultTask(anomalyDetectionMatchTask.getKey()); anomalyDetectionMatchState.getTaskReferences().put(anomalyDetectionMatchTask.getKey(), - new AxStateTaskReference(anomalyDetectionMatchState.getKey(), anomalyDetectionMatchTask.getKey(), - AxStateTaskOutputType.DIRECT, adMat2Est.getKey())); + new AxStateTaskReference(anomalyDetectionMatchState.getKey(), + anomalyDetectionMatchTask.getKey(), AxStateTaskOutputType.DIRECT, + adMat2Est.getKey())); anomalyDetectionPolicy.setFirstState(anomalyDetectionMatchState.getKey().getLocalName()); anomalyDetectionPolicy.getStateMap().put(anomalyDetectionMatchState.getKey().getLocalName(), - anomalyDetectionMatchState); + anomalyDetectionMatchState); anomalyDetectionPolicy.getStateMap().put(anomalyDetectionEstablishState.getKey().getLocalName(), - anomalyDetectionEstablishState); + anomalyDetectionEstablishState); anomalyDetectionPolicy.getStateMap().put(anomalyDetectionDecideState.getKey().getLocalName(), - anomalyDetectionDecideState); + anomalyDetectionDecideState); anomalyDetectionPolicy.getStateMap().put(anomalyDetectionActState.getKey().getLocalName(), - anomalyDetectionActState); + anomalyDetectionActState); - final AxPolicies anomalyDetectionPolicies = - new AxPolicies(new AxArtifactKey("AnomalyDetectionPolicies", "0.0.1")); + final AxPolicies anomalyDetectionPolicies = new AxPolicies( + new AxArtifactKey("AnomalyDetectionPolicies", DEFAULT_VERSION)); anomalyDetectionPolicies.getPolicyMap().put(anomalyDetectionPolicy.getKey(), anomalyDetectionPolicy); - final AxKeyInformation keyInformation = - new AxKeyInformation(new AxArtifactKey("AnomalyDetectionKeyInformation", "0.0.1")); - final AxPolicyModel anomalyDetectionPolicyModel = - new AxPolicyModel(new AxArtifactKey("AnomalyDetectionPolicyModel", "0.0.1")); + final AxKeyInformation keyInformation = new AxKeyInformation( + new AxArtifactKey("AnomalyDetectionKeyInformation", DEFAULT_VERSION)); + final AxPolicyModel anomalyDetectionPolicyModel = new AxPolicyModel( + new AxArtifactKey("AnomalyDetectionPolicyModel", DEFAULT_VERSION)); anomalyDetectionPolicyModel.setPolicies(anomalyDetectionPolicies); anomalyDetectionPolicyModel.setEvents(anomalyDetectionEvents); anomalyDetectionPolicyModel.setTasks(anomalyDetectionTasks); @@ -302,58 +333,65 @@ public class AdaptiveDomainModelFactory { public AxPolicyModel getAutoLearnPolicyModel() { // CHECKSTYLE:ON: checkstyle:maximumMethodLength // Data types for event parameters - final AxContextSchema monitoredValue = - new AxContextSchema(new AxArtifactKey("MonitoredValue", "0.0.1"), "Java", "java.lang.Double"); + final AxContextSchema monitoredValue = new AxContextSchema(new AxArtifactKey(MONITORED_VALUE, DEFAULT_VERSION), + "Java", "java.lang.Double"); - final AxContextSchemas alContextSchemas = new AxContextSchemas(new AxArtifactKey("ALDatatypes", "0.0.1")); + final AxContextSchemas alContextSchemas = new AxContextSchemas( + new AxArtifactKey("ALDatatypes", DEFAULT_VERSION)); alContextSchemas.getSchemasMap().put(monitoredValue.getKey(), monitoredValue); - final AxEvent autoLearnTriggerEvent = new AxEvent(new AxArtifactKey("AutoLearnTriggerEvent", "0.0.1"), - "org.onap.policy.apex.examples.adaptive.events"); - autoLearnTriggerEvent.setSource("External"); - autoLearnTriggerEvent.setTarget("Match"); - autoLearnTriggerEvent.getParameterMap().put("MonitoredValue", new AxField( - new AxReferenceKey(autoLearnTriggerEvent.getKey(), "MonitoredValue"), monitoredValue.getKey())); - autoLearnTriggerEvent.getParameterMap().put("LastMonitoredValue", new AxField( - new AxReferenceKey(autoLearnTriggerEvent.getKey(), "LastMonitoredValue"), monitoredValue.getKey())); - - final AxEvent autoLearnMatchEvent = new AxEvent(new AxArtifactKey("AutoLearnMatchEvent", "0.0.1"), - "org.onap.policy.apex.examples.adaptive.events"); - autoLearnMatchEvent.setSource("Match"); - autoLearnMatchEvent.setTarget("Establish"); - autoLearnMatchEvent.getParameterMap().put("MonitoredValue", new AxField( - new AxReferenceKey(autoLearnMatchEvent.getKey(), "MonitoredValue"), monitoredValue.getKey())); - autoLearnMatchEvent.getParameterMap().put("LastMonitoredValue", new AxField( - new AxReferenceKey(autoLearnMatchEvent.getKey(), "LastMonitoredValue"), monitoredValue.getKey())); - - final AxEvent autoLearnEstablishEvent = new AxEvent(new AxArtifactKey("AutoLearnEstablishEvent", "0.0.1"), - "org.onap.policy.apex.examples.adaptive.events"); - autoLearnEstablishEvent.setSource("Establish"); - autoLearnEstablishEvent.setTarget("Decide"); - autoLearnEstablishEvent.getParameterMap().put("MonitoredValue", new AxField( - new AxReferenceKey(autoLearnEstablishEvent.getKey(), "MonitoredValue"), monitoredValue.getKey())); - autoLearnEstablishEvent.getParameterMap().put("LastMonitoredValue", new AxField( - new AxReferenceKey(autoLearnEstablishEvent.getKey(), "LastMonitoredValue"), monitoredValue.getKey())); - - final AxEvent autoLearnDecideEvent = new AxEvent(new AxArtifactKey("AutoLearnDecideEvent", "0.0.1"), - "org.onap.policy.apex.examples.adaptive.events"); - autoLearnDecideEvent.setSource("Decide"); + final AxEvent autoLearnTriggerEvent = new AxEvent(new AxArtifactKey("AutoLearnTriggerEvent", DEFAULT_VERSION), + DEFAULT_NAMESPACE); + autoLearnTriggerEvent.setSource(EXTERNAL); + autoLearnTriggerEvent.setTarget(MATCH); + autoLearnTriggerEvent.getParameterMap().put(MONITORED_VALUE, new AxField( + new AxReferenceKey(autoLearnTriggerEvent.getKey(), MONITORED_VALUE), monitoredValue.getKey())); + autoLearnTriggerEvent.getParameterMap().put(LAST_MONITORED_VALUE, + new AxField(new AxReferenceKey(autoLearnTriggerEvent.getKey(), LAST_MONITORED_VALUE), + monitoredValue.getKey())); + + final AxEvent autoLearnMatchEvent = new AxEvent(new AxArtifactKey("AutoLearnMatchEvent", DEFAULT_VERSION), + DEFAULT_NAMESPACE); + autoLearnMatchEvent.setSource(MATCH); + autoLearnMatchEvent.setTarget(ESTABLISH); + autoLearnMatchEvent.getParameterMap().put(MONITORED_VALUE, new AxField( + new AxReferenceKey(autoLearnMatchEvent.getKey(), MONITORED_VALUE), monitoredValue.getKey())); + autoLearnMatchEvent.getParameterMap().put(LAST_MONITORED_VALUE, + new AxField(new AxReferenceKey(autoLearnMatchEvent.getKey(), LAST_MONITORED_VALUE), + monitoredValue.getKey())); + + final AxEvent autoLearnEstablishEvent = new AxEvent( + new AxArtifactKey("AutoLearnEstablishEvent", DEFAULT_VERSION), + DEFAULT_NAMESPACE); + autoLearnEstablishEvent.setSource(ESTABLISH); + autoLearnEstablishEvent.setTarget(DECIDE); + autoLearnEstablishEvent.getParameterMap().put(MONITORED_VALUE, + new AxField(new AxReferenceKey(autoLearnEstablishEvent.getKey(), MONITORED_VALUE), + monitoredValue.getKey())); + autoLearnEstablishEvent.getParameterMap().put(LAST_MONITORED_VALUE, + new AxField(new AxReferenceKey(autoLearnEstablishEvent.getKey(), LAST_MONITORED_VALUE), + monitoredValue.getKey())); + + final AxEvent autoLearnDecideEvent = new AxEvent(new AxArtifactKey("AutoLearnDecideEvent", DEFAULT_VERSION), + DEFAULT_NAMESPACE); + autoLearnDecideEvent.setSource(DECIDE); autoLearnDecideEvent.setTarget("Act"); - autoLearnDecideEvent.getParameterMap().put("MonitoredValue", new AxField( - new AxReferenceKey(autoLearnDecideEvent.getKey(), "MonitoredValue"), monitoredValue.getKey())); - autoLearnDecideEvent.getParameterMap().put("LastMonitoredValue", new AxField( - new AxReferenceKey(autoLearnDecideEvent.getKey(), "LastMonitoredValue"), monitoredValue.getKey())); - - final AxEvent autoLearnActEvent = new AxEvent(new AxArtifactKey("AutoLearnActEvent", "0.0.1"), - "org.onap.policy.apex.examples.adaptive.events"); + autoLearnDecideEvent.getParameterMap().put(MONITORED_VALUE, new AxField( + new AxReferenceKey(autoLearnDecideEvent.getKey(), MONITORED_VALUE), monitoredValue.getKey())); + autoLearnDecideEvent.getParameterMap().put(LAST_MONITORED_VALUE, + new AxField(new AxReferenceKey(autoLearnDecideEvent.getKey(), LAST_MONITORED_VALUE), + monitoredValue.getKey())); + + final AxEvent autoLearnActEvent = new AxEvent(new AxArtifactKey("AutoLearnActEvent", DEFAULT_VERSION), + DEFAULT_NAMESPACE); autoLearnActEvent.setSource("Act"); - autoLearnActEvent.setTarget("External"); - autoLearnActEvent.getParameterMap().put("MonitoredValue", - new AxField(new AxReferenceKey(autoLearnActEvent.getKey(), "MonitoredValue"), monitoredValue.getKey())); - autoLearnActEvent.getParameterMap().put("LastMonitoredValue", new AxField( - new AxReferenceKey(autoLearnActEvent.getKey(), "LastMonitoredValue"), monitoredValue.getKey())); + autoLearnActEvent.setTarget(EXTERNAL); + autoLearnActEvent.getParameterMap().put(MONITORED_VALUE, new AxField( + new AxReferenceKey(autoLearnActEvent.getKey(), MONITORED_VALUE), monitoredValue.getKey())); + autoLearnActEvent.getParameterMap().put(LAST_MONITORED_VALUE, new AxField( + new AxReferenceKey(autoLearnActEvent.getKey(), LAST_MONITORED_VALUE), monitoredValue.getKey())); - final AxEvents autoLearnEvents = new AxEvents(new AxArtifactKey("AutoLearnEvents", "0.0.1")); + final AxEvents autoLearnEvents = new AxEvents(new AxArtifactKey("AutoLearnEvents", DEFAULT_VERSION)); autoLearnEvents.getEventMap().put(autoLearnTriggerEvent.getKey(), autoLearnTriggerEvent); autoLearnEvents.getEventMap().put(autoLearnMatchEvent.getKey(), autoLearnMatchEvent); autoLearnEvents.getEventMap().put(autoLearnEstablishEvent.getKey(), autoLearnEstablishEvent); @@ -361,84 +399,86 @@ public class AdaptiveDomainModelFactory { autoLearnEvents.getEventMap().put(autoLearnActEvent.getKey(), autoLearnActEvent); // Data types for context - final AxContextSchema autoLearn = new AxContextSchema(new AxArtifactKey("AutoLearn", "0.0.1"), "Java", - "org.onap.policy.apex.examples.adaptive.concepts.AutoLearn"); + final AxContextSchema autoLearn = new AxContextSchema(new AxArtifactKey("AutoLearn", DEFAULT_VERSION), "Java", + "org.onap.policy.apex.examples.adaptive.concepts.AutoLearn"); alContextSchemas.getSchemasMap().put(autoLearn.getKey(), autoLearn); // One context map - final AxContextAlbum autoLearnAlbum = new AxContextAlbum(new AxArtifactKey("AutoLearnAlbum", "0.0.1"), - "APPLICATION", true, autoLearn.getKey()); + final AxContextAlbum autoLearnAlbum = new AxContextAlbum(new AxArtifactKey("AutoLearnAlbum", DEFAULT_VERSION), + "APPLICATION", true, autoLearn.getKey()); - final AxContextAlbums autoLearnAlbums = new AxContextAlbums(new AxArtifactKey("AutoLearnContext", "0.0.1")); + final AxContextAlbums autoLearnAlbums = new AxContextAlbums( + new AxArtifactKey("AutoLearnContext", DEFAULT_VERSION)); autoLearnAlbums.getAlbumsMap().put(autoLearnAlbum.getKey(), autoLearnAlbum); // Tasks final AxLogicReader logicReader = new PolicyLogicReader() - .setLogicPackage(this.getClass().getPackage().getName()).setDefaultLogic("DefaultAutoLearnTask_Logic"); + .setLogicPackage(this.getClass().getPackage().getName()) + .setDefaultLogic("DefaultAutoLearnTask_Logic"); - final AxTask autoLearnMatchTask = new AxTask(new AxArtifactKey("AutoLearnMatchTask", "0.0.1")); + final AxTask autoLearnMatchTask = new AxTask(new AxArtifactKey("AutoLearnMatchTask", DEFAULT_VERSION)); autoLearnMatchTask.duplicateInputFields(autoLearnTriggerEvent.getParameterMap()); autoLearnMatchTask.duplicateOutputFields(autoLearnMatchEvent.getParameterMap()); - autoLearnMatchTask.setTaskLogic(new AxTaskLogic(autoLearnMatchTask.getKey(), "TaskLogic", "MVEL", logicReader)); + autoLearnMatchTask.setTaskLogic(new AxTaskLogic(autoLearnMatchTask.getKey(), TASK_LOGIC, "MVEL", logicReader)); - final AxTask autoLearnEstablishTask = new AxTask(new AxArtifactKey("AutoLearnEstablishTask", "0.0.1")); + final AxTask autoLearnEstablishTask = new AxTask(new AxArtifactKey("AutoLearnEstablishTask", DEFAULT_VERSION)); autoLearnEstablishTask.duplicateInputFields(autoLearnMatchEvent.getParameterMap()); autoLearnEstablishTask.duplicateOutputFields(autoLearnEstablishEvent.getParameterMap()); - autoLearnEstablishTask - .setTaskLogic(new AxTaskLogic(autoLearnEstablishTask.getKey(), "TaskLogic", "MVEL", logicReader)); + autoLearnEstablishTask.setTaskLogic( + new AxTaskLogic(autoLearnEstablishTask.getKey(), TASK_LOGIC, "MVEL", logicReader)); logicReader.setDefaultLogic(null); - final AxTask autoLearnDecideTask0 = new AxTask(new AxArtifactKey("AutoLearnDecideTask0", "0.0.1")); + final AxTask autoLearnDecideTask0 = new AxTask(new AxArtifactKey("AutoLearnDecideTask0", DEFAULT_VERSION)); autoLearnDecideTask0.duplicateInputFields(autoLearnEstablishEvent.getParameterMap()); autoLearnDecideTask0.duplicateOutputFields(autoLearnDecideEvent.getParameterMap()); autoLearnDecideTask0 - .setTaskLogic(new AxTaskLogic(autoLearnDecideTask0.getKey(), "TaskLogic", "MVEL", logicReader)); + .setTaskLogic(new AxTaskLogic(autoLearnDecideTask0.getKey(), TASK_LOGIC, "MVEL", logicReader)); - final AxTask autoLearnDecideTask1 = new AxTask(new AxArtifactKey("AutoLearnDecideTask1", "0.0.1")); + final AxTask autoLearnDecideTask1 = new AxTask(new AxArtifactKey("AutoLearnDecideTask1", DEFAULT_VERSION)); autoLearnDecideTask1.duplicateInputFields(autoLearnEstablishEvent.getParameterMap()); autoLearnDecideTask1.duplicateOutputFields(autoLearnDecideEvent.getParameterMap()); autoLearnDecideTask1 - .setTaskLogic(new AxTaskLogic(autoLearnDecideTask1.getKey(), "TaskLogic", "MVEL", logicReader)); + .setTaskLogic(new AxTaskLogic(autoLearnDecideTask1.getKey(), TASK_LOGIC, "MVEL", logicReader)); - final AxTask autoLearnDecideTask2 = new AxTask(new AxArtifactKey("AutoLearnDecideTask2", "0.0.1")); + final AxTask autoLearnDecideTask2 = new AxTask(new AxArtifactKey("AutoLearnDecideTask2", DEFAULT_VERSION)); autoLearnDecideTask2.duplicateInputFields(autoLearnEstablishEvent.getParameterMap()); autoLearnDecideTask2.duplicateOutputFields(autoLearnDecideEvent.getParameterMap()); autoLearnDecideTask2 - .setTaskLogic(new AxTaskLogic(autoLearnDecideTask2.getKey(), "TaskLogic", "MVEL", logicReader)); + .setTaskLogic(new AxTaskLogic(autoLearnDecideTask2.getKey(), TASK_LOGIC, "MVEL", logicReader)); - final AxTask autoLearnDecideTask3 = new AxTask(new AxArtifactKey("AutoLearnDecideTask3", "0.0.1")); + final AxTask autoLearnDecideTask3 = new AxTask(new AxArtifactKey("AutoLearnDecideTask3", DEFAULT_VERSION)); autoLearnDecideTask3.duplicateInputFields(autoLearnEstablishEvent.getParameterMap()); autoLearnDecideTask3.duplicateOutputFields(autoLearnDecideEvent.getParameterMap()); autoLearnDecideTask3 - .setTaskLogic(new AxTaskLogic(autoLearnDecideTask3.getKey(), "TaskLogic", "MVEL", logicReader)); + .setTaskLogic(new AxTaskLogic(autoLearnDecideTask3.getKey(), TASK_LOGIC, "MVEL", logicReader)); - final AxTask autoLearnDecideTask4 = new AxTask(new AxArtifactKey("AutoLearnDecideTask4", "0.0.1")); + final AxTask autoLearnDecideTask4 = new AxTask(new AxArtifactKey("AutoLearnDecideTask4", DEFAULT_VERSION)); autoLearnDecideTask4.duplicateInputFields(autoLearnEstablishEvent.getParameterMap()); autoLearnDecideTask4.duplicateOutputFields(autoLearnDecideEvent.getParameterMap()); autoLearnDecideTask4 - .setTaskLogic(new AxTaskLogic(autoLearnDecideTask4.getKey(), "TaskLogic", "MVEL", logicReader)); + .setTaskLogic(new AxTaskLogic(autoLearnDecideTask4.getKey(), TASK_LOGIC, "MVEL", logicReader)); - final AxTask autoLearnDecideTask5 = new AxTask(new AxArtifactKey("AutoLearnDecideTask5", "0.0.1")); + final AxTask autoLearnDecideTask5 = new AxTask(new AxArtifactKey("AutoLearnDecideTask5", DEFAULT_VERSION)); autoLearnDecideTask5.duplicateInputFields(autoLearnEstablishEvent.getParameterMap()); autoLearnDecideTask5.duplicateOutputFields(autoLearnDecideEvent.getParameterMap()); autoLearnDecideTask5 - .setTaskLogic(new AxTaskLogic(autoLearnDecideTask5.getKey(), "TaskLogic", "MVEL", logicReader)); + .setTaskLogic(new AxTaskLogic(autoLearnDecideTask5.getKey(), TASK_LOGIC, "MVEL", logicReader)); - final AxTask autoLearnDecideTask6 = new AxTask(new AxArtifactKey("AutoLearnDecideTask6", "0.0.1")); + final AxTask autoLearnDecideTask6 = new AxTask(new AxArtifactKey("AutoLearnDecideTask6", DEFAULT_VERSION)); autoLearnDecideTask6.duplicateInputFields(autoLearnEstablishEvent.getParameterMap()); autoLearnDecideTask6.duplicateOutputFields(autoLearnDecideEvent.getParameterMap()); autoLearnDecideTask6 - .setTaskLogic(new AxTaskLogic(autoLearnDecideTask6.getKey(), "TaskLogic", "MVEL", logicReader)); + .setTaskLogic(new AxTaskLogic(autoLearnDecideTask6.getKey(), TASK_LOGIC, "MVEL", logicReader)); logicReader.setDefaultLogic("DefaultAutoLearnTask_Logic"); - final AxTask autoLearnActTask = new AxTask(new AxArtifactKey("AutoLearnActTask", "0.0.1")); + final AxTask autoLearnActTask = new AxTask(new AxArtifactKey("AutoLearnActTask", DEFAULT_VERSION)); autoLearnActTask.duplicateInputFields(autoLearnDecideEvent.getParameterMap()); autoLearnActTask.duplicateOutputFields(autoLearnActEvent.getParameterMap()); - autoLearnActTask.setTaskLogic(new AxTaskLogic(autoLearnActTask.getKey(), "TaskLogic", "MVEL", logicReader)); + autoLearnActTask.setTaskLogic(new AxTaskLogic(autoLearnActTask.getKey(), TASK_LOGIC, "MVEL", logicReader)); - final AxTasks autoLearnTasks = new AxTasks(new AxArtifactKey("AutoLearnTasks", "0.0.1")); + final AxTasks autoLearnTasks = new AxTasks(new AxArtifactKey("AutoLearnTasks", DEFAULT_VERSION)); autoLearnTasks.getTaskMap().put(autoLearnMatchTask.getKey(), autoLearnMatchTask); autoLearnTasks.getTaskMap().put(autoLearnEstablishTask.getKey(), autoLearnEstablishTask); autoLearnTasks.getTaskMap().put(autoLearnDecideTask0.getKey(), autoLearnDecideTask0); @@ -451,81 +491,81 @@ public class AdaptiveDomainModelFactory { autoLearnTasks.getTaskMap().put(autoLearnActTask.getKey(), autoLearnActTask); // Policies - logicReader.setDefaultLogic("DefaultState_Logic"); + logicReader.setDefaultLogic(DEFAULT_STATE_LOGIC); - final AxPolicy autoLearnPolicy = new AxPolicy(new AxArtifactKey("AutoLearnPolicy", "0.0.1")); + final AxPolicy autoLearnPolicy = new AxPolicy(new AxArtifactKey("AutoLearnPolicy", DEFAULT_VERSION)); autoLearnPolicy.setTemplate("MEDA"); final AxState autoLearnActState = new AxState(new AxReferenceKey(autoLearnPolicy.getKey(), "Act")); autoLearnActState.setTrigger(autoLearnDecideEvent.getKey()); - final AxStateOutput alAct2Out = - new AxStateOutput(autoLearnActState.getKey(), AxReferenceKey.getNullKey(), autoLearnActEvent.getKey()); + final AxStateOutput alAct2Out = new AxStateOutput(autoLearnActState.getKey(), AxReferenceKey.getNullKey(), + autoLearnActEvent.getKey()); autoLearnActState.getStateOutputs().put(alAct2Out.getKey().getLocalName(), alAct2Out); - autoLearnActState.setTaskSelectionLogic( - new AxTaskSelectionLogic(autoLearnActState.getKey(), "TaskSelectionLogic", "MVEL", logicReader)); + autoLearnActState.setTaskSelectionLogic(new AxTaskSelectionLogic(autoLearnActState.getKey(), + TASK_SELECTION_LOGIC, "MVEL", logicReader)); autoLearnActState.setDefaultTask(autoLearnActTask.getKey()); autoLearnActState.getTaskReferences().put(autoLearnActTask.getKey(), - new AxStateTaskReference(autoLearnActState.getKey(), autoLearnActTask.getKey(), - AxStateTaskOutputType.DIRECT, alAct2Out.getKey())); + new AxStateTaskReference(autoLearnActState.getKey(), autoLearnActTask.getKey(), + AxStateTaskOutputType.DIRECT, alAct2Out.getKey())); logicReader.setDefaultLogic(null); - final AxState autoLearnDecideState = new AxState(new AxReferenceKey(autoLearnPolicy.getKey(), "Decide")); + final AxState autoLearnDecideState = new AxState(new AxReferenceKey(autoLearnPolicy.getKey(), DECIDE)); autoLearnDecideState.setTrigger(autoLearnEstablishEvent.getKey()); final AxStateOutput alDec2Act = new AxStateOutput(autoLearnDecideState.getKey(), autoLearnActState.getKey(), - autoLearnDecideEvent.getKey()); + autoLearnDecideEvent.getKey()); autoLearnDecideState.getStateOutputs().put(alDec2Act.getKey().getLocalName(), alDec2Act); autoLearnDecideState.getContextAlbumReferences().add(autoLearnAlbum.getKey()); - autoLearnDecideState.setTaskSelectionLogic( - new AxTaskSelectionLogic(autoLearnDecideState.getKey(), "TaskSelectionLogic", "JAVA", logicReader)); + autoLearnDecideState.setTaskSelectionLogic(new AxTaskSelectionLogic(autoLearnDecideState.getKey(), + TASK_SELECTION_LOGIC, "JAVA", logicReader)); autoLearnDecideState.setDefaultTask(autoLearnDecideTask0.getKey()); autoLearnDecideState.getTaskReferences().put(autoLearnDecideTask0.getKey(), - new AxStateTaskReference(autoLearnDecideState.getKey(), autoLearnDecideTask0.getKey(), - AxStateTaskOutputType.DIRECT, alDec2Act.getKey())); + new AxStateTaskReference(autoLearnDecideState.getKey(), autoLearnDecideTask0.getKey(), + AxStateTaskOutputType.DIRECT, alDec2Act.getKey())); autoLearnDecideState.getTaskReferences().put(autoLearnDecideTask1.getKey(), - new AxStateTaskReference(autoLearnDecideState.getKey(), autoLearnDecideTask1.getKey(), - AxStateTaskOutputType.DIRECT, alDec2Act.getKey())); + new AxStateTaskReference(autoLearnDecideState.getKey(), autoLearnDecideTask1.getKey(), + AxStateTaskOutputType.DIRECT, alDec2Act.getKey())); autoLearnDecideState.getTaskReferences().put(autoLearnDecideTask2.getKey(), - new AxStateTaskReference(autoLearnDecideState.getKey(), autoLearnDecideTask2.getKey(), - AxStateTaskOutputType.DIRECT, alDec2Act.getKey())); + new AxStateTaskReference(autoLearnDecideState.getKey(), autoLearnDecideTask2.getKey(), + AxStateTaskOutputType.DIRECT, alDec2Act.getKey())); autoLearnDecideState.getTaskReferences().put(autoLearnDecideTask3.getKey(), - new AxStateTaskReference(autoLearnDecideState.getKey(), autoLearnDecideTask3.getKey(), - AxStateTaskOutputType.DIRECT, alDec2Act.getKey())); + new AxStateTaskReference(autoLearnDecideState.getKey(), autoLearnDecideTask3.getKey(), + AxStateTaskOutputType.DIRECT, alDec2Act.getKey())); autoLearnDecideState.getTaskReferences().put(autoLearnDecideTask4.getKey(), - new AxStateTaskReference(autoLearnDecideState.getKey(), autoLearnDecideTask4.getKey(), - AxStateTaskOutputType.DIRECT, alDec2Act.getKey())); + new AxStateTaskReference(autoLearnDecideState.getKey(), autoLearnDecideTask4.getKey(), + AxStateTaskOutputType.DIRECT, alDec2Act.getKey())); autoLearnDecideState.getTaskReferences().put(autoLearnDecideTask5.getKey(), - new AxStateTaskReference(autoLearnDecideState.getKey(), autoLearnDecideTask5.getKey(), - AxStateTaskOutputType.DIRECT, alDec2Act.getKey())); + new AxStateTaskReference(autoLearnDecideState.getKey(), autoLearnDecideTask5.getKey(), + AxStateTaskOutputType.DIRECT, alDec2Act.getKey())); autoLearnDecideState.getTaskReferences().put(autoLearnDecideTask6.getKey(), - new AxStateTaskReference(autoLearnDecideState.getKey(), autoLearnDecideTask6.getKey(), - AxStateTaskOutputType.DIRECT, alDec2Act.getKey())); + new AxStateTaskReference(autoLearnDecideState.getKey(), autoLearnDecideTask6.getKey(), + AxStateTaskOutputType.DIRECT, alDec2Act.getKey())); - logicReader.setDefaultLogic("DefaultState_Logic"); + logicReader.setDefaultLogic(DEFAULT_STATE_LOGIC); - final AxState autoLearnEstablishState = new AxState(new AxReferenceKey(autoLearnPolicy.getKey(), "Establish")); + final AxState autoLearnEstablishState = new AxState(new AxReferenceKey(autoLearnPolicy.getKey(), ESTABLISH)); autoLearnEstablishState.setTrigger(autoLearnMatchEvent.getKey()); final AxStateOutput alEst2Dec = new AxStateOutput(autoLearnEstablishState.getKey(), - autoLearnDecideState.getKey(), autoLearnEstablishEvent.getKey()); + autoLearnDecideState.getKey(), autoLearnEstablishEvent.getKey()); autoLearnEstablishState.getStateOutputs().put(alEst2Dec.getKey().getLocalName(), alEst2Dec); - autoLearnEstablishState.setTaskSelectionLogic( - new AxTaskSelectionLogic(autoLearnEstablishState.getKey(), "TaskSelectionLogic", "MVEL", logicReader)); + autoLearnEstablishState.setTaskSelectionLogic(new AxTaskSelectionLogic(autoLearnEstablishState.getKey(), + TASK_SELECTION_LOGIC, "MVEL", logicReader)); autoLearnEstablishState.setDefaultTask(autoLearnEstablishTask.getKey()); autoLearnEstablishState.getTaskReferences().put(autoLearnEstablishTask.getKey(), - new AxStateTaskReference(autoLearnEstablishState.getKey(), autoLearnEstablishTask.getKey(), - AxStateTaskOutputType.DIRECT, alEst2Dec.getKey())); + new AxStateTaskReference(autoLearnEstablishState.getKey(), autoLearnEstablishTask.getKey(), + AxStateTaskOutputType.DIRECT, alEst2Dec.getKey())); - final AxState autoLearnMatchState = new AxState(new AxReferenceKey(autoLearnPolicy.getKey(), "Match")); + final AxState autoLearnMatchState = new AxState(new AxReferenceKey(autoLearnPolicy.getKey(), MATCH)); autoLearnMatchState.setTrigger(autoLearnTriggerEvent.getKey()); final AxStateOutput alMat2Est = new AxStateOutput(autoLearnMatchState.getKey(), - autoLearnEstablishState.getKey(), autoLearnMatchEvent.getKey()); + autoLearnEstablishState.getKey(), autoLearnMatchEvent.getKey()); autoLearnMatchState.getStateOutputs().put(alMat2Est.getKey().getLocalName(), alMat2Est); - autoLearnMatchState.setTaskSelectionLogic( - new AxTaskSelectionLogic(autoLearnMatchState.getKey(), "TaskSelectionLogic", "MVEL", logicReader)); + autoLearnMatchState.setTaskSelectionLogic(new AxTaskSelectionLogic(autoLearnMatchState.getKey(), + TASK_SELECTION_LOGIC, "MVEL", logicReader)); autoLearnMatchState.setDefaultTask(autoLearnMatchTask.getKey()); autoLearnMatchState.getTaskReferences().put(autoLearnMatchTask.getKey(), - new AxStateTaskReference(autoLearnMatchState.getKey(), autoLearnMatchTask.getKey(), - AxStateTaskOutputType.DIRECT, alMat2Est.getKey())); + new AxStateTaskReference(autoLearnMatchState.getKey(), autoLearnMatchTask.getKey(), + AxStateTaskOutputType.DIRECT, alMat2Est.getKey())); autoLearnPolicy.setFirstState(autoLearnMatchState.getKey().getLocalName()); autoLearnPolicy.getStateMap().put(autoLearnMatchState.getKey().getLocalName(), autoLearnMatchState); @@ -533,13 +573,13 @@ public class AdaptiveDomainModelFactory { autoLearnPolicy.getStateMap().put(autoLearnDecideState.getKey().getLocalName(), autoLearnDecideState); autoLearnPolicy.getStateMap().put(autoLearnActState.getKey().getLocalName(), autoLearnActState); - final AxPolicies autoLearnPolicies = new AxPolicies(new AxArtifactKey("AutoLearnPolicies", "0.0.1")); + final AxPolicies autoLearnPolicies = new AxPolicies(new AxArtifactKey("AutoLearnPolicies", DEFAULT_VERSION)); autoLearnPolicies.getPolicyMap().put(autoLearnPolicy.getKey(), autoLearnPolicy); - final AxKeyInformation keyInformation = - new AxKeyInformation(new AxArtifactKey("AutoLearnKeyInformation", "0.0.1")); - final AxPolicyModel autoLearnPolicyModel = - new AxPolicyModel(new AxArtifactKey("AutoLearnPolicyModel", "0.0.1")); + final AxKeyInformation keyInformation = new AxKeyInformation( + new AxArtifactKey("AutoLearnKeyInformation", DEFAULT_VERSION)); + final AxPolicyModel autoLearnPolicyModel = new AxPolicyModel( + new AxArtifactKey("AutoLearnPolicyModel", DEFAULT_VERSION)); autoLearnPolicyModel.setPolicies(autoLearnPolicies); autoLearnPolicyModel.setEvents(autoLearnEvents); autoLearnPolicyModel.setTasks(autoLearnTasks); diff --git a/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/AdaptiveDomainModelSaver.java b/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/AdaptiveDomainModelSaver.java index 9c860e3c8..4949edd30 100644 --- a/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/AdaptiveDomainModelSaver.java +++ b/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/AdaptiveDomainModelSaver.java @@ -23,6 +23,8 @@ package org.onap.policy.apex.examples.adaptive.model; import org.onap.policy.apex.model.basicmodel.concepts.ApexException; import org.onap.policy.apex.model.basicmodel.handling.ApexModelSaver; import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; +import org.slf4j.ext.XLogger; +import org.slf4j.ext.XLoggerFactory; /** * This class saves sample domain models to disk in XML and JSON format. @@ -30,10 +32,15 @@ import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; * @author Liam Fallon (liam.fallon@ericsson.com) */ public final class AdaptiveDomainModelSaver { + // Logger for this class + private static final XLogger LOGGER = XLoggerFactory.getXLogger(AdaptiveDomainModelSaver.class); + /** * Private default constructor to prevent subclassing. */ - private AdaptiveDomainModelSaver() {} + private AdaptiveDomainModelSaver() { + // Prevent subclassing + } /** * Write the AADM model to args[0]. @@ -43,21 +50,21 @@ public final class AdaptiveDomainModelSaver { */ public static void main(final String[] args) throws ApexException { if (args.length != 1) { - System.err.println("usage: " + AdaptiveDomainModelSaver.class.getCanonicalName() + " modelDirectory"); + LOGGER.error("usage: " + AdaptiveDomainModelSaver.class.getCanonicalName() + " modelDirectory"); return; } // Save Anomaly Detection model final AxPolicyModel adPolicyModel = new AdaptiveDomainModelFactory().getAnomalyDetectionPolicyModel(); final ApexModelSaver<AxPolicyModel> adModelSaver = - new ApexModelSaver<>(AxPolicyModel.class, adPolicyModel, args[0]); + new ApexModelSaver<>(AxPolicyModel.class, adPolicyModel, args[0]); adModelSaver.apexModelWriteJson(); adModelSaver.apexModelWriteXml(); // Save Auto Learn model final AxPolicyModel alPolicyModel = new AdaptiveDomainModelFactory().getAutoLearnPolicyModel(); final ApexModelSaver<AxPolicyModel> alModelSaver = - new ApexModelSaver<>(AxPolicyModel.class, alPolicyModel, args[0]); + new ApexModelSaver<>(AxPolicyModel.class, alPolicyModel, args[0]); alModelSaver.apexModelWriteJson(); alModelSaver.apexModelWriteXml(); } diff --git a/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/java/AnomalyDetectionPolicy_Decide_TaskSelectionLogic.java b/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/java/AnomalyDetectionPolicyDecideTaskSelectionLogic.java index 2a654c38e..5ee114e0e 100644 --- a/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/java/AnomalyDetectionPolicy_Decide_TaskSelectionLogic.java +++ b/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/java/AnomalyDetectionPolicyDecideTaskSelectionLogic.java @@ -34,13 +34,15 @@ import org.onap.policy.apex.model.basicmodel.concepts.ApexException; import org.slf4j.Logger; /** - * The Class AnomalyDetectionPolicy_Decide_TaskSelectionLogic. + * The Class AnomalyDetectionPolicyDecideTaskSelectionLogic. */ -// CHECKSTYLE:OFF: checkstyle:className -public class AnomalyDetectionPolicy_Decide_TaskSelectionLogic { - // CHECKSTYLE:ON: checkstyle:className - +public class AnomalyDetectionPolicyDecideTaskSelectionLogic { private Logger logger; + + // Recurring string constants + private static final String ANOMALY_DETECTION_ALBUM = "AnomalyDetectionAlbum"; + private static final String ANOMALY_DETECTION = "AnomalyDetection"; + // configuration private static final double ANOMALY_SENSITIVITY = 0.05; private static final int FREQUENCY = 360; @@ -73,8 +75,10 @@ public class AnomalyDetectionPolicy_Decide_TaskSelectionLogic { public boolean getTask(final TaskSelectionExecutionContext executor) { executionContext = executor; logger = executionContext.logger; - logger.debug(executor.subject.getId()); - logger.debug(executor.inFields.toString()); + String id = executor.subject.getId(); + logger.debug(id); + String inFields = executor.inFields.toString(); + logger.debug(inFields); final double now = (Double) (executor.inFields.get("MonitoredValue")); final Integer iteration = (Integer) (executor.inFields.get("Iteration")); // get the double[forecastedValue, AnomalyScore, AnomalyProbability] @@ -111,18 +115,18 @@ public class AnomalyDetectionPolicy_Decide_TaskSelectionLogic { */ public double[] forecastingAndAnomaly(final double value) { try { - executionContext.getContextAlbum("AnomalyDetectionAlbum").lockForWriting("AnomalyDetection"); + executionContext.getContextAlbum(ANOMALY_DETECTION_ALBUM).lockForWriting(ANOMALY_DETECTION); } catch (final ApexException e) { logger.error("Failed to acquire write lock on \"AnomalyDetection\" context", e); - return null; + return new double[0]; } // Get the context object AnomalyDetection anomalyDetection = - (AnomalyDetection) executionContext.getContextAlbum("AnomalyDetectionAlbum").get("AnomalyDetection"); + (AnomalyDetection) executionContext.getContextAlbum(ANOMALY_DETECTION_ALBUM).get(ANOMALY_DETECTION); if (anomalyDetection == null) { anomalyDetection = new AnomalyDetection(); - executionContext.getContextAlbum("AnomalyDetectionAlbum").put("AnomalyDetection", anomalyDetection); + executionContext.getContextAlbum(ANOMALY_DETECTION_ALBUM).put(ANOMALY_DETECTION, anomalyDetection); } // Check the lists are initialized @@ -175,10 +179,10 @@ public class AnomalyDetectionPolicy_Decide_TaskSelectionLogic { // CHECKSTYLE:ON: checkstyle:magicNumber try { - executionContext.getContextAlbum("AnomalyDetectionAlbum").unlockForWriting("AnomalyDetection"); + executionContext.getContextAlbum(ANOMALY_DETECTION_ALBUM).unlockForWriting(ANOMALY_DETECTION); } catch (final ApexException e) { logger.error("Failed to release write lock on \"AnomalyDetection\" context", e); - return null; + return new double[0]; } return new double[] {forecastedValue, anomalyScore, anomalyProbability}; diff --git a/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/java/AutoLearnPolicy_Decide_TaskSelectionLogic.java b/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/java/AutoLearnPolicyDecideTaskSelectionLogic.java index 23d4e2486..d60b04c00 100644 --- a/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/java/AutoLearnPolicy_Decide_TaskSelectionLogic.java +++ b/examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/java/AutoLearnPolicyDecideTaskSelectionLogic.java @@ -29,11 +29,13 @@ import org.onap.policy.apex.core.engine.executor.context.TaskSelectionExecutionC import org.onap.policy.apex.examples.adaptive.concepts.AutoLearn; /** - * The Class AutoLearnPolicy_Decide_TaskSelectionLogic. + * The Class AutoLearnPolicyDecideTaskSelectionLogic. */ -// CHECKSTYLE:OFF: checkstyle:typeName -public class AutoLearnPolicy_Decide_TaskSelectionLogic { - // CHECKSTYLE:ON: checkstyle:typeName +public class AutoLearnPolicyDecideTaskSelectionLogic { + // Recurring string constants + private static final String AUTO_LEARN_ALBUM = "AutoLearnAlbum"; + private static final String AUTO_LEARN = "AutoLearn"; + private static final Random RAND = new Random(System.currentTimeMillis()); private static final double WANT = 50.0; private int size; @@ -45,20 +47,24 @@ public class AutoLearnPolicy_Decide_TaskSelectionLogic { * @return the task */ public boolean getTask(final TaskSelectionExecutionContext executor) { - executor.logger.debug(executor.subject.getId()); - executor.logger.debug(executor.inFields.toString()); + String idString = executor.subject.getId(); + executor.logger.debug(idString); + + String inFieldsString = executor.inFields.toString(); + executor.logger.debug(inFieldsString); + final List<String> tasks = executor.subject.getTaskNames(); size = tasks.size(); try { - executor.getContextAlbum("AutoLearnAlbum").lockForWriting("AutoLearn"); + executor.getContextAlbum(AUTO_LEARN_ALBUM).lockForWriting(AUTO_LEARN); } catch (final ContextException e) { executor.logger.error("Failed to acquire write lock on \"autoLearn\" context", e); return false; } // Get the context object - AutoLearn autoLearn = (AutoLearn) executor.getContextAlbum("AutoLearnAlbum").get("AutoLearn"); + AutoLearn autoLearn = (AutoLearn) executor.getContextAlbum(AUTO_LEARN_ALBUM).get(AUTO_LEARN); if (autoLearn == null) { autoLearn = new AutoLearn(); } @@ -73,10 +79,10 @@ public class AutoLearnPolicy_Decide_TaskSelectionLogic { final int option = getOption(diff, autoLearn); learn(option, diff, autoLearn); - executor.getContextAlbum("AutoLearnAlbum").put("AutoLearnAlbum", autoLearn); + executor.getContextAlbum(AUTO_LEARN_ALBUM).put(AUTO_LEARN_ALBUM, autoLearn); try { - executor.getContextAlbum("AutoLearnAlbum").unlockForWriting("AutoLearn"); + executor.getContextAlbum(AUTO_LEARN_ALBUM).unlockForWriting(AUTO_LEARN); } catch (final ContextException e) { executor.logger.error("Failed to acquire write lock on \"autoLearn\" context", e); return false; |