summaryrefslogtreecommitdiffstats
path: root/model/basic-model/src
diff options
context:
space:
mode:
authorramverma <ram.krishna.verma@ericsson.com>2018-05-25 11:55:45 +0100
committerramverma <ram.krishna.verma@ericsson.com>2018-05-25 16:25:25 +0100
commit6029d25f5f3ad43fe02ffe1a4beb1eda0a6ae5e3 (patch)
tree489296a005ced47a3a4acffc6ce64b65f5367d77 /model/basic-model/src
parent5abd3063949496c231ed8d3013c2ab17fc9288bb (diff)
Adding apex event-model module
- Adding apex event-model module - Fixing namespaces Change-Id: If37a1773000ca99eb5d97703fdeb5788ce55365c Issue-ID: POLICY-856 Signed-off-by: ramverma <ram.krishna.verma@ericsson.com>
Diffstat (limited to 'model/basic-model/src')
-rw-r--r--model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/AxArtifactKey.java376
-rw-r--r--model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/AxKeyInformation.java448
-rw-r--r--model/basic-model/src/main/java/org/onap/apex/model/basicmodel/dao/impl/DefaultApexDao.java526
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/ApexConceptException.java (renamed from model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/ApexConceptException.java)2
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/ApexException.java (renamed from model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/ApexException.java)10
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/ApexRuntimeException.java (renamed from model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/ApexRuntimeException.java)2
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxArtifactKey.java384
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConcept.java (renamed from model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/AxConcept.java)32
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConceptGetter.java (renamed from model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/AxConceptGetter.java)2
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConceptGetterImpl.java (renamed from model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/AxConceptGetterImpl.java)30
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKey.java (renamed from model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/AxKey.java)39
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfo.java (renamed from model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/AxKeyInfo.java)79
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInformation.java460
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyUse.java (renamed from model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/AxKeyUse.java)79
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxModel.java (renamed from model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/AxModel.java)178
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxReferenceKey.java (renamed from model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/AxReferenceKey.java)163
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxValidationMessage.java (renamed from model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/AxValidationMessage.java)20
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxValidationResult.java (renamed from model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/AxValidationResult.java)65
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/package-info.java (renamed from model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/package-info.java)16
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/ApexDao.java (renamed from model/basic-model/src/main/java/org/onap/apex/model/basicmodel/dao/ApexDao.java)22
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/ApexDaoFactory.java (renamed from model/basic-model/src/main/java/org/onap/apex/model/basicmodel/dao/ApexDaoFactory.java)28
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/DAOParameters.java (renamed from model/basic-model/src/main/java/org/onap/apex/model/basicmodel/dao/DAOParameters.java)23
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/converters/CDATAConditioner.java (renamed from model/basic-model/src/main/java/org/onap/apex/model/basicmodel/dao/converters/CDATAConditioner.java)17
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/converters/UUID2String.java (renamed from model/basic-model/src/main/java/org/onap/apex/model/basicmodel/dao/converters/UUID2String.java)2
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/converters/package-info.java (renamed from model/basic-model/src/main/java/org/onap/apex/model/basicmodel/dao/converters/package-info.java)17
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/impl/DefaultApexDao.java520
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/impl/package-info.java (renamed from model/basic-model/src/main/java/org/onap/apex/model/basicmodel/dao/impl/package-info.java)4
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/package-info.java (renamed from model/basic-model/src/main/java/org/onap/apex/model/basicmodel/dao/package-info.java)18
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelCreator.java (renamed from model/basic-model/src/main/java/org/onap/apex/model/basicmodel/handling/ApexModelCreator.java)4
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelException.java (renamed from model/basic-model/src/main/java/org/onap/apex/model/basicmodel/handling/ApexModelException.java)4
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelFileWriter.java (renamed from model/basic-model/src/main/java/org/onap/apex/model/basicmodel/handling/ApexModelFileWriter.java)6
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelReader.java (renamed from model/basic-model/src/main/java/org/onap/apex/model/basicmodel/handling/ApexModelReader.java)6
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelSaver.java (renamed from model/basic-model/src/main/java/org/onap/apex/model/basicmodel/handling/ApexModelSaver.java)6
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelStringWriter.java (renamed from model/basic-model/src/main/java/org/onap/apex/model/basicmodel/handling/ApexModelStringWriter.java)6
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelWriter.java (renamed from model/basic-model/src/main/java/org/onap/apex/model/basicmodel/handling/ApexModelWriter.java)6
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexSchemaGenerator.java (renamed from model/basic-model/src/main/java/org/onap/apex/model/basicmodel/handling/ApexSchemaGenerator.java)2
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/package-info.java (renamed from model/basic-model/src/main/java/org/onap/apex/model/basicmodel/handling/package-info.java)23
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/package-info.java (renamed from model/basic-model/src/main/java/org/onap/apex/model/basicmodel/package-info.java)2
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/service/AbstractParameters.java (renamed from model/basic-model/src/main/java/org/onap/apex/model/basicmodel/service/AbstractParameters.java)4
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/service/ModelService.java (renamed from model/basic-model/src/main/java/org/onap/apex/model/basicmodel/service/ModelService.java)6
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/service/ParameterService.java (renamed from model/basic-model/src/main/java/org/onap/apex/model/basicmodel/service/ParameterService.java)4
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/service/package-info.java (renamed from model/basic-model/src/main/java/org/onap/apex/model/basicmodel/service/package-info.java)2
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/test/TestApexModel.java (renamed from model/basic-model/src/main/java/org/onap/apex/model/basicmodel/test/TestApexModel.java)20
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/test/TestApexModelCreator.java (renamed from model/basic-model/src/main/java/org/onap/apex/model/basicmodel/test/TestApexModelCreator.java)6
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/test/package-info.java (renamed from model/basic-model/src/main/java/org/onap/apex/model/basicmodel/test/package-info.java)2
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/xml/AxReferenceKeyAdapter.java (renamed from model/basic-model/src/main/java/org/onap/apex/model/basicmodel/xml/AxReferenceKeyAdapter.java)20
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/xml/package-info.java (renamed from model/basic-model/src/main/java/org/onap/apex/model/basicmodel/xml/package-info.java)16
-rw-r--r--model/basic-model/src/main/resources/xml/example.xsd2
-rw-r--r--model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexBasicModel.java137
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyTest.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/AxKeyTest.java)12
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/TestAxKeyInfo.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/TestAxKeyInfo.java)8
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/TestAxReferenceKey.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/TestAxReferenceKey.java)10
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/TestEntity.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/TestEntity.java)12
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/TestExceptions.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/TestExceptions.java)10
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/TestValidation.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/TestValidation.java)12
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/testKeyUse.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/testKeyUse.java)12
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/dao/EntityTest.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/dao/EntityTest.java)58
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/dao/TestDaoMisc.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/dao/TestDaoMisc.java)50
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/AxModelWithReferences.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/AxModelWithReferences.java)10
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestApexBasicModel.java133
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestApexBasicModelConcepts.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexBasicModelConcepts.java)60
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestApexBasicModelCreator.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexBasicModelCreator.java)12
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestApexTestModelCreator0.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexTestModelCreator0.java)12
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestApexTestModelCreator1.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexTestModelCreator1.java)12
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestApexTestModelCreator2.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexTestModelCreator2.java)12
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestBasicModelTest.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestBasicModelTest.java)68
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestConceptGetter.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestConceptGetter.java)14
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestExceptions.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestExceptions.java)4
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestModelFileWriter.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelFileWriter.java)8
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestModelReader.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelReader.java)10
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestModelSaver.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelSaver.java)8
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestModelStringWriter.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelStringWriter.java)10
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestModelWriter.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelWriter.java)8
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestSchemaGenerator.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestSchemaGenerator.java)48
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/IllegalParameters.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/IllegalParameters.java)4
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/LegalParameters.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/LegalParameters.java)4
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/TestAbstractParameters.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/TestAbstractParameters.java)26
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/TestModelService.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/TestModelService.java)50
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/TestParameterService.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/TestParameterService.java)42
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/xml/TestAxReferenceKeyAdapter.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/xml/TestAxReferenceKeyAdapter.java)6
-rw-r--r--model/basic-model/src/test/resources/META-INF/persistence.xml16
-rw-r--r--model/basic-model/src/test/resources/logback-test.xml10
82 files changed, 2347 insertions, 2270 deletions
diff --git a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/AxArtifactKey.java b/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/AxArtifactKey.java
deleted file mode 100644
index 1de7ae72e..000000000
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/AxArtifactKey.java
+++ /dev/null
@@ -1,376 +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.apex.model.basicmodel.concepts;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.persistence.Column;
-import javax.persistence.Embeddable;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlType;
-
-import org.onap.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
-import org.onap.policy.apex.model.utilities.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 {@link NAME_REGEXP} and {@link VERSION_REGEXP} regular expressions respectively.
- */
-@Embeddable
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlRootElement(name = "apexArtifactKey", namespace = "http://www.ericsson.com/apex")
-
-@XmlType(name = "AxArtifactKey", namespace = "http://www.ericsson.com/apex", propOrder = { "name", "version" })
-
-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";
-
- @Column(name = NAME_TOKEN)
- @XmlElement(required = true)
- private String name;
-
- @Column(name = VERSION_TOKEN)
- @XmlElement(required = true)
- 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 {@link 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);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#getKey()
- */
- @Override
- public AxArtifactKey getKey() {
- return this;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#getKeys()
- */
- @Override
- public List<AxKey> getKeys() {
- final List<AxKey> keyList = new ArrayList<>();
- keyList.add(getKey());
- return keyList;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.model.basicmodel.concepts.AxKey#getID()
- */
- @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);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.model.basicmodel.concepts.AxKey#getCompatibility(com. ericsson.apex.model.basicmodel.concepts.AxKey)
- */
- @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;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.model.basicmodel.concepts.AxKey#isCompatible(com. ericsson.apex.model.basicmodel.concepts.AxKey)
- */
- @Override
- public boolean isCompatible(final AxKey otherKey) {
- if (!(otherKey instanceof AxArtifactKey)) {
- return false;
- }
- final AxArtifactKey otherArtifactKey = (AxArtifactKey) otherKey;
-
- final Compatibility compatibility = this.getCompatibility(otherArtifactKey);
-
- return !(compatibility == Compatibility.DIFFERENT || compatibility == Compatibility.MAJOR);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#validate(com. ericsson.apex.model.basicmodel.concepts.AxValidationResult)
- */
- @Override
- public AxValidationResult validate(final AxValidationResult result) {
- try {
- Assertions.validateStringParameter(NAME_TOKEN, name, NAME_REGEXP);
- }
- catch (final IllegalArgumentException e) {
- result.addValidationMessage(
- new AxValidationMessage(this, this.getClass(), ValidationResult.INVALID, "name invalid-" + e.getMessage()));
- }
-
- try {
- Assertions.validateStringParameter(VERSION_TOKEN, version, VERSION_REGEXP);
- }
- catch (final IllegalArgumentException e) {
- result.addValidationMessage(
- new AxValidationMessage(this, this.getClass(), ValidationResult.INVALID, "version invalid-" + e.getMessage()));
- }
-
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#clean()
- */
- @Override
- public void clean() {
- name = Assertions.validateStringParameter(NAME_TOKEN, name, NAME_REGEXP);
- version = Assertions.validateStringParameter(VERSION_TOKEN, version, VERSION_REGEXP);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#toString()
- */
- @Override
- public String toString() {
- final StringBuilder 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();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#copyTo(com.ericsson.apex.model.basicmodel.concepts.AxConcept)
- */
- @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;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + name.hashCode();
- result = prime * result + version.hashCode();
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#equals(java.lang. Object)
- */
- @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);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- @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/apex/model/basicmodel/concepts/AxKeyInformation.java b/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/AxKeyInformation.java
deleted file mode 100644
index 3082c4f5d..000000000
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/AxKeyInformation.java
+++ /dev/null
@@ -1,448 +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.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 javax.persistence.CascadeType;
-import javax.persistence.EmbeddedId;
-import javax.persistence.Entity;
-import javax.persistence.JoinColumn;
-import javax.persistence.JoinTable;
-import javax.persistence.ManyToMany;
-import javax.persistence.Table;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlType;
-
-import org.onap.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
-import org.onap.policy.apex.model.utilities.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.
- */
-@Entity
-@Table(name = "AxKeyInformation")
-
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "AxKeyInformation", namespace = "http://www.ericsson.com/apex", propOrder = { "key", "keyInfoMap" })
-
-public class AxKeyInformation extends AxConcept implements AxConceptGetter<AxKeyInfo> {
- private static final long serialVersionUID = -2746380769017043888L;
-
- @EmbeddedId
- @XmlElement(name = "key", required = true)
- private AxArtifactKey key;
-
- // @formatter:off
- @ManyToMany(cascade = CascadeType.ALL)
- @JoinTable(
- joinColumns = {
- @JoinColumn(name = "keyInfoMapName", referencedColumnName = "name"),
- @JoinColumn(name = "keyInfoMapVersion", referencedColumnName = "version"),
- },
- inverseJoinColumns = {
- @JoinColumn(name = "keyInfoName", referencedColumnName = "name"),
- @JoinColumn(name = "keyInfoVersion", referencedColumnName = "version")
- })
- private Map<AxArtifactKey, AxKeyInfo> keyInfoMap;
- // @formatter:on
-
- /**
- * 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<AxArtifactKey, AxKeyInfo>());
- }
-
- /**
- * 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);
- }
-
- /**
- * When a model is unmarshalled from disk or from the database, the key information map is returned as a raw Hash Map. This method is called by JAXB
- * after unmarshaling and is used to convert the hash map to a {@link NavigableMap} so that it will work with the {@link AxConceptGetter} interface.
- *
- * @param u the unmarshaler that is unmarshaling the model
- * @param parent the parent object of this object in the unmarshaler
- */
- public void afterUnmarshal(final Unmarshaller u, final Object parent) {
- // The map must be navigable to allow name and version searching,
- // unmarshaling returns a hash map
- final NavigableMap<AxArtifactKey, AxKeyInfo> navigablekeyInfoMap = new TreeMap<>();
- navigablekeyInfoMap.putAll(keyInfoMap);
- keyInfoMap = navigablekeyInfoMap;
- }
-
- /**
- * 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;
- if (!keyInfoMap.containsKey(artifactKey)) {
- final AxKeyInfo keyInfo = new AxKeyInfo(artifactKey);
- //generate a reproducible UUID
- keyInfo.setUuid(AxKeyInfo.generateReproducibleUUID(keyInfo.getID() + keyInfo.getDescription()));
- keyInfoMap.put(artifactKey, keyInfo);
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#getKey()
- */
- @Override
- public AxArtifactKey getKey() {
- return key;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#getKeys()
- */
- @Override
- public List<AxKey> getKeys() {
- final List<AxKey> keyList = key.getKeys();
- keyList.addAll(keyInfoMap.keySet());
-
- 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 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);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#validate(com. ericsson.apex.model.basicmodel.concepts.AxValidationResult)
- */
- @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 an 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, 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;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#clean()
- */
- @Override
- public void clean() {
- key.clean();
- for (final Entry<AxArtifactKey, AxKeyInfo> keyInfoEntry : keyInfoMap.entrySet()) {
- keyInfoEntry.getKey().clean();
- keyInfoEntry.getValue().clean();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#toString()
- */
- @Override
- public String toString() {
- final StringBuilder 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();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#copyTo(com.ericsson.apex.model.basicmodel.concepts.AxConcept)
- */
- @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;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + key.hashCode();
- result = prime * result + keyInfoMap.hashCode();
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#equals(java.lang. Object)
- */
- @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);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- @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;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.core.basicmodel.concepts.AxConceptGetter#get(com. ericsson.apex.core.basicmodel.concepts.AxArtifactKey)
- */
- @Override
- public AxKeyInfo get(final AxArtifactKey conceptKey) {
- return new AxConceptGetterImpl<>((NavigableMap<AxArtifactKey, AxKeyInfo>) keyInfoMap).get(conceptKey);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.core.basicmodel.concepts.AxConceptGetter#get(java.lang. String)
- */
- @Override
- public AxKeyInfo get(final String conceptKeyName) {
- return new AxConceptGetterImpl<>((NavigableMap<AxArtifactKey, AxKeyInfo>) keyInfoMap).get(conceptKeyName);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.core.basicmodel.concepts.AxConceptGetter#get(java.lang. String, java.lang.String)
- */
- @Override
- public AxKeyInfo get(final String conceptKeyName, final String conceptKeyVersion) {
- return new AxConceptGetterImpl<>((NavigableMap<AxArtifactKey, AxKeyInfo>) keyInfoMap).get(conceptKeyName, conceptKeyVersion);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.core.basicmodel.concepts.AxConceptGetter#getAll(java. lang.String)
- */
- @Override
- public Set<AxKeyInfo> getAll(final String conceptKeyName) {
- return new AxConceptGetterImpl<>((NavigableMap<AxArtifactKey, AxKeyInfo>) keyInfoMap).getAll(conceptKeyName);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.core.basicmodel.concepts.AxConceptGetter#getAll(java. lang.String, java.lang.String)
- */
- @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/apex/model/basicmodel/dao/impl/DefaultApexDao.java b/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/dao/impl/DefaultApexDao.java
deleted file mode 100644
index a73a15e41..000000000
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/dao/impl/DefaultApexDao.java
+++ /dev/null
@@ -1,526 +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.apex.model.basicmodel.dao.impl;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.Persistence;
-
-import org.onap.apex.model.basicmodel.concepts.ApexException;
-import org.onap.apex.model.basicmodel.concepts.ApexRuntimeException;
-import org.onap.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.apex.model.basicmodel.concepts.AxConcept;
-import org.onap.apex.model.basicmodel.concepts.AxReferenceKey;
-import org.onap.apex.model.basicmodel.dao.ApexDao;
-import org.onap.apex.model.basicmodel.dao.DAOParameters;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-/**
- * The Class DefaultApexDao is an JPA implementation of the {@link ApexDao} class for Apex concepts ({@link AxConcept}). It uses the default
- * JPA implementation in the javax {@link Persistence} class.
- *
- *
- * @author Sergey Sachkov (sergey.sachkov@ericsson.com)
- */
-public class DefaultApexDao implements ApexDao {
- private static final XLogger LOGGER = XLoggerFactory.getXLogger(DefaultApexDao.class);
-
- private static final String SELECT_C_FROM = "SELECT c FROM ";
- private static final String AND_C_KEY_LOCAL_NAME = "' AND c.key.localName='";
- private static final String AND_C_KEY_PARENT_KEY_VERSION = "' AND c.key.parentKeyVersion='";
- private static final String C_WHERE_C_KEY_PARENT_KEY_NAME = " c WHERE c.key.parentKeyName='";
- private static final String AND_C_KEY_VERSION = "' AND c.key.version='";
- private static final String C_WHERE_C_KEY_NAME = " c WHERE c.key.name='";
- private static final String DELETE_FROM = "DELETE FROM ";
-
- // Entity manager for JPA
- private EntityManagerFactory emf = null;
-
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.model.basicmodel.dao.ApexDao#init(com.ericsson.apex.model.basicmodel.dao.DAOParameters)
- */
- @Override
- public void init(final DAOParameters daoParameters) throws ApexException {
- if (daoParameters == null || daoParameters.getPersistenceUnit() == null) {
- LOGGER.error("Apex persistence unit parameter not set");
- throw new ApexException("Apex persistence unit parameter not set");
- }
-
- LOGGER.debug("Creating Apex persistence unit \"" + daoParameters.getPersistenceUnit() + "\" . . .");
- try {
- emf = Persistence.createEntityManagerFactory(daoParameters.getPersistenceUnit(), daoParameters.getJdbcProperties());
- }
- catch (final Exception e) {
- LOGGER.warn("Creation of Apex persistence unit \"" + daoParameters.getPersistenceUnit() + "\" failed", e);
- throw new ApexException("Creation of Apex persistence unit \"" + daoParameters.getPersistenceUnit() + "\" failed", e);
- }
- LOGGER.debug("Created Apex persistence unit \"" + daoParameters.getPersistenceUnit() + "\"");
- }
-
- /**
- * Gets the entity manager for this DAO.
- *
- * @return the entity manager
- */
- protected final synchronized EntityManager getEntityManager() {
- if (emf == null) {
- LOGGER.warn("Apex DAO has not been initialized");
- throw new ApexRuntimeException("Apex DAO has not been initialized");
- }
-
- return emf.createEntityManager();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.model.basicmodel.dao.ApexDao#close()
- */
- @Override
- public final void close() {
- if (emf != null) {
- emf.close();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.model.basicmodel.dao.ApexDao#create(com.ericsson.apex.model.basicmodel.concepts.AxConcept)
- */
- @Override
- public <T extends AxConcept> void create(final T obj) {
- if (obj == null) {
- return;
- }
- final EntityManager mg = getEntityManager();
- try {
- mg.getTransaction().begin();
- mg.merge(obj);
- mg.getTransaction().commit();
- }
- finally {
- mg.close();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.model.basicmodel.dao.ApexDao#delete(com.ericsson.apex.model.basicmodel.concepts.AxConcept)
- */
- @Override
- public <T extends AxConcept> void delete(final T obj) {
- if (obj == null) {
- return;
- }
- final EntityManager mg = getEntityManager();
- try {
- mg.getTransaction().begin();
- mg.remove(mg.contains(obj) ? obj : mg.merge(obj));
- mg.getTransaction().commit();
- }
- finally {
- mg.close();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.model.basicmodel.dao.ApexDao#delete(java.lang.Class,
- * com.ericsson.apex.model.basicmodel.concepts.AxArtifactKey)
- */
- @Override
- public <T extends AxConcept> void delete(final Class<T> aClass, final AxArtifactKey key) {
- if (key == null) {
- return;
- }
- final EntityManager mg = getEntityManager();
- try {
- mg.getTransaction().begin();
- mg.createQuery(DELETE_FROM + aClass.getSimpleName() + C_WHERE_C_KEY_NAME + key.getName() + AND_C_KEY_VERSION
- + key.getVersion() + "'", aClass).executeUpdate();
- mg.getTransaction().commit();
- }
- finally {
- mg.close();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.model.basicmodel.dao.ApexDao#delete(java.lang.Class,
- * com.ericsson.apex.model.basicmodel.concepts.AxReferenceKey)
- */
- @Override
- public <T extends AxConcept> void delete(final Class<T> aClass, final AxReferenceKey key) {
- if (key == null) {
- return;
- }
- final EntityManager mg = getEntityManager();
- try {
- mg.getTransaction().begin();
- mg.createQuery(DELETE_FROM + aClass.getSimpleName() + C_WHERE_C_KEY_PARENT_KEY_NAME + key.getParentKeyName()
- + AND_C_KEY_PARENT_KEY_VERSION + key.getParentKeyVersion() + AND_C_KEY_LOCAL_NAME + key.getLocalName() + "'",
- aClass).executeUpdate();
- mg.getTransaction().commit();
- }
- finally {
- mg.close();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.model.basicmodel.dao.ApexDao#create(java.util.Collection)
- */
- @Override
- public <T extends AxConcept> void create(final Collection<T> objs) {
- if (objs == null || objs.isEmpty()) {
- return;
- }
- final EntityManager mg = getEntityManager();
- try {
- mg.getTransaction().begin();
- for (final T t : objs) {
- mg.merge(t);
- }
- mg.getTransaction().commit();
- }
- finally {
- mg.close();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.model.basicmodel.dao.ApexDao#delete(java.util.Collection)
- */
- @Override
- public <T extends AxConcept> void delete(final Collection<T> objs) {
- if (objs == null || objs.isEmpty()) {
- return;
- }
- final EntityManager mg = getEntityManager();
- try {
- mg.getTransaction().begin();
- for (final T t : objs) {
- mg.remove(mg.contains(t) ? t : mg.merge(t));
- }
- mg.getTransaction().commit();
- }
- finally {
- mg.close();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.model.basicmodel.dao.ApexDao#deleteByArtifactKey(java.lang.Class, java.util.Collection)
- */
- @Override
- public <T extends AxConcept> int deleteByArtifactKey(final Class<T> aClass, final Collection<AxArtifactKey> keys) {
- if (keys == null || keys.isEmpty()) {
- return 0;
- }
- int deletedCount = 0;
- final EntityManager mg = getEntityManager();
- try {
- mg.getTransaction().begin();
- for (final AxArtifactKey key : keys) {
- deletedCount += mg.createQuery(DELETE_FROM + aClass.getSimpleName() + C_WHERE_C_KEY_NAME + key.getName()
- + AND_C_KEY_VERSION + key.getVersion() + "'", aClass).executeUpdate();
- }
- mg.getTransaction().commit();
- }
- finally {
- mg.close();
- }
- return deletedCount;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.model.basicmodel.dao.ApexDao#deleteByReferenceKey(java.lang.Class, java.util.Collection)
- */
- @Override
- public <T extends AxConcept> int deleteByReferenceKey(final Class<T> aClass, final Collection<AxReferenceKey> keys) {
- if (keys == null || keys.isEmpty()) {
- return 0;
- }
- int deletedCount = 0;
- final EntityManager mg = getEntityManager();
- try {
- mg.getTransaction().begin();
- for (final AxReferenceKey key : keys) {
- deletedCount += mg.createQuery(DELETE_FROM + aClass.getSimpleName() + C_WHERE_C_KEY_PARENT_KEY_NAME
- + key.getParentKeyName() + AND_C_KEY_PARENT_KEY_VERSION + key.getParentKeyVersion() + AND_C_KEY_LOCAL_NAME
- + key.getLocalName() + "'", aClass).executeUpdate();
- }
- mg.getTransaction().commit();
- }
- finally {
- mg.close();
- }
- return deletedCount;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.model.basicmodel.dao.ApexDao#deleteAll(java.lang.Class)
- */
- @Override
- public <T extends AxConcept> void deleteAll(final Class<T> aClass) {
- final EntityManager mg = getEntityManager();
- try {
- mg.getTransaction().begin();
- mg.createQuery(DELETE_FROM + aClass.getSimpleName() + " c ", aClass).executeUpdate();
- mg.getTransaction().commit();
- }
- finally {
- mg.close();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.model.basicmodel.dao.ApexDao#get(java.lang.Class, com.ericsson.apex.model.basicmodel.concepts.AxArtifactKey)
- */
- @Override
- public <T extends AxConcept> T get(final Class<T> aClass, final AxArtifactKey key) {
- if (aClass == null) {
- return null;
- }
- final EntityManager mg = getEntityManager();
- try {
- final T t = mg.find(aClass, key);
- if (t != null) {
- // This clone is created to force the JPA DAO to recurse down through the object
- try {
- T clonedT = aClass.newInstance();
- t.copyTo(clonedT);
- return clonedT;
- }
- catch (Exception e) {
- LOGGER.warn("Could not clone object of class \"" + aClass.getCanonicalName() + "\"", e);
- return null;
- }
- }
- else {
- return null;
- }
- }
- finally {
- mg.close();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.model.basicmodel.dao.ApexDao#get(java.lang.Class, com.ericsson.apex.model.basicmodel.concepts.AxReferenceKey)
- */
- @Override
- public <T extends AxConcept> T get(final Class<T> aClass, final AxReferenceKey key) {
- if (aClass == null) {
- return null;
- }
- final EntityManager mg = getEntityManager();
- try {
- final T t = mg.find(aClass, key);
- if (t != null) {
- try {
- T clonedT = aClass.newInstance();
- t.copyTo(clonedT);
- return clonedT;
- }
- catch (Exception e) {
- LOGGER.warn("Could not clone object of class \"" + aClass.getCanonicalName() + "\"", e);
- return null;
- }
- }
- else {
- return null;
- }
- }
- finally {
- mg.close();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.model.basicmodel.dao.ApexDao#getAll(java.lang.Class)
- */
- @Override
- public <T extends AxConcept> List<T> getAll(final Class<T> aClass) {
- if (aClass == null) {
- return Collections.emptyList();
- }
- final EntityManager mg = getEntityManager();
- try {
- return mg.createQuery(SELECT_C_FROM + aClass.getSimpleName() + " c", aClass).getResultList();
- }
- finally {
- mg.close();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.model.basicmodel.dao.ApexDao#getAll(java.lang.Class,
- * com.ericsson.apex.model.basicmodel.concepts.AxArtifactKey)
- */
- @Override
- public <T extends AxConcept> List<T> getAll(final Class<T> aClass, final AxArtifactKey parentKey) {
- if (aClass == null) {
- return Collections.emptyList();
- }
- final EntityManager mg = getEntityManager();
- try {
- return mg.createQuery(SELECT_C_FROM + aClass.getSimpleName() + C_WHERE_C_KEY_PARENT_KEY_NAME + parentKey.getName()
- + AND_C_KEY_PARENT_KEY_VERSION + parentKey.getVersion() + "'", aClass).getResultList();
- }
- finally {
- mg.close();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.model.basicmodel.dao.ApexDao#getArtifact(java.lang.Class,
- * com.ericsson.apex.model.basicmodel.concepts.AxArtifactKey)
- */
- @Override
- public <T extends AxConcept> T getArtifact(final Class<T> aClass, final AxArtifactKey key) {
- if (aClass == null || key == null) {
- return null;
- }
- final EntityManager mg = getEntityManager();
- List<T> ret;
- try {
- ret = mg.createQuery(SELECT_C_FROM + aClass.getSimpleName() + C_WHERE_C_KEY_NAME + key.getName()
- + AND_C_KEY_VERSION + key.getVersion() + "'", aClass).getResultList();
- }
- finally {
- mg.close();
- }
- if (ret == null || ret.isEmpty()) {
- return null;
- }
- if (ret.size() > 1) {
- throw new IllegalArgumentException(
- "More than one result was returned for search for " + aClass + " with key " + key.getID() + ": " + ret);
- }
- return ret.get(0);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.model.basicmodel.dao.ApexDao#getArtifact(java.lang.Class,
- * com.ericsson.apex.model.basicmodel.concepts.AxReferenceKey)
- */
- @Override
- public <T extends AxConcept> T getArtifact(final Class<T> aClass, final AxReferenceKey key) {
- if (aClass == null || key == null) {
- return null;
- }
- final EntityManager mg = getEntityManager();
- List<T> ret;
- try {
- ret = mg.createQuery(SELECT_C_FROM + aClass.getSimpleName() + C_WHERE_C_KEY_PARENT_KEY_NAME + key.getParentKeyName()
- + AND_C_KEY_PARENT_KEY_VERSION + key.getParentKeyVersion() + AND_C_KEY_LOCAL_NAME + key.getLocalName() + "'",
- aClass).getResultList();
- }
- finally {
- mg.close();
- }
- if (ret == null || ret.isEmpty()) {
- return null;
- }
- if (ret.size() > 1) {
- throw new IllegalArgumentException(
- "More than one result was returned for search for " + aClass + " with key " + key.getID() + ": " + ret);
- }
- return ret.get(0);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.model.basicmodel.dao.ApexDao#update(com.ericsson.apex.model.basicmodel.concepts.AxConcept)
- */
- @Override
- public <T extends AxConcept> T update(final T obj) {
- final EntityManager mg = getEntityManager();
- T ret;
- try {
- mg.getTransaction().begin();
- ret = mg.merge(obj);
- mg.flush();
- mg.getTransaction().commit();
- }
- finally {
- mg.close();
- }
- return ret;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.model.basicmodel.dao.ApexDao#size(java.lang.Class)
- */
- @Override
- public <T extends AxConcept> long size(final Class<T> aClass) {
- if (aClass == null) {
- return 0;
- }
- final EntityManager mg = getEntityManager();
- long size = 0;
- try {
- size = mg.createQuery("SELECT COUNT(c) FROM " + aClass.getSimpleName() + " c", Long.class).getSingleResult();
- }
- finally {
- mg.close();
- }
- return size;
- }
-}
diff --git a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/ApexConceptException.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/ApexConceptException.java
index bfe296d97..1ffb2776c 100644
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/ApexConceptException.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/ApexConceptException.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.apex.model.basicmodel.concepts;
+package org.onap.policy.apex.model.basicmodel.concepts;
/**
* This class is an exception thrown on Apex Concept errors.
diff --git a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/ApexException.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/ApexException.java
index 74a60e243..2dcbf7bcf 100644
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/ApexException.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/ApexException.java
@@ -1,24 +1,24 @@
-/*
+/*-
* ============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.apex.model.basicmodel.concepts;
+package org.onap.policy.apex.model.basicmodel.concepts;
/**
* This class is a base exception from which all Apex exceptions are sub classes.
diff --git a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/ApexRuntimeException.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/ApexRuntimeException.java
index 4cdfbe4b0..f3db3ae60 100644
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/ApexRuntimeException.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/ApexRuntimeException.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.apex.model.basicmodel.concepts;
+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.
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
new file mode 100644
index 000000000..382d5024f
--- /dev/null
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxArtifactKey.java
@@ -0,0 +1,384 @@
+/*-
+ * ============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.ArrayList;
+import java.util.List;
+
+import javax.persistence.Column;
+import javax.persistence.Embeddable;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
+import org.onap.policy.apex.model.utilities.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 {@link NAME_REGEXP} and {@link VERSION_REGEXP}
+ * regular expressions respectively.
+ */
+@Embeddable
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlRootElement(name = "apexArtifactKey", namespace = "http://www.onap.org/policy/apex-pdp")
+
+@XmlType(name = "AxArtifactKey", namespace = "http://www.onap.org/policy/apex-pdp", propOrder = { "name", "version" })
+
+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";
+
+ @Column(name = NAME_TOKEN)
+ @XmlElement(required = true)
+ private String name;
+
+ @Column(name = VERSION_TOKEN)
+ @XmlElement(required = true)
+ 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 {@link 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);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#getKey()
+ */
+ @Override
+ public AxArtifactKey getKey() {
+ return this;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#getKeys()
+ */
+ @Override
+ public List<AxKey> getKeys() {
+ final List<AxKey> keyList = new ArrayList<>();
+ keyList.add(getKey());
+ return keyList;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxKey#getID()
+ */
+ @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);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxKey#getCompatibility(org.onap.policy.apex.model.basicmodel.
+ * concepts.AxKey)
+ */
+ @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;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.onap.policy.apex.model.basicmodel.concepts.AxKey#isCompatible(org.onap.policy.apex.model.basicmodel.concepts.
+ * AxKey)
+ */
+ @Override
+ public boolean isCompatible(final AxKey otherKey) {
+ if (!(otherKey instanceof AxArtifactKey)) {
+ return false;
+ }
+ final AxArtifactKey otherArtifactKey = (AxArtifactKey) otherKey;
+
+ final Compatibility compatibility = this.getCompatibility(otherArtifactKey);
+
+ return !(compatibility == Compatibility.DIFFERENT || compatibility == Compatibility.MAJOR);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.onap.policy.apex.model.basicmodel.concepts.AxConcept#validate(org.onap.policy.apex.model.basicmodel.concepts.
+ * AxValidationResult)
+ */
+ @Override
+ public AxValidationResult validate(final AxValidationResult result) {
+ try {
+ Assertions.validateStringParameter(NAME_TOKEN, name, NAME_REGEXP);
+ } catch (final IllegalArgumentException e) {
+ result.addValidationMessage(new AxValidationMessage(this, this.getClass(), ValidationResult.INVALID,
+ "name invalid-" + e.getMessage()));
+ }
+
+ try {
+ Assertions.validateStringParameter(VERSION_TOKEN, version, VERSION_REGEXP);
+ } catch (final IllegalArgumentException e) {
+ result.addValidationMessage(new AxValidationMessage(this, this.getClass(), ValidationResult.INVALID,
+ "version invalid-" + e.getMessage()));
+ }
+
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#clean()
+ */
+ @Override
+ public void clean() {
+ name = Assertions.validateStringParameter(NAME_TOKEN, name, NAME_REGEXP);
+ version = Assertions.validateStringParameter(VERSION_TOKEN, version, VERSION_REGEXP);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#toString()
+ */
+ @Override
+ public String toString() {
+ final StringBuilder 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();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.onap.policy.apex.model.basicmodel.concepts.AxConcept#copyTo(org.onap.policy.apex.model.basicmodel.concepts.
+ * AxConcept)
+ */
+ @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;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + name.hashCode();
+ result = prime * result + version.hashCode();
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#equals(java.lang. Object)
+ */
+ @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);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ @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/apex/model/basicmodel/concepts/AxConcept.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConcept.java
index 005d17d76..3d7f5027f 100644
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/AxConcept.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConcept.java
@@ -1,24 +1,24 @@
-/*
+/*-
* ============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.apex.model.basicmodel.concepts;
+package org.onap.policy.apex.model.basicmodel.concepts;
import java.io.Serializable;
import java.util.List;
@@ -28,13 +28,13 @@ import javax.xml.bind.annotation.XmlType;
import org.onap.policy.apex.model.utilities.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.
+ * 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)
*/
-@XmlType(name = "AxConcept", namespace = "http://www.ericsson.com/apex")
+@XmlType(name = "AxConcept", namespace = "http://www.onap.org/policy/apex-pdp")
public abstract class AxConcept implements Serializable, Comparable<AxConcept> {
private static final long serialVersionUID = -7434939557282697490L;
@@ -42,18 +42,18 @@ public abstract class AxConcept implements Serializable, Comparable<AxConcept> {
/**
* Default constructor
*/
- public AxConcept() {
- }
-
+ public AxConcept() {}
+
/**
* Copy constructor
+ *
* @param copyConcept the concept to copy from
*/
public AxConcept(final AxConcept copyConcept) {
Assertions.argumentNotNull(copyConcept, "copy concept may not be null");
- copyConcept.copyTo(this);
+ copyConcept.copyTo(this);
}
-
+
/**
* Gets the key of this concept.
*
@@ -62,7 +62,8 @@ public abstract class AxConcept implements Serializable, Comparable<AxConcept> {
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.
+ * 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
*/
@@ -72,7 +73,8 @@ public abstract class AxConcept implements Serializable, Comparable<AxConcept> {
* 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
+ * @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);
diff --git a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/AxConceptGetter.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConceptGetter.java
index d5d1752e6..0735f87c3 100644
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/AxConceptGetter.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConceptGetter.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.apex.model.basicmodel.concepts;
+package org.onap.policy.apex.model.basicmodel.concepts;
import java.util.Set;
diff --git a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/AxConceptGetterImpl.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConceptGetterImpl.java
index af9764113..b4bff80c8 100644
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/AxConceptGetterImpl.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConceptGetterImpl.java
@@ -1,24 +1,24 @@
-/*
+/*-
* ============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.apex.model.basicmodel.concepts;
+package org.onap.policy.apex.model.basicmodel.concepts;
import java.util.NavigableMap;
import java.util.Set;
@@ -49,7 +49,8 @@ public class AxConceptGetterImpl<C> implements AxConceptGetter<C> {
/*
* (non-Javadoc)
*
- * @see com.ericsson.apex.core.basicmodel.concepts.AxConceptGetter#get(com. ericsson.apex.core.basicmodel.concepts.AxArtifactKey)
+ * @see org.onap.policy.apex.core.basicmodel.concepts.AxConceptGetter#get(org.onap.policy.apex.apex.core.basicmodel.
+ * concepts.AxArtifactKey)
*/
@Override
public C get(final AxArtifactKey conceptKey) {
@@ -59,7 +60,7 @@ public class AxConceptGetterImpl<C> implements AxConceptGetter<C> {
/*
* (non-Javadoc)
*
- * @see com.ericsson.apex.core.basicmodel.concepts.AxConceptGetter#get(java.lang. String)
+ * @see org.onap.policy.apex.core.basicmodel.concepts.AxConceptGetter#get(java.lang. String)
*/
@Override
public C get(final String conceptKeyName) {
@@ -81,8 +82,7 @@ public class AxConceptGetterImpl<C> implements AxConceptGetter<C> {
break;
}
foundKey = nextkey;
- }
- while (true);
+ } while (true);
return conceptMap.get(foundKey);
}
@@ -90,7 +90,7 @@ public class AxConceptGetterImpl<C> implements AxConceptGetter<C> {
/*
* (non-Javadoc)
*
- * @see com.ericsson.apex.core.basicmodel.concepts.AxConceptGetter#get(java.lang. String, java.lang.String)
+ * @see org.onap.policy.apex.core.basicmodel.concepts.AxConceptGetter#get(java.lang. String, java.lang.String)
*/
@Override
public C get(final String conceptKeyName, final String conceptKeyVersion) {
@@ -98,8 +98,7 @@ public class AxConceptGetterImpl<C> implements AxConceptGetter<C> {
if (conceptKeyVersion != null) {
return conceptMap.get(new AxArtifactKey(conceptKeyName, conceptKeyVersion));
- }
- else {
+ } else {
return this.get(conceptKeyName);
}
}
@@ -107,7 +106,7 @@ public class AxConceptGetterImpl<C> implements AxConceptGetter<C> {
/*
* (non-Javadoc)
*
- * @see com.ericsson.apex.core.basicmodel.concepts.AxConceptGetter#getAll(java. lang.String)
+ * @see org.onap.policy.apex.core.basicmodel.concepts.AxConceptGetter#getAll(java. lang.String)
*/
@Override
public Set<C> getAll(final String conceptKeyName) {
@@ -117,7 +116,7 @@ public class AxConceptGetterImpl<C> implements AxConceptGetter<C> {
/*
* (non-Javadoc)
*
- * @see com.ericsson.apex.core.basicmodel.concepts.AxConceptGetter#getAll(java. lang.String, java.lang.String)
+ * @see org.onap.policy.apex.core.basicmodel.concepts.AxConceptGetter#getAll(java. lang.String, java.lang.String)
*/
@Override
public Set<C> getAll(final String conceptKeyName, final String conceptKeyVersion) {
@@ -148,8 +147,7 @@ public class AxConceptGetterImpl<C> implements AxConceptGetter<C> {
break;
}
returnSet.add(conceptMap.get(foundKey));
- }
- while (true);
+ } while (true);
return returnSet;
}
diff --git a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/AxKey.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKey.java
index 0d63dbf7d..36b49259b 100644
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/AxKey.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKey.java
@@ -1,28 +1,28 @@
-/*
+/*-
* ============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.apex.model.basicmodel.concepts;
+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.
+ * 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;
@@ -48,11 +48,17 @@ public abstract class AxKey extends AxConcept {
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). */
+ /**
+ * 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). */
+ /**
+ * 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). */
+ /**
+ * 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
@@ -62,21 +68,22 @@ public abstract class AxKey extends AxConcept {
* Default constructor
*/
public AxKey() {
- super();
+ super();
}
-
+
/**
* Copy constructor
+ *
* @param copyConcept the concept to copy from
*/
public AxKey(final AxKey copyConcept) {
- super(copyConcept);
+ super(copyConcept);
}
-
- /*
+
+ /*
* (non-Javadoc)
*
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#getID()
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#getID()
*/
@Override
public abstract String getID();
diff --git a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/AxKeyInfo.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfo.java
index 1ffb40b27..6c709fa63 100644
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/AxKeyInfo.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfo.java
@@ -1,24 +1,24 @@
-/*
+/*-
* ============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.apex.model.basicmodel.concepts;
+package org.onap.policy.apex.model.basicmodel.concepts;
import java.util.List;
import java.util.Random;
@@ -36,24 +36,26 @@ import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-import org.onap.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
-import org.onap.apex.model.basicmodel.dao.converters.CDATAConditioner;
-import org.onap.apex.model.basicmodel.dao.converters.UUID2String;
+import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
+import org.onap.policy.apex.model.basicmodel.dao.converters.CDATAConditioner;
+import org.onap.policy.apex.model.basicmodel.dao.converters.UUID2String;
import org.onap.policy.apex.model.utilities.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.
+ * 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.
+ * 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.
*/
@Entity
@Table(name = "AxKeyInfo")
@XmlAccessorType(XmlAccessType.FIELD)
-@XmlRootElement(name = "apexKeyInfo", namespace = "http://www.ericsson.com/apex")
-@XmlType(name = "AxKeyInfo", namespace = "http://www.ericsson.com/apex", propOrder = { "key", "uuid", "description" })
+@XmlRootElement(name = "apexKeyInfo", namespace = "http://www.onap.org/policy/apex-pdp")
+@XmlType(name = "AxKeyInfo", namespace = "http://www.onap.org/policy/apex-pdp",
+ propOrder = { "key", "uuid", "description" })
public class AxKeyInfo extends AxConcept {
private static final long serialVersionUID = -4023935924068914308L;
@@ -86,12 +88,13 @@ public class AxKeyInfo extends AxConcept {
/**
* Copy constructor
+ *
* @param copyConcept the concept to copy from
*/
public AxKeyInfo(final AxKeyInfo copyConcept) {
- super(copyConcept);
+ super(copyConcept);
}
-
+
/**
* Constructor to create this concept with the specified key.
*
@@ -122,7 +125,7 @@ public class AxKeyInfo extends AxConcept {
/*
* (non-Javadoc)
*
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#getKey()
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#getKey()
*/
@Override
public AxArtifactKey getKey() {
@@ -132,7 +135,7 @@ public class AxKeyInfo extends AxConcept {
/*
* (non-Javadoc)
*
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#getKeys()
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#getKeys()
*/
@Override
public List<AxKey> getKeys() {
@@ -190,24 +193,29 @@ public class AxKeyInfo extends AxConcept {
/*
* (non-Javadoc)
*
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#validate(com. ericsson.apex.model.basicmodel.concepts.AxValidationResult)
+ * @see
+ * org.onap.policy.apex.model.basicmodel.concepts.AxConcept#validate(org.onap.policy.apex.model.basicmodel.concepts.
+ * AxValidationResult)
*/
@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.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"));
+ 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)));
+ result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.WARNING,
+ "UUID is a zero UUID: " + new UUID(0, 0)));
}
return result;
@@ -216,7 +224,7 @@ public class AxKeyInfo extends AxConcept {
/*
* (non-Javadoc)
*
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#clean()
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#clean()
*/
@Override
public void clean() {
@@ -227,7 +235,7 @@ public class AxKeyInfo extends AxConcept {
/*
* (non-Javadoc)
*
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#toString()
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#toString()
*/
@Override
public String toString() {
@@ -244,13 +252,15 @@ public class AxKeyInfo extends AxConcept {
return builder.toString();
}
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#copyTo(com.ericsson.apex.model.basicmodel.concepts.AxConcept)
- */
- @Override
- public AxConcept copyTo(final AxConcept target) {
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.onap.policy.apex.model.basicmodel.concepts.AxConcept#copyTo(org.onap.policy.apex.model.basicmodel.concepts.
+ * AxConcept)
+ */
+ @Override
+ public AxConcept copyTo(final AxConcept target) {
Assertions.argumentNotNull(target, "target may not be null");
final Object copyObject = target;
@@ -267,7 +277,7 @@ public class AxKeyInfo extends AxConcept {
/*
* (non-Javadoc)
*
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#hashCode()
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#hashCode()
*/
@Override
public int hashCode() {
@@ -282,7 +292,7 @@ public class AxKeyInfo extends AxConcept {
/*
* (non-Javadoc)
*
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#equals(java.lang. Object)
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#equals(java.lang. Object)
*/
@Override
public boolean equals(final Object obj) {
@@ -345,11 +355,10 @@ public class AxKeyInfo extends AxConcept {
final Random random;
if (seed != null && seed.length() > 0) {
random = new Random(seed.hashCode());
- }
- else {
+ } else {
random = new Random();
}
- byte[] array = new byte[UUID_BYTE_LENGTH_16];
+ final byte[] 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
new file mode 100644
index 000000000..2ddbe5def
--- /dev/null
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInformation.java
@@ -0,0 +1,460 @@
+/*-
+ * ============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.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 javax.persistence.CascadeType;
+import javax.persistence.EmbeddedId;
+import javax.persistence.Entity;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
+import javax.persistence.ManyToMany;
+import javax.persistence.Table;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
+import org.onap.policy.apex.model.utilities.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.
+ */
+@Entity
+@Table(name = "AxKeyInformation")
+
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "AxKeyInformation", namespace = "http://www.onap.org/policy/apex-pdp",
+ propOrder = { "key", "keyInfoMap" })
+
+public class AxKeyInformation extends AxConcept implements AxConceptGetter<AxKeyInfo> {
+ private static final long serialVersionUID = -2746380769017043888L;
+
+ @EmbeddedId
+ @XmlElement(name = "key", required = true)
+ private AxArtifactKey key;
+
+ // @formatter:off
+ @ManyToMany(cascade = CascadeType.ALL)
+ @JoinTable(
+ joinColumns = { @JoinColumn(name = "keyInfoMapName", referencedColumnName = "name"),
+ @JoinColumn(name = "keyInfoMapVersion", referencedColumnName = "version"), },
+ inverseJoinColumns = { @JoinColumn(name = "keyInfoName", referencedColumnName = "name"),
+ @JoinColumn(name = "keyInfoVersion", referencedColumnName = "version") })
+ private Map<AxArtifactKey, AxKeyInfo> keyInfoMap;
+ // @formatter:on
+
+ /**
+ * 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<AxArtifactKey, AxKeyInfo>());
+ }
+
+ /**
+ * 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);
+ }
+
+ /**
+ * When a model is unmarshalled from disk or from the database, the key information map is returned as a raw Hash
+ * Map. This method is called by JAXB after unmarshaling and is used to convert the hash map to a
+ * {@link NavigableMap} so that it will work with the {@link AxConceptGetter} interface.
+ *
+ * @param u the unmarshaler that is unmarshaling the model
+ * @param parent the parent object of this object in the unmarshaler
+ */
+ public void afterUnmarshal(final Unmarshaller u, final Object parent) {
+ // The map must be navigable to allow name and version searching,
+ // unmarshaling returns a hash map
+ final NavigableMap<AxArtifactKey, AxKeyInfo> navigablekeyInfoMap = new TreeMap<>();
+ navigablekeyInfoMap.putAll(keyInfoMap);
+ keyInfoMap = navigablekeyInfoMap;
+ }
+
+ /**
+ * 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;
+ if (!keyInfoMap.containsKey(artifactKey)) {
+ final AxKeyInfo keyInfo = new AxKeyInfo(artifactKey);
+ // generate a reproducible UUID
+ keyInfo.setUuid(AxKeyInfo.generateReproducibleUUID(keyInfo.getID() + keyInfo.getDescription()));
+ keyInfoMap.put(artifactKey, keyInfo);
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#getKey()
+ */
+ @Override
+ public AxArtifactKey getKey() {
+ return key;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#getKeys()
+ */
+ @Override
+ public List<AxKey> getKeys() {
+ final List<AxKey> keyList = key.getKeys();
+ keyList.addAll(keyInfoMap.keySet());
+
+ 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 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);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.onap.policy.apex.model.basicmodel.concepts.AxConcept#validate(org.onap.policy.apex.model.basicmodel.concepts.
+ * AxValidationResult)
+ */
+ @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 an 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;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#clean()
+ */
+ @Override
+ public void clean() {
+ key.clean();
+ for (final Entry<AxArtifactKey, AxKeyInfo> keyInfoEntry : keyInfoMap.entrySet()) {
+ keyInfoEntry.getKey().clean();
+ keyInfoEntry.getValue().clean();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#toString()
+ */
+ @Override
+ public String toString() {
+ final StringBuilder 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();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.onap.policy.apex.model.basicmodel.concepts.AxConcept#copyTo(org.onap.policy.apex.model.basicmodel.concepts.
+ * AxConcept)
+ */
+ @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;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + key.hashCode();
+ result = prime * result + keyInfoMap.hashCode();
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#equals(java.lang. Object)
+ */
+ @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);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ @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;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.onap.policy.apex.core.basicmodel.concepts.AxConceptGetter#get(org.onap.policy.apex.core.basicmodel.concepts.
+ * AxArtifactKey)
+ */
+ @Override
+ public AxKeyInfo get(final AxArtifactKey conceptKey) {
+ return new AxConceptGetterImpl<>((NavigableMap<AxArtifactKey, AxKeyInfo>) keyInfoMap).get(conceptKey);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.core.basicmodel.concepts.AxConceptGetter#get(java.lang. String)
+ */
+ @Override
+ public AxKeyInfo get(final String conceptKeyName) {
+ return new AxConceptGetterImpl<>((NavigableMap<AxArtifactKey, AxKeyInfo>) keyInfoMap).get(conceptKeyName);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.core.basicmodel.concepts.AxConceptGetter#get(java.lang. String, java.lang.String)
+ */
+ @Override
+ public AxKeyInfo get(final String conceptKeyName, final String conceptKeyVersion) {
+ return new AxConceptGetterImpl<>((NavigableMap<AxArtifactKey, AxKeyInfo>) keyInfoMap).get(conceptKeyName,
+ conceptKeyVersion);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.core.basicmodel.concepts.AxConceptGetter#getAll(java. lang.String)
+ */
+ @Override
+ public Set<AxKeyInfo> getAll(final String conceptKeyName) {
+ return new AxConceptGetterImpl<>((NavigableMap<AxArtifactKey, AxKeyInfo>) keyInfoMap).getAll(conceptKeyName);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.core.basicmodel.concepts.AxConceptGetter#getAll(java. lang.String, java.lang.String)
+ */
+ @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/apex/model/basicmodel/concepts/AxKeyUse.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyUse.java
index 990c8f7de..eeb8dc650 100644
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/AxKeyUse.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyUse.java
@@ -1,34 +1,34 @@
-/*
+/*-
* ============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.apex.model.basicmodel.concepts;
+package org.onap.policy.apex.model.basicmodel.concepts;
import java.util.List;
-import org.onap.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
+import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
import org.onap.policy.apex.model.utilities.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.
+ * 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.
*/
@@ -47,12 +47,13 @@ public class AxKeyUse extends AxKey {
/**
* Copy constructor
+ *
* @param copyConcept the concept to copy from
*/
public AxKeyUse(final AxKeyUse copyConcept) {
- super(copyConcept);
+ super(copyConcept);
}
-
+
/**
* This constructor creates an instance of this class, and holds a reference to a used key.
*
@@ -66,7 +67,7 @@ public class AxKeyUse extends AxKey {
/*
* (non-Javadoc)
*
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#getKey()
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#getKey()
*/
@Override
public AxKey getKey() {
@@ -76,7 +77,7 @@ public class AxKeyUse extends AxKey {
/*
* (non-Javadoc)
*
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#getKeys()
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#getKeys()
*/
@Override
public List<AxKey> getKeys() {
@@ -86,7 +87,7 @@ public class AxKeyUse extends AxKey {
/*
* (non-Javadoc)
*
- * @see com.ericsson.apex.model.basicmodel.concepts.AxKey#getID()
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxKey#getID()
*/
@Override
public String getID() {
@@ -106,7 +107,8 @@ public class AxKeyUse extends AxKey {
/*
* (non-Javadoc)
*
- * @see com.ericsson.apex.model.basicmodel.concepts.AxKey#getCompatibility(com. ericsson.apex.model.basicmodel.concepts.AxKey)
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxKey#getCompatibility(org.onap.policy.apex.model.basicmodel.
+ * concepts.AxKey)
*/
@Override
public AxKey.Compatibility getCompatibility(final AxKey otherKey) {
@@ -116,7 +118,9 @@ public class AxKeyUse extends AxKey {
/*
* (non-Javadoc)
*
- * @see com.ericsson.apex.model.basicmodel.concepts.AxKey#isCompatible(com. ericsson.apex.model.basicmodel.concepts.AxKey)
+ * @see
+ * org.onap.policy.apex.model.basicmodel.concepts.AxKey#isCompatible(org.onap.policy.apex.model.basicmodel.concepts.
+ * AxKey)
*/
@Override
public boolean isCompatible(final AxKey otherKey) {
@@ -126,13 +130,15 @@ public class AxKeyUse extends AxKey {
/*
* (non-Javadoc)
*
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#validate(com. ericsson.apex.model.basicmodel.concepts.AxValidationResult)
+ * @see
+ * org.onap.policy.apex.model.basicmodel.concepts.AxConcept#validate(org.onap.policy.apex.model.basicmodel.concepts.
+ * AxValidationResult)
*/
@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"));
+ result.addValidationMessage(new AxValidationMessage(usedKey, this.getClass(), ValidationResult.INVALID,
+ "usedKey is a null key"));
}
return usedKey.validate(result);
}
@@ -140,7 +146,7 @@ public class AxKeyUse extends AxKey {
/*
* (non-Javadoc)
*
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#clean()
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#clean()
*/
@Override
public void clean() {
@@ -150,7 +156,7 @@ public class AxKeyUse extends AxKey {
/*
* (non-Javadoc)
*
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#toString()
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#toString()
*/
@Override
public String toString() {
@@ -163,13 +169,15 @@ public class AxKeyUse extends AxKey {
return builder.toString();
}
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#copyTo(com.ericsson.apex.model.basicmodel.concepts.AxConcept)
- */
- @Override
- public AxConcept copyTo(final AxConcept target) {
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.onap.policy.apex.model.basicmodel.concepts.AxConcept#copyTo(org.onap.policy.apex.model.basicmodel.concepts.
+ * AxConcept)
+ */
+ @Override
+ public AxConcept copyTo(final AxConcept target) {
Assertions.argumentNotNull(target, "target may not be null");
final Object copyObject = target;
@@ -177,20 +185,19 @@ public class AxKeyUse extends AxKey {
final AxKeyUse copy = ((AxKeyUse) copyObject);
try {
- copy.usedKey = usedKey.getClass().newInstance();
- }
- catch (Exception e) {
- throw new ApexRuntimeException("error copying concept key: " + e.getMessage(), e);
- }
+ copy.usedKey = usedKey.getClass().newInstance();
+ } catch (final Exception e) {
+ throw new ApexRuntimeException("error copying concept key: " + e.getMessage(), e);
+ }
usedKey.copyTo(copy.usedKey);
-
+
return copy;
}
/*
* (non-Javadoc)
*
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#hashCode()
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#hashCode()
*/
@Override
public int hashCode() {
@@ -203,7 +210,7 @@ public class AxKeyUse extends AxKey {
/*
* (non-Javadoc)
*
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#equals(java.lang. Object)
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#equals(java.lang. Object)
*/
@Override
public boolean equals(final Object obj) {
diff --git a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/AxModel.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxModel.java
index f0489c734..dac1d693c 100644
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/AxModel.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxModel.java
@@ -1,24 +1,24 @@
-/*
+/*-
* ============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.apex.model.basicmodel.concepts;
+package org.onap.policy.apex.model.basicmodel.concepts;
import java.util.List;
import java.util.Set;
@@ -39,32 +39,34 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
-import org.onap.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
-import org.onap.apex.model.basicmodel.service.ModelService;
+import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
+import org.onap.policy.apex.model.basicmodel.service.ModelService;
import org.onap.policy.apex.model.utilities.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.
+ * 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.
+ * 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.
*/
@Entity
@Table(name = "AxModel")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
-@XmlRootElement(name = "apexModel", namespace = "http://www.ericsson.com/apex")
+@XmlRootElement(name = "apexModel", namespace = "http://www.onap.org/policy/apex-pdp")
@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "AxModel", namespace = "http://www.ericsson.com/apex", propOrder = { "key", "keyInformation" })
+@XmlType(name = "AxModel", namespace = "http://www.onap.org/policy/apex-pdp", propOrder = { "key", "keyInformation" })
public class AxModel extends AxConcept {
private static final String IS_A_NULL_KEY = " is a null key";
- private static final long serialVersionUID = -771659065637205430L;
+ private static final long serialVersionUID = -771659065637205430L;
@EmbeddedId
@XmlElement(name = "key", required = true)
@@ -72,10 +74,8 @@ public class AxModel extends AxConcept {
// @formatter:off
@OneToOne(cascade = CascadeType.ALL)
- @JoinColumns({
- @JoinColumn(name = "keyInformationName", referencedColumnName = "name"),
- @JoinColumn(name = "keyInformationVersion", referencedColumnName = "version")
- })
+ @JoinColumns({ @JoinColumn(name = "keyInformationName", referencedColumnName = "name"),
+ @JoinColumn(name = "keyInformationVersion", referencedColumnName = "version") })
@XmlElement(name = "keyInformation", required = true)
private AxKeyInformation keyInformation;
// @formatter:on
@@ -89,12 +89,13 @@ public class AxModel extends AxConcept {
/**
* Copy constructor
+ *
* @param copyConcept the concept to copy from
*/
public AxModel(final AxModel copyConcept) {
- super(copyConcept);
+ super(copyConcept);
}
-
+
/**
* Constructor to create this concept with the specified key.
*
@@ -120,8 +121,9 @@ public class AxModel extends AxConcept {
}
/**
- * 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.
+ * 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());
@@ -130,7 +132,7 @@ public class AxModel extends AxConcept {
/*
* (non-Javadoc)
*
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#getKey()
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#getKey()
*/
@Override
public AxArtifactKey getKey() {
@@ -140,7 +142,7 @@ public class AxModel extends AxConcept {
/*
* (non-Javadoc)
*
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#getKeys()
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#getKeys()
*/
@Override
public List<AxKey> getKeys() {
@@ -186,14 +188,17 @@ public class AxModel extends AxConcept {
/*
* (non-Javadoc)
*
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#validate(com. ericsson.apex.model.basicmodel.concepts.AxValidationResult)
+ * @see
+ * org.onap.policy.apex.model.basicmodel.concepts.AxConcept#validate(org.onap.policy.apex.model.basicmodel.concepts.
+ * AxValidationResult)
*/
@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.addValidationMessage(
+ new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID, "key is a null key"));
}
result = key.validate(result);
@@ -207,10 +212,9 @@ public class AxModel extends AxConcept {
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);
+ result = validateArtifactKeyInModel((AxArtifactKey) axKey, artifactKeySet, result);
+ } else if (axKey instanceof AxReferenceKey) {
+ result = validateReferenceKeyInModel((AxReferenceKey) axKey, referenceKeySet, result);
}
// It must be an AxKeyUse, nothing else is legal
else {
@@ -231,26 +235,28 @@ public class AxModel extends AxConcept {
// 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"));
+ 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 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, Set<AxArtifactKey> artifactKeySet, AxValidationResult result) {
+ 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));
+ result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
+ "key " + artifactKey + IS_A_NULL_KEY));
}
// Null key name start check
@@ -261,34 +267,35 @@ public class AxModel extends AxConcept {
// Unique key check
if (artifactKeySet.contains(artifactKey)) {
- result.addValidationMessage(
- new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID, "duplicate key " + artifactKey + " found"));
- }
- else {
+ 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));
+ 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 artifactKey The reference key to check
- * @param referenceKeySet The set of reference 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 validateReferenceKeyInModel(final AxReferenceKey referenceKey, Set<AxReferenceKey> referenceKeySet, AxValidationResult result) {
+ 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));
+ result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
+ "key " + referenceKey + IS_A_NULL_KEY));
}
// Null parent key check
@@ -299,8 +306,8 @@ public class AxModel extends AxConcept {
// 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"));
+ result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
+ "key " + referenceKey + " has a null local name"));
}
// Null key name start check
@@ -311,10 +318,9 @@ public class AxModel extends AxConcept {
// Unique key check
if (referenceKeySet.contains(referenceKey)) {
- result.addValidationMessage(
- new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID, "duplicate key " + referenceKey + " found"));
- }
- else {
+ result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
+ "duplicate key " + referenceKey + " found"));
+ } else {
referenceKeySet.add(referenceKey);
}
@@ -325,44 +331,44 @@ public class AxModel extends AxConcept {
}
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 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, AxValidationResult result) {
+ 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"));
+ result.addValidationMessage(new AxValidationMessage(usedKey.getKey(), this.getClass(),
+ ValidationResult.INVALID, "an artifact key used in the model is not defined"));
}
- }
- else {
+ } 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"));
+ result.addValidationMessage(new AxValidationMessage(usedKey.getKey(), this.getClass(),
+ ValidationResult.INVALID, "a reference key used in the model is not defined"));
}
}
}
-
+
return result;
- }
+ }
- /*
+ /*
* (non-Javadoc)
*
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#clean()
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#clean()
*/
@Override
public void clean() {
@@ -373,7 +379,7 @@ public class AxModel extends AxConcept {
/*
* (non-Javadoc)
*
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#toString()
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#toString()
*/
@Override
public String toString() {
@@ -388,13 +394,15 @@ public class AxModel extends AxConcept {
return builder.toString();
}
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#copyTo(com.ericsson.apex.model.basicmodel.concepts.AxConcept)
- */
- @Override
- public AxConcept copyTo(final AxConcept target) {
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.onap.policy.apex.model.basicmodel.concepts.AxConcept#copyTo(org.onap.policy.apex.model.basicmodel.concepts.
+ * AxConcept)
+ */
+ @Override
+ public AxConcept copyTo(final AxConcept target) {
Assertions.argumentNotNull(target, "target may not be null");
final Object copyObject = target;
@@ -410,7 +418,7 @@ public class AxModel extends AxConcept {
/*
* (non-Javadoc)
*
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#hashCode()
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#hashCode()
*/
@Override
public int hashCode() {
@@ -424,7 +432,7 @@ public class AxModel extends AxConcept {
/*
* (non-Javadoc)
*
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#equals(java.lang. Object)
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#equals(java.lang. Object)
*/
@Override
public boolean equals(final Object obj) {
diff --git a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/AxReferenceKey.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxReferenceKey.java
index 9401152d0..5965dd02b 100644
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/AxReferenceKey.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxReferenceKey.java
@@ -1,24 +1,24 @@
-/*
+/*-
* ============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.apex.model.basicmodel.concepts;
+package org.onap.policy.apex.model.basicmodel.concepts;
import java.util.ArrayList;
import java.util.List;
@@ -31,42 +31,46 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
-import org.onap.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
+import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
import org.onap.policy.apex.model.utilities.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.
+ * 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.
+ * 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.
+ * 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 {@link NAME_REGEXP} and {@link VERSION_REGEXP} regular expressions
- * respectively and that the local name fields match the {@link LOCAL_NAME_REGEXP} regular expression.
+ * Key validation checks that the parent name and parent version fields match the {@link NAME_REGEXP} and
+ * {@link VERSION_REGEXP} regular expressions respectively and that the local name fields match the
+ * {@link LOCAL_NAME_REGEXP} regular expression.
*/
@Embeddable
@XmlAccessorType(XmlAccessType.FIELD)
-@XmlRootElement(name = "apexReferenceKey", namespace = "http://www.ericsson.com/apex")
-@XmlType(name = "AxReferenceKey", namespace = "http://www.ericsson.com/apex", propOrder = { "parentKeyName", "parentKeyVersion", "parentLocalName",
- "localName" })
+@XmlRootElement(name = "apexReferenceKey", namespace = "http://www.onap.org/policy/apex-pdp")
+@XmlType(name = "AxReferenceKey", namespace = "http://www.onap.org/policy/apex-pdp",
+ propOrder = { "parentKeyName", "parentKeyVersion", "parentLocalName", "localName" })
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 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;
+ private static final long serialVersionUID = 8932717618579392561L;
- /** Regular expression to specify the structure of local names in reference keys.*/
+ /** 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\\-_]+";
+ /** 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;
@@ -102,7 +106,8 @@ public class AxReferenceKey extends AxKey {
* @param referenceKey the reference key to copy from
*/
public AxReferenceKey(final AxReferenceKey referenceKey) {
- this(referenceKey.getParentKeyName(), referenceKey.getParentKeyVersion(), referenceKey.getParentLocalName(), referenceKey.getLocalName());
+ this(referenceKey.getParentKeyName(), referenceKey.getParentKeyVersion(), referenceKey.getParentLocalName(),
+ referenceKey.getLocalName());
}
/**
@@ -135,8 +140,8 @@ public class AxReferenceKey extends AxKey {
}
/**
- * 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.
+ * 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
@@ -147,8 +152,8 @@ public class AxReferenceKey extends AxKey {
}
/**
- * 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.
+ * 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
@@ -159,18 +164,22 @@ public class AxReferenceKey extends AxKey {
}
/**
- * 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.
+ * 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) {
+ 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.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);
}
@@ -189,10 +198,14 @@ public class AxReferenceKey extends AxKey {
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);
+ 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);
}
/**
@@ -201,13 +214,14 @@ public class AxReferenceKey extends AxKey {
* @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);
+ return new AxReferenceKey(AxKey.NULL_KEY_NAME, AxKey.NULL_KEY_VERSION, AxKey.NULL_KEY_NAME,
+ AxKey.NULL_KEY_NAME);
}
/*
* (non-Javadoc)
*
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#getKey()
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#getKey()
*/
@Override
public AxReferenceKey getKey() {
@@ -217,7 +231,7 @@ public class AxReferenceKey extends AxKey {
/*
* (non-Javadoc)
*
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#getKeys()
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#getKeys()
*/
@Override
public List<AxKey> getKeys() {
@@ -229,7 +243,7 @@ public class AxReferenceKey extends AxKey {
/*
* (non-Javadoc)
*
- * @see com.ericsson.apex.model.basicmodel.concepts.AxKey#getID()
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxKey#getID()
*/
@Override
public String getID() {
@@ -313,7 +327,8 @@ public class AxReferenceKey extends AxKey {
* @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);
+ this.parentKeyVersion =
+ Assertions.validateStringParameter(PARENT_KEY_VERSION, parentKeyVersion, VERSION_REGEXP);
}
/**
@@ -331,7 +346,8 @@ public class AxReferenceKey extends AxKey {
* @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);
+ this.parentLocalName =
+ Assertions.validateStringParameter(PARENT_LOCAL_NAME, parentLocalName, LOCAL_NAME_REGEXP);
}
/**
@@ -355,7 +371,8 @@ public class AxReferenceKey extends AxKey {
/*
* (non-Javadoc)
*
- * @see com.ericsson.apex.model.basicmodel.concepts.AxKey#getCompatibility(com. ericsson.apex.model.basicmodel.concepts.AxKey)
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxKey#getCompatibility(org.onap.policy.apex.model.basicmodel.
+ * concepts.AxKey)
*/
@Override
public AxKey.Compatibility getCompatibility(final AxKey otherKey) {
@@ -370,7 +387,9 @@ public class AxReferenceKey extends AxKey {
/*
* (non-Javadoc)
*
- * @see com.ericsson.apex.model.basicmodel.concepts.AxKey#isCompatible(com. ericsson.apex.model.basicmodel.concepts.AxKey)
+ * @see
+ * org.onap.policy.apex.model.basicmodel.concepts.AxKey#isCompatible(org.onap.policy.apex.model.basicmodel.concepts.
+ * AxKey)
*/
@Override
public boolean isCompatible(final AxKey otherKey) {
@@ -385,36 +404,38 @@ public class AxReferenceKey extends AxKey {
/*
* (non-Javadoc)
*
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#validate(com. ericsson.apex.model.basicmodel.concepts.AxValidationResult)
+ * @see
+ * org.onap.policy.apex.model.basicmodel.concepts.AxConcept#validate(org.onap.policy.apex.model.basicmodel.concepts.
+ * AxValidationResult)
*/
@Override
public AxValidationResult validate(final AxValidationResult result) {
try {
Assertions.validateStringParameter(PARENT_KEY_NAME, parentKeyName, NAME_REGEXP);
- }
- catch (final IllegalArgumentException e) {
- result.addValidationMessage(new AxValidationMessage(this, this.getClass(), ValidationResult.INVALID, "parentKeyName invalid-" + e.getMessage()));
+ } catch (final IllegalArgumentException e) {
+ result.addValidationMessage(new AxValidationMessage(this, this.getClass(), ValidationResult.INVALID,
+ "parentKeyName invalid-" + e.getMessage()));
}
try {
Assertions.validateStringParameter(PARENT_KEY_VERSION, parentKeyVersion, VERSION_REGEXP);
- }
- catch (final IllegalArgumentException e) {
- result.addValidationMessage(new AxValidationMessage(this, this.getClass(), ValidationResult.INVALID, "parentKeyVersion invalid-" + e.getMessage()));
+ } catch (final IllegalArgumentException e) {
+ result.addValidationMessage(new AxValidationMessage(this, this.getClass(), ValidationResult.INVALID,
+ "parentKeyVersion invalid-" + e.getMessage()));
}
try {
Assertions.validateStringParameter(PARENT_LOCAL_NAME, parentLocalName, LOCAL_NAME_REGEXP);
- }
- catch (final IllegalArgumentException e) {
- result.addValidationMessage(new AxValidationMessage(this, this.getClass(), ValidationResult.INVALID, "parentLocalName invalid-" + e.getMessage()));
+ } catch (final IllegalArgumentException e) {
+ result.addValidationMessage(new AxValidationMessage(this, this.getClass(), ValidationResult.INVALID,
+ "parentLocalName invalid-" + e.getMessage()));
}
try {
Assertions.validateStringParameter(LOCAL_NAME, localName, LOCAL_NAME_REGEXP);
- }
- catch (final IllegalArgumentException e) {
- result.addValidationMessage(new AxValidationMessage(this, this.getClass(), ValidationResult.INVALID, "localName invalid-" + e.getMessage()));
+ } catch (final IllegalArgumentException e) {
+ result.addValidationMessage(new AxValidationMessage(this, this.getClass(), ValidationResult.INVALID,
+ "localName invalid-" + e.getMessage()));
}
return result;
@@ -423,7 +444,7 @@ public class AxReferenceKey extends AxKey {
/*
* (non-Javadoc)
*
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#clean()
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#clean()
*/
@Override
public void clean() {
@@ -436,7 +457,7 @@ public class AxReferenceKey extends AxKey {
/*
* (non-Javadoc)
*
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#toString()
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#toString()
*/
@Override
public String toString() {
@@ -455,13 +476,15 @@ public class AxReferenceKey extends AxKey {
return builder.toString();
}
- /*
- * (non-Javadoc)
- *
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#copyTo(com.ericsson.apex.model.basicmodel.concepts.AxConcept)
- */
- @Override
- public AxConcept copyTo(final AxConcept target) {
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.onap.policy.apex.model.basicmodel.concepts.AxConcept#copyTo(org.onap.policy.apex.model.basicmodel.concepts.
+ * AxConcept)
+ */
+ @Override
+ public AxConcept copyTo(final AxConcept target) {
Assertions.argumentNotNull(target, "target may not be null");
final Object copyObject = target;
@@ -479,7 +502,7 @@ public class AxReferenceKey extends AxKey {
/*
* (non-Javadoc)
*
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#hashCode()
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#hashCode()
*/
@Override
public int hashCode() {
@@ -495,7 +518,7 @@ public class AxReferenceKey extends AxKey {
/*
* (non-Javadoc)
*
- * @see com.ericsson.apex.model.basicmodel.concepts.AxConcept#equals(java.lang. Object)
+ * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#equals(java.lang. Object)
*/
@Override
public boolean equals(final Object obj) {
diff --git a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/AxValidationMessage.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxValidationMessage.java
index ef8eb317c..7ca0b2f3c 100644
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/AxValidationMessage.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxValidationMessage.java
@@ -1,31 +1,32 @@
-/*
+/*-
* ============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.apex.model.basicmodel.concepts;
+package org.onap.policy.apex.model.basicmodel.concepts;
-import org.onap.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
+import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
import org.onap.policy.apex.model.utilities.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.
+ * 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)
*/
@@ -43,7 +44,8 @@ public class AxValidationMessage {
* @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) {
+ 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");
diff --git a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/AxValidationResult.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxValidationResult.java
index 363fd1596..664cf9500 100644
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/AxValidationResult.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxValidationResult.java
@@ -1,24 +1,24 @@
-/*
+/*-
* ============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.apex.model.basicmodel.concepts;
+package org.onap.policy.apex.model.basicmodel.concepts;
import java.util.LinkedList;
import java.util.List;
@@ -35,12 +35,19 @@ public class AxValidationResult {
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. */
+ /**
+ * 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. */
+ /**
+ * 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.
+ * Errors were detected on a concept (such as referenced but undefined concepts) of a nature that will affect
+ * the use of the concept.
*/
INVALID
}
@@ -52,8 +59,8 @@ public class AxValidationResult {
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).
+ * 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
*/
@@ -89,8 +96,8 @@ public class AxValidationResult {
}
/**
- * Adds a validation message to the validation result, used by validate() implementations on {@link AxConcept} subclasses to report
- * validaiton observations.
+ * 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
*/
@@ -115,23 +122,23 @@ public class AxValidationResult {
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;
+ 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) {
diff --git a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/package-info.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/package-info.java
index 4d5c91c66..294a66496 100644
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/concepts/package-info.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/package-info.java
@@ -1,33 +1,33 @@
-/*
+/*-
* ============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=========================================================
*/
/**
* This package contains the fundamental concepts for all APEX models.
- *
+ *
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-@XmlSchema(namespace = "http://www.ericsson.com/apex", elementFormDefault = XmlNsForm.QUALIFIED, xmlns = {
- @XmlNs(namespaceURI = "http://www.ericsson.com/apex", prefix = "") })
+@XmlSchema(namespace = "http://www.onap.org/policy/apex-pdp", elementFormDefault = XmlNsForm.QUALIFIED,
+ xmlns = { @XmlNs(namespaceURI = "http://www.onap.org/policy/apex-pdp", prefix = "") })
-package org.onap.apex.model.basicmodel.concepts;
+package org.onap.policy.apex.model.basicmodel.concepts;
import javax.xml.bind.annotation.XmlNs;
import javax.xml.bind.annotation.XmlNsForm;
diff --git a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/dao/ApexDao.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/ApexDao.java
index 5aab39c1b..461f3f113 100644
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/dao/ApexDao.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/ApexDao.java
@@ -1,36 +1,36 @@
-/*
+/*-
* ============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.apex.model.basicmodel.dao;
+package org.onap.policy.apex.model.basicmodel.dao;
import java.util.Collection;
import java.util.List;
-import org.onap.apex.model.basicmodel.concepts.ApexException;
-import org.onap.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.apex.model.basicmodel.concepts.AxConcept;
-import org.onap.apex.model.basicmodel.concepts.AxReferenceKey;
+import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
+import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
/**
- * The Interface ApexDao describes the DAO interface for reading and writing Apex {@link AxConcept} concepts to and from databases using
- * JDBC.
+ * The Interface ApexDao describes the DAO interface for reading and writing Apex {@link AxConcept} concepts to and from
+ * databases using JDBC.
*
* @author Sergey Sachkov
* @author liam.fallon@ericsson.com
diff --git a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/dao/ApexDaoFactory.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/ApexDaoFactory.java
index ecb8a4658..50724d2d7 100644
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/dao/ApexDaoFactory.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/ApexDaoFactory.java
@@ -1,33 +1,33 @@
-/*
+/*-
* ============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.apex.model.basicmodel.dao;
+package org.onap.policy.apex.model.basicmodel.dao;
-import org.onap.apex.model.basicmodel.concepts.ApexException;
+import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.utilities.Assertions;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
/**
- * This factory class returns an Apex DAO for the configured persistence mechanism. The factory uses the plugin class specified in {@link DAOParameters} to
- * instantiate a DAO instance.
+ * This factory class returns an Apex DAO for the configured persistence mechanism. The factory uses the plugin class
+ * specified in {@link DAOParameters} to instantiate a DAO instance.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
@@ -49,16 +49,18 @@ public class ApexDaoFactory {
Object apexDaoObject = null;
try {
apexDaoObject = Class.forName(daoParameters.getPluginClass()).newInstance();
- }
- catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
+ } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
LOGGER.error("Apex DAO class not found for DAO plugin \"" + daoParameters.getPluginClass() + "\"", e);
- throw new ApexException("Apex DAO class not found for DAO plugin \"" + daoParameters.getPluginClass() + "\"", e);
+ throw new ApexException(
+ "Apex DAO class not found for DAO plugin \"" + daoParameters.getPluginClass() + "\"", e);
}
// Check the class is an Apex DAO
if (!(apexDaoObject instanceof ApexDao)) {
- LOGGER.error("Specified Apex DAO plugin class \"" + daoParameters.getPluginClass() + "\" does not implement the ApexDao interface");
- throw new ApexException("Specified Apex DAO plugin class \"" + daoParameters.getPluginClass() + "\" does not implement the ApexDao interface");
+ LOGGER.error("Specified Apex DAO plugin class \"" + daoParameters.getPluginClass()
+ + "\" does not implement the ApexDao interface");
+ throw new ApexException("Specified Apex DAO plugin class \"" + daoParameters.getPluginClass()
+ + "\" does not implement the ApexDao interface");
}
return (ApexDao) apexDaoObject;
diff --git a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/dao/DAOParameters.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/DAOParameters.java
index ccf15fea7..5a44d18a8 100644
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/dao/DAOParameters.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/DAOParameters.java
@@ -1,24 +1,24 @@
-/*
+/*-
* ============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.apex.model.basicmodel.dao;
+package org.onap.policy.apex.model.basicmodel.dao;
import java.util.Properties;
@@ -29,7 +29,7 @@ import java.util.Properties;
*/
public class DAOParameters {
/** The default Apex DAO plugin class. */
- public static final String DEFAULT_PLUGIN_CLASS = "org.onap.apex.model.basicmodel.dao.impl.DefaultApexDao";
+ public static final String DEFAULT_PLUGIN_CLASS = "org.onap.policy.apex.model.basicmodel.dao.impl.DefaultApexDao";
private String pluginClass = DEFAULT_PLUGIN_CLASS;
private String persistenceUnit;
@@ -55,8 +55,8 @@ public class DAOParameters {
}
/**
- * Gets the persistence unit for the DAO. The persistence unit defines the JDBC properties the DAO will use. The persistence unit must defined in the
- * {@code META-INF/persistence.xml} resource file
+ * Gets the persistence unit for the DAO. The persistence unit defines the JDBC properties the DAO will use. The
+ * persistence unit must defined in the {@code META-INF/persistence.xml} resource file
*
* @return the persistence unit to use for JDBC access
*/
@@ -65,8 +65,8 @@ public class DAOParameters {
}
/**
- * Sets the persistence unit for the DAO. The persistence unit defines the JDBC properties the DAO will use. The persistence unit must defined in the
- * {@code META-INF/persistence.xml} resource file
+ * Sets the persistence unit for the DAO. The persistence unit defines the JDBC properties the DAO will use. The
+ * persistence unit must defined in the {@code META-INF/persistence.xml} resource file
*
* @param daoPersistenceUnit the persistence unit to use for JDBC access
*/
@@ -119,6 +119,7 @@ public class DAOParameters {
*/
@Override
public String toString() {
- return "DAOParameters [pluginClass=" + pluginClass + ", persistenceUnit=" + persistenceUnit + ", jdbcProperties=" + jdbcProperties + "]";
+ return "DAOParameters [pluginClass=" + pluginClass + ", persistenceUnit=" + persistenceUnit
+ + ", jdbcProperties=" + jdbcProperties + "]";
}
}
diff --git a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/dao/converters/CDATAConditioner.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/converters/CDATAConditioner.java
index d949ab28a..9e840da2c 100644
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/dao/converters/CDATAConditioner.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/converters/CDATAConditioner.java
@@ -1,32 +1,32 @@
-/*
+/*-
* ============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.apex.model.basicmodel.dao.converters;
+package org.onap.policy.apex.model.basicmodel.dao.converters;
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
import javax.xml.bind.annotation.adapters.XmlAdapter;
/**
- * The Class CDATAConditioner converts a CDATA String to and from database format by removing spaces at the ends of lines and
- * platform-specific new line endings.
+ * The Class CDATAConditioner converts a CDATA String to and from database format by removing spaces at the ends of
+ * lines and platform-specific new line endings.
*
* @author John Keeney (John.Keeney@ericsson.com)
*/
@@ -84,8 +84,7 @@ public class CDATAConditioner extends XmlAdapter<String, String> implements Attr
public static final String clean(final String in) {
if (in == null) {
return null;
- }
- else {
+ } else {
return in.replaceAll("\\s+$", "").replaceAll("\\r?\\n", NL);
}
}
diff --git a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/dao/converters/UUID2String.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/converters/UUID2String.java
index 4e6b66025..f26dfc2de 100644
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/dao/converters/UUID2String.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/converters/UUID2String.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.apex.model.basicmodel.dao.converters;
+package org.onap.policy.apex.model.basicmodel.dao.converters;
import java.util.UUID;
diff --git a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/dao/converters/package-info.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/converters/package-info.java
index c7bad6777..f1e9a3ba7 100644
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/dao/converters/package-info.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/converters/package-info.java
@@ -1,27 +1,28 @@
-/*
+/*-
* ============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 converters used by APEX EclipseLink marshaling and unmarshaling of {@link org.onap.apex.model.basicmodel.concepts.AxConcept}
- * instances to and from files and databases.
- *
+ * Contains converters used by APEX EclipseLink marshaling and unmarshaling of
+ * {@link org.onap.policy.apex.model.basicmodel.concepts.AxConcept} instances to and from files and databases.
+ *
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-package org.onap.apex.model.basicmodel.dao.converters;
+
+package org.onap.policy.apex.model.basicmodel.dao.converters;
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/impl/DefaultApexDao.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/impl/DefaultApexDao.java
new file mode 100644
index 000000000..228362bce
--- /dev/null
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/impl/DefaultApexDao.java
@@ -0,0 +1,520 @@
+/*-
+ * ============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.dao.impl;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+
+import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
+import org.onap.policy.apex.model.basicmodel.concepts.ApexRuntimeException;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+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.dao.ApexDao;
+import org.onap.policy.apex.model.basicmodel.dao.DAOParameters;
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
+
+/**
+ * The Class DefaultApexDao is an JPA implementation of the {@link ApexDao} class for Apex concepts ({@link AxConcept}).
+ * It uses the default JPA implementation in the javax {@link Persistence} class.
+ *
+ *
+ * @author Sergey Sachkov (sergey.sachkov@ericsson.com)
+ */
+public class DefaultApexDao implements ApexDao {
+ private static final XLogger LOGGER = XLoggerFactory.getXLogger(DefaultApexDao.class);
+
+ private static final String SELECT_C_FROM = "SELECT c FROM ";
+ private static final String AND_C_KEY_LOCAL_NAME = "' AND c.key.localName='";
+ private static final String AND_C_KEY_PARENT_KEY_VERSION = "' AND c.key.parentKeyVersion='";
+ private static final String C_WHERE_C_KEY_PARENT_KEY_NAME = " c WHERE c.key.parentKeyName='";
+ private static final String AND_C_KEY_VERSION = "' AND c.key.version='";
+ private static final String C_WHERE_C_KEY_NAME = " c WHERE c.key.name='";
+ private static final String DELETE_FROM = "DELETE FROM ";
+
+ // Entity manager for JPA
+ private EntityManagerFactory emf = null;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.onap.policy.apex.model.basicmodel.dao.ApexDao#init(org.onap.policy.apex.model.basicmodel.dao.DAOParameters)
+ */
+ @Override
+ public void init(final DAOParameters daoParameters) throws ApexException {
+ if (daoParameters == null || daoParameters.getPersistenceUnit() == null) {
+ LOGGER.error("Apex persistence unit parameter not set");
+ throw new ApexException("Apex persistence unit parameter not set");
+ }
+
+ LOGGER.debug("Creating Apex persistence unit \"" + daoParameters.getPersistenceUnit() + "\" . . .");
+ try {
+ emf = Persistence.createEntityManagerFactory(daoParameters.getPersistenceUnit(),
+ daoParameters.getJdbcProperties());
+ } catch (final Exception e) {
+ LOGGER.warn("Creation of Apex persistence unit \"" + daoParameters.getPersistenceUnit() + "\" failed", e);
+ throw new ApexException(
+ "Creation of Apex persistence unit \"" + daoParameters.getPersistenceUnit() + "\" failed", e);
+ }
+ LOGGER.debug("Created Apex persistence unit \"" + daoParameters.getPersistenceUnit() + "\"");
+ }
+
+ /**
+ * Gets the entity manager for this DAO.
+ *
+ * @return the entity manager
+ */
+ protected final synchronized EntityManager getEntityManager() {
+ if (emf == null) {
+ LOGGER.warn("Apex DAO has not been initialized");
+ throw new ApexRuntimeException("Apex DAO has not been initialized");
+ }
+
+ return emf.createEntityManager();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.dao.ApexDao#close()
+ */
+ @Override
+ public final void close() {
+ if (emf != null) {
+ emf.close();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.dao.ApexDao#create(org.onap.policy.apex.model.basicmodel.concepts.
+ * AxConcept)
+ */
+ @Override
+ public <T extends AxConcept> void create(final T obj) {
+ if (obj == null) {
+ return;
+ }
+ final EntityManager mg = getEntityManager();
+ try {
+ mg.getTransaction().begin();
+ mg.merge(obj);
+ mg.getTransaction().commit();
+ } finally {
+ mg.close();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.dao.ApexDao#delete(org.onap.policy.apex.model.basicmodel.concepts.
+ * AxConcept)
+ */
+ @Override
+ public <T extends AxConcept> void delete(final T obj) {
+ if (obj == null) {
+ return;
+ }
+ final EntityManager mg = getEntityManager();
+ try {
+ mg.getTransaction().begin();
+ mg.remove(mg.contains(obj) ? obj : mg.merge(obj));
+ mg.getTransaction().commit();
+ } finally {
+ mg.close();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.dao.ApexDao#delete(java.lang.Class,
+ * org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey)
+ */
+ @Override
+ public <T extends AxConcept> void delete(final Class<T> aClass, final AxArtifactKey key) {
+ if (key == null) {
+ return;
+ }
+ final EntityManager mg = getEntityManager();
+ try {
+ mg.getTransaction().begin();
+ mg.createQuery(DELETE_FROM + aClass.getSimpleName() + C_WHERE_C_KEY_NAME + key.getName() + AND_C_KEY_VERSION
+ + key.getVersion() + "'", aClass).executeUpdate();
+ mg.getTransaction().commit();
+ } finally {
+ mg.close();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.dao.ApexDao#delete(java.lang.Class,
+ * org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey)
+ */
+ @Override
+ public <T extends AxConcept> void delete(final Class<T> aClass, final AxReferenceKey key) {
+ if (key == null) {
+ return;
+ }
+ final EntityManager mg = getEntityManager();
+ try {
+ mg.getTransaction().begin();
+ mg.createQuery(DELETE_FROM + aClass.getSimpleName() + C_WHERE_C_KEY_PARENT_KEY_NAME + key.getParentKeyName()
+ + AND_C_KEY_PARENT_KEY_VERSION + key.getParentKeyVersion() + AND_C_KEY_LOCAL_NAME
+ + key.getLocalName() + "'", aClass).executeUpdate();
+ mg.getTransaction().commit();
+ } finally {
+ mg.close();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.dao.ApexDao#create(java.util.Collection)
+ */
+ @Override
+ public <T extends AxConcept> void create(final Collection<T> objs) {
+ if (objs == null || objs.isEmpty()) {
+ return;
+ }
+ final EntityManager mg = getEntityManager();
+ try {
+ mg.getTransaction().begin();
+ for (final T t : objs) {
+ mg.merge(t);
+ }
+ mg.getTransaction().commit();
+ } finally {
+ mg.close();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.dao.ApexDao#delete(java.util.Collection)
+ */
+ @Override
+ public <T extends AxConcept> void delete(final Collection<T> objs) {
+ if (objs == null || objs.isEmpty()) {
+ return;
+ }
+ final EntityManager mg = getEntityManager();
+ try {
+ mg.getTransaction().begin();
+ for (final T t : objs) {
+ mg.remove(mg.contains(t) ? t : mg.merge(t));
+ }
+ mg.getTransaction().commit();
+ } finally {
+ mg.close();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.dao.ApexDao#deleteByArtifactKey(java.lang.Class, java.util.Collection)
+ */
+ @Override
+ public <T extends AxConcept> int deleteByArtifactKey(final Class<T> aClass, final Collection<AxArtifactKey> keys) {
+ if (keys == null || keys.isEmpty()) {
+ return 0;
+ }
+ int deletedCount = 0;
+ final EntityManager mg = getEntityManager();
+ try {
+ mg.getTransaction().begin();
+ for (final AxArtifactKey key : keys) {
+ deletedCount += mg.createQuery(DELETE_FROM + aClass.getSimpleName() + C_WHERE_C_KEY_NAME + key.getName()
+ + AND_C_KEY_VERSION + key.getVersion() + "'", aClass).executeUpdate();
+ }
+ mg.getTransaction().commit();
+ } finally {
+ mg.close();
+ }
+ return deletedCount;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.dao.ApexDao#deleteByReferenceKey(java.lang.Class,
+ * java.util.Collection)
+ */
+ @Override
+ public <T extends AxConcept> int deleteByReferenceKey(final Class<T> aClass,
+ final Collection<AxReferenceKey> keys) {
+ if (keys == null || keys.isEmpty()) {
+ return 0;
+ }
+ int deletedCount = 0;
+ final EntityManager mg = getEntityManager();
+ try {
+ mg.getTransaction().begin();
+ for (final AxReferenceKey key : keys) {
+ deletedCount +=
+ mg.createQuery(
+ DELETE_FROM + aClass.getSimpleName() + C_WHERE_C_KEY_PARENT_KEY_NAME
+ + key.getParentKeyName() + AND_C_KEY_PARENT_KEY_VERSION
+ + key.getParentKeyVersion() + AND_C_KEY_LOCAL_NAME + key.getLocalName() + "'",
+ aClass).executeUpdate();
+ }
+ mg.getTransaction().commit();
+ } finally {
+ mg.close();
+ }
+ return deletedCount;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.dao.ApexDao#deleteAll(java.lang.Class)
+ */
+ @Override
+ public <T extends AxConcept> void deleteAll(final Class<T> aClass) {
+ final EntityManager mg = getEntityManager();
+ try {
+ mg.getTransaction().begin();
+ mg.createQuery(DELETE_FROM + aClass.getSimpleName() + " c ", aClass).executeUpdate();
+ mg.getTransaction().commit();
+ } finally {
+ mg.close();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.dao.ApexDao#get(java.lang.Class,
+ * org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey)
+ */
+ @Override
+ public <T extends AxConcept> T get(final Class<T> aClass, final AxArtifactKey key) {
+ if (aClass == null) {
+ return null;
+ }
+ final EntityManager mg = getEntityManager();
+ try {
+ final T t = mg.find(aClass, key);
+ if (t != null) {
+ // This clone is created to force the JPA DAO to recurse down through the object
+ try {
+ final T clonedT = aClass.newInstance();
+ t.copyTo(clonedT);
+ return clonedT;
+ } catch (final Exception e) {
+ LOGGER.warn("Could not clone object of class \"" + aClass.getCanonicalName() + "\"", e);
+ return null;
+ }
+ } else {
+ return null;
+ }
+ } finally {
+ mg.close();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.dao.ApexDao#get(java.lang.Class,
+ * org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey)
+ */
+ @Override
+ public <T extends AxConcept> T get(final Class<T> aClass, final AxReferenceKey key) {
+ if (aClass == null) {
+ return null;
+ }
+ final EntityManager mg = getEntityManager();
+ try {
+ final T t = mg.find(aClass, key);
+ if (t != null) {
+ try {
+ final T clonedT = aClass.newInstance();
+ t.copyTo(clonedT);
+ return clonedT;
+ } catch (final Exception e) {
+ LOGGER.warn("Could not clone object of class \"" + aClass.getCanonicalName() + "\"", e);
+ return null;
+ }
+ } else {
+ return null;
+ }
+ } finally {
+ mg.close();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.dao.ApexDao#getAll(java.lang.Class)
+ */
+ @Override
+ public <T extends AxConcept> List<T> getAll(final Class<T> aClass) {
+ if (aClass == null) {
+ return Collections.emptyList();
+ }
+ final EntityManager mg = getEntityManager();
+ try {
+ return mg.createQuery(SELECT_C_FROM + aClass.getSimpleName() + " c", aClass).getResultList();
+ } finally {
+ mg.close();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.dao.ApexDao#getAll(java.lang.Class,
+ * org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey)
+ */
+ @Override
+ public <T extends AxConcept> List<T> getAll(final Class<T> aClass, final AxArtifactKey parentKey) {
+ if (aClass == null) {
+ return Collections.emptyList();
+ }
+ final EntityManager mg = getEntityManager();
+ try {
+ return mg
+ .createQuery(SELECT_C_FROM + aClass.getSimpleName() + C_WHERE_C_KEY_PARENT_KEY_NAME
+ + parentKey.getName() + AND_C_KEY_PARENT_KEY_VERSION + parentKey.getVersion() + "'", aClass)
+ .getResultList();
+ } finally {
+ mg.close();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.dao.ApexDao#getArtifact(java.lang.Class,
+ * org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey)
+ */
+ @Override
+ public <T extends AxConcept> T getArtifact(final Class<T> aClass, final AxArtifactKey key) {
+ if (aClass == null || key == null) {
+ return null;
+ }
+ final EntityManager mg = getEntityManager();
+ List<T> ret;
+ try {
+ ret = mg.createQuery(SELECT_C_FROM + aClass.getSimpleName() + C_WHERE_C_KEY_NAME + key.getName()
+ + AND_C_KEY_VERSION + key.getVersion() + "'", aClass).getResultList();
+ } finally {
+ mg.close();
+ }
+ if (ret == null || ret.isEmpty()) {
+ return null;
+ }
+ if (ret.size() > 1) {
+ throw new IllegalArgumentException("More than one result was returned for search for " + aClass
+ + " with key " + key.getID() + ": " + ret);
+ }
+ return ret.get(0);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.dao.ApexDao#getArtifact(java.lang.Class,
+ * org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey)
+ */
+ @Override
+ public <T extends AxConcept> T getArtifact(final Class<T> aClass, final AxReferenceKey key) {
+ if (aClass == null || key == null) {
+ return null;
+ }
+ final EntityManager mg = getEntityManager();
+ List<T> ret;
+ try {
+ ret = mg.createQuery(SELECT_C_FROM + aClass.getSimpleName() + C_WHERE_C_KEY_PARENT_KEY_NAME
+ + key.getParentKeyName() + AND_C_KEY_PARENT_KEY_VERSION + key.getParentKeyVersion()
+ + AND_C_KEY_LOCAL_NAME + key.getLocalName() + "'", aClass).getResultList();
+ } finally {
+ mg.close();
+ }
+ if (ret == null || ret.isEmpty()) {
+ return null;
+ }
+ if (ret.size() > 1) {
+ throw new IllegalArgumentException("More than one result was returned for search for " + aClass
+ + " with key " + key.getID() + ": " + ret);
+ }
+ return ret.get(0);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.dao.ApexDao#update(org.onap.policy.apex.model.basicmodel.concepts.
+ * AxConcept)
+ */
+ @Override
+ public <T extends AxConcept> T update(final T obj) {
+ final EntityManager mg = getEntityManager();
+ T ret;
+ try {
+ mg.getTransaction().begin();
+ ret = mg.merge(obj);
+ mg.flush();
+ mg.getTransaction().commit();
+ } finally {
+ mg.close();
+ }
+ return ret;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.basicmodel.dao.ApexDao#size(java.lang.Class)
+ */
+ @Override
+ public <T extends AxConcept> long size(final Class<T> aClass) {
+ if (aClass == null) {
+ return 0;
+ }
+ final EntityManager mg = getEntityManager();
+ long size = 0;
+ try {
+ size = mg.createQuery("SELECT COUNT(c) FROM " + aClass.getSimpleName() + " c", Long.class)
+ .getSingleResult();
+ } finally {
+ mg.close();
+ }
+ return size;
+ }
+}
diff --git a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/dao/impl/package-info.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/impl/package-info.java
index 16da22646..12e854f26 100644
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/dao/impl/package-info.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/impl/package-info.java
@@ -19,8 +19,8 @@
*/
/**
- * Contains a default DAO implementation for APEX {@link org.onap.apex.model.basicmodel.concepts.AxConcept} classes that uses javax persistence.
+ * Contains a default DAO implementation for APEX {@link org.onap.policy.apex.model.basicmodel.concepts.AxConcept} classes that uses javax persistence.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-package org.onap.apex.model.basicmodel.dao.impl;
+package org.onap.policy.apex.model.basicmodel.dao.impl;
diff --git a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/dao/package-info.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/package-info.java
index 0ad255a9a..fe551b87a 100644
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/dao/package-info.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/package-info.java
@@ -1,27 +1,29 @@
-/*
+/*-
* ============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=========================================================
*/
/**
- * Defines and implements the Data Access Object (DAO) that allows Apex {@link org.onap.apex.model.basicmodel.concepts.AxConcept} concepts to
- * be read from and written to databases over JDBC.
- *
+ * Defines and implements the Data Access Object (DAO) that allows Apex
+ * {@link org.onap.policy.apex.model.basicmodel.concepts.AxConcept} concepts to be read from and written to databases over
+ * JDBC.
+ *
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-package org.onap.apex.model.basicmodel.dao;
+
+package org.onap.policy.apex.model.basicmodel.dao;
diff --git a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/handling/ApexModelCreator.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelCreator.java
index 5a9de967f..7b6d830e9 100644
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/handling/ApexModelCreator.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelCreator.java
@@ -18,9 +18,9 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.apex.model.basicmodel.handling;
+package org.onap.policy.apex.model.basicmodel.handling;
-import org.onap.apex.model.basicmodel.concepts.AxModel;
+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.
diff --git a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/handling/ApexModelException.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelException.java
index 252bee4ed..8964a5bc2 100644
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/handling/ApexModelException.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelException.java
@@ -18,9 +18,9 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.apex.model.basicmodel.handling;
+package org.onap.policy.apex.model.basicmodel.handling;
-import org.onap.apex.model.basicmodel.concepts.ApexException;
+import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
/**
* This exception is invoked if an exception occurs in model handling.
diff --git a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/handling/ApexModelFileWriter.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelFileWriter.java
index 8d9cf2ae0..2312b88db 100644
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/handling/ApexModelFileWriter.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelFileWriter.java
@@ -18,13 +18,13 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.apex.model.basicmodel.handling;
+package org.onap.policy.apex.model.basicmodel.handling;
import java.io.File;
import java.io.FileOutputStream;
-import org.onap.apex.model.basicmodel.concepts.ApexException;
-import org.onap.apex.model.basicmodel.concepts.AxModel;
+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;
diff --git a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/handling/ApexModelReader.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelReader.java
index 84760f5db..b19255a5b 100644
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/handling/ApexModelReader.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelReader.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.apex.model.basicmodel.handling;
+package org.onap.policy.apex.model.basicmodel.handling;
import java.io.BufferedReader;
import java.io.IOException;
@@ -40,8 +40,8 @@ import javax.xml.validation.SchemaFactory;
import org.eclipse.persistence.jaxb.JAXBContextFactory;
import org.eclipse.persistence.jaxb.MarshallerProperties;
import org.eclipse.persistence.oxm.MediaType;
-import org.onap.apex.model.basicmodel.concepts.AxConcept;
-import org.onap.apex.model.basicmodel.concepts.AxValidationResult;
+import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
+import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
import org.onap.policy.apex.model.utilities.Assertions;
import org.onap.policy.apex.model.utilities.ResourceUtils;
import org.onap.policy.apex.model.utilities.TextFileUtils;
diff --git a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/handling/ApexModelSaver.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelSaver.java
index 7f4efee99..16ea1f3fa 100644
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/handling/ApexModelSaver.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelSaver.java
@@ -18,12 +18,12 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.apex.model.basicmodel.handling;
+package org.onap.policy.apex.model.basicmodel.handling;
import java.io.File;
-import org.onap.apex.model.basicmodel.concepts.ApexException;
-import org.onap.apex.model.basicmodel.concepts.AxModel;
+import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
+import org.onap.policy.apex.model.basicmodel.concepts.AxModel;
import org.onap.policy.apex.model.utilities.Assertions;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
diff --git a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/handling/ApexModelStringWriter.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelStringWriter.java
index 882092c05..3d2e50b38 100644
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/handling/ApexModelStringWriter.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelStringWriter.java
@@ -18,12 +18,12 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.apex.model.basicmodel.handling;
+package org.onap.policy.apex.model.basicmodel.handling;
import java.io.ByteArrayOutputStream;
-import org.onap.apex.model.basicmodel.concepts.ApexException;
-import org.onap.apex.model.basicmodel.concepts.AxConcept;
+import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
+import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
import org.onap.policy.apex.model.utilities.Assertions;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
diff --git a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/handling/ApexModelWriter.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelWriter.java
index 5b7a9568b..180c2447a 100644
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/handling/ApexModelWriter.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelWriter.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.apex.model.basicmodel.handling;
+package org.onap.policy.apex.model.basicmodel.handling;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
@@ -41,8 +41,8 @@ import javax.xml.transform.stream.StreamResult;
import org.eclipse.persistence.jaxb.JAXBContextFactory;
import org.eclipse.persistence.jaxb.MarshallerProperties;
import org.eclipse.persistence.oxm.MediaType;
-import org.onap.apex.model.basicmodel.concepts.AxConcept;
-import org.onap.apex.model.basicmodel.concepts.AxValidationResult;
+import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
+import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
import org.onap.policy.apex.model.utilities.Assertions;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
diff --git a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/handling/ApexSchemaGenerator.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexSchemaGenerator.java
index 5055df630..6e17ab94d 100644
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/handling/ApexSchemaGenerator.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexSchemaGenerator.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.apex.model.basicmodel.handling;
+package org.onap.policy.apex.model.basicmodel.handling;
import java.io.File;
import java.io.IOException;
diff --git a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/handling/package-info.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/package-info.java
index 871a0ea49..081cff540 100644
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/handling/package-info.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/package-info.java
@@ -1,36 +1,35 @@
-/*
+/*-
* ============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 a number of utility classes for handling APEX {@link org.onap.apex.model.basicmodel.concepts.AxModel} models and
- * {@link org.onap.apex.model.basicmodel.concepts.AxConcept} concepts.
- * Classes to read and write models to files, strings, and databases are included, as
- * well as classes to generate XML schemas for models.
- *
+ * Contains a number of utility classes for handling APEX {@link org.onap.policy.apex.model.basicmodel.concepts.AxModel}
+ * models and {@link org.onap.policy.apex.model.basicmodel.concepts.AxConcept} concepts. Classes to read and write
+ * models to files, strings, and databases are included, as well as classes to generate XML schemas for models.
+ *
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-@XmlSchema(namespace = "http://www.ericsson.com/apex", elementFormDefault = XmlNsForm.QUALIFIED, xmlns = {
- @XmlNs(namespaceURI = "http://www.ericsson.com/apex", prefix = "") })
+@XmlSchema(namespace = "http://www.onap.org/policy/apex-pdp", elementFormDefault = XmlNsForm.QUALIFIED,
+ xmlns = { @XmlNs(namespaceURI = "http://www.onap.org/policy/apex-pdp", prefix = "") })
-package org.onap.apex.model.basicmodel.handling;
+package org.onap.policy.apex.model.basicmodel.handling;
import javax.xml.bind.annotation.XmlNs;
import javax.xml.bind.annotation.XmlNsForm;
diff --git a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/package-info.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/package-info.java
index dbee9cc9d..8c76c5fc8 100644
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/package-info.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/package-info.java
@@ -26,4 +26,4 @@
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-package org.onap.apex.model.basicmodel;
+package org.onap.policy.apex.model.basicmodel;
diff --git a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/service/AbstractParameters.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/service/AbstractParameters.java
index 2cde32518..95bc853b8 100644
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/service/AbstractParameters.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/service/AbstractParameters.java
@@ -18,9 +18,9 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.apex.model.basicmodel.service;
+package org.onap.policy.apex.model.basicmodel.service;
-import org.onap.apex.model.basicmodel.concepts.ApexRuntimeException;
+import org.onap.policy.apex.model.basicmodel.concepts.ApexRuntimeException;
import org.onap.policy.apex.model.utilities.Assertions;
/**
diff --git a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/service/ModelService.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/service/ModelService.java
index 688beaa4f..d1ecc6031 100644
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/service/ModelService.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/service/ModelService.java
@@ -18,13 +18,13 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.apex.model.basicmodel.service;
+package org.onap.policy.apex.model.basicmodel.service;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import org.onap.apex.model.basicmodel.concepts.ApexRuntimeException;
-import org.onap.apex.model.basicmodel.concepts.AxConcept;
+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.
diff --git a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/service/ParameterService.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/service/ParameterService.java
index 9a254b0d6..062213093 100644
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/service/ParameterService.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/service/ParameterService.java
@@ -18,14 +18,14 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.apex.model.basicmodel.service;
+package org.onap.policy.apex.model.basicmodel.service;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
-import org.onap.apex.model.basicmodel.concepts.ApexRuntimeException;
+import org.onap.policy.apex.model.basicmodel.concepts.ApexRuntimeException;
/**
* The parameter service makes Apex parameters available to all classes in a JVM.
diff --git a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/service/package-info.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/service/package-info.java
index da6c69898..a27e45d1a 100644
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/service/package-info.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/service/package-info.java
@@ -23,4 +23,4 @@
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-package org.onap.apex.model.basicmodel.service;
+package org.onap.policy.apex.model.basicmodel.service;
diff --git a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/test/TestApexModel.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/test/TestApexModel.java
index e7e50677e..04b64207d 100644
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/test/TestApexModel.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/test/TestApexModel.java
@@ -18,22 +18,22 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.apex.model.basicmodel.test;
+package org.onap.policy.apex.model.basicmodel.test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.net.URL;
-import org.onap.apex.model.basicmodel.concepts.ApexException;
-import org.onap.apex.model.basicmodel.concepts.AxModel;
-import org.onap.apex.model.basicmodel.concepts.AxValidationResult;
-import org.onap.apex.model.basicmodel.dao.ApexDao;
-import org.onap.apex.model.basicmodel.dao.ApexDaoFactory;
-import org.onap.apex.model.basicmodel.dao.DAOParameters;
-import org.onap.apex.model.basicmodel.handling.ApexModelFileWriter;
-import org.onap.apex.model.basicmodel.handling.ApexModelReader;
-import org.onap.apex.model.basicmodel.handling.ApexModelWriter;
+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.dao.ApexDao;
+import org.onap.policy.apex.model.basicmodel.dao.ApexDaoFactory;
+import org.onap.policy.apex.model.basicmodel.dao.DAOParameters;
+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.apex.model.utilities.ResourceUtils;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
diff --git a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/test/TestApexModelCreator.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/test/TestApexModelCreator.java
index 7213c6694..980748926 100644
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/test/TestApexModelCreator.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/test/TestApexModelCreator.java
@@ -18,10 +18,10 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.apex.model.basicmodel.test;
+package org.onap.policy.apex.model.basicmodel.test;
-import org.onap.apex.model.basicmodel.concepts.AxModel;
-import org.onap.apex.model.basicmodel.handling.ApexModelCreator;
+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
diff --git a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/test/package-info.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/test/package-info.java
index 6bd6b73fb..9bbdd1cce 100644
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/test/package-info.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/test/package-info.java
@@ -23,4 +23,4 @@
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-package org.onap.apex.model.basicmodel.test;
+package org.onap.policy.apex.model.basicmodel.test;
diff --git a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/xml/AxReferenceKeyAdapter.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/xml/AxReferenceKeyAdapter.java
index a2bfbb80a..28f0cf7af 100644
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/xml/AxReferenceKeyAdapter.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/xml/AxReferenceKeyAdapter.java
@@ -1,24 +1,24 @@
-/*
+/*-
* ============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.apex.model.basicmodel.xml;
+package org.onap.policy.apex.model.basicmodel.xml;
import java.io.Serializable;
@@ -27,20 +27,21 @@ import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlAdapter;
-import org.onap.apex.model.basicmodel.concepts.AxReferenceKey;
+import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
/**
- * This class manages marshaling and unmarshaling of Apex {@link AxReferenceKey} concepts using JAXB. The local name in reference keys must have specific
- * handling.
+ * This class manages marshaling and unmarshaling of Apex {@link AxReferenceKey} concepts using JAXB. The local name in
+ * reference keys must have specific handling.
*/
@XmlAccessorType(XmlAccessType.PROPERTY)
-@XmlType(namespace = "http://www.ericsson.com/apex")
+@XmlType(namespace = "http://www.onap.org/policy/apex-pdp")
public class AxReferenceKeyAdapter extends XmlAdapter<String, AxReferenceKey> implements Serializable {
private static final long serialVersionUID = -3480405083900107029L;
/*
* (non-Javadoc)
+ *
* @see javax.xml.bind.annotation.adapters.XmlAdapter#marshal(java.lang.Object)
*/
@Override
@@ -50,6 +51,7 @@ public class AxReferenceKeyAdapter extends XmlAdapter<String, AxReferenceKey> im
/*
* (non-Javadoc)
+ *
* @see javax.xml.bind.annotation.adapters.XmlAdapter#unmarshal(java.lang.Object)
*/
@Override
diff --git a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/xml/package-info.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/xml/package-info.java
index 77bc0c13b..290209d89 100644
--- a/model/basic-model/src/main/java/org/onap/apex/model/basicmodel/xml/package-info.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/xml/package-info.java
@@ -1,33 +1,33 @@
-/*
+/*-
* ============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 for managing marshaling and unmarshaling of APEX models using JAXB.
- *
+ *
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-@XmlSchema(namespace = "http://www.ericsson.com/apex", elementFormDefault = XmlNsForm.QUALIFIED, xmlns = {
- @XmlNs(namespaceURI = "http://www.ericsson.com/apex", prefix = "") })
+@XmlSchema(namespace = "http://www.onap.org/policy/apex-pdp", elementFormDefault = XmlNsForm.QUALIFIED,
+ xmlns = { @XmlNs(namespaceURI = "http://www.onap.org/policy/apex-pdp", prefix = "") })
-package org.onap.apex.model.basicmodel.xml;
+package org.onap.policy.apex.model.basicmodel.xml;
import javax.xml.bind.annotation.XmlNs;
import javax.xml.bind.annotation.XmlNsForm;
diff --git a/model/basic-model/src/main/resources/xml/example.xsd b/model/basic-model/src/main/resources/xml/example.xsd
index 9f253f29c..75ecdc323 100644
--- a/model/basic-model/src/main/resources/xml/example.xsd
+++ b/model/basic-model/src/main/resources/xml/example.xsd
@@ -18,7 +18,7 @@
SPDX-License-Identifier: Apache-2.0
============LICENSE_END=========================================================
-->
-<xs:schema elementFormDefault="qualified" version="1.0" targetNamespace="http://www.ericsson.com/apex" xmlns="http://www.ericsson.com/apex" xmlns:tns="http://www.ericsson.com/apex" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+<xs:schema elementFormDefault="qualified" version="1.0" targetNamespace="http://www.onap.org/policy/apex-pdp" xmlns="http://www.onap.org/policy/apex-pdp" xmlns:tns="http://www.onap.org/policy/apex-pdp" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="apexArtifactKey" type="AxArtifactKey"/>
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexBasicModel.java b/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexBasicModel.java
deleted file mode 100644
index e4d91b7a2..000000000
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexBasicModel.java
+++ /dev/null
@@ -1,137 +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.apex.model.basicmodel.handling;
-
-import static org.junit.Assert.*;
-
-import java.io.File;
-import java.sql.Connection;
-import java.sql.DriverManager;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.apex.model.basicmodel.concepts.ApexException;
-import org.onap.apex.model.basicmodel.concepts.AxModel;
-import org.onap.apex.model.basicmodel.concepts.AxValidationResult;
-import org.onap.apex.model.basicmodel.dao.DAOParameters;
-import org.onap.apex.model.basicmodel.test.TestApexModel;
-
-public class TestApexBasicModel {
- private Connection connection;
- TestApexModel<AxModel> testApexModel;
-
- @Before
- public void setup() throws Exception {
- Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
- connection = DriverManager.getConnection("jdbc:derby:memory:apex_test;create=true");
-
- testApexModel = new TestApexModel<AxModel>(AxModel.class, new TestApexBasicModelCreator());
- }
-
- @After
- public void teardown() throws Exception {
- connection.close();
- new File("derby.log").delete();
- }
-
- @Test
- public void testModelValid() throws Exception {
- AxValidationResult result = testApexModel.testApexModelValid();
- assertTrue(result.toString().equals(VALID_MODEL_STRING));
- }
-
- @Test
- public void testApexModelVaidateObservation() throws Exception {
- try {
- testApexModel.testApexModelVaidateObservation();
- }
- catch (ApexException e) {
- assertEquals("model should have observations", e.getMessage());
- }
- }
-
- @Test
- public void testApexModelVaidateWarning() throws Exception {
- AxValidationResult result = testApexModel.testApexModelVaidateWarning();
- assertTrue(result.toString().equals(WARNING_MODEL_STRING));
- }
-
- @Test
- public void testModelVaidateInvalidModel() throws Exception {
- AxValidationResult result = testApexModel.testApexModelVaidateInvalidModel();
- assertTrue(result.toString().equals(INVALID_MODEL_STRING));
- }
-
- @Test
- public void testModelVaidateMalstructured() throws Exception {
- AxValidationResult result = testApexModel.testApexModelVaidateMalstructured();
- assertTrue(result.toString().equals(INVALID_MODEL_MALSTRUCTURED_STRING));
- }
-
- @Test
- public void testModelWriteReadXML() throws Exception {
- testApexModel.testApexModelWriteReadXML();
- }
-
- @Test
- public void testModelWriteReadJSON() throws Exception {
- testApexModel.testApexModelWriteReadJSON();
- }
-
- @Test
- public void testModelWriteReadJPA() throws Exception {
- DAOParameters daoParameters = new DAOParameters();
- daoParameters.setPluginClass("org.onap.apex.model.basicmodel.dao.impl.DefaultApexDao");
- daoParameters.setPersistenceUnit("DAOTest");
-
- testApexModel.testApexModelWriteReadJPA(daoParameters);
- }
-
- // As there are no real concepts in a basic model, this is as near to a valid model as we can get
- private static final String VALID_MODEL_STRING = "\n" +
- "***warnings issued during validation of model***\n" +
- "AxArtifactKey:(name=FloatKIKey,version=0.0.1):org.onap.apex.model.basicmodel.concepts.AxModel:WARNING:key not found for key information entry\n" +
- "AxArtifactKey:(name=IntegerKIKey,version=0.0.1):org.onap.apex.model.basicmodel.concepts.AxModel:WARNING:key not found for key information entry\n" +
- "********************************";
-
- private static final String WARNING_MODEL_STRING = "\n" +
- "***warnings issued during validation of model***\n" +
- "AxArtifactKey:(name=FloatKIKey,version=0.0.1):org.onap.apex.model.basicmodel.concepts.AxModel:WARNING:key not found for key information entry\n" +
- "AxArtifactKey:(name=IntegerKIKey,version=0.0.1):org.onap.apex.model.basicmodel.concepts.AxModel:WARNING:key not found for key information entry\n" +
- "AxArtifactKey:(name=Unref0,version=0.0.1):org.onap.apex.model.basicmodel.concepts.AxModel:WARNING:key not found for key information entry\n" +
- "AxArtifactKey:(name=Unref1,version=0.0.1):org.onap.apex.model.basicmodel.concepts.AxModel:WARNING:key not found for key information entry\n" +
- "********************************";
-
- private static final String INVALID_MODEL_STRING = "\n" +
- "***validation of model failed***\n" +
- "AxArtifactKey:(name=BasicModelKey,version=0.0.1):org.onap.apex.model.basicmodel.concepts.AxKeyInfo:WARNING:UUID is a zero UUID: 00000000-0000-0000-0000-000000000000\n" +
- "AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1):org.onap.apex.model.basicmodel.concepts.AxKeyInfo:OBSERVATION:description is blank\n" +
- "AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1):org.onap.apex.model.basicmodel.concepts.AxKeyInfo:WARNING:UUID is a zero UUID: 00000000-0000-0000-0000-000000000000\n" +
- "AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1):org.onap.apex.model.basicmodel.concepts.AxKeyInformation:INVALID:duplicate UUID found on keyInfoMap entry AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1):00000000-0000-0000-0000-000000000000\n" +
- "********************************";
-
- private static final String INVALID_MODEL_MALSTRUCTURED_STRING = "\n" +
- "***validation of model failed***\n" +
- "AxArtifactKey:(name=BasicModelKey,version=0.0.1):org.onap.apex.model.basicmodel.concepts.AxKeyInfo:WARNING:UUID is a zero UUID: 00000000-0000-0000-0000-000000000000\n" +
- "AxArtifactKey:(name=BasicModelKey,version=0.0.1):org.onap.apex.model.basicmodel.concepts.AxModel:INVALID:key information not found for key AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1)\n" +
- "********************************";
-}
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/AxKeyTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyTest.java
index a454aaf92..6ac46b14e 100644
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/AxKeyTest.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyTest.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.apex.model.basicmodel.concepts;
+package org.onap.policy.apex.model.basicmodel.concepts;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -27,11 +27,11 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.junit.Test;
-import org.onap.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.apex.model.basicmodel.concepts.AxKey;
-import org.onap.apex.model.basicmodel.concepts.AxReferenceKey;
-import org.onap.apex.model.basicmodel.concepts.AxValidationResult;
-import org.onap.apex.model.basicmodel.concepts.AxKey.Compatibility;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
+import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
+import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
+import org.onap.policy.apex.model.basicmodel.concepts.AxKey.Compatibility;
/**
* @author Liam Fallon (liam.fallon@ericsson.com)
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/TestAxKeyInfo.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/TestAxKeyInfo.java
index 6af662bdf..8368634bf 100644
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/TestAxKeyInfo.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/TestAxKeyInfo.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.apex.model.basicmodel.concepts;
+package org.onap.policy.apex.model.basicmodel.concepts;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -29,9 +29,9 @@ import static org.junit.Assert.assertTrue;
import java.util.UUID;
import org.junit.Test;
-import org.onap.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.apex.model.basicmodel.concepts.AxKeyInfo;
-import org.onap.apex.model.basicmodel.concepts.AxValidationResult;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo;
+import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
/**
* @author Liam Fallon (liam.fallon@ericsson.com)
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/TestAxReferenceKey.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/TestAxReferenceKey.java
index 7ec3cbbbf..dbc925d66 100644
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/TestAxReferenceKey.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/TestAxReferenceKey.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.apex.model.basicmodel.concepts;
+package org.onap.policy.apex.model.basicmodel.concepts;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -27,10 +27,10 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
-import org.onap.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.apex.model.basicmodel.concepts.AxKey;
-import org.onap.apex.model.basicmodel.concepts.AxReferenceKey;
-import org.onap.apex.model.basicmodel.concepts.AxValidationResult;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
+import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
+import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
/**
* @author Liam Fallon (liam.fallon@ericsson.com)
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/TestEntity.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/TestEntity.java
index 3e821f7c5..6ba380bb8 100644
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/TestEntity.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/TestEntity.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.apex.model.basicmodel.concepts;
+package org.onap.policy.apex.model.basicmodel.concepts;
import java.util.Arrays;
import java.util.List;
@@ -29,11 +29,11 @@ import javax.persistence.Table;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-import org.onap.apex.model.basicmodel.concepts.AxConcept;
-import org.onap.apex.model.basicmodel.concepts.AxKey;
-import org.onap.apex.model.basicmodel.concepts.AxReferenceKey;
-import org.onap.apex.model.basicmodel.concepts.AxValidationResult;
-import org.onap.apex.model.basicmodel.xml.AxReferenceKeyAdapter;
+import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
+import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
+import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
+import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
+import org.onap.policy.apex.model.basicmodel.xml.AxReferenceKeyAdapter;
@Entity
@Table(name = "TestEntity")
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/TestExceptions.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/TestExceptions.java
index 1d37cd8ed..1fc5209b0 100644
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/TestExceptions.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/TestExceptions.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.apex.model.basicmodel.concepts;
+package org.onap.policy.apex.model.basicmodel.concepts;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -26,10 +26,10 @@ import static org.junit.Assert.assertNotNull;
import java.io.IOException;
import org.junit.Test;
-import org.onap.apex.model.basicmodel.concepts.ApexConceptException;
-import org.onap.apex.model.basicmodel.concepts.ApexException;
-import org.onap.apex.model.basicmodel.concepts.ApexRuntimeException;
-import org.onap.apex.model.basicmodel.concepts.AxArtifactKey;
+import org.onap.policy.apex.model.basicmodel.concepts.ApexConceptException;
+import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
+import org.onap.policy.apex.model.basicmodel.concepts.ApexRuntimeException;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
/**
* @author Liam Fallon (liam.fallon@ericsson.com)
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/TestValidation.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/TestValidation.java
index e8eff5230..93eb78b7c 100644
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/TestValidation.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/TestValidation.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.apex.model.basicmodel.concepts;
+package org.onap.policy.apex.model.basicmodel.concepts;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -26,11 +26,11 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
-import org.onap.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.apex.model.basicmodel.concepts.AxReferenceKey;
-import org.onap.apex.model.basicmodel.concepts.AxValidationMessage;
-import org.onap.apex.model.basicmodel.concepts.AxValidationResult;
-import org.onap.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
+import org.onap.policy.apex.model.basicmodel.concepts.AxValidationMessage;
+import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
+import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
/**
* @author Liam Fallon (liam.fallon@ericsson.com)
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/testKeyUse.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/testKeyUse.java
index ca1e5c191..10706f36a 100644
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/testKeyUse.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/testKeyUse.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.apex.model.basicmodel.concepts;
+package org.onap.policy.apex.model.basicmodel.concepts;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -27,11 +27,11 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
-import org.onap.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.apex.model.basicmodel.concepts.AxKeyUse;
-import org.onap.apex.model.basicmodel.concepts.AxReferenceKey;
-import org.onap.apex.model.basicmodel.concepts.AxValidationResult;
-import org.onap.apex.model.basicmodel.concepts.AxKey.Compatibility;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+import org.onap.policy.apex.model.basicmodel.concepts.AxKeyUse;
+import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
+import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
+import org.onap.policy.apex.model.basicmodel.concepts.AxKey.Compatibility;
public class testKeyUse {
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/dao/EntityTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/dao/EntityTest.java
index 87779848e..e5d597375 100644
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/dao/EntityTest.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/dao/EntityTest.java
@@ -1,24 +1,24 @@
-/*
+/*-
* ============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.apex.model.basicmodel.dao;
+package org.onap.policy.apex.model.basicmodel.dao;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -38,14 +38,11 @@ import java.util.UUID;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import org.onap.apex.model.basicmodel.concepts.ApexException;
-import org.onap.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.apex.model.basicmodel.concepts.AxKeyInfo;
-import org.onap.apex.model.basicmodel.concepts.AxReferenceKey;
-import org.onap.apex.model.basicmodel.concepts.TestEntity;
-import org.onap.apex.model.basicmodel.dao.ApexDao;
-import org.onap.apex.model.basicmodel.dao.ApexDaoFactory;
-import org.onap.apex.model.basicmodel.dao.DAOParameters;
+import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo;
+import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
+import org.onap.policy.apex.model.basicmodel.concepts.TestEntity;
/**
* JUnit test class
@@ -75,16 +72,14 @@ public class EntityTest {
try {
apexDao.init(null);
fail("Test should throw an exception here");
- }
- catch (final Exception e) {
+ } catch (final Exception e) {
assertEquals("Apex persistence unit parameter not set", e.getMessage());
}
try {
apexDao.init(daoParameters);
fail("Test should throw an exception here");
- }
- catch (final Exception e) {
+ } catch (final Exception e) {
assertEquals("Apex persistence unit parameter not set", e.getMessage());
}
@@ -93,15 +88,13 @@ public class EntityTest {
try {
apexDao.init(daoParameters);
fail("Test should throw an exception here");
- }
- catch (final Exception e) {
+ } catch (final Exception e) {
assertEquals("Creation of Apex persistence unit \"Dorothy\" failed", e.getMessage());
}
try {
apexDao.create(new AxArtifactKey());
fail("Test should throw an exception here");
- }
- catch (final Exception e) {
+ } catch (final Exception e) {
assertEquals("Apex DAO has not been initialized", e.getMessage());
}
apexDao.close();
@@ -110,7 +103,7 @@ public class EntityTest {
@Test
public void testEntityTestAllOpsJPA() throws ApexException {
final DAOParameters daoParameters = new DAOParameters();
- daoParameters.setPluginClass("org.onap.apex.model.basicmodel.dao.impl.DefaultApexDao");
+ daoParameters.setPluginClass("org.onap.policy.apex.model.basicmodel.dao.impl.DefaultApexDao");
daoParameters.setPersistenceUnit("DAOTest");
apexDao = new ApexDaoFactory().createApexDao(daoParameters);
@@ -123,7 +116,7 @@ public class EntityTest {
@Test
public void testEntityTestBadVals() throws ApexException {
final DAOParameters daoParameters = new DAOParameters();
- daoParameters.setPluginClass("org.onap.apex.model.basicmodel.dao.impl.DefaultApexDao");
+ daoParameters.setPluginClass("org.onap.policy.apex.model.basicmodel.dao.impl.DefaultApexDao");
daoParameters.setPersistenceUnit("DAOTest");
apexDao = new ApexDaoFactory().createApexDao(daoParameters);
@@ -163,13 +156,16 @@ public class EntityTest {
apexDao.close();
}
- private void testAllOps(){
- final AxArtifactKey aKey0 = new AxArtifactKey("A-KEY0", "0.0.1");
- final AxArtifactKey aKey1 = new AxArtifactKey("A-KEY1", "0.0.1");
- final AxArtifactKey aKey2 = new AxArtifactKey("A-KEY2", "0.0.1");
- final AxKeyInfo keyInfo0 = new AxKeyInfo(aKey0, UUID.fromString("00000000-0000-0000-0000-000000000000"), "key description 0");
- final AxKeyInfo keyInfo1 = new AxKeyInfo(aKey1, UUID.fromString("00000000-0000-0000-0000-000000000001"), "key description 1");
- final AxKeyInfo keyInfo2 = new AxKeyInfo(aKey2, UUID.fromString("00000000-0000-0000-0000-000000000002"), "key description 2");
+ private void testAllOps() {
+ final AxArtifactKey aKey0 = new AxArtifactKey("A-KEY0", "0.0.1");
+ final AxArtifactKey aKey1 = new AxArtifactKey("A-KEY1", "0.0.1");
+ final AxArtifactKey aKey2 = new AxArtifactKey("A-KEY2", "0.0.1");
+ final AxKeyInfo keyInfo0 =
+ new AxKeyInfo(aKey0, UUID.fromString("00000000-0000-0000-0000-000000000000"), "key description 0");
+ final AxKeyInfo keyInfo1 =
+ new AxKeyInfo(aKey1, UUID.fromString("00000000-0000-0000-0000-000000000001"), "key description 1");
+ final AxKeyInfo keyInfo2 =
+ new AxKeyInfo(aKey2, UUID.fromString("00000000-0000-0000-0000-000000000002"), "key description 2");
apexDao.create(keyInfo0);
@@ -182,7 +178,7 @@ public class EntityTest {
final AxKeyInfo keyInfoBack1 = apexDao.getArtifact(AxKeyInfo.class, aKey0);
assertTrue(keyInfoBack0.equals(keyInfoBack1));
- final AxKeyInfo keyInfoBack2 = apexDao.getArtifact(AxKeyInfo.class, new AxArtifactKey("A-KEY3", "0.0.1"));
+ final AxKeyInfo keyInfoBack2 = apexDao.getArtifact(AxKeyInfo.class, new AxArtifactKey("A-KEY3", "0.0.1"));
assertNull(keyInfoBack2);
final Set<AxKeyInfo> keyInfoSetIn = new TreeSet<AxKeyInfo>();
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/dao/TestDaoMisc.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/dao/TestDaoMisc.java
index 9109bc24b..9f5b72d39 100644
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/dao/TestDaoMisc.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/dao/TestDaoMisc.java
@@ -1,24 +1,24 @@
-/*
+/*-
* ============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.apex.model.basicmodel.dao;
+package org.onap.policy.apex.model.basicmodel.dao;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
@@ -27,10 +27,8 @@ import static org.junit.Assert.fail;
import java.util.Properties;
import org.junit.Test;
-import org.onap.apex.model.basicmodel.dao.ApexDaoFactory;
-import org.onap.apex.model.basicmodel.dao.DAOParameters;
-import org.onap.apex.model.basicmodel.dao.converters.CDATAConditioner;
-import org.onap.apex.model.basicmodel.dao.converters.UUID2String;
+import org.onap.policy.apex.model.basicmodel.dao.converters.CDATAConditioner;
+import org.onap.policy.apex.model.basicmodel.dao.converters.UUID2String;
/**
* @author Liam Fallon (liam.fallon@ericsson.com)
@@ -39,7 +37,7 @@ public class TestDaoMisc {
@Test
public void testUUID2StringMopUp() {
- UUID2String uuid2String = new UUID2String();
+ final UUID2String uuid2String = new UUID2String();
assertEquals("", uuid2String.convertToDatabaseColumn(null));
}
@@ -47,45 +45,47 @@ public class TestDaoMisc {
public void testCDataConditionerMopUp() {
assertNull(CDATAConditioner.clean(null));
}
-
+
@Test
public void testDaoFactory() {
- DAOParameters daoParameters = new DAOParameters();
+ final DAOParameters daoParameters = new DAOParameters();
daoParameters.setPluginClass("somewhere.over.the.rainbow");
try {
new ApexDaoFactory().createApexDao(daoParameters);
fail("test shold throw an exception here");
- }
- catch (Exception e) {
+ } catch (final Exception e) {
assertEquals("Apex DAO class not found for DAO plugin \"somewhere.over.the.rainbow\"", e.getMessage());
}
-
+
daoParameters.setPluginClass("java.lang.String");
try {
new ApexDaoFactory().createApexDao(daoParameters);
fail("test shold throw an exception here");
- }
- catch (Exception e) {
- assertEquals("Specified Apex DAO plugin class \"java.lang.String\" does not implement the ApexDao interface", e.getMessage());
+ } catch (final Exception e) {
+ assertEquals(
+ "Specified Apex DAO plugin class \"java.lang.String\" does not implement the ApexDao interface",
+ e.getMessage());
}
}
-
+
@Test
public void testDaoParameters() {
- DAOParameters pars = new DAOParameters();
+ final DAOParameters pars = new DAOParameters();
pars.setJdbcProperties(new Properties());
assertEquals(0, pars.getJdbcProperties().size());
-
+
pars.setJdbcProperty("name", "Dorothy");
assertEquals("Dorothy", pars.getJdbcProperty("name"));
-
+
pars.setPersistenceUnit("Kansas");
assertEquals("Kansas", pars.getPersistenceUnit());
-
+
pars.setPluginClass("somewhere.over.the.rainbow");
assertEquals("somewhere.over.the.rainbow", pars.getPluginClass());
-
- assertEquals("DAOParameters [pluginClass=somewhere.over.the.rainbow, persistenceUnit=Kansas, jdbcProperties={name=Dorothy}]", pars.toString());
+
+ assertEquals(
+ "DAOParameters [pluginClass=somewhere.over.the.rainbow, persistenceUnit=Kansas, jdbcProperties={name=Dorothy}]",
+ pars.toString());
}
}
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/AxModelWithReferences.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/AxModelWithReferences.java
index e08b4482c..38359052b 100644
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/AxModelWithReferences.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/AxModelWithReferences.java
@@ -18,15 +18,15 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.apex.model.basicmodel.handling;
+package org.onap.policy.apex.model.basicmodel.handling;
import java.util.ArrayList;
import java.util.List;
-import org.onap.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.apex.model.basicmodel.concepts.AxKey;
-import org.onap.apex.model.basicmodel.concepts.AxModel;
-import org.onap.apex.model.basicmodel.concepts.AxReferenceKey;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
+import org.onap.policy.apex.model.basicmodel.concepts.AxModel;
+import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
public class AxModelWithReferences extends AxModel {
private static final long serialVersionUID = -8194956638511120008L;
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestApexBasicModel.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestApexBasicModel.java
new file mode 100644
index 000000000..d0423eb3a
--- /dev/null
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestApexBasicModel.java
@@ -0,0 +1,133 @@
+/*-
+ * ============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 static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.sql.Connection;
+import java.sql.DriverManager;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+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.dao.DAOParameters;
+import org.onap.policy.apex.model.basicmodel.test.TestApexModel;
+
+public class TestApexBasicModel {
+ private Connection connection;
+ TestApexModel<AxModel> testApexModel;
+
+ @Before
+ public void setup() throws Exception {
+ Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
+ connection = DriverManager.getConnection("jdbc:derby:memory:apex_test;create=true");
+
+ testApexModel = new TestApexModel<AxModel>(AxModel.class, new TestApexBasicModelCreator());
+ }
+
+ @After
+ public void teardown() throws Exception {
+ connection.close();
+ new File("derby.log").delete();
+ }
+
+ @Test
+ public void testModelValid() throws Exception {
+ final AxValidationResult result = testApexModel.testApexModelValid();
+ assertTrue(result.toString().equals(VALID_MODEL_STRING));
+ }
+
+ @Test
+ public void testApexModelVaidateObservation() throws Exception {
+ try {
+ testApexModel.testApexModelVaidateObservation();
+ } catch (final ApexException e) {
+ assertEquals("model should have observations", e.getMessage());
+ }
+ }
+
+ @Test
+ public void testApexModelVaidateWarning() throws Exception {
+ final AxValidationResult result = testApexModel.testApexModelVaidateWarning();
+ assertTrue(result.toString().equals(WARNING_MODEL_STRING));
+ }
+
+ @Test
+ public void testModelVaidateInvalidModel() throws Exception {
+ final AxValidationResult result = testApexModel.testApexModelVaidateInvalidModel();
+ assertTrue(result.toString().equals(INVALID_MODEL_STRING));
+ }
+
+ @Test
+ public void testModelVaidateMalstructured() throws Exception {
+ final AxValidationResult result = testApexModel.testApexModelVaidateMalstructured();
+ assertTrue(result.toString().equals(INVALID_MODEL_MALSTRUCTURED_STRING));
+ }
+
+ @Test
+ public void testModelWriteReadXML() throws Exception {
+ testApexModel.testApexModelWriteReadXML();
+ }
+
+ @Test
+ public void testModelWriteReadJSON() throws Exception {
+ testApexModel.testApexModelWriteReadJSON();
+ }
+
+ @Test
+ public void testModelWriteReadJPA() throws Exception {
+ final DAOParameters daoParameters = new DAOParameters();
+ daoParameters.setPluginClass("org.onap.policy.apex.model.basicmodel.dao.impl.DefaultApexDao");
+ daoParameters.setPersistenceUnit("DAOTest");
+
+ testApexModel.testApexModelWriteReadJPA(daoParameters);
+ }
+
+ // As there are no real concepts in a basic model, this is as near to a valid model as we can get
+ private static final String VALID_MODEL_STRING = "\n" + "***warnings issued during validation of model***\n"
+ + "AxArtifactKey:(name=FloatKIKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts.AxModel:WARNING:key not found for key information entry\n"
+ + "AxArtifactKey:(name=IntegerKIKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts.AxModel:WARNING:key not found for key information entry\n"
+ + "********************************";
+
+ private static final String WARNING_MODEL_STRING = "\n" + "***warnings issued during validation of model***\n"
+ + "AxArtifactKey:(name=FloatKIKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts.AxModel:WARNING:key not found for key information entry\n"
+ + "AxArtifactKey:(name=IntegerKIKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts.AxModel:WARNING:key not found for key information entry\n"
+ + "AxArtifactKey:(name=Unref0,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts.AxModel:WARNING:key not found for key information entry\n"
+ + "AxArtifactKey:(name=Unref1,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts.AxModel:WARNING:key not found for key information entry\n"
+ + "********************************";
+
+ private static final String INVALID_MODEL_STRING = "\n" + "***validation of model failed***\n"
+ + "AxArtifactKey:(name=BasicModelKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo:WARNING:UUID is a zero UUID: 00000000-0000-0000-0000-000000000000\n"
+ + "AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo:OBSERVATION:description is blank\n"
+ + "AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo:WARNING:UUID is a zero UUID: 00000000-0000-0000-0000-000000000000\n"
+ + "AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation:INVALID:duplicate UUID found on keyInfoMap entry AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1):00000000-0000-0000-0000-000000000000\n"
+ + "********************************";
+
+ private static final String INVALID_MODEL_MALSTRUCTURED_STRING = "\n" + "***validation of model failed***\n"
+ + "AxArtifactKey:(name=BasicModelKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo:WARNING:UUID is a zero UUID: 00000000-0000-0000-0000-000000000000\n"
+ + "AxArtifactKey:(name=BasicModelKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts.AxModel:INVALID:key information not found for key AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1)\n"
+ + "********************************";
+}
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexBasicModelConcepts.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestApexBasicModelConcepts.java
index 9d29c08f0..1ab7a2666 100644
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexBasicModelConcepts.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestApexBasicModelConcepts.java
@@ -1,24 +1,24 @@
-/*
+/*-
* ============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.apex.model.basicmodel.handling;
+package org.onap.policy.apex.model.basicmodel.handling;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -31,17 +31,17 @@ import java.util.Set;
import org.junit.Before;
import org.junit.Test;
-import org.onap.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.apex.model.basicmodel.concepts.AxKey;
-import org.onap.apex.model.basicmodel.concepts.AxKeyInfo;
-import org.onap.apex.model.basicmodel.concepts.AxKeyInformation;
-import org.onap.apex.model.basicmodel.concepts.AxKeyUse;
-import org.onap.apex.model.basicmodel.concepts.AxModel;
-import org.onap.apex.model.basicmodel.concepts.AxReferenceKey;
-import org.onap.apex.model.basicmodel.concepts.AxValidationResult;
-import org.onap.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
-import org.onap.apex.model.basicmodel.service.ModelService;
-import org.onap.apex.model.basicmodel.test.TestApexModel;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
+import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo;
+import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation;
+import org.onap.policy.apex.model.basicmodel.concepts.AxKeyUse;
+import org.onap.policy.apex.model.basicmodel.concepts.AxModel;
+import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
+import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
+import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
+import org.onap.policy.apex.model.basicmodel.service.ModelService;
+import org.onap.policy.apex.model.basicmodel.test.TestApexModel;
public class TestApexBasicModelConcepts {
TestApexModel<AxModel> testApexModel;
@@ -53,7 +53,7 @@ public class TestApexBasicModelConcepts {
@Test
public void testModelConcepts() {
- AxModel model = testApexModel.getModel();
+ final AxModel model = testApexModel.getModel();
assertNotNull(model);
model.clean();
assertNotNull(model);
@@ -65,7 +65,7 @@ public class TestApexBasicModelConcepts {
model.register();
assertEquals(model.getKeyInformation(), ModelService.getModel(AxKeyInformation.class));
- AxModel clonedModel = new AxModel(model);
+ final AxModel clonedModel = new AxModel(model);
assertTrue(clonedModel.toString().startsWith("AxModel:(key=AxArtifactKey:(name=BasicModel"));
assertFalse(model.hashCode() == 0);
@@ -91,8 +91,8 @@ public class TestApexBasicModelConcepts {
model.getKeyInformation().generateKeyInfo(model);
assertNotNull(model.getKeyInformation());
- AxKeyInformation keyI = model.getKeyInformation();
- AxKeyInformation clonedKeyI = new AxKeyInformation(keyI);
+ final AxKeyInformation keyI = model.getKeyInformation();
+ final AxKeyInformation clonedKeyI = new AxKeyInformation(keyI);
assertFalse(keyI.equals(null));
assertFalse(keyI.equals(new AxArtifactKey()));
@@ -177,7 +177,7 @@ public class TestApexBasicModelConcepts {
result = clonedKeyI.validate(result);
assertEquals(ValidationResult.VALID, result.getValidationResult());
- AxKeyInfo mk = clonedKeyI.get(new AxArtifactKey("BasicModel", "0.0.1"));
+ final AxKeyInfo mk = clonedKeyI.get(new AxArtifactKey("BasicModel", "0.0.1"));
assertNotNull(mk);
mk.setKey(AxArtifactKey.getNullKey());
result = new AxValidationResult();
@@ -189,7 +189,7 @@ public class TestApexBasicModelConcepts {
result = new AxValidationResult();
result = clonedKeyI.validate(result);
assertEquals(ValidationResult.VALID, result.getValidationResult());
-
+
clonedModel.setKey(AxArtifactKey.getNullKey());
result = new AxValidationResult();
result = clonedModel.validate(result);
@@ -200,14 +200,14 @@ public class TestApexBasicModelConcepts {
result = clonedKeyI.validate(result);
assertEquals(ValidationResult.VALID, result.getValidationResult());
}
-
+
@Test
public void testModelConceptsWithReferences() {
- AxModelWithReferences mwr = new TestApexBasicModelCreator().getModelWithReferences();
+ final AxModelWithReferences mwr = new TestApexBasicModelCreator().getModelWithReferences();
assertNotNull(mwr);
mwr.getKeyInformation().getKeyInfoMap().clear();
mwr.getKeyInformation().generateKeyInfo(mwr);
-
+
AxValidationResult result = new AxValidationResult();
result = mwr.validate(result);
assertEquals(ValidationResult.VALID, result.getValidationResult());
@@ -235,7 +235,7 @@ public class TestApexBasicModelConcepts {
assertEquals(ValidationResult.VALID, result.getValidationResult());
// Duplicate Reference Key
- AxReferenceKey rKey = new AxReferenceKey(mwr.getKey(), "LocalName");
+ final AxReferenceKey rKey = new AxReferenceKey(mwr.getKey(), "LocalName");
mwr.addKey(rKey);
mwr.addKey(rKey);
result = new AxValidationResult();
@@ -247,9 +247,9 @@ public class TestApexBasicModelConcepts {
result = new AxValidationResult();
result = mwr.validate(result);
assertEquals(ValidationResult.VALID, result.getValidationResult());
-
+
// Key Use is legal
- AxKeyUse keyU = new AxKeyUse(mwr.getKey());
+ final AxKeyUse keyU = new AxKeyUse(mwr.getKey());
mwr.addKey(keyU);
result = new AxValidationResult();
result = mwr.validate(result);
@@ -257,7 +257,7 @@ public class TestApexBasicModelConcepts {
mwr.removeKey(keyU);
// Key Use on bad artifact key
- AxKeyUse keyBU = new AxKeyUse(new AxArtifactKey("SomeKey", "0.0.1"));
+ final AxKeyUse keyBU = new AxKeyUse(new AxArtifactKey("SomeKey", "0.0.1"));
mwr.addKey(keyBU);
result = new AxValidationResult();
result = mwr.validate(result);
@@ -265,7 +265,7 @@ public class TestApexBasicModelConcepts {
mwr.removeKey(keyBU);
// Key Use on bad reference key
- AxKeyUse keyBRU = new AxKeyUse(new AxReferenceKey("SomeKey", "0.0.1", "Local"));
+ final AxKeyUse keyBRU = new AxKeyUse(new AxReferenceKey("SomeKey", "0.0.1", "Local"));
mwr.addKey(keyBRU);
result = new AxValidationResult();
result = mwr.validate(result);
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexBasicModelCreator.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestApexBasicModelCreator.java
index fca6c4425..762c7555f 100644
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexBasicModelCreator.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestApexBasicModelCreator.java
@@ -18,15 +18,15 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.apex.model.basicmodel.handling;
+package org.onap.policy.apex.model.basicmodel.handling;
import java.util.UUID;
-import org.onap.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.apex.model.basicmodel.concepts.AxKeyInfo;
-import org.onap.apex.model.basicmodel.concepts.AxKeyInformation;
-import org.onap.apex.model.basicmodel.concepts.AxModel;
-import org.onap.apex.model.basicmodel.test.TestApexModelCreator;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo;
+import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation;
+import org.onap.policy.apex.model.basicmodel.concepts.AxModel;
+import org.onap.policy.apex.model.basicmodel.test.TestApexModelCreator;
public class TestApexBasicModelCreator implements TestApexModelCreator<AxModel> {
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexTestModelCreator0.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestApexTestModelCreator0.java
index 4b3c00226..ff958373e 100644
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexTestModelCreator0.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestApexTestModelCreator0.java
@@ -18,13 +18,13 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.apex.model.basicmodel.handling;
+package org.onap.policy.apex.model.basicmodel.handling;
-import org.onap.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.apex.model.basicmodel.concepts.AxKeyInfo;
-import org.onap.apex.model.basicmodel.concepts.AxKeyInformation;
-import org.onap.apex.model.basicmodel.concepts.AxModel;
-import org.onap.apex.model.basicmodel.test.TestApexModelCreator;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo;
+import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation;
+import org.onap.policy.apex.model.basicmodel.concepts.AxModel;
+import org.onap.policy.apex.model.basicmodel.test.TestApexModelCreator;
public class TestApexTestModelCreator0 implements TestApexModelCreator<AxModel> {
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexTestModelCreator1.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestApexTestModelCreator1.java
index e208bd850..d2aa738a0 100644
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexTestModelCreator1.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestApexTestModelCreator1.java
@@ -18,15 +18,15 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.apex.model.basicmodel.handling;
+package org.onap.policy.apex.model.basicmodel.handling;
import java.util.UUID;
-import org.onap.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.apex.model.basicmodel.concepts.AxKeyInfo;
-import org.onap.apex.model.basicmodel.concepts.AxKeyInformation;
-import org.onap.apex.model.basicmodel.concepts.AxModel;
-import org.onap.apex.model.basicmodel.test.TestApexModelCreator;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo;
+import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation;
+import org.onap.policy.apex.model.basicmodel.concepts.AxModel;
+import org.onap.policy.apex.model.basicmodel.test.TestApexModelCreator;
public class TestApexTestModelCreator1 implements TestApexModelCreator<AxModel> {
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexTestModelCreator2.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestApexTestModelCreator2.java
index 9b9eb13ac..85751bf12 100644
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexTestModelCreator2.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestApexTestModelCreator2.java
@@ -18,13 +18,13 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.apex.model.basicmodel.handling;
+package org.onap.policy.apex.model.basicmodel.handling;
-import org.onap.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.apex.model.basicmodel.concepts.AxKeyInfo;
-import org.onap.apex.model.basicmodel.concepts.AxKeyInformation;
-import org.onap.apex.model.basicmodel.concepts.AxModel;
-import org.onap.apex.model.basicmodel.test.TestApexModelCreator;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo;
+import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation;
+import org.onap.policy.apex.model.basicmodel.concepts.AxModel;
+import org.onap.policy.apex.model.basicmodel.test.TestApexModelCreator;
public class TestApexTestModelCreator2 implements TestApexModelCreator<AxModel> {
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestBasicModelTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestBasicModelTest.java
index ea5433f08..9ddd3cc7e 100644
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestBasicModelTest.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestBasicModelTest.java
@@ -1,33 +1,33 @@
-/*
+/*-
* ============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.apex.model.basicmodel.handling;
+package org.onap.policy.apex.model.basicmodel.handling;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.junit.Test;
-import org.onap.apex.model.basicmodel.concepts.ApexException;
-import org.onap.apex.model.basicmodel.concepts.AxModel;
-import org.onap.apex.model.basicmodel.test.TestApexModel;
+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.test.TestApexModel;
/**
* @author Liam Fallon (liam.fallon@ericsson.com)
@@ -36,14 +36,14 @@ public class TestBasicModelTest {
@Test
public void testNormalModelCreator() throws ApexException {
- TestApexModel<AxModel> testApexModel = new TestApexModel<AxModel>(AxModel.class, new TestApexBasicModelCreator());
+ final TestApexModel<AxModel> testApexModel =
+ new TestApexModel<AxModel>(AxModel.class, new TestApexBasicModelCreator());
testApexModel.testApexModelValid();
try {
testApexModel.testApexModelVaidateObservation();
fail("Test should throw an exception");
- }
- catch (Exception e) {
+ } catch (final Exception e) {
assertEquals("model should have observations", e.getMessage());
}
testApexModel.testApexModelVaidateWarning();
@@ -56,100 +56,94 @@ public class TestBasicModelTest {
@Test
public void testModelCreator0() throws ApexException {
- TestApexModel<AxModel> testApexModel = new TestApexModel<AxModel>(AxModel.class, new TestApexTestModelCreator0());
+ final TestApexModel<AxModel> testApexModel =
+ new TestApexModel<AxModel>(AxModel.class, new TestApexTestModelCreator0());
testApexModel.testApexModelValid();
try {
testApexModel.testApexModelVaidateObservation();
fail("Test should throw an exception");
- }
- catch (Exception e) {
+ } catch (final Exception e) {
assertEquals("model should have observations", e.getMessage());
}
try {
testApexModel.testApexModelVaidateWarning();
fail("Test should throw an exception");
- }
- catch (Exception e) {
+ } catch (final Exception e) {
assertEquals("model should have warnings", e.getMessage());
}
try {
testApexModel.testApexModelVaidateInvalidModel();
fail("Test should throw an exception");
- }
- catch (Exception e) {
+ } catch (final Exception e) {
assertEquals("should not be valid ***validation of model successful***", e.getMessage());
}
try {
testApexModel.testApexModelVaidateMalstructured();
fail("Test should throw an exception");
- }
- catch (Exception e) {
+ } catch (final Exception e) {
assertEquals("should not be valid ***validation of model successful***", e.getMessage());
}
}
@Test
public void testModelCreator1() throws ApexException {
- TestApexModel<AxModel> testApexModel = new TestApexModel<AxModel>(AxModel.class, new TestApexTestModelCreator1());
+ final TestApexModel<AxModel> testApexModel =
+ new TestApexModel<AxModel>(AxModel.class, new TestApexTestModelCreator1());
try {
testApexModel.testApexModelValid();
fail("Test should throw an exception");
- }
- catch (Exception e) {
+ } catch (final Exception e) {
assertTrue(e.getMessage().startsWith("model is invalid"));
}
try {
testApexModel.testApexModelVaidateObservation();
fail("Test should throw an exception");
- }
- catch (Exception e) {
+ } catch (final Exception e) {
assertTrue(e.getMessage().startsWith("model is invalid"));
}
try {
testApexModel.testApexModelVaidateWarning();
fail("Test should throw an exception");
- }
- catch (Exception e) {
+ } catch (final Exception e) {
assertTrue(e.getMessage().startsWith("model is invalid"));
}
testApexModel.testApexModelVaidateInvalidModel();
testApexModel.testApexModelVaidateMalstructured();
}
-
+
@Test
public void testModelCreator2() throws ApexException {
- TestApexModel<AxModel> testApexModel = new TestApexModel<AxModel>(AxModel.class, new TestApexTestModelCreator2());
+ final TestApexModel<AxModel> testApexModel =
+ new TestApexModel<AxModel>(AxModel.class, new TestApexTestModelCreator2());
testApexModel.testApexModelValid();
testApexModel.testApexModelVaidateObservation();
try {
testApexModel.testApexModelVaidateWarning();
fail("Test should throw an exception");
- }
- catch (Exception e) {
+ } catch (final Exception e) {
assertEquals("model should have warnings", e.getMessage());
}
}
-
+
@Test
public void testModelCreator1XMLJSON() throws ApexException {
- TestApexModel<AxModel> testApexModel = new TestApexModel<AxModel>(AxModel.class, new TestApexTestModelCreator1());
+ final TestApexModel<AxModel> testApexModel =
+ new TestApexModel<AxModel>(AxModel.class, new TestApexTestModelCreator1());
try {
testApexModel.testApexModelWriteReadJSON();
fail("Test should throw an exception");
- }
- catch (Exception e) {
+ } catch (final Exception e) {
assertTrue(e.getMessage().startsWith("error processing file"));
}
try {
testApexModel.testApexModelWriteReadXML();
fail("Test should throw an exception");
- }
- catch (Exception e) {
+ } catch (final Exception e) {
assertTrue(e.getMessage().startsWith("error processing file"));
}
}
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestConceptGetter.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestConceptGetter.java
index a6ff9dc0b..83545bf06 100644
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestConceptGetter.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestConceptGetter.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.apex.model.basicmodel.handling;
+package org.onap.policy.apex.model.basicmodel.handling;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
@@ -30,12 +30,12 @@ import java.io.IOException;
import java.util.UUID;
import org.junit.Test;
-import org.onap.apex.model.basicmodel.concepts.ApexException;
-import org.onap.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.apex.model.basicmodel.concepts.AxKeyInfo;
-import org.onap.apex.model.basicmodel.concepts.AxModel;
-import org.onap.apex.model.basicmodel.handling.ApexModelFileWriter;
-import org.onap.apex.model.basicmodel.handling.ApexModelReader;
+import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
+import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo;
+import org.onap.policy.apex.model.basicmodel.concepts.AxModel;
+import org.onap.policy.apex.model.basicmodel.handling.ApexModelFileWriter;
+import org.onap.policy.apex.model.basicmodel.handling.ApexModelReader;
/**
* @author Liam Fallon (liam.fallon@ericsson.com)
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestExceptions.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestExceptions.java
index 0dd271f98..5c8922793 100644
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestExceptions.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestExceptions.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.apex.model.basicmodel.handling;
+package org.onap.policy.apex.model.basicmodel.handling;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -26,7 +26,7 @@ import static org.junit.Assert.assertNotNull;
import java.io.IOException;
import org.junit.Test;
-import org.onap.apex.model.basicmodel.handling.ApexModelException;
+import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
/**
* @author Liam Fallon (liam.fallon@ericsson.com)
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelFileWriter.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestModelFileWriter.java
index c2116a1d2..ec4d0a5a9 100644
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelFileWriter.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestModelFileWriter.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.apex.model.basicmodel.handling;
+package org.onap.policy.apex.model.basicmodel.handling;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -27,9 +27,9 @@ import java.io.File;
import java.io.IOException;
import org.junit.Test;
-import org.onap.apex.model.basicmodel.concepts.ApexException;
-import org.onap.apex.model.basicmodel.concepts.AxModel;
-import org.onap.apex.model.basicmodel.handling.ApexModelFileWriter;
+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.handling.ApexModelFileWriter;
/**
* @author Liam Fallon (liam.fallon@ericsson.com)
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelReader.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestModelReader.java
index 134f6ff89..140817e00 100644
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelReader.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestModelReader.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.apex.model.basicmodel.handling;
+package org.onap.policy.apex.model.basicmodel.handling;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -34,10 +34,10 @@ import java.io.FileReader;
import java.io.IOException;
import org.junit.Test;
-import org.onap.apex.model.basicmodel.concepts.ApexException;
-import org.onap.apex.model.basicmodel.concepts.AxModel;
-import org.onap.apex.model.basicmodel.handling.ApexModelReader;
-import org.onap.apex.model.basicmodel.handling.ApexModelWriter;
+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.handling.ApexModelReader;
+import org.onap.policy.apex.model.basicmodel.handling.ApexModelWriter;
/**
* @author Liam Fallon (liam.fallon@ericsson.com)
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelSaver.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestModelSaver.java
index 182d341aa..08f123cba 100644
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelSaver.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestModelSaver.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.apex.model.basicmodel.handling;
+package org.onap.policy.apex.model.basicmodel.handling;
import java.io.File;
import java.io.IOException;
@@ -26,9 +26,9 @@ import java.nio.file.Files;
import java.nio.file.Path;
import org.junit.Test;
-import org.onap.apex.model.basicmodel.concepts.ApexException;
-import org.onap.apex.model.basicmodel.concepts.AxModel;
-import org.onap.apex.model.basicmodel.handling.ApexModelSaver;
+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.handling.ApexModelSaver;
/**
* @author Liam Fallon (liam.fallon@ericsson.com)
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelStringWriter.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestModelStringWriter.java
index 2f4fcd2c7..d2a504676 100644
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelStringWriter.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestModelStringWriter.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.apex.model.basicmodel.handling;
+package org.onap.policy.apex.model.basicmodel.handling;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -28,10 +28,10 @@ import static org.junit.Assert.fail;
import java.io.IOException;
import org.junit.Test;
-import org.onap.apex.model.basicmodel.concepts.ApexException;
-import org.onap.apex.model.basicmodel.concepts.AxKeyInfo;
-import org.onap.apex.model.basicmodel.concepts.AxModel;
-import org.onap.apex.model.basicmodel.handling.ApexModelStringWriter;
+import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
+import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo;
+import org.onap.policy.apex.model.basicmodel.concepts.AxModel;
+import org.onap.policy.apex.model.basicmodel.handling.ApexModelStringWriter;
/**
* @author Liam Fallon (liam.fallon@ericsson.com)
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelWriter.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestModelWriter.java
index a21c148b6..8e5af45b3 100644
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelWriter.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestModelWriter.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.apex.model.basicmodel.handling;
+package org.onap.policy.apex.model.basicmodel.handling;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -29,9 +29,9 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import org.junit.Test;
-import org.onap.apex.model.basicmodel.concepts.ApexException;
-import org.onap.apex.model.basicmodel.concepts.AxModel;
-import org.onap.apex.model.basicmodel.handling.ApexModelWriter;
+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.handling.ApexModelWriter;
/**
* @author Liam Fallon (liam.fallon@ericsson.com)
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestSchemaGenerator.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestSchemaGenerator.java
index 2e10b51b6..cdf3b4615 100644
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestSchemaGenerator.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestSchemaGenerator.java
@@ -1,24 +1,24 @@
-/*
+/*-
* ============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.apex.model.basicmodel.handling;
+package org.onap.policy.apex.model.basicmodel.handling;
import static org.junit.Assert.assertTrue;
@@ -30,7 +30,6 @@ import java.io.IOException;
import java.io.PrintStream;
import org.junit.Test;
-import org.onap.apex.model.basicmodel.handling.ApexSchemaGenerator;
/**
* @author Liam Fallon (liam.fallon@ericsson.com)
@@ -41,50 +40,51 @@ public class TestSchemaGenerator {
public void test() throws IOException {
final ByteArrayOutputStream baos0 = new ByteArrayOutputStream();
System.setOut(new PrintStream(baos0));
-
+
final String[] args0 = {};
ApexSchemaGenerator.main(args0);
assertTrue(baos0.toString().contains("usage: ApexSchemaGenerator apex-root-class [schema-file-name]"));
System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out)));
-
+
final ByteArrayOutputStream baos1 = new ByteArrayOutputStream();
System.setOut(new PrintStream(baos1));
-
- final String[] args1 = {"hello", "goodbye", "here"};
+
+ final String[] args1 = { "hello", "goodbye", "here" };
ApexSchemaGenerator.main(args1);
assertTrue(baos1.toString().contains("usage: ApexSchemaGenerator apex-root-class [schema-file-name]"));
System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out)));
-
+
final ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
System.setOut(new PrintStream(baos2));
-
- final String[] args2 = {"hello", "goodbye"};
+
+ final String[] args2 = { "hello", "goodbye" };
ApexSchemaGenerator.main(args2);
assertTrue(baos2.toString().contains("error on Apex schema output"));
System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out)));
-
+
final ByteArrayOutputStream baos3 = new ByteArrayOutputStream();
System.setOut(new PrintStream(baos3));
-
- final String[] args3 = {"hello"};
+
+ final String[] args3 = { "hello" };
ApexSchemaGenerator.main(args3);
assertTrue(baos3.toString().contains("could not create JAXB context, root class hello not found"));
System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out)));
-
+
final ByteArrayOutputStream baos4 = new ByteArrayOutputStream();
System.setOut(new PrintStream(baos4));
-
- final String[] args4 = {"org.onap.apex.model.basicmodel.concepts.AxModel"};
+
+ final String[] args4 = { "org.onap.policy.apex.model.basicmodel.concepts.AxModel" };
ApexSchemaGenerator.main(args4);
- assertTrue(baos4.toString().contains("targetNamespace=\"http://www.ericsson.com/apex\""));
+ assertTrue(baos4.toString().contains("targetNamespace=\"http://www.onap.org/policy/apex-pdp\""));
System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out)));
-
+
final ByteArrayOutputStream baos5 = new ByteArrayOutputStream();
System.setOut(new PrintStream(baos5));
-
+
final File tempFile = File.createTempFile("ApexSchemaGeneratorTest", "xsd");
- final String[] args5 = {"org.onap.apex.model.basicmodel.concepts.AxModel", tempFile.getCanonicalPath()};
-
+ final String[] args5 =
+ { "org.onap.policy.apex.model.basicmodel.concepts.AxModel", tempFile.getCanonicalPath() };
+
ApexSchemaGenerator.main(args5);
assertTrue(tempFile.length() > 100);
System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out)));
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/IllegalParameters.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/IllegalParameters.java
index 3cb4808bf..3a7fdf530 100644
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/IllegalParameters.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/IllegalParameters.java
@@ -18,9 +18,9 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.apex.model.basicmodel.service;
+package org.onap.policy.apex.model.basicmodel.service;
-import org.onap.apex.model.basicmodel.service.AbstractParameters;
+import org.onap.policy.apex.model.basicmodel.service.AbstractParameters;
/**
* @author Liam Fallon (liam.fallon@ericsson.com)
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/LegalParameters.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/LegalParameters.java
index 2bab6fd2a..3de3ecb58 100644
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/LegalParameters.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/LegalParameters.java
@@ -18,9 +18,9 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.apex.model.basicmodel.service;
+package org.onap.policy.apex.model.basicmodel.service;
-import org.onap.apex.model.basicmodel.service.AbstractParameters;
+import org.onap.policy.apex.model.basicmodel.service.AbstractParameters;
/**
* @author Liam Fallon (liam.fallon@ericsson.com)
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/TestAbstractParameters.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/TestAbstractParameters.java
index e9a0e2f0a..7afa14440 100644
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/TestAbstractParameters.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/TestAbstractParameters.java
@@ -1,24 +1,24 @@
-/*
+/*-
* ============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.apex.model.basicmodel.service;
+package org.onap.policy.apex.model.basicmodel.service;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -35,17 +35,21 @@ public class TestAbstractParameters {
public void testAbstractParameters() {
final LegalParameters parameters = new LegalParameters();
assertNotNull(parameters);
- assertEquals("AbstractParameters [parameterClassName=org.onap.apex.model.basicmodel.service.LegalParameters]", parameters.toString());
+ assertEquals(
+ "AbstractParameters [parameterClassName=org.onap.policy.apex.model.basicmodel.service.LegalParameters]",
+ parameters.toString());
assertEquals(LegalParameters.class, parameters.getParameterClass());
- assertEquals("org.onap.apex.model.basicmodel.service.LegalParameters", parameters.getParameterClassName());
-
+ assertEquals("org.onap.policy.apex.model.basicmodel.service.LegalParameters",
+ parameters.getParameterClassName());
+
try {
new IllegalParameters();
fail("test should throw an exception here");
- }
- catch (final Exception e) {
- assertEquals("class \"somewhere.over.the.rainbow\" not found or not an instance of \"org.onap.apex.model.basicmodel.service.IllegalParameters\"", e.getMessage());
+ } catch (final Exception e) {
+ assertEquals(
+ "class \"somewhere.over.the.rainbow\" not found or not an instance of \"org.onap.policy.apex.model.basicmodel.service.IllegalParameters\"",
+ e.getMessage());
}
}
}
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/TestModelService.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/TestModelService.java
index 51af9baaf..9c20d837f 100644
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/TestModelService.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/TestModelService.java
@@ -1,24 +1,24 @@
-/*
+/*-
* ============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.apex.model.basicmodel.service;
+package org.onap.policy.apex.model.basicmodel.service;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -26,9 +26,8 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
-import org.onap.apex.model.basicmodel.concepts.AxKeyInformation;
-import org.onap.apex.model.basicmodel.handling.TestApexBasicModelCreator;
-import org.onap.apex.model.basicmodel.service.ModelService;
+import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation;
+import org.onap.policy.apex.model.basicmodel.handling.TestApexBasicModelCreator;
/**
* @author Liam Fallon (liam.fallon@ericsson.com)
@@ -42,36 +41,41 @@ public class TestModelService {
assertFalse(ModelService.existsModel(AxKeyInformation.class));
try {
ModelService.getModel(AxKeyInformation.class);
+ } catch (final Exception e) {
+ assertEquals(
+ "Model for org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation not found in model service",
+ e.getMessage());
}
- catch (Exception e) {
- assertEquals("Model for org.onap.apex.model.basicmodel.concepts.AxKeyInformation not found in model service", e.getMessage());
- }
-
- ModelService.registerModel(AxKeyInformation.class, new TestApexBasicModelCreator().getModel().getKeyInformation());
+
+ ModelService.registerModel(AxKeyInformation.class,
+ new TestApexBasicModelCreator().getModel().getKeyInformation());
assertTrue(ModelService.existsModel(AxKeyInformation.class));
assertNotNull(ModelService.getModel(AxKeyInformation.class));
-
+
ModelService.deregisterModel(AxKeyInformation.class);
-
+
assertFalse(ModelService.existsModel(AxKeyInformation.class));
try {
ModelService.getModel(AxKeyInformation.class);
- }
- catch (Exception e) {
- assertEquals("Model for org.onap.apex.model.basicmodel.concepts.AxKeyInformation not found in model service", e.getMessage());
+ } catch (final Exception e) {
+ assertEquals(
+ "Model for org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation not found in model service",
+ e.getMessage());
}
- ModelService.registerModel(AxKeyInformation.class, new TestApexBasicModelCreator().getModel().getKeyInformation());
+ ModelService.registerModel(AxKeyInformation.class,
+ new TestApexBasicModelCreator().getModel().getKeyInformation());
assertTrue(ModelService.existsModel(AxKeyInformation.class));
assertNotNull(ModelService.getModel(AxKeyInformation.class));
-
+
ModelService.clear();
assertFalse(ModelService.existsModel(AxKeyInformation.class));
try {
ModelService.getModel(AxKeyInformation.class);
- }
- catch (Exception e) {
- assertEquals("Model for org.onap.apex.model.basicmodel.concepts.AxKeyInformation not found in model service", e.getMessage());
+ } catch (final Exception e) {
+ assertEquals(
+ "Model for org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation not found in model service",
+ e.getMessage());
}
}
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/TestParameterService.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/TestParameterService.java
index ff2a9c876..e84b3e252 100644
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/TestParameterService.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/TestParameterService.java
@@ -1,24 +1,24 @@
-/*
+/*-
* ============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.apex.model.basicmodel.service;
+package org.onap.policy.apex.model.basicmodel.service;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -26,7 +26,6 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
-import org.onap.apex.model.basicmodel.service.ParameterService;
/**
* @author Liam Fallon (liam.fallon@ericsson.com)
@@ -40,38 +39,41 @@ public class TestParameterService {
assertFalse(ParameterService.existsParameters(LegalParameters.class));
try {
ParameterService.getParameters(LegalParameters.class);
+ } catch (final Exception e) {
+ assertEquals(
+ "Parameters for org.onap.policy.apex.model.basicmodel.service.LegalParameters not found in parameter service",
+ e.getMessage());
}
- catch (final Exception e) {
- assertEquals("Parameters for org.onap.apex.model.basicmodel.service.LegalParameters not found in parameter service", e.getMessage());
- }
-
+
ParameterService.registerParameters(LegalParameters.class, new LegalParameters());
assertTrue(ParameterService.existsParameters(LegalParameters.class));
assertNotNull(ParameterService.getParameters(LegalParameters.class));
-
+
ParameterService.deregisterParameters(LegalParameters.class);
-
+
assertFalse(ParameterService.existsParameters(LegalParameters.class));
try {
ParameterService.getParameters(LegalParameters.class);
- }
- catch (final Exception e) {
- assertEquals("Parameters for org.onap.apex.model.basicmodel.service.LegalParameters not found in parameter service", e.getMessage());
+ } catch (final Exception e) {
+ assertEquals(
+ "Parameters for org.onap.policy.apex.model.basicmodel.service.LegalParameters not found in parameter service",
+ e.getMessage());
}
ParameterService.registerParameters(LegalParameters.class, new LegalParameters());
assertTrue(ParameterService.existsParameters(LegalParameters.class));
assertNotNull(ParameterService.getParameters(LegalParameters.class));
-
+
assertNotNull(ParameterService.getAll());
ParameterService.clear();
assertFalse(ParameterService.existsParameters(LegalParameters.class));
try {
ParameterService.getParameters(LegalParameters.class);
+ } catch (final Exception e) {
+ assertEquals(
+ "Parameters for org.onap.policy.apex.model.basicmodel.service.LegalParameters not found in parameter service",
+ e.getMessage());
}
- catch (final Exception e) {
- assertEquals("Parameters for org.onap.apex.model.basicmodel.service.LegalParameters not found in parameter service", e.getMessage());
- }
-
+
}
}
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/xml/TestAxReferenceKeyAdapter.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/xml/TestAxReferenceKeyAdapter.java
index b723439b5..bde0956b8 100644
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/xml/TestAxReferenceKeyAdapter.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/xml/TestAxReferenceKeyAdapter.java
@@ -18,14 +18,14 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.apex.model.basicmodel.xml;
+package org.onap.policy.apex.model.basicmodel.xml;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import org.junit.Test;
-import org.onap.apex.model.basicmodel.concepts.AxReferenceKey;
-import org.onap.apex.model.basicmodel.xml.AxReferenceKeyAdapter;
+import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
+import org.onap.policy.apex.model.basicmodel.xml.AxReferenceKeyAdapter;
/**
* @author Liam Fallon (liam.fallon@ericsson.com)
diff --git a/model/basic-model/src/test/resources/META-INF/persistence.xml b/model/basic-model/src/test/resources/META-INF/persistence.xml
index 5d02906fc..a7bf1f6ac 100644
--- a/model/basic-model/src/test/resources/META-INF/persistence.xml
+++ b/model/basic-model/src/test/resources/META-INF/persistence.xml
@@ -23,14 +23,14 @@
<persistence-unit name="DAOTest" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
- <class>org.onap.apex.model.basicmodel.dao.converters.CDATAConditioner</class>
- <class>org.onap.apex.model.basicmodel.dao.converters.UUID2String</class>
- <class>org.onap.apex.model.basicmodel.concepts.AxArtifactKey</class>
- <class>org.onap.apex.model.basicmodel.concepts.AxReferenceKey</class>
- <class>org.onap.apex.model.basicmodel.concepts.AxKeyInfo</class>
- <class>org.onap.apex.model.basicmodel.concepts.AxKeyInformation</class>
- <class>org.onap.apex.model.basicmodel.concepts.AxModel</class>
- <class>org.onap.apex.model.basicmodel.concepts.TestEntity</class>
+ <class>org.onap.policy.apex.model.basicmodel.dao.converters.CDATAConditioner</class>
+ <class>org.onap.policy.apex.model.basicmodel.dao.converters.UUID2String</class>
+ <class>org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey</class>
+ <class>org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey</class>
+ <class>org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo</class>
+ <class>org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation</class>
+ <class>org.onap.policy.apex.model.basicmodel.concepts.AxModel</class>
+ <class>org.onap.policy.apex.model.basicmodel.concepts.TestEntity</class>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:derby:memory:apex_test" />
diff --git a/model/basic-model/src/test/resources/logback-test.xml b/model/basic-model/src/test/resources/logback-test.xml
index d9d77f797..4ece82083 100644
--- a/model/basic-model/src/test/resources/logback-test.xml
+++ b/model/basic-model/src/test/resources/logback-test.xml
@@ -44,8 +44,7 @@
<appender-ref ref="STDOUT" />
</logger>
- <appender name="FILE"
- class="ch.qos.logback.core.FileAppender">
+ <appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>${LOG_DIR}/apex.log</file>
<encoder>
<pattern>%d %-5relative [procId=${processId}] [%thread] %-5level
@@ -53,8 +52,7 @@
</encoder>
</appender>
- <appender name="CTXT_FILE"
- class="ch.qos.logback.core.FileAppender">
+ <appender name="CTXT_FILE" class="ch.qos.logback.core.FileAppender">
<file>${LOG_DIR}/apex_ctxt.log</file>
<encoder>
<pattern>%d %-5relative [procId=${processId}] [%thread] %-5level
@@ -62,11 +60,11 @@
</encoder>
</appender>
- <logger name="com.ericsson.apex.core.context.impl.monitoring" level="TRACE" additivity="false">
+ <logger name="org.onap.policy.apex.core.context.impl.monitoring" level="TRACE" additivity="false">
<appender-ref ref="CTXT_FILE" />
</logger>
- <logger name="com.ericsson.apex.core.context" level="INFO" additivity="false">
+ <logger name="org.onap.policy.apex.core.context" level="INFO" additivity="false">
<appender-ref ref="STDOUT" />
</logger>
</configuration>