summaryrefslogtreecommitdiffstats
path: root/model/basic-model/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'model/basic-model/src/main')
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/ApexConceptException.java49
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/ApexException.java111
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/ApexRuntimeException.java93
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxArtifactKey.java344
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConcept.java137
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConceptGetter.java77
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConceptGetterImpl.java143
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKey.java105
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfo.java317
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInformation.java389
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyUse.java221
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxModel.java423
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxReferenceKey.java527
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxToscaPolicyProcessingStatus.java46
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxValidationMessage.java104
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxValidationResult.java150
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/package-info.java27
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelCreator.java41
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelCustomGsonMapAdapter.java118
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelCustomGsonRefereceKeyAdapter.java50
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelException.java51
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelFileWriter.java99
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelReader.java169
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelSaver.java80
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelStringWriter.java94
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelWriter.java148
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/package-info.java21
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/package-info.java31
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/service/ModelService.java108
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/service/package-info.java26
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/test/TestApexModel.java259
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/test/TestApexModelCreator.java62
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/test/package-info.java26
-rw-r--r--model/basic-model/src/main/resources/doc/JDBCPropertiesExamples.txt35
34 files changed, 0 insertions, 4681 deletions
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/ApexConceptException.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/ApexConceptException.java
deleted file mode 100644
index d62818dc8..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/ApexConceptException.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. 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=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.concepts;
-
-/**
- * This class is an exception thrown on Apex Concept errors.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class ApexConceptException extends ApexException {
- private static final long serialVersionUID = -8507246953751956974L;
-
- /**
- * Instantiates a new apex concept exception.
- *
- * @param message the message on the exception
- */
- public ApexConceptException(final String message) {
- super(message);
- }
-
- /**
- * Instantiates a new apex concept exception.
- *
- * @param message the message on the exception
- * @param exception the exception that caused this Apex exception
- */
- public ApexConceptException(final String message, final Exception exception) {
- super(message, exception);
- }
-}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/ApexException.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/ApexException.java
deleted file mode 100644
index 2eca2f783..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/ApexException.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * 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=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.concepts;
-
-/**
- * This class is a base exception from which all Apex exceptions are sub classes.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class ApexException extends Exception {
- private static final long serialVersionUID = -8507246953751956974L;
-
- // The object on which the exception was thrown
- private final transient Object object;
-
- /**
- * Instantiates a new apex exception.
- *
- * @param message the message on the exception
- */
- public ApexException(final String message) {
- this(message, null);
- }
-
- /**
- * Instantiates a new apex exception.
- *
- * @param message the message on the exception
- * @param object the object that the exception was thrown on
- */
- public ApexException(final String message, final Object object) {
- super(message);
- this.object = object;
- }
-
- /**
- * Instantiates a new apex exception.
- *
- * @param message the message on the exception
- * @param exception the exception that caused this Apex exception
- */
- public ApexException(final String message, final Exception exception) {
- this(message, exception, null);
- }
-
- /**
- * Instantiates a new apex exception.
- *
- * @param message the message on the exception
- * @param exception the exception that caused this Apex exception
- * @param object the object that the exception was thrown on
- */
- public ApexException(final String message, final Exception exception, final Object object) {
- super(message, exception);
- this.object = object;
- }
-
- /**
- * Get the message from this exception and its causes.
- *
- * @return the cascaded messages from this exception and the exceptions that caused it
- */
- public String getCascadedMessage() {
- return buildCascadedMessage(this);
- }
-
- /**
- * Build a cascaded message from an exception and all its nested exceptions.
- * @param throwable the top level exception
- * @return cascaded message string
- */
- public static String buildCascadedMessage(Throwable throwable) {
- final var builder = new StringBuilder();
- builder.append(throwable.getMessage());
-
- for (var t = throwable; t != null; t = t.getCause()) {
- builder.append("\ncaused by: ");
- builder.append(t.getMessage());
- }
-
- return builder.toString();
- }
-
- /**
- * Get the object on which the exception was thrown.
- *
- * @return The object on which the exception was thrown
- */
- public Object getObject() {
- return object;
- }
-}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/ApexRuntimeException.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/ApexRuntimeException.java
deleted file mode 100644
index b4240ad0f..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/ApexRuntimeException.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. 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=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.concepts;
-
-/**
- * This class is a base run time exception from which all Apex run time exceptions are sub classes.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class ApexRuntimeException extends RuntimeException {
- private static final long serialVersionUID = -8507246953751956974L;
-
- // The object on which the exception was thrown
- private final transient Object object;
-
- /**
- * Instantiates a new apex runtime exception.
- *
- * @param message the message on the exception
- */
- public ApexRuntimeException(final String message) {
- this(message, null);
- }
-
- /**
- * Instantiates a new apex runtime exception.
- *
- * @param message the message on the exception
- * @param object the object that the exception was thrown on
- */
- public ApexRuntimeException(final String message, final Object object) {
- super(message);
- this.object = object;
- }
-
- /**
- * Instantiates a new apex runtime exception.
- *
- * @param message the message on the exception
- * @param exception the exception that caused this Apex exception
- */
- public ApexRuntimeException(final String message, final Exception exception) {
- this(message, exception, null);
- }
-
- /**
- * Instantiates a new apex runtime exception.
- *
- * @param message the message on the exception
- * @param exception the exception that caused this Apex exception
- * @param object the object that the exception was thrown on
- */
- public ApexRuntimeException(final String message, final Exception exception, final Object object) {
- super(message, exception);
- this.object = object;
- }
-
- /**
- * Get the message from this exception and its causes.
- *
- * @return the message of this exception and all the exceptions that caused this exception
- */
- public String getCascadedMessage() {
- return ApexException.buildCascadedMessage(this);
- }
-
- /**
- * Get the object on which the exception was thrown.
- *
- * @return The object
- */
- public Object getObject() {
- return object;
- }
-}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxArtifactKey.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxArtifactKey.java
deleted file mode 100644
index 1efe83db8..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxArtifactKey.java
+++ /dev/null
@@ -1,344 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2022 Nordix Foundation.
- * ================================================================================
- * 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=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.concepts;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
-import org.onap.policy.common.utils.validation.Assertions;
-
-/**
- * An artifact key uniquely identifies every first order entity in the system. Every first order concept in the system
- * must have an {@link AxArtifactKey} to identify it. Concepts that are wholly contained in another concept are
- * identified using a {@link AxReferenceKey} key.
- *
- * <p>Key validation checks that the name and version fields match the NAME_REGEXP and VERSION_REGEXP
- * regular expressions respectively.
- */
-public class AxArtifactKey extends AxKey {
- private static final long serialVersionUID = 8932717618579392561L;
-
- private static final String NAME_TOKEN = "name";
- private static final String VERSION_TOKEN = "version";
-
- private String name;
- private String version;
-
- /**
- * The default constructor creates a null artifact key.
- */
- public AxArtifactKey() {
- this(NULL_KEY_NAME, NULL_KEY_VERSION);
- }
-
- /**
- * Copy constructor.
- *
- * @param copyConcept the concept to copy from
- */
- public AxArtifactKey(final AxArtifactKey copyConcept) {
- super(copyConcept);
- }
-
- /**
- * Constructor to create a key with the specified name and version.
- *
- * @param name the key name
- * @param version the key version
- */
- public AxArtifactKey(final String name, final String version) {
- super();
- this.name = Assertions.validateStringParameter(NAME_TOKEN, name, NAME_REGEXP);
- this.version = Assertions.validateStringParameter(VERSION_TOKEN, version, VERSION_REGEXP);
- }
-
- /**
- * Constructor to create a key using the key and version from the specified key ID.
- *
- * @param id the key ID in a format that respects the KEY_ID_REGEXP
- */
- public AxArtifactKey(final String id) {
- Assertions.argumentNotNull(id, "id may not be null");
-
- // Check the incoming ID is valid
- Assertions.validateStringParameter("id", id, KEY_ID_REGEXP);
-
- // Split on colon, if the id passes the regular expression test above
- // it'll have just one colon separating the name and version
- // No need for range checks or size checks on the array
- final String[] nameVersionArray = id.split(":");
-
- // Return the new key
- name = Assertions.validateStringParameter(NAME_TOKEN, nameVersionArray[0], NAME_REGEXP);
- version = Assertions.validateStringParameter(VERSION_TOKEN, nameVersionArray[1], VERSION_REGEXP);
- }
-
- /**
- * Get a null artifact key.
- *
- * @return a null artifact key
- */
- public static final AxArtifactKey getNullKey() {
- return new AxArtifactKey(AxKey.NULL_KEY_NAME, AxKey.NULL_KEY_VERSION);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public AxArtifactKey getKey() {
- return this;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public List<AxKey> getKeys() {
- final List<AxKey> keyList = new ArrayList<>();
- keyList.add(getKey());
- return keyList;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public String getId() {
- return name + ':' + version;
- }
-
- /**
- * Gets the key name.
- *
- * @return the key name
- */
- public String getName() {
- return name;
- }
-
- /**
- * Sets the key name.
- *
- * @param name the key name
- */
- public void setName(final String name) {
- this.name = Assertions.validateStringParameter(NAME_TOKEN, name, NAME_REGEXP);
- }
-
- /**
- * Gets the key version.
- *
- * @return the key version
- */
- public String getVersion() {
- return version;
- }
-
- /**
- * Sets the key version.
- *
- * @param version the key version
- */
- public void setVersion(final String version) {
- this.version = Assertions.validateStringParameter(VERSION_TOKEN, version, VERSION_REGEXP);
- }
-
- /**
- * Check if the key is IDENTICAL to a null key.
- *
- * @return true, if the key is IDENTICAL to a null key
- */
- public boolean isNullKey() {
- return this.getCompatibility(AxArtifactKey.getNullKey()).equals(AxKey.Compatibility.IDENTICAL);
- }
-
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public AxKey.Compatibility getCompatibility(final AxKey otherKey) {
- if (!(otherKey instanceof AxArtifactKey)) {
- return Compatibility.DIFFERENT;
- }
- final AxArtifactKey otherArtifactKey = (AxArtifactKey) otherKey;
-
- if (this.equals(otherArtifactKey)) {
- return Compatibility.IDENTICAL;
- }
- if (!this.getName().equals(otherArtifactKey.getName())) {
- return Compatibility.DIFFERENT;
- }
-
- final String[] thisVersionArray = getVersion().split("\\.");
- final String[] otherVersionArray = otherArtifactKey.getVersion().split("\\.");
-
- // There must always be at least one element in each version
- if (!thisVersionArray[0].equals(otherVersionArray[0])) {
- return Compatibility.MAJOR;
- }
-
- if (thisVersionArray.length >= 2 && otherVersionArray.length >= 2
- && !thisVersionArray[1].equals(otherVersionArray[1])) {
- return Compatibility.MINOR;
- }
-
- return Compatibility.PATCH;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public boolean isCompatible(final AxKey otherKey) {
- if (!(otherKey instanceof AxArtifactKey)) {
- return false;
- }
- final AxArtifactKey otherArtifactKey = (AxArtifactKey) otherKey;
-
- final var compatibility = this.getCompatibility(otherArtifactKey);
-
- return !(compatibility == Compatibility.DIFFERENT || compatibility == Compatibility.MAJOR);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public AxValidationResult validate(final AxValidationResult result) {
- final var nameValidationErrorMessage = Assertions.getStringParameterValidationMessage(NAME_TOKEN, name,
- NAME_REGEXP);
- if (nameValidationErrorMessage != null) {
- result.addValidationMessage(new AxValidationMessage(this, this.getClass(), ValidationResult.INVALID,
- "name invalid-" + nameValidationErrorMessage));
- }
-
- final var versionValidationErrorMessage = Assertions.getStringParameterValidationMessage(VERSION_TOKEN,
- version, VERSION_REGEXP);
- if (versionValidationErrorMessage != null) {
- result.addValidationMessage(new AxValidationMessage(this, this.getClass(), ValidationResult.INVALID,
- "version invalid-" + versionValidationErrorMessage));
- }
-
- return result;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public void clean() {
- name = Assertions.validateStringParameter(NAME_TOKEN, name, NAME_REGEXP);
- version = Assertions.validateStringParameter(VERSION_TOKEN, version, VERSION_REGEXP);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public String toString() {
- final var builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- builder.append(":(");
- builder.append("name=");
- builder.append(name);
- builder.append(",version=");
- builder.append(version);
- builder.append(")");
- return builder.toString();
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public AxConcept copyTo(final AxConcept target) {
- Assertions.argumentNotNull(target, "target may not be null");
-
- final AxConcept copyObject = target;
- Assertions.instanceOf(copyObject, AxArtifactKey.class);
-
- final AxArtifactKey copy = ((AxArtifactKey) copyObject);
- copy.setName(name);
- copy.setVersion(version);
-
- return copyObject;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public int hashCode() {
- final var prime = 31;
- var result = 1;
- result = prime * result + name.hashCode();
- result = prime * result + version.hashCode();
- return result;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj == null) {
- return false;
- }
- if (this == obj) {
- return true;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
-
- final AxArtifactKey other = (AxArtifactKey) obj;
-
- if (!name.equals(other.name)) {
- return false;
- }
- return version.equals(other.version);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public int compareTo(final AxConcept otherObj) {
- Assertions.argumentNotNull(otherObj, "comparison object may not be null");
-
- if (this == otherObj) {
- return 0;
- }
- if (getClass() != otherObj.getClass()) {
- return this.hashCode() - otherObj.hashCode();
- }
-
- final AxArtifactKey other = (AxArtifactKey) otherObj;
-
- if (!name.equals(other.name)) {
- return name.compareTo(other.name);
- }
- return version.compareTo(other.version);
- }
-}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConcept.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConcept.java
deleted file mode 100644
index 37fe30b33..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConcept.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019,2022 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.
- * 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=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.concepts;
-
-import java.io.Serializable;
-import java.util.List;
-import org.onap.policy.common.utils.validation.Assertions;
-
-/**
- * This class is the base class for all Apex concept classes. It enforces implementation of abstract methods and
- * interfaces on all concepts that are sub-classes of this class.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public abstract class AxConcept implements Serializable, Comparable<AxConcept> {
- private static final long serialVersionUID = -7434939557282697490L;
-
- /**
- * Default constructor.
- */
- protected AxConcept() {
- // Default constructor
- }
-
- /**
- * Copy constructor.
- *
- * @param copyConcept the concept to copy from
- */
- protected AxConcept(final AxConcept copyConcept) {
- Assertions.argumentNotNull(copyConcept, "copy concept may not be null");
- copyConcept.copyTo(this);
- }
-
- /**
- * Gets the key of this concept.
- *
- * @return the concept key
- */
- public abstract AxKey getKey();
-
- /**
- * Gets a list of all keys for this concept and all concepts that are defined or referenced by this concept and its
- * sub-concepts.
- *
- * @return the keys used by this concept and it's contained concepts
- */
- public abstract List<AxKey> getKeys();
-
- /**
- * Validate that this concept is structurally correct.
- *
- * @param result the parameter in which the result of the validation will be returned
- * @return the validation result that was passed in in the @{link result} field with the result of this validation
- * added
- */
- public abstract AxValidationResult validate(AxValidationResult result);
-
- /**
- * Clean this concept, tidy up any superfluous information such as leading and trailing white space.
- */
- public abstract void clean();
-
- /**
- * Builds references used by a concept.
- */
- public void buildReferences() {
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public abstract boolean equals(Object otherObject);
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public abstract String toString();
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public abstract int hashCode();
-
- /**
- * Copy this concept to another object. The target object must have the same class as the source object.
- *
- * @param target the target object to which this object is copied
- * @return the copied object
- */
- public abstract AxConcept copyTo(AxConcept target);
-
- /**
- * Gets the ID string of this concept.
- *
- * @return the ID string of this concept
- */
- public String getId() {
- return getKey().getId();
- }
-
- /**
- * Checks if this key matches the given key ID.
- *
- * @param id the key ID to match against
- * @return true, if this key matches the ID
- */
- public final boolean matchesId(final String id) {
- Assertions.argumentNotNull(id, "id may not be null");
-
- // Check the ID
- return getId().equals(id);
- }
-}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConceptGetter.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConceptGetter.java
deleted file mode 100644
index 0284de48a..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConceptGetter.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. 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=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.concepts;
-
-import java.util.Set;
-
-/**
- * This interface is used to allow get methods to be placed on concepts that have embedded maps.
- *
- * <p>It forces those concepts with maps to implement the get methods specified on this interface as convenience methods
- * to avoid concept users having to use a second level of referencing to access concepts in the the maps.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- * @param <C> the type of concept on which the interface is applied.
- */
-public interface AxConceptGetter<C> {
-
- /**
- * Get the latest version for a concept with the given key.
- *
- * @param conceptKey The key of the concept
- * @return The concept
- */
- C get(AxArtifactKey conceptKey);
-
- /**
- * Get the latest version for a concept with the given key name.
- *
- * @param conceptKeyName The name of the concept
- * @return The concept
- */
- C get(String conceptKeyName);
-
- /**
- * Get the latest version for a concept with the given key name and version.
- *
- * @param conceptKeyName The name of the concept
- * @param conceptKeyVersion The version of the concept
- * @return The concept
- */
- C get(String conceptKeyName, String conceptKeyVersion);
-
- /**
- * Get the all versions for a concept with the given key name.
- *
- * @param conceptKeyName The name of the concept
- * @return The concepts
- */
- Set<C> getAll(String conceptKeyName);
-
- /**
- * Get the all versions for a concept with the given key name and starting version.
- *
- * @param conceptKeyName The name of the concept
- * @param conceptKeyVersion The first version version of the concept to get
- * @return The concepts
- */
- Set<C> getAll(String conceptKeyName, String conceptKeyVersion);
-}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConceptGetterImpl.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConceptGetterImpl.java
deleted file mode 100644
index 9c907da9c..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConceptGetterImpl.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2021 Nordix Foundation.
- * ================================================================================
- * 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=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.concepts;
-
-import java.util.NavigableMap;
-import java.util.Set;
-import java.util.TreeSet;
-import org.onap.policy.common.utils.validation.Assertions;
-
-/**
- * Implements concept getting from navigable maps.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- * @param <C> the type of concept on which the interface implementation is applied.
- */
-public class AxConceptGetterImpl<C> implements AxConceptGetter<C> {
-
- // The map from which to get concepts
- private final NavigableMap<AxArtifactKey, C> conceptMap;
-
- /**
- * Constructor that sets the concept map on which the getter methods in the interface will operate..
- *
- * @param conceptMap the concept map on which the method will operate
- */
- public AxConceptGetterImpl(final NavigableMap<AxArtifactKey, C> conceptMap) {
- this.conceptMap = conceptMap;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public C get(final AxArtifactKey conceptKey) {
- return conceptMap.get(conceptKey);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public C get(final String conceptKeyName) {
- Assertions.argumentNotNull(conceptKeyName, "conceptKeyName may not be null");
-
- // The very fist key that could have this name
- final var lowestArtifactKey = new AxArtifactKey(conceptKeyName, "0.0.1");
-
- // Check if we found a key for our name
- AxArtifactKey foundKey = conceptMap.ceilingKey(lowestArtifactKey);
- if (foundKey == null || !foundKey.getName().equals(conceptKeyName)) {
- return null;
- }
-
- // Look for higher versions of the key
- do {
- final AxArtifactKey nextkey = conceptMap.higherKey(foundKey);
- if (nextkey == null || !nextkey.getName().equals(conceptKeyName)) {
- break;
- }
- foundKey = nextkey;
- } while (true);
-
- return conceptMap.get(foundKey);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public C get(final String conceptKeyName, final String conceptKeyVersion) {
- Assertions.argumentNotNull(conceptKeyName, "conceptKeyName may not be null");
-
- if (conceptKeyVersion != null) {
- return conceptMap.get(new AxArtifactKey(conceptKeyName, conceptKeyVersion));
- } else {
- return this.get(conceptKeyName);
- }
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public Set<C> getAll(final String conceptKeyName) {
- return getAll(conceptKeyName, null);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public Set<C> getAll(final String conceptKeyName, final String conceptKeyVersion) {
- final Set<C> returnSet = new TreeSet<>();
-
- if (conceptKeyName == null) {
- returnSet.addAll(conceptMap.values());
- return returnSet;
- }
-
- // The very fist key that could have this name
- final var lowestArtifactKey = new AxArtifactKey(conceptKeyName, "0.0.1");
- if (conceptKeyVersion != null) {
- lowestArtifactKey.setVersion(conceptKeyVersion);
- }
-
- // Check if we found a key for our name
- AxArtifactKey foundKey = conceptMap.ceilingKey(lowestArtifactKey);
- if (foundKey == null || !foundKey.getName().equals(conceptKeyName)) {
- return returnSet;
- }
- returnSet.add(conceptMap.get(foundKey));
-
- // Look for higher versions of the key
- do {
- foundKey = conceptMap.higherKey(foundKey);
- if (foundKey == null || !foundKey.getName().equals(conceptKeyName)) {
- break;
- }
- returnSet.add(conceptMap.get(foundKey));
- } while (true);
-
- return returnSet;
- }
-}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKey.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKey.java
deleted file mode 100644
index 1b6f0148f..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKey.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*-
- * ============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.
- * 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=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.concepts;
-
-/**
- * The key uniquely identifies every entity in the system. This class is an abstract class to give a common parent for
- * all key types in the system.
- */
-public abstract class AxKey extends AxConcept {
- private static final long serialVersionUID = 6281159885962014041L;
-
- /** Regular expression to specify the structure of key names. */
- public static final String NAME_REGEXP = "[A-Za-z0-9\\-_\\.]+";
-
- /** Regular expression to specify the structure of key versions. */
- public static final String VERSION_REGEXP = "[A-Za-z0-9.]+";
-
- /** Regular expression to specify the structure of key IDs. */
- public static final String KEY_ID_REGEXP = "[A-Za-z0-9\\-_\\.]+:[0-9].[0-9].[0-9]";
-
- /** Specifies the value for names in NULL keys. */
- public static final String NULL_KEY_NAME = "NULL";
-
- /** Specifies the value for versions in NULL keys. */
- public static final String NULL_KEY_VERSION = "0.0.0";
-
- /**
- * This enumeration is returned on key compatibility checks.
- */
- public enum Compatibility {
- /** The keys have different names. */
- DIFFERENT,
- /**
- * The name of the key matches but the Major version number of the keys is different (x in x.y.z do not match).
- */
- MAJOR,
- /**
- * The name of the key matches but the Minor version number of the keys is different (y in x.y.z do not match).
- */
- MINOR,
- /**
- * The name of the key matches but the Patch version number of the keys is different (z in x.y.z do not match).
- */
- PATCH,
- /** The keys match completely. */
- IDENTICAL
- }
-
- /**
- * Default constructor.
- */
- protected AxKey() {
- super();
- }
-
- /**
- * Copy constructor.
- *
- * @param copyConcept the concept to copy from
- */
- protected AxKey(final AxKey copyConcept) {
- super(copyConcept);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public abstract String getId();
-
- /**
- * Return the result of a compatibility check of two keys.
- *
- * @param otherKey the key to check compatibility against
- * @return the compatibility result of the check
- */
- public abstract Compatibility getCompatibility(AxKey otherKey);
-
- /**
- * Check if two keys are compatible, that is the keys are IDENTICAL or have only MINOR, PATCH differences.
- *
- * @param otherKey the key to check compatibility against
- * @return true, if the keys are compatible
- */
- public abstract boolean isCompatible(AxKey otherKey);
-}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfo.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfo.java
deleted file mode 100644
index bd3b18ec9..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfo.java
+++ /dev/null
@@ -1,317 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2022 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.
- * 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=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.concepts;
-
-import com.google.gson.annotations.SerializedName;
-import java.util.List;
-import java.util.Random;
-import java.util.UUID;
-import org.apache.commons.lang3.StringUtils;
-import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
-import org.onap.policy.common.utils.validation.Assertions;
-
-/**
- * The key information on an {@link AxArtifactKey} key in an Apex policy model. Each {@link AxArtifactKey} must have an
- * {@link AxKeyInfo} object. THe information held is the key's UUID and it's description.
- *
- * <p>Validation checks that all fields are defined and that the key is valid. It also observes that descriptions are
- * blank and warns if the UUID is a zero UUID.
- */
-public class AxKeyInfo extends AxConcept {
- private static final long serialVersionUID = -4023935924068914308L;
-
- private static final int UUID_BYTE_LENGTH_16 = 16;
-
- /*
- * This is not used for encryption/security, thus disabling sonar.
- */
- private static final Random sharedRandom = new Random(); // NOSONAR
-
- private AxArtifactKey key;
-
- @SerializedName("UUID")
- private UUID uuid;
-
- private String description;
-
- /**
- * The Default Constructor creates this concept with a NULL artifact key.
- */
- public AxKeyInfo() {
- this(new AxArtifactKey());
- }
-
- /**
- * Copy constructor.
- *
- * @param copyConcept the concept to copy from
- */
- public AxKeyInfo(final AxKeyInfo copyConcept) {
- super(copyConcept);
- }
-
- /**
- * Constructor to create this concept with the specified key.
- *
- * @param key the key of the concept
- */
- public AxKeyInfo(final AxArtifactKey key) {
- this(key, UUID.randomUUID(), "Generated description for concept referred to by key \"" + key.getId() + "\"");
- }
-
- /**
- * Constructor to create this concept and set all its fields.
- *
- * @param key the key of the concept
- * @param uuid the UUID of the concept
- * @param description the description of the concept
- */
- public AxKeyInfo(final AxArtifactKey key, final UUID uuid, final String description) {
- super();
- Assertions.argumentNotNull(key, "key may not be null");
- Assertions.argumentNotNull(uuid, "uuid may not be null");
- Assertions.argumentNotNull(description, "description may not be null");
-
- this.key = key;
- this.uuid = uuid;
- this.description = description.trim();
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public AxArtifactKey getKey() {
- return key;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public List<AxKey> getKeys() {
- return key.getKeys();
- }
-
- /**
- * Sets the key of the concept.
- *
- * @param key the concept key
- */
- public void setKey(final AxArtifactKey key) {
- Assertions.argumentNotNull(key, "key may not be null");
- this.key = key;
- }
-
- /**
- * Gets the UUID of the concept.
- *
- * @return the uuid of the concept
- */
- public UUID getUuid() {
- return uuid;
- }
-
- /**
- * Sets the UUID of the concept.
- *
- * @param uuid the uuid of the concept
- */
- public void setUuid(final UUID uuid) {
- Assertions.argumentNotNull(uuid, "uuid may not be null");
- this.uuid = uuid;
- }
-
- /**
- * Gets the description of the concept.
- *
- * @return the description of the concept
- */
- public String getDescription() {
- return description;
- }
-
- /**
- * Sets the description of the concept.
- *
- * @param description the description of the concept
- */
- public void setDescription(final String description) {
- Assertions.argumentNotNull(description, "description may not be null");
- this.description = description.trim();
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public AxValidationResult validate(final AxValidationResult resultIn) {
- AxValidationResult result = resultIn;
-
- if (key.equals(AxArtifactKey.getNullKey())) {
- result.addValidationMessage(
- new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID, "key is a null key"));
- }
-
- result = key.validate(result);
-
- if (description.trim().length() == 0) {
- result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.OBSERVATION,
- "description is blank"));
- }
-
- if (uuid.equals(new UUID(0, 0))) {
- result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.WARNING,
- "UUID is a zero UUID: " + new UUID(0, 0)));
- }
-
- return result;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public void clean() {
- key.clean();
- description = description.trim();
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public String toString() {
- final var builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- builder.append(":(");
- builder.append("artifactId=");
- builder.append(key);
- builder.append(",uuid=");
- builder.append(uuid);
- builder.append(",description=");
- builder.append(description);
- builder.append(")");
- return builder.toString();
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public AxConcept copyTo(final AxConcept target) {
- Assertions.argumentNotNull(target, "target may not be null");
-
- final Object copyObject = target;
- Assertions.instanceOf(copyObject, AxKeyInfo.class);
-
- final AxKeyInfo copy = ((AxKeyInfo) copyObject);
- copy.setKey(new AxArtifactKey(key));
- copy.setUuid(UUID.fromString(uuid.toString()));
- copy.setDescription(description);
-
- return copy;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public int hashCode() {
- final var prime = 31;
- var result = 1;
- result = prime * result + key.hashCode();
- result = prime * result + uuid.hashCode();
- result = prime * result + description.hashCode();
- return result;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj == null) {
- return false;
- }
- if (this == obj) {
- return true;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
-
- final AxKeyInfo other = (AxKeyInfo) obj;
- if (!key.equals(other.key)) {
- return false;
- }
- if (!uuid.equals(other.uuid)) {
- return false;
- }
- return description.equals(description);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public int compareTo(final AxConcept otherObj) {
- if (otherObj == null) {
- return -1;
- }
- if (this == otherObj) {
- return 0;
- }
- if (getClass() != otherObj.getClass()) {
- return this.hashCode() - otherObj.hashCode();
- }
-
- final AxKeyInfo other = (AxKeyInfo) otherObj;
- if (!key.equals(other.key)) {
- return key.compareTo(other.key);
- }
- if (!uuid.equals(other.uuid)) {
- return uuid.compareTo(other.uuid);
- }
- return description.compareTo(other.description);
- }
-
- /**
- * Generate a reproducible UUID for a given string seed.
- *
- * @param seed the seed
- * @return the uuid
- */
- public static UUID generateReproducibleUuid(final String seed) {
- var random = sharedRandom;
- if (!StringUtils.isEmpty(seed)) {
- /*
- * This is not used for encryption/security, thus disabling sonar.
- */
- random = new Random(seed.hashCode()); // NOSONAR
- }
- final var array = new byte[UUID_BYTE_LENGTH_16];
- random.nextBytes(array);
- return UUID.nameUUIDFromBytes(array);
- }
-}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInformation.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInformation.java
deleted file mode 100644
index 439b2960f..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInformation.java
+++ /dev/null
@@ -1,389 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2022 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.
- * 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=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.concepts;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.NavigableMap;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.TreeSet;
-import java.util.UUID;
-import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
-import org.onap.policy.common.utils.validation.Assertions;
-
-/**
- * The Class AxKeyInformation holds a map of the key information for the entire Apex model. All Apex models
- * {@link AxModel} must have an {@link AxKeyInformation} field. The {@link AxKeyInformation} class implements the helper
- * methods of the {@link AxConceptGetter} interface to allow {@link AxKeyInfo} instances to be retrieved by calling
- * methods directly on this class without referencing the contained map.
- *
- * <p>Validation checks that the key is not null, that the key information map is not empty, that each key and value in
- * the map is defined, that the key in each map entry matches the key if each entry value, and that no duplicate UUIDs
- * exist. Each key information entry is then validated individually.
- */
-public class AxKeyInformation extends AxConcept implements AxConceptGetter<AxKeyInfo> {
- private static final long serialVersionUID = -2746380769017043888L;
-
- private AxArtifactKey key;
- private Map<AxArtifactKey, AxKeyInfo> keyInfoMap;
-
- /**
- * The Default Constructor creates this concept with a null key.
- */
- public AxKeyInformation() {
- this(new AxArtifactKey());
- }
-
- /**
- * Copy constructor.
- *
- * @param copyConcept the concept to copy from
- */
- public AxKeyInformation(final AxKeyInformation copyConcept) {
- super(copyConcept);
- }
-
- /**
- * Constructor to create this concept with the specified key.
- *
- * @param key the key of the concept
- */
- public AxKeyInformation(final AxArtifactKey key) {
- this(key, new TreeMap<>());
- }
-
- /**
- * Constructor to create this concept and set all its fields.
- *
- * @param key the key of the concept
- * @param keyInfoMap the key info map of the concept
- */
- public AxKeyInformation(final AxArtifactKey key, final Map<AxArtifactKey, AxKeyInfo> keyInfoMap) {
- super();
- Assertions.argumentNotNull(key, "key may not be null");
- Assertions.argumentNotNull(keyInfoMap, "keyInfoMap may not be null");
-
- this.key = key;
- this.keyInfoMap = new TreeMap<>();
- this.keyInfoMap.putAll(keyInfoMap);
- }
-
- /**
- * This method generates default key information for all keys found in the concept passed in as a parameter that do
- * not already have key information.
- *
- * @param concept the concept for which to generate key information
- */
- public void generateKeyInfo(final AxConcept concept) {
- for (final AxKey axKey : concept.getKeys()) {
- if (!(axKey instanceof AxArtifactKey)) {
- continue;
- }
-
- final AxArtifactKey artifactKey = (AxArtifactKey) axKey;
-
- keyInfoMap.computeIfAbsent(artifactKey, unusedKey -> {
- final var keyInfo = new AxKeyInfo(artifactKey);
- // generate a reproducible UUID
- keyInfo.setUuid(AxKeyInfo.generateReproducibleUuid(keyInfo.getId() + keyInfo.getDescription()));
- return keyInfo;
- });
- }
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public AxArtifactKey getKey() {
- return key;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public List<AxKey> getKeys() {
- final List<AxKey> keyList = key.getKeys();
- keyList.addAll(keyInfoMap.keySet());
-
- return keyList;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public void buildReferences() {
- keyInfoMap.values().stream().forEach(keyInfo -> keyInfo.buildReferences());
- }
-
- /**
- * Sets the key of this concept.
- *
- * @param key the key of this concept
- */
- public void setKey(final AxArtifactKey key) {
- Assertions.argumentNotNull(key, "key may not be null");
- this.key = key;
- }
-
- /**
- * Gets the key info map of this concept.
- *
- * @return the key info map of this concept
- */
- public Map<AxArtifactKey, AxKeyInfo> getKeyInfoMap() {
- return keyInfoMap;
- }
-
- /**
- * Sets the key info map of this concept.
- *
- * @param keyInfoMap the key info map of this concept
- */
- public void setKeyInfoMap(final Map<AxArtifactKey, AxKeyInfo> keyInfoMap) {
- Assertions.argumentNotNull(keyInfoMap, "keyInfoMap may not be null");
- this.keyInfoMap = new TreeMap<>();
- this.keyInfoMap.putAll(keyInfoMap);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public AxValidationResult validate(final AxValidationResult resultIn) {
- AxValidationResult result = resultIn;
-
- if (key.equals(AxArtifactKey.getNullKey())) {
- result.addValidationMessage(
- new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID, "key is a null key"));
- }
-
- result = key.validate(result);
-
- if (keyInfoMap.size() == 0) {
- result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "keyInfoMap may not be empty"));
- } else {
- final Set<UUID> uuidSet = new TreeSet<>();
-
- for (final Entry<AxArtifactKey, AxKeyInfo> keyInfoEntry : keyInfoMap.entrySet()) {
- result = validateKeyInfoEntry(keyInfoEntry, uuidSet, result);
- }
- }
-
- return result;
- }
-
- /**
- * Validate a key information entry.
- *
- * @param keyInfoEntry the key information entry
- * @param uuidSet the set of UUIDs encountered in validation so far, the UUID of this entry is added to the set
- * @param result the validation result to append to
- * @return The validation result
- */
- private AxValidationResult validateKeyInfoEntry(final Entry<AxArtifactKey, AxKeyInfo> keyInfoEntry,
- final Set<UUID> uuidSet, AxValidationResult result) {
- if (keyInfoEntry.getKey().equals(AxArtifactKey.getNullKey())) {
- result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "key on keyInfoMap entry " + keyInfoEntry.getKey() + " may not be the null key"));
- } else if (keyInfoEntry.getValue() == null) {
- result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "value on keyInfoMap entry " + keyInfoEntry.getKey() + " may not be null"));
- } else {
- if (!keyInfoEntry.getKey().equals(keyInfoEntry.getValue().getKey())) {
- result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "key on keyInfoMap entry " + keyInfoEntry.getKey() + " does not equal entry key "
- + keyInfoEntry.getValue().getKey()));
- }
-
- result = keyInfoEntry.getValue().validate(result);
-
- if (uuidSet.contains(keyInfoEntry.getValue().getUuid())) {
- result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "duplicate UUID found on keyInfoMap entry " + keyInfoEntry.getKey() + ":"
- + keyInfoEntry.getValue().getUuid()));
- } else {
- uuidSet.add(keyInfoEntry.getValue().getUuid());
- }
- }
-
- return result;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public void clean() {
- key.clean();
- for (final Entry<AxArtifactKey, AxKeyInfo> keyInfoEntry : keyInfoMap.entrySet()) {
- keyInfoEntry.getKey().clean();
- keyInfoEntry.getValue().clean();
- }
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public String toString() {
- final var builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- builder.append(":(");
- builder.append("key=");
- builder.append(key);
- builder.append(",keyInfoMap=");
- builder.append(keyInfoMap);
- builder.append(")");
- return builder.toString();
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public AxConcept copyTo(final AxConcept target) {
- Assertions.argumentNotNull(target, "target may not be null");
-
- final Object copyObject = target;
- Assertions.instanceOf(copyObject, AxKeyInformation.class);
-
- final AxKeyInformation copy = ((AxKeyInformation) copyObject);
- copy.setKey(new AxArtifactKey(key));
- final Map<AxArtifactKey, AxKeyInfo> newKeyInfoMap = new TreeMap<>();
- for (final Entry<AxArtifactKey, AxKeyInfo> keyInfoMapEntry : keyInfoMap.entrySet()) {
- newKeyInfoMap.put(new AxArtifactKey(keyInfoMapEntry.getKey()), new AxKeyInfo(keyInfoMapEntry.getValue()));
- }
- copy.setKeyInfoMap(newKeyInfoMap);
-
- return copy;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public int hashCode() {
- final var prime = 31;
- var result = 1;
- result = prime * result + key.hashCode();
- result = prime * result + keyInfoMap.hashCode();
- return result;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj == null) {
- return false;
- }
- if (this == obj) {
- return true;
- }
-
- if (getClass() != obj.getClass()) {
- return false;
- }
-
- final AxKeyInformation other = (AxKeyInformation) obj;
- if (!key.equals(other.key)) {
- return false;
- }
- return keyInfoMap.equals(other.keyInfoMap);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public int compareTo(final AxConcept otherObj) {
- if (otherObj == null) {
- return -1;
- }
- if (this == otherObj) {
- return 0;
- }
- if (getClass() != otherObj.getClass()) {
- return this.hashCode() - otherObj.hashCode();
- }
-
- final AxKeyInformation other = (AxKeyInformation) otherObj;
- if (!key.equals(other.key)) {
- return key.compareTo(other.key);
- }
- if (!keyInfoMap.equals(other.keyInfoMap)) {
- return (keyInfoMap.hashCode() - other.keyInfoMap.hashCode());
- }
-
- return 0;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public AxKeyInfo get(final AxArtifactKey conceptKey) {
- return new AxConceptGetterImpl<>((NavigableMap<AxArtifactKey, AxKeyInfo>) keyInfoMap).get(conceptKey);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public AxKeyInfo get(final String conceptKeyName) {
- return new AxConceptGetterImpl<>((NavigableMap<AxArtifactKey, AxKeyInfo>) keyInfoMap).get(conceptKeyName);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public AxKeyInfo get(final String conceptKeyName, final String conceptKeyVersion) {
- return new AxConceptGetterImpl<>((NavigableMap<AxArtifactKey, AxKeyInfo>) keyInfoMap).get(conceptKeyName,
- conceptKeyVersion);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public Set<AxKeyInfo> getAll(final String conceptKeyName) {
- return new AxConceptGetterImpl<>((NavigableMap<AxArtifactKey, AxKeyInfo>) keyInfoMap).getAll(conceptKeyName);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public Set<AxKeyInfo> getAll(final String conceptKeyName, final String conceptKeyVersion) {
- return new AxConceptGetterImpl<>((NavigableMap<AxArtifactKey, AxKeyInfo>) keyInfoMap).getAll(conceptKeyName,
- conceptKeyVersion);
- }
-}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyUse.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyUse.java
deleted file mode 100644
index eb701e5b3..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyUse.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2021 Nordix Foundation.
- * ================================================================================
- * 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=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.concepts;
-
-import java.util.List;
-import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
-import org.onap.policy.common.utils.validation.Assertions;
-
-/**
- * This class records a usage of a key in the system. When the list of keys being used by a concept is built using the
- * getKeys() method of the {@link AxConcept} class, an instance of this class is created for every key occurrence. The
- * list of keys returned by the getKeys() method is a list of {@link AxKeyUse} objects.
- *
- * <p>Validation checks that each key is valid.
- */
-
-public class AxKeyUse extends AxKey {
- private static final long serialVersionUID = 2007147220109881705L;
-
- private AxKey usedKey;
-
- /**
- * The Default Constructor creates this concept with a null key.
- */
- public AxKeyUse() {
- this(new AxArtifactKey());
- }
-
- /**
- * Copy constructor.
- *
- * @param copyConcept the concept to copy from
- */
- public AxKeyUse(final AxKeyUse copyConcept) {
- super(copyConcept);
- }
-
- /**
- * This constructor creates an instance of this class, and holds a reference to a used key.
- *
- * @param usedKey a used key
- */
- public AxKeyUse(final AxKey usedKey) {
- Assertions.argumentNotNull(usedKey, "usedKey may not be null");
- this.usedKey = usedKey;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public AxKey getKey() {
- return usedKey;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public List<AxKey> getKeys() {
- return usedKey.getKeys();
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public String getId() {
- return usedKey.getId();
- }
-
- /**
- * Sets the key.
- *
- * @param key the key
- */
- public void setKey(final AxKey key) {
- Assertions.argumentNotNull(key, "usedKey may not be null");
- this.usedKey = key;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public AxKey.Compatibility getCompatibility(final AxKey otherKey) {
- return usedKey.getCompatibility(otherKey);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public boolean isCompatible(final AxKey otherKey) {
- return usedKey.isCompatible(otherKey);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public AxValidationResult validate(final AxValidationResult result) {
- if (usedKey.equals(AxArtifactKey.getNullKey())) {
- result.addValidationMessage(new AxValidationMessage(usedKey, this.getClass(), ValidationResult.INVALID,
- "usedKey is a null key"));
- }
- return usedKey.validate(result);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public void clean() {
- usedKey.clean();
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public String toString() {
- final var builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- builder.append(":(");
- builder.append("usedKey=");
- builder.append(usedKey);
- builder.append(")");
- return builder.toString();
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public AxConcept copyTo(final AxConcept target) {
- Assertions.argumentNotNull(target, "target may not be null");
-
- final Object copyObject = target;
- Assertions.instanceOf(copyObject, AxKeyUse.class);
-
- final AxKeyUse copy = ((AxKeyUse) copyObject);
- try {
- copy.usedKey = usedKey.getClass().getDeclaredConstructor().newInstance();
- } catch (final Exception e) {
- throw new ApexRuntimeException("error copying concept key: " + e.getMessage(), e);
- }
- usedKey.copyTo(copy.usedKey);
-
- return copy;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public int hashCode() {
- final var prime = 31;
- var result = 1;
- result = prime * result + usedKey.hashCode();
- return result;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj == null) {
- throw new IllegalArgumentException("comparison object may not be null");
- }
-
- if (this == obj) {
- return true;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
-
- final AxKeyUse other = (AxKeyUse) obj;
- return usedKey.equals(other.usedKey);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public int compareTo(final AxConcept otherObj) {
- Assertions.argumentNotNull(otherObj, "comparison object may not be null");
-
- if (this == otherObj) {
- return 0;
- }
- if (getClass() != otherObj.getClass()) {
- return this.hashCode() - otherObj.hashCode();
- }
-
- final AxKeyUse other = (AxKeyUse) otherObj;
-
- return usedKey.compareTo(other.usedKey);
- }
-}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxModel.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxModel.java
deleted file mode 100644
index ce52b147f..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxModel.java
+++ /dev/null
@@ -1,423 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2022 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.
- * 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=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.concepts;
-
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
-import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
-import org.onap.policy.apex.model.basicmodel.service.ModelService;
-import org.onap.policy.common.utils.validation.Assertions;
-
-/**
- * This class is the base class for all models in Apex. All model classes inherit from this model so all models must
- * have a key and have key information.
- *
- * <p>Validation checks that the model key is valid. It goes on to check for null keys and checks each key for
- * uniqueness in the model. A check is carried out to ensure that an {@link AxKeyInfo} instance exists for every
- * {@link AxArtifactKey} key. For each {@link AxReferenceKey} instance, a check is made that its parent and local name
- * are nut null and that a {@link AxKeyInfo} entry exists for its parent. Then a check is made that each used
- * {@link AxArtifactKey} and {@link AxReferenceKey} usage references a key that exists. Finally, a check is made to
- * ensure that an {@link AxArtifactKey} instance exists for every {@link AxKeyInfo} instance.
- */
-public class AxModel extends AxConcept {
- private static final String IS_A_NULL_KEY = " is a null key";
-
- private static final long serialVersionUID = -771659065637205430L;
-
- private AxArtifactKey key;
- private AxKeyInformation keyInformation;
-
- /**
- * The Default Constructor creates this concept with a NULL artifact key.
- */
- public AxModel() {
- this(new AxArtifactKey());
- }
-
- /**
- * Copy constructor.
- *
- * @param copyConcept the concept to copy from
- */
- public AxModel(final AxModel copyConcept) {
- super(copyConcept);
- }
-
- /**
- * Constructor to create this concept with the specified key.
- *
- * @param key the key of this concept
- */
- public AxModel(final AxArtifactKey key) {
- this(key, new AxKeyInformation(new AxArtifactKey(key.getName() + "_KeyInfo", key.getVersion())));
- }
-
- /**
- * Constructor to create this concept and set all its fields.
- *
- * @param key the key of this concept
- * @param keyInformation the key information of this concept
- */
- public AxModel(final AxArtifactKey key, final AxKeyInformation keyInformation) {
- super();
- Assertions.argumentNotNull(key, "key may not be null");
- Assertions.argumentNotNull(keyInformation, "keyInformation may not be null");
-
- this.key = key;
- this.keyInformation = keyInformation;
- }
-
- /**
- * Registers this model with the {@link ModelService}. All models are registered with the model service so that
- * models can be references from anywhere in the Apex system without being passed as references through deep call
- * chains.
- */
- public void register() {
- ModelService.registerModel(AxKeyInformation.class, getKeyInformation());
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public AxArtifactKey getKey() {
- return key;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public List<AxKey> getKeys() {
- final List<AxKey> keyList = key.getKeys();
-
- // We just add the key for the KeyInformation itself. We don't add the
- // keys from key information because
- // that is a list of key information for existing keys
- keyList.add(keyInformation.getKey());
-
- return keyList;
- }
-
- /**
- * Sets the key of this concept.
- *
- * @param key the key of this concept
- */
- public void setKey(final AxArtifactKey key) {
- Assertions.argumentNotNull(key, "key may not be null");
- this.key = key;
- }
-
- /**
- * Gets the key information of this concept.
- *
- * @return the key information of this concept
- */
- public AxKeyInformation getKeyInformation() {
- return keyInformation;
- }
-
- /**
- * Sets the key information of this concept.
- *
- * @param keyInformation the key information of this concept
- */
- public void setKeyInformation(final AxKeyInformation keyInformation) {
- Assertions.argumentNotNull(keyInformation, "keyInformation may not be null");
- this.keyInformation = keyInformation;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public AxValidationResult validate(final AxValidationResult resultIn) {
- AxValidationResult result = resultIn;
-
- if (key.equals(AxArtifactKey.getNullKey())) {
- result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "key is a null key"));
- }
-
- result = key.validate(result);
- result = keyInformation.validate(result);
-
- // Key consistency check
- final Set<AxArtifactKey> artifactKeySet = new TreeSet<>();
- final Set<AxReferenceKey> referenceKeySet = new TreeSet<>();
- final Set<AxKeyUse> usedKeySet = new TreeSet<>();
-
- for (final AxKey axKey : this.getKeys()) {
- // Check for the two type of keys we have
- if (axKey instanceof AxArtifactKey) {
- result = validateArtifactKeyInModel((AxArtifactKey) axKey, artifactKeySet, result);
- } else if (axKey instanceof AxReferenceKey) {
- result = validateReferenceKeyInModel((AxReferenceKey) axKey, referenceKeySet, result);
- } else {
- // It must be an AxKeyUse, nothing else is legal
- usedKeySet.add((AxKeyUse) axKey);
- }
- }
-
- // Check all reference keys have correct parent keys
- for (final AxReferenceKey referenceKey : referenceKeySet) {
- if (!artifactKeySet.contains(referenceKey.getParentArtifactKey())) {
- result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "parent artifact key not found for reference key " + referenceKey));
- }
- }
-
- result = validateKeyUses(usedKeySet, artifactKeySet, referenceKeySet, result);
-
- // Check key information for unused key information
- for (final AxArtifactKey keyInfoKey : keyInformation.getKeyInfoMap().keySet()) {
- if (!artifactKeySet.contains(keyInfoKey)) {
- result.addValidationMessage(new AxValidationMessage(keyInfoKey, this.getClass(),
- ValidationResult.WARNING, "key not found for key information entry"));
- }
- }
-
- return result;
- }
-
- /**
- * Check for consistent usage of an artifact key in the model.
- *
- * @param artifactKey The artifact key to check
- * @param artifactKeySet The set of artifact keys encountered so far, this key is appended to the set
- * @param result The validation result to append to
- * @return the result of the validation
- */
- private AxValidationResult validateArtifactKeyInModel(final AxArtifactKey artifactKey,
- final Set<AxArtifactKey> artifactKeySet, final AxValidationResult result) {
- // Null key check
- if (artifactKey.equals(AxArtifactKey.getNullKey())) {
- result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "key " + artifactKey + IS_A_NULL_KEY));
- }
-
- // Null key name start check
- if (artifactKey.getName().toUpperCase().startsWith(AxKey.NULL_KEY_NAME)) {
- result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "key " + artifactKey + " name starts with keyword " + AxKey.NULL_KEY_NAME));
- }
-
- // Unique key check
- if (artifactKeySet.contains(artifactKey)) {
- result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "duplicate key " + artifactKey + " found"));
- } else {
- artifactKeySet.add(artifactKey);
- }
-
- // Key information check
- if (!keyInformation.getKeyInfoMap().containsKey(artifactKey)) {
- result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "key information not found for key " + artifactKey));
- }
-
- return result;
- }
-
- /**
- * Check for consistent usage of a reference key in the model.
- *
- * @param referenceKey The reference key to check
- * @param referenceKeySet The set of reference keys encountered so far, this key is appended to the set
- * @param result The validation result to append to
- * @return the result of the validation
- */
- private AxValidationResult validateReferenceKeyInModel(final AxReferenceKey referenceKey,
- final Set<AxReferenceKey> referenceKeySet, final AxValidationResult result) {
- // Null key check
- if (referenceKey.equals(AxReferenceKey.getNullKey())) {
- result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "key " + referenceKey + IS_A_NULL_KEY));
- }
-
- // Null parent key check
- if (referenceKey.getParentArtifactKey().equals(AxArtifactKey.getNullKey())) {
- result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "parent artifact key of key " + referenceKey + IS_A_NULL_KEY));
- }
-
- // Null local name check
- if (referenceKey.getLocalName().equals(AxKey.NULL_KEY_NAME)) {
- result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "key " + referenceKey + " has a null local name"));
- }
-
- // Null key name start check
- if (referenceKey.getParentArtifactKey().getName().toUpperCase().startsWith(AxKey.NULL_KEY_NAME)) {
- result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "key " + referenceKey + " parent name starts with keyword " + AxKey.NULL_KEY_NAME));
- }
-
- // Unique key check
- if (referenceKeySet.contains(referenceKey)) {
- result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "duplicate key " + referenceKey + " found"));
- } else {
- referenceKeySet.add(referenceKey);
- }
-
- // Key information check
- if (!keyInformation.getKeyInfoMap().containsKey(referenceKey.getParentArtifactKey())) {
- result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "key information not found for parent key of key " + referenceKey));
- }
-
- return result;
- }
-
- /**
- * Check for consistent usage of cross-key references in the model.
- *
- * @param usedKeySet The set of all keys used in the model
- * @param artifactKeySet The set of artifact keys encountered so far, this key is appended to the set
- * @param referenceKeySet The set of reference keys encountered so far, this key is appended to the set
- * @param result The validation result to append to
- * @return the result of the validation
- */
- private AxValidationResult validateKeyUses(final Set<AxKeyUse> usedKeySet, final Set<AxArtifactKey> artifactKeySet,
- final Set<AxReferenceKey> referenceKeySet, final AxValidationResult result) {
- // Check all key uses
- for (final AxKeyUse usedKey : usedKeySet) {
- if (usedKey.getKey() instanceof AxArtifactKey) {
- // AxArtifact key usage, check the key exists
- if (!artifactKeySet.contains(usedKey.getKey())) {
- result.addValidationMessage(new AxValidationMessage(usedKey.getKey(), this.getClass(),
- ValidationResult.INVALID, "an artifact key used in the model is not defined"));
- }
- } else {
- // AxReference key usage, check the key exists
- if (!referenceKeySet.contains(usedKey.getKey())) {
- result.addValidationMessage(new AxValidationMessage(usedKey.getKey(), this.getClass(),
- ValidationResult.INVALID, "a reference key used in the model is not defined"));
- }
- }
- }
-
- return result;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public void clean() {
- key.clean();
- keyInformation.clean();
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public String toString() {
- final var builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- builder.append(":(");
- builder.append("key=");
- builder.append(key);
- builder.append(",keyInformation=");
- builder.append(keyInformation);
- builder.append(")");
- return builder.toString();
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public AxConcept copyTo(final AxConcept target) {
- Assertions.argumentNotNull(target, "target may not be null");
-
- final Object copyObject = target;
- Assertions.instanceOf(copyObject, AxModel.class);
-
- final AxModel copy = ((AxModel) copyObject);
- copy.setKey(new AxArtifactKey(key));
- copy.setKeyInformation(new AxKeyInformation(keyInformation));
-
- return copy;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public int hashCode() {
- final var prime = 31;
- var result = 1;
- result = prime * result + key.hashCode();
- result = prime * result + keyInformation.hashCode();
- return result;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj == null) {
- return false;
- }
- if (this == obj) {
- return true;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
-
- final AxModel other = (AxModel) obj;
- if (!key.equals(other.key)) {
- return false;
- }
- return keyInformation.equals(other.keyInformation);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public int compareTo(final AxConcept otherObj) {
- if (otherObj == null) {
- return -1;
- }
- if (this == otherObj) {
- return 0;
- }
- if (getClass() != otherObj.getClass()) {
- return this.hashCode() - otherObj.hashCode();
- }
-
- final AxModel other = (AxModel) otherObj;
- if (!key.equals(other.key)) {
- return key.compareTo(other.key);
- }
- return keyInformation.compareTo(other.keyInformation);
- }
-}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxReferenceKey.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxReferenceKey.java
deleted file mode 100644
index b37bc47e4..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxReferenceKey.java
+++ /dev/null
@@ -1,527 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2022 Nordix Foundation.
- * ================================================================================
- * 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=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.concepts;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
-import org.onap.policy.common.utils.validation.Assertions;
-
-/**
- * A reference key identifies entities in the system that are contained in other entities. Every contained concept in
- * the system must have an {@link AxReferenceKey} to identify it. Non-contained first order concepts are identified
- * using an {@link AxArtifactKey} key.
- *
- * <p>An {@link AxReferenceKey} contains an {@link AxArtifactKey} key reference to the first order entity that contains
- * it. The local name of the reference key must uniquely identify the referenced concept among those concepts contained
- * in the reference key's parent. In other words, if a parent concept has more than one child, the local name in the key
- * of all its children must be unique.
- *
- * <p>If a reference key's parent is itself a reference key, then the parent's local name must be set in the reference
- * key. If the parent is a first order concept, then the parent's local name in the key will be set to NULL.
- *
- * <p>Key validation checks that the parent name and parent version fields match the NAME_REGEXP and
- * VERSION_REGEXP regular expressions respectively and that the local name fields match the
- * LOCAL_NAME_REGEXP regular expression.
- */
-public class AxReferenceKey extends AxKey {
- private static final String PARENT_KEY_NAME = "parentKeyName";
- private static final String PARENT_KEY_VERSION = "parentKeyVersion";
- private static final String PARENT_LOCAL_NAME = "parentLocalName";
- private static final String LOCAL_NAME = "localName";
-
- private static final long serialVersionUID = 8932717618579392561L;
-
- /**
- * Regular expression to specify the structure of local names in reference keys.
- */
- public static final String LOCAL_NAME_REGEXP = "[A-Za-z0-9\\-_\\.]+|^$";
-
- /**
- * Regular expression to specify the structure of IDs in reference keys.
- */
- public static final String REFERENCE_KEY_ID_REGEXP =
- "[A-Za-z0-9\\-_]+:[0-9].[0-9].[0-9]:[A-Za-z0-9\\-_]+:[A-Za-z0-9\\-_]+";
-
- private static final int PARENT_NAME_FIELD = 0;
- private static final int PARENT_VERSION_FIELD = 1;
- private static final int PARENT_LOCAL_NAME_FIELD = 2;
- private static final int LOCAL_NAME_FIELD = 3;
-
- private String parentKeyName;
- private String parentKeyVersion;
- private String parentLocalName;
- private String localName;
-
- /**
- * The default constructor creates a null reference key.
- */
- public AxReferenceKey() {
- this(NULL_KEY_NAME, NULL_KEY_VERSION, NULL_KEY_NAME, NULL_KEY_NAME);
- }
-
- /**
- * The Copy Constructor creates a key by copying another key.
- *
- * @param referenceKey the reference key to copy from
- */
- public AxReferenceKey(final AxReferenceKey referenceKey) {
- this(referenceKey.getParentKeyName(), referenceKey.getParentKeyVersion(), referenceKey.getParentLocalName(),
- referenceKey.getLocalName());
- }
-
- /**
- * Constructor to create a null reference key for the specified parent artifact key.
- *
- * @param axArtifactKey the parent artifact key of this reference key
- */
- public AxReferenceKey(final AxArtifactKey axArtifactKey) {
- this(axArtifactKey.getName(), axArtifactKey.getVersion(), NULL_KEY_NAME, NULL_KEY_NAME);
- }
-
- /**
- * Constructor to create a reference key for the given parent artifact key with the given local name.
- *
- * @param axArtifactKey the parent artifact key of this reference key
- * @param localName the local name of this reference key
- */
- public AxReferenceKey(final AxArtifactKey axArtifactKey, final String localName) {
- this(axArtifactKey, NULL_KEY_NAME, localName);
- }
-
- /**
- * Constructor to create a reference key for the given parent reference key with the given local name.
- *
- * @param parentReferenceKey the parent reference key of this reference key
- * @param localName the local name of this reference key
- */
- public AxReferenceKey(final AxReferenceKey parentReferenceKey, final String localName) {
- this(parentReferenceKey.getParentArtifactKey(), parentReferenceKey.getLocalName(), localName);
- }
-
- /**
- * Constructor to create a reference key for the given parent reference key (specified by the parent reference key's
- * artifact key and local name) with the given local name.
- *
- * @param axArtifactKey the artifact key of the parent reference key of this reference key
- * @param parentLocalName the local name of the parent reference key of this reference key
- * @param localName the local name of this reference key
- */
- public AxReferenceKey(final AxArtifactKey axArtifactKey, final String parentLocalName, final String localName) {
- this(axArtifactKey.getName(), axArtifactKey.getVersion(), parentLocalName, localName);
- }
-
- /**
- * Constructor to create a reference key for the given parent artifact key (specified by the parent artifact key's
- * name and version) with the given local name.
- *
- * @param parentKeyName the name of the parent artifact key of this reference key
- * @param parentKeyVersion the version of the parent artifact key of this reference key
- * @param localName the local name of this reference key
- */
- public AxReferenceKey(final String parentKeyName, final String parentKeyVersion, final String localName) {
- this(parentKeyName, parentKeyVersion, NULL_KEY_NAME, localName);
- }
-
- /**
- * Constructor to create a reference key for the given parent key (specified by the parent key's name, version nad
- * local name) with the given local name.
- *
- * @param parentKeyName the parent key name of this reference key
- * @param parentKeyVersion the parent key version of this reference key
- * @param parentLocalName the parent local name of this reference key
- * @param localName the local name of this reference key
- */
- public AxReferenceKey(final String parentKeyName, final String parentKeyVersion, final String parentLocalName,
- final String localName) {
- super();
- this.parentKeyName = Assertions.validateStringParameter(PARENT_KEY_NAME, parentKeyName, NAME_REGEXP);
- this.parentKeyVersion = Assertions.validateStringParameter(PARENT_KEY_VERSION, parentKeyVersion,
- VERSION_REGEXP);
- this.parentLocalName = Assertions.validateStringParameter(PARENT_LOCAL_NAME, parentLocalName,
- LOCAL_NAME_REGEXP);
- this.localName = Assertions.validateStringParameter(LOCAL_NAME, localName, LOCAL_NAME_REGEXP);
- }
-
- /**
- * Constructor to create a key from the specified key ID.
- *
- * @param id the key ID in a format that respects the KEY_ID_REGEXP
- */
- public AxReferenceKey(final String id) {
- final var conditionedId = Assertions.validateStringParameter("id", id, REFERENCE_KEY_ID_REGEXP);
-
- // Split on colon, if the id passes the regular expression test above
- // it'll have just three colons separating the parent name,
- // parent version, parent local name, and and local name
- // No need for range checks or size checks on the array
- final String[] nameVersionNameArray = conditionedId.split(":");
-
- // Initiate the new key
- parentKeyName = Assertions.validateStringParameter(PARENT_KEY_NAME, nameVersionNameArray[PARENT_NAME_FIELD],
- NAME_REGEXP);
- parentKeyVersion = Assertions.validateStringParameter(PARENT_KEY_VERSION,
- nameVersionNameArray[PARENT_VERSION_FIELD], VERSION_REGEXP);
- parentLocalName = Assertions.validateStringParameter(PARENT_LOCAL_NAME,
- nameVersionNameArray[PARENT_LOCAL_NAME_FIELD], LOCAL_NAME_REGEXP);
- localName = Assertions.validateStringParameter(LOCAL_NAME, nameVersionNameArray[LOCAL_NAME_FIELD],
- LOCAL_NAME_REGEXP);
- }
-
- /**
- * Get a null reference key.
- *
- * @return a null reference key
- */
- public static AxReferenceKey getNullKey() {
- return new AxReferenceKey(AxKey.NULL_KEY_NAME, AxKey.NULL_KEY_VERSION, AxKey.NULL_KEY_NAME,
- AxKey.NULL_KEY_NAME);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public AxReferenceKey getKey() {
- return this;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public List<AxKey> getKeys() {
- final List<AxKey> keyList = new ArrayList<>();
- keyList.add(getKey());
- return keyList;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public String getId() {
- return parentKeyName + ':' + parentKeyVersion + ':' + parentLocalName + ':' + localName;
- }
-
- /**
- * Gets the parent artifact key of this reference key.
- *
- * @return the parent artifact key of this reference key
- */
- public AxArtifactKey getParentArtifactKey() {
- return new AxArtifactKey(parentKeyName, parentKeyVersion);
- }
-
- /**
- * Gets the parent reference key of this reference key.
- *
- * @return the parent reference key of this reference key
- */
- public AxReferenceKey getParentReferenceKey() {
- return new AxReferenceKey(parentKeyName, parentKeyVersion, parentLocalName);
- }
-
- /**
- * Sets the parent artifact key of this reference key.
- *
- * @param parentKey the parent artifact key of this reference key
- */
- public void setParentArtifactKey(final AxArtifactKey parentKey) {
- Assertions.argumentNotNull(parentKey, "parentKey may not be null");
-
- parentKeyName = parentKey.getName();
- parentKeyVersion = parentKey.getVersion();
- parentLocalName = NULL_KEY_NAME;
- }
-
- /**
- * Sets the parent reference key of this reference key.
- *
- * @param parentKey the parent reference key of this reference key
- */
- public void setParentReferenceKey(final AxReferenceKey parentKey) {
- Assertions.argumentNotNull(parentKey, "parentKey may not be null");
-
- parentKeyName = parentKey.getParentKeyName();
- parentKeyVersion = parentKey.getParentKeyVersion();
- parentLocalName = parentKey.getLocalName();
- }
-
- /**
- * Gets the parent key name of this reference key.
- *
- * @return the parent key name of this reference key
- */
- public String getParentKeyName() {
- return parentKeyName;
- }
-
- /**
- * Sets the parent key name of this reference key.
- *
- * @param parentKeyName the parent key name of this reference key
- */
- public void setParentKeyName(final String parentKeyName) {
- this.parentKeyName = Assertions.validateStringParameter(PARENT_KEY_NAME, parentKeyName, NAME_REGEXP);
- }
-
- /**
- * Gets the parent key version of this reference key.
- *
- * @return the parent key version of this reference key
- */
- public String getParentKeyVersion() {
- return parentKeyVersion;
- }
-
- /**
- * Sets the parent key version of this reference key.
- *
- * @param parentKeyVersion the parent key version of this reference key
- */
- public void setParentKeyVersion(final String parentKeyVersion) {
- this.parentKeyVersion = Assertions.validateStringParameter(PARENT_KEY_VERSION, parentKeyVersion,
- VERSION_REGEXP);
- }
-
- /**
- * Gets the parent local name of this reference key.
- *
- * @return the parent local name of this reference key
- */
- public String getParentLocalName() {
- return parentLocalName;
- }
-
- /**
- * Sets the parent local name of this reference key.
- *
- * @param parentLocalName the parent local name of this reference key
- */
- public void setParentLocalName(final String parentLocalName) {
- this.parentLocalName = Assertions.validateStringParameter(PARENT_LOCAL_NAME, parentLocalName,
- LOCAL_NAME_REGEXP);
- }
-
- /**
- * Gets the local name of this reference key.
- *
- * @return the local name of this reference key
- */
- public String getLocalName() {
- return localName;
- }
-
- /**
- * Sets the local name of this reference key.
- *
- * @param localName the local name of this reference key
- */
- public void setLocalName(final String localName) {
- this.localName = Assertions.validateStringParameter(LOCAL_NAME, localName, LOCAL_NAME_REGEXP);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public AxKey.Compatibility getCompatibility(final AxKey otherKey) {
- if (!(otherKey instanceof AxReferenceKey)) {
- return Compatibility.DIFFERENT;
- }
- final AxReferenceKey otherReferenceKey = (AxReferenceKey) otherKey;
-
- return this.getParentArtifactKey().getCompatibility(otherReferenceKey.getParentArtifactKey());
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public boolean isCompatible(final AxKey otherKey) {
- if (!(otherKey instanceof AxReferenceKey)) {
- return false;
- }
- final AxReferenceKey otherReferenceKey = (AxReferenceKey) otherKey;
-
- return this.getParentArtifactKey().isCompatible(otherReferenceKey.getParentArtifactKey());
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public AxValidationResult validate(final AxValidationResult result) {
- final var parentNameValidationErrorMessage = Assertions.getStringParameterValidationMessage(PARENT_KEY_NAME,
- parentKeyName, NAME_REGEXP);
- if (parentNameValidationErrorMessage != null) {
- result.addValidationMessage(new AxValidationMessage(this, this.getClass(), ValidationResult.INVALID,
- "parentKeyName invalid-" + parentNameValidationErrorMessage));
- }
-
- final var parentKeyVersionValidationErrorMessage = Assertions
- .getStringParameterValidationMessage(PARENT_KEY_VERSION, parentKeyVersion, VERSION_REGEXP);
- if (parentKeyVersionValidationErrorMessage != null) {
- result.addValidationMessage(new AxValidationMessage(this, this.getClass(), ValidationResult.INVALID,
- "parentKeyVersion invalid-" + parentKeyVersionValidationErrorMessage));
- }
-
- final var parentLocalNameValidationErrorMessage = Assertions
- .getStringParameterValidationMessage(PARENT_LOCAL_NAME, parentLocalName, LOCAL_NAME_REGEXP);
- if (parentLocalNameValidationErrorMessage != null) {
- result.addValidationMessage(new AxValidationMessage(this, this.getClass(), ValidationResult.INVALID,
- "parentLocalName invalid-" + parentLocalNameValidationErrorMessage));
- }
-
- final var localNameValidationErrorMessage = Assertions.getStringParameterValidationMessage(LOCAL_NAME,
- localName, LOCAL_NAME_REGEXP);
- if (localNameValidationErrorMessage != null) {
- result.addValidationMessage(new AxValidationMessage(this, this.getClass(), ValidationResult.INVALID,
- "localName invalid-" + localNameValidationErrorMessage));
- }
-
- return result;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public void clean() {
- parentKeyName = Assertions.validateStringParameter(PARENT_KEY_NAME, parentKeyName, NAME_REGEXP);
- parentKeyVersion = Assertions.validateStringParameter(PARENT_KEY_VERSION, parentKeyVersion, VERSION_REGEXP);
- parentLocalName = Assertions.validateStringParameter(PARENT_LOCAL_NAME, parentLocalName, LOCAL_NAME_REGEXP);
- localName = Assertions.validateStringParameter(LOCAL_NAME, localName, LOCAL_NAME_REGEXP);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public String toString() {
- final var builder = new StringBuilder();
- builder.append(this.getClass().getSimpleName());
- builder.append(":(");
- builder.append("parentKeyName=");
- builder.append(parentKeyName);
- builder.append(",parentKeyVersion=");
- builder.append(parentKeyVersion);
- builder.append(",parentLocalName=");
- builder.append(parentLocalName);
- builder.append(",localName=");
- builder.append(localName);
- builder.append(")");
- return builder.toString();
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public AxConcept copyTo(final AxConcept target) {
- Assertions.argumentNotNull(target, "target may not be null");
-
- final Object copyObject = target;
- Assertions.instanceOf(copyObject, AxReferenceKey.class);
-
- final AxReferenceKey copy = ((AxReferenceKey) copyObject);
- copy.setParentKeyName(parentKeyName);
- copy.setParentKeyVersion(parentKeyVersion);
- copy.setLocalName(localName);
- copy.setParentLocalName(parentLocalName);
-
- return copy;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public int hashCode() {
- final var prime = 31;
- var result = 1;
- result = prime * result + parentKeyName.hashCode();
- result = prime * result + parentKeyVersion.hashCode();
- result = prime * result + parentLocalName.hashCode();
- result = prime * result + localName.hashCode();
- return result;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public boolean equals(final Object obj) {
- if (obj == null) {
- throw new IllegalArgumentException("comparison object may not be null");
- }
-
- if (this == obj) {
- return true;
- }
-
- if (getClass() != obj.getClass()) {
- return false;
- }
-
- final AxReferenceKey other = (AxReferenceKey) obj;
-
- if (!parentKeyName.equals(other.parentKeyName)) {
- return false;
- }
- if (!parentKeyVersion.equals(other.parentKeyVersion)) {
- return false;
- }
- if (!parentLocalName.equals(other.parentLocalName)) {
- return false;
- }
- return localName.equals(other.localName);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public int compareTo(final AxConcept otherObj) {
- Assertions.argumentNotNull(otherObj, "comparison object may not be null");
-
- if (this == otherObj) {
- return 0;
- }
- if (getClass() != otherObj.getClass()) {
- return this.hashCode() - otherObj.hashCode();
- }
-
- final AxReferenceKey other = (AxReferenceKey) otherObj;
- if (!parentKeyName.equals(other.parentKeyName)) {
- return parentKeyName.compareTo(other.parentKeyName);
- }
- if (!parentKeyVersion.equals(other.parentKeyVersion)) {
- return parentKeyVersion.compareTo(other.parentKeyVersion);
- }
- if (!parentLocalName.equals(other.parentLocalName)) {
- return parentLocalName.compareTo(other.parentLocalName);
- }
- return localName.compareTo(other.localName);
- }
-}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxToscaPolicyProcessingStatus.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxToscaPolicyProcessingStatus.java
deleted file mode 100644
index 43c7e7866..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxToscaPolicyProcessingStatus.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2022 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=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.concepts;
-
-/**
- * This enumeration indicates the status of TOSCA policy processing on an APEX event.
- */
-public enum AxToscaPolicyProcessingStatus {
-
- /** Indicates the entrypoint for the processing of a TOSCA Policy. */
- ENTRY(0),
-
- /** Indicates a successful exit point for a TOSCA Policy. */
- EXIT_SUCCESS(1),
-
- /** Indicates a failure exit point for a TOSCA Policy. */
- EXIT_FAILURE(2);
-
- private final int statusCode;
-
- AxToscaPolicyProcessingStatus(int statusCode) {
- this.statusCode = statusCode;
- }
-
- public int getStatusCode() {
- return statusCode;
- }
-} \ No newline at end of file
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxValidationMessage.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxValidationMessage.java
deleted file mode 100644
index 9e245c07b..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxValidationMessage.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * 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=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.concepts;
-
-import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
-import org.onap.policy.common.utils.validation.Assertions;
-
-/**
- * A validation message is created for each validation observation observed during validation of a concept. The message
- * holds the key and the class of the concept on which the observation was made as well as the type of observation and a
- * message describing the observation.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class AxValidationMessage {
- private final AxKey observedKey;
- private ValidationResult validationResult = ValidationResult.VALID;
- private final String observedClass;
- private final String message;
-
- /**
- * Create an validation observation with the given fields.
- *
- * @param observedKey the key of the class on which the validation observation was made
- * @param observedClass the class on which the validation observation was made
- * @param validationResult the type of observation made
- * @param message a message describing the observation
- */
- public AxValidationMessage(final AxKey observedKey, final Class<?> observedClass,
- final ValidationResult validationResult, final String message) {
- Assertions.argumentNotNull(observedKey, "observedKey may not be null");
- Assertions.argumentNotNull(observedClass, "observedClass may not be null");
- Assertions.argumentNotNull(validationResult, "validationResult may not be null");
- Assertions.argumentNotNull(message, "message may not be null");
-
- this.observedKey = observedKey;
- this.observedClass = observedClass.getName();
- this.validationResult = validationResult;
- this.message = message;
- }
-
- /**
- * Gets the key of the observation.
- *
- * @return the key of the observation
- */
- public AxKey getObservedKey() {
- return observedKey;
- }
-
- /**
- * Gets the observed class.
- *
- * @return the observed class
- */
- public String getObservedClass() {
- return observedClass;
- }
-
- /**
- * Gets the type of observation made.
- *
- * @return the type of observation made
- */
- public ValidationResult getValidationResult() {
- return validationResult;
- }
-
- /**
- * Get a description of the observation.
- *
- * @return the observation description
- */
- public String getMessage() {
- return message;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public String toString() {
- return observedKey.toString() + ':' + observedClass + ':' + validationResult.name() + ':' + message;
- }
-}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxValidationResult.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxValidationResult.java
deleted file mode 100644
index 10ccb30aa..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxValidationResult.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. 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=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.concepts;
-
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * This class records the result of a validation and holds all validatino observation messages.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class AxValidationResult {
- /**
- * The ValidationResult enumeration describes the severity of a validation result.
- */
- public enum ValidationResult {
- /** No problems or observations were detected during validation. */
- VALID,
- /**
- * Observations were made on a concept (such as blank descriptions) of a nature that will not affect the use of
- * the concept.
- */
- OBSERVATION,
- /**
- * Warnings were made on a concept (such as defined but unused concepts) of a nature that may affect the use of
- * the concept.
- */
- WARNING,
- /**
- * Errors were detected on a concept (such as referenced but undefined concepts) of a nature that will affect
- * the use of the concept.
- */
- INVALID
- }
-
- // The actual verification result
- private ValidationResult validationResult = ValidationResult.VALID;
-
- // Messages collected during the verification process
- private final List<AxValidationMessage> messageList = new LinkedList<>();
-
- /**
- * Check if a validation reported a valid concept, returns true if the model is usable (that is, even if the model
- * has warnings or observations).
- *
- * @return true, if the concept is reported as valid and can be used
- */
- public boolean isValid() {
- return validationResult != ValidationResult.INVALID;
- }
-
- /**
- * Check if a validation reported a concept with no errors or warnings, returns true if the model is OK to use.
- *
- * @return true, if the concept has no warnings or errors
- */
- public boolean isOk() {
- return validationResult == ValidationResult.VALID || validationResult == ValidationResult.OBSERVATION;
- }
-
- /**
- * Gets the validation result.
- *
- * @return the validation result on a concept
- */
- public ValidationResult getValidationResult() {
- return validationResult;
- }
-
- /**
- * Gets the list of validation results on the concept.
- *
- * @return the list of validaiton results
- */
- public List<AxValidationMessage> getMessageList() {
- return messageList;
- }
-
- /**
- * Adds a validation message to the validation result, used by validate() implementations on {@link AxConcept}
- * subclasses to report validaiton observations.
- *
- * @param validationMessage the validation message
- */
- public void addValidationMessage(final AxValidationMessage validationMessage) {
- messageList.add(validationMessage);
-
- // Check if the incoming message has a more sever status than the
- // current one on the overall validation result,
- // if so, the overall result goes to that level
- if (validationMessage.getValidationResult().ordinal() > validationResult.ordinal()) {
- validationResult = validationMessage.getValidationResult();
- }
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public String toString() {
- final StringBuilder builder = new StringBuilder();
-
- switch (validationResult) {
- case VALID:
-
- builder.append("***validation of model successful***");
- return builder.toString();
- case OBSERVATION:
-
- builder.append("\n***observations noted during validation of model***\n");
- break;
- case WARNING:
-
- builder.append("\n***warnings issued during validation of model***\n");
- break;
- case INVALID:
- builder.append("\n***validation of model failed***\n");
- break;
- default:
- break;
- }
-
- for (final AxValidationMessage message : messageList) {
- builder.append(message);
- builder.append("\n");
- }
-
- builder.append("********************************");
- return builder.toString();
- }
-}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/package-info.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/package-info.java
deleted file mode 100644
index 347e46a0f..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/package-info.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2022 Nordix Foundation.
- * ================================================================================
- * 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=========================================================
- */
-
-/**
- * This package contains the fundamental concepts for all APEX models.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-package org.onap.policy.apex.model.basicmodel.concepts;
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelCreator.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelCreator.java
deleted file mode 100644
index a33e1bf1a..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelCreator.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. 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=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.handling;
-
-import org.onap.policy.apex.model.basicmodel.concepts.AxModel;
-
-/**
- * This interface is implemented by factories that create Apex models. It is mainly used by unit test classes that
- * generate Apex models for test purposes.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- * @param <M> the type of Apex model to create, must be a sub class of {@link AxModel}
- */
-@FunctionalInterface
-public interface ApexModelCreator<M extends AxModel> {
-
- /**
- * Gets the model created by the model creator.
- *
- * @return the model created by the model creator
- */
- M getModel();
-}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelCustomGsonMapAdapter.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelCustomGsonMapAdapter.java
deleted file mode 100644
index cb67590f7..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelCustomGsonMapAdapter.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2022 Nordix Foundation.
- * ================================================================================
- * 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=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.handling;
-
-import com.google.gson.JsonArray;
-import com.google.gson.JsonDeserializationContext;
-import com.google.gson.JsonDeserializer;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParseException;
-import com.google.gson.JsonSerializationContext;
-import com.google.gson.JsonSerializer;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.util.AbstractMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.TreeMap;
-import java.util.stream.Collectors;
-import java.util.stream.StreamSupport;
-
-@SuppressWarnings("rawtypes")
-public class ApexModelCustomGsonMapAdapter implements JsonSerializer<Map>, JsonDeserializer<Map> {
- private static final String MAP_ENTRY_KEY = "entry";
-
- @SuppressWarnings("unchecked")
- @Override
- public Map deserialize(JsonElement jsonElement, Type typeOfT, JsonDeserializationContext context)
- throws JsonParseException {
-
- if (!(jsonElement instanceof JsonObject)) {
- throw new JsonParseException("could not parse JSON map, map is not a JsonObject");
- }
-
- JsonObject jsonObject = (JsonObject) jsonElement;
-
- if (jsonObject.size() != 1) {
- throw new JsonParseException("could not parse JSON map, map must be in a JsonObject with a single member");
- }
-
- JsonArray mapEntryArray = (JsonArray) jsonObject.get(MAP_ENTRY_KEY);
- if (mapEntryArray == null) {
- throw new JsonParseException("could not parse JSON map, map \"entry\" in JsonObject not found");
- }
-
- return new TreeMap(
- StreamSupport
- .stream(mapEntryArray.spliterator(), true)
- .map(element -> deserializeMapEntry(element, typeOfT, context))
- .collect(Collectors.toMap(entry -> entry.getKey(), entry -> entry.getValue()))
- );
- }
-
- @Override
- public JsonElement serialize(Map sourceMap, Type typeOfSrc, JsonSerializationContext context) {
-
- // A map is stored in a JsonArray
- JsonArray mapEntryArray = new JsonArray();
-
- for (Object mapEntryObject : sourceMap.entrySet()) {
- Entry mapEntry = (Entry) mapEntryObject;
- mapEntryArray.add(serializeMapEntry(mapEntry, typeOfSrc, context));
- }
-
- JsonObject returnObject = new JsonObject();
- returnObject.add(MAP_ENTRY_KEY, mapEntryArray);
-
- return returnObject;
- }
-
- @SuppressWarnings("unchecked")
- private static Entry deserializeMapEntry(JsonElement element, Type typeOfT, JsonDeserializationContext context) {
- // Get the types of the map
- ParameterizedType pt = (ParameterizedType) typeOfT;
-
- // Type of the key and value of the map
- Type keyType = pt.getActualTypeArguments()[0];
- Type valueType = pt.getActualTypeArguments()[1];
-
- // Deserialize the key and value
- return new AbstractMap.SimpleEntry(
- context.deserialize(element.getAsJsonObject().get("key"), keyType),
- context.deserialize(element.getAsJsonObject().get("value"), valueType));
- }
-
- private static JsonElement serializeMapEntry(Entry sourceEntry, Type typeOfSrc, JsonSerializationContext context) {
- // Get the types of the map
- ParameterizedType pt = (ParameterizedType) typeOfSrc;
-
- // Type of the key and value of the map
- Type keyType = pt.getActualTypeArguments()[0];
- Type valueType = pt.getActualTypeArguments()[1];
-
- JsonObject entryObject = new JsonObject();
- entryObject.add("key", context.serialize(sourceEntry.getKey(), keyType));
- entryObject.add("value", context.serialize(sourceEntry.getValue(), valueType));
-
- return entryObject;
- }
-}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelCustomGsonRefereceKeyAdapter.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelCustomGsonRefereceKeyAdapter.java
deleted file mode 100644
index d731c8689..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelCustomGsonRefereceKeyAdapter.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2022 Nordix Foundation.
- * ================================================================================
- * 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=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.handling;
-
-import com.google.gson.JsonDeserializationContext;
-import com.google.gson.JsonDeserializer;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParseException;
-import java.lang.reflect.Type;
-import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
-
-public class ApexModelCustomGsonRefereceKeyAdapter implements JsonDeserializer<AxReferenceKey> {
-
- @Override
- public AxReferenceKey deserialize(JsonElement jsonElement, Type typeOfT, JsonDeserializationContext context)
- throws JsonParseException {
-
- if (jsonElement instanceof JsonObject) {
- return new AxReferenceKey(
- jsonElement.getAsJsonObject().get("parentKeyName").getAsString(),
- jsonElement.getAsJsonObject().get("parentKeyVersion").getAsString(),
- jsonElement.getAsJsonObject().get("parentLocalName").getAsString(),
- jsonElement.getAsJsonObject().get("localName").getAsString()
- );
- } else {
- AxReferenceKey returnKey = new AxReferenceKey();
- returnKey.setLocalName(jsonElement.getAsString());
- return returnKey;
- }
- }
-}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelException.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelException.java
deleted file mode 100644
index 17eb2639d..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelException.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. 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=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.handling;
-
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
-
-/**
- * This exception is invoked if an exception occurs in model handling.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class ApexModelException extends ApexException {
- private static final long serialVersionUID = -4245694568321686450L;
-
- /**
- * Instantiates a new apex model handling exception.
- *
- * @param message the message
- */
- public ApexModelException(final String message) {
- super(message);
- }
-
- /**
- * Instantiates a new apex model handling exception.
- *
- * @param message the message
- * @param exception the exception
- */
- public ApexModelException(final String message, final Exception exception) {
- super(message, exception);
- }
-}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelFileWriter.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelFileWriter.java
deleted file mode 100644
index 54b5651cc..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelFileWriter.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2021-2022 Nordix Foundation.
- * ================================================================================
- * 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=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.handling;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import lombok.Getter;
-import lombok.Setter;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
-import org.onap.policy.apex.model.basicmodel.concepts.AxModel;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-/**
- * This class writes an Apex model to a file.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- * @param <M> the type of Apex model to write to file, must be a sub class of {@link AxModel}
- */
-@Getter
-@Setter
-public class ApexModelFileWriter<M extends AxModel> {
- private static final XLogger LOGGER = XLoggerFactory.getXLogger(ApexModelFileWriter.class);
-
- // Should models being written to files be valid
- private boolean validate;
-
- /**
- * Constructor, set the validation flag.
- *
- * @param validate indicates if validation be performed prior to output
- */
- public ApexModelFileWriter(final boolean validate) {
- this.validate = validate;
- }
-
- /**
- * Write a model to an JSON file.
- *
- * @param model The model to write
- * @param rootModelClass The concept class
- * @param modelFileName The name of the file to write to
- * @throws ApexException thrown on errors
- */
- public void apexModelWriteJsonFile(final M model, final Class<M> rootModelClass, final String modelFileName)
- throws ApexException {
- LOGGER.debug("running apexModelWriteJSONFile . . .");
-
- final ApexModelWriter<M> modelWriter = new ApexModelWriter<>(rootModelClass);
- modelWriter.setValidate(validate);
-
- writeModelFile(model, modelWriter, modelFileName);
-
- LOGGER.debug("ran apexModelWriteJSONFile");
- }
-
- /**
- * Write a model to a file using a model writer.
- *
- * @param model The model to write
- * @param modelWriter the model writer to use to write the model to the file
- * @param modelFileName the file name of the file to write to
- * @throws ApexException on exceptions writing the model
- */
- private void writeModelFile(final M model, final ApexModelWriter<M> modelWriter, final String modelFileName)
- throws ApexException {
- final var modelFile = new File(modelFileName);
- if (!modelFile.getParentFile().exists() && !modelFile.getParentFile().mkdirs()) {
- LOGGER.warn("could not create directory " + modelFile.getParentFile());
- throw new ApexException("could not create directory " + modelFile.getParentFile());
- }
-
- try (final var fileOutputStream = new FileOutputStream(modelFile)) {
- modelWriter.write(model, fileOutputStream);
- } catch (final Exception e) {
- LOGGER.warn("error processing file " + modelFile.getAbsolutePath(), e);
- throw new ApexException("error processing file " + modelFile.getAbsolutePath(), e);
- }
- }
-}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelReader.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelReader.java
deleted file mode 100644
index a9bd2fe60..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelReader.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2022 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.
- * 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=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.handling;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.Map;
-import lombok.Getter;
-import lombok.Setter;
-import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
-import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
-import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
-import org.onap.policy.common.utils.resources.TextFileUtils;
-import org.onap.policy.common.utils.validation.Assertions;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-/**
- * This class reads an Apex concept from a file into a Java Apex Concept {@link AxConcept}.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- * @param <C> the type of Apex concept to read, must be a sub class of {@link AxConcept}
- */
-@Getter
-@Setter
-public class ApexModelReader<C extends AxConcept> {
- // Get a reference to the logger
- private static final XLogger LOGGER = XLoggerFactory.getXLogger(ApexModelReader.class);
-
- // Use GSON to deserialize JSON
- private static Gson gson = new GsonBuilder()
- .registerTypeAdapter(AxReferenceKey.class, new ApexModelCustomGsonRefereceKeyAdapter())
- .registerTypeAdapter(Map.class, new ApexModelCustomGsonMapAdapter())
- .setPrettyPrinting()
- .create();
-
- //  The root class of the concept we are reading
- private final Class<C> rootConceptClass;
-
- // All read concepts are validated after reading if this flag is set
- private boolean validate = true;
-
- /**
- * Constructor, initiates the reader with validation on.
- *
- * @param rootConceptClass the root concept class for concept reading
- * @throws ApexModelException the apex concept reader exception
- */
- public ApexModelReader(final Class<C> rootConceptClass) throws ApexModelException {
- // Save the root concept class
- this.rootConceptClass = rootConceptClass;
- }
-
- /**
- * Constructor, initiates the reader.
- *
- * @param rootConceptClass the root concept class for concept reading
- * @param validate whether to perform validation by default
- * @throws ApexModelException the apex concept reader exception
- */
- public ApexModelReader(final Class<C> rootConceptClass, final boolean validate) throws ApexModelException {
- this(rootConceptClass);
- this.validate = validate;
- }
-
- /**
- * This method checks the specified Apex concept file and reads it into an Apex concept.
- *
- * @param apexConceptStream the apex concept stream
- * @return the Apex concept
- * @throws ApexModelException on reading exceptions
- */
- public C read(final InputStream apexConceptStream) throws ApexModelException {
- Assertions.argumentNotNull(apexConceptStream, "concept stream may not be null");
-
- return read(new BufferedReader(new InputStreamReader(apexConceptStream)));
- }
-
- /**
- * This method reads the specified Apex reader into an Apex concept.
- *
- * @param apexConceptReader the apex concept reader
- * @return the Apex concept
- * @throws ApexModelException on reading exceptions
- */
- public C read(final BufferedReader apexConceptReader) throws ApexModelException {
- Assertions.argumentNotNull(apexConceptReader, "concept reader may not be null");
-
- LOGGER.entry("reading Apex concept into a String . . .");
-
- // Get the Apex concept as a string
- String apexConceptString = null;
- try {
- apexConceptString = TextFileUtils.getReaderAsString(apexConceptReader).trim();
- } catch (final IOException e) {
- throw new ApexModelException("Unable to read Apex concept ", e);
- }
-
- return read(apexConceptString);
- }
-
- /**
- * This method reads the specified Apex string into an Apex concept.
- *
- * @param apexConceptString the apex concept as a string
- * @return the Apex concept
- * @throws ApexModelException on reading exceptions
- */
- public C read(final String apexConceptString) throws ApexModelException {
- Assertions.argumentNotNull(apexConceptString, "concept string may not be null");
-
- LOGGER.entry("reading Apex concept from string . . .");
-
- C apexConcept = null;
- try {
- apexConcept = gson.fromJson(apexConceptString, rootConceptClass);
- } catch (final Exception je) {
- throw new ApexModelException("Unable to unmarshal Apex concept ", je);
- }
-
- if (apexConcept == null) {
- throw new ApexModelException("Unable to unmarshal Apex concept, unmarshaled model is null ");
- }
-
- LOGGER.debug("reading of Apex concept {} completed");
-
- apexConcept.buildReferences();
-
- // Check if the concept should be validated
- if (validate) {
- // Validate the configuration file
- final AxValidationResult validationResult = apexConcept.validate(new AxValidationResult());
- if (validationResult.isValid()) {
- return apexConcept;
- } else {
- String message = "Apex concept validation failed" + validationResult.toString();
- LOGGER.error(message);
- throw new ApexModelException(message);
- }
- } else {
- // No validation check
- return apexConcept;
- }
- }
-}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelSaver.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelSaver.java
deleted file mode 100644
index 79d69bdd5..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelSaver.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2022 Nordix Foundation.
- * ================================================================================
- * 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=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.handling;
-
-import java.io.File;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
-import org.onap.policy.apex.model.basicmodel.concepts.AxModel;
-import org.onap.policy.common.utils.validation.Assertions;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-/**
- * This class is used to save Apex models to file in JSON format.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- * @param <M> the type of Apex model to save to file, must be a sub class of {@link AxModel}
- */
-public class ApexModelSaver<M extends AxModel> {
- private static final XLogger LOGGER = XLoggerFactory.getXLogger(ApexModelSaver.class);
-
- // The class of the model and the model to write to disk
- private final Class<M> rootModelClass;
- private final M model;
-
- // The path into which to write the models
- private final String writePath;
-
- /**
- * Constructor, specifies the type of the Apex model (a sub class of {@link AxModel}), the model to write, and the
- * path of a directory to which to write the model.
- *
- * @param rootModelClass the class of the model, a sub class of {@link AxModel}
- * @param model the model to write, an instance of a sub class of {@link AxModel}
- * @param writePath the directory to which models will be written. The name of the written model will be the Model
- * Name for its key with the suffix {@code .json}.
- */
- public ApexModelSaver(final Class<M> rootModelClass, final M model, final String writePath) {
- Assertions.argumentNotNull(rootModelClass, "argument rootModelClass may not be null");
- Assertions.argumentNotNull(model, "argument model may not be null");
- Assertions.argumentNotNull(writePath, "writePath rootModelClass may not be null");
-
- this.rootModelClass = rootModelClass;
- this.model = model;
- this.writePath = writePath;
- }
-
- /**
- * Write an Apex model to a file in JSON format. The model will be written to {@code <writePath/modelKeyName.json>}
- *
- * @throws ApexException on errors writing the Apex model
- */
- public void apexModelWriteJson() throws ApexException {
- LOGGER.debug("running apexModelWriteJSON . . .");
-
- // Write the file to disk
- final var jsonFile = new File(writePath + File.separatorChar + model.getKey().getName() + ".json");
- new ApexModelFileWriter<M>(true).apexModelWriteJsonFile(model, rootModelClass, jsonFile.getPath());
-
- LOGGER.debug("ran apexModelWriteJSON");
- }
-}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelStringWriter.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelStringWriter.java
deleted file mode 100644
index a9df23afc..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelStringWriter.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2022 Nordix Foundation.
- * ================================================================================
- * 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=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.handling;
-
-import java.io.ByteArrayOutputStream;
-import lombok.Getter;
-import lombok.Setter;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
-import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
-import org.onap.policy.common.utils.validation.Assertions;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-/**
- * This class writes an Apex concept to a string.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- * @param <C> the type of Apex concept to write to a string, must be a sub class of {@link AxConcept}
- */
-@Getter
-@Setter
-public class ApexModelStringWriter<C extends AxConcept> {
- private static final XLogger LOGGER = XLoggerFactory.getXLogger(ApexModelStringWriter.class);
-
- // Should concepts being written to files be valid
- private boolean validate;
-
- /**
- * Constructor, set the validation flag.
- *
- * @param validate Should validation be performed prior to output
- */
- public ApexModelStringWriter(final boolean validate) {
- this.validate = validate;
- }
-
- /**
- * Write a concept to a string.
- *
- * @param concept The concept to write
- * @param rootConceptClass The concept class
- * @return The string with the concept
- * @throws ApexException thrown on errors
- */
- public String writeString(final C concept, final Class<C> rootConceptClass)
- throws ApexException {
- Assertions.argumentNotNull(concept, "concept may not be null");
-
- return writeJsonString(concept, rootConceptClass);
- }
-
- /**
- * Write a concept to a JSON string.
- *
- * @param concept The concept to write
- * @param rootConceptClass The concept class
- * @return The string with the concept
- * @throws ApexException thrown on errors
- */
- public String writeJsonString(final C concept, final Class<C> rootConceptClass) throws ApexException {
- LOGGER.debug("running writeJSONString . . .");
-
- final ApexModelWriter<C> conceptWriter = new ApexModelWriter<>(rootConceptClass);
- conceptWriter.setValidate(validate);
-
- try (var baOutputStream = new ByteArrayOutputStream()) {
- conceptWriter.write(concept, baOutputStream);
- return baOutputStream.toString();
- } catch (final Exception e) {
- LOGGER.warn("error writing JSON string", e);
- throw new ApexException("error writing JSON string", e);
- }
-
- }
-}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelWriter.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelWriter.java
deleted file mode 100644
index 349622697..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelWriter.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2022 Nordix Foundation.
- * ================================================================================
- * 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=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.handling;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.util.Map;
-import lombok.Getter;
-import lombok.Setter;
-import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
-import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
-import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
-import org.onap.policy.common.utils.validation.Assertions;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-/**
- * This class writes an Apex concept to a file from a Java Apex Concept.
- *
- * @param <C> the type of Apex concept to write, must be a sub class of {@link AxConcept}
- * @author John Keeney (john.keeney@ericsson.com)
- */
-@Getter
-@Setter
-public class ApexModelWriter<C extends AxConcept> {
-
- private static final String CONCEPT_MAY_NOT_BE_NULL = "concept may not be null";
- private static final String CONCEPT_WRITER_MAY_NOT_BE_NULL = "concept writer may not be null";
- private static final String CONCEPT_STREAM_MAY_NOT_BE_NULL = "concept stream may not be null";
-
- // Use GSON to serialize JSON
- private static Gson gson = new GsonBuilder()
- .registerTypeAdapter(AxReferenceKey.class, new ApexModelCustomGsonRefereceKeyAdapter())
- .registerTypeAdapter(Map.class, new ApexModelCustomGsonMapAdapter())
- .setPrettyPrinting()
- .create();
-
- // Get a reference to the logger
- private static final XLogger LOGGER = XLoggerFactory.getXLogger(ApexModelWriter.class);
-
- //  The root class of the concept we are reading
- private final Class<C> rootConceptClass;
-
- // All written concepts are validated before writing if this flag is set
- private boolean validate = true;
-
- /**
- * Constructor, initiates the writer with validation on.
- *
- * @param rootConceptClass the root concept class for concept reading
- * @throws ApexModelException the apex concept reader exception
- */
- public ApexModelWriter(final Class<C> rootConceptClass) throws ApexModelException {
- // Save the root concept class
- this.rootConceptClass = rootConceptClass;
- }
-
- /**
- * This method validates the Apex concept then writes it into a stream.
- *
- * @param concept the concept to write
- * @param apexConceptStream the stream to write to
- * @throws ApexModelException on validation or writing exceptions
- */
- public void write(final C concept, final OutputStream apexConceptStream) throws ApexModelException {
- Assertions.argumentNotNull(concept, CONCEPT_MAY_NOT_BE_NULL);
- Assertions.argumentNotNull(apexConceptStream, CONCEPT_STREAM_MAY_NOT_BE_NULL);
-
- this.write(concept, new OutputStreamWriter(apexConceptStream));
- }
-
- /**
- * This method validates the Apex concept then writes it into a writer.
- *
- * @param concept the concept to write
- * @param apexConceptWriter the writer to write to
- * @throws ApexModelException on validation or writing exceptions
- */
- public void write(final C concept, final Writer apexConceptWriter) throws ApexModelException {
- Assertions.argumentNotNull(concept, CONCEPT_MAY_NOT_BE_NULL);
- Assertions.argumentNotNull(apexConceptWriter, CONCEPT_WRITER_MAY_NOT_BE_NULL);
-
- // Check if we should validate the concept
- if (validate) {
- // Validate the concept first
- final AxValidationResult validationResult = concept.validate(new AxValidationResult());
- if (!validationResult.isValid()) {
- String message =
- "Apex concept (" + concept.getKey().getId() + ") validation failed: " + validationResult.toString();
- throw new ApexModelException(message);
- }
- }
-
- writeJson(concept, apexConceptWriter);
- }
-
- /**
- * This method writes the Apex concept into a writer in JSON format.
- *
- * @param concept the concept to write
- * @param apexConceptWriter the writer to write to
- * @throws ApexModelException on validation or writing exceptions
- */
- private void writeJson(final C concept, final Writer apexConceptWriter) throws ApexModelException {
- Assertions.argumentNotNull(concept, CONCEPT_MAY_NOT_BE_NULL);
-
- LOGGER.debug("writing Apex concept JSON . . .");
-
- String modelJsonString = null;
- try {
- modelJsonString = gson.toJson(concept, rootConceptClass);
- } catch (Exception je) {
- throw new ApexModelException("Unable to marshal Apex concept to JSON", je);
- }
-
- try {
- apexConceptWriter.write(modelJsonString);
- apexConceptWriter.close();
- } catch (IOException ioe) {
- throw new ApexModelException("Unable to write Apex concept as JSON", ioe);
- }
-
- LOGGER.debug("wrote Apex concept JSON");
- }
-}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/package-info.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/package-info.java
deleted file mode 100644
index 3d6dab3b2..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2022 Nordix Foundation.
- * ================================================================================
- * 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=========================================================
- */
-package org.onap.policy.apex.model.basicmodel.handling;
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/package-info.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/package-info.java
deleted file mode 100644
index 8ad405e25..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/package-info.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019,2022 Nordix Foundation.
- * ================================================================================
- * 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=========================================================
- */
-
-/**
- * Provides the base definition of an APEX model. It also defines the Model Service, the mechanism that allows access to
- * the model for APEX concepts anywhere in the system.
- *
- * <p>It also provides handling support to models, allowing them to be read and written to file and databases in JSON
- * format.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-package org.onap.policy.apex.model.basicmodel;
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/service/ModelService.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/service/ModelService.java
deleted file mode 100644
index c6eb0e011..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/service/ModelService.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * 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=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.service;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexRuntimeException;
-import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
-
-/**
- * The model service makes Apex models available to all classes in a JVM.
- *
- * <p>The reason for having a model service is to avoid having to pass concept and model definitions down long call
- * chains in modules such as the Apex engine and editor. The model service makes the model and concept definitions
- * available statically.
- *
- * <p>Note that the use of the model service means that only a single Apex model of a particular type may exist in Apex
- * (particularly the engine) at any time. Of course the model in a JVM can be changed at any time provided all users of
- * the model are stopped and restarted in an orderly manner.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public abstract class ModelService {
- // The map holding the models
- private static Map<Class<?>, AxConcept> modelMap = new ConcurrentHashMap<>();
-
- /**
- * This class is an abstract static class that cannot be extended.
- */
- private ModelService() {
- }
-
- /**
- * Register a model with the model service.
- *
- * @param <M> the generic type
- * @param modelClass the class of the model, used to index the model
- * @param model The model
- */
- public static <M extends AxConcept> void registerModel(final Class<M> modelClass, final M model) {
- modelMap.put(modelClass, model);
- }
-
- /**
- * Remove a model from the model service.
- *
- * @param <M> the generic type
- * @param modelClass the class of the model, used to index the model
- */
- public static <M extends AxConcept> void deregisterModel(final Class<M> modelClass) {
- modelMap.remove(modelClass);
- }
-
- /**
- * Get a model from the model service.
- *
- * @param <M> the generic type
- * @param modelClass the class of the model, used to index the model
- * @return The model
- */
- @SuppressWarnings("unchecked")
- public static <M extends AxConcept> M getModel(final Class<M> modelClass) {
- final M model = (M) modelMap.get(modelClass);
-
- if (model == null) {
- throw new ApexRuntimeException("Model for " + modelClass.getName() + " not found in model service");
- }
-
- return model;
- }
-
- /**
- * Check if a model is defined on the model service.
- *
- * @param <M> the generic type
- * @param modelClass the class of the model, used to index the model
- * @return true if the model is defined
- */
- public static <M extends AxConcept> boolean existsModel(final Class<M> modelClass) {
- return modelMap.get(modelClass) != null;
- }
-
- /**
- * Clear all models in the model service.
- */
- public static void clear() {
- modelMap.clear();
- }
-}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/service/package-info.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/service/package-info.java
deleted file mode 100644
index a27e45d1a..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/service/package-info.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. 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=========================================================
- */
-
-/**
- * Contains the static services in Apex that make models and parameters available to all objects in the JVM.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-package org.onap.policy.apex.model.basicmodel.service;
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/test/TestApexModel.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/test/TestApexModel.java
deleted file mode 100644
index 9dde47d05..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/test/TestApexModel.java
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2021-2022 Nordix Foundation.
- * ================================================================================
- * 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=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.test;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
-import org.onap.policy.apex.model.basicmodel.concepts.AxModel;
-import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
-import org.onap.policy.apex.model.basicmodel.handling.ApexModelFileWriter;
-import org.onap.policy.apex.model.basicmodel.handling.ApexModelReader;
-import org.onap.policy.apex.model.basicmodel.handling.ApexModelWriter;
-import org.onap.policy.common.utils.resources.ResourceUtils;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-/**
- * This class tests reading and writing of Apex models to file and to a database using JPA. It also tests validation of
- * Apex models. This class is designed for use in unit tests in modules that define Apex models.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- * @param <M> the generic type
- */
-public class TestApexModel<M extends AxModel> {
- private static final String MODEL_IS_INVALID = "model is invalid ";
- private static final String ERROR_PROCESSING_FILE = "error processing file ";
- private static final String TEST_MODEL_UNEQUAL_STR = "test model does not equal model read from file ";
- private static final String TEMP_FILE_CREATE_ERR_STR = "error creating temporary file for Apex model";
-
- private static final XLogger LOGGER = XLoggerFactory.getXLogger(TestApexModel.class);
-
- // The root model class that specifies the root to import and export from
- private final Class<M> rootModelClass;
-
- // The class that provides the model
- private TestApexModelCreator<M> modelCreator = null;
-
- /**
- * Constructor, defines the subclass of {@link AxModel} that is being tested and the {@link TestApexModelCreator}
- * object that is used to generate Apex models.
- *
- * @param rootModelClass the Apex model class, a sub class of {@link AxModel}
- * @param modelCreator the @link TestApexModelCreator} that will generate Apex models of various types for testing
- */
- public TestApexModel(final Class<M> rootModelClass, final TestApexModelCreator<M> modelCreator) {
- this.rootModelClass = rootModelClass;
- this.modelCreator = modelCreator;
- }
-
- /**
- * Get a test Apex model using the model creator.
- *
- * @return the test Apex model
- */
- public final M getModel() {
- return modelCreator.getModel();
- }
-
- /**
- * Test write and read in JSON format.
- *
- * @throws ApexException on write/read errors
- */
- public final void testApexModelWriteReadJson() throws ApexException {
- LOGGER.debug("running testApexModelWriteReadJSON . . .");
-
- final var model = modelCreator.getModel();
-
- // Write the file to disk
- File jsonFile;
- try {
- jsonFile = File.createTempFile("ApexModel", ".json");
- jsonFile.deleteOnExit();
- } catch (final Exception e) {
- LOGGER.warn(TEMP_FILE_CREATE_ERR_STR, e);
- throw new ApexException(TEMP_FILE_CREATE_ERR_STR, e);
- }
- new ApexModelFileWriter<M>(true).apexModelWriteJsonFile(model, rootModelClass, jsonFile.getPath());
-
- // Read the file from disk
- final ApexModelReader<M> modelReader = new ApexModelReader<>(rootModelClass);
-
- try {
- final var apexModelUrl = ResourceUtils.getLocalFile(jsonFile.getAbsolutePath());
- final var fileModel = modelReader.read(apexModelUrl.openStream());
- checkModelEquality(model, fileModel, TEST_MODEL_UNEQUAL_STR + jsonFile.getAbsolutePath());
- } catch (final Exception e) {
- LOGGER.warn(ERROR_PROCESSING_FILE + jsonFile.getAbsolutePath(), e);
- throw new ApexException(ERROR_PROCESSING_FILE + jsonFile.getAbsolutePath(), e);
- }
-
- final ApexModelWriter<M> modelWriter = new ApexModelWriter<>(rootModelClass);
-
- final var baOutputStream = new ByteArrayOutputStream();
- modelWriter.write(model, baOutputStream);
- final var baInputStream = new ByteArrayInputStream(baOutputStream.toByteArray());
- final var byteArrayModel = modelReader.read(baInputStream);
-
- checkModelEquality(model, byteArrayModel, "test model does not equal JSON marshalled and unmarshalled model");
-
- LOGGER.debug("ran testApexModelWriteReadJSON");
- }
-
- /**
- * Test that an Apex model is valid.
- *
- * @return the result of the validation
- * @throws ApexException thrown on errors validating the Apex model
- */
- public final AxValidationResult testApexModelValid() throws ApexException {
- LOGGER.debug("running testApexModelVaid . . .");
-
- final var model = modelCreator.getModel();
- final AxValidationResult result = model.validate(new AxValidationResult());
-
- if (!result.isValid()) {
- String message = MODEL_IS_INVALID + result.toString();
- LOGGER.warn(message);
- throw new ApexException(message);
- }
-
- LOGGER.debug("ran testApexModelVaid");
- return result;
- }
-
- /**
- * Test that an Apex model is structured incorrectly.
- *
- * @return the result of the validation
- * @throws ApexException thrown on errors validating the Apex model
- */
- public final AxValidationResult testApexModelVaidateMalstructured() throws ApexException {
- LOGGER.debug("running testApexModelVaidateMalstructured . . .");
-
- final var model = modelCreator.getMalstructuredModel();
- final AxValidationResult result = model.validate(new AxValidationResult());
-
- if (result.isValid()) {
- String message = "model should not be valid " + result.toString();
- LOGGER.warn(message);
- throw new ApexException(message);
- }
-
- LOGGER.debug("ran testApexModelVaidateMalstructured");
- return result;
- }
-
- /**
- * Test that an Apex model has observations.
- *
- * @return the result of the validation
- * @throws ApexException thrown on errors validating the Apex model
- */
- public final AxValidationResult testApexModelVaidateObservation() throws ApexException {
- LOGGER.debug("running testApexModelVaidateObservation . . .");
-
- final var model = modelCreator.getObservationModel();
- final AxValidationResult result = model.validate(new AxValidationResult());
-
- if (!result.isValid()) {
- String message = MODEL_IS_INVALID + result.toString();
- LOGGER.warn(message);
- throw new ApexException(message);
- }
-
- if (!result.getValidationResult().equals(AxValidationResult.ValidationResult.OBSERVATION)) {
- LOGGER.warn("model should have observations");
- throw new ApexException("model should have observations");
- }
-
- LOGGER.debug("ran testApexModelVaidateObservation");
- return result;
- }
-
- /**
- * Test that an Apex model has warnings.
- *
- * @return the result of the validation
- * @throws ApexException thrown on errors validating the Apex model
- */
- public final AxValidationResult testApexModelVaidateWarning() throws ApexException {
- LOGGER.debug("running testApexModelVaidateWarning . . .");
-
- final var model = modelCreator.getWarningModel();
- final AxValidationResult result = model.validate(new AxValidationResult());
-
- if (!result.isValid()) {
- String message = MODEL_IS_INVALID + result.toString();
- LOGGER.warn(message);
- throw new ApexException(message);
- }
-
- if (!result.getValidationResult().equals(AxValidationResult.ValidationResult.WARNING)) {
- LOGGER.warn("model should have warnings");
- throw new ApexException("model should have warnings");
- }
-
- LOGGER.debug("ran testApexModelVaidateWarning");
- return result;
- }
-
- /**
- * Test that an Apex model is invalid.
- *
- * @return the result of the validation
- * @throws ApexException thrown on errors validating the Apex model
- */
- public final AxValidationResult testApexModelVaidateInvalidModel() throws ApexException {
- LOGGER.debug("running testApexModelVaidateInvalidModel . . .");
-
- final var model = modelCreator.getInvalidModel();
- final AxValidationResult result = model.validate(new AxValidationResult());
-
- if (result.isValid()) {
- String message = "model should not be valid " + result.toString();
- LOGGER.warn(message);
- throw new ApexException(message);
- }
-
- LOGGER.debug("ran testApexModelVaidateInvalidModel");
- return result;
- }
-
- /**
- * Check if two models are equal.
- *
- * @param leftModel the left model
- * @param rightModel the right model
- * @param errorMessage the error message to output on inequality
- * @throws ApexException the exception to throw on inequality
- */
- public void checkModelEquality(final M leftModel, final M rightModel, final String errorMessage)
- throws ApexException {
- if (!leftModel.equals(rightModel)) {
- LOGGER.warn(errorMessage);
- throw new ApexException(errorMessage);
- }
- }
-}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/test/TestApexModelCreator.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/test/TestApexModelCreator.java
deleted file mode 100644
index 65441a33c..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/test/TestApexModelCreator.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. 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=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.test;
-
-import org.onap.policy.apex.model.basicmodel.concepts.AxModel;
-import org.onap.policy.apex.model.basicmodel.handling.ApexModelCreator;
-
-/**
- * The Interface TestApexModelCreator is used to create models for Apex model tests. It is mainly used by unit tests for
- * Apex domain models so that developers can write test Java programs to create models.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- * @param <M> the generic type
- */
-public interface TestApexModelCreator<M extends AxModel> extends ApexModelCreator<M> {
-
- /**
- * Gets the malstructured model.
- *
- * @return the malstructured model
- */
- M getMalstructuredModel();
-
- /**
- * Gets the observation model.
- *
- * @return the observation model
- */
- M getObservationModel();
-
- /**
- * Gets the warning model.
- *
- * @return the warning model
- */
- M getWarningModel();
-
- /**
- * Gets the invalid model.
- *
- * @return the invalid model
- */
- M getInvalidModel();
-}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/test/package-info.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/test/package-info.java
deleted file mode 100644
index 9bbdd1cce..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/test/package-info.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. 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=========================================================
- */
-
-/**
- * Contains utility classes that allow testing of validation and reads and writes on APEX models to files and databases.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-package org.onap.policy.apex.model.basicmodel.test;
diff --git a/model/basic-model/src/main/resources/doc/JDBCPropertiesExamples.txt b/model/basic-model/src/main/resources/doc/JDBCPropertiesExamples.txt
deleted file mode 100644
index 6e105a68d..000000000
--- a/model/basic-model/src/main/resources/doc/JDBCPropertiesExamples.txt
+++ /dev/null
@@ -1,35 +0,0 @@
-#-------------------------------------------------------------------------------
-# ============LICENSE_START=======================================================
-# Copyright (C) 2016-2018 Ericsson. 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=========================================================
-#-------------------------------------------------------------------------------
-
-Properties jdbcProperties = new Properties();
-jdbcProperties.put("javax.persistence.jdbc.url", "jdbc:postgresql://localhost:5432/apex_test");
-jdbcProperties.put("eclipselink.ddl-generation", "drop-and-create-tables");
-
-Properties jdbcProperties = new Properties();
-jdbcProperties.put("javax.persistence.jdbc.url", "jdbc:postgresql://localhost:5432/apex_test");
-jdbcProperties.put("hibernate.hbm2ddl.auto", "create-drop");
-
-Properties jdbcProperties = new Properties();
-jdbcProperties.put("javax.persistence.jdbc.url", "jdbc:postgresql://localhost:5432/apex");
-jdbcProperties.put("eclipselink.ddl-generation", "create-or-extend-tables");
-
-Properties jdbcProperties = new Properties();
-jdbcProperties.put("javax.persistence.jdbc.url", "jdbc:postgresql://localhost:5432/apex");
-jdbcProperties.put("hibernate.hbm2ddl.auto", "update");