aboutsummaryrefslogtreecommitdiffstats
path: root/model
diff options
context:
space:
mode:
Diffstat (limited to 'model')
-rw-r--r--model/basic-model/pom.xml39
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxArtifactKey.java14
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConcept.java12
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfo.java17
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInformation.java37
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxModel.java19
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxReferenceKey.java134
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/package-info.java9
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelCustomGsonMapAdapter.java118
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelCustomGsonRefereceKeyAdapter.java50
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelFileWriter.java58
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelReader.java157
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelSaver.java21
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelStringWriter.java71
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelWriter.java216
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexSchemaGenerator.java161
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/KeyInfoMarshalFilter.java104
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/package-info.java17
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/package-info.java4
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/test/TestApexModel.java54
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/xml/AxReferenceKeyAdapter.java58
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/xml/package-info.java34
-rw-r--r--model/basic-model/src/main/resources/xml/example.xsd100
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/DummyEntity.java6
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelFileWriterTest.java34
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelReaderTest.java77
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelSaverTest.java8
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelStringWriterTest.java29
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelWriterTest.java108
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexSchemaGeneratorTest.java95
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTest.java5
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportBasicModelTest.java8
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportConceptGetterTest.java24
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/xml/AxReferenceKeyAdapterTest.java42
-rw-r--r--model/context-model/pom.xml27
-rw-r--r--model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbum.java15
-rw-r--r--model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbums.java39
-rw-r--r--model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextModel.java14
-rw-r--r--model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchema.java15
-rw-r--r--model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchemas.java62
-rw-r--r--model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/ApexContextModelTest.java5
-rw-r--r--model/context-model/src/test/resources/json/ContextModel.json156
-rw-r--r--model/engine-model/pom.xml29
-rw-r--r--model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/AxEngineModel.java13
-rw-r--r--model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/AxEngineState.java9
-rw-r--r--model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/AxEngineStats.java22
-rw-r--r--model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/package-info.java16
-rw-r--r--model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/handling/ApexEngineModelTest.java5
-rw-r--r--model/event-model/pom.xml27
-rw-r--r--model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEvent.java32
-rw-r--r--model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEventModel.java13
-rw-r--r--model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEvents.java35
-rw-r--r--model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxField.java18
-rw-r--r--model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxInputField.java8
-rw-r--r--model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxOutputField.java8
-rw-r--r--model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/package-info.java9
-rw-r--r--model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventsTest.java58
-rw-r--r--model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/handling/ApexEventModelTest.java5
-rw-r--r--model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexApiResult.java17
-rw-r--r--model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexModel.java6
-rw-r--r--model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexModelFactory.java13
-rw-r--r--model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ApexModelImpl.java55
-rw-r--r--model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ContextAlbumFacade.java62
-rw-r--r--model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ContextSchemaFacade.java47
-rw-r--r--model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/EventFacade.java78
-rw-r--r--model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/KeyInformationFacade.java34
-rw-r--r--model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ModelFacade.java29
-rw-r--r--model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ModelHandlerFacade.java34
-rw-r--r--model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/PolicyFacade.java353
-rw-r--r--model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/TaskFacade.java126
-rw-r--r--model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiContextAlbumTest.java26
-rw-r--r--model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiContextSchemaTest.java4
-rw-r--r--model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiEventTest.java29
-rw-r--r--model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiKeyInfoTest.java4
-rw-r--r--model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiPolicyTest.java179
-rw-r--r--model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiTaskTest.java19
-rw-r--r--model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexModelApiTest.java51
-rw-r--r--model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ModelFacadeTest.java11
-rw-r--r--model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ModelHandlerFacadeTest.java10
-rw-r--r--model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/RealModelTest.java46
-rw-r--r--model/model-api/src/test/resources/models/PolicyModel.json1465
-rw-r--r--model/model-api/src/test/resources/models/PolicyModel.xml697
-rw-r--r--model/model-api/src/test/resources/models/RealPolicyModel.json3076
-rw-r--r--model/policy-model/pom.xml27
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxLogic.java19
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicies.java60
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicy.java120
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicyModel.java100
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxState.java54
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateFinalizerLogic.java8
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateOutput.java16
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateTaskOutputType.java14
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateTaskReference.java16
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTask.java41
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTaskLogic.java8
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTaskParameter.java14
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTaskSelectionLogic.java8
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTasks.java53
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/package-info.java17
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/handling/EmptyAlbumsAdapter.java91
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PoliciesTest.java13
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateTest.java10
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TasksTest.java11
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java5
104 files changed, 5110 insertions, 4646 deletions
diff --git a/model/basic-model/pom.xml b/model/basic-model/pom.xml
index 4d7930298..45d9978cf 100644
--- a/model/basic-model/pom.xml
+++ b/model/basic-model/pom.xml
@@ -18,10 +18,7 @@
============LICENSE_END=========================================================
-->
-<project
- xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
@@ -45,6 +42,12 @@
<dependency>
<groupId>org.onap.policy.common</groupId>
<artifactId>utils</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.onap.policy.apex-pdp.model</groupId>
@@ -77,30 +80,4 @@
<scope>test</scope>
</dependency>
</dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>generate-xml-schema</id>
- <phase>process-classes</phase>
- <goals>
- <goal>java</goal>
- </goals>
- <configuration>
- <mainClass>org.onap.policy.apex.model.basicmodel.handling.ApexSchemaGenerator</mainClass>
- <classpathScope>compile</classpathScope>
- <arguments>
- <argument>org.onap.policy.apex.model.basicmodel.concepts.AxModel</argument>
- <argument>${project.build.directory}/model/xml/apex-basic-model.xsd</argument>
- </arguments>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
+</project> \ No newline at end of file
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
index f5d421956..1efe83db8 100644
--- 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
@@ -23,11 +23,6 @@ package org.onap.policy.apex.model.basicmodel.concepts;
import java.util.ArrayList;
import java.util.List;
-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.common.utils.validation.Assertions;
@@ -39,22 +34,13 @@ import org.onap.policy.common.utils.validation.Assertions;
* <p>Key validation checks that the name and version fields match the NAME_REGEXP and VERSION_REGEXP
* regular expressions respectively.
*/
-@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";
- @XmlElement(required = true)
private String name;
-
- @XmlElement(required = true)
private String version;
/**
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConcept.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConcept.java
index 0e2c6bef2..37fe30b33 100644
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConcept.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConcept.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019,2022 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -24,7 +24,6 @@ package org.onap.policy.apex.model.basicmodel.concepts;
import java.io.Serializable;
import java.util.List;
-import javax.xml.bind.annotation.XmlType;
import org.onap.policy.common.utils.validation.Assertions;
/**
@@ -33,9 +32,6 @@ import org.onap.policy.common.utils.validation.Assertions;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-
-@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;
@@ -86,6 +82,12 @@ public abstract class AxConcept implements Serializable, Comparable<AxConcept> {
public abstract void clean();
/**
+ * Builds references used by a concept.
+ */
+ public void buildReferences() {
+ }
+
+ /**
* {@inheritDoc}.
*/
@Override
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfo.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfo.java
index 9b96d3398..bd3b18ec9 100644
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfo.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfo.java
@@ -22,14 +22,10 @@
package org.onap.policy.apex.model.basicmodel.concepts;
+import com.google.gson.annotations.SerializedName;
import java.util.List;
import java.util.Random;
import java.util.UUID;
-import 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.apache.commons.lang3.StringUtils;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
import org.onap.policy.common.utils.validation.Assertions;
@@ -41,16 +37,9 @@ import org.onap.policy.common.utils.validation.Assertions;
* <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.
*/
-
-@XmlAccessorType(XmlAccessType.FIELD)
-@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;
- private static final int MAX_DESCRIPTION_LENGTH_8192 = 8192;
private static final int UUID_BYTE_LENGTH_16 = 16;
/*
@@ -58,13 +47,11 @@ public class AxKeyInfo extends AxConcept {
*/
private static final Random sharedRandom = new Random(); // NOSONAR
- @XmlElement(name = "key", required = true)
private AxArtifactKey key;
- @XmlElement(name = "UUID", required = true)
+ @SerializedName("UUID")
private UUID uuid;
- @XmlElement(required = true)
private String description;
/**
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
index d1cc99a22..439b2960f 100644
--- 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
@@ -30,11 +30,6 @@ import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.UUID;
-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.common.utils.validation.Assertions;
@@ -48,16 +43,10 @@ import org.onap.policy.common.utils.validation.Assertions;
* 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.
*/
-@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;
- @XmlElement(name = "key", required = true)
private AxArtifactKey key;
-
private Map<AxArtifactKey, AxKeyInfo> keyInfoMap;
/**
@@ -102,22 +91,6 @@ public class AxKeyInformation extends AxConcept implements AxConceptGetter<AxKey
}
/**
- * 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 unmarshaler the unmarshaler that is unmarshaling the model
- * @param parent the parent object of this object in the unmarshaler
- */
- public void afterUnmarshal(final Unmarshaller unmarshaler, 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.
*
@@ -160,6 +133,14 @@ public class AxKeyInformation extends AxConcept implements AxConceptGetter<AxKey
}
/**
+ * {@inheritDoc}.
+ */
+ @Override
+ public void buildReferences() {
+ keyInfoMap.values().stream().forEach(keyInfo -> keyInfo.buildReferences());
+ }
+
+ /**
* Sets the key of this concept.
*
* @param key the key of this concept
@@ -218,7 +199,7 @@ public class AxKeyInformation extends AxConcept implements AxConceptGetter<AxKey
}
/**
- * Validate an key information entry.
+ * Validate a key information entry.
*
* @param keyInfoEntry the key information entry
* @param uuidSet the set of UUIDs encountered in validation so far, the UUID of this entry is added to the set
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxModel.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxModel.java
index 5f63b9a3e..ce52b147f 100644
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxModel.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxModel.java
@@ -25,14 +25,7 @@ package org.onap.policy.apex.model.basicmodel.concepts;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
-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 javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
-import org.onap.policy.apex.model.basicmodel.handling.KeyInfoMarshalFilter;
import org.onap.policy.apex.model.basicmodel.service.ModelService;
import org.onap.policy.common.utils.validation.Assertions;
@@ -47,25 +40,13 @@ import org.onap.policy.common.utils.validation.Assertions;
* {@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.
*/
-
-@XmlRootElement(name = "apexModel", namespace = "http://www.onap.org/policy/apex-pdp")
-@XmlAccessorType(XmlAccessType.FIELD)
-@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;
- @XmlElement(name = "key", required = true)
private AxArtifactKey key;
-
- // @formatter:off
- @XmlElement(name = "keyInformation", required = true)
- @XmlJavaTypeAdapter(KeyInfoMarshalFilter.class)
private AxKeyInformation keyInformation;
- // @formatter:on
/**
* The Default Constructor creates this concept with a NULL artifact key.
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxReferenceKey.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxReferenceKey.java
index 6c671d3e6..b37bc47e4 100644
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxReferenceKey.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxReferenceKey.java
@@ -23,11 +23,6 @@ package org.onap.policy.apex.model.basicmodel.concepts;
import java.util.ArrayList;
import java.util.List;
-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.common.utils.validation.Assertions;
@@ -48,11 +43,6 @@ import org.onap.policy.common.utils.validation.Assertions;
* VERSION_REGEXP regular expressions respectively and that the local name fields match the
* LOCAL_NAME_REGEXP regular expression.
*/
-@XmlAccessorType(XmlAccessType.FIELD)
-@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";
@@ -61,28 +51,25 @@ public class AxReferenceKey extends AxKey {
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. */
+ /**
+ * 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\\-_]+";
+ "[A-Za-z0-9\\-_]+:[0-9].[0-9].[0-9]:[A-Za-z0-9\\-_]+:[A-Za-z0-9\\-_]+";
private static final int PARENT_NAME_FIELD = 0;
private static final int PARENT_VERSION_FIELD = 1;
private static final int PARENT_LOCAL_NAME_FIELD = 2;
private static final int LOCAL_NAME_FIELD = 3;
- @XmlElement(required = true)
private String parentKeyName;
-
- @XmlElement(required = true)
private String parentKeyVersion;
-
- @XmlElement(required = true)
private String parentLocalName;
-
- @XmlElement(required = true)
private String localName;
/**
@@ -95,19 +82,17 @@ public class AxReferenceKey extends AxKey {
/**
* The Copy Constructor creates a key by copying another key.
*
- * @param referenceKey
- * the reference key to copy from
+ * @param referenceKey the reference key to copy from
*/
public AxReferenceKey(final AxReferenceKey referenceKey) {
this(referenceKey.getParentKeyName(), referenceKey.getParentKeyVersion(), referenceKey.getParentLocalName(),
- referenceKey.getLocalName());
+ referenceKey.getLocalName());
}
/**
* Constructor to create a null reference key for the specified parent artifact key.
*
- * @param axArtifactKey
- * the parent artifact key of this reference key
+ * @param axArtifactKey the parent artifact key of this reference key
*/
public AxReferenceKey(final AxArtifactKey axArtifactKey) {
this(axArtifactKey.getName(), axArtifactKey.getVersion(), NULL_KEY_NAME, NULL_KEY_NAME);
@@ -116,10 +101,8 @@ public class AxReferenceKey extends AxKey {
/**
* Constructor to create a reference key for the given parent artifact key with the given local name.
*
- * @param axArtifactKey
- * the parent artifact key of this reference key
- * @param localName
- * the local name of this reference key
+ * @param axArtifactKey the parent artifact key of this reference key
+ * @param localName the local name of this reference key
*/
public AxReferenceKey(final AxArtifactKey axArtifactKey, final String localName) {
this(axArtifactKey, NULL_KEY_NAME, localName);
@@ -128,10 +111,8 @@ public class AxReferenceKey extends AxKey {
/**
* Constructor to create a reference key for the given parent reference key with the given local name.
*
- * @param parentReferenceKey
- * the parent reference key of this reference key
- * @param localName
- * the local name of this reference key
+ * @param parentReferenceKey the parent reference key of this reference key
+ * @param localName the local name of this reference key
*/
public AxReferenceKey(final AxReferenceKey parentReferenceKey, final String localName) {
this(parentReferenceKey.getParentArtifactKey(), parentReferenceKey.getLocalName(), localName);
@@ -141,12 +122,9 @@ 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.
*
- * @param axArtifactKey
- * the artifact key of the parent reference key of this reference key
- * @param parentLocalName
- * the local name of the parent reference key of this reference key
- * @param localName
- * the local name of this reference key
+ * @param axArtifactKey the artifact key of the parent reference key of this reference key
+ * @param parentLocalName the local name of the parent reference key of this reference key
+ * @param localName the local name of this reference key
*/
public AxReferenceKey(final AxArtifactKey axArtifactKey, final String parentLocalName, final String localName) {
this(axArtifactKey.getName(), axArtifactKey.getVersion(), parentLocalName, localName);
@@ -156,12 +134,9 @@ 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.
*
- * @param parentKeyName
- * the name of the parent artifact key of this reference key
- * @param parentKeyVersion
- * the version of the parent artifact key of this reference key
- * @param localName
- * the local name of this reference key
+ * @param parentKeyName the name of the parent artifact key of this reference key
+ * @param parentKeyVersion the version of the parent artifact key of this reference key
+ * @param localName the local name of this reference key
*/
public AxReferenceKey(final String parentKeyName, final String parentKeyVersion, final String localName) {
this(parentKeyName, parentKeyVersion, NULL_KEY_NAME, localName);
@@ -171,31 +146,26 @@ 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.
*
- * @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
+ * @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) {
+ final String localName) {
super();
this.parentKeyName = Assertions.validateStringParameter(PARENT_KEY_NAME, parentKeyName, NAME_REGEXP);
this.parentKeyVersion = Assertions.validateStringParameter(PARENT_KEY_VERSION, parentKeyVersion,
- VERSION_REGEXP);
+ VERSION_REGEXP);
this.parentLocalName = Assertions.validateStringParameter(PARENT_LOCAL_NAME, parentLocalName,
- LOCAL_NAME_REGEXP);
+ LOCAL_NAME_REGEXP);
this.localName = Assertions.validateStringParameter(LOCAL_NAME, localName, LOCAL_NAME_REGEXP);
}
/**
* Constructor to create a key from the specified key ID.
*
- * @param id
- * the key ID in a format that respects the KEY_ID_REGEXP
+ * @param id the key ID in a format that respects the KEY_ID_REGEXP
*/
public AxReferenceKey(final String id) {
final var conditionedId = Assertions.validateStringParameter("id", id, REFERENCE_KEY_ID_REGEXP);
@@ -208,13 +178,13 @@ public class AxReferenceKey extends AxKey {
// Initiate the new key
parentKeyName = Assertions.validateStringParameter(PARENT_KEY_NAME, nameVersionNameArray[PARENT_NAME_FIELD],
- NAME_REGEXP);
+ NAME_REGEXP);
parentKeyVersion = Assertions.validateStringParameter(PARENT_KEY_VERSION,
- nameVersionNameArray[PARENT_VERSION_FIELD], VERSION_REGEXP);
+ nameVersionNameArray[PARENT_VERSION_FIELD], VERSION_REGEXP);
parentLocalName = Assertions.validateStringParameter(PARENT_LOCAL_NAME,
- nameVersionNameArray[PARENT_LOCAL_NAME_FIELD], LOCAL_NAME_REGEXP);
+ nameVersionNameArray[PARENT_LOCAL_NAME_FIELD], LOCAL_NAME_REGEXP);
localName = Assertions.validateStringParameter(LOCAL_NAME, nameVersionNameArray[LOCAL_NAME_FIELD],
- LOCAL_NAME_REGEXP);
+ LOCAL_NAME_REGEXP);
}
/**
@@ -224,7 +194,7 @@ public class AxReferenceKey extends AxKey {
*/
public static AxReferenceKey getNullKey() {
return new AxReferenceKey(AxKey.NULL_KEY_NAME, AxKey.NULL_KEY_VERSION, AxKey.NULL_KEY_NAME,
- AxKey.NULL_KEY_NAME);
+ AxKey.NULL_KEY_NAME);
}
/**
@@ -274,8 +244,7 @@ public class AxReferenceKey extends AxKey {
/**
* Sets the parent artifact key of this reference key.
*
- * @param parentKey
- * the parent artifact key of this reference key
+ * @param parentKey the parent artifact key of this reference key
*/
public void setParentArtifactKey(final AxArtifactKey parentKey) {
Assertions.argumentNotNull(parentKey, "parentKey may not be null");
@@ -288,8 +257,7 @@ public class AxReferenceKey extends AxKey {
/**
* Sets the parent reference key of this reference key.
*
- * @param parentKey
- * the parent reference key of this reference key
+ * @param parentKey the parent reference key of this reference key
*/
public void setParentReferenceKey(final AxReferenceKey parentKey) {
Assertions.argumentNotNull(parentKey, "parentKey may not be null");
@@ -311,8 +279,7 @@ public class AxReferenceKey extends AxKey {
/**
* Sets the parent key name of this reference key.
*
- * @param parentKeyName
- * the parent key name of this reference key
+ * @param parentKeyName the parent key name of this reference key
*/
public void setParentKeyName(final String parentKeyName) {
this.parentKeyName = Assertions.validateStringParameter(PARENT_KEY_NAME, parentKeyName, NAME_REGEXP);
@@ -330,12 +297,11 @@ public class AxReferenceKey extends AxKey {
/**
* Sets the parent key version of this reference key.
*
- * @param parentKeyVersion
- * the parent key version of this reference key
+ * @param parentKeyVersion the parent key version of this reference key
*/
public void setParentKeyVersion(final String parentKeyVersion) {
this.parentKeyVersion = Assertions.validateStringParameter(PARENT_KEY_VERSION, parentKeyVersion,
- VERSION_REGEXP);
+ VERSION_REGEXP);
}
/**
@@ -350,12 +316,11 @@ public class AxReferenceKey extends AxKey {
/**
* Sets the parent local name of this reference key.
*
- * @param parentLocalName
- * the parent local name of this reference key
+ * @param parentLocalName the parent local name of this reference key
*/
public void setParentLocalName(final String parentLocalName) {
this.parentLocalName = Assertions.validateStringParameter(PARENT_LOCAL_NAME, parentLocalName,
- LOCAL_NAME_REGEXP);
+ LOCAL_NAME_REGEXP);
}
/**
@@ -370,8 +335,7 @@ public class AxReferenceKey extends AxKey {
/**
* Sets the local name of this reference key.
*
- * @param localName
- * the local name of this reference key
+ * @param localName the local name of this reference key
*/
public void setLocalName(final String localName) {
this.localName = Assertions.validateStringParameter(LOCAL_NAME, localName, LOCAL_NAME_REGEXP);
@@ -409,31 +373,31 @@ public class AxReferenceKey extends AxKey {
@Override
public AxValidationResult validate(final AxValidationResult result) {
final var parentNameValidationErrorMessage = Assertions.getStringParameterValidationMessage(PARENT_KEY_NAME,
- parentKeyName, NAME_REGEXP);
+ parentKeyName, NAME_REGEXP);
if (parentNameValidationErrorMessage != null) {
result.addValidationMessage(new AxValidationMessage(this, this.getClass(), ValidationResult.INVALID,
- "parentKeyName invalid-" + parentNameValidationErrorMessage));
+ "parentKeyName invalid-" + parentNameValidationErrorMessage));
}
final var parentKeyVersionValidationErrorMessage = Assertions
- .getStringParameterValidationMessage(PARENT_KEY_VERSION, parentKeyVersion, VERSION_REGEXP);
+ .getStringParameterValidationMessage(PARENT_KEY_VERSION, parentKeyVersion, VERSION_REGEXP);
if (parentKeyVersionValidationErrorMessage != null) {
result.addValidationMessage(new AxValidationMessage(this, this.getClass(), ValidationResult.INVALID,
- "parentKeyVersion invalid-" + parentKeyVersionValidationErrorMessage));
+ "parentKeyVersion invalid-" + parentKeyVersionValidationErrorMessage));
}
final var parentLocalNameValidationErrorMessage = Assertions
- .getStringParameterValidationMessage(PARENT_LOCAL_NAME, parentLocalName, LOCAL_NAME_REGEXP);
+ .getStringParameterValidationMessage(PARENT_LOCAL_NAME, parentLocalName, LOCAL_NAME_REGEXP);
if (parentLocalNameValidationErrorMessage != null) {
result.addValidationMessage(new AxValidationMessage(this, this.getClass(), ValidationResult.INVALID,
- "parentLocalName invalid-" + parentLocalNameValidationErrorMessage));
+ "parentLocalName invalid-" + parentLocalNameValidationErrorMessage));
}
final var localNameValidationErrorMessage = Assertions.getStringParameterValidationMessage(LOCAL_NAME,
- localName, LOCAL_NAME_REGEXP);
+ localName, LOCAL_NAME_REGEXP);
if (localNameValidationErrorMessage != null) {
result.addValidationMessage(new AxValidationMessage(this, this.getClass(), ValidationResult.INVALID,
- "localName invalid-" + localNameValidationErrorMessage));
+ "localName invalid-" + localNameValidationErrorMessage));
}
return result;
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/package-info.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/package-info.java
index 294a66496..347e46a0f 100644
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/package-info.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/package-info.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,12 +24,4 @@
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-
-@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.policy.apex.model.basicmodel.concepts;
-
-import javax.xml.bind.annotation.XmlNs;
-import javax.xml.bind.annotation.XmlNsForm;
-import javax.xml.bind.annotation.XmlSchema;
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelCustomGsonMapAdapter.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelCustomGsonMapAdapter.java
new file mode 100644
index 000000000..cb67590f7
--- /dev/null
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelCustomGsonMapAdapter.java
@@ -0,0 +1,118 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.model.basicmodel.handling;
+
+import com.google.gson.JsonArray;
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParseException;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSerializer;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.AbstractMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.TreeMap;
+import java.util.stream.Collectors;
+import java.util.stream.StreamSupport;
+
+@SuppressWarnings("rawtypes")
+public class ApexModelCustomGsonMapAdapter implements JsonSerializer<Map>, JsonDeserializer<Map> {
+ private static final String MAP_ENTRY_KEY = "entry";
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Map deserialize(JsonElement jsonElement, Type typeOfT, JsonDeserializationContext context)
+ throws JsonParseException {
+
+ if (!(jsonElement instanceof JsonObject)) {
+ throw new JsonParseException("could not parse JSON map, map is not a JsonObject");
+ }
+
+ JsonObject jsonObject = (JsonObject) jsonElement;
+
+ if (jsonObject.size() != 1) {
+ throw new JsonParseException("could not parse JSON map, map must be in a JsonObject with a single member");
+ }
+
+ JsonArray mapEntryArray = (JsonArray) jsonObject.get(MAP_ENTRY_KEY);
+ if (mapEntryArray == null) {
+ throw new JsonParseException("could not parse JSON map, map \"entry\" in JsonObject not found");
+ }
+
+ return new TreeMap(
+ StreamSupport
+ .stream(mapEntryArray.spliterator(), true)
+ .map(element -> deserializeMapEntry(element, typeOfT, context))
+ .collect(Collectors.toMap(entry -> entry.getKey(), entry -> entry.getValue()))
+ );
+ }
+
+ @Override
+ public JsonElement serialize(Map sourceMap, Type typeOfSrc, JsonSerializationContext context) {
+
+ // A map is stored in a JsonArray
+ JsonArray mapEntryArray = new JsonArray();
+
+ for (Object mapEntryObject : sourceMap.entrySet()) {
+ Entry mapEntry = (Entry) mapEntryObject;
+ mapEntryArray.add(serializeMapEntry(mapEntry, typeOfSrc, context));
+ }
+
+ JsonObject returnObject = new JsonObject();
+ returnObject.add(MAP_ENTRY_KEY, mapEntryArray);
+
+ return returnObject;
+ }
+
+ @SuppressWarnings("unchecked")
+ private static Entry deserializeMapEntry(JsonElement element, Type typeOfT, JsonDeserializationContext context) {
+ // Get the types of the map
+ ParameterizedType pt = (ParameterizedType) typeOfT;
+
+ // Type of the key and value of the map
+ Type keyType = pt.getActualTypeArguments()[0];
+ Type valueType = pt.getActualTypeArguments()[1];
+
+ // Deserialize the key and value
+ return new AbstractMap.SimpleEntry(
+ context.deserialize(element.getAsJsonObject().get("key"), keyType),
+ context.deserialize(element.getAsJsonObject().get("value"), valueType));
+ }
+
+ private static JsonElement serializeMapEntry(Entry sourceEntry, Type typeOfSrc, JsonSerializationContext context) {
+ // Get the types of the map
+ ParameterizedType pt = (ParameterizedType) typeOfSrc;
+
+ // Type of the key and value of the map
+ Type keyType = pt.getActualTypeArguments()[0];
+ Type valueType = pt.getActualTypeArguments()[1];
+
+ JsonObject entryObject = new JsonObject();
+ entryObject.add("key", context.serialize(sourceEntry.getKey(), keyType));
+ entryObject.add("value", context.serialize(sourceEntry.getValue(), valueType));
+
+ return entryObject;
+ }
+}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelCustomGsonRefereceKeyAdapter.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelCustomGsonRefereceKeyAdapter.java
new file mode 100644
index 000000000..d731c8689
--- /dev/null
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelCustomGsonRefereceKeyAdapter.java
@@ -0,0 +1,50 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.model.basicmodel.handling;
+
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParseException;
+import java.lang.reflect.Type;
+import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
+
+public class ApexModelCustomGsonRefereceKeyAdapter implements JsonDeserializer<AxReferenceKey> {
+
+ @Override
+ public AxReferenceKey deserialize(JsonElement jsonElement, Type typeOfT, JsonDeserializationContext context)
+ throws JsonParseException {
+
+ if (jsonElement instanceof JsonObject) {
+ return new AxReferenceKey(
+ jsonElement.getAsJsonObject().get("parentKeyName").getAsString(),
+ jsonElement.getAsJsonObject().get("parentKeyVersion").getAsString(),
+ jsonElement.getAsJsonObject().get("parentLocalName").getAsString(),
+ jsonElement.getAsJsonObject().get("localName").getAsString()
+ );
+ } else {
+ AxReferenceKey returnKey = new AxReferenceKey();
+ returnKey.setLocalName(jsonElement.getAsString());
+ return returnKey;
+ }
+ }
+}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelFileWriter.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelFileWriter.java
index 908ad31aa..54b5651cc 100644
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelFileWriter.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelFileWriter.java
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +23,8 @@ package org.onap.policy.apex.model.basicmodel.handling;
import java.io.File;
import java.io.FileOutputStream;
+import lombok.Getter;
+import lombok.Setter;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.concepts.AxModel;
import org.slf4j.ext.XLogger;
@@ -34,42 +36,21 @@ import org.slf4j.ext.XLoggerFactory;
* @author Liam Fallon (liam.fallon@ericsson.com)
* @param <M> the type of Apex model to write to file, must be a sub class of {@link AxModel}
*/
+@Getter
+@Setter
public class ApexModelFileWriter<M extends AxModel> {
private static final XLogger LOGGER = XLoggerFactory.getXLogger(ApexModelFileWriter.class);
// Should models being written to files be valid
- private boolean validateFlag;
+ private boolean validate;
/**
* Constructor, set the validation flag.
*
- * @param validateFlag indicates if validation be performed prior to output
+ * @param validate indicates if validation be performed prior to output
*/
- public ApexModelFileWriter(final boolean validateFlag) {
- this.validateFlag = validateFlag;
- }
-
- /**
- * Write a model to an XML file.
- *
- * @param model The model to write
- * @param rootModelClass The concept class
- * @param modelFileName The name of the file to write to
- * @throws ApexException thrown on errors
- */
- public void apexModelWriteXmlFile(final M model, final Class<M> rootModelClass, final String modelFileName)
- throws ApexException {
- LOGGER.debug("running apexModelWriteXMLFile . . .");
-
- final ApexModelWriter<M> modelWriter = new ApexModelWriter<>(rootModelClass);
- modelWriter.setValidateFlag(validateFlag);
- modelWriter.getCDataFieldSet().add("description");
- modelWriter.getCDataFieldSet().add("logic");
- modelWriter.getCDataFieldSet().add("uiLogic");
-
- writeModelFile(model, modelWriter, modelFileName);
-
- LOGGER.debug("ran apexModelWriteXMLFile");
+ public ApexModelFileWriter(final boolean validate) {
+ this.validate = validate;
}
/**
@@ -85,8 +66,7 @@ public class ApexModelFileWriter<M extends AxModel> {
LOGGER.debug("running apexModelWriteJSONFile . . .");
final ApexModelWriter<M> modelWriter = new ApexModelWriter<>(rootModelClass);
- modelWriter.setJsonOutput(true);
- modelWriter.setValidateFlag(validateFlag);
+ modelWriter.setValidate(validate);
writeModelFile(model, modelWriter, modelFileName);
@@ -94,24 +74,6 @@ public class ApexModelFileWriter<M extends AxModel> {
}
/**
- * Checks if the validation flag is set.
- *
- * @return true, the validation flag is set
- */
- public boolean isValidateFlag() {
- return validateFlag;
- }
-
- /**
- * Sets the validate flag.
- *
- * @param validateFlag the validate flag value
- */
- public void setValidateFlag(final boolean validateFlag) {
- this.validateFlag = validateFlag;
- }
-
- /**
* Write a model to a file using a model writer.
*
* @param model The model to write
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelReader.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelReader.java
index 7e136f6b3..a9bd2fe60 100644
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelReader.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelReader.java
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2022 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,55 +22,47 @@
package org.onap.policy.apex.model.basicmodel.handling;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.io.StringReader;
-import java.util.regex.Pattern;
-import javax.xml.XMLConstants;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.transform.stream.StreamSource;
-import javax.xml.validation.SchemaFactory;
-import org.eclipse.persistence.jaxb.JAXBContextFactory;
-import org.eclipse.persistence.jaxb.MarshallerProperties;
-import org.eclipse.persistence.oxm.MediaType;
+import java.util.Map;
+import lombok.Getter;
+import lombok.Setter;
import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
+import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
-import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.common.utils.resources.TextFileUtils;
import org.onap.policy.common.utils.validation.Assertions;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
/**
- * This class reads an Apex concept from an XML file into a Java Apex Concept {@link AxConcept}.
+ * This class reads an Apex concept from a file into a Java Apex Concept {@link AxConcept}.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
* @param <C> the type of Apex concept to read, must be a sub class of {@link AxConcept}
*/
+@Getter
+@Setter
public class ApexModelReader<C extends AxConcept> {
// Get a reference to the logger
private static final XLogger LOGGER = XLoggerFactory.getXLogger(ApexModelReader.class);
- // Regular expressions for checking input types
- // (starts with <?xml...>
- private static final String XML_INPUT_TYPE_REGEXP = "^\\s*<\\?xml.*>\\s*";
- // starts with some kind of bracket [ or (
- private static final String JSON_INPUT_TYPE_REGEXP = "^\\s*[\\(\\{\\[][\\s\\S]*[\\)\\}\\]]";
- // or {, then has something, then has
- // and has a close bracket
+ // Use GSON to deserialize JSON
+ private static Gson gson = new GsonBuilder()
+ .registerTypeAdapter(AxReferenceKey.class, new ApexModelCustomGsonRefereceKeyAdapter())
+ .registerTypeAdapter(Map.class, new ApexModelCustomGsonMapAdapter())
+ .setPrettyPrinting()
+ .create();
//  The root class of the concept we are reading
private final Class<C> rootConceptClass;
- // The unmarshaller for the Apex concepts
- private Unmarshaller unmarshaller = null;
-
// All read concepts are validated after reading if this flag is set
- private boolean validateFlag = true;
+ private boolean validate = true;
/**
* Constructor, initiates the reader with validation on.
@@ -81,17 +73,6 @@ public class ApexModelReader<C extends AxConcept> {
public ApexModelReader(final Class<C> rootConceptClass) throws ApexModelException {
// Save the root concept class
this.rootConceptClass = rootConceptClass;
-
- try {
- final var jaxbContext = JAXBContextFactory.createContext(new Class[] {rootConceptClass}, null);
-
- // Set up the unmarshaller to carry out validation
- unmarshaller = jaxbContext.createUnmarshaller();
- unmarshaller.setEventHandler(new javax.xml.bind.helpers.DefaultValidationEventHandler());
- } catch (final JAXBException e) {
- LOGGER.error("Unable to set JAXB context", e);
- throw new ApexModelException("Unable to set JAXB context", e);
- }
}
/**
@@ -103,36 +84,11 @@ public class ApexModelReader<C extends AxConcept> {
*/
public ApexModelReader(final Class<C> rootConceptClass, final boolean validate) throws ApexModelException {
this(rootConceptClass);
- this.validateFlag = validate;
- }
-
- /**
- * Set the schema to use for reading XML files.
- *
- * @param schemaFileName the schema file to use
- * @throws ApexModelException if the schema cannot be set
- */
- public void setSchema(final String schemaFileName) throws ApexModelException {
- // Has a schema been set
- if (schemaFileName != null) {
- try {
- // Set the concept schema
- final var schemaUrl = ResourceUtils.getUrlResource(schemaFileName);
- final var apexConceptSchema =
- SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(schemaUrl);
- unmarshaller.setSchema(apexConceptSchema);
- } catch (final Exception e) {
- LOGGER.error("Unable to load schema ", e);
- throw new ApexModelException("Unable to load schema", e);
- }
- } else {
- // Clear the schema
- unmarshaller.setSchema(null);
- }
+ this.validate = validate;
}
/**
- * This method checks the specified Apex concept XML file and reads it into an Apex concept.
+ * This method checks the specified Apex concept file and reads it into an Apex concept.
*
* @param apexConceptStream the apex concept stream
* @return the Apex concept
@@ -179,28 +135,23 @@ public class ApexModelReader<C extends AxConcept> {
LOGGER.entry("reading Apex concept from string . . .");
- final var apexString = apexConceptString.trim();
-
- // Set the type of input for this stream
- setInputType(apexString);
-
- // The Apex Concept
C apexConcept = null;
-
- // Use JAXB to read and verify the Apex concept XML file
try {
- // Load the configuration file
- final var source = new StreamSource(new StringReader(apexString));
- final JAXBElement<C> rootElement = unmarshaller.unmarshal(source, rootConceptClass);
- apexConcept = rootElement.getValue();
- } catch (final JAXBException e) {
- throw new ApexModelException("Unable to unmarshal Apex concept ", e);
+ apexConcept = gson.fromJson(apexConceptString, rootConceptClass);
+ } catch (final Exception je) {
+ throw new ApexModelException("Unable to unmarshal Apex concept ", je);
+ }
+
+ if (apexConcept == null) {
+ throw new ApexModelException("Unable to unmarshal Apex concept, unmarshaled model is null ");
}
LOGGER.debug("reading of Apex concept {} completed");
+ apexConcept.buildReferences();
+
// Check if the concept should be validated
- if (validateFlag) {
+ if (validate) {
// Validate the configuration file
final AxValidationResult validationResult = apexConcept.validate(new AxValidationResult());
if (validationResult.isValid()) {
@@ -215,54 +166,4 @@ public class ApexModelReader<C extends AxConcept> {
return apexConcept;
}
}
-
- /**
- * Gets the value of the validation flag.
- *
- * @return the validation flag value
- */
- public boolean getValidateFlag() {
- return validateFlag;
- }
-
- /**
- * Sets the validation flag.
- *
- * @param validateFlag the validation flag value
- */
- public void setValidateFlag(final boolean validateFlag) {
- this.validateFlag = validateFlag;
- }
-
- /**
- * Set the type of input for the concept reader.
- *
- * @param apexConceptString The stream with
- * @throws ApexModelException on errors setting input type
- */
- private void setInputType(final String apexConceptString) throws ApexModelException {
- // Check the input type
- if (Pattern.compile(JSON_INPUT_TYPE_REGEXP).matcher(apexConceptString).find()) {
- // is json
- try {
- unmarshaller.setProperty(MarshallerProperties.MEDIA_TYPE, MediaType.APPLICATION_JSON);
- unmarshaller.setProperty(MarshallerProperties.JSON_INCLUDE_ROOT, true);
- } catch (final Exception e) {
- LOGGER.warn("JAXB error setting marshaller for JSON Input", e);
- throw new ApexModelException("JAXB error setting unmarshaller for JSON input", e);
- }
- } else if (Pattern.compile(XML_INPUT_TYPE_REGEXP).matcher(apexConceptString).find()) {
- // is xml
- try {
- unmarshaller.setProperty(MarshallerProperties.MEDIA_TYPE, MediaType.APPLICATION_XML);
- } catch (final Exception e) {
- LOGGER.warn("JAXB error setting marshaller for XML Input", e);
- throw new ApexModelException("JAXB error setting unmarshaller for XML input", e);
- }
- } else {
- LOGGER.warn("format of input for Apex concept is neither JSON nor XML");
- throw new ApexModelException("format of input for Apex concept is neither JSON nor XML");
- }
- }
-
}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelSaver.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelSaver.java
index dea32df49..79d69bdd5 100644
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelSaver.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelSaver.java
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,7 +29,7 @@ import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
/**
- * This class is used to save Apex models to file in XML or JSON format.
+ * This class is used to save Apex models to file in JSON format.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
* @param <M> the type of Apex model to save to file, must be a sub class of {@link AxModel}
@@ -51,7 +51,7 @@ public class ApexModelSaver<M extends AxModel> {
* @param rootModelClass the class of the model, a sub class of {@link AxModel}
* @param model the model to write, an instance of a sub class of {@link AxModel}
* @param writePath the directory to which models will be written. The name of the written model will be the Model
- * Name for its key with the suffix {@code .xml} or {@code .json}.
+ * Name for its key with the suffix {@code .json}.
*/
public ApexModelSaver(final Class<M> rootModelClass, final M model, final String writePath) {
Assertions.argumentNotNull(rootModelClass, "argument rootModelClass may not be null");
@@ -64,21 +64,6 @@ public class ApexModelSaver<M extends AxModel> {
}
/**
- * Write an Apex model to a file in XML format. The model will be written to {@code <writePath/modelKeyName.xml>}
- *
- * @throws ApexException on errors writing the Apex model
- */
- public void apexModelWriteXml() throws ApexException {
- LOGGER.debug("running apexModelWriteXML . . .");
-
- // Write the file to disk
- final var xmlFile = new File(writePath + File.separatorChar + model.getKey().getName() + ".xml");
- new ApexModelFileWriter<M>(true).apexModelWriteXmlFile(model, rootModelClass, xmlFile.getPath());
-
- LOGGER.debug("ran apexModelWriteXML");
- }
-
- /**
* Write an Apex model to a file in JSON format. The model will be written to {@code <writePath/modelKeyName.json>}
*
* @throws ApexException on errors writing the Apex model
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelStringWriter.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelStringWriter.java
index de6a72ffd..a9df23afc 100644
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelStringWriter.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelStringWriter.java
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,6 +22,8 @@
package org.onap.policy.apex.model.basicmodel.handling;
import java.io.ByteArrayOutputStream;
+import lombok.Getter;
+import lombok.Setter;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
import org.onap.policy.common.utils.validation.Assertions;
@@ -34,19 +36,21 @@ import org.slf4j.ext.XLoggerFactory;
* @author Liam Fallon (liam.fallon@ericsson.com)
* @param <C> the type of Apex concept to write to a string, must be a sub class of {@link AxConcept}
*/
+@Getter
+@Setter
public class ApexModelStringWriter<C extends AxConcept> {
private static final XLogger LOGGER = XLoggerFactory.getXLogger(ApexModelStringWriter.class);
// Should concepts being written to files be valid
- private boolean validateFlag;
+ private boolean validate;
/**
* Constructor, set the validation flag.
*
- * @param validateFlag Should validation be performed prior to output
+ * @param validate Should validation be performed prior to output
*/
- public ApexModelStringWriter(final boolean validateFlag) {
- this.validateFlag = validateFlag;
+ public ApexModelStringWriter(final boolean validate) {
+ this.validate = validate;
}
/**
@@ -54,46 +58,14 @@ public class ApexModelStringWriter<C extends AxConcept> {
*
* @param concept The concept to write
* @param rootConceptClass The concept class
- * @param jsonFlag writes JSON if true, and a generic string if false
* @return The string with the concept
* @throws ApexException thrown on errors
*/
- public String writeString(final C concept, final Class<C> rootConceptClass, final boolean jsonFlag)
+ public String writeString(final C concept, final Class<C> rootConceptClass)
throws ApexException {
Assertions.argumentNotNull(concept, "concept may not be null");
- if (jsonFlag) {
- return writeJsonString(concept, rootConceptClass);
- } else {
- return concept.toString();
- }
- }
-
- /**
- * Write a concept to an XML string.
- *
- * @param concept The concept to write
- * @param rootConceptClass The concept class
- * @return The string with the concept
- * @throws ApexException thrown on errors
- */
- public String writeXmlString(final C concept, final Class<C> rootConceptClass) throws ApexException {
- LOGGER.debug("running writeXMLString . . .");
-
- final ApexModelWriter<C> conceptWriter = new ApexModelWriter<>(rootConceptClass);
- conceptWriter.setValidateFlag(validateFlag);
- conceptWriter.getCDataFieldSet().add("description");
- conceptWriter.getCDataFieldSet().add("logic");
- conceptWriter.getCDataFieldSet().add("uiLogic");
-
- try (var baOutputStream = new ByteArrayOutputStream()) {
- conceptWriter.write(concept, baOutputStream);
- return baOutputStream.toString();
- } catch (final Exception e) {
- LOGGER.warn("error writing XML string", e);
- throw new ApexException("error writing XML string", e);
- }
-
+ return writeJsonString(concept, rootConceptClass);
}
/**
@@ -108,8 +80,7 @@ public class ApexModelStringWriter<C extends AxConcept> {
LOGGER.debug("running writeJSONString . . .");
final ApexModelWriter<C> conceptWriter = new ApexModelWriter<>(rootConceptClass);
- conceptWriter.setJsonOutput(true);
- conceptWriter.setValidateFlag(validateFlag);
+ conceptWriter.setValidate(validate);
try (var baOutputStream = new ByteArrayOutputStream()) {
conceptWriter.write(concept, baOutputStream);
@@ -120,22 +91,4 @@ public class ApexModelStringWriter<C extends AxConcept> {
}
}
-
- /**
- * Checks if is validate flag.
- *
- * @return true, if checks if is validate flag
- */
- public boolean isValidateFlag() {
- return validateFlag;
- }
-
- /**
- * Sets the validate flag.
- *
- * @param validateFlag the validate flag
- */
- public void setValidateFlag(final boolean validateFlag) {
- this.validateFlag = validateFlag;
- }
}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelWriter.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelWriter.java
index 9e43f76bd..349622697 100644
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelWriter.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelWriter.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,129 +21,67 @@
package org.onap.policy.apex.model.basicmodel.handling;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
-import java.util.Set;
-import java.util.TreeSet;
-import javax.xml.XMLConstants;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-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 java.util.Map;
+import lombok.Getter;
+import lombok.Setter;
import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
+import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
import org.onap.policy.common.utils.validation.Assertions;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
/**
- * This class writes an Apex concept to an XML file or JSON file from a Java Apex Concept.
+ * This class writes an Apex concept to a file from a Java Apex Concept.
*
* @param <C> the type of Apex concept to write, must be a sub class of {@link AxConcept}
* @author John Keeney (john.keeney@ericsson.com)
*/
+@Getter
+@Setter
public class ApexModelWriter<C extends AxConcept> {
private static final String CONCEPT_MAY_NOT_BE_NULL = "concept may not be null";
private static final String CONCEPT_WRITER_MAY_NOT_BE_NULL = "concept writer may not be null";
private static final String CONCEPT_STREAM_MAY_NOT_BE_NULL = "concept stream may not be null";
+ // Use GSON to serialize JSON
+ private static Gson gson = new GsonBuilder()
+ .registerTypeAdapter(AxReferenceKey.class, new ApexModelCustomGsonRefereceKeyAdapter())
+ .registerTypeAdapter(Map.class, new ApexModelCustomGsonMapAdapter())
+ .setPrettyPrinting()
+ .create();
+
// Get a reference to the logger
private static final XLogger LOGGER = XLoggerFactory.getXLogger(ApexModelWriter.class);
- // Writing as JSON or XML
- private boolean jsonOutput = false;
-
- // The list of fields to output as CDATA
- private final Set<String> cdataFieldSet = new TreeSet<>();
-
- // The Marshaller for the Apex concepts
- private Marshaller marshaller = null;
+ //  The root class of the concept we are reading
+ private final Class<C> rootConceptClass;
// All written concepts are validated before writing if this flag is set
- private boolean validateFlag = true;
+ private boolean validate = true;
/**
- * Constructor, initiates the writer.
+ * Constructor, initiates the writer with validation on.
*
* @param rootConceptClass the root concept class for concept reading
- * @throws ApexModelException the apex concept writer exception
+ * @throws ApexModelException the apex concept reader exception
*/
public ApexModelWriter(final Class<C> rootConceptClass) throws ApexModelException {
- // Set up Eclipselink for XML and JSON output
- System.setProperty("javax.xml.bind.context.factory", "org.eclipse.persistence.jaxb.JAXBContextFactory");
-
- try {
- final var jaxbContext = JAXBContextFactory.createContext(new Class[]{rootConceptClass}, null);
-
- // Set up the unmarshaller to carry out validation
- marshaller = jaxbContext.createMarshaller();
- marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
- marshaller.setEventHandler(new javax.xml.bind.helpers.DefaultValidationEventHandler());
- } catch (final JAXBException e) {
- throw new ApexModelException("JAXB marshaller creation exception", e);
- }
- }
-
- /**
- * The set of fields to be output as CDATA.
- *
- * @return the set of fields
- */
- public Set<String> getCDataFieldSet() {
- return cdataFieldSet;
- }
-
- /**
- * Return true if JSON output enabled, XML output if false.
- *
- * @return true for JSON output
- */
- public boolean isJsonOutput() {
- return jsonOutput;
- }
-
- /**
- * Set the value of JSON output, true for JSON output, false for XML output.
- *
- * @param jsonOutput true for JSON output
- * @throws ApexModelException on errors setting output type
- */
- public void setJsonOutput(final boolean jsonOutput) throws ApexModelException {
- this.jsonOutput = jsonOutput;
-
- // Set up output specific parameters
- if (this.jsonOutput) {
- try {
- marshaller.setProperty(MarshallerProperties.MEDIA_TYPE, MediaType.APPLICATION_JSON);
- marshaller.setProperty(MarshallerProperties.JSON_INCLUDE_ROOT, true);
- } catch (final Exception e) {
- throw new ApexModelException("JAXB error setting marshaller for JSON output", e);
- }
- } else {
- try {
- marshaller.setProperty(MarshallerProperties.MEDIA_TYPE, MediaType.APPLICATION_XML);
- } catch (final Exception e) {
- throw new ApexModelException("JAXB error setting marshaller for XML output", e);
- }
- }
+ // Save the root concept class
+ this.rootConceptClass = rootConceptClass;
}
/**
* This method validates the Apex concept then writes it into a stream.
*
- * @param concept the concept to write
+ * @param concept the concept to write
* @param apexConceptStream the stream to write to
* @throws ApexModelException on validation or writing exceptions
*/
@@ -157,7 +95,7 @@ public class ApexModelWriter<C extends AxConcept> {
/**
* This method validates the Apex concept then writes it into a writer.
*
- * @param concept the concept to write
+ * @param concept the concept to write
* @param apexConceptWriter the writer to write to
* @throws ApexModelException on validation or writing exceptions
*/
@@ -166,84 +104,23 @@ public class ApexModelWriter<C extends AxConcept> {
Assertions.argumentNotNull(apexConceptWriter, CONCEPT_WRITER_MAY_NOT_BE_NULL);
// Check if we should validate the concept
- if (validateFlag) {
+ if (validate) {
// Validate the concept first
final AxValidationResult validationResult = concept.validate(new AxValidationResult());
if (!validationResult.isValid()) {
String message =
- "Apex concept xml (" + concept.getKey().getId() + ") validation failed: " + validationResult
- .toString();
+ "Apex concept (" + concept.getKey().getId() + ") validation failed: " + validationResult.toString();
throw new ApexModelException(message);
}
}
- if (jsonOutput) {
- writeJson(concept, apexConceptWriter);
- } else {
- writeXml(concept, apexConceptWriter);
- }
- }
-
- /**
- * This method writes the Apex concept into a writer in XML format.
- *
- * @param concept the concept to write
- * @param apexConceptWriter the writer to write to
- * @throws ApexModelException on validation or writing exceptions
- */
- private void writeXml(final C concept, final Writer apexConceptWriter) throws ApexModelException {
- Assertions.argumentNotNull(concept, CONCEPT_MAY_NOT_BE_NULL);
-
- LOGGER.debug("writing Apex concept XML . . .");
-
- try {
- // Write the concept into a DOM document, then transform to add CDATA fields and pretty
- // print, then write out the result
- final var docBuilderFactory = DocumentBuilderFactory.newInstance();
- docBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
- docBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
-
- docBuilderFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
- final var document = docBuilderFactory.newDocumentBuilder().newDocument();
-
- // Marshal the concept into the empty document.
- marshaller.marshal(concept, document);
-
- final var domTransformer = getTransformer();
-
- // Convert the cDataFieldSet into a space delimited string
- domTransformer.setOutputProperty(OutputKeys.CDATA_SECTION_ELEMENTS,
- cdataFieldSet.toString().replaceAll("[\\[\\]\\,]", " "));
- domTransformer.transform(new DOMSource(document), new StreamResult(apexConceptWriter));
- } catch (JAXBException | TransformerException | ParserConfigurationException e) {
- throw new ApexModelException("Unable to marshal Apex concept to XML", e);
- }
- LOGGER.debug("wrote Apex concept XML");
- }
-
- private Transformer getTransformer() throws TransformerConfigurationException {
- // Transform the DOM to the output stream
- final var transformerFactory = TransformerFactory.newInstance();
- transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
- transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
-
- final var domTransformer = transformerFactory.newTransformer();
-
- // Pretty print
- try {
- domTransformer.setOutputProperty(OutputKeys.INDENT, "yes");
- // May fail if not using XALAN XSLT engine. But not in any way vital
- domTransformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
- } catch (final Exception ignore) {
- LOGGER.trace("Unable to set indent property", ignore);
- }
- return domTransformer;
+ writeJson(concept, apexConceptWriter);
}
/**
* This method writes the Apex concept into a writer in JSON format.
*
- * @param concept the concept to write
+ * @param concept the concept to write
* @param apexConceptWriter the writer to write to
* @throws ApexModelException on validation or writing exceptions
*/
@@ -252,29 +129,20 @@ public class ApexModelWriter<C extends AxConcept> {
LOGGER.debug("writing Apex concept JSON . . .");
+ String modelJsonString = null;
try {
- marshaller.marshal(concept, apexConceptWriter);
- } catch (final JAXBException e) {
- throw new ApexModelException("Unable to marshal Apex concept to JSON", e);
+ modelJsonString = gson.toJson(concept, rootConceptClass);
+ } catch (Exception je) {
+ throw new ApexModelException("Unable to marshal Apex concept to JSON", je);
}
- LOGGER.debug("wrote Apex concept JSON");
- }
- /**
- * Gets the validation flag value.
- *
- * @return the validation flag value
- */
- public boolean getValidateFlag() {
- return validateFlag;
- }
+ try {
+ apexConceptWriter.write(modelJsonString);
+ apexConceptWriter.close();
+ } catch (IOException ioe) {
+ throw new ApexModelException("Unable to write Apex concept as JSON", ioe);
+ }
- /**
- * Sets the validation flag.
- *
- * @param validateFlag the validation flag value
- */
- public void setValidateFlag(final boolean validateFlag) {
- this.validateFlag = validateFlag;
+ LOGGER.debug("wrote Apex concept JSON");
}
}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexSchemaGenerator.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexSchemaGenerator.java
deleted file mode 100644
index d5f34785b..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexSchemaGenerator.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020-2021 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.handling;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.io.StringWriter;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.SchemaOutputResolver;
-import javax.xml.transform.Result;
-import javax.xml.transform.stream.StreamResult;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-/**
- * This class generates the XML model schema from the given Apex concept classes.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class ApexSchemaGenerator {
- // Get a reference to the logger
- private static final XLogger LOGGER = XLoggerFactory.getXLogger(ApexSchemaGenerator.class);
-
- /**
- * A Main method to allow schema generation from the command line or from maven or scripts.
- *
- * @param args the command line arguments, usage is {@code ApexSchemaGenerator apex-root-class [schema-file-name]}
- */
- public static void main(final String[] args) {
- PrintStream printStream = null;
-
- if (args.length == 1) {
- printStream = System.out;
- } else if (args.length == 2) {
- final var schemaFile = new File(args[1]);
-
- try {
- schemaFile.getParentFile().mkdirs();
- printStream = new PrintStream(schemaFile);
- } catch (final Exception e) {
- LOGGER.error("error on Apex schema output", e);
- return;
- }
- } else {
- LOGGER.error("usage: ApexSchemaGenerator apex-root-class [schema-file-name]");
- return;
- }
-
- // Get the schema
- final String schema = new ApexSchemaGenerator().generate(args[0]);
-
- // Output the schema
- printStream.println(schema);
-
- printStream.close();
- }
-
- /**
- * Generates the XML schema (XSD) for the Apex model described using JAXB annotations.
- *
- * @param rootClassName the name of the root class for schema generation
- * @return The schema
- */
- public String generate(final String rootClassName) {
- JAXBContext jaxbContext;
- try {
- jaxbContext = JAXBContext.newInstance(Class.forName(rootClassName));
- } catch (final ClassNotFoundException e) {
- LOGGER.error("could not create JAXB context, root class " + rootClassName + " not found", e);
- return null;
- } catch (final JAXBException e) {
- LOGGER.error("could not create JAXB context", e);
- return null;
- }
-
- final var sor = new ApexSchemaOutputResolver();
- try {
- jaxbContext.generateSchema(sor);
- } catch (final IOException e) {
- LOGGER.error("error generating the Apex schema (XSD) file", e);
- return null;
- }
-
- var schemaString = sor.getSchema();
- schemaString = fixForUnqualifiedBug(schemaString);
-
- return schemaString;
- }
-
- /**
- * There is a bug in schema generation that does not specify the elements from Java Maps as being unqualified. This
- * method "hacks" those elements in the schema to fix this, the elements being {@code entry}, {@code key}, and
- * {@code value}
- *
- * @param schemaString The schema in which elements should be fixed
- * @return the string
- */
- private String fixForUnqualifiedBug(final String schemaString) {
- // Fix the "entry" element
- var newSchemaString = schemaString.replace(
- "<xs:element name=\"entry\" minOccurs=\"0\" maxOccurs=\"unbounded\">",
- "<xs:element name=\"entry\" minOccurs=\"0\" maxOccurs=\"unbounded\" form=\"unqualified\">");
-
- // Fix the "key" element
- newSchemaString = newSchemaString.replace("<xs:element name=\"key\"",
- "<xs:element name=\"key\" form=\"unqualified\"");
-
- // Fix the "value" element
- newSchemaString = newSchemaString.replace("<xs:element name=\"value\"",
- "<xs:element name=\"value\" form=\"unqualified\"");
-
- return newSchemaString;
- }
-
- /**
- * This inner class is used to receive the output of schema generation from the JAXB schema generator.
- */
- private class ApexSchemaOutputResolver extends SchemaOutputResolver {
- private final StringWriter stringWriter = new StringWriter();
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public Result createOutput(final String namespaceUri, final String suggestedFileName) throws IOException {
- final var result = new StreamResult(stringWriter);
- result.setSystemId(suggestedFileName);
- return result;
- }
-
- /**
- * Get the schema from the string writer.
- *
- * @return the schema generated by JAXB
- */
- public String getSchema() {
- return stringWriter.toString();
- }
- }
-}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/KeyInfoMarshalFilter.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/KeyInfoMarshalFilter.java
deleted file mode 100644
index cfc385d01..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/KeyInfoMarshalFilter.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.handling;
-
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-import javax.xml.bind.annotation.adapters.XmlAdapter;
-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;
-
-/**
- * This class implements a filter to prevent some keyinfo information being marshalled when a model is serialised.
- */
-public class KeyInfoMarshalFilter extends XmlAdapter<AxKeyInformation, AxKeyInformation> {
-
- private List<AxKey> filterList = new LinkedList<>();
-
- /**
- * Adds a key to the list to be filtered.
- *
- * @param key the key to add to the filter list
- */
- public void addFilterKey(AxKey key) {
- filterList.add(key);
- }
-
- /**
- * Remove a key from the list to be filtered.
- *
- * @param key the key to remove from the filter list
- * @return true if the passed key was in the filter list and has been removed.
- */
- public boolean removeFilterKey(AxKey key) {
- return filterList.remove(key);
- }
-
- /**
- * Adds some keys to the list to be filtered.
- *
- * @param keys the keys to add to the filter list
- */
- public void addFilterKeys(Collection<? extends AxKey> keys) {
- filterList.addAll(keys);
- }
-
- /**
- * Decide whether to unmarshall some keyinfos - Always.
- *
- * @param val the keyinfo
- * @return the keyinfo
- * @throws Exception if there is some problem unmarshalling
- * @see javax.xml.bind.annotation.adapters.XmlAdapter#unmarshal(Object)
- */
- @Override
- public AxKeyInformation unmarshal(AxKeyInformation val) throws Exception {
- return val;
- }
-
- /**
- * Select which keyinfo entries will be marshalled - i.e. those not in the filter list.
- *
- * @param val the keyinfo
- * @return the keyinfo
- * @throws Exception if there is some problem with the marshalling
- * @see javax.xml.bind.annotation.adapters.XmlAdapter#marshal(Object)
- */
- @Override
- public AxKeyInformation marshal(AxKeyInformation val) throws Exception {
- if (val == null || val.getKeyInfoMap() == null || val.getKeyInfoMap().isEmpty() || filterList.isEmpty()) {
- return val;
- }
- //create a new keyinfo clone to avoid removing keyinfo entries from the original model
- AxKeyInformation ret = new AxKeyInformation(val);
- Map<AxArtifactKey, AxKeyInfo> retmap = new TreeMap<>(ret.getKeyInfoMap());
- for (AxKey key : filterList) {
- retmap.remove(key);
- }
- ret.setKeyInfoMap(retmap);
- return ret;
- }
-}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/package-info.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/package-info.java
index 081cff540..3d6dab3b2 100644
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/package-info.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/package-info.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,20 +18,4 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
-/**
- * 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.onap.org/policy/apex-pdp", elementFormDefault = XmlNsForm.QUALIFIED,
- xmlns = { @XmlNs(namespaceURI = "http://www.onap.org/policy/apex-pdp", prefix = "") })
-
package org.onap.policy.apex.model.basicmodel.handling;
-
-import javax.xml.bind.annotation.XmlNs;
-import javax.xml.bind.annotation.XmlNsForm;
-import javax.xml.bind.annotation.XmlSchema;
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/package-info.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/package-info.java
index e540646d9..8ad405e25 100644
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/package-info.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/package-info.java
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019,2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,7 +24,7 @@
* the model for APEX concepts anywhere in the system.
*
* <p>It also provides handling support to models, allowing them to be read and written to file and databases in JSON
- * and XML format.
+ * format.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/test/TestApexModel.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/test/TestApexModel.java
index 5dbf69492..9dde47d05 100644
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/test/TestApexModel.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/test/TestApexModel.java
@@ -44,7 +44,7 @@ import org.slf4j.ext.XLoggerFactory;
public class TestApexModel<M extends AxModel> {
private static final String MODEL_IS_INVALID = "model is invalid ";
private static final String ERROR_PROCESSING_FILE = "error processing file ";
- private static final String TEST_MODEL_UNEQUAL_STR = "test model does not equal model read from XML file ";
+ private static final String TEST_MODEL_UNEQUAL_STR = "test model does not equal model read from file ";
private static final String TEMP_FILE_CREATE_ERR_STR = "error creating temporary file for Apex model";
private static final XLogger LOGGER = XLoggerFactory.getXLogger(TestApexModel.class);
@@ -77,55 +77,6 @@ public class TestApexModel<M extends AxModel> {
}
/**
- * Test write and read in XML format.
- *
- * @throws ApexException on write/read errors
- */
- public final void testApexModelWriteReadXml() throws ApexException {
- LOGGER.debug("running testApexModelWriteReadXML . . .");
-
- final var model = modelCreator.getModel();
-
- // Write the file to disk
- File xmlFile;
-
- try {
- xmlFile = File.createTempFile("ApexModel", ".xml");
- xmlFile.deleteOnExit();
- } catch (final Exception e) {
- LOGGER.warn(TEMP_FILE_CREATE_ERR_STR, e);
- throw new ApexException(TEMP_FILE_CREATE_ERR_STR, e);
- }
- new ApexModelFileWriter<M>(true).apexModelWriteXmlFile(model, rootModelClass, xmlFile.getPath());
-
- // Read the file from disk
- final ApexModelReader<M> modelReader = new ApexModelReader<>(rootModelClass);
-
- try {
- final var apexModelUrl = ResourceUtils.getLocalFile(xmlFile.getAbsolutePath());
- final var fileModel = modelReader.read(apexModelUrl.openStream());
- checkModelEquality(model, fileModel, TEST_MODEL_UNEQUAL_STR + xmlFile.getAbsolutePath());
- } catch (final Exception e) {
- LOGGER.warn(ERROR_PROCESSING_FILE + xmlFile.getAbsolutePath(), e);
- throw new ApexException(ERROR_PROCESSING_FILE + xmlFile.getAbsolutePath(), e);
- }
-
- final ApexModelWriter<M> modelWriter = new ApexModelWriter<>(rootModelClass);
- modelWriter.getCDataFieldSet().add("description");
- modelWriter.getCDataFieldSet().add("logic");
- modelWriter.getCDataFieldSet().add("uiLogic");
-
- final var baOutputStream = new ByteArrayOutputStream();
- modelWriter.write(model, baOutputStream);
- final var baInputStream = new ByteArrayInputStream(baOutputStream.toByteArray());
- final var byteArrayModel = modelReader.read(baInputStream);
-
- checkModelEquality(model, byteArrayModel, "test model does not equal XML marshalled and unmarshalled model");
-
- LOGGER.debug("ran testApexModelWriteReadXML");
- }
-
- /**
* Test write and read in JSON format.
*
* @throws ApexException on write/read errors
@@ -138,7 +89,7 @@ public class TestApexModel<M extends AxModel> {
// Write the file to disk
File jsonFile;
try {
- jsonFile = File.createTempFile("ApexModel", ".xml");
+ jsonFile = File.createTempFile("ApexModel", ".json");
jsonFile.deleteOnExit();
} catch (final Exception e) {
LOGGER.warn(TEMP_FILE_CREATE_ERR_STR, e);
@@ -159,7 +110,6 @@ public class TestApexModel<M extends AxModel> {
}
final ApexModelWriter<M> modelWriter = new ApexModelWriter<>(rootModelClass);
- modelWriter.setJsonOutput(true);
final var baOutputStream = new ByteArrayOutputStream();
modelWriter.write(model, baOutputStream);
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/xml/AxReferenceKeyAdapter.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/xml/AxReferenceKeyAdapter.java
deleted file mode 100644
index 8515f5724..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/xml/AxReferenceKeyAdapter.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.xml;
-
-import java.io.Serializable;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlType;
-import javax.xml.bind.annotation.adapters.XmlAdapter;
-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.
- */
-@XmlAccessorType(XmlAccessType.PROPERTY)
-@XmlType(namespace = "http://www.onap.org/policy/apex-pdp")
-public class AxReferenceKeyAdapter extends XmlAdapter<String, AxReferenceKey> implements Serializable {
-
- private static final long serialVersionUID = -3480405083900107029L;
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public final String marshal(final AxReferenceKey key) throws Exception {
- return key.getLocalName();
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public final AxReferenceKey unmarshal(final String key) throws Exception {
- final var axReferenceKey = new AxReferenceKey();
- axReferenceKey.setLocalName(key);
- return axReferenceKey;
- }
-}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/xml/package-info.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/xml/package-info.java
deleted file mode 100644
index 290209d89..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/xml/package-info.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-/**
- * Contains utility classes for managing marshaling and unmarshaling of APEX models using JAXB.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-
-@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.policy.apex.model.basicmodel.xml;
-
-import javax.xml.bind.annotation.XmlNs;
-import javax.xml.bind.annotation.XmlNsForm;
-import javax.xml.bind.annotation.XmlSchema;
diff --git a/model/basic-model/src/main/resources/xml/example.xsd b/model/basic-model/src/main/resources/xml/example.xsd
deleted file mode 100644
index 75ecdc323..000000000
--- a/model/basic-model/src/main/resources/xml/example.xsd
+++ /dev/null
@@ -1,100 +0,0 @@
-<?xml version="1.0" standalone="yes"?>
-<!--
- ============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=========================================================
--->
-<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"/>
-
- <xs:element name="apexKeyInfo" type="AxKeyInfo"/>
-
- <xs:element name="apexModel" type="AxModel"/>
-
- <xs:complexType name="AxModel">
- <xs:complexContent>
- <xs:extension base="AxConcept">
- <xs:sequence>
- <xs:element name="key" form="unqualified" type="AxArtifactKey"/>
- <xs:element name="keyInformation" type="AxKeyInformation"/>
- </xs:sequence>
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
-
- <xs:complexType name="AxConcept" abstract="true">
- <xs:sequence/>
- </xs:complexType>
-
- <xs:complexType name="AxArtifactKey">
- <xs:complexContent>
- <xs:extension base="axKey">
- <xs:sequence>
- <xs:element name="name" type="xs:string"/>
- <xs:element name="version" type="xs:string"/>
- </xs:sequence>
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
-
- <xs:complexType name="axKey" abstract="true">
- <xs:complexContent>
- <xs:extension base="AxConcept">
- <xs:sequence/>
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
-
- <xs:complexType name="AxKeyInformation">
- <xs:complexContent>
- <xs:extension base="AxConcept">
- <xs:sequence>
- <xs:element name="key" form="unqualified" type="AxArtifactKey"/>
- <xs:element name="keyInfoMap">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="entry" minOccurs="0" maxOccurs="unbounded" form="unqualified">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="key" form="unqualified" minOccurs="0" type="AxArtifactKey"/>
- <xs:element name="value" form="unqualified" minOccurs="0" type="AxKeyInfo"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
-
- <xs:complexType name="AxKeyInfo">
- <xs:complexContent>
- <xs:extension base="AxConcept">
- <xs:sequence>
- <xs:element name="key" form="unqualified" type="AxArtifactKey"/>
- <xs:element name="UUID" type="xs:string"/>
- <xs:element name="description" type="xs:string"/>
- </xs:sequence>
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
-</xs:schema>
-
-
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/DummyEntity.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/DummyEntity.java
index cd8b52ce6..2b16e89ed 100644
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/DummyEntity.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/DummyEntity.java
@@ -23,17 +23,11 @@ package org.onap.policy.apex.model.basicmodel.concepts;
import java.util.Arrays;
import java.util.List;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-import org.onap.policy.apex.model.basicmodel.xml.AxReferenceKeyAdapter;
public class DummyEntity extends AxConcept {
private static final long serialVersionUID = -2962570563281067894L;
- @XmlElement(name = "key", required = true)
- @XmlJavaTypeAdapter(AxReferenceKeyAdapter.class)
protected AxReferenceKey key;
-
private double doubleValue;
public DummyEntity() {
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelFileWriterTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelFileWriterTest.java
index 331e57f47..0f8f956ab 100644
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelFileWriterTest.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelFileWriterTest.java
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2020,2022 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,33 +36,27 @@ public class ApexModelFileWriterTest {
public void testModelFileWriter() throws IOException, ApexException {
ApexModelFileWriter<AxModel> modelFileWriter = new ApexModelFileWriter<>(true);
- modelFileWriter.setValidateFlag(true);
- assertTrue(modelFileWriter.isValidateFlag());
+ modelFileWriter.setValidate(true);
+ assertTrue(modelFileWriter.isValidate());
File tempFile = File.createTempFile("ApexFileWriterTest", "test");
File tempDir = tempFile.getParentFile();
File jsonTempFile = new File(tempDir.getAbsolutePath() + "/aaa/ApexFileWriterTest.json");
- File xmlTempFile = new File(tempDir.getAbsolutePath() + "/ccc/ApexFileWriterTest.xml");
AxModel model = new DummyApexBasicModelCreator().getModel();
modelFileWriter.apexModelWriteJsonFile(model, AxModel.class, jsonTempFile.getAbsolutePath());
- modelFileWriter.apexModelWriteXmlFile(model, AxModel.class, xmlTempFile.getAbsolutePath());
jsonTempFile.delete();
- xmlTempFile.delete();
new File(tempDir.getAbsolutePath() + "/aaa").delete();
new File(tempDir.getAbsolutePath() + "/ccc").delete();
jsonTempFile = new File(tempDir.getAbsolutePath() + "/aaa/bbb/ApexFileWriterTest.json");
- xmlTempFile = new File(tempDir.getAbsolutePath() + "/ccc/ddd/ApexFileWriterTest.xml");
modelFileWriter.apexModelWriteJsonFile(model, AxModel.class, jsonTempFile.getAbsolutePath());
- modelFileWriter.apexModelWriteXmlFile(model, AxModel.class, xmlTempFile.getAbsolutePath());
jsonTempFile.delete();
- xmlTempFile.delete();
new File(tempDir.getAbsolutePath() + "/aaa/bbb").delete();
new File(tempDir.getAbsolutePath() + "/aaa").delete();
@@ -70,19 +64,14 @@ public class ApexModelFileWriterTest {
new File(tempDir.getAbsolutePath() + "/ccc").delete();
File dirA = new File(tempDir.getAbsolutePath() + "/aaa");
- //File dirB = new File(tempDir.getAbsolutePath() + "/aaa/bbb");
+ // File dirB = new File(tempDir.getAbsolutePath() + "/aaa/bbb");
dirA.createNewFile();
- //dirB.createNewFile();
+ // dirB.createNewFile();
jsonTempFile = new File(tempDir.getAbsolutePath() + "/aaa/bbb/ApexFileWriterTest.json");
- jsonTempFile = new File(tempDir.getAbsolutePath() + "/aaa/bbb/ApexFileWriterTest.xml");
final File jsonTempFile01 = jsonTempFile;
- assertThatThrownBy(() -> modelFileWriter.apexModelWriteJsonFile(model, AxModel.class,
- jsonTempFile01.getAbsolutePath()))
- .hasMessageContaining("could not create directory");
-
- assertThatThrownBy(() -> modelFileWriter.apexModelWriteXmlFile(model, AxModel.class,
- jsonTempFile01.getAbsolutePath()))
+ assertThatThrownBy(
+ () -> modelFileWriter.apexModelWriteJsonFile(model, AxModel.class, jsonTempFile01.getAbsolutePath()))
.hasMessageContaining("could not create directory");
dirA.delete();
@@ -93,15 +82,10 @@ public class ApexModelFileWriterTest {
fileB.createNewFile();
jsonTempFile = new File(tempDir.getAbsolutePath() + "/aaa/bbb/ApexFileWriterTest.json");
- jsonTempFile = new File(tempDir.getAbsolutePath() + "/aaa/bbb/ApexFileWriterTest.xml");
File jsonTempFile02 = jsonTempFile;
- assertThatThrownBy(() -> modelFileWriter.apexModelWriteJsonFile(model, AxModel.class,
- jsonTempFile02.getAbsolutePath()))
- .hasMessageContaining("error processing file");
-
- assertThatThrownBy(() -> modelFileWriter.apexModelWriteXmlFile(model, AxModel.class,
- jsonTempFile02.getAbsolutePath()))
+ assertThatThrownBy(
+ () -> modelFileWriter.apexModelWriteJsonFile(model, AxModel.class, jsonTempFile02.getAbsolutePath()))
.hasMessageContaining("error processing file");
fileB.delete();
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelReaderTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelReaderTest.java
index d75f20253..1152771ea 100644
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelReaderTest.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelReaderTest.java
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2020,2022 Nordix Foundation
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -34,45 +34,33 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
-import java.lang.reflect.Field;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.PropertyException;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.transform.stream.StreamSource;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
import org.mockito.runners.MockitoJUnitRunner;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.concepts.AxModel;
@RunWith(MockitoJUnitRunner.class)
public class ApexModelReaderTest {
- @Mock
- private Unmarshaller unmarshallerMock;
-
@Test
public void testModelReader() throws IOException, ApexException {
AxModel model = new DummyApexBasicModelCreator().getModel();
AxModel invalidModel = new DummyApexBasicModelCreator().getInvalidModel();
ApexModelWriter<AxModel> modelWriter = new ApexModelWriter<AxModel>(AxModel.class);
- modelWriter.setValidateFlag(true);
- modelWriter.setJsonOutput(true);
+ modelWriter.setValidate(true);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
modelWriter.write(model, baos);
ByteArrayOutputStream baosInvalid = new ByteArrayOutputStream();
- modelWriter.setValidateFlag(false);
+ modelWriter.setValidate(false);
modelWriter.write(invalidModel, baosInvalid);
ApexModelReader<AxModel> modelReader = new ApexModelReader<AxModel>(AxModel.class, true);
- modelReader.setValidateFlag(true);
- assertTrue(modelReader.getValidateFlag());
+ modelReader.setValidate(true);
+ assertTrue(modelReader.isValidate());
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
AxModel readModel = modelReader.read(bais);
@@ -81,26 +69,24 @@ public class ApexModelReaderTest {
ByteArrayInputStream baisInvalid = new ByteArrayInputStream(baosInvalid.toByteArray());
assertThatThrownBy(() -> modelReader.read(baisInvalid))
.hasMessageStartingWith("Apex concept validation failed");
- modelReader.setValidateFlag(false);
- assertFalse(modelReader.getValidateFlag());
+ modelReader.setValidate(false);
+ assertFalse(modelReader.isValidate());
ByteArrayInputStream bais2 = new ByteArrayInputStream(baos.toByteArray());
AxModel readModel2 = modelReader.read(bais2);
assertEquals(model, readModel2);
- modelWriter.setJsonOutput(false);
-
- ByteArrayOutputStream baosXml = new ByteArrayOutputStream();
- modelWriter.write(model, baosXml);
+ ByteArrayOutputStream baosJson = new ByteArrayOutputStream();
+ modelWriter.write(model, baosJson);
- ByteArrayInputStream baisXml = new ByteArrayInputStream(baosXml.toByteArray());
- AxModel readModelXml = modelReader.read(baisXml);
- assertEquals(model, readModelXml);
+ ByteArrayInputStream baisJson = new ByteArrayInputStream(baosJson.toByteArray());
+ AxModel readModelJson = modelReader.read(baisJson);
+ assertEquals(model, readModelJson);
String dummyString = "SomeDummyText";
ByteArrayInputStream baisDummy = new ByteArrayInputStream(dummyString.getBytes());
assertThatThrownBy(() -> modelReader.read(baisDummy))
- .hasMessage("format of input for Apex concept is neither JSON nor XML");
+ .hasMessageContaining("Unable to unmarshal Apex concept");
ByteArrayInputStream nullBais = null;
assertThatThrownBy(() -> modelReader.read(nullBais))
.hasMessage("concept stream may not be null");
@@ -115,42 +101,5 @@ public class ApexModelReaderTest {
assertThatThrownBy(() -> modelReader.read(br))
.hasMessage("Unable to read Apex concept ");
tempFile.delete();
- modelReader.setSchema(null);
-
- final File tempFileA = File.createTempFile("Apex", "Dummy");
- assertThatThrownBy(() -> modelReader.setSchema(tempFileA.getCanonicalPath()))
- .hasMessage("Unable to load schema");
- tempFile.delete();
- modelReader.setSchema("xml/example.xsd");
- }
-
- @Test
- public void testSetInputTypeError() throws ApexModelException,
- NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
- MockitoAnnotations.initMocks(this);
-
- ApexModelReader<AxModel> modelReader = new ApexModelReader<AxModel>(AxModel.class, true);
-
- Field marshallerField = modelReader.getClass().getDeclaredField("unmarshaller");
- marshallerField.setAccessible(true);
- marshallerField.set(modelReader, unmarshallerMock);
- marshallerField.setAccessible(false);
-
- assertThatThrownBy(() -> {
- Mockito.doThrow(new JAXBException("Exception marshalling to JSON")).when(unmarshallerMock)
- .unmarshal((StreamSource) Mockito.anyObject(), Mockito.anyObject());
-
- modelReader.read("{Hello}");
- }).hasMessage("Unable to unmarshal Apex concept ");
- assertThatThrownBy(() -> {
- Mockito.doThrow(new PropertyException("Exception setting JAXB property")).when(unmarshallerMock)
- .setProperty(Mockito.anyString(), Mockito.anyString());
- modelReader.read("{Hello}");
- }).hasMessage("JAXB error setting unmarshaller for JSON input");
- assertThatThrownBy(() -> {
- Mockito.doThrow(new PropertyException("Exception setting JAXB property")).when(unmarshallerMock)
- .setProperty(Mockito.anyString(), Mockito.anyString());
- modelReader.read("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
- }).hasMessage("JAXB error setting unmarshaller for XML input");
}
}
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelSaverTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelSaverTest.java
index ad897832e..c95106aa8 100644
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelSaverTest.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelSaverTest.java
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2020,2022 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -41,14 +41,12 @@ public class ApexModelSaverTest {
Path tempPath = Files.createTempDirectory("ApexTest");
assertNotNull(tempPath);
- ApexModelSaver<AxModel> modelSaver = new ApexModelSaver<AxModel>(AxModel.class, model,
- tempPath.toAbsolutePath().toString());
+ ApexModelSaver<AxModel> modelSaver =
+ new ApexModelSaver<AxModel>(AxModel.class, model, tempPath.toAbsolutePath().toString());
assertNotNull(modelSaver);
- modelSaver.apexModelWriteXml();
modelSaver.apexModelWriteJson();
Files.deleteIfExists(new File(tempPath.toAbsolutePath() + "/BasicModel.json").toPath());
- Files.deleteIfExists(new File(tempPath.toAbsolutePath() + "/BasicModel.xml").toPath());
Files.deleteIfExists(tempPath);
}
}
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelStringWriterTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelStringWriterTest.java
index 0b8d789ad..13e72d3e2 100644
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelStringWriterTest.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelStringWriterTest.java
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2020,2022 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,33 +38,26 @@ public class ApexModelStringWriterTest {
AxModel basicModel = new DummyApexBasicModelCreator().getModel();
assertNotNull(basicModel);
- AxKeyInfo intKeyInfo = basicModel.getKeyInformation().get("IntegerKIKey");
+ AxKeyInfo intKeyInfo = basicModel.getKeyInformation().get("IntegerKIKey");
AxKeyInfo floatKeyInfo = basicModel.getKeyInformation().get("FloatKIKey");
// Ensure marshalling is OK
ApexModelStringWriter<AxKeyInfo> stringWriter = new ApexModelStringWriter<AxKeyInfo>(true);
- assertNotNull(stringWriter.writeJsonString(intKeyInfo, AxKeyInfo.class));
+ assertNotNull(stringWriter.writeJsonString(intKeyInfo, AxKeyInfo.class));
assertNotNull(stringWriter.writeJsonString(floatKeyInfo, AxKeyInfo.class));
- assertNotNull(stringWriter.writeString(intKeyInfo, AxKeyInfo.class, true));
- assertNotNull(stringWriter.writeString(floatKeyInfo, AxKeyInfo.class, true));
+ assertNotNull(stringWriter.writeString(intKeyInfo, AxKeyInfo.class));
+ assertNotNull(stringWriter.writeString(floatKeyInfo, AxKeyInfo.class));
- assertNotNull(stringWriter.writeString(intKeyInfo, AxKeyInfo.class, false));
- assertNotNull(stringWriter.writeString(floatKeyInfo, AxKeyInfo.class, false));
+ assertNotNull(stringWriter.writeString(intKeyInfo, AxKeyInfo.class));
+ assertNotNull(stringWriter.writeString(floatKeyInfo, AxKeyInfo.class));
- assertNotNull(stringWriter.writeXmlString(intKeyInfo, AxKeyInfo.class));
- assertNotNull(stringWriter.writeXmlString(floatKeyInfo, AxKeyInfo.class));
-
- assertThatThrownBy(() -> stringWriter.writeString(null, AxKeyInfo.class, true))
- .hasMessage("concept may not be null");
- assertThatThrownBy(() -> stringWriter.writeString(null, AxKeyInfo.class, false))
- .hasMessage("concept may not be null");
+ assertThatThrownBy(() -> stringWriter.writeString(null, AxKeyInfo.class)).hasMessage("concept may not be null");
+ assertThatThrownBy(() -> stringWriter.writeString(null, AxKeyInfo.class)).hasMessage("concept may not be null");
assertThatThrownBy(() -> stringWriter.writeJsonString(null, AxKeyInfo.class))
.hasMessage("error writing JSON string");
- assertThatThrownBy(() -> stringWriter.writeXmlString(null, AxKeyInfo.class))
- .hasMessage("error writing XML string");
- stringWriter.setValidateFlag(true);
- assertTrue(stringWriter.isValidateFlag());
+ stringWriter.setValidate(true);
+ assertTrue(stringWriter.isValidate());
}
}
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelWriterTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelWriterTest.java
index 147eb206a..063855976 100644
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelWriterTest.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelWriterTest.java
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2020,2022 Nordix Foundation
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,65 +23,38 @@
package org.onap.policy.apex.model.basicmodel.handling;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
-import java.io.Writer;
-import java.lang.reflect.Field;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
-import javax.xml.bind.PropertyException;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
import org.mockito.runners.MockitoJUnitRunner;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.concepts.AxModel;
-import org.w3c.dom.Document;
@RunWith(MockitoJUnitRunner.class)
public class ApexModelWriterTest {
- @Mock
- private Marshaller marshallerMock;
-
@Test
public void testModelWriter() throws IOException, ApexException {
ApexModelWriter<AxModel> modelWriter = new ApexModelWriter<AxModel>(AxModel.class);
- modelWriter.setValidateFlag(true);
- assertTrue(modelWriter.getValidateFlag());
- assertEquals(0, modelWriter.getCDataFieldSet().size());
-
- assertFalse(modelWriter.isJsonOutput());
- modelWriter.setJsonOutput(true);
- assertTrue(modelWriter.isJsonOutput());
- modelWriter.setJsonOutput(false);
- assertFalse(modelWriter.isJsonOutput());
+ modelWriter.setValidate(true);
+ assertTrue(modelWriter.isValidate());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
AxModel model = new DummyApexBasicModelCreator().getModel();
modelWriter.write(model, baos);
- modelWriter.setJsonOutput(true);
- modelWriter.write(model, baos);
- modelWriter.setJsonOutput(false);
- modelWriter.setValidateFlag(false);
+ modelWriter.setValidate(false);
modelWriter.write(model, baos);
- modelWriter.setJsonOutput(true);
- modelWriter.write(model, baos);
- modelWriter.setJsonOutput(false);
- modelWriter.setValidateFlag(true);
+ modelWriter.setValidate(true);
model.getKeyInformation().getKeyInfoMap().clear();
assertThatThrownBy(() -> modelWriter.write(model, baos))
- .hasMessageContaining("Apex concept xml (BasicModel:0.0.1) validation failed");
+ .hasMessageContaining("Apex concept (BasicModel:0.0.1) validation failed");
model.getKeyInformation().generateKeyInfo(model);
assertThatThrownBy(() -> modelWriter.write(null, baos))
@@ -91,73 +64,4 @@ public class ApexModelWriterTest {
assertThatThrownBy(() -> modelWriter.write(model, nullBaos))
.hasMessage("concept stream may not be null");
}
-
- @Test
- public void testSetOutputTypeError() throws ApexModelException, NoSuchFieldException, SecurityException,
- IllegalArgumentException, IllegalAccessException, PropertyException {
- MockitoAnnotations.initMocks(this);
-
- ApexModelWriter<AxModel> modelWriter = new ApexModelWriter<AxModel>(AxModel.class);
-
- Field marshallerField = modelWriter.getClass().getDeclaredField("marshaller");
- marshallerField.setAccessible(true);
- marshallerField.set(modelWriter, marshallerMock);
- marshallerField.setAccessible(false);
- Mockito.doThrow(new PropertyException("Exception setting JAXB property")).when(marshallerMock)
- .setProperty(Mockito.anyString(), Mockito.anyString());
- assertThatThrownBy(() -> modelWriter.setJsonOutput(true))
- .hasMessage("JAXB error setting marshaller for JSON output");
- Mockito.doThrow(new PropertyException("Exception setting JAXB property")).when(marshallerMock)
- .setProperty(Mockito.anyString(), Mockito.anyString());
- assertThatThrownBy(() -> modelWriter.setJsonOutput(false))
- .hasMessage("JAXB error setting marshaller for XML output");
- }
-
- @Test
- public void testOutputJsonError() throws ApexModelException, NoSuchFieldException, SecurityException,
- IllegalArgumentException, IllegalAccessException, JAXBException {
- MockitoAnnotations.initMocks(this);
-
- ApexModelWriter<AxModel> modelWriter = new ApexModelWriter<AxModel>(AxModel.class);
-
- Field marshallerField = modelWriter.getClass().getDeclaredField("marshaller");
- marshallerField.setAccessible(true);
- marshallerField.set(modelWriter, marshallerMock);
- marshallerField.setAccessible(false);
-
- modelWriter.setValidateFlag(false);
- modelWriter.setJsonOutput(true);
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- AxModel model = new DummyApexBasicModelCreator().getModel();
- Mockito.doThrow(new JAXBException("Exception marshalling to JSON")).when(marshallerMock)
- .marshal((AxModel) Mockito.anyObject(), (Writer) Mockito.anyObject());
- assertThatThrownBy(() -> modelWriter.write(model, baos)).hasMessage("Unable to marshal Apex concept to JSON");
- }
-
- @Test
- public void testOutputXmlError() throws ApexModelException, NoSuchFieldException, SecurityException,
- IllegalArgumentException, IllegalAccessException, JAXBException {
- MockitoAnnotations.initMocks(this);
-
- ApexModelWriter<AxModel> modelWriter = new ApexModelWriter<AxModel>(AxModel.class);
- modelWriter.setJsonOutput(false);
-
- Field marshallerField = modelWriter.getClass().getDeclaredField("marshaller");
- marshallerField.setAccessible(true);
- marshallerField.set(modelWriter, marshallerMock);
- marshallerField.setAccessible(false);
-
- modelWriter.setValidateFlag(false);
- modelWriter.setJsonOutput(false);
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- AxModel model = new DummyApexBasicModelCreator().getModel();
-
- Mockito.doThrow(new JAXBException("Exception marshalling to JSON")).when(marshallerMock)
- .marshal((AxModel) Mockito.anyObject(), (Document) Mockito.anyObject());
-
- assertThatThrownBy(() -> modelWriter.write(model, baos))
- .hasMessage("Unable to marshal Apex concept to XML");
- }
}
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexSchemaGeneratorTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexSchemaGeneratorTest.java
deleted file mode 100644
index 3385830e2..000000000
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexSchemaGeneratorTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.handling;
-
-import static org.junit.Assert.assertTrue;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileDescriptor;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-import org.junit.After;
-import org.junit.Test;
-
-public class ApexSchemaGeneratorTest {
- private final PrintStream stdout = System.out;
-
- @After
- public void tearDown() throws Exception {
- System.setOut(stdout);
- }
-
- @Test
- 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" };
- 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" };
- 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" };
- 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.policy.apex.model.basicmodel.concepts.AxModel" };
- ApexSchemaGenerator.main(args4);
- 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");
- tempFile.deleteOnExit();
- final String[] args5 =
- { "org.onap.policy.apex.model.basicmodel.concepts.AxModel", tempFile.getCanonicalPath() };
-
- ApexSchemaGenerator.main(args5);
- assertTrue(tempFile.length() > 100);
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTest.java
index bb9776fc7..68f755886 100644
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTest.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTest.java
@@ -110,11 +110,6 @@ public class SupportApexBasicModelTest {
}
@Test
- public void testModelWriteReadXml() throws Exception {
- testApexModel.testApexModelWriteReadXml();
- }
-
- @Test
public void testModelWriteReadJson() throws Exception {
testApexModel.testApexModelWriteReadJson();
}
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportBasicModelTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportBasicModelTest.java
index 5fc678ac0..d55a9da29 100644
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportBasicModelTest.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportBasicModelTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020-2021 Nordix Foundation
+ * Modifications Copyright (C) 2020-2022 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -43,7 +43,6 @@ public class SupportBasicModelTest {
testApexModel.testApexModelVaidateMalstructured();
testApexModel.testApexModelWriteReadJson();
- testApexModel.testApexModelWriteReadXml();
}
@Test
@@ -102,14 +101,11 @@ public class SupportBasicModelTest {
}
@Test
- public void testModelCreator1XmlJson() throws ApexException {
+ public void testModelCreator1Json() throws ApexException {
final TestApexModel<AxModel> testApexModel = new TestApexModel<AxModel>(AxModel.class,
new SupportApexModelCreator1());
assertThatThrownBy(() -> testApexModel.testApexModelWriteReadJson())
.hasMessageStartingWith("error processing file");
-
- assertThatThrownBy(() -> testApexModel.testApexModelWriteReadXml())
- .hasMessageStartingWith("error processing file");
}
}
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportConceptGetterTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportConceptGetterTest.java
index 006c583ec..1783fc00f 100644
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportConceptGetterTest.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportConceptGetterTest.java
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2020-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -156,19 +156,19 @@ public class SupportConceptGetterTest {
ApexModelReader<AxModel> modelReader = new ApexModelReader<AxModel>(AxModel.class);
ApexModelFileWriter<AxModel> modelWriter = new ApexModelFileWriter<AxModel>(true);
- modelReader.setValidateFlag(false);
- modelWriter.setValidateFlag(false);
+ modelReader.setValidate(false);
+ modelWriter.setValidate(false);
- File tempXmlFile = File.createTempFile("ApexModel", "xml");
- modelWriter.apexModelWriteJsonFile(basicModel, AxModel.class, tempXmlFile.getCanonicalPath());
+ File tempJsonFile = File.createTempFile("ApexModel", "json");
+ modelWriter.apexModelWriteJsonFile(basicModel, AxModel.class, tempJsonFile.getCanonicalPath());
- FileInputStream xmlFileInputStream = new FileInputStream(tempXmlFile);
- AxModel readXmlModel = modelReader.read(xmlFileInputStream);
- xmlFileInputStream.close();
- assertEquals(basicModel, readXmlModel);
- assertEquals(intKI91, readXmlModel.getKeyInformation().get("IntegerKIKey91"));
- assertNotNull(readXmlModel.getKeyInformation().get("FloatKIKey"));
- tempXmlFile.delete();
+ FileInputStream jsonFileInputStream = new FileInputStream(tempJsonFile);
+ AxModel readJsonModel = modelReader.read(jsonFileInputStream);
+ jsonFileInputStream.close();
+ assertEquals(basicModel, readJsonModel);
+ assertEquals(intKI91, readJsonModel.getKeyInformation().get("IntegerKIKey91"));
+ assertNotNull(readJsonModel.getKeyInformation().get("FloatKIKey"));
+ tempJsonFile.delete();
}
private AxModel setTestBasicModel() {
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/xml/AxReferenceKeyAdapterTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/xml/AxReferenceKeyAdapterTest.java
deleted file mode 100644
index 12a67c803..000000000
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/xml/AxReferenceKeyAdapterTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.xml;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import org.junit.Test;
-import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
-
-public class AxReferenceKeyAdapterTest {
-
- @Test
- public void test() throws Exception {
- AxReferenceKeyAdapter arka = new AxReferenceKeyAdapter();
- assertNotNull(arka);
-
- AxReferenceKey rkey = new AxReferenceKey("Name", "0.0.1", "PLN", "LN");
-
- String rkeyString = arka.marshal(rkey);
- assertEquals("LN", rkeyString);
- assertEquals(rkey.getLocalName(), arka.unmarshal(rkeyString).getLocalName());
- }
-}
diff --git a/model/context-model/pom.xml b/model/context-model/pom.xml
index f38067cfa..f20808186 100644
--- a/model/context-model/pom.xml
+++ b/model/context-model/pom.xml
@@ -1,6 +1,7 @@
<!--
============LICENSE_START=======================================================
Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ Modifications Copyright (C) 2022 Nordix Foundation.
================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -36,30 +37,4 @@
<version>${project.version}</version>
</dependency>
</dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>generate-xml-schema</id>
- <phase>process-classes</phase>
- <goals>
- <goal>java</goal>
- </goals>
- <configuration>
- <mainClass>org.onap.policy.apex.model.basicmodel.handling.ApexSchemaGenerator</mainClass>
- <classpathScope>compile</classpathScope>
- <arguments>
- <argument>org.onap.policy.apex.model.contextmodel.concepts.AxContextModel</argument>
- <argument>${project.build.directory}/model/xml/apex-context-model.xsd</argument>
- </arguments>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
</project>
diff --git a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbum.java b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbum.java
index d7d8a1d96..db64f8847 100644
--- a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbum.java
+++ b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbum.java
@@ -23,11 +23,6 @@
package org.onap.policy.apex.model.contextmodel.concepts;
import java.util.List;
-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 lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@@ -66,11 +61,6 @@ import org.onap.policy.common.utils.validation.Assertions;
@ToString
@EqualsAndHashCode(callSuper = false)
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlRootElement(name = "apexContextAlbum", namespace = "http://www.onap.org/policy/apex-pdp")
-@XmlType(name = "AxContextAlbum", namespace = "http://www.onap.org/policy/apex-pdp", propOrder =
- { "key", "scope", "isWritable", "itemSchema" })
-
public class AxContextAlbum extends AxConcept {
private static final String SCOPE_STRING = "scope";
@@ -84,17 +74,12 @@ public class AxContextAlbum extends AxConcept {
/** The value of scope for a context album for which a scope has not been specified. */
public static final String SCOPE_UNDEFINED = "UNDEFINED";
- @XmlElement(name = "key", required = true)
private AxArtifactKey key;
-
- @XmlElement(name = SCOPE_STRING, required = true)
private String scope;
- @XmlElement(name = "isWritable", required = true)
@Setter
private boolean isWritable;
- @XmlElement(name = "itemSchema", required = true)
private AxArtifactKey itemSchema;
/**
diff --git a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbums.java b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbums.java
index 65247ab80..54e3ce44b 100644
--- a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbums.java
+++ b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbums.java
@@ -28,11 +28,6 @@ import java.util.Map.Entry;
import java.util.NavigableMap;
import java.util.Set;
import java.util.TreeMap;
-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 lombok.AccessLevel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
@@ -61,18 +56,11 @@ import org.onap.policy.common.utils.validation.Assertions;
@Getter
@ToString
@EqualsAndHashCode(callSuper = false)
-
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "AxContextAlbums", namespace = "http://www.onap.org/policy/apex-pdp", propOrder =
- { "key", "albums" })
-
public final class AxContextAlbums extends AxConcept implements AxConceptGetter<AxContextAlbum> {
private static final long serialVersionUID = -4844259809024470975L;
- @XmlElement(name = "key", required = true)
private AxArtifactKey key;
- @XmlElement(name = "albums", required = true)
@Getter(AccessLevel.NONE)
private Map<AxArtifactKey, AxContextAlbum> albums;
@@ -120,25 +108,6 @@ public final class AxContextAlbums extends AxConcept implements AxConceptGetter<
}
/**
- * When a model is unmarshalled from disk or from the database, the context album 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 unmarsaller the unmarshaler that is unmarshaling the model
- * @param parent the parent object of this object in the unmarshaler
- */
- public void afterUnmarshal(final Unmarshaller unmarsaller, final Object parent) {
- Assertions.argumentNotNull(unmarsaller, "unmarsaller should not be null");
- Assertions.argumentNotNull(parent, "parent should not be null");
-
- // The map must be navigable to allow name and version searching, unmarshaling returns a
- // hash map
- final NavigableMap<AxArtifactKey, AxContextAlbum> navigableAlbums = new TreeMap<>();
- navigableAlbums.putAll(albums);
- albums = navigableAlbums;
- }
-
- /**
* {@inheritDoc}.
*/
@Override
@@ -153,6 +122,14 @@ public final class AxContextAlbums extends AxConcept implements AxConceptGetter<
}
/**
+ * {@inheritDoc}.
+ */
+ @Override
+ public void buildReferences() {
+ albums.values().stream().forEach(album -> album.buildReferences());
+ }
+
+ /**
* Sets the key of the context album container.
*
* @param key the context album container key
diff --git a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextModel.java b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextModel.java
index e17149336..1effe8079 100644
--- a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextModel.java
+++ b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextModel.java
@@ -23,11 +23,6 @@
package org.onap.policy.apex.model.contextmodel.concepts;
import java.util.List;
-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 lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
@@ -52,19 +47,10 @@ import org.onap.policy.common.utils.validation.Assertions;
@Getter
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
-
-@XmlRootElement(name = "apexContextModel", namespace = "http://www.onap.org/policy/apex-pdp")
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "AxContextModel", namespace = "http://www.onap.org/policy/apex-pdp",
- propOrder = { "schemas", "albums" })
-
public class AxContextModel extends AxModel {
private static final long serialVersionUID = 8800599637708309945L;
- @XmlElement(name = "schemas", required = true)
private AxContextSchemas schemas;
-
- @XmlElement(name = "albums", required = true)
private AxContextAlbums albums;
/**
diff --git a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchema.java b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchema.java
index a1560c07b..61434ca67 100644
--- a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchema.java
+++ b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchema.java
@@ -23,11 +23,6 @@
package org.onap.policy.apex.model.contextmodel.concepts;
import java.util.List;
-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 lombok.AccessLevel;
import lombok.Getter;
import lombok.ToString;
@@ -59,12 +54,6 @@ import org.onap.policy.common.utils.validation.Assertions;
*/
@Getter
@ToString
-
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlRootElement(name = "apexContextSchema", namespace = "http://www.onap.org/policy/apex-pdp")
-@XmlType(name = "AxContextSchema", namespace = "http://www.onap.org/policy/apex-pdp", propOrder =
- { "key", "schemaFlavour", "schemaDefinition" })
-
public class AxContextSchema extends AxConcept {
private static final String SCHEMA_FLAVOUR = "schemaFlavour";
private static final String WHITESPACE_REGEXP = "\\s+$";
@@ -80,13 +69,9 @@ public class AxContextSchema extends AxConcept {
/** The maximum permissible size of a schema definition. */
public static final int MAX_SCHEMA_SIZE = 32672; // The maximum size supported by Apache Derby
- @XmlElement(name = "key", required = true)
private AxArtifactKey key;
-
- @XmlElement(required = true)
private String schemaFlavour;
- @XmlElement(name = "schemaDefinition", required = true)
@Getter(AccessLevel.NONE)
private String schemaDefinition;
diff --git a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchemas.java b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchemas.java
index a5b56f244..5b79a3dcb 100644
--- a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchemas.java
+++ b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchemas.java
@@ -28,11 +28,6 @@ import java.util.Map.Entry;
import java.util.NavigableMap;
import java.util.Set;
import java.util.TreeMap;
-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 lombok.AccessLevel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
@@ -60,18 +55,11 @@ import org.onap.policy.common.utils.validation.Assertions;
@Getter
@ToString
@EqualsAndHashCode(callSuper = false)
-
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "AxContextSchemas", namespace = "http://www.onap.org/policy/apex-pdp", propOrder =
- { "key", "schemas" })
-
public class AxContextSchemas extends AxConcept implements AxConceptGetter<AxContextSchema> {
private static final long serialVersionUID = -3203734282886453582L;
- @XmlElement(name = "key", required = true)
private AxArtifactKey key;
- @XmlElement(name = "schemas", required = true)
@Getter(AccessLevel.NONE)
private Map<AxArtifactKey, AxContextSchema> schemas;
@@ -105,7 +93,7 @@ public class AxContextSchemas extends AxConcept implements AxConceptGetter<AxCon
/**
* This Constructor creates a {@link AxContextSchemas} object with all its fields defined.
*
- * @param key the key of the context schema container
+ * @param key the key of the context schema container
* @param schemas a map of the schemas to insert in the context schema container
*/
public AxContextSchemas(final AxArtifactKey key, final Map<AxArtifactKey, AxContextSchema> schemas) {
@@ -119,22 +107,6 @@ public class AxContextSchemas extends AxConcept implements AxConceptGetter<AxCon
}
/**
- * When a model is unmarshalled from disk or from the database, the context schema 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 unmarshaller the unmarshaler that is unmarshaling the model
- * @param parent the parent object of this object in the unmarshaler
- */
- public void afterUnmarshal(final Unmarshaller unmarshaller, final Object parent) {
- // The map must be navigable to allow name and version searching, unmarshaling returns a
- // hash map
- final NavigableMap<AxArtifactKey, AxContextSchema> navigableContextSchemas = new TreeMap<>();
- navigableContextSchemas.putAll(schemas);
- schemas = navigableContextSchemas;
- }
-
- /**
* {@inheritDoc}.
*/
@Override
@@ -146,6 +118,14 @@ public class AxContextSchemas extends AxConcept implements AxConceptGetter<AxCon
}
/**
+ * {@inheritDoc}.
+ */
+ @Override
+ public void buildReferences() {
+ schemas.values().stream().forEach(schema -> schema.buildReferences());
+ }
+
+ /**
* Sets the key of the context schema container.
*
* @param key the key of the container
@@ -185,30 +165,30 @@ public class AxContextSchemas extends AxConcept implements AxConceptGetter<AxCon
if (key.equals(AxArtifactKey.getNullKey())) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "key is a null key"));
+ "key is a null key"));
}
result = key.validate(result);
if (schemas.size() == 0) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "contextSchemas may not be empty"));
+ "contextSchemas may not be empty"));
} else {
for (final Entry<AxArtifactKey, AxContextSchema> contextSchemaEntry : schemas.entrySet()) {
if (contextSchemaEntry.getKey().equals(AxArtifactKey.getNullKey())) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "key on schemas entry " + contextSchemaEntry.getKey()
- + " may not be the null key"));
+ "key on schemas entry " + contextSchemaEntry.getKey()
+ + " may not be the null key"));
} else if (contextSchemaEntry.getValue() == null) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "value on schemas entry " + contextSchemaEntry.getKey() + " may not be null"));
+ "value on schemas entry " + contextSchemaEntry.getKey() + " may not be null"));
} else {
if (!contextSchemaEntry.getKey().equals(contextSchemaEntry.getValue().getKey())) {
result.addValidationMessage(
- new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "key on schemas entry " + contextSchemaEntry.getKey()
- + " does not equal entry key "
- + contextSchemaEntry.getValue().getKey()));
+ new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
+ "key on schemas entry " + contextSchemaEntry.getKey()
+ + " does not equal entry key "
+ + contextSchemaEntry.getValue().getKey()));
}
result = contextSchemaEntry.getValue().validate(result);
@@ -247,7 +227,7 @@ public class AxContextSchemas extends AxConcept implements AxConceptGetter<AxCon
final Map<AxArtifactKey, AxContextSchema> newcontextSchemas = new TreeMap<>();
for (final Entry<AxArtifactKey, AxContextSchema> contextSchemasEntry : schemas.entrySet()) {
newcontextSchemas.put(new AxArtifactKey(contextSchemasEntry.getKey()),
- new AxContextSchema(contextSchemasEntry.getValue()));
+ new AxContextSchema(contextSchemasEntry.getValue()));
}
copy.setSchemasMap(newcontextSchemas);
@@ -302,7 +282,7 @@ public class AxContextSchemas extends AxConcept implements AxConceptGetter<AxCon
@Override
public AxContextSchema get(final String conceptKeyName, final String conceptKeyVersion) {
return new AxConceptGetterImpl<>((NavigableMap<AxArtifactKey, AxContextSchema>) schemas).get(conceptKeyName,
- conceptKeyVersion);
+ conceptKeyVersion);
}
/**
@@ -319,6 +299,6 @@ public class AxContextSchemas extends AxConcept implements AxConceptGetter<AxCon
@Override
public Set<AxContextSchema> getAll(final String conceptKeyName, final String conceptKeyVersion) {
return new AxConceptGetterImpl<>((NavigableMap<AxArtifactKey, AxContextSchema>) schemas).getAll(conceptKeyName,
- conceptKeyVersion);
+ conceptKeyVersion);
}
}
diff --git a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/ApexContextModelTest.java b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/ApexContextModelTest.java
index a18065ed9..998469bac 100644
--- a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/ApexContextModelTest.java
+++ b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/ApexContextModelTest.java
@@ -118,11 +118,6 @@ public class ApexContextModelTest {
}
@Test
- public void testModelWriteReadXml() throws Exception {
- testApexModel.testApexModelWriteReadXml();
- }
-
- @Test
public void testModelWriteReadJson() throws Exception {
testApexModel.testApexModelWriteReadJson();
}
diff --git a/model/context-model/src/test/resources/json/ContextModel.json b/model/context-model/src/test/resources/json/ContextModel.json
deleted file mode 100644
index 2c93ef1c2..000000000
--- a/model/context-model/src/test/resources/json/ContextModel.json
+++ /dev/null
@@ -1,156 +0,0 @@
-{
- "apexContextModel" : {
- "key" : {
- "name" : "contextModel",
- "version" : "0.0.1"
- },
- "keyInformation" : {
- "key" : {
- "name" : "KeyInfoMapKey",
- "version" : "0.0.1"
- },
- "keyInfoMap" : {
- "keyInfoEntry" : [ {
- "key" : {
- "name" : "StringType",
- "version" : "0.0.1"
- },
- "UUID" : "00000000-0000-0000-0000-000000000000",
- "description" : "axContextType0"
- }, {
- "key" : {
- "name" : "MapType",
- "version" : "0.0.1"
- },
- "UUID" : "00000000-0000-0000-0000-000000000001",
- "description" : "axContextType1"
- }, {
- "key" : {
- "name" : "contextMap0",
- "version" : "0.0.1"
- },
- "UUID" : "00000000-0000-0000-0000-000000000002",
- "description" : "contextMap0"
- }, {
- "key" : {
- "name" : "contextMap1",
- "version" : "0.0.1"
- },
- "UUID" : "00000000-0000-0000-0000-000000000003",
- "description" : "contextMap1"
- }, {
- "key" : {
- "name" : "context",
- "version" : "0.0.1"
- },
- "UUID" : "00000000-0000-0000-0000-000000000004",
- "description" : "axContext"
- }, {
- "key" : {
- "name" : "contextModel",
- "version" : "0.0.1"
- },
- "UUID" : "00000000-0000-0000-0000-000000000005",
- "description" : "contextModel"
- }, {
- "key" : {
- "name" : "KeyInfoMapKey",
- "version" : "0.0.1"
- },
- "UUID" : "00000000-0000-0000-0000-000000000006",
- "description" : "keyInformation"
- } ]
- }
- },
- "context" : {
- "key" : {
- "name" : "context",
- "version" : "0.0.1"
- },
- "contextMaps" : {
- "entry" : [ {
- "key" : "contextMap0",
- "value" : {
- "key" : {
- "name" : "contextMap0",
- "version" : "0.0.1"
- },
- "scope" : "APPLICATION",
- "mapType" : "BAG",
- "contextMap" : {
- "contextItem" : [ {
- "key" : "axContextItem0_0",
- "contextType" : {
- "key" : {
- "name" : "StringType",
- "version" : "0.0.1"
- },
- "javaType" : "org.onap.policy.apex.core.contextmodel.concepts.TestContextItem000"
- },
- "isWritable" : true,
- "valueString" : ""
- }, {
- "key" : "axContextItem0_1",
- "contextType" : {
- "key" : {
- "name" : "MapType",
- "version" : "0.0.1"
- },
- "javaType" : "org.onap.policy.apex.core.contextmodel.concepts.TestContextItem00A"
- },
- "isWritable" : true,
- "valueString" : ""
- }, {
- "key" : "axContextItem0_2",
- "contextType" : {
- "key" : {
- "name" : "StringType",
- "version" : "0.0.1"
- },
- "javaType" : "org.onap.policy.apex.core.contextmodel.concepts.TestContextItem000"
- },
- "isWritable" : true,
- "valueString" : ""
- }, {
- "key" : "axContextItem0_3",
- "contextType" : {
- "key" : {
- "name" : "MapType",
- "version" : "0.0.1"
- },
- "javaType" : "org.onap.policy.apex.core.contextmodel.concepts.TestContextItem00A"
- },
- "isWritable" : true,
- "valueString" : ""
- } ]
- }
- }
- }, {
- "key" : "contextMap1",
- "value" : {
- "key" : {
- "name" : "contextMap1",
- "version" : "0.0.1"
- },
- "scope" : "GLOBAL",
- "mapType" : "SAMETYPE",
- "templateContextItem" : {
- "key" : "axTemplateContextItem",
- "contextType" : {
- "key" : {
- "name" : "MapType",
- "version" : "0.0.1"
- },
- "javaType" : "org.onap.policy.apex.core.contextmodel.concepts.TestContextItem00A"
- },
- "isWritable" : true
- },
- "contextMap" : {
- "contextItem" : [ ]
- }
- }
- } ]
- }
- }
- }
-} \ No newline at end of file
diff --git a/model/engine-model/pom.xml b/model/engine-model/pom.xml
index 7a1b485f8..9db1b2053 100644
--- a/model/engine-model/pom.xml
+++ b/model/engine-model/pom.xml
@@ -2,6 +2,7 @@
============LICENSE_START=======================================================
Copyright (C) 2018 Ericsson. All rights reserved.
Modifications Copyright (C) 2022 Bell Canada.
+ Modifications Copyright (C) 2022 Nordix Foundation.
================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -41,30 +42,4 @@
<artifactId>simpleclient</artifactId>
</dependency>
</dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>generate-xml-schema</id>
- <phase>process-classes</phase>
- <goals>
- <goal>java</goal>
- </goals>
- <configuration>
- <mainClass>org.onap.policy.apex.model.basicmodel.handling.ApexSchemaGenerator</mainClass>
- <classpathScope>compile</classpathScope>
- <arguments>
- <argument>org.onap.policy.apex.model.enginemodel.concepts.AxEngineModel</argument>
- <argument>${project.build.directory}/model/xml/apex-engine-model.xsd</argument>
- </arguments>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project> \ No newline at end of file
+</project>
diff --git a/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/AxEngineModel.java b/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/AxEngineModel.java
index 97e85c596..1a590a411 100644
--- a/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/AxEngineModel.java
+++ b/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/AxEngineModel.java
@@ -24,11 +24,6 @@ package org.onap.policy.apex.model.enginemodel.concepts;
import java.text.SimpleDateFormat;
import java.util.List;
-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.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
@@ -53,20 +48,12 @@ import org.onap.policy.common.utils.validation.Assertions;
* <p>Validation checks that the current state {@link AxEngineState} is defined and that the time stamp
* is set on the engine model.
*/
-@XmlRootElement(name = "apexEngineModel", namespace = "http://www.onap.org/policy/apex-pdp")
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "AxEngineModel", namespace = "http://www.onap.org/policy/apex-pdp",
- propOrder = {"timestamp", "state", "stats"})
-
public class AxEngineModel extends AxContextModel {
private static final long serialVersionUID = 6381235864606564046L;
private static final int HASH_CODE_PRIME = 32;
private long timestamp;
-
- @XmlElement(required = true)
private AxEngineState state;
-
private AxEngineStats stats;
/**
diff --git a/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/AxEngineState.java b/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/AxEngineState.java
index 63c8706d2..24c564b96 100644
--- a/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/AxEngineState.java
+++ b/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/AxEngineState.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,18 +22,12 @@
package org.onap.policy.apex.model.enginemodel.concepts;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlType;
-
/**
* This enumeration indicates the execution state of an Apex engine.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "AxEngineState", namespace = "http://www.onap.org/policy/apex-pdp")
public enum AxEngineState {
/** The state of the engine is not known. */
UNDEFINED(0),
@@ -54,4 +49,4 @@ public enum AxEngineState {
public int getStateIdentifier() {
return stateIdentifier;
}
-} \ No newline at end of file
+}
diff --git a/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/AxEngineStats.java b/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/AxEngineStats.java
index af5e8d458..36df645a5 100644
--- a/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/AxEngineStats.java
+++ b/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/AxEngineStats.java
@@ -26,11 +26,6 @@ import io.prometheus.client.Gauge;
import io.prometheus.client.Histogram;
import java.text.SimpleDateFormat;
import java.util.List;
-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 lombok.Getter;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
@@ -47,10 +42,6 @@ import org.onap.policy.common.utils.validation.Assertions;
* engine, and the time stamp of the last engine start are recorded.
*/
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlRootElement(name = "apexEngineStats", namespace = "http://www.onap.org/policy/apex-pdp")
-@XmlType(name = "AxEngineStats", namespace = "http://www.onap.org/policy/apex-pdp", propOrder = {"key", "timeStamp",
- "eventCount", "lastExecutionTime", "averageExecutionTime", "upTime", "lastStart"})
public class AxEngineStats extends AxConcept {
private static final long serialVersionUID = -6981129081962785368L;
private static final int HASH_CODE_PRIME = 32;
@@ -71,28 +62,15 @@ public class AxEngineStats extends AxConcept {
.name("apex_engine_last_execution_time").labelNames(ENGINE_INSTANCE_ID)
.help("Time taken to execute the last APEX policy in seconds.").register();
- @XmlElement(name = "key", required = true)
private AxReferenceKey key;
-
- @XmlElement(required = true)
private long timeStamp;
-
- @XmlElement(required = true)
private long eventCount;
-
- @XmlElement(required = true)
private long lastExecutionTime;
-
- @XmlElement(required = true)
private double averageExecutionTime;
-
- @XmlElement(required = true)
private long upTime;
@Getter
private transient long lastEnterTime;
-
- @XmlElement(required = true)
private long lastStart;
/**
diff --git a/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/package-info.java b/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/package-info.java
index ea47c6993..4557af7db 100644
--- a/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/package-info.java
+++ b/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/package-info.java
@@ -1,19 +1,20 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
@@ -21,14 +22,7 @@
/**
* Contains the concepts required to receive state information and statistcs from running APEX
* engines.
- *
+ *
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-@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.policy.apex.model.enginemodel.concepts;
-
-import javax.xml.bind.annotation.XmlNs;
-import javax.xml.bind.annotation.XmlNsForm;
-import javax.xml.bind.annotation.XmlSchema;
diff --git a/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/handling/ApexEngineModelTest.java b/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/handling/ApexEngineModelTest.java
index 8baa59b2f..e7fdd2d93 100644
--- a/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/handling/ApexEngineModelTest.java
+++ b/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/handling/ApexEngineModelTest.java
@@ -75,11 +75,6 @@ public class ApexEngineModelTest {
}
@Test
- public void testModelWriteReadXml() throws Exception {
- testApexModel.testApexModelWriteReadXml();
- }
-
- @Test
public void testModelWriteReadJson() throws Exception {
testApexModel.testApexModelWriteReadJson();
}
diff --git a/model/event-model/pom.xml b/model/event-model/pom.xml
index 5e5f84885..813ebb8bb 100644
--- a/model/event-model/pom.xml
+++ b/model/event-model/pom.xml
@@ -1,6 +1,7 @@
<!--
============LICENSE_START=======================================================
Copyright (C) 2018 Ericsson. All rights reserved.
+ Modifications Copyright (C) 2022 Nordix Foundation.
================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -36,30 +37,4 @@
<version>${project.version}</version>
</dependency>
</dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>generate-xml-schema</id>
- <phase>process-classes</phase>
- <goals>
- <goal>java</goal>
- </goals>
- <configuration>
- <mainClass>org.onap.policy.apex.model.basicmodel.handling.ApexSchemaGenerator</mainClass>
- <classpathScope>compile</classpathScope>
- <arguments>
- <argument>org.onap.policy.apex.model.eventmodel.concepts.AxEventModel</argument>
- <argument>${project.build.directory}/model/xml/apex-event-model.xsd</argument>
- </arguments>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
</project>
diff --git a/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEvent.java b/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEvent.java
index 8128b3d9a..a4c0e9db1 100644
--- a/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEvent.java
+++ b/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEvent.java
@@ -23,6 +23,7 @@
package org.onap.policy.apex.model.eventmodel.concepts;
import com.google.common.base.Strings;
+import com.google.gson.annotations.SerializedName;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@@ -31,12 +32,6 @@ import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.TreeSet;
-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.XmlRootElement;
-import javax.xml.bind.annotation.XmlType;
import org.apache.commons.lang3.EnumUtils;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
@@ -69,35 +64,22 @@ import org.onap.policy.common.utils.validation.Assertions;
* is checked to ensure it matches the event parameter key on the event. Finally, the parent key of each parameter is
* checked to ensure it matches the event key.
*/
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlRootElement(name = "apexEvent", namespace = "http://www.onap.org/policy/apex-pdp")
-@XmlType(name = "AxEvent", namespace = "http://www.onap.org/policy/apex-pdp", propOrder =
- { "key", "nameSpace", "source", "target", "parameterMap", "toscaPolicyState"})
-
public class AxEvent extends AxConcept {
private static final long serialVersionUID = -1460388382582984269L;
private static final String WHITESPACE_REGEXP = "\\s+$";
/** The key of the event, unique in the Apex system. */
- @XmlElement(name = "key", required = true)
// CHECKSTYLE:OFF: checkstyle:VisibilityMonitor
protected AxArtifactKey key;
// CHECKSTYLE:ON: checkstyle:VisibilityMonitor
- @XmlElement(required = true)
private String nameSpace;
-
- @XmlElement(required = true)
private String source;
-
- @XmlElement(required = true)
private String target;
- @XmlElement(name = "parameter", required = true)
+ @SerializedName("parameter")
private Map<String, AxField> parameterMap;
-
- @XmlElement(required = false)
private String toscaPolicyState;
/**
@@ -189,14 +171,10 @@ public class AxEvent extends AxConcept {
}
/**
- * When an event is unmarshalled from disk or from the database, the parent key in the reference keys in its
- * parameter map are not set. This method is called by JAXB after unmarshaling and is used to set the parent key of
- * the {@link AxField} instances in the parameter map to be the key of the event that contains them.
- *
- * @param unmarshaler the unmarshaler that is unmarshaling the model
- * @param parent the parent object of this object in the unmarshaler
+ * {@inheritDoc}.
*/
- public void afterUnmarshal(final Unmarshaller unmarshaler, final Object parent) {
+ @Override
+ public void buildReferences() {
for (final AxField parameter : parameterMap.values()) {
parameter.getKey().setParentArtifactKey(key);
}
diff --git a/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEventModel.java b/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEventModel.java
index bb4307604..b91712c9d 100644
--- a/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEventModel.java
+++ b/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEventModel.java
@@ -23,11 +23,6 @@
package org.onap.policy.apex.model.eventmodel.concepts;
import java.util.List;
-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.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
@@ -46,18 +41,10 @@ import org.onap.policy.common.utils.validation.Assertions;
* <p>Validation runs {@link AxModel} validation on the model. In addition, the {@link AxContextSchemas} and
* {@link AxEvents} validation is run on the context schemas and events in the model.
*/
-
-@XmlRootElement(name = "apexEventModel", namespace = "http://www.onap.org/policy/apex-pdp")
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "AxEventModel", namespace = "http://www.onap.org/policy/apex-pdp", propOrder = { "schemas", "events" })
-
public class AxEventModel extends AxModel {
private static final long serialVersionUID = 8800599637708309945L;
- @XmlElement(name = "schemas", required = true)
private AxContextSchemas schemas;
-
- @XmlElement(name = "events", required = true)
private AxEvents events;
/**
diff --git a/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEvents.java b/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEvents.java
index 26275a157..aac1562de 100644
--- a/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEvents.java
+++ b/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEvents.java
@@ -27,11 +27,6 @@ import java.util.Map.Entry;
import java.util.NavigableMap;
import java.util.Set;
import java.util.TreeMap;
-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.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
import org.onap.policy.apex.model.basicmodel.concepts.AxConceptGetter;
@@ -52,17 +47,10 @@ import org.onap.policy.common.utils.validation.Assertions;
* container. Each event entry is checked to ensure that its key and value are not null and that the key matches the key
* in the map value. Each event entry is then validated individually.
*/
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "AxEvents", namespace = "http://www.onap.org/policy/apex-pdp", propOrder =
- { "key", "eventMap" })
-
public class AxEvents extends AxConcept implements AxConceptGetter<AxEvent> {
private static final long serialVersionUID = 4290442590545820316L;
- @XmlElement(name = "key", required = true)
private AxArtifactKey key;
-
- @XmlElement(required = true)
private Map<AxArtifactKey, AxEvent> eventMap;
/**
@@ -108,21 +96,6 @@ public class AxEvents extends AxConcept implements AxConceptGetter<AxEvent> {
}
/**
- * When a model is unmarshalled from disk or from the database, the event 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 unmarshaler the unmarshaler that is unmarshaling the model
- * @param parent the parent object of this object in the unmarshaler
- */
- public void afterUnmarshal(final Unmarshaller unmarshaler, final Object parent) {
- // The map must be navigable to allow name and version searching, unmarshaling returns a hash map
- final NavigableMap<AxArtifactKey, AxEvent> navigableEventMap = new TreeMap<>();
- navigableEventMap.putAll(eventMap);
- eventMap = navigableEventMap;
- }
-
- /**
* {@inheritDoc}.
*/
@Override
@@ -145,6 +118,14 @@ public class AxEvents extends AxConcept implements AxConceptGetter<AxEvent> {
}
/**
+ * {@inheritDoc}.
+ */
+ @Override
+ public void buildReferences() {
+ eventMap.values().stream().forEach(event -> event.buildReferences());
+ }
+
+ /**
* Sets the key of the event container.
*
* @param key the event container key
diff --git a/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxField.java b/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxField.java
index 9f98a6253..26511c9d1 100644
--- a/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxField.java
+++ b/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxField.java
@@ -23,12 +23,6 @@
package org.onap.policy.apex.model.eventmodel.concepts;
import java.util.List;
-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 javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
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.AxKey;
@@ -37,7 +31,6 @@ 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;
-import org.onap.policy.apex.model.basicmodel.xml.AxReferenceKeyAdapter;
import org.onap.policy.common.utils.validation.Assertions;
/**
@@ -50,11 +43,6 @@ import org.onap.policy.common.utils.validation.Assertions;
*
* <p>Validation checks that the field key and the field schema reference key are not null.
*/
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlRootElement(name = "apexField", namespace = "http://www.onap.org/policy/apex-pdp")
-@XmlType(name = "AxField", namespace = "http://www.onap.org/policy/apex-pdp", propOrder =
- { "key", "fieldSchemaKey", "optional" })
-
public class AxField extends AxConcept {
private static final String KEY_MAY_NOT_BE_NULL = "key may not be null";
private static final String FIELD_SCHEMA_KEY_MAY_NOT_BE_NULL = "fieldSchemaKey may not be null";
@@ -64,14 +52,8 @@ public class AxField extends AxConcept {
private static final int HASH_PRIME_0 = 1231;
private static final int HASH_PRIME_1 = 1237;
- @XmlElement(name = "key", required = true)
- @XmlJavaTypeAdapter(AxReferenceKeyAdapter.class)
private AxReferenceKey key;
-
- @XmlElement(required = true)
private AxArtifactKey fieldSchemaKey;
-
- @XmlElement(required = false)
private boolean optional;
/**
diff --git a/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxInputField.java b/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxInputField.java
index 2626e8b25..6155c7186 100644
--- a/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxInputField.java
+++ b/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxInputField.java
@@ -21,20 +21,12 @@
package org.onap.policy.apex.model.eventmodel.concepts;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlType;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
/**
* This class specializes the {@link AxField} class for use as input fields on events.
*/
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlRootElement(name = "apexInputField", namespace = "http://www.onap.org/policy/apex-pdp")
-@XmlType(name = "AxInputField", namespace = "http://www.onap.org/policy/apex-pdp")
-
public class AxInputField extends AxField {
private static final long serialVersionUID = 2090324845463750391L;
diff --git a/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxOutputField.java b/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxOutputField.java
index a3e835202..7f3437617 100644
--- a/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxOutputField.java
+++ b/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxOutputField.java
@@ -21,20 +21,12 @@
package org.onap.policy.apex.model.eventmodel.concepts;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlType;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
/**
* This class specializes the {@link AxField} class for use as output fields on events.
*/
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlRootElement(name = "apexOutputField", namespace = "http://www.onap.org/policy/apex-pdp")
-@XmlType(name = "AxOutputField", namespace = "http://www.onap.org/policy/apex-pdp")
-
public class AxOutputField extends AxField {
private static final long serialVersionUID = 2090324845463750391L;
diff --git a/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/package-info.java b/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/package-info.java
index 7b20b3939..414d22d0e 100644
--- a/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/package-info.java
+++ b/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/package-info.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,12 +24,4 @@
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-
-@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.policy.apex.model.eventmodel.concepts;
-
-import javax.xml.bind.annotation.XmlNs;
-import javax.xml.bind.annotation.XmlNsForm;
-import javax.xml.bind.annotation.XmlSchema;
diff --git a/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventsTest.java b/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventsTest.java
index 111d27f70..7062fcb3c 100644
--- a/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventsTest.java
+++ b/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventsTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020,2022 Nordix Foundation.
* Modifications Copyright (C) 2022 Bell Canada.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -39,6 +39,7 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.Validat
/**
* Test events.
+ *
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class EventsTest {
@@ -78,20 +79,20 @@ public class EventsTest {
assertEquals(AxToscaPolicyProcessingStatus.ENTRY.name(), event.getToscaPolicyState());
final AxField eventField =
- new AxField(new AxReferenceKey(eventKey, "Field0"), new AxArtifactKey("Field0Schema", "0.0.1"));
+ new AxField(new AxReferenceKey(eventKey, "Field0"), new AxArtifactKey("Field0Schema", "0.0.1"));
event.getParameterMap().put(eventField.getKey().getLocalName(), eventField);
assertEquals(1, event.getParameterMap().size());
final AxField eventFieldBadParent =
- new AxField(new AxReferenceKey(new AxArtifactKey("OtherEvent", "0.0.01"), "Field0"),
- new AxArtifactKey("Field0Schema", "0.0.1"));
+ new AxField(new AxReferenceKey(new AxArtifactKey("OtherEvent", "0.0.01"), "Field0"),
+ new AxArtifactKey("Field0Schema", "0.0.1"));
final AxArtifactKey newEventKey = new AxArtifactKey("NewEventName", "0.0.1");
event.setKey(newEventKey);
assertEquals("NewEventName:0.0.1", event.getKey().getId());
assertEquals("NewEventName:0.0.1", event.getKeys().get(0).getId());
assertEquals("NewEventName:0.0.1",
- event.getParameterMap().get("Field0").getKey().getParentArtifactKey().getId());
+ event.getParameterMap().get("Field0").getKey().getParentArtifactKey().getId());
event.setKey(eventKey);
assertEquals("EventName:0.0.1", event.getKey().getId());
assertEquals("EventName:0.0.1", event.getKeys().get(0).getId());
@@ -190,11 +191,13 @@ public class EventsTest {
event.setToscaPolicyState(AxToscaPolicyProcessingStatus.ENTRY.name());
event.clean();
- event.afterUnmarshal(null, null);
+ event.buildReferences();
+ assertNotEquals(AxKey.NULL_KEY_NAME,
+ event.getParameterMap().values().iterator().next().getKey().getParentKeyName());
final AxEvent clonedEvent = new AxEvent(event);
assertEquals("AxEvent:(key=AxArtifactKey:(name=EventName,version=0.0.1),nameSpace=namespace",
- clonedEvent.toString().substring(0, 77));
+ clonedEvent.toString().substring(0, 77));
assertNotEquals(0, event.hashCode());
@@ -202,37 +205,38 @@ public class EventsTest {
assertEquals(event, event); // NOSONAR
assertEquals(event, clonedEvent);
assertNotNull(event);
- assertNotEquals(event, (Object) "Hello");
+
+ Object helloObj = "Hello";
+ assertNotEquals(event, helloObj);
assertNotEquals(event, new AxEvent(AxArtifactKey.getNullKey(), "namespace", "source", "target", parameterMap,
- AxToscaPolicyProcessingStatus.ENTRY.name()));
+ AxToscaPolicyProcessingStatus.ENTRY.name()));
assertNotEquals(event, new AxEvent(eventKey, "namespace1", "source", "target", parameterMap,
- AxToscaPolicyProcessingStatus.ENTRY.name()));
+ AxToscaPolicyProcessingStatus.ENTRY.name()));
assertNotEquals(event, new AxEvent(eventKey, "namespace", "source2", "target", parameterMap,
- AxToscaPolicyProcessingStatus.ENTRY.name()));
+ AxToscaPolicyProcessingStatus.ENTRY.name()));
assertNotEquals(event, new AxEvent(eventKey, "namespace", "source", "target3", parameterMap,
- AxToscaPolicyProcessingStatus.ENTRY.name()));
+ AxToscaPolicyProcessingStatus.ENTRY.name()));
assertNotEquals(event, new AxEvent(eventKey, "namespace", "source", "target", parameterMapEmpty,
- AxToscaPolicyProcessingStatus.ENTRY.name()));
+ AxToscaPolicyProcessingStatus.ENTRY.name()));
assertEquals(event, new AxEvent(eventKey, "namespace", "source", "target", parameterMap,
- AxToscaPolicyProcessingStatus.ENTRY.name()));
+ AxToscaPolicyProcessingStatus.ENTRY.name()));
assertEquals(0, event.compareTo(event));
assertEquals(0, event.compareTo(clonedEvent));
assertNotEquals(0, event.compareTo(new AxArtifactKey()));
assertNotEquals(0, event.compareTo(null));
- assertNotEquals(0, event
- .compareTo(new AxEvent(AxArtifactKey.getNullKey(), "namespace", "source", "target", parameterMap,
- AxToscaPolicyProcessingStatus.ENTRY.name())));
+ assertNotEquals(0, event.compareTo(new AxEvent(AxArtifactKey.getNullKey(), "namespace", "source", "target",
+ parameterMap, AxToscaPolicyProcessingStatus.ENTRY.name())));
assertNotEquals(0, event.compareTo(new AxEvent(eventKey, "namespace1", "source", "target", parameterMap,
- AxToscaPolicyProcessingStatus.ENTRY.name())));
+ AxToscaPolicyProcessingStatus.ENTRY.name())));
assertNotEquals(0, event.compareTo(new AxEvent(eventKey, "namespace", "source2", "target", parameterMap,
- AxToscaPolicyProcessingStatus.ENTRY.name())));
+ AxToscaPolicyProcessingStatus.ENTRY.name())));
assertNotEquals(0, event.compareTo(new AxEvent(eventKey, "namespace", "source", "target3", parameterMap,
- AxToscaPolicyProcessingStatus.ENTRY.name())));
+ AxToscaPolicyProcessingStatus.ENTRY.name())));
assertNotEquals(0, event.compareTo(new AxEvent(eventKey, "namespace", "source", "target", parameterMapEmpty,
- AxToscaPolicyProcessingStatus.ENTRY.name())));
+ AxToscaPolicyProcessingStatus.ENTRY.name())));
assertEquals(0, event.compareTo(new AxEvent(eventKey, "namespace", "source", "target", parameterMap,
- AxToscaPolicyProcessingStatus.ENTRY.name())));
+ AxToscaPolicyProcessingStatus.ENTRY.name())));
assertNotNull(event.getKeys());
@@ -285,17 +289,19 @@ public class EventsTest {
assertEquals(ValidationResult.VALID, result.getValidationResult());
events.clean();
- events.afterUnmarshal(null, null);
+ event.buildReferences();
+ assertNotEquals(AxKey.NULL_KEY_NAME,
+ event.getParameterMap().values().iterator().next().getKey().getParentKeyName());
final AxEvents clonedEvents = new AxEvents(events);
assertEquals("AxEvents:(key=AxArtifactKey:(name=EventsKey,version=0.0.1),e",
- clonedEvents.toString().substring(0, 60));
+ clonedEvents.toString().substring(0, 60));
assertNotEquals(0, events.hashCode());
assertEquals(events, clonedEvents);
assertNotNull(events);
- assertNotEquals(events, (Object) "Hello");
+ assertNotEquals(event, helloObj);
assertNotEquals(events, new AxEvents(new AxArtifactKey()));
assertEquals(0, events.compareTo(events));
@@ -314,4 +320,4 @@ public class EventsTest {
assertEquals(1, events.getAll("EventName", "0.0.1").size());
assertEquals(0, events.getAll("NonExistantEventsName").size());
}
-} \ No newline at end of file
+}
diff --git a/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/handling/ApexEventModelTest.java b/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/handling/ApexEventModelTest.java
index 5f770d1b3..21b97c454 100644
--- a/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/handling/ApexEventModelTest.java
+++ b/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/handling/ApexEventModelTest.java
@@ -273,11 +273,6 @@ public class ApexEventModelTest {
}
@Test
- public void testModelWriteReadXml() throws Exception {
- testApexModel.testApexModelWriteReadXml();
- }
-
- @Test
public void testModelWriteReadJson() throws Exception {
testApexModel.testApexModelWriteReadJson();
}
diff --git a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexApiResult.java b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexApiResult.java
index d05d410f8..83e3b5370 100644
--- a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexApiResult.java
+++ b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexApiResult.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020,2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,13 +25,6 @@ import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlElementWrapper;
-import javax.xml.bind.annotation.XmlEnum;
-import javax.xml.bind.annotation.XmlRootElement;
import lombok.Setter;
/**
@@ -39,14 +32,11 @@ import lombok.Setter;
* {@link ApexModel} API.
*/
@Setter
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.NONE)
public class ApexApiResult {
/**
* This enumeration is used to represent the result status of a call on the {@link ApexModel} API.
*/
- @XmlEnum(value = String.class)
public enum Result {
/** The method call succeeded. */
SUCCESS,
@@ -155,7 +145,6 @@ public class ApexApiResult {
*
* @return true, if the result indicates the API operation succeeded
*/
- @XmlAttribute(required = true)
public boolean isOk() {
return Result.isOk(result);
}
@@ -174,7 +163,6 @@ public class ApexApiResult {
*
* @return the result status
*/
- @XmlAttribute(required = true)
public Result getResult() {
return result;
}
@@ -184,8 +172,6 @@ public class ApexApiResult {
*
* @return the list of messages returned by an API operation
*/
- @XmlElementWrapper(required = false, nillable = true)
- @XmlElement(nillable = true, name = "message")
public List<String> getMessages() {
return messages;
}
@@ -195,7 +181,6 @@ public class ApexApiResult {
*
* @return the messages returned by an API operation as a single string
*/
- @XmlElement(required = true, name = "content")
public String getMessage() {
final StringBuilder builder = new StringBuilder();
for (final String message : messages) {
diff --git a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexModel.java b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexModel.java
index d721e33fd..3c6e4c063 100644
--- a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexModel.java
+++ b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexModel.java
@@ -56,10 +56,9 @@ public interface ApexModel extends ApexEditorApi {
* Save an Apex model to a file.
*
* @param fileName the file name
- * @param xmlFlag if true, save the file in XML format, otherwise save the file in the default JSON format
* @return the result of the operation
*/
- ApexApiResult saveToFile(String fileName, boolean xmlFlag);
+ ApexApiResult saveToFile(String fileName);
/**
* Read an APEX model from a location identified by a URL.
@@ -73,10 +72,9 @@ public interface ApexModel extends ApexEditorApi {
* Write an APEX model to a location identified by a URL.
*
* @param urlString the URL to read the model from
- * @param xmlFlag if true, save the file in XML format, otherwise save the file in the default JSON format
* @return the result of the operation
*/
- ApexApiResult writeToUrl(String urlString, boolean xmlFlag);
+ ApexApiResult writeToUrl(String urlString);
/**
* Analyse an Apex model that shows the concept usage references of a policy model.
diff --git a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexModelFactory.java b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexModelFactory.java
index 5be8b02b8..908f562d2 100644
--- a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexModelFactory.java
+++ b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexModelFactory.java
@@ -1,19 +1,20 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
@@ -34,12 +35,10 @@ public class ApexModelFactory {
* Creates a new ApexModel object from its implementation.
*
* @param apexProperties default values and other configuration information for the apex model
- * @param jsonMode set to true to return JSON strings in list and delete operations, otherwise
- * set to false
* @return the apex model
*/
- public ApexModel createApexModel(final Properties apexProperties, final boolean jsonMode) {
- return new ApexModelImpl(setDefaultPropertyValues(apexProperties), jsonMode);
+ public ApexModel createApexModel(final Properties apexProperties) {
+ return new ApexModelImpl(setDefaultPropertyValues(apexProperties));
}
/**
diff --git a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ApexModelImpl.java b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ApexModelImpl.java
index 944d95f2b..54b94d0e7 100644
--- a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ApexModelImpl.java
+++ b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ApexModelImpl.java
@@ -54,9 +54,6 @@ public final class ApexModelImpl implements ApexModel {
@Setter
private AxPolicyModel policyModel = new AxPolicyModel();
- // The file name for the loaded file
- private String fileName = null;
-
// @formatter:off
private ModelFacade modelFacade;
private KeyInformationFacade keyInformationFacade;
@@ -69,27 +66,24 @@ public final class ApexModelImpl implements ApexModel {
// @formatter:on
private Properties apexProperties;
- private boolean jsonMode;
/**
* Create an implementation of the Apex editor and model APIs.
*
* @param apexProperties The properties to use for the model
- * @param jsonMode set to true to return JSON strings in list and delete operations, otherwise set to false
*/
- public ApexModelImpl(final Properties apexProperties, final boolean jsonMode) {
+ public ApexModelImpl(final Properties apexProperties) {
this.apexProperties = apexProperties;
- this.jsonMode = jsonMode;
// @formatter:off
- this.modelFacade = new ModelFacade(this, apexProperties, jsonMode);
- this.keyInformationFacade = new KeyInformationFacade(this, apexProperties, jsonMode);
- this.contextSchemaFacade = new ContextSchemaFacade(this, apexProperties, jsonMode);
- this.eventFacade = new EventFacade(this, apexProperties, jsonMode);
- this.contextAlbumFacade = new ContextAlbumFacade(this, apexProperties, jsonMode);
- this.taskFacade = new TaskFacade(this, apexProperties, jsonMode);
- this.policyFacade = new PolicyFacade(this, apexProperties, jsonMode);
- this.modelHandlerFacade = new ModelHandlerFacade(this, apexProperties, jsonMode);
+ this.modelFacade = new ModelFacade(this, apexProperties);
+ this.keyInformationFacade = new KeyInformationFacade(this, apexProperties);
+ this.contextSchemaFacade = new ContextSchemaFacade(this, apexProperties);
+ this.eventFacade = new EventFacade(this, apexProperties);
+ this.contextAlbumFacade = new ContextAlbumFacade(this, apexProperties);
+ this.taskFacade = new TaskFacade(this, apexProperties);
+ this.policyFacade = new PolicyFacade(this, apexProperties);
+ this.modelHandlerFacade = new ModelHandlerFacade(this, apexProperties);
// @formatter:on
}
@@ -101,17 +95,15 @@ public final class ApexModelImpl implements ApexModel {
ApexModelImpl ret = new ApexModelImpl();
// @formatter:off
ret.policyModel = new AxPolicyModel(policyModel);
- ret.fileName = this.fileName;
ret.apexProperties = this.apexProperties;
- ret.jsonMode = this.jsonMode;
- ret.modelFacade = new ModelFacade(ret, this.apexProperties, this.jsonMode);
- ret.keyInformationFacade = new KeyInformationFacade(ret, this.apexProperties, this.jsonMode);
- ret.contextSchemaFacade = new ContextSchemaFacade(ret, this.apexProperties, this.jsonMode);
- ret.eventFacade = new EventFacade(ret, this.apexProperties, this.jsonMode);
- ret.contextAlbumFacade = new ContextAlbumFacade(ret, this.apexProperties, this.jsonMode);
- ret.taskFacade = new TaskFacade(ret, this.apexProperties, this.jsonMode);
- ret.policyFacade = new PolicyFacade(ret, this.apexProperties, this.jsonMode);
- ret.modelHandlerFacade = new ModelHandlerFacade(ret, this.apexProperties, this.jsonMode);
+ ret.modelFacade = new ModelFacade(ret, this.apexProperties);
+ ret.keyInformationFacade = new KeyInformationFacade(ret, this.apexProperties);
+ ret.contextSchemaFacade = new ContextSchemaFacade(ret, this.apexProperties);
+ ret.eventFacade = new EventFacade(ret, this.apexProperties);
+ ret.contextAlbumFacade = new ContextAlbumFacade(ret, this.apexProperties);
+ ret.taskFacade = new TaskFacade(ret, this.apexProperties);
+ ret.policyFacade = new PolicyFacade(ret, this.apexProperties);
+ ret.modelHandlerFacade = new ModelHandlerFacade(ret, this.apexProperties);
// @formatter:on
return ret;
@@ -770,7 +762,6 @@ public final class ApexModelImpl implements ApexModel {
@Override
// CHECKSTYLE:OFF: checkstyle:HiddenField
public ApexApiResult loadFromFile(final String fileName) {
- this.fileName = fileName;
return modelHandlerFacade.loadFromFile(fileName);
}
// CHECKSTYLE:ON: checkstyle:HiddenField
@@ -779,12 +770,8 @@ public final class ApexModelImpl implements ApexModel {
* {@inheritDoc}.
*/
@Override
- public ApexApiResult saveToFile(final String saveFileName, final boolean xmlFlag) {
- if (saveFileName == null) {
- return modelHandlerFacade.saveToFile(fileName, xmlFlag);
- } else {
- return modelHandlerFacade.saveToFile(saveFileName, xmlFlag);
- }
+ public ApexApiResult saveToFile(final String fileName) {
+ return modelHandlerFacade.saveToFile(fileName);
}
/**
@@ -799,8 +786,8 @@ public final class ApexModelImpl implements ApexModel {
* {@inheritDoc}.
*/
@Override
- public ApexApiResult writeToUrl(final String urlString, final boolean xmlFlag) {
- return modelHandlerFacade.writeToUrl(urlString, xmlFlag);
+ public ApexApiResult writeToUrl(final String urlString) {
+ return modelHandlerFacade.writeToUrl(urlString);
}
/**
diff --git a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ContextAlbumFacade.java b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ContextAlbumFacade.java
index a78444da6..d29f32ea0 100644
--- a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ContextAlbumFacade.java
+++ b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ContextAlbumFacade.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019 Samsung Electronics Co., Ltd.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019,2022 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -53,24 +53,17 @@ public class ContextAlbumFacade {
// Facade classes for working towards the real Apex model
private final KeyInformationFacade keyInformationFacade;
- // JSON output on list/delete if set
- private final boolean jsonMode;
-
/**
* Constructor that creates a context album facade for the Apex Model API.
*
* @param apexModel the apex model
* @param apexProperties Properties for the model
- * @param jsonMode set to true to return JSON strings in list and delete operations, otherwise
- * set to false * Modifications Copyright (C) 2019 Nordix Foundation.
-
*/
- public ContextAlbumFacade(final ApexModel apexModel, final Properties apexProperties, final boolean jsonMode) {
+ public ContextAlbumFacade(final ApexModel apexModel, final Properties apexProperties) {
this.apexModel = apexModel;
this.apexProperties = apexProperties;
- this.jsonMode = jsonMode;
- keyInformationFacade = new KeyInformationFacade(apexModel, apexProperties, jsonMode);
+ keyInformationFacade = new KeyInformationFacade(apexModel, apexProperties);
}
/**
@@ -92,14 +85,14 @@ public class ContextAlbumFacade {
if (apexModel.getPolicyModel().getAlbums().getAlbumsMap().containsKey(key)) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_EXISTS,
- CONCEPT + key.getId() + " already exists");
+ CONCEPT + key.getId() + " already exists");
}
final AxContextSchema schema = apexModel.getPolicyModel().getSchemas().get(builder.getContextSchemaName(),
- builder.getContextSchemaVersion());
+ builder.getContextSchemaVersion());
if (schema == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, CONCEPT
- + builder.getContextSchemaName() + ':' + builder.getContextSchemaVersion() + DOES_NOT_EXIST);
+ + builder.getContextSchemaName() + ':' + builder.getContextSchemaVersion() + DOES_NOT_EXIST);
}
final AxContextAlbum contextAlbum = new AxContextAlbum(key);
@@ -107,17 +100,17 @@ public class ContextAlbumFacade {
contextAlbum.setItemSchema(schema.getKey());
contextAlbum
- .setWritable(builder.getWritable() != null && ("true".equalsIgnoreCase(builder.getWritable().trim())
- || "t".equalsIgnoreCase(builder.getWritable().trim())));
+ .setWritable(builder.getWritable() != null && ("true".equalsIgnoreCase(builder.getWritable().trim())
+ || "t".equalsIgnoreCase(builder.getWritable().trim())));
apexModel.getPolicyModel().getAlbums().getAlbumsMap().put(key, contextAlbum);
if (apexModel.getPolicyModel().getKeyInformation().getKeyInfoMap().containsKey(key)) {
return keyInformationFacade.updateKeyInformation(builder.getName(), builder.getVersion(),
- builder.getUuid(), builder.getDescription());
+ builder.getUuid(), builder.getDescription());
} else {
return keyInformationFacade.createKeyInformation(builder.getName(), builder.getVersion(),
- builder.getUuid(), builder.getDescription());
+ builder.getUuid(), builder.getDescription());
}
} catch (final Exception e) {
return new ApexApiResult(ApexApiResult.Result.FAILED, e);
@@ -135,10 +128,10 @@ public class ContextAlbumFacade {
public ApexApiResult updateContextAlbum(ContextAlbum builder) {
try {
final AxContextAlbum contextAlbum =
- apexModel.getPolicyModel().getAlbums().get(builder.getName(), builder.getVersion());
+ apexModel.getPolicyModel().getAlbums().get(builder.getName(), builder.getVersion());
if (contextAlbum == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + builder.getName() + ':' + builder.getVersion() + DOES_NOT_EXIST);
+ CONCEPT + builder.getName() + ':' + builder.getVersion() + DOES_NOT_EXIST);
}
if (builder.getScope() != null) {
@@ -146,22 +139,21 @@ public class ContextAlbumFacade {
}
contextAlbum
- .setWritable(builder.getWritable() != null && ("true".equalsIgnoreCase(builder.getWritable().trim())
- || "t".equalsIgnoreCase(builder.getWritable().trim())));
+ .setWritable(builder.getWritable() != null && ("true".equalsIgnoreCase(builder.getWritable().trim())
+ || "t".equalsIgnoreCase(builder.getWritable().trim())));
if (builder.getContextSchemaName() != null) {
final AxContextSchema schema = apexModel.getPolicyModel().getSchemas()
- .get(builder.getContextSchemaName(), builder.getContextSchemaVersion());
+ .get(builder.getContextSchemaName(), builder.getContextSchemaVersion());
if (schema == null) {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + builder.getContextSchemaName() + ':' + builder.getContextSchemaVersion()
- + DOES_NOT_EXIST);
+ return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, CONCEPT
+ + builder.getContextSchemaName() + ':' + builder.getContextSchemaVersion() + DOES_NOT_EXIST);
}
contextAlbum.setItemSchema(schema.getKey());
}
return keyInformationFacade.updateKeyInformation(builder.getName(), builder.getVersion(), builder.getUuid(),
- builder.getDescription());
+ builder.getDescription());
} catch (final Exception e) {
return new ApexApiResult(ApexApiResult.Result.FAILED, e);
}
@@ -180,13 +172,13 @@ public class ContextAlbumFacade {
final Set<AxContextAlbum> contextAlbumSet = apexModel.getPolicyModel().getAlbums().getAll(name, version);
if (name != null && contextAlbumSet.isEmpty()) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT_S + name + ':' + version + DO_ES_NOT_EXIST);
+ CONCEPT_S + name + ':' + version + DO_ES_NOT_EXIST);
}
final ApexApiResult result = new ApexApiResult();
for (final AxContextAlbum contextAlbum : contextAlbumSet) {
- result.addMessage(new ApexModelStringWriter<AxContextAlbum>(false).writeString(contextAlbum,
- AxContextAlbum.class, jsonMode));
+ result.addMessage(
+ new ApexModelStringWriter<AxContextAlbum>(false).writeString(contextAlbum, AxContextAlbum.class));
}
return result;
} catch (final Exception e) {
@@ -209,20 +201,20 @@ public class ContextAlbumFacade {
return new ApexApiResult();
} else {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + key.getId() + DOES_NOT_EXIST);
+ CONCEPT + key.getId() + DOES_NOT_EXIST);
}
}
final Set<AxContextAlbum> contextAlbumSet = apexModel.getPolicyModel().getAlbums().getAll(name, version);
if (contextAlbumSet.isEmpty()) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT_S + name + ':' + version + DO_ES_NOT_EXIST);
+ CONCEPT_S + name + ':' + version + DO_ES_NOT_EXIST);
}
final ApexApiResult result = new ApexApiResult();
for (final AxContextAlbum contextAlbum : contextAlbumSet) {
- result.addMessage(new ApexModelStringWriter<AxContextAlbum>(false).writeString(contextAlbum,
- AxContextAlbum.class, jsonMode));
+ result.addMessage(
+ new ApexModelStringWriter<AxContextAlbum>(false).writeString(contextAlbum, AxContextAlbum.class));
apexModel.getPolicyModel().getAlbums().getAlbumsMap().remove(contextAlbum.getKey());
keyInformationFacade.deleteKeyInformation(name, version);
}
@@ -244,14 +236,14 @@ public class ContextAlbumFacade {
final Set<AxContextAlbum> contextAlbumSet = apexModel.getPolicyModel().getAlbums().getAll(name, version);
if (contextAlbumSet.isEmpty()) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT_S + name + ':' + version + DO_ES_NOT_EXIST);
+ CONCEPT_S + name + ':' + version + DO_ES_NOT_EXIST);
}
final ApexApiResult result = new ApexApiResult();
for (final AxContextAlbum contextAlbum : contextAlbumSet) {
final AxValidationResult validationResult = contextAlbum.validate(new AxValidationResult());
result.addMessage(new ApexModelStringWriter<AxArtifactKey>(false).writeString(contextAlbum.getKey(),
- AxArtifactKey.class, jsonMode));
+ AxArtifactKey.class));
result.addMessage(validationResult.toString());
}
return result;
diff --git a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ContextSchemaFacade.java b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ContextSchemaFacade.java
index 00156c5bd..83bca5a01 100644
--- a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ContextSchemaFacade.java
+++ b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ContextSchemaFacade.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019,2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -52,22 +52,17 @@ public class ContextSchemaFacade {
// Facade classes for working towards the real Apex model
private final KeyInformationFacade keyInformationFacade;
- // JSON output on list/delete if set
- private final boolean jsonMode;
-
/**
* Constructor to create the context schema facade for the Model API.
*
* @param apexModel the apex model
* @param apexProperties Properties for the model
- * @param jsonMode set to true to return JSON strings in list and delete operations, otherwise set to false
*/
- public ContextSchemaFacade(final ApexModel apexModel, final Properties apexProperties, final boolean jsonMode) {
+ public ContextSchemaFacade(final ApexModel apexModel, final Properties apexProperties) {
this.apexModel = apexModel;
this.apexProperties = apexProperties;
- this.jsonMode = jsonMode;
- keyInformationFacade = new KeyInformationFacade(apexModel, apexProperties, jsonMode);
+ keyInformationFacade = new KeyInformationFacade(apexModel, apexProperties);
}
/**
@@ -82,7 +77,7 @@ public class ContextSchemaFacade {
* @return result of the operation
*/
public ApexApiResult createContextSchema(final String name, final String version, final String schemaFlavour,
- final String schemaDefinition, final String uuid, final String description) {
+ final String schemaDefinition, final String uuid, final String description) {
try {
Assertions.argumentNotNull(schemaFlavour, "schemaFlavour may not be null");
@@ -99,7 +94,7 @@ public class ContextSchemaFacade {
}
apexModel.getPolicyModel().getSchemas().getSchemasMap().put(key,
- new AxContextSchema(key, schemaFlavour, schemaDefinition));
+ new AxContextSchema(key, schemaFlavour, schemaDefinition));
if (apexModel.getPolicyModel().getKeyInformation().getKeyInfoMap().containsKey(key)) {
return keyInformationFacade.updateKeyInformation(name, version, uuid, description);
@@ -123,12 +118,12 @@ public class ContextSchemaFacade {
* @return result of the operation
*/
public ApexApiResult updateContextSchema(final String name, final String version, final String schemaFlavour,
- final String schemaDefinition, final String uuid, final String description) {
+ final String schemaDefinition, final String uuid, final String description) {
try {
final AxContextSchema schema = apexModel.getPolicyModel().getSchemas().get(name, version);
if (schema == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
+ CONCEPT + name + ':' + version + DOES_NOT_EXIST);
}
if (schemaFlavour != null) {
@@ -157,13 +152,13 @@ public class ContextSchemaFacade {
final Set<AxContextSchema> schemaSet = apexModel.getPolicyModel().getSchemas().getAll(name, version);
if (name != null && schemaSet.isEmpty()) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT_S + name + ':' + version + DO_ES_NOT_EXIST);
+ CONCEPT_S + name + ':' + version + DO_ES_NOT_EXIST);
}
final ApexApiResult result = new ApexApiResult();
for (final AxContextSchema schema : schemaSet) {
- result.addMessage(new ApexModelStringWriter<AxContextSchema>(false).writeString(schema,
- AxContextSchema.class, jsonMode));
+ result.addMessage(
+ new ApexModelStringWriter<AxContextSchema>(false).writeString(schema, AxContextSchema.class));
}
return result;
} catch (final Exception e) {
@@ -182,28 +177,28 @@ public class ContextSchemaFacade {
try {
if (version != null) {
final AxArtifactKey key = new AxArtifactKey(name, version);
- final AxContextSchema removedSchema = apexModel.getPolicyModel().getSchemas().getSchemasMap()
- .remove(key);
+ final AxContextSchema removedSchema =
+ apexModel.getPolicyModel().getSchemas().getSchemasMap().remove(key);
if (removedSchema != null) {
return new ApexApiResult(ApexApiResult.Result.SUCCESS,
- new ApexModelStringWriter<AxContextSchema>(false).writeString(removedSchema,
- AxContextSchema.class, jsonMode));
+ new ApexModelStringWriter<AxContextSchema>(false).writeString(removedSchema,
+ AxContextSchema.class));
} else {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + key.getId() + DOES_NOT_EXIST);
+ CONCEPT + key.getId() + DOES_NOT_EXIST);
}
}
final Set<AxContextSchema> schemaSet = apexModel.getPolicyModel().getSchemas().getAll(name, version);
if (schemaSet.isEmpty()) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT_S + name + ':' + version + DO_ES_NOT_EXIST);
+ CONCEPT_S + name + ':' + version + DO_ES_NOT_EXIST);
}
final ApexApiResult result = new ApexApiResult();
for (final AxContextSchema schema : schemaSet) {
- result.addMessage(new ApexModelStringWriter<AxContextSchema>(false).writeString(schema,
- AxContextSchema.class, jsonMode));
+ result.addMessage(
+ new ApexModelStringWriter<AxContextSchema>(false).writeString(schema, AxContextSchema.class));
apexModel.getPolicyModel().getSchemas().getSchemasMap().remove(schema.getKey());
keyInformationFacade.deleteKeyInformation(name, version);
}
@@ -225,14 +220,14 @@ public class ContextSchemaFacade {
final Set<AxContextSchema> schemaSet = apexModel.getPolicyModel().getSchemas().getAll(name, version);
if (schemaSet.isEmpty()) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT_S + name + ':' + version + DO_ES_NOT_EXIST);
+ CONCEPT_S + name + ':' + version + DO_ES_NOT_EXIST);
}
final ApexApiResult result = new ApexApiResult();
for (final AxContextSchema schema : schemaSet) {
final AxValidationResult validationResult = schema.validate(new AxValidationResult());
- result.addMessage(new ApexModelStringWriter<AxArtifactKey>(false).writeString(schema.getKey(),
- AxArtifactKey.class, jsonMode));
+ result.addMessage(
+ new ApexModelStringWriter<AxArtifactKey>(false).writeString(schema.getKey(), AxArtifactKey.class));
result.addMessage(validationResult.toString());
}
return result;
diff --git a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/EventFacade.java b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/EventFacade.java
index f1f939397..336f27b5d 100644
--- a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/EventFacade.java
+++ b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/EventFacade.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019,2022 Nordix Foundation.
* Modifications Copyright (C) 2022 Bell Canada.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -57,23 +57,17 @@ public class EventFacade {
// Facade classes for working towards the real Apex model
private final KeyInformationFacade keyInformationFacade;
- // JSON output on list/delete if set
- private final boolean jsonMode;
-
/**
* Constructor to create an event facade for the Model API.
*
* @param apexModel the apex model
* @param apexProperties Properties for the model
- * @param jsonMode set to true to return JSON strings in list and delete operations, otherwise
- * set to false
*/
- public EventFacade(final ApexModel apexModel, final Properties apexProperties, final boolean jsonMode) {
+ public EventFacade(final ApexModel apexModel, final Properties apexProperties) {
this.apexModel = apexModel;
this.apexProperties = apexProperties;
- this.jsonMode = jsonMode;
- keyInformationFacade = new KeyInformationFacade(apexModel, apexProperties, jsonMode);
+ keyInformationFacade = new KeyInformationFacade(apexModel, apexProperties);
}
/**
@@ -90,8 +84,8 @@ public class EventFacade {
* @return result of the operation
*/
public ApexApiResult createEvent(final String name, final String version, final String nameSpace,
- final String source, final String target, final String uuid, final String description,
- final String toscaPolicyState) {
+ final String source, final String target, final String uuid, final String description,
+ final String toscaPolicyState) {
try {
final AxArtifactKey key = new AxArtifactKey();
key.setName(name);
@@ -140,13 +134,13 @@ public class EventFacade {
* @return result of the operation
*/
public ApexApiResult updateEvent(final String name, final String version, final String nameSpace,
- final String source, final String target, final String uuid, final String description,
- final String toscaPolicyState) {
+ final String source, final String target, final String uuid, final String description,
+ final String toscaPolicyState) {
try {
final AxEvent event = apexModel.getPolicyModel().getEvents().get(name, version);
if (event == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
+ CONCEPT + name + ':' + version + DOES_NOT_EXIST);
}
if (nameSpace != null) {
@@ -180,13 +174,12 @@ public class EventFacade {
final Set<AxEvent> eventSet = apexModel.getPolicyModel().getEvents().getAll(name, version);
if (name != null && eventSet.isEmpty()) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT_S + name + ':' + version + DO_ES_NOT_EXIST);
+ CONCEPT_S + name + ':' + version + DO_ES_NOT_EXIST);
}
final ApexApiResult result = new ApexApiResult();
for (final AxEvent event : eventSet) {
- result.addMessage(
- new ApexModelStringWriter<AxEvent>(false).writeString(event, AxEvent.class, jsonMode));
+ result.addMessage(new ApexModelStringWriter<AxEvent>(false).writeString(event, AxEvent.class));
}
return result;
} catch (final Exception e) {
@@ -207,24 +200,23 @@ public class EventFacade {
final AxArtifactKey key = new AxArtifactKey(name, version);
final AxEvent removedEvent = apexModel.getPolicyModel().getEvents().getEventMap().remove(key);
if (removedEvent != null) {
- return new ApexApiResult(ApexApiResult.Result.SUCCESS, new ApexModelStringWriter<AxEvent>(false)
- .writeString(removedEvent, AxEvent.class, jsonMode));
+ return new ApexApiResult(ApexApiResult.Result.SUCCESS,
+ new ApexModelStringWriter<AxEvent>(false).writeString(removedEvent, AxEvent.class));
} else {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + key.getId() + DOES_NOT_EXIST);
+ CONCEPT + key.getId() + DOES_NOT_EXIST);
}
}
final Set<AxEvent> eventSet = apexModel.getPolicyModel().getEvents().getAll(name, version);
if (eventSet.isEmpty()) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT_S + name + ':' + version + DO_ES_NOT_EXIST);
+ CONCEPT_S + name + ':' + version + DO_ES_NOT_EXIST);
}
final ApexApiResult result = new ApexApiResult();
for (final AxEvent event : eventSet) {
- result.addMessage(
- new ApexModelStringWriter<AxEvent>(false).writeString(event, AxEvent.class, jsonMode));
+ result.addMessage(new ApexModelStringWriter<AxEvent>(false).writeString(event, AxEvent.class));
apexModel.getPolicyModel().getEvents().getEventMap().remove(event.getKey());
keyInformationFacade.deleteKeyInformation(name, version);
}
@@ -246,14 +238,14 @@ public class EventFacade {
final Set<AxEvent> eventSet = apexModel.getPolicyModel().getEvents().getAll(name, version);
if (eventSet.isEmpty()) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT_S + name + ':' + version + DO_ES_NOT_EXIST);
+ CONCEPT_S + name + ':' + version + DO_ES_NOT_EXIST);
}
final ApexApiResult result = new ApexApiResult();
for (final AxEvent event : eventSet) {
final AxValidationResult validationResult = event.validate(new AxValidationResult());
- result.addMessage(new ApexModelStringWriter<AxArtifactKey>(false).writeString(event.getKey(),
- AxArtifactKey.class, jsonMode));
+ result.addMessage(
+ new ApexModelStringWriter<AxArtifactKey>(false).writeString(event.getKey(), AxArtifactKey.class));
result.addMessage(validationResult.toString());
}
return result;
@@ -275,28 +267,28 @@ public class EventFacade {
* @return result of the operation
*/
public ApexApiResult createEventPar(final String name, final String version, final String parName,
- final String contextSchemaName, final String contextSchemaVersion, final boolean optional) {
+ final String contextSchemaName, final String contextSchemaVersion, final boolean optional) {
try {
Assertions.argumentNotNull(parName, "parName may not be null");
final AxEvent event = apexModel.getPolicyModel().getEvents().get(name, version);
if (event == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
+ CONCEPT + name + ':' + version + DOES_NOT_EXIST);
}
final AxReferenceKey refKey = new AxReferenceKey(event.getKey(), parName);
if (event.getParameterMap().containsKey(refKey.getLocalName())) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_EXISTS,
- CONCEPT + refKey.getId() + ALREADY_EXISTS);
+ CONCEPT + refKey.getId() + ALREADY_EXISTS);
}
final AxContextSchema schema =
- apexModel.getPolicyModel().getSchemas().get(contextSchemaName, contextSchemaVersion);
+ apexModel.getPolicyModel().getSchemas().get(contextSchemaName, contextSchemaVersion);
if (schema == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + contextSchemaName + ':' + contextSchemaVersion + DOES_NOT_EXIST);
+ CONCEPT + contextSchemaName + ':' + contextSchemaVersion + DOES_NOT_EXIST);
}
event.getParameterMap().put(refKey.getLocalName(), new AxField(refKey, schema.getKey(), optional));
@@ -319,28 +311,27 @@ public class EventFacade {
final AxEvent event = apexModel.getPolicyModel().getEvents().get(name, version);
if (event == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
+ CONCEPT + name + ':' + version + DOES_NOT_EXIST);
}
if (parName != null) {
final AxField eventField = event.getParameterMap().get(parName);
if (eventField != null) {
return new ApexApiResult(ApexApiResult.Result.SUCCESS,
- new ApexModelStringWriter<AxField>(false).writeString(eventField, AxField.class, jsonMode));
+ new ApexModelStringWriter<AxField>(false).writeString(eventField, AxField.class));
} else {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + ':' + parName + DOES_NOT_EXIST);
+ CONCEPT + name + ':' + version + ':' + parName + DOES_NOT_EXIST);
}
} else {
if (event.getParameterMap().size() == 0) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- "no parameters defined on event " + event.getKey().getId());
+ "no parameters defined on event " + event.getKey().getId());
}
final ApexApiResult result = new ApexApiResult();
for (final AxField eventPar : event.getParameterMap().values()) {
- result.addMessage(
- new ApexModelStringWriter<AxField>(false).writeString(eventPar, AxField.class, jsonMode));
+ result.addMessage(new ApexModelStringWriter<AxField>(false).writeString(eventPar, AxField.class));
}
return result;
}
@@ -362,29 +353,28 @@ public class EventFacade {
final AxEvent event = apexModel.getPolicyModel().getEvents().get(name, version);
if (event == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
+ CONCEPT + name + ':' + version + DOES_NOT_EXIST);
}
final ApexApiResult result = new ApexApiResult();
if (parName != null) {
if (event.getParameterMap().containsKey(parName)) {
result.addMessage(new ApexModelStringWriter<AxField>(false)
- .writeString(event.getParameterMap().get(parName), AxField.class, jsonMode));
+ .writeString(event.getParameterMap().get(parName), AxField.class));
event.getParameterMap().remove(parName);
return result;
} else {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + ':' + parName + DOES_NOT_EXIST);
+ CONCEPT + name + ':' + version + ':' + parName + DOES_NOT_EXIST);
}
} else {
if (event.getParameterMap().size() == 0) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- "no parameters defined on event " + event.getKey().getId());
+ "no parameters defined on event " + event.getKey().getId());
}
for (final AxField eventPar : event.getParameterMap().values()) {
- result.addMessage(
- new ApexModelStringWriter<AxField>(false).writeString(eventPar, AxField.class, jsonMode));
+ result.addMessage(new ApexModelStringWriter<AxField>(false).writeString(eventPar, AxField.class));
}
event.getParameterMap().clear();
return result;
@@ -393,4 +383,4 @@ public class EventFacade {
return new ApexApiResult(ApexApiResult.Result.FAILED, e);
}
}
-} \ No newline at end of file
+}
diff --git a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/KeyInformationFacade.java b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/KeyInformationFacade.java
index b76bfdc06..6875a4c20 100644
--- a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/KeyInformationFacade.java
+++ b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/KeyInformationFacade.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -51,9 +52,6 @@ public class KeyInformationFacade {
// Properties to use for the model
private final Properties apexProperties;
- // JSON output on list/delete if set
- private final boolean jsonMode;
-
/**
* Create key information.
*
@@ -65,7 +63,7 @@ public class KeyInformationFacade {
* @return result of the operation
*/
public ApexApiResult createKeyInformation(final String name, final String version, final String uuid,
- final String description) {
+ final String description) {
try {
final AxArtifactKey key = new AxArtifactKey();
key.setName(name);
@@ -107,12 +105,12 @@ public class KeyInformationFacade {
* @return result of the operation
*/
public ApexApiResult updateKeyInformation(final String name, final String version, final String uuid,
- final String description) {
+ final String description) {
try {
final AxKeyInfo keyInfo = apexModel.getPolicyModel().getKeyInformation().get(name, version);
if (keyInfo == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ":" + version + DOES_NOT_EXIST);
+ CONCEPT + name + ":" + version + DOES_NOT_EXIST);
}
if (description != null) {
@@ -145,13 +143,12 @@ public class KeyInformationFacade {
final Set<AxKeyInfo> keyInfoSet = apexModel.getPolicyModel().getKeyInformation().getAll(name, version);
if (name != null && keyInfoSet.isEmpty()) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT_S + name + ':' + version + DO_ES_NOT_EXIST);
+ CONCEPT_S + name + ':' + version + DO_ES_NOT_EXIST);
}
final ApexApiResult result = new ApexApiResult();
for (final AxKeyInfo keyInfo : keyInfoSet) {
- result.addMessage(
- new ApexModelStringWriter<AxKeyInfo>(false).writeString(keyInfo, AxKeyInfo.class, jsonMode));
+ result.addMessage(new ApexModelStringWriter<AxKeyInfo>(false).writeString(keyInfo, AxKeyInfo.class));
}
return result;
} catch (final Exception e) {
@@ -172,26 +169,25 @@ public class KeyInformationFacade {
if (version != null) {
final AxArtifactKey key = new AxArtifactKey(name, version);
final AxKeyInfo removedKeyInfo =
- apexModel.getPolicyModel().getKeyInformation().getKeyInfoMap().remove(key);
+ apexModel.getPolicyModel().getKeyInformation().getKeyInfoMap().remove(key);
if (removedKeyInfo != null) {
- return new ApexApiResult(ApexApiResult.Result.SUCCESS, new ApexModelStringWriter<AxKeyInfo>(false)
- .writeString(removedKeyInfo, AxKeyInfo.class, jsonMode));
+ return new ApexApiResult(ApexApiResult.Result.SUCCESS,
+ new ApexModelStringWriter<AxKeyInfo>(false).writeString(removedKeyInfo, AxKeyInfo.class));
} else {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + key.getId() + DOES_NOT_EXIST);
+ CONCEPT + key.getId() + DOES_NOT_EXIST);
}
}
final Set<AxKeyInfo> keyInfoSet = apexModel.getPolicyModel().getKeyInformation().getAll(name, version);
if (keyInfoSet.isEmpty()) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT_S + name + ':' + version + DO_ES_NOT_EXIST);
+ CONCEPT_S + name + ':' + version + DO_ES_NOT_EXIST);
}
final ApexApiResult result = new ApexApiResult();
for (final AxKeyInfo keyInfo : keyInfoSet) {
- result.addMessage(
- new ApexModelStringWriter<AxKeyInfo>(false).writeString(keyInfo, AxKeyInfo.class, jsonMode));
+ result.addMessage(new ApexModelStringWriter<AxKeyInfo>(false).writeString(keyInfo, AxKeyInfo.class));
apexModel.getPolicyModel().getKeyInformation().getKeyInfoMap().remove(keyInfo.getKey());
}
return result;
@@ -213,14 +209,14 @@ public class KeyInformationFacade {
final Set<AxKeyInfo> keyInfoSet = apexModel.getPolicyModel().getKeyInformation().getAll(name, version);
if (keyInfoSet.isEmpty()) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT_S + name + ':' + version + DO_ES_NOT_EXIST);
+ CONCEPT_S + name + ':' + version + DO_ES_NOT_EXIST);
}
final ApexApiResult result = new ApexApiResult();
for (final AxKeyInfo keyInfo : keyInfoSet) {
final AxValidationResult validationResult = keyInfo.validate(new AxValidationResult());
- result.addMessage(new ApexModelStringWriter<AxArtifactKey>(false).writeString(keyInfo.getKey(),
- AxArtifactKey.class, jsonMode));
+ result.addMessage(
+ new ApexModelStringWriter<AxArtifactKey>(false).writeString(keyInfo.getKey(), AxArtifactKey.class));
result.addMessage(validationResult.toString());
}
return result;
diff --git a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ModelFacade.java b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ModelFacade.java
index 2adf99050..1030a5bf5 100644
--- a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ModelFacade.java
+++ b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ModelFacade.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019,2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -49,26 +49,20 @@ public class ModelFacade {
// Facade classes for working towards the real Apex model
private final KeyInformationFacade keyInformationFacade;
- // JSON output on list/delete if set
- private final boolean jsonMode;
-
/**
* Constructor to create a model facade for the Apex model.
*
* @param apexModel the apex model
* @param apexProperties Properties for the model
- * @param jsonMode set to true to return JSON strings in list and delete operations, otherwise
- * set to false
*/
- public ModelFacade(final ApexModel apexModel, final Properties apexProperties, final boolean jsonMode) {
+ public ModelFacade(final ApexModel apexModel, final Properties apexProperties) {
Assertions.argumentNotNull(apexModel, "apexModel may not be null");
Assertions.argumentNotNull(apexProperties, "apexProperties may not be null");
this.apexModel = apexModel;
this.apexProperties = apexProperties;
- this.jsonMode = jsonMode;
- keyInformationFacade = new KeyInformationFacade(apexModel, apexProperties, jsonMode);
+ keyInformationFacade = new KeyInformationFacade(apexModel, apexProperties);
}
/**
@@ -81,7 +75,7 @@ public class ModelFacade {
* @return result of the operation
*/
public ApexApiResult createModel(final String name, final String version, final String uuid,
- final String description) {
+ final String description) {
try {
final AxArtifactKey key = new AxArtifactKey();
key.setName(name);
@@ -98,7 +92,7 @@ public class ModelFacade {
if (!apexModel.getPolicyModel().getKey().equals(AxArtifactKey.getNullKey())) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_EXISTS,
- CONCEPT + apexModel.getPolicyModel().getKey().getId() + ALREADY_CREATED);
+ CONCEPT + apexModel.getPolicyModel().getKey().getId() + ALREADY_CREATED);
}
apexModel.setPolicyModel(new AxPolicyModel(key));
@@ -107,6 +101,7 @@ public class ModelFacade {
result = keyInformationFacade.createKeyInformation(name, version, uuid, description);
if (result.getResult().equals(ApexApiResult.Result.SUCCESS)) {
+ apexModel.getPolicyModel().buildReferences();
apexModel.getPolicyModel().getKeyInformation().generateKeyInfo(apexModel.getPolicyModel());
}
return result;
@@ -125,7 +120,7 @@ public class ModelFacade {
* @return result of the operation
*/
public ApexApiResult updateModel(final String name, final String version, final String uuid,
- final String description) {
+ final String description) {
try {
final AxArtifactKey key = new AxArtifactKey();
key.setName(name);
@@ -137,13 +132,13 @@ public class ModelFacade {
key.setVersion(defaultVersion);
} else {
return new ApexApiResult(ApexApiResult.Result.FAILED,
- CONCEPT + apexModel.getPolicyModel().getKey().getId() + NO_VERSION_SPECIFIED);
+ CONCEPT + apexModel.getPolicyModel().getKey().getId() + NO_VERSION_SPECIFIED);
}
}
if (apexModel.getPolicyModel().getKey().equals(AxArtifactKey.getNullKey())) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + apexModel.getPolicyModel().getKey().getId() + DOES_NOT_EXIST);
+ CONCEPT + apexModel.getPolicyModel().getKey().getId() + DOES_NOT_EXIST);
}
return keyInformationFacade.updateKeyInformation(name, version, uuid, description);
@@ -161,8 +156,8 @@ public class ModelFacade {
try {
final ApexApiResult result = new ApexApiResult();
final AxArtifactKey modelkey = apexModel.getPolicyModel().getKey();
- result.addMessage(new ApexModelStringWriter<AxArtifactKey>(false).writeString(modelkey, AxArtifactKey.class,
- jsonMode));
+ result
+ .addMessage(new ApexModelStringWriter<AxArtifactKey>(false).writeString(modelkey, AxArtifactKey.class));
return result;
} catch (final Exception e) {
return new ApexApiResult(ApexApiResult.Result.FAILED, e);
@@ -178,7 +173,7 @@ public class ModelFacade {
try {
final ApexApiResult result = new ApexApiResult();
result.addMessage(new ApexModelStringWriter<AxPolicyModel>(false).writeString(apexModel.getPolicyModel(),
- AxPolicyModel.class, jsonMode));
+ AxPolicyModel.class));
return result;
} catch (final Exception e) {
return new ApexApiResult(ApexApiResult.Result.FAILED, e);
diff --git a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ModelHandlerFacade.java b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ModelHandlerFacade.java
index 9d03ba1e0..fecf92e1f 100644
--- a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ModelHandlerFacade.java
+++ b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ModelHandlerFacade.java
@@ -70,22 +70,17 @@ public class ModelHandlerFacade {
// Apex model we're working towards
private final ApexModel apexModel;
- // JSON output on list/delete if set
- private final boolean jsonMode;
-
/**
* This Constructor creates a model handling facade for the given {@link ApexModel}.
*
* @param apexModel the apex model to manipulate
* @param apexProperties properties for the model
- * @param jsonMode set to true to return JSON strings in list and delete operations, otherwise set to false
*/
- public ModelHandlerFacade(final ApexModel apexModel, final Properties apexProperties, final boolean jsonMode) {
+ public ModelHandlerFacade(final ApexModel apexModel, final Properties apexProperties) {
Assertions.argumentNotNull(apexModel, "apexModel may not be null");
Assertions.argumentNotNull(apexProperties, "apexProperties may not be null");
this.apexModel = apexModel;
- this.jsonMode = jsonMode;
}
/**
@@ -134,20 +129,15 @@ public class ModelHandlerFacade {
* Save an Apex model to a file.
*
* @param fileName the file name
- * @param xmlFlag if true, save the file in XML format, otherwise save the file in the default JSON format
* @return the result of the operation
*/
- public ApexApiResult saveToFile(final String fileName, final boolean xmlFlag) {
+ public ApexApiResult saveToFile(final String fileName) {
Assertions.argumentNotNull(fileName, FILE_NAME_MAY_NOT_BE_NULL);
ApexModelFileWriter<AxPolicyModel> apexModelFileWriter = new ApexModelFileWriter<>(false);
try {
- if (xmlFlag) {
- apexModelFileWriter.apexModelWriteXmlFile(apexModel.getPolicyModel(), AxPolicyModel.class, fileName);
- } else {
- apexModelFileWriter.apexModelWriteJsonFile(apexModel.getPolicyModel(), AxPolicyModel.class, fileName);
- }
+ apexModelFileWriter.apexModelWriteJsonFile(apexModel.getPolicyModel(), AxPolicyModel.class, fileName);
return new ApexApiResult();
} catch (ApexException e) {
return new ApexApiResult(ApexApiResult.Result.FAILED, e);
@@ -180,7 +170,7 @@ public class ModelHandlerFacade {
try {
ApexModelReader<AxPolicyModel> apexModelReader = new ApexModelReader<>(AxPolicyModel.class);
- apexModelReader.setValidateFlag(false);
+ apexModelReader.setValidate(false);
AxPolicyModel newPolicyModel = apexModelReader.read(apexModelUrl.openStream());
apexModel.setPolicyModel(newPolicyModel != null ? newPolicyModel : new AxPolicyModel());
return new ApexApiResult();
@@ -194,10 +184,9 @@ public class ModelHandlerFacade {
* Write an APEX model to a location identified by a URL.
*
* @param urlString the URL to read the model from
- * @param xmlFlag if true, save the file in XML format, otherwise save the file in the default JSON format
* @return the result of the operation
*/
- public ApexApiResult writeToUrl(final String urlString, final boolean xmlFlag) {
+ public ApexApiResult writeToUrl(final String urlString) {
Assertions.argumentNotNull(urlString, "urlString may not be null");
URL apexModelUrl;
@@ -212,8 +201,7 @@ public class ModelHandlerFacade {
try {
ApexModelWriter<AxPolicyModel> apexModelWriter = new ApexModelWriter<>(AxPolicyModel.class);
- apexModelWriter.setValidateFlag(false);
- apexModelWriter.setJsonOutput(!xmlFlag);
+ apexModelWriter.setValidate(false);
// Open the URL for output and write the model
URLConnection urlConnection = apexModelUrl.openConnection();
@@ -250,7 +238,7 @@ public class ModelHandlerFacade {
result.setResult(ApexApiResult.Result.FAILED);
}
result.addMessage(new ApexModelStringWriter<AxArtifactKey>(false)
- .writeString(apexModel.getPolicyModel().getKey(), AxArtifactKey.class, jsonMode));
+ .writeString(apexModel.getPolicyModel().getKey(), AxArtifactKey.class));
result.addMessage(validationResult.toString());
return result;
} catch (Exception e) {
@@ -277,7 +265,7 @@ public class ModelHandlerFacade {
PolicyModelComparer policyModelComparer =
new PolicyModelComparer(apexModel.getPolicyModel(), otherPolicyModel);
result.addMessage(new ApexModelStringWriter<AxArtifactKey>(false)
- .writeString(apexModel.getPolicyModel().getKey(), AxArtifactKey.class, jsonMode));
+ .writeString(apexModel.getPolicyModel().getKey(), AxArtifactKey.class));
result.addMessage(policyModelComparer.toString());
return result;
@@ -306,7 +294,7 @@ public class ModelHandlerFacade {
PolicyModelComparer policyModelComparer =
new PolicyModelComparer(apexModel.getPolicyModel(), otherPolicyModel);
result.addMessage(new ApexModelStringWriter<AxArtifactKey>(false)
- .writeString(apexModel.getPolicyModel().getKey(), AxArtifactKey.class, jsonMode));
+ .writeString(apexModel.getPolicyModel().getKey(), AxArtifactKey.class));
result.addMessage(policyModelComparer.toString());
return result;
@@ -470,7 +458,7 @@ public class ModelHandlerFacade {
try {
ApexModelReader<AxPolicyModel> apexModelReader = new ApexModelReader<>(AxPolicyModel.class);
- apexModelReader.setValidateFlag(false);
+ apexModelReader.setValidate(false);
readModel = apexModelReader.read(apexModelUrl.openStream());
result.setResult(ApexApiResult.Result.SUCCESS);
return readModel;
@@ -497,7 +485,7 @@ public class ModelHandlerFacade {
try {
ApexModelReader<AxPolicyModel> apexModelReader = new ApexModelReader<>(AxPolicyModel.class);
- apexModelReader.setValidateFlag(false);
+ apexModelReader.setValidate(false);
readModel = apexModelReader.read(modelStringStream);
result.setResult(ApexApiResult.Result.SUCCESS);
return readModel;
diff --git a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/PolicyFacade.java b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/PolicyFacade.java
index 4d0999ab1..408f0913f 100644
--- a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/PolicyFacade.java
+++ b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/PolicyFacade.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019,2022 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -72,23 +72,17 @@ public class PolicyFacade {
// Facade classes for working towards the real Apex model
private final KeyInformationFacade keyInformationFacade;
- // JSON output on list/delete if set
- private final boolean jsonMode;
-
/**
* Constructor that creates a policy facade for the Apex Model API.
*
* @param apexModel the apex model
* @param apexProperties Properties for the model
- * @param jsonMode set to true to return JSON strings in list and delete operations, otherwise
- * set to false
*/
- public PolicyFacade(final ApexModel apexModel, final Properties apexProperties, final boolean jsonMode) {
+ public PolicyFacade(final ApexModel apexModel, final Properties apexProperties) {
this.apexModel = apexModel;
this.apexProperties = apexProperties;
- this.jsonMode = jsonMode;
- keyInformationFacade = new KeyInformationFacade(apexModel, apexProperties, jsonMode);
+ keyInformationFacade = new KeyInformationFacade(apexModel, apexProperties);
}
/**
@@ -103,7 +97,7 @@ public class PolicyFacade {
* @return result of the operation
*/
public ApexApiResult createPolicy(final String name, final String version, final String template,
- final String firstState, final String uuid, final String description) {
+ final String firstState, final String uuid, final String description) {
try {
final AxArtifactKey key = new AxArtifactKey();
key.setName(name);
@@ -150,12 +144,12 @@ public class PolicyFacade {
* @return result of the operation
*/
public ApexApiResult updatePolicy(final String name, final String version, final String template,
- final String firstState, final String uuid, final String description) {
+ final String firstState, final String uuid, final String description) {
try {
final AxPolicy policy = apexModel.getPolicyModel().getPolicies().get(name, version);
if (policy == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
+ CONCEPT + name + ':' + version + DOES_NOT_EXIST);
}
if (template != null) {
@@ -183,13 +177,12 @@ public class PolicyFacade {
final Set<AxPolicy> policySet = apexModel.getPolicyModel().getPolicies().getAll(name, version);
if (name != null && policySet.isEmpty()) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT_S + name + ':' + version + DO_ES_NOT_EXIST);
+ CONCEPT_S + name + ':' + version + DO_ES_NOT_EXIST);
}
final ApexApiResult result = new ApexApiResult();
for (final AxPolicy policy : policySet) {
- result.addMessage(
- new ApexModelStringWriter<AxPolicy>(false).writeString(policy, AxPolicy.class, jsonMode));
+ result.addMessage(new ApexModelStringWriter<AxPolicy>(false).writeString(policy, AxPolicy.class));
}
return result;
} catch (final Exception e) {
@@ -210,24 +203,23 @@ public class PolicyFacade {
final AxArtifactKey key = new AxArtifactKey(name, version);
final AxPolicy removedPolicy = apexModel.getPolicyModel().getPolicies().getPolicyMap().remove(key);
if (removedPolicy != null) {
- return new ApexApiResult(ApexApiResult.Result.SUCCESS, new ApexModelStringWriter<AxPolicy>(false)
- .writeString(removedPolicy, AxPolicy.class, jsonMode));
+ return new ApexApiResult(ApexApiResult.Result.SUCCESS,
+ new ApexModelStringWriter<AxPolicy>(false).writeString(removedPolicy, AxPolicy.class));
} else {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + key.getId() + DOES_NOT_EXIST);
+ CONCEPT + key.getId() + DOES_NOT_EXIST);
}
}
final Set<AxPolicy> policySet = apexModel.getPolicyModel().getPolicies().getAll(name, version);
if (policySet.isEmpty()) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT_S + name + ':' + version + DO_ES_NOT_EXIST);
+ CONCEPT_S + name + ':' + version + DO_ES_NOT_EXIST);
}
final ApexApiResult result = new ApexApiResult();
for (final AxPolicy policy : policySet) {
- result.addMessage(
- new ApexModelStringWriter<AxPolicy>(false).writeString(policy, AxPolicy.class, jsonMode));
+ result.addMessage(new ApexModelStringWriter<AxPolicy>(false).writeString(policy, AxPolicy.class));
apexModel.getPolicyModel().getPolicies().getPolicyMap().remove(policy.getKey());
keyInformationFacade.deleteKeyInformation(name, version);
}
@@ -249,14 +241,14 @@ public class PolicyFacade {
final Set<AxPolicy> policySet = apexModel.getPolicyModel().getPolicies().getAll(name, version);
if (policySet.isEmpty()) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT_S + name + ':' + version + DO_ES_NOT_EXIST);
+ CONCEPT_S + name + ':' + version + DO_ES_NOT_EXIST);
}
final ApexApiResult result = new ApexApiResult();
for (final AxPolicy policy : policySet) {
final AxValidationResult validationResult = policy.validate(new AxValidationResult());
- result.addMessage(new ApexModelStringWriter<AxArtifactKey>(false).writeString(policy.getKey(),
- AxArtifactKey.class, jsonMode));
+ result.addMessage(
+ new ApexModelStringWriter<AxArtifactKey>(false).writeString(policy.getKey(), AxArtifactKey.class));
result.addMessage(validationResult.toString());
}
return result;
@@ -279,34 +271,34 @@ public class PolicyFacade {
* @return result of the operation
*/
public ApexApiResult createPolicyState(final String name, final String version, final String stateName,
- final String triggerName, final String triggerVersion, final String defaultTaskName,
- final String defaltTaskVersion) {
+ final String triggerName, final String triggerVersion, final String defaultTaskName,
+ final String defaltTaskVersion) {
try {
Assertions.argumentNotNull(stateName, STATE_NAME_MAY_NOT_BE_NULL);
final AxPolicy policy = apexModel.getPolicyModel().getPolicies().get(name, version);
if (policy == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
+ CONCEPT + name + ':' + version + DOES_NOT_EXIST);
}
final AxReferenceKey refKey = new AxReferenceKey(policy.getKey(), stateName);
if (policy.getStateMap().containsKey(refKey.getLocalName())) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_EXISTS,
- CONCEPT + refKey.getId() + ALREADY_EXISTS);
+ CONCEPT + refKey.getId() + ALREADY_EXISTS);
}
final AxEvent triggerEvent = apexModel.getPolicyModel().getEvents().get(triggerName, triggerVersion);
if (triggerEvent == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + triggerName + ':' + triggerVersion + DOES_NOT_EXIST);
+ CONCEPT + triggerName + ':' + triggerVersion + DOES_NOT_EXIST);
}
final AxTask defaultTask = apexModel.getPolicyModel().getTasks().get(defaultTaskName, defaltTaskVersion);
if (defaultTask == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + defaultTaskName + ':' + defaltTaskVersion + DOES_NOT_EXIST);
+ CONCEPT + defaultTaskName + ':' + defaltTaskVersion + DOES_NOT_EXIST);
}
final AxState state = new AxState(refKey);
@@ -334,38 +326,38 @@ public class PolicyFacade {
* @return result of the operation
*/
public ApexApiResult updatePolicyState(final String name, final String version, final String stateName,
- final String triggerName, final String triggerVersion, final String defaultTaskName,
- final String defaltTaskVersion) {
+ final String triggerName, final String triggerVersion, final String defaultTaskName,
+ final String defaltTaskVersion) {
try {
Assertions.argumentNotNull(stateName, STATE_NAME_MAY_NOT_BE_NULL);
final AxPolicy policy = apexModel.getPolicyModel().getPolicies().get(name, version);
if (policy == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
+ CONCEPT + name + ':' + version + DOES_NOT_EXIST);
}
final AxState state = policy.getStateMap().get(stateName);
if (state == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + policy.getKey().getId() + ':' + stateName + DOES_NOT_EXIST);
+ CONCEPT + policy.getKey().getId() + ':' + stateName + DOES_NOT_EXIST);
}
if (triggerName != null) {
final AxEvent triggerEvent = apexModel.getPolicyModel().getEvents().get(triggerName, triggerVersion);
if (triggerEvent == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + triggerName + ':' + triggerVersion + DOES_NOT_EXIST);
+ CONCEPT + triggerName + ':' + triggerVersion + DOES_NOT_EXIST);
}
state.setTrigger(triggerEvent.getKey());
}
if (defaultTaskName != null) {
final AxTask defaultTask =
- apexModel.getPolicyModel().getTasks().get(defaultTaskName, defaltTaskVersion);
+ apexModel.getPolicyModel().getTasks().get(defaultTaskName, defaltTaskVersion);
if (defaultTask == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + defaultTaskName + ':' + defaltTaskVersion + DOES_NOT_EXIST);
+ CONCEPT + defaultTaskName + ':' + defaltTaskVersion + DOES_NOT_EXIST);
}
state.setDefaultTask(defaultTask.getKey());
}
@@ -389,27 +381,26 @@ public class PolicyFacade {
final AxPolicy policy = apexModel.getPolicyModel().getPolicies().get(name, version);
if (policy == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
+ CONCEPT + name + ':' + version + DOES_NOT_EXIST);
}
if (stateName != null) {
final AxState state = policy.getStateMap().get(stateName);
if (state != null) {
return new ApexApiResult(ApexApiResult.Result.SUCCESS,
- new ApexModelStringWriter<AxState>(false).writeString(state, AxState.class, jsonMode));
+ new ApexModelStringWriter<AxState>(false).writeString(state, AxState.class));
} else {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + ':' + state + DOES_NOT_EXIST);
+ CONCEPT + name + ':' + version + ':' + state + DOES_NOT_EXIST);
}
} else {
if (policy.getStateMap().size() == 0) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- "no states defined on policy " + policy.getKey().getId());
+ "no states defined on policy " + policy.getKey().getId());
}
final ApexApiResult result = new ApexApiResult();
for (final AxState state : policy.getStateMap().values()) {
- result.addMessage(
- new ApexModelStringWriter<AxState>(false).writeString(state, AxState.class, jsonMode));
+ result.addMessage(new ApexModelStringWriter<AxState>(false).writeString(state, AxState.class));
}
return result;
}
@@ -431,28 +422,27 @@ public class PolicyFacade {
final AxPolicy policy = apexModel.getPolicyModel().getPolicies().get(name, version);
if (policy == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
+ CONCEPT + name + ':' + version + DOES_NOT_EXIST);
}
final ApexApiResult result = new ApexApiResult();
if (stateName != null) {
if (policy.getStateMap().containsKey(stateName)) {
result.addMessage(new ApexModelStringWriter<AxState>(false)
- .writeString(policy.getStateMap().get(stateName), AxState.class, jsonMode));
+ .writeString(policy.getStateMap().get(stateName), AxState.class));
policy.getStateMap().remove(stateName);
return result;
} else {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + ':' + stateName + DOES_NOT_EXIST);
+ CONCEPT + name + ':' + version + ':' + stateName + DOES_NOT_EXIST);
}
} else {
if (policy.getStateMap().size() == 0) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- "no states defined on policy " + policy.getKey().getId());
+ "no states defined on policy " + policy.getKey().getId());
}
for (final AxState state : policy.getStateMap().values()) {
- result.addMessage(
- new ApexModelStringWriter<AxState>(false).writeString(state, AxState.class, jsonMode));
+ result.addMessage(new ApexModelStringWriter<AxState>(false).writeString(state, AxState.class));
}
policy.getStateMap().clear();
return result;
@@ -474,20 +464,20 @@ public class PolicyFacade {
* @return result of the operation
*/
public ApexApiResult createPolicyStateTaskSelectionLogic(final String name, final String version,
- final String stateName, final String logicFlavour, final String logic) {
+ final String stateName, final String logicFlavour, final String logic) {
try {
Assertions.argumentNotNull(stateName, STATE_NAME_MAY_NOT_BE_NULL);
final AxPolicy policy = apexModel.getPolicyModel().getPolicies().get(name, version);
if (policy == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
+ CONCEPT + name + ':' + version + DOES_NOT_EXIST);
}
final AxState state = policy.getStateMap().get(stateName);
if (state == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + policy.getKey().getId() + ':' + stateName + DOES_NOT_EXIST);
+ CONCEPT + policy.getKey().getId() + ':' + stateName + DOES_NOT_EXIST);
}
// There is only one logic item associated with a state so we use a hard coded logic
@@ -496,7 +486,7 @@ public class PolicyFacade {
if (!state.getTaskSelectionLogic().getKey().getLocalName().equals(AxKey.NULL_KEY_NAME)) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_EXISTS,
- CONCEPT + refKey.getId() + ALREADY_EXISTS);
+ CONCEPT + refKey.getId() + ALREADY_EXISTS);
}
state.setTaskSelectionLogic(new AxTaskSelectionLogic(refKey, logicFlavour, logic));
@@ -517,25 +507,25 @@ public class PolicyFacade {
* @return result of the operation
*/
public ApexApiResult updatePolicyStateTaskSelectionLogic(final String name, final String version,
- final String stateName, final String logicFlavour, final String logic) {
+ final String stateName, final String logicFlavour, final String logic) {
try {
Assertions.argumentNotNull(stateName, STATE_NAME_MAY_NOT_BE_NULL);
final AxPolicy policy = apexModel.getPolicyModel().getPolicies().get(name, version);
if (policy == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
+ CONCEPT + name + ':' + version + DOES_NOT_EXIST);
}
final AxState state = policy.getStateMap().get(stateName);
if (state == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + policy.getKey().getId() + ':' + stateName + DOES_NOT_EXIST);
+ CONCEPT + policy.getKey().getId() + ':' + stateName + DOES_NOT_EXIST);
}
if (state.getTaskSelectionLogic().getKey().getLocalName().equals(AxKey.NULL_KEY_NAME)) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + state.getTaskSelectionLogic().getKey().getId() + DOES_NOT_EXIST);
+ CONCEPT + state.getTaskSelectionLogic().getKey().getId() + DOES_NOT_EXIST);
}
final AxTaskSelectionLogic taskSelectionLogic = state.getTaskSelectionLogic();
@@ -561,25 +551,25 @@ public class PolicyFacade {
* @return result of the operation
*/
public ApexApiResult listPolicyStateTaskSelectionLogic(final String name, final String version,
- final String stateName) {
+ final String stateName) {
try {
Assertions.argumentNotNull(stateName, STATE_NAME_MAY_NOT_BE_NULL);
final AxPolicy policy = apexModel.getPolicyModel().getPolicies().get(name, version);
if (policy == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
+ CONCEPT + name + ':' + version + DOES_NOT_EXIST);
}
final AxState state = policy.getStateMap().get(stateName);
if (state == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + policy.getKey().getId() + ':' + stateName + DOES_NOT_EXIST);
+ CONCEPT + policy.getKey().getId() + ':' + stateName + DOES_NOT_EXIST);
}
return new ApexApiResult(ApexApiResult.Result.SUCCESS,
- new ApexModelStringWriter<AxTaskSelectionLogic>(false).writeString(state.getTaskSelectionLogic(),
- AxTaskSelectionLogic.class, jsonMode));
+ new ApexModelStringWriter<AxTaskSelectionLogic>(false).writeString(state.getTaskSelectionLogic(),
+ AxTaskSelectionLogic.class));
} catch (final Exception e) {
return new ApexApiResult(ApexApiResult.Result.FAILED, e);
}
@@ -594,30 +584,30 @@ public class PolicyFacade {
* @return result of the operation
*/
public ApexApiResult deletePolicyStateTaskSelectionLogic(final String name, final String version,
- final String stateName) {
+ final String stateName) {
try {
Assertions.argumentNotNull(stateName, STATE_NAME_MAY_NOT_BE_NULL);
final AxPolicy policy = apexModel.getPolicyModel().getPolicies().get(name, version);
if (policy == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
+ CONCEPT + name + ':' + version + DOES_NOT_EXIST);
}
final AxState state = policy.getStateMap().get(stateName);
if (state == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + policy.getKey().getId() + ':' + stateName + DOES_NOT_EXIST);
+ CONCEPT + policy.getKey().getId() + ':' + stateName + DOES_NOT_EXIST);
}
if (state.getTaskSelectionLogic().getKey().getLocalName().equals(AxKey.NULL_KEY_NAME)) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + state.getTaskSelectionLogic().getKey().getId() + DOES_NOT_EXIST);
+ CONCEPT + state.getTaskSelectionLogic().getKey().getId() + DOES_NOT_EXIST);
}
final ApexApiResult result = new ApexApiResult();
result.addMessage(new ApexModelStringWriter<AxTaskSelectionLogic>(false)
- .writeString(state.getTaskSelectionLogic(), AxTaskSelectionLogic.class, jsonMode));
+ .writeString(state.getTaskSelectionLogic(), AxTaskSelectionLogic.class));
state.setTaskSelectionLogic(new AxTaskSelectionLogic());
return result;
} catch (final Exception e) {
@@ -640,7 +630,7 @@ public class PolicyFacade {
* @return result of the operation
*/
public ApexApiResult createPolicyStateOutput(final String name, final String version, final String stateName,
- final String outputName, final String eventName, final String eventVersion, final String nextState) {
+ final String outputName, final String eventName, final String eventVersion, final String nextState) {
try {
Assertions.argumentNotNull(stateName, STATE_NAME_MAY_NOT_BE_NULL);
Assertions.argumentNotNull(outputName, "outputName may not be null");
@@ -648,13 +638,13 @@ public class PolicyFacade {
final AxPolicy policy = apexModel.getPolicyModel().getPolicies().get(name, version);
if (policy == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- "Policy concept " + name + ':' + version + DOES_NOT_EXIST);
+ "Policy concept " + name + ':' + version + DOES_NOT_EXIST);
}
final AxState state = policy.getStateMap().get(stateName);
if (state == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- "State concept " + policy.getKey().getId() + ':' + stateName + DOES_NOT_EXIST);
+ "State concept " + policy.getKey().getId() + ':' + stateName + DOES_NOT_EXIST);
}
final AxReferenceKey refKey = new AxReferenceKey(state.getKey(), outputName);
@@ -668,20 +658,20 @@ public class PolicyFacade {
final AxEvent event = apexModel.getPolicyModel().getEvents().get(eventName, eventVersion);
if (event == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- "Event concept " + eventName + ':' + eventVersion + DOES_NOT_EXIST);
+ "Event concept " + eventName + ':' + eventVersion + DOES_NOT_EXIST);
}
AxReferenceKey nextStateKey = AxReferenceKey.getNullKey();
if (nextState != null && !(AxReferenceKey.getNullKey().getLocalName().equals(nextState))) {
if (state.getKey().getLocalName().equals(nextState)) {
return new ApexApiResult(ApexApiResult.Result.FAILED,
- "next state " + nextState + " of a state cannot be the state itself");
+ "next state " + nextState + " of a state cannot be the state itself");
}
nextStateKey = new AxReferenceKey(state.getKey().getParentArtifactKey(), nextState);
if (!policy.getStateMap().containsKey(nextState)) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- "Next state concept " + nextStateKey.getId() + DOES_NOT_EXIST);
+ "Next state concept " + nextStateKey.getId() + DOES_NOT_EXIST);
}
}
@@ -724,43 +714,42 @@ public class PolicyFacade {
* @return result of the operation
*/
public ApexApiResult listPolicyStateOutput(final String name, final String version, final String stateName,
- final String outputName) {
+ final String outputName) {
try {
Assertions.argumentNotNull(stateName, STATE_NAME_MAY_NOT_BE_NULL);
final AxPolicy policy = apexModel.getPolicyModel().getPolicies().get(name, version);
if (policy == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
+ CONCEPT + name + ':' + version + DOES_NOT_EXIST);
}
final AxState state = policy.getStateMap().get(stateName);
if (state == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + policy.getKey().getId() + ':' + stateName + DOES_NOT_EXIST);
+ CONCEPT + policy.getKey().getId() + ':' + stateName + DOES_NOT_EXIST);
}
if (outputName != null) {
final AxStateOutput stateOutput = state.getStateOutputs().get(outputName);
if (stateOutput != null) {
return new ApexApiResult(ApexApiResult.Result.SUCCESS,
- new ApexModelStringWriter<AxStateOutput>(false).writeString(stateOutput,
- AxStateOutput.class, jsonMode));
+ new ApexModelStringWriter<AxStateOutput>(false).writeString(stateOutput, AxStateOutput.class));
} else {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + state.getKey().getId() + ':' + outputName + DOES_NOT_EXIST);
+ CONCEPT + state.getKey().getId() + ':' + outputName + DOES_NOT_EXIST);
}
} else {
if (state.getStateOutputs().size() == 0) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- "no state output concepts exist for state " + state.getKey().getId());
+ "no state output concepts exist for state " + state.getKey().getId());
}
final ApexApiResult result = new ApexApiResult();
for (final AxStateOutput stateOutput : state.getStateOutputs().values()) {
- result.addMessage(new ApexModelStringWriter<AxStateOutput>(false).writeString(stateOutput,
- AxStateOutput.class, jsonMode));
+ result.addMessage(
+ new ApexModelStringWriter<AxStateOutput>(false).writeString(stateOutput, AxStateOutput.class));
}
return result;
}
@@ -779,45 +768,44 @@ public class PolicyFacade {
* @return result of the operation
*/
public ApexApiResult deletePolicyStateOutput(final String name, final String version, final String stateName,
- final String outputName) {
+ final String outputName) {
try {
Assertions.argumentNotNull(stateName, STATE_NAME_MAY_NOT_BE_NULL);
final AxPolicy policy = apexModel.getPolicyModel().getPolicies().get(name, version);
if (policy == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
+ CONCEPT + name + ':' + version + DOES_NOT_EXIST);
}
final AxState state = policy.getStateMap().get(stateName);
if (state == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + policy.getKey().getId() + ':' + stateName + DOES_NOT_EXIST);
+ CONCEPT + policy.getKey().getId() + ':' + stateName + DOES_NOT_EXIST);
}
if (outputName != null) {
final AxStateOutput stateOutput = state.getStateOutputs().get(outputName);
if (stateOutput != null) {
final ApexApiResult result = new ApexApiResult(ApexApiResult.Result.SUCCESS,
- new ApexModelStringWriter<AxStateOutput>(false).writeString(stateOutput,
- AxStateOutput.class, jsonMode));
+ new ApexModelStringWriter<AxStateOutput>(false).writeString(stateOutput, AxStateOutput.class));
state.getStateOutputs().remove(outputName);
return result;
} else {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + state.getKey().getId() + ':' + outputName + DOES_NOT_EXIST);
+ CONCEPT + state.getKey().getId() + ':' + outputName + DOES_NOT_EXIST);
}
} else {
if (state.getStateOutputs().size() == 0) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- "no state output concepts exist for state " + state.getKey().getId());
+ "no state output concepts exist for state " + state.getKey().getId());
}
final ApexApiResult result = new ApexApiResult();
for (final Entry<String, AxStateOutput> stateOutputEntry : state.getStateOutputs().entrySet()) {
result.addMessage(new ApexModelStringWriter<AxStateOutput>(false)
- .writeString(stateOutputEntry.getValue(), AxStateOutput.class, jsonMode));
+ .writeString(stateOutputEntry.getValue(), AxStateOutput.class));
}
state.getStateOutputs().clear();
return result;
@@ -840,7 +828,7 @@ public class PolicyFacade {
* @return result of the operation
*/
public ApexApiResult createPolicyStateFinalizerLogic(final String name, final String version,
- final String stateName, final String finalizerLogicName, final String logicFlavour, final String logic) {
+ final String stateName, final String finalizerLogicName, final String logicFlavour, final String logic) {
try {
Assertions.argumentNotNull(stateName, STATE_NAME_MAY_NOT_BE_NULL);
Assertions.argumentNotNull(finalizerLogicName, "finalizerlogicName may not be null");
@@ -848,24 +836,24 @@ public class PolicyFacade {
final AxPolicy policy = apexModel.getPolicyModel().getPolicies().get(name, version);
if (policy == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
+ CONCEPT + name + ':' + version + DOES_NOT_EXIST);
}
final AxState state = policy.getStateMap().get(stateName);
if (state == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + policy.getKey().getId() + ':' + stateName + DOES_NOT_EXIST);
+ CONCEPT + policy.getKey().getId() + ':' + stateName + DOES_NOT_EXIST);
}
final AxReferenceKey refKey = new AxReferenceKey(state.getKey(), finalizerLogicName);
if (state.getStateFinalizerLogicMap().containsKey(refKey.getLocalName())) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_EXISTS,
- CONCEPT + refKey.getId() + ALREADY_EXISTS);
+ CONCEPT + refKey.getId() + ALREADY_EXISTS);
}
state.getStateFinalizerLogicMap().put(finalizerLogicName,
- new AxStateFinalizerLogic(refKey, logicFlavour, logic));
+ new AxStateFinalizerLogic(refKey, logicFlavour, logic));
return new ApexApiResult();
} catch (final Exception e) {
return new ApexApiResult(ApexApiResult.Result.FAILED, e);
@@ -885,7 +873,7 @@ public class PolicyFacade {
* @return result of the operation
*/
public ApexApiResult updatePolicyStateFinalizerLogic(final String name, final String version,
- final String stateName, final String finalizerLogicName, final String logicFlavour, final String logic) {
+ final String stateName, final String finalizerLogicName, final String logicFlavour, final String logic) {
try {
Assertions.argumentNotNull(stateName, STATE_NAME_MAY_NOT_BE_NULL);
Assertions.argumentNotNull(finalizerLogicName, "finalizerLogicName may not be null");
@@ -893,21 +881,21 @@ public class PolicyFacade {
final AxPolicy policy = apexModel.getPolicyModel().getPolicies().get(name, version);
if (policy == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
+ CONCEPT + name + ':' + version + DOES_NOT_EXIST);
}
final AxState state = policy.getStateMap().get(stateName);
if (state == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + policy.getKey().getId() + ':' + stateName + DOES_NOT_EXIST);
+ CONCEPT + policy.getKey().getId() + ':' + stateName + DOES_NOT_EXIST);
}
final AxReferenceKey refKey = new AxReferenceKey(state.getKey(), finalizerLogicName);
final AxStateFinalizerLogic stateFinalizerLogic =
- state.getStateFinalizerLogicMap().get(refKey.getKey().getLocalName());
+ state.getStateFinalizerLogicMap().get(refKey.getKey().getLocalName());
if (stateFinalizerLogic == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- STATE_FINALIZER_LOGIC + refKey.getId() + DOES_NOT_EXIST);
+ STATE_FINALIZER_LOGIC + refKey.getId() + DOES_NOT_EXIST);
}
if (logicFlavour != null) {
@@ -933,43 +921,43 @@ public class PolicyFacade {
* @return result of the operation
*/
public ApexApiResult listPolicyStateFinalizerLogic(final String name, final String version, final String stateName,
- final String finalizerLogicName) {
+ final String finalizerLogicName) {
try {
Assertions.argumentNotNull(stateName, STATE_NAME_MAY_NOT_BE_NULL);
final AxPolicy policy = apexModel.getPolicyModel().getPolicies().get(name, version);
if (policy == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
+ CONCEPT + name + ':' + version + DOES_NOT_EXIST);
}
final AxState state = policy.getStateMap().get(stateName);
if (state == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + policy.getKey().getId() + ':' + stateName + DOES_NOT_EXIST);
+ CONCEPT + policy.getKey().getId() + ':' + stateName + DOES_NOT_EXIST);
}
if (finalizerLogicName != null) {
final AxReferenceKey refKey = new AxReferenceKey(state.getKey(), finalizerLogicName);
final AxStateFinalizerLogic stateFinalizerLogic =
- state.getStateFinalizerLogicMap().get(refKey.getKey().getLocalName());
+ state.getStateFinalizerLogicMap().get(refKey.getKey().getLocalName());
if (stateFinalizerLogic == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- STATE_FINALIZER_LOGIC + refKey.getId() + DOES_NOT_EXIST);
+ STATE_FINALIZER_LOGIC + refKey.getId() + DOES_NOT_EXIST);
}
return new ApexApiResult(ApexApiResult.Result.SUCCESS,
- new ApexModelStringWriter<AxStateFinalizerLogic>(false).writeString(stateFinalizerLogic,
- AxStateFinalizerLogic.class, jsonMode));
+ new ApexModelStringWriter<AxStateFinalizerLogic>(false).writeString(stateFinalizerLogic,
+ AxStateFinalizerLogic.class));
} else {
if (state.getStateFinalizerLogicMap().size() == 0) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- "no state finalizer logic defined on state " + state.getKey().getId());
+ "no state finalizer logic defined on state " + state.getKey().getId());
}
final ApexApiResult result = new ApexApiResult();
for (final AxStateFinalizerLogic stateFinalizerLogic : state.getStateFinalizerLogicMap().values()) {
result.addMessage(new ApexModelStringWriter<AxStateFinalizerLogic>(false)
- .writeString(stateFinalizerLogic, AxStateFinalizerLogic.class, jsonMode));
+ .writeString(stateFinalizerLogic, AxStateFinalizerLogic.class));
}
return result;
}
@@ -988,46 +976,46 @@ public class PolicyFacade {
* @return result of the operation
*/
public ApexApiResult deletePolicyStateFinalizerLogic(final String name, final String version,
- final String stateName, final String finalizerLogicName) {
+ final String stateName, final String finalizerLogicName) {
try {
Assertions.argumentNotNull(stateName, STATE_NAME_MAY_NOT_BE_NULL);
final AxPolicy policy = apexModel.getPolicyModel().getPolicies().get(name, version);
if (policy == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
+ CONCEPT + name + ':' + version + DOES_NOT_EXIST);
}
final AxState state = policy.getStateMap().get(stateName);
if (state == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + policy.getKey().getId() + ':' + stateName + DOES_NOT_EXIST);
+ CONCEPT + policy.getKey().getId() + ':' + stateName + DOES_NOT_EXIST);
}
if (finalizerLogicName != null) {
final AxReferenceKey refKey = new AxReferenceKey(state.getKey(), finalizerLogicName);
final AxStateFinalizerLogic stateFinalizerLogic =
- state.getStateFinalizerLogicMap().get(refKey.getKey().getLocalName());
+ state.getStateFinalizerLogicMap().get(refKey.getKey().getLocalName());
if (stateFinalizerLogic == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- STATE_FINALIZER_LOGIC + refKey.getId() + DOES_NOT_EXIST);
+ STATE_FINALIZER_LOGIC + refKey.getId() + DOES_NOT_EXIST);
}
final ApexApiResult result = new ApexApiResult();
result.addMessage(new ApexModelStringWriter<AxStateFinalizerLogic>(false)
- .writeString(stateFinalizerLogic, AxStateFinalizerLogic.class, jsonMode));
+ .writeString(stateFinalizerLogic, AxStateFinalizerLogic.class));
state.getStateFinalizerLogicMap().remove(refKey.getLocalName());
return result;
} else {
if (state.getStateFinalizerLogicMap().size() == 0) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- "no state finalizer logic defined on state " + state.getKey().getId());
+ "no state finalizer logic defined on state " + state.getKey().getId());
}
final ApexApiResult result = new ApexApiResult();
for (final AxStateFinalizerLogic stateFinalizerLogic : state.getStateFinalizerLogicMap().values()) {
result.addMessage(new ApexModelStringWriter<AxStateFinalizerLogic>(false)
- .writeString(stateFinalizerLogic, AxStateFinalizerLogic.class, jsonMode));
+ .writeString(stateFinalizerLogic, AxStateFinalizerLogic.class));
}
state.getStateFinalizerLogicMap().clear();
return result;
@@ -1049,38 +1037,28 @@ public class PolicyFacade {
Assertions.argumentNotNull(builder.getOutputName(), "outputName may not be null");
final AxPolicy policy =
- apexModel.getPolicyModel().getPolicies().get(builder.getName(), builder.getVersion());
+ apexModel.getPolicyModel().getPolicies().get(builder.getName(), builder.getVersion());
if (policy == null) {
- return new ApexApiResult(
- ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + builder.getName() + ':' + builder.getVersion() + DOES_NOT_EXIST);
+ return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
+ CONCEPT + builder.getName() + ':' + builder.getVersion() + DOES_NOT_EXIST);
}
final AxState state = policy.getStateMap().get(builder.getStateName());
if (state == null) {
- return new ApexApiResult(
- ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + policy.getKey().getId() + ':' + builder.getStateName() + DOES_NOT_EXIST);
+ return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
+ CONCEPT + policy.getKey().getId() + ':' + builder.getStateName() + DOES_NOT_EXIST);
}
final AxTask task =
- apexModel
- .getPolicyModel()
- .getTasks()
- .get(builder.getTaskName(), builder.getTaskVersion());
+ apexModel.getPolicyModel().getTasks().get(builder.getTaskName(), builder.getTaskVersion());
if (task == null) {
- return new ApexApiResult(
- ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + builder.getTaskName() + ':' + builder.getTaskVersion() + DOES_NOT_EXIST);
+ return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
+ CONCEPT + builder.getTaskName() + ':' + builder.getTaskVersion() + DOES_NOT_EXIST);
}
if (state.getTaskReferences().containsKey(task.getKey())) {
- return new ApexApiResult(
- ApexApiResult.Result.CONCEPT_EXISTS,
- "task "
- + task.getKey().getId()
- + " already has reference with output "
- + state.getTaskReferences().get(task.getKey()));
+ return new ApexApiResult(ApexApiResult.Result.CONCEPT_EXISTS, "task " + task.getKey().getId()
+ + " already has reference with output " + state.getTaskReferences().get(task.getKey()));
}
AxReferenceKey refKey;
@@ -1091,26 +1069,22 @@ public class PolicyFacade {
}
// The reference to the output we're using here
- final AxReferenceKey outputRefKey =
- new AxReferenceKey(state.getKey(), builder.getOutputName());
+ final AxReferenceKey outputRefKey = new AxReferenceKey(state.getKey(), builder.getOutputName());
- final AxStateTaskOutputType stateTaskOutputType =
- AxStateTaskOutputType.valueOf(builder.getOutputType());
+ final AxStateTaskOutputType stateTaskOutputType = AxStateTaskOutputType.valueOf(builder.getOutputType());
if (stateTaskOutputType.equals(AxStateTaskOutputType.DIRECT)) {
if (!state.getStateOutputs().containsKey(outputRefKey.getLocalName())) {
- return new ApexApiResult(
- ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- "state output concept " + outputRefKey.getId() + DOES_NOT_EXIST);
+ return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
+ "state output concept " + outputRefKey.getId() + DOES_NOT_EXIST);
}
} else if (stateTaskOutputType.equals(AxStateTaskOutputType.LOGIC)) {
if (!state.getStateFinalizerLogicMap().containsKey(outputRefKey.getLocalName())) {
- return new ApexApiResult(
- ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- "state finalizer logic concept " + outputRefKey.getId() + DOES_NOT_EXIST);
+ return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
+ "state finalizer logic concept " + outputRefKey.getId() + DOES_NOT_EXIST);
}
} else {
- return new ApexApiResult(
- ApexApiResult.Result.FAILED, "output type " + builder.getOutputType() + " invalid");
+ return new ApexApiResult(ApexApiResult.Result.FAILED,
+ "output type " + builder.getOutputType() + " invalid");
}
String outputRefName = outputRefKey.getLocalName();
@@ -1138,14 +1112,11 @@ public class PolicyFacade {
Map<String, AxEvent> outputEvents = new TreeMap<>();
if (state.getNextStateSet().isEmpty()
|| state.getNextStateSet().contains(AxReferenceKey.getNullKey().getLocalName())) {
- state.getStateOutputs().get(outputRefName).getOutgoingEventSet()
- .forEach(outgoingEventKey -> outputEvents.put(outgoingEventKey.getName(),
- apexModel.getPolicyModel().getEvents().get(outgoingEventKey)));
+ state.getStateOutputs().get(outputRefName).getOutgoingEventSet().forEach(outgoingEventKey -> outputEvents
+ .put(outgoingEventKey.getName(), apexModel.getPolicyModel().getEvents().get(outgoingEventKey)));
} else {
- AxArtifactKey outgoingEventKey =
- state.getStateOutputs().get(outputRefName).getOutgoingEvent();
- outputEvents.put(outgoingEventKey.getName(),
- apexModel.getPolicyModel().getEvents().get(outgoingEventKey));
+ AxArtifactKey outgoingEventKey = state.getStateOutputs().get(outputRefName).getOutgoingEvent();
+ outputEvents.put(outgoingEventKey.getName(), apexModel.getPolicyModel().getEvents().get(outgoingEventKey));
}
task.setOutputEvents(outputEvents);
}
@@ -1161,20 +1132,20 @@ public class PolicyFacade {
* @return result of the operation
*/
public ApexApiResult listPolicyStateTaskRef(final String name, final String version, final String stateName,
- final String taskName, final String taskVersion) {
+ final String taskName, final String taskVersion) {
try {
Assertions.argumentNotNull(stateName, STATE_NAME_MAY_NOT_BE_NULL);
final AxPolicy policy = apexModel.getPolicyModel().getPolicies().get(name, version);
if (policy == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
+ CONCEPT + name + ':' + version + DOES_NOT_EXIST);
}
final AxState state = policy.getStateMap().get(stateName);
if (state == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + policy.getKey().getId() + ':' + stateName + DOES_NOT_EXIST);
+ CONCEPT + policy.getKey().getId() + ':' + stateName + DOES_NOT_EXIST);
}
final ApexApiResult result = new ApexApiResult();
@@ -1184,21 +1155,21 @@ public class PolicyFacade {
final AxArtifactKey key = taskReferenceEntry.getKey();
final AxStateTaskReference value = taskReferenceEntry.getValue();
if ((taskName != null && !key.getName().equals(taskName))
- || (taskVersion != null && !key.getVersion().equals(taskVersion))) {
+ || (taskVersion != null && !key.getVersion().equals(taskVersion))) {
continue;
}
found = true;
- result.addMessage(new ApexModelStringWriter<AxArtifactKey>(false).writeString(key, AxArtifactKey.class,
- jsonMode));
+ result
+ .addMessage(new ApexModelStringWriter<AxArtifactKey>(false).writeString(key, AxArtifactKey.class));
result.addMessage(new ApexModelStringWriter<AxStateTaskReference>(false).writeString(value,
- AxStateTaskReference.class, jsonMode));
+ AxStateTaskReference.class));
}
if (found) {
return result;
} else {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- "no task references found for state " + state.getKey().getId());
+ "no task references found for state " + state.getKey().getId());
}
} catch (final Exception e) {
return new ApexApiResult(ApexApiResult.Result.FAILED, e);
@@ -1216,41 +1187,41 @@ public class PolicyFacade {
* @return result of the operation
*/
public ApexApiResult deletePolicyStateTaskRef(final String name, final String version, final String stateName,
- final String taskName, final String taskVersion) {
+ final String taskName, final String taskVersion) {
try {
Assertions.argumentNotNull(stateName, STATE_NAME_MAY_NOT_BE_NULL);
final AxPolicy policy = apexModel.getPolicyModel().getPolicies().get(name, version);
if (policy == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
+ CONCEPT + name + ':' + version + DOES_NOT_EXIST);
}
final AxState state = policy.getStateMap().get(stateName);
if (state == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + policy.getKey().getId() + ':' + stateName + DOES_NOT_EXIST);
+ CONCEPT + policy.getKey().getId() + ':' + stateName + DOES_NOT_EXIST);
}
final Set<AxArtifactKey> deleteSet = new TreeSet<>();
for (final AxArtifactKey taskReferenceKey : state.getTaskReferences().keySet()) {
if ((taskName != null && !taskReferenceKey.getName().equals(taskName))
- || (taskVersion != null && !taskReferenceKey.getVersion().equals(taskVersion))) {
+ || (taskVersion != null && !taskReferenceKey.getVersion().equals(taskVersion))) {
continue;
}
deleteSet.add(taskReferenceKey);
}
if (deleteSet.isEmpty()) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + taskName + ':' + taskVersion + DOES_NOT_EXIST_ON_STATE + state.getKey().getId());
+ CONCEPT + taskName + ':' + taskVersion + DOES_NOT_EXIST_ON_STATE + state.getKey().getId());
}
final ApexApiResult result = new ApexApiResult();
for (final AxArtifactKey keyToDelete : deleteSet) {
state.getTaskReferences().remove(keyToDelete);
- result.addMessage(new ApexModelStringWriter<AxArtifactKey>(false).writeString(keyToDelete,
- AxArtifactKey.class, jsonMode));
+ result.addMessage(
+ new ApexModelStringWriter<AxArtifactKey>(false).writeString(keyToDelete, AxArtifactKey.class));
}
return result;
} catch (final Exception e) {
@@ -1270,32 +1241,32 @@ public class PolicyFacade {
* @return result of the operation
*/
public ApexApiResult createPolicyStateContextRef(final String name, final String version, final String stateName,
- final String contextAlbumName, final String contextAlbumVersion) {
+ final String contextAlbumName, final String contextAlbumVersion) {
try {
Assertions.argumentNotNull(stateName, STATE_NAME_MAY_NOT_BE_NULL);
final AxPolicy policy = apexModel.getPolicyModel().getPolicies().get(name, version);
if (policy == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
+ CONCEPT + name + ':' + version + DOES_NOT_EXIST);
}
final AxState state = policy.getStateMap().get(stateName);
if (state == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + policy.getKey().getId() + ':' + stateName + DOES_NOT_EXIST);
+ CONCEPT + policy.getKey().getId() + ':' + stateName + DOES_NOT_EXIST);
}
final AxContextAlbum contextAlbum =
- apexModel.getPolicyModel().getAlbums().get(contextAlbumName, contextAlbumVersion);
+ apexModel.getPolicyModel().getAlbums().get(contextAlbumName, contextAlbumVersion);
if (contextAlbum == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + contextAlbumName + ':' + contextAlbumVersion + DOES_NOT_EXIST);
+ CONCEPT + contextAlbumName + ':' + contextAlbumVersion + DOES_NOT_EXIST);
}
if (state.getContextAlbumReferences().contains(contextAlbum.getKey())) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_EXISTS, "concept album reference for concept "
- + contextAlbum.getKey().getId() + " already exists in state");
+ + contextAlbum.getKey().getId() + " already exists in state");
}
state.getContextAlbumReferences().add(contextAlbum.getKey());
@@ -1318,36 +1289,36 @@ public class PolicyFacade {
* @return result of the operation
*/
public ApexApiResult listPolicyStateContextRef(final String name, final String version, final String stateName,
- final String contextAlbumName, final String contextAlbumVersion) {
+ final String contextAlbumName, final String contextAlbumVersion) {
try {
Assertions.argumentNotNull(stateName, STATE_NAME_MAY_NOT_BE_NULL);
final AxPolicy policy = apexModel.getPolicyModel().getPolicies().get(name, version);
if (policy == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
+ CONCEPT + name + ':' + version + DOES_NOT_EXIST);
}
final AxState state = policy.getStateMap().get(stateName);
if (state == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + policy.getKey().getId() + ':' + stateName + DOES_NOT_EXIST);
+ CONCEPT + policy.getKey().getId() + ':' + stateName + DOES_NOT_EXIST);
}
final ApexApiResult result = new ApexApiResult();
boolean found = false;
for (final AxArtifactKey albumKey : state.getContextAlbumReferences()) {
if ((contextAlbumName != null && !albumKey.getName().equals(contextAlbumName))
- || (contextAlbumVersion != null && !albumKey.getVersion().equals(contextAlbumVersion))) {
+ || (contextAlbumVersion != null && !albumKey.getVersion().equals(contextAlbumVersion))) {
continue;
}
- result.addMessage(new ApexModelStringWriter<AxArtifactKey>(false).writeString(albumKey,
- AxArtifactKey.class, jsonMode));
+ result.addMessage(
+ new ApexModelStringWriter<AxArtifactKey>(false).writeString(albumKey, AxArtifactKey.class));
found = true;
}
if (!found) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, CONCEPT + contextAlbumName + ':'
- + contextAlbumVersion + DOES_NOT_EXIST_ON_STATE + state.getKey().getId());
+ + contextAlbumVersion + DOES_NOT_EXIST_ON_STATE + state.getKey().getId());
}
return result;
} catch (final Exception e) {
@@ -1368,20 +1339,20 @@ public class PolicyFacade {
* @return result of the operation
*/
public ApexApiResult deletePolicyStateContextRef(final String name, final String version, final String stateName,
- final String contextAlbumName, final String contextAlbumVersion) {
+ final String contextAlbumName, final String contextAlbumVersion) {
try {
Assertions.argumentNotNull(stateName, STATE_NAME_MAY_NOT_BE_NULL);
final AxPolicy policy = apexModel.getPolicyModel().getPolicies().get(name, version);
if (policy == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
+ CONCEPT + name + ':' + version + DOES_NOT_EXIST);
}
final AxState state = policy.getStateMap().get(stateName);
if (state == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + policy.getKey().getId() + ':' + stateName + DOES_NOT_EXIST);
+ CONCEPT + policy.getKey().getId() + ':' + stateName + DOES_NOT_EXIST);
}
final Set<AxArtifactKey> deleteSet = new TreeSet<>();
@@ -1389,7 +1360,7 @@ public class PolicyFacade {
for (final AxArtifactKey albumKey : state.getContextAlbumReferences()) {
if ((contextAlbumName != null && !albumKey.getName().equals(contextAlbumName))
- || (contextAlbumVersion != null && !albumKey.getVersion().equals(contextAlbumVersion))) {
+ || (contextAlbumVersion != null && !albumKey.getVersion().equals(contextAlbumVersion))) {
continue;
}
@@ -1397,14 +1368,14 @@ public class PolicyFacade {
}
if (deleteSet.isEmpty()) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, CONCEPT + contextAlbumName + ':'
- + contextAlbumVersion + DOES_NOT_EXIST_ON_STATE + state.getKey().getId());
+ + contextAlbumVersion + DOES_NOT_EXIST_ON_STATE + state.getKey().getId());
}
final ApexApiResult result = new ApexApiResult();
for (final AxArtifactKey keyToDelete : deleteSet) {
state.getContextAlbumReferences().remove(keyToDelete);
- result.addMessage(new ApexModelStringWriter<AxArtifactKey>(false).writeString(keyToDelete,
- AxArtifactKey.class, jsonMode));
+ result.addMessage(
+ new ApexModelStringWriter<AxArtifactKey>(false).writeString(keyToDelete, AxArtifactKey.class));
}
return result;
} catch (final Exception e) {
diff --git a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/TaskFacade.java b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/TaskFacade.java
index ad1edd72e..6a2ded3e2 100644
--- a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/TaskFacade.java
+++ b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/TaskFacade.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019,2022 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -59,23 +59,17 @@ public class TaskFacade {
// Facade classes for working towards the real Apex model
private final KeyInformationFacade keyInformationFacade;
- // JSON output on list/delete if set
- private final boolean jsonMode;
-
/**
* Constructor that creates a task facade for the Apex Model API.
*
* @param apexModel the apex model
* @param apexProperties Properties for the model
- * @param jsonMode set to true to return JSON strings in list and delete operations, otherwise
- * set to false
*/
- public TaskFacade(final ApexModel apexModel, final Properties apexProperties, final boolean jsonMode) {
+ public TaskFacade(final ApexModel apexModel, final Properties apexProperties) {
this.apexModel = apexModel;
this.apexProperties = apexProperties;
- this.jsonMode = jsonMode;
- keyInformationFacade = new KeyInformationFacade(apexModel, apexProperties, jsonMode);
+ keyInformationFacade = new KeyInformationFacade(apexModel, apexProperties);
}
/**
@@ -88,7 +82,7 @@ public class TaskFacade {
* @return result of the operation
*/
public ApexApiResult createTask(final String name, final String version, final String uuid,
- final String description) {
+ final String description) {
try {
final AxArtifactKey key = new AxArtifactKey();
key.setName(name);
@@ -124,12 +118,12 @@ public class TaskFacade {
* @return result of the operation
*/
public ApexApiResult updateTask(final String name, final String version, final String uuid,
- final String description) {
+ final String description) {
try {
final AxTask task = apexModel.getPolicyModel().getTasks().get(name, version);
if (task == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
+ CONCEPT + name + ':' + version + DOES_NOT_EXIST);
}
return keyInformationFacade.updateKeyInformation(name, version, uuid, description);
@@ -150,12 +144,12 @@ public class TaskFacade {
final Set<AxTask> taskSet = apexModel.getPolicyModel().getTasks().getAll(name, version);
if (name != null && taskSet.isEmpty()) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT_S + name + ':' + version + DO_ES_NOT_EXIST);
+ CONCEPT_S + name + ':' + version + DO_ES_NOT_EXIST);
}
final ApexApiResult result = new ApexApiResult();
for (final AxTask task : taskSet) {
- result.addMessage(new ApexModelStringWriter<AxTask>(false).writeString(task, AxTask.class, jsonMode));
+ result.addMessage(new ApexModelStringWriter<AxTask>(false).writeString(task, AxTask.class));
}
return result;
} catch (final Exception e) {
@@ -177,22 +171,22 @@ public class TaskFacade {
final AxTask removedTask = apexModel.getPolicyModel().getTasks().getTaskMap().remove(key);
if (removedTask != null) {
return new ApexApiResult(ApexApiResult.Result.SUCCESS,
- new ApexModelStringWriter<AxTask>(false).writeString(removedTask, AxTask.class, jsonMode));
+ new ApexModelStringWriter<AxTask>(false).writeString(removedTask, AxTask.class));
} else {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + key.getId() + DOES_NOT_EXIST);
+ CONCEPT + key.getId() + DOES_NOT_EXIST);
}
}
final Set<AxTask> taskSet = apexModel.getPolicyModel().getTasks().getAll(name, version);
if (taskSet.isEmpty()) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT_S + name + ':' + version + DO_ES_NOT_EXIST);
+ CONCEPT_S + name + ':' + version + DO_ES_NOT_EXIST);
}
final ApexApiResult result = new ApexApiResult();
for (final AxTask task : taskSet) {
- result.addMessage(new ApexModelStringWriter<AxTask>(false).writeString(task, AxTask.class, jsonMode));
+ result.addMessage(new ApexModelStringWriter<AxTask>(false).writeString(task, AxTask.class));
apexModel.getPolicyModel().getTasks().getTaskMap().remove(task.getKey());
keyInformationFacade.deleteKeyInformation(name, version);
}
@@ -214,14 +208,14 @@ public class TaskFacade {
final Set<AxTask> taskSet = apexModel.getPolicyModel().getTasks().getAll(name, version);
if (taskSet.isEmpty()) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT_S + name + ':' + version + DO_ES_NOT_EXIST);
+ CONCEPT_S + name + ':' + version + DO_ES_NOT_EXIST);
}
final ApexApiResult result = new ApexApiResult();
for (final AxTask task : taskSet) {
final AxValidationResult validationResult = task.validate(new AxValidationResult());
- result.addMessage(new ApexModelStringWriter<AxArtifactKey>(false).writeString(task.getKey(),
- AxArtifactKey.class, jsonMode));
+ result.addMessage(
+ new ApexModelStringWriter<AxArtifactKey>(false).writeString(task.getKey(), AxArtifactKey.class));
result.addMessage(validationResult.toString());
}
return result;
@@ -241,12 +235,12 @@ public class TaskFacade {
* @return result of the operation
*/
public ApexApiResult createTaskLogic(final String name, final String version, final String logicFlavour,
- final String logic) {
+ final String logic) {
try {
final AxTask task = apexModel.getPolicyModel().getTasks().get(name, version);
if (task == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
+ CONCEPT + name + ':' + version + DOES_NOT_EXIST);
}
// There is only one logic item associated with a task so we use a hard coded logic name
@@ -254,7 +248,7 @@ public class TaskFacade {
if (!task.getTaskLogic().getKey().getLocalName().equals(AxKey.NULL_KEY_NAME)) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_EXISTS,
- CONCEPT + refKey.getId() + ALREADY_EXISTS);
+ CONCEPT + refKey.getId() + ALREADY_EXISTS);
}
task.setTaskLogic(new AxTaskLogic(refKey, logicFlavour, logic));
@@ -274,17 +268,17 @@ public class TaskFacade {
* @return result of the operation
*/
public ApexApiResult updateTaskLogic(final String name, final String version, final String logicFlavour,
- final String logic) {
+ final String logic) {
try {
final AxTask task = apexModel.getPolicyModel().getTasks().get(name, version);
if (task == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
+ CONCEPT + name + ':' + version + DOES_NOT_EXIST);
}
if (task.getTaskLogic().getKey().getLocalName().equals(AxKey.NULL_KEY_NAME)) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + task.getTaskLogic().getKey().getId() + DOES_NOT_EXIST);
+ CONCEPT + task.getTaskLogic().getKey().getId() + DOES_NOT_EXIST);
}
final AxTaskLogic taskLogic = task.getTaskLogic();
@@ -313,11 +307,11 @@ public class TaskFacade {
final AxTask task = apexModel.getPolicyModel().getTasks().get(name, version);
if (task == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
+ CONCEPT + name + ':' + version + DOES_NOT_EXIST);
}
- return new ApexApiResult(ApexApiResult.Result.SUCCESS, new ApexModelStringWriter<AxTaskLogic>(false)
- .writeString(task.getTaskLogic(), AxTaskLogic.class, jsonMode));
+ return new ApexApiResult(ApexApiResult.Result.SUCCESS,
+ new ApexModelStringWriter<AxTaskLogic>(false).writeString(task.getTaskLogic(), AxTaskLogic.class));
} catch (final Exception e) {
return new ApexApiResult(ApexApiResult.Result.FAILED, e);
}
@@ -335,17 +329,17 @@ public class TaskFacade {
final AxTask task = apexModel.getPolicyModel().getTasks().get(name, version);
if (task == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
+ CONCEPT + name + ':' + version + DOES_NOT_EXIST);
}
if (task.getTaskLogic().getKey().getLocalName().equals(AxKey.NULL_KEY_NAME)) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + task.getTaskLogic().getKey().getId() + DOES_NOT_EXIST);
+ CONCEPT + task.getTaskLogic().getKey().getId() + DOES_NOT_EXIST);
}
final ApexApiResult result = new ApexApiResult();
- result.addMessage(new ApexModelStringWriter<AxTaskLogic>(false).writeString(task.getTaskLogic(),
- AxTaskLogic.class, jsonMode));
+ result.addMessage(
+ new ApexModelStringWriter<AxTaskLogic>(false).writeString(task.getTaskLogic(), AxTaskLogic.class));
task.setTaskLogic(new AxTaskLogic());
return result;
} catch (final Exception e) {
@@ -363,21 +357,21 @@ public class TaskFacade {
* @return result of the operation
*/
public ApexApiResult createTaskParameter(final String name, final String version, final String parName,
- final String defaultValue) {
+ final String defaultValue) {
try {
Assertions.argumentNotNull(parName, "parName may not be null");
final AxTask task = apexModel.getPolicyModel().getTasks().get(name, version);
if (task == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
+ CONCEPT + name + ':' + version + DOES_NOT_EXIST);
}
final AxReferenceKey refKey = new AxReferenceKey(task.getKey(), parName);
if (task.getTaskParameters().containsKey(refKey.getLocalName())) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_EXISTS,
- CONCEPT + refKey.getId() + ALREADY_EXISTS);
+ CONCEPT + refKey.getId() + ALREADY_EXISTS);
}
task.getTaskParameters().put(refKey.getLocalName(), new AxTaskParameter(refKey, defaultValue));
@@ -400,29 +394,29 @@ public class TaskFacade {
final AxTask task = apexModel.getPolicyModel().getTasks().get(name, version);
if (task == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
+ CONCEPT + name + ':' + version + DOES_NOT_EXIST);
}
if (parName != null) {
final AxTaskParameter taskParameter = task.getTaskParameters().get(parName);
if (taskParameter != null) {
return new ApexApiResult(ApexApiResult.Result.SUCCESS,
- new ApexModelStringWriter<AxTaskParameter>(false).writeString(taskParameter,
- AxTaskParameter.class, jsonMode));
+ new ApexModelStringWriter<AxTaskParameter>(false).writeString(taskParameter,
+ AxTaskParameter.class));
} else {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + ':' + taskParameter + DOES_NOT_EXIST);
+ CONCEPT + name + ':' + version + ':' + taskParameter + DOES_NOT_EXIST);
}
} else {
if (task.getTaskParameters().size() == 0) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- "no task parameters defined on task " + task.getKey().getId());
+ "no task parameters defined on task " + task.getKey().getId());
}
final ApexApiResult result = new ApexApiResult();
for (final AxTaskParameter parameter : task.getTaskParameters().values()) {
result.addMessage(new ApexModelStringWriter<AxTaskParameter>(false).writeString(parameter,
- AxTaskParameter.class, jsonMode));
+ AxTaskParameter.class));
}
return result;
}
@@ -444,29 +438,29 @@ public class TaskFacade {
final AxTask task = apexModel.getPolicyModel().getTasks().get(name, version);
if (task == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
+ CONCEPT + name + ':' + version + DOES_NOT_EXIST);
}
final ApexApiResult result = new ApexApiResult();
if (parName != null) {
if (task.getTaskParameters().containsKey(parName)) {
result.addMessage(new ApexModelStringWriter<AxTaskParameter>(false)
- .writeString(task.getTaskParameters().get(parName), AxTaskParameter.class, jsonMode));
+ .writeString(task.getTaskParameters().get(parName), AxTaskParameter.class));
task.getTaskParameters().remove(parName);
return result;
} else {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + ':' + parName + DOES_NOT_EXIST);
+ CONCEPT + name + ':' + version + ':' + parName + DOES_NOT_EXIST);
}
} else {
if (task.getTaskParameters().size() == 0) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- "no task parameters defined on task " + task.getKey().getId());
+ "no task parameters defined on task " + task.getKey().getId());
}
for (final AxTaskParameter parameter : task.getTaskParameters().values()) {
result.addMessage(new ApexModelStringWriter<AxTaskParameter>(false).writeString(parameter,
- AxTaskParameter.class, jsonMode));
+ AxTaskParameter.class));
}
task.getTaskParameters().clear();
return result;
@@ -487,24 +481,24 @@ public class TaskFacade {
* @return result of the operation
*/
public ApexApiResult createTaskContextRef(final String name, final String version, final String contextAlbumName,
- final String contextAlbumVersion) {
+ final String contextAlbumVersion) {
try {
final AxTask task = apexModel.getPolicyModel().getTasks().get(name, version);
if (task == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
+ CONCEPT + name + ':' + version + DOES_NOT_EXIST);
}
final AxContextAlbum contextAlbum =
- apexModel.getPolicyModel().getAlbums().get(contextAlbumName, contextAlbumVersion);
+ apexModel.getPolicyModel().getAlbums().get(contextAlbumName, contextAlbumVersion);
if (contextAlbum == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + contextAlbumName + ':' + contextAlbumVersion + DOES_NOT_EXIST);
+ CONCEPT + contextAlbumName + ':' + contextAlbumVersion + DOES_NOT_EXIST);
}
if (task.getContextAlbumReferences().contains(contextAlbum.getKey())) {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_EXISTS, "context album reference for concept "
- + contextAlbum.getKey().getId() + " already exists in task");
+ return new ApexApiResult(ApexApiResult.Result.CONCEPT_EXISTS,
+ "context album reference for concept " + contextAlbum.getKey().getId() + " already exists in task");
}
task.getContextAlbumReferences().add(contextAlbum.getKey());
@@ -526,28 +520,28 @@ public class TaskFacade {
* @return result of the operation
*/
public ApexApiResult listTaskContextRef(final String name, final String version, final String contextAlbumName,
- final String contextAlbumVersion) {
+ final String contextAlbumVersion) {
try {
final AxTask task = apexModel.getPolicyModel().getTasks().get(name, version);
if (task == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
+ CONCEPT + name + ':' + version + DOES_NOT_EXIST);
}
final ApexApiResult result = new ApexApiResult();
boolean found = false;
for (final AxArtifactKey albumKey : task.getContextAlbumReferences()) {
if ((contextAlbumName != null && !albumKey.getName().equals(contextAlbumName))
- || (contextAlbumVersion != null && !albumKey.getVersion().equals(contextAlbumVersion))) {
+ || (contextAlbumVersion != null && !albumKey.getVersion().equals(contextAlbumVersion))) {
continue;
}
- result.addMessage(new ApexModelStringWriter<AxArtifactKey>(false).writeString(albumKey,
- AxArtifactKey.class, jsonMode));
+ result.addMessage(
+ new ApexModelStringWriter<AxArtifactKey>(false).writeString(albumKey, AxArtifactKey.class));
found = true;
}
if (!found) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + contextAlbumName + ':' + contextAlbumVersion + DOES_NOT_EXIST);
+ CONCEPT + contextAlbumName + ':' + contextAlbumVersion + DOES_NOT_EXIST);
}
return result;
} catch (final Exception e) {
@@ -567,19 +561,19 @@ public class TaskFacade {
* @return result of the operation
*/
public ApexApiResult deleteTaskContextRef(final String name, final String version, final String contextAlbumName,
- final String contextAlbumVersion) {
+ final String contextAlbumVersion) {
try {
final AxTask task = apexModel.getPolicyModel().getTasks().get(name, version);
if (task == null) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
+ CONCEPT + name + ':' + version + DOES_NOT_EXIST);
}
final Set<AxArtifactKey> deleteSet = new TreeSet<>();
for (final AxArtifactKey albumKey : task.getContextAlbumReferences()) {
if ((contextAlbumName != null && !albumKey.getName().equals(contextAlbumName))
- || (contextAlbumVersion != null && !albumKey.getVersion().equals(contextAlbumVersion))) {
+ || (contextAlbumVersion != null && !albumKey.getVersion().equals(contextAlbumVersion))) {
continue;
}
deleteSet.add(albumKey);
@@ -587,13 +581,13 @@ public class TaskFacade {
if (deleteSet.isEmpty()) {
return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + contextAlbumName + ':' + contextAlbumVersion + DOES_NOT_EXIST);
+ CONCEPT + contextAlbumName + ':' + contextAlbumVersion + DOES_NOT_EXIST);
}
final ApexApiResult result = new ApexApiResult();
for (final AxArtifactKey keyToDelete : deleteSet) {
task.getContextAlbumReferences().remove(keyToDelete);
- result.addMessage(new ApexModelStringWriter<AxArtifactKey>(false).writeString(keyToDelete,
- AxArtifactKey.class, jsonMode));
+ result.addMessage(
+ new ApexModelStringWriter<AxArtifactKey>(false).writeString(keyToDelete, AxArtifactKey.class));
}
return result;
} catch (final Exception e) {
diff --git a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiContextAlbumTest.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiContextAlbumTest.java
index e6ed351ae..5ce6b6760 100644
--- a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiContextAlbumTest.java
+++ b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiContextAlbumTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020,2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,12 +27,13 @@ import org.junit.Test;
/**
* Context album for API tests.
+ *
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class ApexEditorApiContextAlbumTest {
@Test
public void testContextAlbumCrud() {
- final ApexModel apexModel = new ApexModelFactory().createApexModel(null, false);
+ final ApexModel apexModel = new ApexModelFactory().createApexModel(null);
ApexApiResult result = apexModel.validateContextAlbum(null, null);
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
@@ -44,13 +45,13 @@ public class ApexEditorApiContextAlbumTest {
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createContextAlbum("MyMap002", "0.0.2", "APPLICATION", "true", "MapType", "0.0.1",
- "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002");
+ "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createContextAlbum("MyMap012", "0.1.2", "ZOOBY", "false", "MapType", "0.0.1",
- "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 012");
+ "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 012");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createContextAlbum("MyMap012", "0.1.4", "UNDEFINED", null, "MapType", "0.0.1",
- "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 014");
+ "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 014");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createContextAlbum("MyMap012", null, null, null, null, null, null, null);
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
@@ -73,16 +74,16 @@ public class ApexEditorApiContextAlbumTest {
result = apexModel.createContextAlbum("MyMap012", null, "EPHEMERAL", "false", "MapType", null, null, null);
assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult());
result = apexModel.createContextAlbum("MyMap002", "0.0.2", "APPLICATION", "true", "MapType", null,
- "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002");
+ "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002");
assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult());
result = apexModel.createContextAlbum("MyMap011", "0.1.2", "APPLICATION", "true", "MapType", "0.0.1",
- "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002");
+ "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.deleteContextAlbum("MyMap012", "0.1.2");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createContextAlbum("MyMap012", "0.1.2", "ZOOBY", "false", "MapType", "0.0.1",
- "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 012");
+ "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 012");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.validateContextAlbum(null, null);
@@ -95,7 +96,7 @@ public class ApexEditorApiContextAlbumTest {
result = apexModel.updateContextAlbum("MyMap002", "0.0.2", "ZOOBY", "true", null, null, null, null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.updateContextAlbum("MyMap002", "0.0.2", null, null, null, null,
- "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002");
+ "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.updateContextAlbum("MyMap012", null, null, null, null, null, null, null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
@@ -114,13 +115,13 @@ public class ApexEditorApiContextAlbumTest {
result = apexModel.updateContextAlbum("MyMap012", null, "APPLICATION", "false", "String", null, null, null);
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
result = apexModel.updateContextAlbum("MyMap012", null, "APPLICATION", "false", "StringType", "0.0.2", null,
- null);
+ null);
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
result = apexModel.updateContextAlbum("MyMap012", null, "APPLICATION", "false", "StringType", "0.0.1", null,
- null);
+ null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.updateContextAlbum("MyMap012", null, "APPLICATION", "Hello", "StringType", "0.0.1", null,
- null);
+ null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.listContextAlbum("@£%%$", null);
@@ -159,6 +160,7 @@ public class ApexEditorApiContextAlbumTest {
result = apexModel.deleteContextAlbum("MyMap012", null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ assertEquals(2, result.getMessages().size());
result = apexModel.listContextAlbum("MyMap012", null);
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
diff --git a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiContextSchemaTest.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiContextSchemaTest.java
index 04605f4a1..20310a29e 100644
--- a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiContextSchemaTest.java
+++ b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiContextSchemaTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020,2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,7 +32,7 @@ import org.junit.Test;
public class ApexEditorApiContextSchemaTest {
@Test
public void testContextSchemaCrud() {
- final ApexModel apexModel = new ApexModelFactory().createApexModel(null, false);
+ final ApexModel apexModel = new ApexModelFactory().createApexModel(null);
ApexApiResult result = apexModel.validateContextSchemas(null, null);
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
diff --git a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiEventTest.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiEventTest.java
index 775fcc1d3..ac9265e84 100644
--- a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiEventTest.java
+++ b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiEventTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020,2022 Nordix Foundation.
* Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -28,12 +28,13 @@ import org.junit.Test;
/**
* Test events for API tests.
+ *
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class ApexEditorApiEventTest {
@Test
public void testEventCrud() {
- final ApexModel apexModel = new ApexModelFactory().createApexModel(null, false);
+ final ApexModel apexModel = new ApexModelFactory().createApexModel(null);
ApexApiResult result = apexModel.validateEvent(null, null);
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
@@ -45,41 +46,41 @@ public class ApexEditorApiEventTest {
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createEvent("MyEvent002", "0.0.2", "My Namespace", "My Source", "my target",
- "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002", null);
+ "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002", null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createEvent("MyEvent012", "0.1.2", "My Namespace", "My Source", "my target",
- "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 012", null);
+ "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 012", null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createEvent("MyEvent012", "0.1.4", "My Namespace", "My Source", "my target",
- "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 014", null);
+ "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 014", null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createEvent("MyEvent012", null, null, null, null, null, null, null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createEvent("MyEvent012", null, null, null, null, null, null, null);
assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult());
result = apexModel.createEvent("MyEvent002", "0.0.2", "My Namespace", "My Source", "my target",
- "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002", null);
+ "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002", null);
assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult());
result = apexModel.createEvent("@£$%^", "0.2.5", "My Namespace", "My Source", "my target",
- "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002", null);
+ "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002", null);
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
result = apexModel.deleteEvent("MyEvent012", "0.1.4");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createEvent("MyEvent012", "0.1.4", "My Namespace", "My Source", "my target",
- "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 014", null);
+ "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 014", null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.validateEvent(null, null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.updateContextSchema(null, null, null, null, null, null);
+ result = apexModel.updateEvent(null, null, null, null, null, null, null, null);
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
- result = apexModel.updateEvent("MyEvent012", "0.1.2", "Another Namespace", null, "Another target", null, null,
- null);
+ result =
+ apexModel.updateEvent("MyEvent012", "0.1.2", "Another Namespace", null, "Another target", null, null, null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.updateEvent("MyEvent002", "0.0.2", "My Namespace", "My Source", "my target",
- "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002", null);
+ "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002", null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.updateEvent("MyEvent012", null, null, null, null, null, null, null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
@@ -140,6 +141,8 @@ public class ApexEditorApiEventTest {
result = apexModel.createEventPar("MyEvent002", "0.0.2", "NewPar00", null, null, true);
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = apexModel.createContextSchema("eventContextItem0", "0.0.1", "Java", "java.lang.Integer",
+ "1fa2e430-f2b2-11e6-bc64-92361f002673", "A further updated description of hola");
result = apexModel.createEventPar("MyEvent002", "0.0.2", "NewPar00", "eventContextItem0", null, false);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createEventPar("MyEvent002", "0.0.2", "NewPar00", "eventContextItem0", null, true);
@@ -196,4 +199,4 @@ public class ApexEditorApiEventTest {
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
assertEquals(0, result.getMessages().size());
}
-} \ No newline at end of file
+}
diff --git a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiKeyInfoTest.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiKeyInfoTest.java
index caa25e4a4..2519b8cb2 100644
--- a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiKeyInfoTest.java
+++ b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiKeyInfoTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020,2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,7 +33,7 @@ public class ApexEditorApiKeyInfoTest {
@Test
public void testKeyInfoCrud() {
- final ApexModel apexModel = new ApexModelFactory().createApexModel(null, false);
+ final ApexModel apexModel = new ApexModelFactory().createApexModel(null);
ApexApiResult result = apexModel.validateKeyInformation(null, null);
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
diff --git a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiPolicyTest.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiPolicyTest.java
index 3e78921e9..0a4d72214 100644
--- a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiPolicyTest.java
+++ b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiPolicyTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020,2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,7 +33,7 @@ import org.junit.Test;
public class ApexEditorApiPolicyTest {
@Test
public void testMyTestPolicyCrud() {
- final ApexModel apexModel = new ApexModelFactory().createApexModel(null, false);
+ final ApexModel apexModel = new ApexModelFactory().createApexModel(null);
ApexApiResult result = apexModel.validatePolicy(null, null);
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
@@ -45,10 +45,10 @@ public class ApexEditorApiPolicyTest {
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createPolicy("MyPolicy002", "0.0.2", "SomeTemplate", "AState",
- "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002");
+ "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createPolicy("MyPolicy002", "0.0.2", "SomeTemplate", "AState",
- "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002");
+ "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002");
assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult());
result = apexModel.createPolicy("MyPolicy012", null, null, null, null, null);
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
@@ -59,19 +59,19 @@ public class ApexEditorApiPolicyTest {
result = apexModel.createPolicy("MyPolicy012", null, "SomeTemplate", "AState", null, null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createPolicy("MyPolicy002", "0.0.2", "SomeTemplate", "AState",
- "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002");
+ "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002");
assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult());
result = apexModel.createPolicy("MyPolicy012", "0.1.2", "SomeTemplate", "AState",
- "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002");
+ "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createPolicy("MyTestPolicy", "0.0.1", "SomeTemplate", "TestState",
- "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002");
+ "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.deletePolicy("MyPolicy002", "0.0.2");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createPolicy("MyPolicy002", "0.0.2", "SomeTemplate", "AState",
- "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002");
+ "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.validatePolicy(null, null);
@@ -84,7 +84,7 @@ public class ApexEditorApiPolicyTest {
result = apexModel.updatePolicy("MyPolicy002", "0.0.1", null, null, null, null);
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
result = apexModel.updatePolicy("MyPolicy002", "0.0.2", "SomeOtherTemplate", "BState",
- "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002");
+ "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.updatePolicy("MyPolicy012", null, "SomeOtherTemplate", null, null, null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
@@ -137,7 +137,6 @@ public class ApexEditorApiPolicyTest {
result = apexModel.deletePolicy("MyPolicy012", null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
assertEquals(2, result.getMessages().size());
-
result = apexModel.createPolicyState(null, null, null, null, null, null, null);
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
result = apexModel.createPolicyState("MyPolicy123", null, null, null, null, null, null);
@@ -255,15 +254,15 @@ public class ApexEditorApiPolicyTest {
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
result = apexModel.createPolicyState("MyTestPolicy", "0.0.1", "TestState1", "inEvent", "0.0.1", "task",
- "0.0.1");
+ "0.0.1");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createPolicyState("MyTestPolicy", "0.0.1", "TestState2", "outEvent0", "0.0.1", "task",
- "0.0.1");
+ "0.0.1");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createPolicyState("MyTestPolicy", "0.0.1", "TestState3", "outEvent1", "0.0.1", "task",
- "0.0.1");
+ "0.0.1");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createPolicyStateTaskSelectionLogic(null, null, null, null, null);
@@ -279,29 +278,29 @@ public class ApexEditorApiPolicyTest {
result = apexModel.createPolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "TestState1", "NewTSL00", null);
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
result = apexModel.createPolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "TestState1", "UNDEFINED",
- "Some Policy Logic");
+ "Some Policy Logic");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createPolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "TestState1", "MVEL",
- "Some Policy Logic");
+ "Some Policy Logic");
assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult());
result = apexModel.deletePolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "TestState1");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createPolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "TestState1", "JAVA",
- "Some Policy Logic");
+ "Some Policy Logic");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createPolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "TestState1", "JYTHON",
- "Some Policy Logic");
+ "Some Policy Logic");
assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult());
result = apexModel.deletePolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "TestState1");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createPolicyStateTaskSelectionLogic("MyTestPolicy", null, "TestState1", "JAVASCRIPT",
- "Some Policy Logic");
+ "Some Policy Logic");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.deletePolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "TestState1");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createPolicyStateTaskSelectionLogic("MyTestPolicy", null, "TestState1", "JRUBY",
- "Some Policy Logic");
+ "Some Policy Logic");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.updatePolicyStateTaskSelectionLogic(null, null, null, null, null);
@@ -321,15 +320,15 @@ public class ApexEditorApiPolicyTest {
result = apexModel.updatePolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "NonExistantState", null, null);
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
result = apexModel.updatePolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "TestState1", "",
- "Some Other Policy Logic");
+ "Some Other Policy Logic");
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
result = apexModel.updatePolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "TestState1", "MVEL",
- "Some Other Policy Logic");
+ "Some Other Policy Logic");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.updatePolicyStateTaskSelectionLogic("MyPolicy012", null, "TestState1", null, null);
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
result = apexModel.updatePolicyStateTaskSelectionLogic("MyTestPolicy", null, "TestState1", null,
- "Some Other Policy Logic");
+ "Some Other Policy Logic");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.updatePolicyStateTaskSelectionLogic("MyTestPolicy", null, "TestState1", null, null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
@@ -373,13 +372,13 @@ public class ApexEditorApiPolicyTest {
result = apexModel.deletePolicyStateTaskSelectionLogic("MyTestPolicy", "0.0.1", "TestState1");
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
result = apexModel.updatePolicyStateTaskSelectionLogic("MyTestPolicy", null, "TestState1", null,
- "Some Other Policy Logic");
+ "Some Other Policy Logic");
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
result = apexModel.listPolicyStateTaskSelectionLogic("MyTestPolicy", null, "TestState1");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
assertEquals(1, result.getMessages().size());
result = apexModel.createPolicyStateTaskSelectionLogic("MyTestPolicy", null, "TestState1", "JRUBY",
- "Some Policy Logic");
+ "Some Policy Logic");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.listPolicyStateTaskSelectionLogic("MyTestPolicy", null, "TestState1");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
@@ -397,37 +396,37 @@ public class ApexEditorApiPolicyTest {
result = apexModel.createPolicyStateOutput("MyTestPolicy", null, "SomeState", "SomeOutput", null, null, null);
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
result = apexModel.createPolicyStateOutput("MyTestPolicy", "1.2.3", "TestState1", "SomeOutput", null, null,
- null);
+ null);
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState1", "SomeOutput", null, null,
- null);
+ null);
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState1", "SomeOutput",
- "SomeDummyEvent", null, null);
+ "SomeDummyEvent", null, null);
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState1", "SomeOutput", "inEvent",
- "1.2.3", null);
+ "1.2.3", null);
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState1", "SomeOutput", "inEvent",
- "0.0.1", "SomeDummyNextState");
+ "0.0.1", "SomeDummyNextState");
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState1", "SomeOutput", "inEvent",
- "0.0.1", null);
+ "0.0.1", null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState1", "SomeOtherOutput", "inEvent",
- "0.0.1", "TestState1");
+ "0.0.1", "TestState1");
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState1", "SomeOtherOutput", "inEvent",
- "0.0.1", "TestState2");
+ "0.0.1", "TestState2");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState1", "SomeOtherOutput", "inEvent",
- "0.0.1", "TestState2");
+ "0.0.1", "TestState2");
assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult());
result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState2", "AnotherOtherOutput",
- "outEvent0", "0.0.1", "TestState3");
+ "outEvent0", "0.0.1", "TestState3");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState2", "YetAnotherOtherOutput",
- "outEvent0", "0.0.1", "TestState3");
+ "outEvent0", "0.0.1", "TestState3");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.listPolicyStateOutput(null, null, null, null);
@@ -495,19 +494,19 @@ public class ApexEditorApiPolicyTest {
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState1", "SomeOutput", "inEvent",
- "0.0.1", null);
+ "0.0.1", null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState1", "SomeOtherOutput", "inEvent",
- "0.0.1", "TestState1");
+ "0.0.1", "TestState1");
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState1", "SomeOtherOutput", "inEvent",
- "0.0.1", "TestState2");
+ "0.0.1", "TestState2");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState2", "AnotherOtherOutput",
- "outEvent0", "0.0.1", "TestState3");
+ "outEvent0", "0.0.1", "TestState3");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createPolicyStateOutput("MyTestPolicy", "0.0.1", "TestState2", "YetAnotherOtherOutput",
- "outEvent0", "0.0.1", "TestState3");
+ "outEvent0", "0.0.1", "TestState3");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createPolicyStateFinalizerLogic(null, null, null, null, null, null);
@@ -519,34 +518,34 @@ public class ApexEditorApiPolicyTest {
result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", null, "SomeState", "SFLName01", null, null);
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", "1.2.3", "TestState1", "SFLName01", null,
- null);
+ null);
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName01", null,
- null);
+ null);
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName01",
- "NewTSL00", null);
+ "NewTSL00", null);
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName02",
- "UNDEFINED", "Some Policy Logic");
+ "UNDEFINED", "Some Policy Logic");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName03", "MVEL",
- "Some Policy Logic");
+ "Some Policy Logic");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName03", "MVEL",
- "Some Policy Logic");
+ "Some Policy Logic");
assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult());
result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName04", "JAVA",
- "Some Policy Logic");
+ "Some Policy Logic");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName05", "JYTHON",
- "Some Policy Logic");
+ "Some Policy Logic");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", null, "TestState1", "SFLName06",
- "JAVASCRIPT", "Some Policy Logic");
+ "JAVASCRIPT", "Some Policy Logic");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", null, "TestState1", "SFLName07", "JRUBY",
- "Some Policy Logic");
+ "Some Policy Logic");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.updatePolicyStateFinalizerLogic(null, null, null, null, null, null);
@@ -556,37 +555,37 @@ public class ApexEditorApiPolicyTest {
result = apexModel.updatePolicyStateFinalizerLogic("MyTestPolicy", null, "TestState1", null, null, null);
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
result = apexModel.updatePolicyStateFinalizerLogic("MyTestPolicy", null, "TestState99", "SomeSFLName", null,
- null);
+ null);
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
result = apexModel.updatePolicyStateFinalizerLogic("MyTestPolicy2", null, "TestState1", "SomeSFLName", null,
- null);
+ null);
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
result = apexModel.updatePolicyStateFinalizerLogic("MyTestPolicy1", "0.0.2", "TestState1", "SomeSFLName", null,
- null);
+ null);
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
result = apexModel.updatePolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "NonEistantSFL", null,
- null);
+ null);
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
result = apexModel.updatePolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName06", null,
- null);
+ null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.updatePolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName06", "",
- "Some Other Policy Logic");
+ "Some Other Policy Logic");
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
result = apexModel.updatePolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName06", "MVEL",
- "Some Other Policy Logic");
+ "Some Other Policy Logic");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.updatePolicyStateFinalizerLogic("MyPolicy012", null, "TestState1", "SFLName06", null, null);
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
result = apexModel.updatePolicyStateFinalizerLogic("MyTestPolicy", null, "TestState1", "SFLName06", null,
- "Some Other Policy Logic");
+ "Some Other Policy Logic");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.updatePolicyStateFinalizerLogic("MyTestPolicy", null, "TestState1", "SFLName06", null, null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.updatePolicyStateFinalizerLogic("MyPolicy015", null, "TestState1", "SFLName06", null, null);
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
result = apexModel.updatePolicyStateFinalizerLogic("MyPolicy014", "0.1.5", "TestState1", "SFLName06", null,
- null);
+ null);
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
result = apexModel.listPolicyStateFinalizerLogic(null, null, null, null);
@@ -669,22 +668,22 @@ public class ApexEditorApiPolicyTest {
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName02",
- "UNDEFINED", "Some Policy Logic");
+ "UNDEFINED", "Some Policy Logic");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName03", "MVEL",
- "Some Policy Logic");
+ "Some Policy Logic");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName04", "JAVA",
- "Some Policy Logic");
+ "Some Policy Logic");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", "0.0.1", "TestState1", "SFLName05", "JYTHON",
- "Some Policy Logic");
+ "Some Policy Logic");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", null, "TestState1", "SFLName06",
- "JAVASCRIPT", "Some Policy Logic");
+ "JAVASCRIPT", "Some Policy Logic");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createPolicyStateFinalizerLogic("MyTestPolicy", null, "TestState1", "SFLName07", "JRUBY",
- "Some Policy Logic");
+ "Some Policy Logic");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createTask("TestTask0", null, null, null);
@@ -705,81 +704,81 @@ public class ApexEditorApiPolicyTest {
result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "SomeState", null, null, null, null, null);
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "SomeState", null, null, null, null,
- "DummyOutput");
+ "DummyOutput");
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
result = apexModel.createPolicyStateTaskRef("MyTestPolicy", "1.2.3", "SomeState", null, null, null, null,
- "DummyOutput");
+ "DummyOutput");
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
result = apexModel.createPolicyStateTaskRef("AnyOldPolicy", "1.2.3", "SomeState", null, null, null, null,
- "DummyOutput");
+ "DummyOutput");
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
result = apexModel.createPolicyStateTaskRef("MyTestPolicy", "0.0.1", "TestState1", "SomeTaskLocalName", null,
- null, null, "DummyOutput");
+ null, null, "DummyOutput");
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
result = apexModel.createPolicyStateTaskRef("MyTestPolicy", "0.0.1", "TestState1", "SomeTaskLocalName",
- "SomeTask", "Zooby|", null, "DummyOutput");
+ "SomeTask", "Zooby|", null, "DummyOutput");
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
result = apexModel.createPolicyStateTaskRef("MyTestPolicy", "0.0.1", "TestState1", "SomeTaskLocalName",
- "SomeTask", "0.0.1", null, "DummyOutput");
+ "SomeTask", "0.0.1", null, "DummyOutput");
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
result = apexModel.createPolicyStateTaskRef("MyTestPolicy", "0.0.1", "TestState1", "SomeTaskLocalName", "task",
- "0.0.1", null, "DummyOutput");
+ "0.0.1", null, "DummyOutput");
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
result = apexModel.createPolicyStateTaskRef("MyTestPolicy", "0.0.1", "TestState1", "SomeTaskLocalName", "task",
- "0.0.1", "Some Policy Logic", "DummyOutput");
+ "0.0.1", "Some Policy Logic", "DummyOutput");
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
result = apexModel.createPolicyStateTaskRef("MyTestPolicy", "0.0.1", "TestState1", "SomeTaskLocalName", "task",
- "0.0.1", "DIRECT", "DummyOutput");
+ "0.0.1", "DIRECT", "DummyOutput");
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
result = apexModel.createPolicyStateTaskRef("MyTestPolicy", "0.0.1", "TestState1", "SomeTaskLocalName", "task",
- "0.0.1", "LOGIC", "DummyOutput");
+ "0.0.1", "LOGIC", "DummyOutput");
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "SomeTaskLocalName", "task",
- "0.0.1", "DIRECT", "SFLName07");
+ "0.0.1", "DIRECT", "SFLName07");
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "SomeTaskLocalName", "task",
- "0.0.1", "LOGIC", "SomeOutput");
+ "0.0.1", "LOGIC", "SomeOutput");
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "SomeTaskLocalName", "task",
- "0.0.1", "DIRECT", "SomeOutput");
+ "0.0.1", "DIRECT", "SomeOutput");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "SomeTaskLocalName",
- "NonExistantTask", "0.0.1", "DIRECT", "SomeOutput");
+ "NonExistantTask", "0.0.1", "DIRECT", "SomeOutput");
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "SomeTaskLocalName", "task",
- "0.0.1", "LOGIC", "SFLName07");
+ "0.0.1", "LOGIC", "SFLName07");
assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult());
result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "SomeTaskLocalName",
- "TestTask0", "0.0.1", "LOGIC", "SFLName07");
+ "TestTask0", "0.0.1", "LOGIC", "SFLName07");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "SomeTaskLocalName",
- "TestTask1", "0.0.1", "DIRECT", "SomeOtherOutput");
+ "TestTask1", "0.0.1", "DIRECT", "SomeOtherOutput");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "SomeTaskLocalName",
- "TestTask2", "0.0.1", "LOGIC", "SFLName07");
+ "TestTask2", "0.0.1", "LOGIC", "SFLName07");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "SomeTaskLocalName",
- "TestTask3", "0.0.1", "DIRECT", "SomeOtherOutput");
+ "TestTask3", "0.0.1", "DIRECT", "SomeOtherOutput");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", null, "TestTask4", "0.0.1",
- "LOGIC", "SFLName07");
+ "LOGIC", "SFLName07");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", null, "TestTask4", "0.0.1",
- "LOGIC", "SFLName07");
+ "LOGIC", "SFLName07");
assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult());
result = apexModel.deletePolicyStateTaskRef("MyTestPolicy", null, "TestState1", "TestTask4", "0.0.1");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "SomeTaskLocalName",
- "TestTask4", "0.0.1", "FUNKY", "SFLName07");
+ "TestTask4", "0.0.1", "FUNKY", "SFLName07");
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "SomeTaskLocalName",
- "TestTask4", "0.0.1", "UNDEFINED", "SFLName07");
+ "TestTask4", "0.0.1", "UNDEFINED", "SFLName07");
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", "SomeTaskLocalName",
- "TestTask4", "0.0.1", "LOGIC", "SFLName07");
+ "TestTask4", "0.0.1", "LOGIC", "SFLName07");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createPolicyStateTaskRef("MyTestPolicy", null, "TestState1", null, "TestTask0", "0.0.1",
- "LOGIC", "SFLName07");
+ "LOGIC", "SFLName07");
assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult());
result = apexModel.listPolicyStateTaskRef(null, null, null, null, null);
diff --git a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiTaskTest.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiTaskTest.java
index 026f67c29..15e53f925 100644
--- a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiTaskTest.java
+++ b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiTaskTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020,2022 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -29,12 +29,13 @@ import org.onap.policy.apex.model.modelapi.impl.ApexModelImpl;
/**
* Test tasks for API tests.
+ *
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class ApexEditorApiTaskTest {
@Test
public void testTaskCrud() {
- final ApexModel apexModel = new ApexModelFactory().createApexModel(null, false);
+ final ApexModel apexModel = new ApexModelFactory().createApexModel(null);
ApexApiResult result = apexModel.validateTask(null, null);
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
@@ -46,13 +47,13 @@ public class ApexEditorApiTaskTest {
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createTask("@^^$^^$", "0.0.2", "1fa2e430-f2b2-11e6-bc64-92361f002700",
- "A description of 002");
+ "A description of 002");
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
result = apexModel.createTask("MyTask002", "0.0.2", "1fa2e430-f2b2-11e6-bc64-92361f002700",
- "A description of 002");
+ "A description of 002");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createTask("MyTask002", "0.0.2", "1fa2e430-f2b2-11e6-bc64-92361f002700",
- "A description of 002");
+ "A description of 002");
assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult());
result = apexModel.createTask("MyTask012", null, null, null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
@@ -60,16 +61,16 @@ public class ApexEditorApiTaskTest {
assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult());
result = apexModel.listTask(null, null);
result = apexModel.createTask("MyTask002", "0.0.2", "1fa2e430-f2b2-11e6-bc64-92361f002700",
- "A description of 002");
+ "A description of 002");
assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult());
result = apexModel.createTask("MyTask012", "0.1.2", "1fa2e430-f2b2-11e6-bc64-92361f002700",
- "A description of 002");
+ "A description of 002");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.deleteTask("MyTask002", "0.0.2");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.createTask("MyTask002", "0.0.2", "1fa2e430-f2b2-11e6-bc64-92361f002700",
- "A description of 002");
+ "A description of 002");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.validateTask(null, null);
@@ -82,7 +83,7 @@ public class ApexEditorApiTaskTest {
result = apexModel.updateTask("MyTask002", "0.0.1", null, null);
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
result = apexModel.updateTask("MyTask002", "0.0.2", "1fa2e430-f2b2-11e6-bc64-92361f002700",
- "A description of 002");
+ "A description of 002");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.updateTask("MyTask012", null, null, null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
diff --git a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexModelApiTest.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexModelApiTest.java
index 132864bc9..f28d0e634 100644
--- a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexModelApiTest.java
+++ b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexModelApiTest.java
@@ -59,7 +59,7 @@ public class ApexModelApiTest {
@Test
public void testApexModelLoadFromFile() {
- final ApexModel apexModel = new ApexModelFactory().createApexModel(null, false);
+ final ApexModel apexModel = new ApexModelFactory().createApexModel(null);
ApexApiResult result = apexModel.loadFromFile("src/main/resources/models/PolicyModel.json");
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
@@ -70,7 +70,7 @@ public class ApexModelApiTest {
result = apexModel.deleteModel();
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.loadFromFile("src/test/resources/models/PolicyModel.xml");
+ result = apexModel.loadFromFile("src/test/resources/models/PolicyModel.json");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModel.deleteModel();
@@ -78,64 +78,64 @@ public class ApexModelApiTest {
result = apexModel.loadFromFile("src/test/resources/models/PolicyModel.junk");
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
- assertEquals("format of input for Apex concept is neither JSON nor XML", result.getMessages().get(0));
+ assertEquals("Unable to unmarshal Apex concept", result.getMessages().get(0).trim());
}
@Test
public void testApexModelSaveToFile() throws IOException {
- final ApexModel apexModel = new ApexModelFactory().createApexModel(null, false);
+ final ApexModel apexModel = new ApexModelFactory().createApexModel(null);
ApexApiResult result = apexModel.loadFromFile("src/test/resources/models/PolicyModel.json");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
final File tempJsonModelFile = File.createTempFile("ApexModelTest", ".json");
- result = apexModel.saveToFile(tempJsonModelFile.getCanonicalPath(), false);
+ result = apexModel.saveToFile(tempJsonModelFile.getPath());
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- final ApexModel jsonApexModel = new ApexModelFactory().createApexModel(null, false);
- result = jsonApexModel.loadFromFile(tempJsonModelFile.getCanonicalPath());
+ final ApexModel jsonApexModel = new ApexModelFactory().createApexModel(null);
+ result = jsonApexModel.loadFromFile(tempJsonModelFile.getPath());
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
tempJsonModelFile.delete();
- final File tempXmlModelFile = File.createTempFile("ApexModelTest", ".xml");
- result = apexModel.saveToFile(tempXmlModelFile.getCanonicalPath(), true);
+ final File tempModelFile = File.createTempFile("ApexModelTest", ".json");
+ result = apexModel.saveToFile(tempModelFile.getPath());
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- final ApexModel xmlApexModel = new ApexModelFactory().createApexModel(null, false);
- result = xmlApexModel.loadFromFile(tempXmlModelFile.getCanonicalPath());
+ final ApexModel testApexModel = new ApexModelFactory().createApexModel(null);
+ result = testApexModel.loadFromFile(tempModelFile.getPath());
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- tempXmlModelFile.delete();
+ tempModelFile.delete();
}
@Test
public void testApexModelUrl() throws IOException {
- final ApexModel apexModel = new ApexModelFactory().createApexModel(null, false);
+ final ApexModel apexModel = new ApexModelFactory().createApexModel(null);
assertThatThrownBy(() -> apexModel.readFromUrl(null)).isInstanceOf(IllegalArgumentException.class);
- assertThatThrownBy(() -> apexModel.writeToUrl(null, true)).isInstanceOf(IllegalArgumentException.class);
+ assertThatThrownBy(() -> apexModel.writeToUrl(null)).isInstanceOf(IllegalArgumentException.class);
ApexApiResult result = null;
result = apexModel.readFromUrl("zooby/looby");
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
- result = apexModel.writeToUrl("zooby/looby", true);
+ result = apexModel.writeToUrl("zooby/looby");
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
result = apexModel.readFromUrl("zooby://zooby/looby");
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
- result = apexModel.writeToUrl("zooby://zooby/looby", false);
+ result = apexModel.writeToUrl("zooby://zooby/looby");
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
- final File tempJsonModelFile = File.createTempFile("ApexModelTest", ".json");
+ final File tempJsonModelFile = File.createTempFile("ApexModelTest", "json");
- result = apexModel.saveToFile(tempJsonModelFile.getCanonicalPath(), false);
+ result = apexModel.saveToFile(tempJsonModelFile.getPath());
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
final String tempFileUrlString = tempJsonModelFile.toURI().toString();
result = apexModel.readFromUrl(tempFileUrlString);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.writeToUrl(tempFileUrlString, false);
+ result = apexModel.writeToUrl(tempFileUrlString);
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
assertEquals("protocol doesn't support output", result.getMessages().get(0));
@@ -144,7 +144,7 @@ public class ApexModelApiTest {
@Test
public void testApexModelMisc() throws IOException {
- final ApexModelImpl apexModelImpl = (ApexModelImpl) new ApexModelFactory().createApexModel(null, false);
+ final ApexModelImpl apexModelImpl = (ApexModelImpl) new ApexModelFactory().createApexModel(null);
ApexApiResult result = null;
@@ -174,10 +174,7 @@ public class ApexModelApiTest {
apexModelImpl.deleteModel();
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModelImpl.loadFromFile(tempFile.getCanonicalPath());
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
-
- result = apexModelImpl.saveToFile(null, false);
+ result = apexModelImpl.loadFromFile(tempFile.getPath());
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModelImpl.analyse();
@@ -186,7 +183,7 @@ public class ApexModelApiTest {
result = apexModelImpl.validate();
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModelImpl.compare(tempFile.getCanonicalPath(), true, true);
+ result = apexModelImpl.compare(tempFile.getPath(), true, true);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModelImpl.compareWithString(modelString, true, true);
@@ -195,10 +192,10 @@ public class ApexModelApiTest {
result = apexModelImpl.split("policy");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModelImpl.split(tempFile.getCanonicalPath(), "policy");
+ result = apexModelImpl.split(tempFile.getPath(), "policy");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModelImpl.merge(tempFile.getCanonicalPath(), true);
+ result = apexModelImpl.merge(tempFile.getPath(), true);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
result = apexModelImpl.mergeWithString(modelString, true);
diff --git a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ModelFacadeTest.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ModelFacadeTest.java
index a5f258e4c..d3b32b923 100644
--- a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ModelFacadeTest.java
+++ b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ModelFacadeTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2020,2022 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,14 +34,14 @@ public class ModelFacadeTest {
@Test
public void testModelFacade() {
- assertThatThrownBy(() -> new ModelFacade(null, null, false))
+ assertThatThrownBy(() -> new ModelFacade(null, null))
.hasMessage("apexModel may not be null");
- final ApexModel apexModel = new ApexModelFactory().createApexModel(null, false);
+ final ApexModel apexModel = new ApexModelFactory().createApexModel(null);
- assertThatThrownBy(() -> new ModelFacade(apexModel, null, false))
+ assertThatThrownBy(() -> new ModelFacade(apexModel, null))
.hasMessage("apexProperties may not be null");
final Properties modelProperties = new Properties();
- final ModelFacade mf = new ModelFacade(apexModel, modelProperties, false);
+ final ModelFacade mf = new ModelFacade(apexModel, modelProperties);
ApexApiResult result = mf.createModel(null, null, null, null);
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
@@ -91,7 +91,6 @@ public class ModelFacadeTest {
result = mf.listModel();
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- assertEquals("AxPolicyModel:(AxPolicyModel:(key=AxArtifactKey:(n", result.getMessage().substring(0, 50));
result = mf.deleteModel();
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
diff --git a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ModelHandlerFacadeTest.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ModelHandlerFacadeTest.java
index e43e5896b..5bbc95992 100644
--- a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ModelHandlerFacadeTest.java
+++ b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ModelHandlerFacadeTest.java
@@ -41,14 +41,14 @@ public class ModelHandlerFacadeTest {
@Test
public void testModelHandlerFacade() throws IOException {
- assertThatThrownBy(() -> new ModelHandlerFacade(null, null, false))
+ assertThatThrownBy(() -> new ModelHandlerFacade(null, null))
.hasMessage("apexModel may not be null");
- final ApexModel apexModel = new ApexModelFactory().createApexModel(null, false);
+ final ApexModel apexModel = new ApexModelFactory().createApexModel(null);
- assertThatThrownBy(() -> new ModelHandlerFacade(apexModel, null, false))
+ assertThatThrownBy(() -> new ModelHandlerFacade(apexModel, null))
.hasMessage("apexProperties may not be null");
final Properties modelProperties = new Properties();
- final ModelHandlerFacade mhf = new ModelHandlerFacade(apexModel, modelProperties, false);
+ final ModelHandlerFacade mhf = new ModelHandlerFacade(apexModel, modelProperties);
assertNotNull(mhf);
ApexApiResult result = mhf.loadFromFile("src/test/resources/models/PolicyModel.json");
@@ -83,7 +83,7 @@ public class ModelHandlerFacadeTest {
final File tempFile = File.createTempFile("ApexModel", "json");
tempFile.deleteOnExit();
- result = mhf.writeToUrl("File:///" + tempFile.getCanonicalPath(), false);
+ result = mhf.writeToUrl("File:///" + tempFile.getCanonicalPath());
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
result = mhf.validate();
diff --git a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/RealModelTest.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/RealModelTest.java
new file mode 100644
index 000000000..2a29f5297
--- /dev/null
+++ b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/RealModelTest.java
@@ -0,0 +1,46 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.model.modelapi;
+
+import static org.junit.Assert.assertTrue;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import java.util.Map;
+import org.junit.Test;
+import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
+import org.onap.policy.apex.model.basicmodel.handling.ApexModelCustomGsonMapAdapter;
+import org.onap.policy.apex.model.basicmodel.handling.ApexModelReader;
+import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
+import org.onap.policy.common.utils.resources.TextFileUtils;
+
+public class RealModelTest {
+ @Test
+ public void testRealModel() throws Exception {
+
+ final String modelString = TextFileUtils.getTextFileAsString("src/test/resources/models/PolicyModel.json");
+
+ AxPolicyModel policyModel = new ApexModelReader<AxPolicyModel>(AxPolicyModel.class).read(modelString);
+
+ AxValidationResult result = new AxValidationResult();
+ assertTrue(policyModel.validate(result).isValid());
+ }
+}
diff --git a/model/model-api/src/test/resources/models/PolicyModel.json b/model/model-api/src/test/resources/models/PolicyModel.json
index 81c222609..fbb91bb0b 100644
--- a/model/model-api/src/test/resources/models/PolicyModel.json
+++ b/model/model-api/src/test/resources/models/PolicyModel.json
@@ -1,708 +1,775 @@
{
- "apexPolicyModel" : {
- "key" : {
- "name" : "PolicyModel",
- "version" : "0.0.1"
- },
- "keyInformation" : {
- "key" : {
- "name" : "KeyInfoMapKey",
- "version" : "0.0.1"
- },
- "keyInfoMap" : {
- "entry" : [ {
- "key" : {
- "name" : "ContextSchemas",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "ContextSchemas",
- "version" : "0.0.1"
- },
- "UUID" : "0ce9168c-e6df-414f-9646-6da464b6e000",
- "description" : "Generated description for concept referred to by key \"ContextSchemas:0.0.1\""
- }
- }, {
- "key" : {
- "name" : "KeyInfoMapKey",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "KeyInfoMapKey",
- "version" : "0.0.1"
- },
- "UUID" : "0ce9168c-e6df-414f-9646-6da464b6e001",
- "description" : "Generated description for concept referred to by key \"KeyInfoMapKey:0.0.1\""
- }
- }, {
- "key" : {
- "name" : "MapType",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "MapType",
- "version" : "0.0.1"
- },
- "UUID" : "0ce9168c-e6df-414f-9646-6da464b6e002",
- "description" : "Generated description for concept referred to by key \"MapType:0.0.1\""
- }
- }, {
- "key" : {
- "name" : "PolicyModel",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "PolicyModel",
- "version" : "0.0.1"
- },
- "UUID" : "0ce9168c-e6df-414f-9646-6da464b6e003",
- "description" : "Generated description for concept referred to by key \"PolicyModel:0.0.1\""
- }
- }, {
- "key" : {
- "name" : "StringType",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "StringType",
- "version" : "0.0.1"
- },
- "UUID" : "0ce9168c-e6df-414f-9646-6da464b6e004",
- "description" : "Generated description for concept referred to by key \"StringType:0.0.1\""
- }
- }, {
- "key" : {
- "name" : "context",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "context",
- "version" : "0.0.1"
- },
- "UUID" : "0ce9168c-e6df-414f-9646-6da464b6e005",
- "description" : "Generated description for concept referred to by key \"context:0.0.1\""
- }
- }, {
- "key" : {
- "name" : "contextAlbum0",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "contextAlbum0",
- "version" : "0.0.1"
- },
- "UUID" : "0ce9168c-e6df-414f-9646-6da464b6e006",
- "description" : "Generated description for concept referred to by key \"contextAlbum0:0.0.1\""
- }
- }, {
- "key" : {
- "name" : "contextAlbum1",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "contextAlbum1",
- "version" : "0.0.1"
- },
- "UUID" : "0ce9168c-e6df-414f-9646-6da464b6e007",
- "description" : "Generated description for concept referred to by key \"contextAlbum1:0.0.1\""
- }
- }, {
- "key" : {
- "name" : "eventContextItem0",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "eventContextItem0",
- "version" : "0.0.1"
- },
- "UUID" : "0ce9168c-e6df-414f-9646-6da464b6e008",
- "description" : "Generated description for concept referred to by key \"eventContextItem0:0.0.1\""
- }
- }, {
- "key" : {
- "name" : "eventContextItem1",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "eventContextItem1",
- "version" : "0.0.1"
- },
- "UUID" : "0ce9168c-e6df-414f-9646-6da464b6e009",
- "description" : "Generated description for concept referred to by key \"eventContextItem1:0.0.1\""
- }
- }, {
- "key" : {
- "name" : "events",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "events",
- "version" : "0.0.1"
- },
- "UUID" : "0ce9168c-e6df-414f-9646-6da464b6e010",
- "description" : "Generated description for concept referred to by key \"events:0.0.1\""
- }
- }, {
- "key" : {
- "name" : "inEvent",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "inEvent",
- "version" : "0.0.1"
- },
- "UUID" : "0ce9168c-e6df-414f-9646-6da464b6e011",
- "description" : "Generated description for concept referred to by key \"inEvent:0.0.1\""
- }
- }, {
- "key" : {
- "name" : "outEvent0",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "outEvent0",
- "version" : "0.0.1"
- },
- "UUID" : "0ce9168c-e6df-414f-9646-6da464b6e012",
- "description" : "Generated description for concept referred to by key \"outEvent0:0.0.1\""
- }
- }, {
- "key" : {
- "name" : "outEvent1",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "outEvent1",
- "version" : "0.0.1"
- },
- "UUID" : "0ce9168c-e6df-414f-9646-6da464b6e013",
- "description" : "Generated description for concept referred to by key \"outEvent1:0.0.1\""
- }
- }, {
- "key" : {
- "name" : "policies",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "policies",
- "version" : "0.0.1"
- },
- "UUID" : "0ce9168c-e6df-414f-9646-6da464b6e014",
- "description" : "Generated description for concept referred to by key \"policies:0.0.1\""
- }
- }, {
- "key" : {
- "name" : "policy",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "policy",
- "version" : "0.0.1"
- },
- "UUID" : "0ce9168c-e6df-414f-9646-6da464b6e015",
- "description" : "Generated description for concept referred to by key \"policy:0.0.1\""
- }
- }, {
- "key" : {
- "name" : "task",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "task",
- "version" : "0.0.1"
- },
- "UUID" : "0ce9168c-e6df-414f-9646-6da464b6e016",
- "description" : "Generated description for concept referred to by key \"task:0.0.1\""
- }
- }, {
- "key" : {
- "name" : "tasks",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "tasks",
- "version" : "0.0.1"
- },
- "UUID" : "0ce9168c-e6df-414f-9646-6da464b6e017",
- "description" : "Generated description for concept referred to by key \"tasks:0.0.1\""
- }
- } ]
- }
- },
- "policies" : {
- "key" : {
- "name" : "policies",
- "version" : "0.0.1"
- },
- "policyMap" : {
- "entry" : [ {
- "key" : {
- "name" : "policy",
- "version" : "0.0.1"
- },
- "value" : {
- "policyKey" : {
- "name" : "policy",
- "version" : "0.0.1"
- },
- "template" : "FREEFORM",
- "state" : {
- "entry" : [ {
- "key" : "state",
- "value" : {
- "stateKey" : {
- "parentKeyName" : "policy",
- "parentKeyVersion" : "0.0.1",
- "parentLocalName" : "NULL",
- "localName" : "state"
- },
- "trigger" : {
- "name" : "inEvent",
- "version" : "0.0.1"
- },
- "stateOutputs" : {
- "entry" : [ {
- "key" : "stateOutput0",
- "value" : {
- "key" : {
- "parentKeyName" : "policy",
- "parentKeyVersion" : "0.0.1",
- "parentLocalName" : "state",
- "localName" : "stateOutput0"
- },
- "outgoingEvent" : {
- "name" : "outEvent0",
- "version" : "0.0.1"
- },
- "nextState" : {
- "parentKeyName" : "NULL",
- "parentKeyVersion" : "0.0.0",
- "parentLocalName" : "NULL",
- "localName" : "NULL"
- }
- }
- } ]
- },
- "contextAlbumReference" : [ {
- "name" : "contextAlbum0",
- "version" : "0.0.1"
- }, {
- "name" : "contextAlbum1",
- "version" : "0.0.1"
- } ],
- "taskSelectionLogic" : {
- "key" : "taskSelectionLogic",
- "logicFlavour" : "MVEL",
- "logic" : "Some TS logic"
- },
- "stateFinalizerLogicMap" : {
- "entry" : [ ]
- },
- "defaultTask" : {
- "name" : "task",
- "version" : "0.0.1"
- },
- "taskReferences" : {
- "entry" : [ {
- "key" : {
- "name" : "task",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "parentKeyName" : "policy",
- "parentKeyVersion" : "0.0.1",
- "parentLocalName" : "state",
- "localName" : "task"
- },
- "outputType" : "DIRECT",
- "output" : {
- "parentKeyName" : "policy",
- "parentKeyVersion" : "0.0.1",
- "parentLocalName" : "state",
- "localName" : "stateOutput0"
- }
- }
- } ]
- }
+ "key": {
+ "name": "PolicyModel",
+ "version": "0.0.1"
+ },
+ "keyInformation": {
+ "key": {
+ "name": "KeyInfoMapKey",
+ "version": "0.0.1"
+ },
+ "keyInfoMap": {
+ "entry": [
+ {
+ "key": {
+ "name": "ContextSchemas",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "ContextSchemas",
+ "version": "0.0.1"
+ },
+ "UUID": "0ce9168c-e6df-414f-9646-6da464b6e000",
+ "description": "Generated description for concept referred to by key \"ContextSchemas:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "KeyInfoMapKey",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "KeyInfoMapKey",
+ "version": "0.0.1"
+ },
+ "UUID": "0ce9168c-e6df-414f-9646-6da464b6e001",
+ "description": "Generated description for concept referred to by key \"KeyInfoMapKey:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "MapType",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "MapType",
+ "version": "0.0.1"
+ },
+ "UUID": "0ce9168c-e6df-414f-9646-6da464b6e002",
+ "description": "Generated description for concept referred to by key \"MapType:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "PolicyModel",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "PolicyModel",
+ "version": "0.0.1"
+ },
+ "UUID": "0ce9168c-e6df-414f-9646-6da464b6e003",
+ "description": "Generated description for concept referred to by key \"PolicyModel:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "StringType",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "StringType",
+ "version": "0.0.1"
+ },
+ "UUID": "0ce9168c-e6df-414f-9646-6da464b6e004",
+ "description": "Generated description for concept referred to by key \"StringType:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "context",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "context",
+ "version": "0.0.1"
+ },
+ "UUID": "0ce9168c-e6df-414f-9646-6da464b6e005",
+ "description": "Generated description for concept referred to by key \"context:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "contextAlbum0",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "contextAlbum0",
+ "version": "0.0.1"
+ },
+ "UUID": "0ce9168c-e6df-414f-9646-6da464b6e006",
+ "description": "Generated description for concept referred to by key \"contextAlbum0:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "contextAlbum1",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "contextAlbum1",
+ "version": "0.0.1"
+ },
+ "UUID": "0ce9168c-e6df-414f-9646-6da464b6e007",
+ "description": "Generated description for concept referred to by key \"contextAlbum1:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "eventContextItem0",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "eventContextItem0",
+ "version": "0.0.1"
+ },
+ "UUID": "0ce9168c-e6df-414f-9646-6da464b6e008",
+ "description": "Generated description for concept referred to by key \"eventContextItem0:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "eventContextItem1",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "eventContextItem1",
+ "version": "0.0.1"
+ },
+ "UUID": "0ce9168c-e6df-414f-9646-6da464b6e009",
+ "description": "Generated description for concept referred to by key \"eventContextItem1:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "events",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "events",
+ "version": "0.0.1"
+ },
+ "UUID": "0ce9168c-e6df-414f-9646-6da464b6e010",
+ "description": "Generated description for concept referred to by key \"events:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "inEvent",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "inEvent",
+ "version": "0.0.1"
+ },
+ "UUID": "0ce9168c-e6df-414f-9646-6da464b6e011",
+ "description": "Generated description for concept referred to by key \"inEvent:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "outEvent0",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "outEvent0",
+ "version": "0.0.1"
+ },
+ "UUID": "0ce9168c-e6df-414f-9646-6da464b6e012",
+ "description": "Generated description for concept referred to by key \"outEvent0:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "outEvent1",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "outEvent1",
+ "version": "0.0.1"
+ },
+ "UUID": "0ce9168c-e6df-414f-9646-6da464b6e013",
+ "description": "Generated description for concept referred to by key \"outEvent1:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "policies",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "policies",
+ "version": "0.0.1"
+ },
+ "UUID": "0ce9168c-e6df-414f-9646-6da464b6e014",
+ "description": "Generated description for concept referred to by key \"policies:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "policy",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "policy",
+ "version": "0.0.1"
+ },
+ "UUID": "0ce9168c-e6df-414f-9646-6da464b6e015",
+ "description": "Generated description for concept referred to by key \"policy:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "task",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "task",
+ "version": "0.0.1"
+ },
+ "UUID": "0ce9168c-e6df-414f-9646-6da464b6e016",
+ "description": "Generated description for concept referred to by key \"task:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "tasks",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "tasks",
+ "version": "0.0.1"
+ },
+ "UUID": "0ce9168c-e6df-414f-9646-6da464b6e017",
+ "description": "Generated description for concept referred to by key \"tasks:0.0.1\""
+ }
+ }
+ ]
+ }
+ },
+ "policies": {
+ "key": {
+ "name": "policies",
+ "version": "0.0.1"
+ },
+ "policyMap": {
+ "entry": [
+ {
+ "key": {
+ "name": "policy",
+ "version": "0.0.1"
+ },
+ "value": {
+ "policyKey": {
+ "name": "policy",
+ "version": "0.0.1"
+ },
+ "template": "FREEFORM",
+ "state": {
+ "entry": [
+ {
+ "key": "state",
+ "value": {
+ "stateKey": {
+ "parentKeyName": "policy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "NULL",
+ "localName": "state"
+ },
+ "trigger": {
+ "name": "inEvent",
+ "version": "0.0.1"
+ },
+ "stateOutputs": {
+ "entry": [
+ {
+ "key": "stateOutput0",
+ "value": {
+ "key": {
+ "parentKeyName": "policy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "state",
+ "localName": "stateOutput0"
+ },
+ "outgoingEvent": {
+ "name": "outEvent0",
+ "version": "0.0.1"
+ },
+ "nextState": {
+ "parentKeyName": "NULL",
+ "parentKeyVersion": "0.0.0",
+ "parentLocalName": "NULL",
+ "localName": "NULL"
+ }
+ }
}
- } ]
- },
- "firstState" : "state"
- }
- } ]
- }
- },
- "tasks" : {
- "key" : {
- "name" : "tasks",
- "version" : "0.0.1"
- },
- "taskMap" : {
- "entry" : [ {
- "key" : {
- "name" : "task",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "task",
- "version" : "0.0.1"
- },
- "inputFields" : {
- "entry" : [ {
- "key" : "IEPAR0",
- "value" : {
- "key" : "IEPAR0",
- "fieldSchemaKey" : {
- "name" : "eventContextItem0",
- "version" : "0.0.1"
- }
+ ]
+ },
+ "contextAlbumReference": [
+ {
+ "name": "contextAlbum0",
+ "version": "0.0.1"
+ },
+ {
+ "name": "contextAlbum1",
+ "version": "0.0.1"
+ }
+ ],
+ "taskSelectionLogic": {
+ "key": "taskSelectionLogic",
+ "logicFlavour": "MVEL",
+ "logic": "Some TS logic"
+ },
+ "stateFinalizerLogicMap": {
+ "entry": []
+ },
+ "defaultTask": {
+ "name": "task",
+ "version": "0.0.1"
+ },
+ "taskReferences": {
+ "entry": [
+ {
+ "key": {
+ "name": "task",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "parentKeyName": "policy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "state",
+ "localName": "task"
+ },
+ "outputType": "DIRECT",
+ "output": {
+ "parentKeyName": "policy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "state",
+ "localName": "stateOutput0"
+ }
+ }
}
- }, {
- "key" : "IEPAR1",
- "value" : {
- "key" : "IEPAR1",
- "fieldSchemaKey" : {
- "name" : "eventContextItem1",
- "version" : "0.0.1"
- }
- }
- } ]
- },
- "outputFields" : {
- "entry" : [ {
- "key" : "OE0PAR0",
- "value" : {
- "key" : "OE0PAR0",
- "fieldSchemaKey" : {
- "name" : "eventContextItem0",
- "version" : "0.0.1"
- }
- }
- }, {
- "key" : "OE0PAR1",
- "value" : {
- "key" : "OE0PAR1",
- "fieldSchemaKey" : {
- "name" : "eventContextItem1",
- "version" : "0.0.1"
- }
- }
- }, {
- "key" : "OE1PAR0",
- "value" : {
- "key" : "OE1PAR0",
- "fieldSchemaKey" : {
- "name" : "eventContextItem0",
- "version" : "0.0.1"
- }
- }
- }, {
- "key" : "OE1PAR1",
- "value" : {
- "key" : "OE1PAR1",
- "fieldSchemaKey" : {
- "name" : "eventContextItem1",
- "version" : "0.0.1"
- }
- }
- } ]
- },
- "taskParameters" : {
- "entry" : [ {
- "key" : "taskParameter0",
- "value" : {
- "key" : {
- "parentKeyName" : "task",
- "parentKeyVersion" : "0.0.1",
- "parentLocalName" : "NULL",
- "localName" : "taskParameter0"
- },
- "defaultValue" : "Task parameter 0 value"
- }
- }, {
- "key" : "taskParameter1",
- "value" : {
- "key" : {
- "parentKeyName" : "task",
- "parentKeyVersion" : "0.0.1",
- "parentLocalName" : "NULL",
- "localName" : "taskParameter1"
- },
- "defaultValue" : "Task parameter 1 value"
- }
- } ]
- },
- "contextAlbumReference" : [ {
- "name" : "contextAlbum0",
- "version" : "0.0.1"
- }, {
- "name" : "contextAlbum1",
- "version" : "0.0.1"
- } ],
- "taskLogic" : {
- "key" : "taskLogic",
- "logicFlavour" : "MVEL",
- "logic" : "Some task logic"
+ ]
+ }
}
- }
- } ]
- }
- },
- "events" : {
- "key" : {
- "name" : "events",
- "version" : "0.0.1"
- },
- "eventMap" : {
- "entry" : [ {
- "key" : {
- "name" : "inEvent",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "inEvent",
- "version" : "0.0.1"
- },
- "nameSpace" : "org.onap.policy.apex.model.policymodel.events",
- "source" : "Source",
- "target" : "Target",
- "parameter" : {
- "entry" : [ {
- "key" : "IEPAR0",
- "value" : {
- "key" : "IEPAR0",
- "fieldSchemaKey" : {
- "name" : "eventContextItem0",
- "version" : "0.0.1"
- }
- }
- }, {
- "key" : "IEPAR1",
- "value" : {
- "key" : "IEPAR1",
- "fieldSchemaKey" : {
- "name" : "eventContextItem1",
- "version" : "0.0.1"
- }
- }
- } ]
+ }
+ ]
+ },
+ "firstState": "state"
+ }
+ }
+ ]
+ }
+ },
+ "tasks": {
+ "key": {
+ "name": "tasks",
+ "version": "0.0.1"
+ },
+ "taskMap": {
+ "entry": [
+ {
+ "key": {
+ "name": "task",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "task",
+ "version": "0.0.1"
+ },
+ "inputFields": {
+ "entry": [
+ {
+ "key": "IEPAR0",
+ "value": {
+ "key": "IEPAR0",
+ "fieldSchemaKey": {
+ "name": "eventContextItem0",
+ "version": "0.0.1"
+ }
}
- }
- }, {
- "key" : {
- "name" : "outEvent0",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "outEvent0",
- "version" : "0.0.1"
- },
- "nameSpace" : "org.onap.policy.apex.model.policymodel.events",
- "source" : "Source",
- "target" : "Target",
- "parameter" : {
- "entry" : [ {
- "key" : "OE0PAR0",
- "value" : {
- "key" : "OE0PAR0",
- "fieldSchemaKey" : {
- "name" : "eventContextItem0",
- "version" : "0.0.1"
- }
- }
- }, {
- "key" : "OE0PAR1",
- "value" : {
- "key" : "OE0PAR1",
- "fieldSchemaKey" : {
- "name" : "eventContextItem1",
- "version" : "0.0.1"
- }
- }
- }, {
- "key" : "OE1PAR0",
- "value" : {
- "key" : "OE1PAR0",
- "fieldSchemaKey" : {
- "name" : "eventContextItem0",
- "version" : "0.0.1"
- }
- }
- }, {
- "key" : "OE1PAR1",
- "value" : {
- "key" : "OE1PAR1",
- "fieldSchemaKey" : {
- "name" : "eventContextItem1",
- "version" : "0.0.1"
- }
- }
- } ]
+ },
+ {
+ "key": "IEPAR1",
+ "value": {
+ "key": "IEPAR1",
+ "fieldSchemaKey": {
+ "name": "eventContextItem1",
+ "version": "0.0.1"
+ }
}
- }
- }, {
- "key" : {
- "name" : "outEvent1",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "outEvent1",
- "version" : "0.0.1"
- },
- "nameSpace" : "org.onap.policy.apex.model.policymodel.events",
- "source" : "Source",
- "target" : "Target",
- "parameter" : {
- "entry" : [ {
- "key" : "OE1PAR0",
- "value" : {
- "key" : "OE1PAR0",
- "fieldSchemaKey" : {
- "name" : "eventContextItem0",
- "version" : "0.0.1"
- }
- }
- }, {
- "key" : "OE1PAR1",
- "value" : {
- "key" : "OE1PAR1",
- "fieldSchemaKey" : {
- "name" : "eventContextItem1",
- "version" : "0.0.1"
- }
- }
- } ]
+ }
+ ]
+ },
+ "outputFields": {
+ "entry": [
+ {
+ "key": "OE0PAR0",
+ "value": {
+ "key": "OE0PAR0",
+ "fieldSchemaKey": {
+ "name": "eventContextItem0",
+ "version": "0.0.1"
+ }
+ }
+ },
+ {
+ "key": "OE0PAR1",
+ "value": {
+ "key": "OE0PAR1",
+ "fieldSchemaKey": {
+ "name": "eventContextItem1",
+ "version": "0.0.1"
+ }
+ }
+ },
+ {
+ "key": "OE1PAR0",
+ "value": {
+ "key": "OE1PAR0",
+ "fieldSchemaKey": {
+ "name": "eventContextItem0",
+ "version": "0.0.1"
+ }
+ }
+ },
+ {
+ "key": "OE1PAR1",
+ "value": {
+ "key": "OE1PAR1",
+ "fieldSchemaKey": {
+ "name": "eventContextItem1",
+ "version": "0.0.1"
+ }
+ }
+ }
+ ]
+ },
+ "taskParameters": {
+ "entry": [
+ {
+ "key": "taskParameter0",
+ "value": {
+ "key": {
+ "parentKeyName": "task",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "NULL",
+ "localName": "taskParameter0"
+ },
+ "defaultValue": "Task parameter 0 value"
+ }
+ },
+ {
+ "key": "taskParameter1",
+ "value": {
+ "key": {
+ "parentKeyName": "task",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "NULL",
+ "localName": "taskParameter1"
+ },
+ "defaultValue": "Task parameter 1 value"
+ }
+ }
+ ]
+ },
+ "contextAlbumReference": [
+ {
+ "name": "contextAlbum0",
+ "version": "0.0.1"
+ },
+ {
+ "name": "contextAlbum1",
+ "version": "0.0.1"
+ }
+ ],
+ "taskLogic": {
+ "key": "taskLogic",
+ "logicFlavour": "MVEL",
+ "logic": "Some task logic"
+ }
+ }
+ }
+ ]
+ }
+ },
+ "events": {
+ "key": {
+ "name": "events",
+ "version": "0.0.1"
+ },
+ "eventMap": {
+ "entry": [
+ {
+ "key": {
+ "name": "inEvent",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "inEvent",
+ "version": "0.0.1"
+ },
+ "nameSpace": "org.onap.policy.apex.model.policymodel.events",
+ "source": "Source",
+ "target": "Target",
+ "parameter": {
+ "entry": [
+ {
+ "key": "IEPAR0",
+ "value": {
+ "key": "IEPAR0",
+ "fieldSchemaKey": {
+ "name": "eventContextItem0",
+ "version": "0.0.1"
+ }
+ }
+ },
+ {
+ "key": "IEPAR1",
+ "value": {
+ "key": "IEPAR1",
+ "fieldSchemaKey": {
+ "name": "eventContextItem1",
+ "version": "0.0.1"
+ }
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "key": {
+ "name": "outEvent0",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "outEvent0",
+ "version": "0.0.1"
+ },
+ "nameSpace": "org.onap.policy.apex.model.policymodel.events",
+ "source": "Source",
+ "target": "Target",
+ "parameter": {
+ "entry": [
+ {
+ "key": "OE0PAR0",
+ "value": {
+ "key": "OE0PAR0",
+ "fieldSchemaKey": {
+ "name": "eventContextItem0",
+ "version": "0.0.1"
+ }
+ }
+ },
+ {
+ "key": "OE0PAR1",
+ "value": {
+ "key": "OE0PAR1",
+ "fieldSchemaKey": {
+ "name": "eventContextItem1",
+ "version": "0.0.1"
+ }
+ }
+ },
+ {
+ "key": "OE1PAR0",
+ "value": {
+ "key": "OE1PAR0",
+ "fieldSchemaKey": {
+ "name": "eventContextItem0",
+ "version": "0.0.1"
+ }
+ }
+ },
+ {
+ "key": "OE1PAR1",
+ "value": {
+ "key": "OE1PAR1",
+ "fieldSchemaKey": {
+ "name": "eventContextItem1",
+ "version": "0.0.1"
+ }
}
- }
- } ]
- }
- },
- "albums" : {
- "key" : {
- "name" : "context",
- "version" : "0.0.1"
- },
- "albums" : {
- "entry" : [ {
- "key" : {
- "name" : "contextAlbum0",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "contextAlbum0",
- "version" : "0.0.1"
- },
- "scope" : "APPLICATION",
- "isWritable" : true,
- "itemSchema" : {
- "name" : "MapType",
- "version" : "0.0.1"
+ }
+ ]
+ }
+ }
+ },
+ {
+ "key": {
+ "name": "outEvent1",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "outEvent1",
+ "version": "0.0.1"
+ },
+ "nameSpace": "org.onap.policy.apex.model.policymodel.events",
+ "source": "Source",
+ "target": "Target",
+ "parameter": {
+ "entry": [
+ {
+ "key": "OE1PAR0",
+ "value": {
+ "key": "OE1PAR0",
+ "fieldSchemaKey": {
+ "name": "eventContextItem0",
+ "version": "0.0.1"
+ }
}
- }
- }, {
- "key" : {
- "name" : "contextAlbum1",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "contextAlbum1",
- "version" : "0.0.1"
- },
- "scope" : "GLOBAL",
- "isWritable" : false,
- "itemSchema" : {
- "name" : "StringType",
- "version" : "0.0.1"
+ },
+ {
+ "key": "OE1PAR1",
+ "value": {
+ "key": "OE1PAR1",
+ "fieldSchemaKey": {
+ "name": "eventContextItem1",
+ "version": "0.0.1"
+ }
}
- }
- } ]
- }
- },
- "schemas" : {
- "key" : {
- "name" : "ContextSchemas",
- "version" : "0.0.1"
- },
- "schemas" : {
- "entry" : [ {
- "key" : {
- "name" : "MapType",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "MapType",
- "version" : "0.0.1"
- },
- "schemaFlavour" : "Java",
- "schemaDefinition" : "org.onap.policy.apex.model.policymodel.concepts.TestContextItem00A"
- }
- }, {
- "key" : {
- "name" : "StringType",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "StringType",
- "version" : "0.0.1"
- },
- "schemaFlavour" : "Java",
- "schemaDefinition" : "org.onap.policy.apex.model.policymodel.concepts.TestContextItem000"
- }
- }, {
- "key" : {
- "name" : "eventContextItem0",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "eventContextItem0",
- "version" : "0.0.1"
- },
- "schemaFlavour" : "Java",
- "schemaDefinition" : "java.lang.String"
- }
- }, {
- "key" : {
- "name" : "eventContextItem1",
- "version" : "0.0.1"
- },
- "value" : {
- "key" : {
- "name" : "eventContextItem1",
- "version" : "0.0.1"
- },
- "schemaFlavour" : "Java",
- "schemaDefinition" : "java.lang.Long"
- }
- } ]
- }
- }
- }
-} \ No newline at end of file
+ }
+ ]
+ }
+ }
+ }
+ ]
+ }
+ },
+ "albums": {
+ "key": {
+ "name": "context",
+ "version": "0.0.1"
+ },
+ "albums": {
+ "entry": [
+ {
+ "key": {
+ "name": "contextAlbum0",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "contextAlbum0",
+ "version": "0.0.1"
+ },
+ "scope": "APPLICATION",
+ "isWritable": true,
+ "itemSchema": {
+ "name": "MapType",
+ "version": "0.0.1"
+ }
+ }
+ },
+ {
+ "key": {
+ "name": "contextAlbum1",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "contextAlbum1",
+ "version": "0.0.1"
+ },
+ "scope": "GLOBAL",
+ "isWritable": false,
+ "itemSchema": {
+ "name": "StringType",
+ "version": "0.0.1"
+ }
+ }
+ }
+ ]
+ }
+ },
+ "schemas": {
+ "key": {
+ "name": "ContextSchemas",
+ "version": "0.0.1"
+ },
+ "schemas": {
+ "entry": [
+ {
+ "key": {
+ "name": "MapType",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "MapType",
+ "version": "0.0.1"
+ },
+ "schemaFlavour": "Java",
+ "schemaDefinition": "org.onap.policy.apex.model.policymodel.concepts.TestContextItem00A"
+ }
+ },
+ {
+ "key": {
+ "name": "StringType",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "StringType",
+ "version": "0.0.1"
+ },
+ "schemaFlavour": "Java",
+ "schemaDefinition": "org.onap.policy.apex.model.policymodel.concepts.TestContextItem000"
+ }
+ },
+ {
+ "key": {
+ "name": "eventContextItem0",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "eventContextItem0",
+ "version": "0.0.1"
+ },
+ "schemaFlavour": "Java",
+ "schemaDefinition": "java.lang.String"
+ }
+ },
+ {
+ "key": {
+ "name": "eventContextItem1",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "eventContextItem1",
+ "version": "0.0.1"
+ },
+ "schemaFlavour": "Java",
+ "schemaDefinition": "java.lang.Long"
+ }
+ }
+ ]
+ }
+ }
+}
diff --git a/model/model-api/src/test/resources/models/PolicyModel.xml b/model/model-api/src/test/resources/models/PolicyModel.xml
deleted file mode 100644
index e47e21afc..000000000
--- a/model/model-api/src/test/resources/models/PolicyModel.xml
+++ /dev/null
@@ -1,697 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ============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=========================================================
--->
-
-<apexPolicyModel xmlns="http://www.onap.org/policy/apex-pdp">
- <key>
- <name>PolicyModel</name>
- <version>0.0.1</version>
- </key>
- <keyInformation>
- <key>
- <name>KeyInfoMapKey</name>
- <version>0.0.1</version>
- </key>
- <keyInfoMap>
- <entry>
- <key>
- <name>ContextSchemas</name>
- <version>0.0.1</version>
- </key>
- <value>
- <key>
- <name>ContextSchemas</name>
- <version>0.0.1</version>
- </key>
- <UUID>0ce9168c-e6df-414f-9646-6da464b6e000</UUID>
- <description><![CDATA[Description for concept with key "ContextSchemas:0.0.1"]]></description>
- </value>
- </entry>
- <entry>
- <key>
- <name>KeyInfoMapKey</name>
- <version>0.0.1</version>
- </key>
- <value>
- <key>
- <name>KeyInfoMapKey</name>
- <version>0.0.1</version>
- </key>
- <UUID>0ce9168c-e6df-414f-9646-6da464b6e001</UUID>
- <description><![CDATA[Description for concept with key "KeyInfoMapKey:0.0.1"]]></description>
- </value>
- </entry>
- <entry>
- <key>
- <name>MapType</name>
- <version>0.0.1</version>
- </key>
- <value>
- <key>
- <name>MapType</name>
- <version>0.0.1</version>
- </key>
- <UUID>0ce9168c-e6df-414f-9646-6da464b6e002</UUID>
- <description><![CDATA[Description for concept with key "MapType:0.0.1"]]></description>
- </value>
- </entry>
- <entry>
- <key>
- <name>PolicyModel</name>
- <version>0.0.1</version>
- </key>
- <value>
- <key>
- <name>PolicyModel</name>
- <version>0.0.1</version>
- </key>
- <UUID>0ce9168c-e6df-414f-9646-6da464b6e003</UUID>
- <description><![CDATA[Description for concept with key "PolicyModel:0.0.1"]]></description>
- </value>
- </entry>
- <entry>
- <key>
- <name>StringType</name>
- <version>0.0.1</version>
- </key>
- <value>
- <key>
- <name>StringType</name>
- <version>0.0.1</version>
- </key>
- <UUID>0ce9168c-e6df-414f-9646-6da464b6e004</UUID>
- <description><![CDATA[Description for concept with key "StringType:0.0.1"]]></description>
- </value>
- </entry>
- <entry>
- <key>
- <name>context</name>
- <version>0.0.1</version>
- </key>
- <value>
- <key>
- <name>context</name>
- <version>0.0.1</version>
- </key>
- <UUID>0ce9168c-e6df-414f-9646-6da464b6e005</UUID>
- <description><![CDATA[Description for concept with key "context:0.0.1"]]></description>
- </value>
- </entry>
- <entry>
- <key>
- <name>contextAlbum0</name>
- <version>0.0.1</version>
- </key>
- <value>
- <key>
- <name>contextAlbum0</name>
- <version>0.0.1</version>
- </key>
- <UUID>0ce9168c-e6df-414f-9646-6da464b6e006</UUID>
- <description><![CDATA[Description for concept with key "contextAlbum0:0.0.1"]]></description>
- </value>
- </entry>
- <entry>
- <key>
- <name>contextAlbum1</name>
- <version>0.0.1</version>
- </key>
- <value>
- <key>
- <name>contextAlbum1</name>
- <version>0.0.1</version>
- </key>
- <UUID>0ce9168c-e6df-414f-9646-6da464b6e007</UUID>
- <description><![CDATA[Description for concept with key "contextAlbum1:0.0.1"]]></description>
- </value>
- </entry>
- <entry>
- <key>
- <name>eventContextItem0</name>
- <version>0.0.1</version>
- </key>
- <value>
- <key>
- <name>eventContextItem0</name>
- <version>0.0.1</version>
- </key>
- <UUID>0ce9168c-e6df-414f-9646-6da464b6e008</UUID>
- <description><![CDATA[Description for concept with key "eventContextItem0:0.0.1"]]></description>
- </value>
- </entry>
- <entry>
- <key>
- <name>eventContextItem1</name>
- <version>0.0.1</version>
- </key>
- <value>
- <key>
- <name>eventContextItem1</name>
- <version>0.0.1</version>
- </key>
- <UUID>0ce9168c-e6df-414f-9646-6da464b6e009</UUID>
- <description><![CDATA[Description for concept with key "eventContextItem1:0.0.1"]]></description>
- </value>
- </entry>
- <entry>
- <key>
- <name>events</name>
- <version>0.0.1</version>
- </key>
- <value>
- <key>
- <name>events</name>
- <version>0.0.1</version>
- </key>
- <UUID>0ce9168c-e6df-414f-9646-6da464b6e010</UUID>
- <description><![CDATA[Description for concept with key "events:0.0.1"]]></description>
- </value>
- </entry>
- <entry>
- <key>
- <name>inEvent</name>
- <version>0.0.1</version>
- </key>
- <value>
- <key>
- <name>inEvent</name>
- <version>0.0.1</version>
- </key>
- <UUID>0ce9168c-e6df-414f-9646-6da464b6e011</UUID>
- <description><![CDATA[Description for concept with key "inEvent:0.0.1"]]></description>
- </value>
- </entry>
- <entry>
- <key>
- <name>outEvent0</name>
- <version>0.0.1</version>
- </key>
- <value>
- <key>
- <name>outEvent0</name>
- <version>0.0.1</version>
- </key>
- <UUID>0ce9168c-e6df-414f-9646-6da464b6e012</UUID>
- <description><![CDATA[Description for concept with key "outEvent0:0.0.1"]]></description>
- </value>
- </entry>
- <entry>
- <key>
- <name>outEvent1</name>
- <version>0.0.1</version>
- </key>
- <value>
- <key>
- <name>outEvent1</name>
- <version>0.0.1</version>
- </key>
- <UUID>0ce9168c-e6df-414f-9646-6da464b6e013</UUID>
- <description><![CDATA[Description for concept with key "outEvent1:0.0.1"]]></description>
- </value>
- </entry>
- <entry>
- <key>
- <name>policies</name>
- <version>0.0.1</version>
- </key>
- <value>
- <key>
- <name>policies</name>
- <version>0.0.1</version>
- </key>
- <UUID>0ce9168c-e6df-414f-9646-6da464b6e014</UUID>
- <description><![CDATA[Description for concept with key "policies:0.0.1"]]></description>
- </value>
- </entry>
- <entry>
- <key>
- <name>policy</name>
- <version>0.0.1</version>
- </key>
- <value>
- <key>
- <name>policy</name>
- <version>0.0.1</version>
- </key>
- <UUID>0ce9168c-e6df-414f-9646-6da464b6e015</UUID>
- <description><![CDATA[Description for concept with key "policy:0.0.1"]]></description>
- </value>
- </entry>
- <entry>
- <key>
- <name>task</name>
- <version>0.0.1</version>
- </key>
- <value>
- <key>
- <name>task</name>
- <version>0.0.1</version>
- </key>
- <UUID>0ce9168c-e6df-414f-9646-6da464b6e016</UUID>
- <description><![CDATA[Description for concept with key "task:0.0.1"]]></description>
- </value>
- </entry>
- <entry>
- <key>
- <name>tasks</name>
- <version>0.0.1</version>
- </key>
- <value>
- <key>
- <name>tasks</name>
- <version>0.0.1</version>
- </key>
- <UUID>0ce9168c-e6df-414f-9646-6da464b6e017</UUID>
- <description><![CDATA[Description for concept with key "tasks:0.0.1"]]></description>
- </value>
- </entry>
- </keyInfoMap>
- </keyInformation>
- <policies>
- <key>
- <name>policies</name>
- <version>0.0.1</version>
- </key>
- <policyMap>
- <entry>
- <key>
- <name>policy</name>
- <version>0.0.1</version>
- </key>
- <value>
- <policyKey>
- <name>policy</name>
- <version>0.0.1</version>
- </policyKey>
- <template>FREEFORM</template>
- <state>
- <entry>
- <key>state</key>
- <value>
- <stateKey>
- <parentKeyName>policy</parentKeyName>
- <parentKeyVersion>0.0.1</parentKeyVersion>
- <parentLocalName>NULL</parentLocalName>
- <localName>state</localName>
- </stateKey>
- <trigger>
- <name>inEvent</name>
- <version>0.0.1</version>
- </trigger>
- <stateOutputs>
- <entry>
- <key>stateOutput0</key>
- <value>
- <key>
- <parentKeyName>policy</parentKeyName>
- <parentKeyVersion>0.0.1</parentKeyVersion>
- <parentLocalName>state</parentLocalName>
- <localName>stateOutput0</localName>
- </key>
- <outgoingEvent>
- <name>outEvent0</name>
- <version>0.0.1</version>
- </outgoingEvent>
- <nextState>
- <parentKeyName>NULL</parentKeyName>
- <parentKeyVersion>0.0.0</parentKeyVersion>
- <parentLocalName>NULL</parentLocalName>
- <localName>NULL</localName>
- </nextState>
- </value>
- </entry>
- </stateOutputs>
- <contextAlbumReference>
- <name>contextAlbum0</name>
- <version>0.0.1</version>
- </contextAlbumReference>
- <contextAlbumReference>
- <name>contextAlbum1</name>
- <version>0.0.1</version>
- </contextAlbumReference>
- <taskSelectionLogic>
- <key>taskSelectionLogic</key>
- <logicFlavour>MVEL</logicFlavour>
- <logic><![CDATA[Some TS logic]]></logic>
- </taskSelectionLogic>
- <defaultTask>
- <name>task</name>
- <version>0.0.1</version>
- </defaultTask>
- <taskReferences>
- <entry>
- <key>
- <name>task</name>
- <version>0.0.1</version>
- </key>
- <value>
- <key>
- <parentKeyName>policy</parentKeyName>
- <parentKeyVersion>0.0.1</parentKeyVersion>
- <parentLocalName>state</parentLocalName>
- <localName>task</localName>
- </key>
- <outputType>DIRECT</outputType>
- <output>
- <parentKeyName>policy</parentKeyName>
- <parentKeyVersion>0.0.1</parentKeyVersion>
- <parentLocalName>state</parentLocalName>
- <localName>stateOutput0</localName>
- </output>
- </value>
- </entry>
- </taskReferences>
- </value>
- </entry>
- </state>
- <firstState>state</firstState>
- </value>
- </entry>
- </policyMap>
- </policies>
- <tasks>
- <key>
- <name>tasks</name>
- <version>0.0.1</version>
- </key>
- <taskMap>
- <entry>
- <key>
- <name>task</name>
- <version>0.0.1</version>
- </key>
- <value>
- <key>
- <name>task</name>
- <version>0.0.1</version>
- </key>
- <taskParameters>
- <entry>
- <key>taskParameter0</key>
- <value>
- <key>
- <parentKeyName>task</parentKeyName>
- <parentKeyVersion>0.0.1</parentKeyVersion>
- <parentLocalName>NULL</parentLocalName>
- <localName>taskParameter0</localName>
- </key>
- <defaultValue>Task parameter 0 value</defaultValue>
- </value>
- </entry>
- <entry>
- <key>taskParameter1</key>
- <value>
- <key>
- <parentKeyName>task</parentKeyName>
- <parentKeyVersion>0.0.1</parentKeyVersion>
- <parentLocalName>NULL</parentLocalName>
- <localName>taskParameter1</localName>
- </key>
- <defaultValue>Task parameter 1 value</defaultValue>
- </value>
- </entry>
- </taskParameters>
- <contextAlbumReference>
- <name>contextAlbum0</name>
- <version>0.0.1</version>
- </contextAlbumReference>
- <contextAlbumReference>
- <name>contextAlbum1</name>
- <version>0.0.1</version>
- </contextAlbumReference>
- <taskLogic>
- <key>taskLogic</key>
- <logicFlavour>MVEL</logicFlavour>
- <logic><![CDATA[Some task logic]]></logic>
- </taskLogic>
- </value>
- </entry>
- </taskMap>
- </tasks>
- <events>
- <key>
- <name>events</name>
- <version>0.0.1</version>
- </key>
- <eventMap>
- <entry>
- <key>
- <name>inEvent</name>
- <version>0.0.1</version>
- </key>
- <value>
- <key>
- <name>inEvent</name>
- <version>0.0.1</version>
- </key>
- <nameSpace>org.onap.policy.apex.model.policymodel.events</nameSpace>
- <source>Source</source>
- <target>Target</target>
- <parameter>
- <entry>
- <key>IEPAR0</key>
- <value>
- <key>IEPAR0</key>
- <fieldSchemaKey>
- <name>eventContextItem0</name>
- <version>0.0.1</version>
- </fieldSchemaKey>
- </value>
- </entry>
- <entry>
- <key>IEPAR1</key>
- <value>
- <key>IEPAR1</key>
- <fieldSchemaKey>
- <name>eventContextItem1</name>
- <version>0.0.1</version>
- </fieldSchemaKey>
- </value>
- </entry>
- </parameter>
- </value>
- </entry>
- <entry>
- <key>
- <name>outEvent0</name>
- <version>0.0.1</version>
- </key>
- <value>
- <key>
- <name>outEvent0</name>
- <version>0.0.1</version>
- </key>
- <nameSpace>org.onap.policy.apex.model.policymodel.events</nameSpace>
- <source>Source</source>
- <target>Target</target>
- <parameter>
- <entry>
- <key>OE0PAR0</key>
- <value>
- <key>OE0PAR0</key>
- <fieldSchemaKey>
- <name>eventContextItem0</name>
- <version>0.0.1</version>
- </fieldSchemaKey>
- </value>
- </entry>
- <entry>
- <key>OE0PAR1</key>
- <value>
- <key>OE0PAR1</key>
- <fieldSchemaKey>
- <name>eventContextItem1</name>
- <version>0.0.1</version>
- </fieldSchemaKey>
- </value>
- </entry>
- <entry>
- <key>OE1PAR0</key>
- <value>
- <key>OE1PAR0</key>
- <fieldSchemaKey>
- <name>eventContextItem0</name>
- <version>0.0.1</version>
- </fieldSchemaKey>
- </value>
- </entry>
- <entry>
- <key>OE1PAR1</key>
- <value>
- <key>OE1PAR1</key>
- <fieldSchemaKey>
- <name>eventContextItem1</name>
- <version>0.0.1</version>
- </fieldSchemaKey>
- </value>
- </entry>
- </parameter>
- </value>
- </entry>
- <entry>
- <key>
- <name>outEvent1</name>
- <version>0.0.1</version>
- </key>
- <value>
- <key>
- <name>outEvent1</name>
- <version>0.0.1</version>
- </key>
- <nameSpace>org.onap.policy.apex.model.policymodel.events</nameSpace>
- <source>Source</source>
- <target>Target</target>
- <parameter>
- <entry>
- <key>OE1PAR0</key>
- <value>
- <key>OE1PAR0</key>
- <fieldSchemaKey>
- <name>eventContextItem0</name>
- <version>0.0.1</version>
- </fieldSchemaKey>
- </value>
- </entry>
- <entry>
- <key>OE1PAR1</key>
- <value>
- <key>OE1PAR1</key>
- <fieldSchemaKey>
- <name>eventContextItem1</name>
- <version>0.0.1</version>
- </fieldSchemaKey>
- </value>
- </entry>
- </parameter>
- </value>
- </entry>
- </eventMap>
- </events>
- <albums>
- <key xmlns="http://www.onap.org/policy/apex-pdp">
- <name xmlns="http://www.onap.org/policy/apex-pdp">context</name>
- <version xmlns="http://www.onap.org/policy/apex-pdp">0.0.1</version>
- </key>
- <albums xmlns="http://www.onap.org/policy/apex-pdp">
- <entry>
- <key>
- <name xmlns="http://www.onap.org/policy/apex-pdp">contextAlbum0</name>
- <version xmlns="http://www.onap.org/policy/apex-pdp">0.0.1</version>
- </key>
- <value>
- <key>
- <name xmlns="http://www.onap.org/policy/apex-pdp">contextAlbum0</name>
- <version xmlns="http://www.onap.org/policy/apex-pdp">0.0.1</version>
- </key>
- <scope>APPLICATION</scope>
- <isWritable>true</isWritable>
- <itemSchema>
- <name xmlns="http://www.onap.org/policy/apex-pdp">MapType</name>
- <version xmlns="http://www.onap.org/policy/apex-pdp">0.0.1</version>
- </itemSchema>
- </value>
- </entry>
- <entry>
- <key>
- <name xmlns="http://www.onap.org/policy/apex-pdp">contextAlbum1</name>
- <version xmlns="http://www.onap.org/policy/apex-pdp">0.0.1</version>
- </key>
- <value>
- <key>
- <name xmlns="http://www.onap.org/policy/apex-pdp">contextAlbum1</name>
- <version xmlns="http://www.onap.org/policy/apex-pdp">0.0.1</version>
- </key>
- <scope>GLOBAL</scope>
- <isWritable>false</isWritable>
- <itemSchema>
- <name xmlns="http://www.onap.org/policy/apex-pdp">StringType</name>
- <version xmlns="http://www.onap.org/policy/apex-pdp">0.0.1</version>
- </itemSchema>
- </value>
- </entry>
- </albums>
- </albums>
- <schemas>
- <key xmlns="http://www.onap.org/policy/apex-pdp">
- <name xmlns="http://www.onap.org/policy/apex-pdp">ContextSchemas</name>
- <version xmlns="http://www.onap.org/policy/apex-pdp">0.0.1</version>
- </key>
- <schemas xmlns="http://www.onap.org/policy/apex-pdp">
- <entry>
- <key>
- <name xmlns="http://www.onap.org/policy/apex-pdp">MapType</name>
- <version xmlns="http://www.onap.org/policy/apex-pdp">0.0.1</version>
- </key>
- <value>
- <key>
- <name xmlns="http://www.onap.org/policy/apex-pdp">MapType</name>
- <version xmlns="http://www.onap.org/policy/apex-pdp">0.0.1</version>
- </key>
- <schemaFlavour>Java</schemaFlavour>
- <schemaDefinition>org.onap.policy.apex.model.policymodel.concepts.TestContextItem00A
- </schemaDefinition>
- </value>
- </entry>
- <entry>
- <key>
- <name xmlns="http://www.onap.org/policy/apex-pdp">StringType</name>
- <version xmlns="http://www.onap.org/policy/apex-pdp">0.0.1</version>
- </key>
- <value>
- <key>
- <name xmlns="http://www.onap.org/policy/apex-pdp">StringType</name>
- <version xmlns="http://www.onap.org/policy/apex-pdp">0.0.1</version>
- </key>
- <schemaFlavour>Java</schemaFlavour>
- <schemaDefinition>org.onap.policy.apex.model.policymodel.concepts.TestContextItem000
- </schemaDefinition>
- </value>
- </entry>
- <entry>
- <key>
- <name xmlns="http://www.onap.org/policy/apex-pdp">eventContextItem0</name>
- <version xmlns="http://www.onap.org/policy/apex-pdp">0.0.1</version>
- </key>
- <value>
- <key>
- <name xmlns="http://www.onap.org/policy/apex-pdp">eventContextItem0</name>
- <version xmlns="http://www.onap.org/policy/apex-pdp">0.0.1</version>
- </key>
- <schemaFlavour>Java</schemaFlavour>
- <schemaDefinition>java.lang.String</schemaDefinition>
- </value>
- </entry>
- <entry>
- <key>
- <name xmlns="http://www.onap.org/policy/apex-pdp">eventContextItem1</name>
- <version xmlns="http://www.onap.org/policy/apex-pdp">0.0.1</version>
- </key>
- <value>
- <key>
- <name xmlns="http://www.onap.org/policy/apex-pdp">eventContextItem1</name>
- <version xmlns="http://www.onap.org/policy/apex-pdp">0.0.1</version>
- </key>
- <schemaFlavour>Java</schemaFlavour>
- <schemaDefinition>java.lang.Long</schemaDefinition>
- </value>
- </entry>
- </schemas>
- </schemas>
-</apexPolicyModel>
diff --git a/model/model-api/src/test/resources/models/RealPolicyModel.json b/model/model-api/src/test/resources/models/RealPolicyModel.json
new file mode 100644
index 000000000..f084747f2
--- /dev/null
+++ b/model/model-api/src/test/resources/models/RealPolicyModel.json
@@ -0,0 +1,3076 @@
+{
+ "key": {
+ "name": "ONAPvCPEPolicyModel",
+ "version": "0.0.1"
+ },
+ "keyInformation": {
+ "key": {
+ "name": "ONAPvCPEPolicyModel_KeyInfo",
+ "version": "0.0.1"
+ },
+ "keyInfoMap": {
+ "entry": [
+ {
+ "key": {
+ "name": "AAILookupTask",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "AAILookupTask",
+ "version": "0.0.1"
+ },
+ "UUID": "bc77813f-e2fa-33e0-aef0-c5b6a8832698",
+ "description": "Generated description for concept referred to by key \"AAILookupTask:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "APPCLCMRequestType",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "APPCLCMRequestType",
+ "version": "0.0.1"
+ },
+ "UUID": "ab26e475-d09d-36cd-a65c-8a8b556f0fa2",
+ "description": "Generated description for concept referred to by key \"APPCLCMRequestType:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "APPCLCMResponseType",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "APPCLCMResponseType",
+ "version": "0.0.1"
+ },
+ "UUID": "a60b42bb-c308-30ea-be59-5bc54864508b",
+ "description": "Generated description for concept referred to by key \"APPCLCMResponseType:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "APPCRestartVNFRequestEvent",
+ "version": "2.0.0"
+ },
+ "value": {
+ "key": {
+ "name": "APPCRestartVNFRequestEvent",
+ "version": "2.0.0"
+ },
+ "UUID": "0b16f8d9-6ee9-30d7-bcd2-e4ded9fccf9b",
+ "description": "Generated description for concept referred to by key \"APPCRestartVNFRequestEvent:2.0.0\""
+ }
+ },
+ {
+ "key": {
+ "name": "APPCRestartVNFRequestTask",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "APPCRestartVNFRequestTask",
+ "version": "0.0.1"
+ },
+ "UUID": "719ae90e-ab01-322e-ace3-8c379e7c1fbf",
+ "description": "Generated description for concept referred to by key \"APPCRestartVNFRequestTask:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "APPCRestartVNFResponseEvent",
+ "version": "2.0.0"
+ },
+ "value": {
+ "key": {
+ "name": "APPCRestartVNFResponseEvent",
+ "version": "2.0.0"
+ },
+ "UUID": "7034c5a9-2ea7-3e9e-9ccf-3610c3bf80d9",
+ "description": "Generated description for concept referred to by key \"APPCRestartVNFResponseEvent:2.0.0\""
+ }
+ },
+ {
+ "key": {
+ "name": "APPCRestartVNFResponseTask",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "APPCRestartVNFResponseTask",
+ "version": "0.0.1"
+ },
+ "UUID": "fe641fd9-6583-37c5-b317-2a33a3ca5ac7",
+ "description": "Generated description for concept referred to by key \"APPCRestartVNFResponseTask:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "AbatedTask",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "AbatedTask",
+ "version": "0.0.1"
+ },
+ "UUID": "0eb3974f-4fdc-3c90-b351-34e7e18ff1ab",
+ "description": "Generated description for concept referred to by key \"AbatedTask:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e",
+ "version": "1.0.2"
+ },
+ "value": {
+ "key": {
+ "name": "ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e",
+ "version": "1.0.2"
+ },
+ "UUID": "63ff5c25-f245-37e9-a580-6ac274ced3a7",
+ "description": "Generated description for concept referred to by key \"ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e:1.0.2\""
+ }
+ },
+ {
+ "key": {
+ "name": "ControlLoopExecutionIDAlbum",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "ControlLoopExecutionIDAlbum",
+ "version": "0.0.1"
+ },
+ "UUID": "5b2bc0cf-0807-3ab1-9004-f21806d800f0",
+ "description": "Generated description for concept referred to by key \"ControlLoopExecutionIDAlbum:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "ControlLoopLogEvent",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "ControlLoopLogEvent",
+ "version": "0.0.1"
+ },
+ "UUID": "ed8a82ad-52c2-3d58-8c08-601606894b86",
+ "description": "Generated description for concept referred to by key \"ControlLoopLogEvent:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "ControlLoopLogTask",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "ControlLoopLogTask",
+ "version": "0.0.1"
+ },
+ "UUID": "1b175691-6b5d-31f6-bf2d-4be95a01f92e",
+ "description": "Generated description for concept referred to by key \"ControlLoopLogTask:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "DeniedTask",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "DeniedTask",
+ "version": "0.0.1"
+ },
+ "UUID": "00142e3c-ee3b-323f-9490-6e4b7f34b09f",
+ "description": "Generated description for concept referred to by key \"DeniedTask:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "GetVCPEStateTask",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "GetVCPEStateTask",
+ "version": "0.0.1"
+ },
+ "UUID": "644d2a3d-0f3a-3664-8000-280c400a5cc1",
+ "description": "Generated description for concept referred to by key \"GetVCPEStateTask:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "GuardDecisionAttributesType",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "GuardDecisionAttributesType",
+ "version": "0.0.1"
+ },
+ "UUID": "5f6dff51-c183-322f-9aba-c6074aa0ece5",
+ "description": "Generated description for concept referred to by key \"GuardDecisionAttributesType:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "GuardRequestEvent",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "GuardRequestEvent",
+ "version": "0.0.1"
+ },
+ "UUID": "fb383a58-715b-3972-a3e6-38010a8de234",
+ "description": "Generated description for concept referred to by key \"GuardRequestEvent:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "GuardRequestTask",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "GuardRequestTask",
+ "version": "0.0.1"
+ },
+ "UUID": "0427d63c-da78-334c-a5bd-95fbbb162398",
+ "description": "Generated description for concept referred to by key \"GuardRequestTask:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "GuardResponseEvent",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "GuardResponseEvent",
+ "version": "0.0.1"
+ },
+ "UUID": "395f6d46-cf24-3d3e-b1fd-1a189a58993d",
+ "description": "Generated description for concept referred to by key \"GuardResponseEvent:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "GuardResponseTask",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "GuardResponseTask",
+ "version": "0.0.1"
+ },
+ "UUID": "1a8b3f30-a7aa-330b-8131-4aea06ad6934",
+ "description": "Generated description for concept referred to by key \"GuardResponseTask:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "NoAAILookupTask",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "NoAAILookupTask",
+ "version": "0.0.1"
+ },
+ "UUID": "648bc8f9-ad2b-3a1b-abe2-89401645f191",
+ "description": "Generated description for concept referred to by key \"NoAAILookupTask:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "ONAPvCPEPolicyModel",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "ONAPvCPEPolicyModel",
+ "version": "0.0.1"
+ },
+ "UUID": "cf1aa7f4-6fe3-3cba-90b4-49dcf46f0d57",
+ "description": "Generated description for concept referred to by key \"ONAPvCPEPolicyModel:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "ONAPvCPEPolicyModel_Albums",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "ONAPvCPEPolicyModel_Albums",
+ "version": "0.0.1"
+ },
+ "UUID": "13f8471b-2b9c-32e0-940b-fe640ea442cf",
+ "description": "Generated description for concept referred to by key \"ONAPvCPEPolicyModel_Albums:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "ONAPvCPEPolicyModel_Events",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "ONAPvCPEPolicyModel_Events",
+ "version": "0.0.1"
+ },
+ "UUID": "4b8e6653-731d-38c5-a195-0cadf533a7a1",
+ "description": "Generated description for concept referred to by key \"ONAPvCPEPolicyModel_Events:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "ONAPvCPEPolicyModel_KeyInfo",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "ONAPvCPEPolicyModel_KeyInfo",
+ "version": "0.0.1"
+ },
+ "UUID": "87a9d6da-7d4b-3041-8a70-49442750d590",
+ "description": "Generated description for concept referred to by key \"ONAPvCPEPolicyModel_KeyInfo:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "ONAPvCPEPolicyModel_Policies",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "ONAPvCPEPolicyModel_Policies",
+ "version": "0.0.1"
+ },
+ "UUID": "6220cca4-66f5-3d1b-9f19-688a9b4b70f5",
+ "description": "Generated description for concept referred to by key \"ONAPvCPEPolicyModel_Policies:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "ONAPvCPEPolicyModel_Schemas",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "ONAPvCPEPolicyModel_Schemas",
+ "version": "0.0.1"
+ },
+ "UUID": "3df4eef8-e764-3398-afe9-86730e20905a",
+ "description": "Generated description for concept referred to by key \"ONAPvCPEPolicyModel_Schemas:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "ONAPvCPEPolicyModel_Tasks",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "ONAPvCPEPolicyModel_Tasks",
+ "version": "0.0.1"
+ },
+ "UUID": "1781b875-a3e8-3407-98bd-ba9580cfc543",
+ "description": "Generated description for concept referred to by key \"ONAPvCPEPolicyModel_Tasks:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "ReceiveEventPolicy",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "ReceiveEventPolicy",
+ "version": "0.0.1"
+ },
+ "UUID": "568b7345-9de1-36d3-b6a3-9b857e6809a1",
+ "description": "Generated description for concept referred to by key \"ReceiveEventPolicy:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "RequestIDVNFIDAlbum",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "RequestIDVNFIDAlbum",
+ "version": "0.0.1"
+ },
+ "UUID": "5d8e8298-ded6-30a5-9825-48111dc17a58",
+ "description": "Generated description for concept referred to by key \"RequestIDVNFIDAlbum:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "RestartAPPCRequestPolicy",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "RestartAPPCRequestPolicy",
+ "version": "0.0.1"
+ },
+ "UUID": "33d02162-314b-352b-b8b9-2862e8883894",
+ "description": "Generated description for concept referred to by key \"RestartAPPCRequestPolicy:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "RestartAPPCResponsePolicy",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "RestartAPPCResponsePolicy",
+ "version": "0.0.1"
+ },
+ "UUID": "ef4fcbd2-1609-377c-9875-8d27f7a901df",
+ "description": "Generated description for concept referred to by key \"RestartAPPCResponsePolicy:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "SimpleBooleanType",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "SimpleBooleanType",
+ "version": "0.0.1"
+ },
+ "UUID": "7218fb2f-59e3-321d-9ae1-bc97b19eb4ae",
+ "description": "Generated description for concept referred to by key \"SimpleBooleanType:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "SimpleLongType",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "SimpleLongType",
+ "version": "0.0.1"
+ },
+ "UUID": "2dfcd9ec-a6f9-3f9f-958f-9b36cf4ac574",
+ "description": "Generated description for concept referred to by key \"SimpleLongType:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "SimpleStringType",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "SimpleStringType",
+ "version": "0.0.1"
+ },
+ "UUID": "8a4957cf-9493-3a76-8c22-a208e23259af",
+ "description": "Generated description for concept referred to by key \"SimpleStringType:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "UUIDType",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "UUIDType",
+ "version": "0.0.1"
+ },
+ "UUID": "6a8cc68e-dfc8-3403-9c6d-071c886b319c",
+ "description": "Generated description for concept referred to by key \"UUIDType:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "VCPEClosedLoopStatusAlbum",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "VCPEClosedLoopStatusAlbum",
+ "version": "0.0.1"
+ },
+ "UUID": "47a4403e-3074-3964-83ef-93eefaffd192",
+ "description": "Generated description for concept referred to by key \"VCPEClosedLoopStatusAlbum:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "VCPEClosedLoopStatusType",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "VCPEClosedLoopStatusType",
+ "version": "0.0.1"
+ },
+ "UUID": "6e7dced1-53f1-39e2-b4e6-412b75d5b9e6",
+ "description": "Generated description for concept referred to by key \"VCPEClosedLoopStatusType:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "VCPEStateUpdatedEvent",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "VCPEStateUpdatedEvent",
+ "version": "0.0.1"
+ },
+ "UUID": "5e56a3fd-f82a-3ced-821b-b9fbaf65d367",
+ "description": "Generated description for concept referred to by key \"VCPEStateUpdatedEvent:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "VirtualControlLoopEventType",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "VirtualControlLoopEventType",
+ "version": "0.0.1"
+ },
+ "UUID": "15aca887-8f6c-3713-8114-0f49f03adab7",
+ "description": "Generated description for concept referred to by key \"VirtualControlLoopEventType:0.0.1\""
+ }
+ },
+ {
+ "key": {
+ "name": "VirtualControlLoopNotificationType",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "VirtualControlLoopNotificationType",
+ "version": "0.0.1"
+ },
+ "UUID": "283f5b0d-d8cd-31b0-91fa-89b9de2e1fda",
+ "description": "Generated description for concept referred to by key \"VirtualControlLoopNotificationType:0.0.1\""
+ }
+ }
+ ]
+ }
+ },
+ "policies": {
+ "key": {
+ "name": "ONAPvCPEPolicyModel_Policies",
+ "version": "0.0.1"
+ },
+ "policyMap": {
+ "entry": [
+ {
+ "key": {
+ "name": "ReceiveEventPolicy",
+ "version": "0.0.1"
+ },
+ "value": {
+ "policyKey": {
+ "name": "ReceiveEventPolicy",
+ "version": "0.0.1"
+ },
+ "template": "Freestyle",
+ "state": {
+ "entry": [
+ {
+ "key": "AbatedState",
+ "value": {
+ "stateKey": {
+ "parentKeyName": "ReceiveEventPolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "NULL",
+ "localName": "AbatedState"
+ },
+ "trigger": {
+ "name": "VCPEStateUpdatedEvent",
+ "version": "0.0.1"
+ },
+ "stateOutputs": {
+ "entry": [
+ {
+ "key": "AbatedOutput",
+ "value": {
+ "key": {
+ "parentKeyName": "ReceiveEventPolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "AbatedState",
+ "localName": "AbatedOutput"
+ },
+ "outgoingEvent": {
+ "name": "ControlLoopLogEvent",
+ "version": "0.0.1"
+ },
+ "outgoingEventReference": [
+ {
+ "name": "ControlLoopLogEvent",
+ "version": "0.0.1"
+ }
+ ],
+ "nextState": {
+ "parentKeyName": "NULL",
+ "parentKeyVersion": "0.0.0",
+ "parentLocalName": "NULL",
+ "localName": "NULL"
+ }
+ }
+ }
+ ]
+ },
+ "contextAlbumReference": [],
+ "taskSelectionLogic": {
+ "key": "NULL",
+ "logicFlavour": "UNDEFINED",
+ "logic": ""
+ },
+ "stateFinalizerLogicMap": {
+ "entry": []
+ },
+ "defaultTask": {
+ "name": "ControlLoopLogTask",
+ "version": "0.0.1"
+ },
+ "taskReferences": {
+ "entry": [
+ {
+ "key": {
+ "name": "ControlLoopLogTask",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "parentKeyName": "ReceiveEventPolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "AbatedState",
+ "localName": "ReceiveEventPolicy"
+ },
+ "outputType": "DIRECT",
+ "output": {
+ "parentKeyName": "ReceiveEventPolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "AbatedState",
+ "localName": "AbatedOutput"
+ }
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "key": "GetVCPEState",
+ "value": {
+ "stateKey": {
+ "parentKeyName": "ReceiveEventPolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "NULL",
+ "localName": "GetVCPEState"
+ },
+ "trigger": {
+ "name": "ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e",
+ "version": "1.0.2"
+ },
+ "stateOutputs": {
+ "entry": [
+ {
+ "key": "GetVCPEStateOutput",
+ "value": {
+ "key": {
+ "parentKeyName": "ReceiveEventPolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "GetVCPEState",
+ "localName": "GetVCPEStateOutput"
+ },
+ "outgoingEvent": {
+ "name": "VCPEStateUpdatedEvent",
+ "version": "0.0.1"
+ },
+ "outgoingEventReference": [
+ {
+ "name": "VCPEStateUpdatedEvent",
+ "version": "0.0.1"
+ }
+ ],
+ "nextState": {
+ "parentKeyName": "ReceiveEventPolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "NULL",
+ "localName": "RequestAAIState"
+ }
+ }
+ }
+ ]
+ },
+ "contextAlbumReference": [],
+ "taskSelectionLogic": {
+ "key": "NULL",
+ "logicFlavour": "UNDEFINED",
+ "logic": ""
+ },
+ "stateFinalizerLogicMap": {
+ "entry": []
+ },
+ "defaultTask": {
+ "name": "GetVCPEStateTask",
+ "version": "0.0.1"
+ },
+ "taskReferences": {
+ "entry": [
+ {
+ "key": {
+ "name": "GetVCPEStateTask",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "parentKeyName": "ReceiveEventPolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "GetVCPEState",
+ "localName": "ReceiveEventPolicy"
+ },
+ "outputType": "DIRECT",
+ "output": {
+ "parentKeyName": "ReceiveEventPolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "GetVCPEState",
+ "localName": "GetVCPEStateOutput"
+ }
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "key": "OnsetOrAbatedState",
+ "value": {
+ "stateKey": {
+ "parentKeyName": "ReceiveEventPolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "NULL",
+ "localName": "OnsetOrAbatedState"
+ },
+ "trigger": {
+ "name": "VCPEStateUpdatedEvent",
+ "version": "0.0.1"
+ },
+ "stateOutputs": {
+ "entry": [
+ {
+ "key": "AbatedOutput",
+ "value": {
+ "key": {
+ "parentKeyName": "ReceiveEventPolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "OnsetOrAbatedState",
+ "localName": "AbatedOutput"
+ },
+ "outgoingEvent": {
+ "name": "VCPEStateUpdatedEvent",
+ "version": "0.0.1"
+ },
+ "outgoingEventReference": [
+ {
+ "name": "VCPEStateUpdatedEvent",
+ "version": "0.0.1"
+ }
+ ],
+ "nextState": {
+ "parentKeyName": "ReceiveEventPolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "NULL",
+ "localName": "AbatedState"
+ }
+ }
+ },
+ {
+ "key": "OnsetOutput",
+ "value": {
+ "key": {
+ "parentKeyName": "ReceiveEventPolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "OnsetOrAbatedState",
+ "localName": "OnsetOutput"
+ },
+ "outgoingEvent": {
+ "name": "GuardRequestEvent",
+ "version": "0.0.1"
+ },
+ "outgoingEventReference": [
+ {
+ "name": "GuardRequestEvent",
+ "version": "0.0.1"
+ }
+ ],
+ "nextState": {
+ "parentKeyName": "NULL",
+ "parentKeyVersion": "0.0.0",
+ "parentLocalName": "NULL",
+ "localName": "NULL"
+ }
+ }
+ }
+ ]
+ },
+ "contextAlbumReference": [
+ {
+ "name": "VCPEClosedLoopStatusAlbum",
+ "version": "0.0.1"
+ }
+ ],
+ "taskSelectionLogic": {
+ "key": "TaskSelectionLogic",
+ "logicFlavour": "JAVASCRIPT",
+ "logic": "/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2016-2018 Ericsson. All rights reserved.\n * Modifications Copyright (C) 2020 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(executor.subject.id);\nexecutor.logger.info(executor.inFields);\n\nvar returnValue = true;\nvar status = null;\n\nif( executor.inFields.get(\"vnfID\") == null) {\n executor.logger.info(\"OnsetOrAbatedStateTSL: vnfID is null\");\n var vnfName = executor.inFields.get(\"vnfName\");\n var vcpeClosedLoopStatus = executor.getContextAlbum(\"VCPEClosedLoopStatusAlbum\").get(\n executor.inFields.get(\"vnfName\"));\n status = vcpeClosedLoopStatus.get(\"closedLoopEventStatus\").toString();\n} else {\n var vcpeClosedLoopStatus = executor.getContextAlbum(\"VCPEClosedLoopStatusAlbum\").get(\n executor.inFields.get(\"vnfID\").toString());\n status = vcpeClosedLoopStatus.get(\"closedLoopEventStatus\").toString();\n}\n\nif (status == \"ONSET\") {\n executor.subject.getTaskKey(\"GuardRequestTask\").copyTo(executor.selectedTask);\n} else if (status == \"ABATED\") {\n executor.subject.getTaskKey(\"AbatedTask\").copyTo(executor.selectedTask);\n onsetFlag = executor.isFalse;\n} else {\n executor.message = \"closedLoopEventStatus is \\\"\" + status + \"\\\", it must be either \\\"ONSET\\\" or \\\"ABATED\\\"\";\n returnValue = false;\n}\n\nexecutor.logger.info(\"ReceiveEventPolicyOnsetOrAbatedStateTSL State Selected Task:\" + executor.selectedTask);\n\nreturnValue;"
+ },
+ "stateFinalizerLogicMap": {
+ "entry": []
+ },
+ "defaultTask": {
+ "name": "AbatedTask",
+ "version": "0.0.1"
+ },
+ "taskReferences": {
+ "entry": [
+ {
+ "key": {
+ "name": "AbatedTask",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "parentKeyName": "ReceiveEventPolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "OnsetOrAbatedState",
+ "localName": "ReceiveEventPolicy"
+ },
+ "outputType": "DIRECT",
+ "output": {
+ "parentKeyName": "ReceiveEventPolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "OnsetOrAbatedState",
+ "localName": "AbatedOutput"
+ }
+ }
+ },
+ {
+ "key": {
+ "name": "GuardRequestTask",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "parentKeyName": "ReceiveEventPolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "OnsetOrAbatedState",
+ "localName": "ReceiveEventPolicy"
+ },
+ "outputType": "DIRECT",
+ "output": {
+ "parentKeyName": "ReceiveEventPolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "OnsetOrAbatedState",
+ "localName": "OnsetOutput"
+ }
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "key": "RequestAAIState",
+ "value": {
+ "stateKey": {
+ "parentKeyName": "ReceiveEventPolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "NULL",
+ "localName": "RequestAAIState"
+ },
+ "trigger": {
+ "name": "VCPEStateUpdatedEvent",
+ "version": "0.0.1"
+ },
+ "stateOutputs": {
+ "entry": [
+ {
+ "key": "RequestAAIStateOutput",
+ "value": {
+ "key": {
+ "parentKeyName": "ReceiveEventPolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "RequestAAIState",
+ "localName": "RequestAAIStateOutput"
+ },
+ "outgoingEvent": {
+ "name": "VCPEStateUpdatedEvent",
+ "version": "0.0.1"
+ },
+ "outgoingEventReference": [
+ {
+ "name": "VCPEStateUpdatedEvent",
+ "version": "0.0.1"
+ }
+ ],
+ "nextState": {
+ "parentKeyName": "ReceiveEventPolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "NULL",
+ "localName": "OnsetOrAbatedState"
+ }
+ }
+ }
+ ]
+ },
+ "contextAlbumReference": [
+ {
+ "name": "VCPEClosedLoopStatusAlbum",
+ "version": "0.0.1"
+ }
+ ],
+ "taskSelectionLogic": {
+ "key": "NULL",
+ "logicFlavour": "UNDEFINED",
+ "logic": ""
+ },
+ "stateFinalizerLogicMap": {
+ "entry": []
+ },
+ "defaultTask": {
+ "name": "AAILookupTask",
+ "version": "0.0.1"
+ },
+ "taskReferences": {
+ "entry": [
+ {
+ "key": {
+ "name": "AAILookupTask",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "parentKeyName": "ReceiveEventPolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "RequestAAIState",
+ "localName": "ReceiveEventPolicy"
+ },
+ "outputType": "DIRECT",
+ "output": {
+ "parentKeyName": "ReceiveEventPolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "RequestAAIState",
+ "localName": "RequestAAIStateOutput"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ ]
+ },
+ "firstState": "GetVCPEState"
+ }
+ },
+ {
+ "key": {
+ "name": "RestartAPPCRequestPolicy",
+ "version": "0.0.1"
+ },
+ "value": {
+ "policyKey": {
+ "name": "RestartAPPCRequestPolicy",
+ "version": "0.0.1"
+ },
+ "template": "Freestyle",
+ "state": {
+ "entry": [
+ {
+ "key": "DeniedState",
+ "value": {
+ "stateKey": {
+ "parentKeyName": "RestartAPPCRequestPolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "NULL",
+ "localName": "DeniedState"
+ },
+ "trigger": {
+ "name": "VCPEStateUpdatedEvent",
+ "version": "0.0.1"
+ },
+ "stateOutputs": {
+ "entry": [
+ {
+ "key": "DeniedOutput",
+ "value": {
+ "key": {
+ "parentKeyName": "RestartAPPCRequestPolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "DeniedState",
+ "localName": "DeniedOutput"
+ },
+ "outgoingEvent": {
+ "name": "ControlLoopLogEvent",
+ "version": "0.0.1"
+ },
+ "outgoingEventReference": [
+ {
+ "name": "ControlLoopLogEvent",
+ "version": "0.0.1"
+ }
+ ],
+ "nextState": {
+ "parentKeyName": "NULL",
+ "parentKeyVersion": "0.0.0",
+ "parentLocalName": "NULL",
+ "localName": "NULL"
+ }
+ }
+ }
+ ]
+ },
+ "contextAlbumReference": [],
+ "taskSelectionLogic": {
+ "key": "NULL",
+ "logicFlavour": "UNDEFINED",
+ "logic": ""
+ },
+ "stateFinalizerLogicMap": {
+ "entry": []
+ },
+ "defaultTask": {
+ "name": "ControlLoopLogTask",
+ "version": "0.0.1"
+ },
+ "taskReferences": {
+ "entry": [
+ {
+ "key": {
+ "name": "ControlLoopLogTask",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "parentKeyName": "RestartAPPCRequestPolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "DeniedState",
+ "localName": "RestartAPPCRequestPolicy"
+ },
+ "outputType": "DIRECT",
+ "output": {
+ "parentKeyName": "RestartAPPCRequestPolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "DeniedState",
+ "localName": "DeniedOutput"
+ }
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "key": "PermitOrDenyState",
+ "value": {
+ "stateKey": {
+ "parentKeyName": "RestartAPPCRequestPolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "NULL",
+ "localName": "PermitOrDenyState"
+ },
+ "trigger": {
+ "name": "VCPEStateUpdatedEvent",
+ "version": "0.0.1"
+ },
+ "stateOutputs": {
+ "entry": [
+ {
+ "key": "DenyOutput",
+ "value": {
+ "key": {
+ "parentKeyName": "RestartAPPCRequestPolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "PermitOrDenyState",
+ "localName": "DenyOutput"
+ },
+ "outgoingEvent": {
+ "name": "VCPEStateUpdatedEvent",
+ "version": "0.0.1"
+ },
+ "outgoingEventReference": [
+ {
+ "name": "VCPEStateUpdatedEvent",
+ "version": "0.0.1"
+ }
+ ],
+ "nextState": {
+ "parentKeyName": "RestartAPPCRequestPolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "NULL",
+ "localName": "DeniedState"
+ }
+ }
+ },
+ {
+ "key": "PermitOutput",
+ "value": {
+ "key": {
+ "parentKeyName": "RestartAPPCRequestPolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "PermitOrDenyState",
+ "localName": "PermitOutput"
+ },
+ "outgoingEvent": {
+ "name": "APPCRestartVNFRequestEvent",
+ "version": "2.0.0"
+ },
+ "outgoingEventReference": [
+ {
+ "name": "APPCRestartVNFRequestEvent",
+ "version": "2.0.0"
+ }
+ ],
+ "nextState": {
+ "parentKeyName": "NULL",
+ "parentKeyVersion": "0.0.0",
+ "parentLocalName": "NULL",
+ "localName": "NULL"
+ }
+ }
+ }
+ ]
+ },
+ "contextAlbumReference": [
+ {
+ "name": "VCPEClosedLoopStatusAlbum",
+ "version": "0.0.1"
+ }
+ ],
+ "taskSelectionLogic": {
+ "key": "TaskSelectionLogic",
+ "logicFlavour": "JAVASCRIPT",
+ "logic": "/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2016-2018 Ericsson. All rights reserved.\n * Modifications Copyright (C) 2020 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(executor.subject.id);\nexecutor.logger.info(executor.inFields);\n\nvar vcpeClosedLoopStatus = executor.getContextAlbum(\"VCPEClosedLoopStatusAlbum\").get(\n executor.inFields.get(\"vnfID\").toString());\n\nvar guardResult = vcpeClosedLoopStatus.get(\"notification\");\n\nif (guardResult == \"OPERATION: GUARD_PERMIT\") {\n executor.subject.getTaskKey(\"APPCRestartVNFRequestTask\").copyTo(executor.selectedTask);\n} else {\n executor.subject.getTaskKey(\"DeniedTask\").copyTo(executor.selectedTask);\n}\n\nexecutor.logger.info(\"RestartAPPCRequestPolicyPermitOrDenyTSL State Selected Task:\" + executor.selectedTask);\n\ntrue;"
+ },
+ "stateFinalizerLogicMap": {
+ "entry": []
+ },
+ "defaultTask": {
+ "name": "DeniedTask",
+ "version": "0.0.1"
+ },
+ "taskReferences": {
+ "entry": [
+ {
+ "key": {
+ "name": "APPCRestartVNFRequestTask",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "parentKeyName": "RestartAPPCRequestPolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "PermitOrDenyState",
+ "localName": "RestartAPPCRequestPolicy"
+ },
+ "outputType": "DIRECT",
+ "output": {
+ "parentKeyName": "RestartAPPCRequestPolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "PermitOrDenyState",
+ "localName": "PermitOutput"
+ }
+ }
+ },
+ {
+ "key": {
+ "name": "DeniedTask",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "parentKeyName": "RestartAPPCRequestPolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "PermitOrDenyState",
+ "localName": "RestartAPPCRequestPolicy"
+ },
+ "outputType": "DIRECT",
+ "output": {
+ "parentKeyName": "RestartAPPCRequestPolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "PermitOrDenyState",
+ "localName": "DenyOutput"
+ }
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "key": "PolicyGuardResponseState",
+ "value": {
+ "stateKey": {
+ "parentKeyName": "RestartAPPCRequestPolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "NULL",
+ "localName": "PolicyGuardResponseState"
+ },
+ "trigger": {
+ "name": "GuardResponseEvent",
+ "version": "0.0.1"
+ },
+ "stateOutputs": {
+ "entry": [
+ {
+ "key": "GuardResponseOutput",
+ "value": {
+ "key": {
+ "parentKeyName": "RestartAPPCRequestPolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "PolicyGuardResponseState",
+ "localName": "GuardResponseOutput"
+ },
+ "outgoingEvent": {
+ "name": "VCPEStateUpdatedEvent",
+ "version": "0.0.1"
+ },
+ "outgoingEventReference": [
+ {
+ "name": "VCPEStateUpdatedEvent",
+ "version": "0.0.1"
+ }
+ ],
+ "nextState": {
+ "parentKeyName": "RestartAPPCRequestPolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "NULL",
+ "localName": "PermitOrDenyState"
+ }
+ }
+ }
+ ]
+ },
+ "contextAlbumReference": [],
+ "taskSelectionLogic": {
+ "key": "NULL",
+ "logicFlavour": "UNDEFINED",
+ "logic": ""
+ },
+ "stateFinalizerLogicMap": {
+ "entry": []
+ },
+ "defaultTask": {
+ "name": "GuardResponseTask",
+ "version": "0.0.1"
+ },
+ "taskReferences": {
+ "entry": [
+ {
+ "key": {
+ "name": "GuardResponseTask",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "parentKeyName": "RestartAPPCRequestPolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "PolicyGuardResponseState",
+ "localName": "RestartAPPCRequestPolicy"
+ },
+ "outputType": "DIRECT",
+ "output": {
+ "parentKeyName": "RestartAPPCRequestPolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "PolicyGuardResponseState",
+ "localName": "GuardResponseOutput"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ ]
+ },
+ "firstState": "PolicyGuardResponseState"
+ }
+ },
+ {
+ "key": {
+ "name": "RestartAPPCResponsePolicy",
+ "version": "0.0.1"
+ },
+ "value": {
+ "policyKey": {
+ "name": "RestartAPPCResponsePolicy",
+ "version": "0.0.1"
+ },
+ "template": "Freestyle",
+ "state": {
+ "entry": [
+ {
+ "key": "ResponseLogState",
+ "value": {
+ "stateKey": {
+ "parentKeyName": "RestartAPPCResponsePolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "NULL",
+ "localName": "ResponseLogState"
+ },
+ "trigger": {
+ "name": "VCPEStateUpdatedEvent",
+ "version": "0.0.1"
+ },
+ "stateOutputs": {
+ "entry": [
+ {
+ "key": "ResponseLogOutput",
+ "value": {
+ "key": {
+ "parentKeyName": "RestartAPPCResponsePolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "ResponseLogState",
+ "localName": "ResponseLogOutput"
+ },
+ "outgoingEvent": {
+ "name": "ControlLoopLogEvent",
+ "version": "0.0.1"
+ },
+ "outgoingEventReference": [
+ {
+ "name": "ControlLoopLogEvent",
+ "version": "0.0.1"
+ }
+ ],
+ "nextState": {
+ "parentKeyName": "NULL",
+ "parentKeyVersion": "0.0.0",
+ "parentLocalName": "NULL",
+ "localName": "NULL"
+ }
+ }
+ }
+ ]
+ },
+ "contextAlbumReference": [],
+ "taskSelectionLogic": {
+ "key": "NULL",
+ "logicFlavour": "UNDEFINED",
+ "logic": ""
+ },
+ "stateFinalizerLogicMap": {
+ "entry": []
+ },
+ "defaultTask": {
+ "name": "ControlLoopLogTask",
+ "version": "0.0.1"
+ },
+ "taskReferences": {
+ "entry": [
+ {
+ "key": {
+ "name": "ControlLoopLogTask",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "parentKeyName": "RestartAPPCResponsePolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "ResponseLogState",
+ "localName": "RestartAPPCResponsePolicy"
+ },
+ "outputType": "DIRECT",
+ "output": {
+ "parentKeyName": "RestartAPPCResponsePolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "ResponseLogState",
+ "localName": "ResponseLogOutput"
+ }
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "key": "RestartAPPCResponseState",
+ "value": {
+ "stateKey": {
+ "parentKeyName": "RestartAPPCResponsePolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "NULL",
+ "localName": "RestartAPPCResponseState"
+ },
+ "trigger": {
+ "name": "APPCRestartVNFResponseEvent",
+ "version": "2.0.0"
+ },
+ "stateOutputs": {
+ "entry": [
+ {
+ "key": "APPCRestartVNFResponseOutput",
+ "value": {
+ "key": {
+ "parentKeyName": "RestartAPPCResponsePolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "RestartAPPCResponseState",
+ "localName": "APPCRestartVNFResponseOutput"
+ },
+ "outgoingEvent": {
+ "name": "VCPEStateUpdatedEvent",
+ "version": "0.0.1"
+ },
+ "outgoingEventReference": [
+ {
+ "name": "VCPEStateUpdatedEvent",
+ "version": "0.0.1"
+ }
+ ],
+ "nextState": {
+ "parentKeyName": "RestartAPPCResponsePolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "NULL",
+ "localName": "ResponseLogState"
+ }
+ }
+ }
+ ]
+ },
+ "contextAlbumReference": [],
+ "taskSelectionLogic": {
+ "key": "NULL",
+ "logicFlavour": "UNDEFINED",
+ "logic": ""
+ },
+ "stateFinalizerLogicMap": {
+ "entry": []
+ },
+ "defaultTask": {
+ "name": "APPCRestartVNFResponseTask",
+ "version": "0.0.1"
+ },
+ "taskReferences": {
+ "entry": [
+ {
+ "key": {
+ "name": "APPCRestartVNFResponseTask",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "parentKeyName": "RestartAPPCResponsePolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "RestartAPPCResponseState",
+ "localName": "RestartAPPCResponsePolicy"
+ },
+ "outputType": "DIRECT",
+ "output": {
+ "parentKeyName": "RestartAPPCResponsePolicy",
+ "parentKeyVersion": "0.0.1",
+ "parentLocalName": "RestartAPPCResponseState",
+ "localName": "APPCRestartVNFResponseOutput"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ ]
+ },
+ "firstState": "RestartAPPCResponseState"
+ }
+ }
+ ]
+ }
+ },
+ "tasks": {
+ "key": {
+ "name": "ONAPvCPEPolicyModel_Tasks",
+ "version": "0.0.1"
+ },
+ "taskMap": {
+ "entry": [
+ {
+ "key": {
+ "name": "AAILookupTask",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "AAILookupTask",
+ "version": "0.0.1"
+ },
+ "inputEvent": {
+ "key": {
+ "name": "VCPEStateUpdatedEvent",
+ "version": "0.0.1"
+ },
+ "nameSpace": "org.onap.policy.apex.onap.vcpe",
+ "source": "APEX",
+ "target": "APEX",
+ "parameter": {
+ "entry": [
+ {
+ "key": "requestID",
+ "value": {
+ "key": "requestID",
+ "fieldSchemaKey": {
+ "name": "UUIDType",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "vnfID",
+ "value": {
+ "key": "vnfID",
+ "fieldSchemaKey": {
+ "name": "UUIDType",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "vnfName",
+ "value": {
+ "key": "vnfName",
+ "fieldSchemaKey": {
+ "name": "SimpleStringType",
+ "version": "0.0.1"
+ },
+ "optional": true
+ }
+ }
+ ]
+ },
+ "toscaPolicyState": ""
+ },
+ "outputEvents": {
+ "entry": [
+ {
+ "key": "VCPEStateUpdatedEvent",
+ "value": {
+ "key": {
+ "name": "VCPEStateUpdatedEvent",
+ "version": "0.0.1"
+ },
+ "nameSpace": "org.onap.policy.apex.onap.vcpe",
+ "source": "APEX",
+ "target": "APEX",
+ "parameter": {
+ "entry": [
+ {
+ "key": "requestID",
+ "value": {
+ "key": "requestID",
+ "fieldSchemaKey": {
+ "name": "UUIDType",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "vnfID",
+ "value": {
+ "key": "vnfID",
+ "fieldSchemaKey": {
+ "name": "UUIDType",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "vnfName",
+ "value": {
+ "key": "vnfName",
+ "fieldSchemaKey": {
+ "name": "SimpleStringType",
+ "version": "0.0.1"
+ },
+ "optional": true
+ }
+ }
+ ]
+ },
+ "toscaPolicyState": ""
+ }
+ }
+ ]
+ },
+ "taskParameters": {
+ "entry": []
+ },
+ "contextAlbumReference": [
+ {
+ "name": "VCPEClosedLoopStatusAlbum",
+ "version": "0.0.1"
+ }
+ ],
+ "taskLogic": {
+ "key": "TaskLogic",
+ "logicFlavour": "JAVASCRIPT",
+ "logic": "/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2016-2018 Ericsson. All rights reserved.\n * Modifications Copyright (C) 2020 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(executor.subject.id);\nexecutor.logger.info(executor.inFields);\n\nvar vcpeClosedLoopStatus = executor.getContextAlbum(\"VCPEClosedLoopStatusAlbum\").get(\n executor.inFields.get(\"vnfID\").toString());\n\nexecutor.logger.info(\"Executing A&AI Lookup\");\nexecutor.logger.info(vcpeClosedLoopStatus);\n\nvar aaiInfo = vcpeClosedLoopStatus.get(\"AAI\");\nvar returnValue = true;\n\nif (aaiInfo.get(\"vserverName\") == null) {\n executor.message = \"the field vserver.vserver-name must exist in the onset control loop event\";\n executor.logger.warn(executor.message);\n returnValue = false;\n}\nelse if (aaiInfo.get(\"genericVnfVnfId\") == null && aaiInfo.get(\"genericVnfVnfName\") == null) {\n executor.message = \"either the field generic-vnf.vnf-id or generic-vnf.vnf-name must exist\"\n + \" in the onset control loop event\";\n executor.logger.warn(executor.message);\n returnValue = false;\n}\nelse {\n var restManager = new org.onap.policy.rest.RestManager;\n var aaiManager = new org.onap.policy.aai.AaiManager(restManager);\n\n // We need to instantiate the type in order to trigger the static JAXB handling\n // in the AaiCqResponse class\n var aaiCqResponseType = org.onap.policy.aai.AaiCqResponse;\n\n var aaiResponse = aaiManager.getCustomQueryResponse(\n \"http://localhost:54321/OnapVCpeSim/sim\",\n \"aai.username\",\n \"aai.password\",\n executor.inFields.get(\"requestID\"),\n vcpeClosedLoopStatus.get(\"AAI\").get(\"vserverName\")\n );\n\n var genericVnf;\n\n if (aaiInfo.get(\"genericVnfVnfId\") != null) {\n genericVnf = aaiResponse.getGenericVnfByModelInvariantId(aaiInfo.get(\"genericVnfVnfId\"));\n }\n else {\n genericVnf = aaiResponse.getGenericVnfByVnfName(aaiInfo.get(\"genericVnfVnfId\"));\n }\n\n aaiInfo.put(\"genericVnfResourceVersion\", genericVnf.getResourceVersion());\n aaiInfo.put(\"genericVnfVnfName\", genericVnf.getVnfName());\n aaiInfo.put(\"genericVnfProvStatus\", genericVnf.getProvStatus());\n aaiInfo.put(\"genericVnfIsClosedLoopDisabled\", genericVnf.isIsClosedLoopDisabled().toString());\n aaiInfo.put(\"genericVnfVnfType\", genericVnf.getVnfType());\n aaiInfo.put(\"genericVnfInMaint\", genericVnf.isInMaint().toString());\n aaiInfo.put(\"genericVnfServiceId\", genericVnf.getServiceId());\n aaiInfo.put(\"genericVnfVnfId\", genericVnf.getVnfId());\n aaiInfo.put(\"genericVnfOrchestrationStatus\",\n genericVnf.getVfModules().getVfModule().get(0).getOrchestrationStatus());\n\n executor.outFields.put(\"requestID\", executor.inFields.get(\"requestID\"));\n executor.outFields.put(\"vnfID\", executor.inFields.get(\"vnfID\"));\n\n executor.logger.info(executor.outFields);\n}\n\nreturnValue;"
+ }
+ }
+ },
+ {
+ "key": {
+ "name": "APPCRestartVNFRequestTask",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "APPCRestartVNFRequestTask",
+ "version": "0.0.1"
+ },
+ "inputEvent": {
+ "key": {
+ "name": "VCPEStateUpdatedEvent",
+ "version": "0.0.1"
+ },
+ "nameSpace": "org.onap.policy.apex.onap.vcpe",
+ "source": "APEX",
+ "target": "APEX",
+ "parameter": {
+ "entry": [
+ {
+ "key": "requestID",
+ "value": {
+ "key": "requestID",
+ "fieldSchemaKey": {
+ "name": "UUIDType",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "vnfID",
+ "value": {
+ "key": "vnfID",
+ "fieldSchemaKey": {
+ "name": "UUIDType",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "vnfName",
+ "value": {
+ "key": "vnfName",
+ "fieldSchemaKey": {
+ "name": "SimpleStringType",
+ "version": "0.0.1"
+ },
+ "optional": true
+ }
+ }
+ ]
+ },
+ "toscaPolicyState": ""
+ },
+ "outputEvents": {
+ "entry": [
+ {
+ "key": "APPCRestartVNFRequestEvent",
+ "value": {
+ "key": {
+ "name": "APPCRestartVNFRequestEvent",
+ "version": "2.0.0"
+ },
+ "nameSpace": "org.onap.policy.apex.onap.vcpe",
+ "source": "APEX",
+ "target": "APPC",
+ "parameter": {
+ "entry": [
+ {
+ "key": "APPCLCMRequestEvent",
+ "value": {
+ "key": "APPCLCMRequestEvent",
+ "fieldSchemaKey": {
+ "name": "APPCLCMRequestType",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ }
+ ]
+ },
+ "toscaPolicyState": ""
+ }
+ }
+ ]
+ },
+ "taskParameters": {
+ "entry": []
+ },
+ "contextAlbumReference": [
+ {
+ "name": "RequestIDVNFIDAlbum",
+ "version": "0.0.1"
+ },
+ {
+ "name": "VCPEClosedLoopStatusAlbum",
+ "version": "0.0.1"
+ }
+ ],
+ "taskLogic": {
+ "key": "TaskLogic",
+ "logicFlavour": "JAVASCRIPT",
+ "logic": "/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2016-2018 Ericsson. All rights reserved.\n * Modifications Copyright (C) 2020 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(executor.subject.id);\nexecutor.logger.info(executor.inFields);\n\nvar appcRequest = new org.onap.policy.appclcm.AppcLcmDmaapWrapper;\nappcRequest.setBody(new org.onap.policy.appclcm.AppcLcmBody);\nappcRequest.getBody().setInput(new org.onap.policy.appclcm.AppcLcmInput);\nappcRequest.getBody().getInput().setCommonHeader(\n new org.onap.policy.appclcm.AppcLcmCommonHeader);\n\nappcRequest.setVersion(\"2.0.0\");\nappcRequest.setRpcName(\"restart\");\nappcRequest.setCorrelationId(executor.inFields.get(\"requestID\"));\nappcRequest.setType(\"request\");\n\nvar vcpeClosedLoopStatus = executor\n .getContextAlbum(\"VCPEClosedLoopStatusAlbum\").get(\n executor.inFields.get(\"vnfID\").toString());\n\nappcRequest.getBody().getInput().getCommonHeader().setTimeStamp(java.time.Instant.now());\nappcRequest.getBody().getInput().getCommonHeader().setApiVer(\"2.00\");\nappcRequest.getBody().getInput().getCommonHeader().setOriginatorId(\n executor.inFields.get(\"requestID\").toString());\nappcRequest.getBody().getInput().getCommonHeader().setRequestId(\n executor.inFields.get(\"requestID\"));\nappcRequest.getBody().getInput().getCommonHeader().setSubRequestId(\"1\");\nappcRequest.getBody().getInput().getCommonHeader().getFlags().put(\"ttl\", \"10000\");\nappcRequest.getBody().getInput().getCommonHeader().getFlags().put(\"force\", \"TRUE\");\nappcRequest.getBody().getInput().getCommonHeader().getFlags().put(\"mode\", \"EXCLUSIVE\");\n\nappcRequest.getBody().getInput().setAction(\"Restart\");\nappcRequest.getBody().getInput().setActionIdentifiers(new java.util.HashMap());\nappcRequest.getBody().getInput().getActionIdentifiers().put(\"vnf-id\",\n executor.inFields.get(\"vnfID\").toString());\n\nexecutor.getContextAlbum(\"RequestIDVNFIDAlbum\").put(\n executor.inFields.get(\"requestID\").toString(),\n executor.inFields.get(\"vnfID\"));\n\nvcpeClosedLoopStatus.put(\"notification\", \"OPERATION\");\nvcpeClosedLoopStatus.put(\"notificationTime\", java.lang.System\n .currentTimeMillis());\n\nexecutor.outFields.put(\"APPCLCMRequestEvent\", appcRequest);\n\nexecutor.logger.info(executor.outFields);\n\ntrue;"
+ }
+ }
+ },
+ {
+ "key": {
+ "name": "APPCRestartVNFResponseTask",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "APPCRestartVNFResponseTask",
+ "version": "0.0.1"
+ },
+ "inputEvent": {
+ "key": {
+ "name": "APPCRestartVNFResponseEvent",
+ "version": "2.0.0"
+ },
+ "nameSpace": "org.onap.policy.apex.onap.vcpe",
+ "source": "APEX",
+ "target": "APPC",
+ "parameter": {
+ "entry": [
+ {
+ "key": "APPCLCMResponseEvent",
+ "value": {
+ "key": "APPCLCMResponseEvent",
+ "fieldSchemaKey": {
+ "name": "APPCLCMResponseType",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ }
+ ]
+ },
+ "toscaPolicyState": ""
+ },
+ "outputEvents": {
+ "entry": [
+ {
+ "key": "VCPEStateUpdatedEvent",
+ "value": {
+ "key": {
+ "name": "VCPEStateUpdatedEvent",
+ "version": "0.0.1"
+ },
+ "nameSpace": "org.onap.policy.apex.onap.vcpe",
+ "source": "APEX",
+ "target": "APEX",
+ "parameter": {
+ "entry": [
+ {
+ "key": "requestID",
+ "value": {
+ "key": "requestID",
+ "fieldSchemaKey": {
+ "name": "UUIDType",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "vnfID",
+ "value": {
+ "key": "vnfID",
+ "fieldSchemaKey": {
+ "name": "UUIDType",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "vnfName",
+ "value": {
+ "key": "vnfName",
+ "fieldSchemaKey": {
+ "name": "SimpleStringType",
+ "version": "0.0.1"
+ },
+ "optional": true
+ }
+ }
+ ]
+ },
+ "toscaPolicyState": ""
+ }
+ }
+ ]
+ },
+ "taskParameters": {
+ "entry": []
+ },
+ "contextAlbumReference": [
+ {
+ "name": "RequestIDVNFIDAlbum",
+ "version": "0.0.1"
+ },
+ {
+ "name": "VCPEClosedLoopStatusAlbum",
+ "version": "0.0.1"
+ }
+ ],
+ "taskLogic": {
+ "key": "TaskLogic",
+ "logicFlavour": "JAVASCRIPT",
+ "logic": "/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2016-2018 Ericsson. All rights reserved.\n * Modifications Copyright (C) 2020 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * APPC LCM Response code: 100 ACCEPTED\n * 200 ERROR UNEXPECTED ERROR means failure\n * 312 REJECTED DUPLICATE REQUEST\n * 400 SUCCESS\n *\n * Note: Sometimes the corelationId has a -1 at the tail, need to get rid of it when present.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(executor.subject.id);\nexecutor.logger.info(executor.inFields);\n\nvar appcResponse = executor.inFields.get(\"APPCLCMResponseEvent\");\n\nvar requestIDString = appcResponse.getCorrelationId().substr(0, 36);\nexecutor.logger.info(\"requestIDString = \" + requestIDString);\nvar vnfID = executor.getContextAlbum(\"RequestIDVNFIDAlbum\")\n .get(requestIDString);\nexecutor.logger.info(\"Size of RequestIDVNFIDAlbum = \"\n + executor.getContextAlbum(\"RequestIDVNFIDAlbum\").size());\nexecutor.logger.info(\"vnfID = \" + vnfID);\n\nvar returnValue = true;\n\nif (vnfID != null) {\n var vcpeClosedLoopStatus = executor.getContextAlbum(\n \"VCPEClosedLoopStatusAlbum\").get(vnfID.toString());\n var requestId = java.util.UUID.fromString(vcpeClosedLoopStatus\n .get(\"requestID\"));\n\n vcpeClosedLoopStatus.put(\"notificationTime\", java.lang.System\n .currentTimeMillis());\n\n executor.logger.info(\"Got from APPC code: \"\n + org.onap.policy.appclcm.AppcLcmResponseCode\n .toResponseValue(appcResponse.getBody().getOutput()\n .getStatus().getCode()));\n\n if (org.onap.policy.appclcm.AppcLcmResponseCode\n .toResponseValue(appcResponse.getBody().getOutput().getStatus()\n .getCode()) == org.onap.policy.appclcm.AppcLcmResponseCode.SUCCESS) {\n vcpeClosedLoopStatus.put(\"notification\", \"OPERATION_SUCCESS\");\n vcpeClosedLoopStatus.put(\"message\", \"vCPE restarted\");\n executor.getContextAlbum(\"RequestIDVNFIDAlbum\").remove(requestIDString);\n } else if (org.onap.policy.appclcm.AppcLcmResponseCode\n .toResponseValue(appcResponse.getBody().getOutput().getStatus()\n .getCode()) == \"ACCEPTED\"\n || org.onap.policy.appclcm.AppcLcmResponseCode\n .toResponseValue(appcResponse.getBody().getOutput()\n .getStatus().getCode()) == \"REJECT\") {\n executor.logger\n .info(\"Got ACCEPTED 100 or REJECT 312, keep the context, wait for next response. Code is: \"\n + org.onap.policy.appclcm.AppcLcmResponseCode\n .toResponseValue(appcResponse.getBody()\n .getOutput().getStatus().getCode()));\n } else {\n executor.getContextAlbum(\"RequestIDVNFIDAlbum\").remove(requestIDString);\n vcpeClosedLoopStatus.put(\"notification\", \"OPERATION_FAILURE\");\n vcpeClosedLoopStatus.put(\"message\", \"vCPE restart failed\");\n }\n\n executor.outFields.put(\"requestID\", requestId);\n executor.outFields.put(\"vnfID\", vnfID);\n} else {\n executor.message = \"VNF ID not found in context album for request ID \"\n + requestIDString;\n returnValue = false\n}\n\nexecutor.logger.info(executor.outFields);\n\nreturnValue;"
+ }
+ }
+ },
+ {
+ "key": {
+ "name": "AbatedTask",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "AbatedTask",
+ "version": "0.0.1"
+ },
+ "inputEvent": {
+ "key": {
+ "name": "VCPEStateUpdatedEvent",
+ "version": "0.0.1"
+ },
+ "nameSpace": "org.onap.policy.apex.onap.vcpe",
+ "source": "APEX",
+ "target": "APEX",
+ "parameter": {
+ "entry": [
+ {
+ "key": "requestID",
+ "value": {
+ "key": "requestID",
+ "fieldSchemaKey": {
+ "name": "UUIDType",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "vnfID",
+ "value": {
+ "key": "vnfID",
+ "fieldSchemaKey": {
+ "name": "UUIDType",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "vnfName",
+ "value": {
+ "key": "vnfName",
+ "fieldSchemaKey": {
+ "name": "SimpleStringType",
+ "version": "0.0.1"
+ },
+ "optional": true
+ }
+ }
+ ]
+ },
+ "toscaPolicyState": ""
+ },
+ "outputEvents": {
+ "entry": [
+ {
+ "key": "VCPEStateUpdatedEvent",
+ "value": {
+ "key": {
+ "name": "VCPEStateUpdatedEvent",
+ "version": "0.0.1"
+ },
+ "nameSpace": "org.onap.policy.apex.onap.vcpe",
+ "source": "APEX",
+ "target": "APEX",
+ "parameter": {
+ "entry": [
+ {
+ "key": "requestID",
+ "value": {
+ "key": "requestID",
+ "fieldSchemaKey": {
+ "name": "UUIDType",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "vnfID",
+ "value": {
+ "key": "vnfID",
+ "fieldSchemaKey": {
+ "name": "UUIDType",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "vnfName",
+ "value": {
+ "key": "vnfName",
+ "fieldSchemaKey": {
+ "name": "SimpleStringType",
+ "version": "0.0.1"
+ },
+ "optional": true
+ }
+ }
+ ]
+ },
+ "toscaPolicyState": ""
+ }
+ }
+ ]
+ },
+ "taskParameters": {
+ "entry": []
+ },
+ "contextAlbumReference": [
+ {
+ "name": "VCPEClosedLoopStatusAlbum",
+ "version": "0.0.1"
+ }
+ ],
+ "taskLogic": {
+ "key": "TaskLogic",
+ "logicFlavour": "JAVASCRIPT",
+ "logic": "/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2016-2018 Ericsson. All rights reserved.\n * Modifications Copyright (C) 2020 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(executor.subject.id);\nexecutor.logger.info(executor.inFields);\n\nvar vcpeClosedLoopStatus = null;\nif( executor.inFields.get(\"vnfID\") == null) {\n executor.logger.info(\"AbatedTask: vnfID is null\");\n var vnfName = executor.inFields.get(\"vnfName\");\n vcpeClosedLoopStatus = executor.getContextAlbum(\"VCPEClosedLoopStatusAlbum\").get(\n executor.inFields.get(\"vnfName\"));\n} else {\n vcpeClosedLoopStatus = executor.getContextAlbum(\"VCPEClosedLoopStatusAlbum\").get(\n executor.inFields.get(\"vnfID\").toString());\n}\n\nvcpeClosedLoopStatus.put(\"notification\", \"FINAL_SUCCESS\");\nvcpeClosedLoopStatus.put(\"notificationTime\", java.lang.System.currentTimeMillis());\nvcpeClosedLoopStatus.put(\"message\", \"situation has been abated\");\n\nexecutor.logger.info(executor.outFields);\n\ntrue;"
+ }
+ }
+ },
+ {
+ "key": {
+ "name": "ControlLoopLogTask",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "ControlLoopLogTask",
+ "version": "0.0.1"
+ },
+ "inputEvent": {
+ "key": {
+ "name": "VCPEStateUpdatedEvent",
+ "version": "0.0.1"
+ },
+ "nameSpace": "org.onap.policy.apex.onap.vcpe",
+ "source": "APEX",
+ "target": "APEX",
+ "parameter": {
+ "entry": [
+ {
+ "key": "requestID",
+ "value": {
+ "key": "requestID",
+ "fieldSchemaKey": {
+ "name": "UUIDType",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "vnfID",
+ "value": {
+ "key": "vnfID",
+ "fieldSchemaKey": {
+ "name": "UUIDType",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "vnfName",
+ "value": {
+ "key": "vnfName",
+ "fieldSchemaKey": {
+ "name": "SimpleStringType",
+ "version": "0.0.1"
+ },
+ "optional": true
+ }
+ }
+ ]
+ },
+ "toscaPolicyState": ""
+ },
+ "outputEvents": {
+ "entry": [
+ {
+ "key": "ControlLoopLogEvent",
+ "value": {
+ "key": {
+ "name": "ControlLoopLogEvent",
+ "version": "0.0.1"
+ },
+ "nameSpace": "org.onap.policy.apex.onap.vcpe",
+ "source": "APEX",
+ "target": "APEX",
+ "parameter": {
+ "entry": [
+ {
+ "key": "VirtualControlLoopNotification",
+ "value": {
+ "key": "VirtualControlLoopNotification",
+ "fieldSchemaKey": {
+ "name": "VirtualControlLoopNotificationType",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ }
+ ]
+ },
+ "toscaPolicyState": ""
+ }
+ }
+ ]
+ },
+ "taskParameters": {
+ "entry": []
+ },
+ "contextAlbumReference": [
+ {
+ "name": "VCPEClosedLoopStatusAlbum",
+ "version": "0.0.1"
+ }
+ ],
+ "taskLogic": {
+ "key": "TaskLogic",
+ "logicFlavour": "JAVASCRIPT",
+ "logic": "/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2016-2018 Ericsson. All rights reserved.\n * Modifications Copyright (C) 2020 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(executor.subject.id);\nexecutor.logger.info(executor.inFields);\n\nvar vnfID = executor.inFields.get(\"vnfID\");\nif(vnfID == null) {\n vnfID = executor.inFields.get(\"vnfName\");\n}\nexecutor.logger.info(\"vnfID=\" + vnfID);\n\nvar vcpeClosedLoopStatus = executor.getContextAlbum(\"VCPEClosedLoopStatusAlbum\").get(vnfID.toString());\n\nexecutor.logger.info(\"Logging context information for VNF \\\"\" + vnfID + \"\\\"\");\n\nvar clNotification = new org.onap.policy.controlloop.VirtualControlLoopNotification();\n\nclNotification.setClosedLoopControlName(vcpeClosedLoopStatus.get(\"closedLoopControlName\"));\nclNotification.setClosedLoopAlarmStart(java.time.Instant.ofEpochMilli(vcpeClosedLoopStatus.get(\"closedLoopAlarmStart\")));\nclNotification.setClosedLoopAlarmEnd(java.time.Instant.ofEpochMilli(vcpeClosedLoopStatus.get(\"closedLoopAlarmEnd\")));\nclNotification.setClosedLoopEventClient(vcpeClosedLoopStatus.get(\"closedLoopEventClient\"));\nclNotification.setVersion(vcpeClosedLoopStatus.get(\"version\"));\nclNotification.setRequestId(java.util.UUID.fromString(vcpeClosedLoopStatus.get(\"requestID\")));\nclNotification.setTargetType(vcpeClosedLoopStatus.get(\"target_type\"));\nclNotification.setTarget(vcpeClosedLoopStatus.get(\"target\"));\nclNotification.setFrom(vcpeClosedLoopStatus.get(\"from\"));\nclNotification.setPolicyScope(vcpeClosedLoopStatus.get(\"policyScope\"));\nclNotification.setPolicyName(vcpeClosedLoopStatus.get(\"policyName\"));\nclNotification.setPolicyVersion(vcpeClosedLoopStatus.get(\"policyVersion\"));\nclNotification.setNotification(org.onap.policy.controlloop.ControlLoopNotificationType.toType(vcpeClosedLoopStatus.get(\"notification\")));\nclNotification.setMessage(vcpeClosedLoopStatus.get(\"message\"));\n\nvar notificationInstant = java.time.Instant.ofEpochSecond(vcpeClosedLoopStatus.get(\"notificationTime\"));\nvar notificationTime = java.time.ZonedDateTime.ofInstant(notificationInstant, java.time.ZoneOffset.UTC);\nclNotification.setNotificationTime(notificationTime);\n\nvar aaiInfo = vcpeClosedLoopStatus.get(\"AAI\");\n\nclNotification.getAai().put(\"generic-vnf.resource-version\", aaiInfo.get(\"genericVnfResourceVersion\"));\nclNotification.getAai().put(\"generic-vnf.vnf-name\", aaiInfo.get(\"genericVnfVnfName\"));\nclNotification.getAai().put(\"generic-vnf.prov-status\", aaiInfo.get(\"genericVnfProvStatus\"));\nclNotification.getAai().put(\"generic-vnf.is-closed-loop-disabled\", aaiInfo.get(\"genericVnfIsClosedLoopDisabled\"));\nclNotification.getAai().put(\"generic-vnf.orchestration-status\", aaiInfo.get(\"genericVnfOrchestrationStatus\"));\nclNotification.getAai().put(\"generic-vnf.vnf-type\", aaiInfo.get(\"genericVnfVnfType\"));\nclNotification.getAai().put(\"generic-vnf.in-maint\", aaiInfo.get(\"genericVnfInMaint\"));\nclNotification.getAai().put(\"generic-vnf.service-id\", aaiInfo.get(\"genericVnfServiceId\"));\n\nif(vnfID != null) {\n clNotification.getAai().put(\"generic-vnf.vnf-id\", aaiInfo.get(\"genericVnfVnfId\"));\n}\nexecutor.outFields.put(\"VirtualControlLoopNotification\", clNotification);\n\nexecutor.logger.info(executor.outFields);\n\ntrue;"
+ }
+ }
+ },
+ {
+ "key": {
+ "name": "DeniedTask",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "DeniedTask",
+ "version": "0.0.1"
+ },
+ "inputEvent": {
+ "key": {
+ "name": "VCPEStateUpdatedEvent",
+ "version": "0.0.1"
+ },
+ "nameSpace": "org.onap.policy.apex.onap.vcpe",
+ "source": "APEX",
+ "target": "APEX",
+ "parameter": {
+ "entry": [
+ {
+ "key": "requestID",
+ "value": {
+ "key": "requestID",
+ "fieldSchemaKey": {
+ "name": "UUIDType",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "vnfID",
+ "value": {
+ "key": "vnfID",
+ "fieldSchemaKey": {
+ "name": "UUIDType",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "vnfName",
+ "value": {
+ "key": "vnfName",
+ "fieldSchemaKey": {
+ "name": "SimpleStringType",
+ "version": "0.0.1"
+ },
+ "optional": true
+ }
+ }
+ ]
+ },
+ "toscaPolicyState": ""
+ },
+ "outputEvents": {
+ "entry": [
+ {
+ "key": "VCPEStateUpdatedEvent",
+ "value": {
+ "key": {
+ "name": "VCPEStateUpdatedEvent",
+ "version": "0.0.1"
+ },
+ "nameSpace": "org.onap.policy.apex.onap.vcpe",
+ "source": "APEX",
+ "target": "APEX",
+ "parameter": {
+ "entry": [
+ {
+ "key": "requestID",
+ "value": {
+ "key": "requestID",
+ "fieldSchemaKey": {
+ "name": "UUIDType",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "vnfID",
+ "value": {
+ "key": "vnfID",
+ "fieldSchemaKey": {
+ "name": "UUIDType",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "vnfName",
+ "value": {
+ "key": "vnfName",
+ "fieldSchemaKey": {
+ "name": "SimpleStringType",
+ "version": "0.0.1"
+ },
+ "optional": true
+ }
+ }
+ ]
+ },
+ "toscaPolicyState": ""
+ }
+ }
+ ]
+ },
+ "taskParameters": {
+ "entry": []
+ },
+ "contextAlbumReference": [
+ {
+ "name": "VCPEClosedLoopStatusAlbum",
+ "version": "0.0.1"
+ }
+ ],
+ "taskLogic": {
+ "key": "TaskLogic",
+ "logicFlavour": "JAVASCRIPT",
+ "logic": "/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2016-2018 Ericsson. All rights reserved.\n * Modifications Copyright (C) 2020 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(executor.subject.id);\nexecutor.logger.info(executor.inFields);\n\nvar vcpeClosedLoopStatus = executor.getContextAlbum(\"VCPEClosedLoopStatusAlbum\").get(\n executor.inFields.get(\"vnfID\").toString());\n\nvcpeClosedLoopStatus.put(\"notification\", \"REJECTED\");\nvcpeClosedLoopStatus.put(\"notificationTime\", java.lang.System.currentTimeMillis());\n\nexecutor.logger.info(executor.outFields);\n\ntrue;"
+ }
+ }
+ },
+ {
+ "key": {
+ "name": "GetVCPEStateTask",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "GetVCPEStateTask",
+ "version": "0.0.1"
+ },
+ "inputEvent": {
+ "key": {
+ "name": "ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e",
+ "version": "1.0.2"
+ },
+ "nameSpace": "org.onap.policy.apex.onap.vcpe",
+ "source": "DCAE",
+ "target": "APEX",
+ "parameter": {
+ "entry": [
+ {
+ "key": "VirtualControlLoopEvent",
+ "value": {
+ "key": "VirtualControlLoopEvent",
+ "fieldSchemaKey": {
+ "name": "VirtualControlLoopEventType",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ }
+ ]
+ },
+ "toscaPolicyState": ""
+ },
+ "outputEvents": {
+ "entry": [
+ {
+ "key": "VCPEStateUpdatedEvent",
+ "value": {
+ "key": {
+ "name": "VCPEStateUpdatedEvent",
+ "version": "0.0.1"
+ },
+ "nameSpace": "org.onap.policy.apex.onap.vcpe",
+ "source": "APEX",
+ "target": "APEX",
+ "parameter": {
+ "entry": [
+ {
+ "key": "requestID",
+ "value": {
+ "key": "requestID",
+ "fieldSchemaKey": {
+ "name": "UUIDType",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "vnfID",
+ "value": {
+ "key": "vnfID",
+ "fieldSchemaKey": {
+ "name": "UUIDType",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "vnfName",
+ "value": {
+ "key": "vnfName",
+ "fieldSchemaKey": {
+ "name": "SimpleStringType",
+ "version": "0.0.1"
+ },
+ "optional": true
+ }
+ }
+ ]
+ },
+ "toscaPolicyState": ""
+ }
+ }
+ ]
+ },
+ "taskParameters": {
+ "entry": []
+ },
+ "contextAlbumReference": [
+ {
+ "name": "RequestIDVNFIDAlbum",
+ "version": "0.0.1"
+ },
+ {
+ "name": "VCPEClosedLoopStatusAlbum",
+ "version": "0.0.1"
+ }
+ ],
+ "taskLogic": {
+ "key": "TaskLogic",
+ "logicFlavour": "JAVASCRIPT",
+ "logic": "/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2016-2018 Ericsson. All rights reserved.\n * Modifications Copyright (C) 2020 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * Note: The incoming closedloop message can be ONSET with both VNF-name and VNF-ID\n * or ABATED with only VNF-name. So need to handle differently. For ABATED case,\n * since we still keep the RequireIDVNFID context album, we can get it from there.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(executor.subject.id);\nexecutor.logger.info(executor.inFields);\n\nvar clEventType = org.onap.policy.controlloop.VirtualControlLoopEvent;\nvar longType = java.lang.Long;\nvar uuidType = java.util.UUID;\n\nvar clEvent = executor.inFields.get(\"VirtualControlLoopEvent\");\n\nexecutor.logger.info(clEvent.toString());\nexecutor.logger.info(clEvent.getClosedLoopControlName());\n\nvar requestID = clEvent.getRequestId();\nexecutor.logger.info(\"requestID = \" + requestID);\nvar vnfID = null;\nvar vcpeClosedLoopStatus = null;\n\nif (clEvent.getAai().get(\"generic-vnf.vnf-id\") != null) {\n vnfID = uuidType.fromString(clEvent.getAai().get(\"generic-vnf.vnf-id\"));\n executor.logger.info(\"vnfID = \" + vnfID);\n vcpeClosedLoopStatus = executor.getContextAlbum(\"VCPEClosedLoopStatusAlbum\").get(vnfID);\n\n if (vcpeClosedLoopStatus == null) {\n executor.logger.info(\"Creating context information for new vCPE VNF \\\"\" + vnfID.toString() + \"\\\"\");\n\n vcpeClosedLoopStatus = executor.getContextAlbum(\"VCPEClosedLoopStatusAlbum\").getSchemaHelper().createNewInstance();\n\n vcpeClosedLoopStatus.put(\"closedLoopControlName\", clEvent.getClosedLoopControlName());\n vcpeClosedLoopStatus.put(\"closedLoopAlarmStart\", clEvent.getClosedLoopAlarmStart().toEpochMilli());\n vcpeClosedLoopStatus.put(\"closedLoopEventClient\", clEvent.getClosedLoopEventClient());\n vcpeClosedLoopStatus.put(\"closedLoopEventStatus\", clEvent.getClosedLoopEventStatus().toString());\n vcpeClosedLoopStatus.put(\"version\", clEvent.getVersion());\n vcpeClosedLoopStatus.put(\"requestID\", clEvent.getRequestId().toString());\n vcpeClosedLoopStatus.put(\"target_type\", clEvent.getTargetType().toString());\n vcpeClosedLoopStatus.put(\"target\", clEvent.getTarget());\n vcpeClosedLoopStatus.put(\"from\", clEvent.getFrom());\n vcpeClosedLoopStatus.put(\"policyScope\", \"vCPE\");\n vcpeClosedLoopStatus.put(\"policyName\", \"ONAPvCPEPolicyModel\");\n vcpeClosedLoopStatus.put(\"policyVersion\", \"0.0.1\");\n vcpeClosedLoopStatus.put(\"notification\", \"ACTIVE\");\n vcpeClosedLoopStatus.put(\"notificationTime\", java.lang.System.currentTimeMillis());\n vcpeClosedLoopStatus.put(\"message\", \"\");\n\n var aaiInfo = executor.getContextAlbum(\"VCPEClosedLoopStatusAlbum\").getSchemaHelper().createNewSubInstance(\"VCPE_AAI_Type\");\n\n aaiInfo.put(\"genericVnfResourceVersion\", clEvent.getAai().get(\"generic-vnf.resource-version\"));\n aaiInfo.put(\"genericVnfVnfName\", clEvent.getAai().get(\"generic-vnf.vnf-name\"));\n aaiInfo.put(\"genericVnfProvStatus\", clEvent.getAai().get(\"generic-vnf.prov-status\"));\n aaiInfo.put(\"genericVnfIsClosedLoopDisabled\", clEvent.getAai().get(\"generic-vnf.is-closed-loop-disabled\"));\n aaiInfo.put(\"genericVnfOrchestrationStatus\", clEvent.getAai().get(\"generic-vnf.orchestration-status\"));\n aaiInfo.put(\"genericVnfVnfType\", clEvent.getAai().get(\"generic-vnf.vnf-type\"));\n aaiInfo.put(\"genericVnfInMaint\", clEvent.getAai().get(\"generic-vnf.in-maint\"));\n aaiInfo.put(\"genericVnfServiceId\", clEvent.getAai().get(\"generic-vnf.service-id\"));\n aaiInfo.put(\"genericVnfVnfId\", clEvent.getAai().get(\"generic-vnf.vnf-id\"));\n aaiInfo.put(\"vserverIsClosedLoopDisabled\", clEvent.getAai().get(\"vserver.is-closed-loop-disabled\"));\n aaiInfo.put(\"vserverProvStatus\", clEvent.getAai().get(\"vserver.prov-status\"));\n aaiInfo.put(\"vserverName\", clEvent.getAai().get(\"vserver.vserver-name\"));\n\n vcpeClosedLoopStatus.put(\"AAI\", aaiInfo);\n\n if (clEvent.getClosedLoopAlarmEnd() != null) {\n vcpeClosedLoopStatus.put(\"closedLoopAlarmEnd\", clEvent.getClosedLoopAlarmEnd().toEpochMilli());\n } else {\n vcpeClosedLoopStatus.put(\"closedLoopAlarmEnd\", java.lang.Long.valueOf(0));\n }\n\n executor.getContextAlbum(\"VCPEClosedLoopStatusAlbum\").put(vnfID.toString(), vcpeClosedLoopStatus);\n\n executor.logger.info(\"Created context information for new vCPE VNF \\\"\" + vnfID.toString() + \"\\\"\");\n }\n\n executor.outFields.put(\"requestID\", requestID);\n executor.outFields.put(\"vnfID\", vnfID);\n\n executor.logger.info(executor.outFields);\n}\nelse {\n executor.logger.info(\"No vnf-id in VirtualControlLoopEvent, status:\" + clEvent.getClosedLoopEventStatus().toString());\n var vnfName = clEvent.getAai().get(\"generic-vnf.vnf-name\");\n executor.logger.info(\"No vnf-id in VirtualControlLoopEvent for \" + vnfName);\n\n vcpeClosedLoopStatus = executor.getContextAlbum(\"VCPEClosedLoopStatusAlbum\").get(vnfName.toString());\n\n if (vcpeClosedLoopStatus == null) {\n executor.logger.info(\"Creating context information for new vCPE VNF \\\"\" + vnfName.toString() + \"\\\"\");\n\n vcpeClosedLoopStatus = executor.getContextAlbum(\"VCPEClosedLoopStatusAlbum\").getSchemaHelper().createNewInstance();\n\n vcpeClosedLoopStatus.put(\"closedLoopControlName\", clEvent.getClosedLoopControlName());\n vcpeClosedLoopStatus.put(\"closedLoopAlarmStart\", clEvent.getClosedLoopAlarmStart().toEpochMilli());\n vcpeClosedLoopStatus.put(\"closedLoopEventClient\", clEvent.getClosedLoopEventClient());\n vcpeClosedLoopStatus.put(\"closedLoopEventStatus\", clEvent.getClosedLoopEventStatus().toString());\n vcpeClosedLoopStatus.put(\"version\", clEvent.getVersion());\n vcpeClosedLoopStatus.put(\"requestID\", clEvent.getRequestId().toString());\n vcpeClosedLoopStatus.put(\"target_type\", clEvent.getTargetType().toString());\n vcpeClosedLoopStatus.put(\"target\", clEvent.getTarget());\n vcpeClosedLoopStatus.put(\"from\", clEvent.getFrom());\n vcpeClosedLoopStatus.put(\"policyScope\", \"vCPE\");\n vcpeClosedLoopStatus.put(\"policyName\", \"ONAPvCPEPolicyModel\");\n vcpeClosedLoopStatus.put(\"policyVersion\", \"0.0.1\");\n vcpeClosedLoopStatus.put(\"notification\", \"ACTIVE\");\n vcpeClosedLoopStatus.put(\"notificationTime\", java.lang.System.currentTimeMillis());\n vcpeClosedLoopStatus.put(\"message\", \"\");\n\n var aaiInfo = executor.getContextAlbum(\"VCPEClosedLoopStatusAlbum\").getSchemaHelper().createNewSubInstance(\"VCPE_AAI_Type\");\n\n aaiInfo.put(\"genericVnfVnfName\", clEvent.getAai().get(\"generic-vnf.vnf-name\"));\n vcpeClosedLoopStatus.put(\"AAI\", aaiInfo);\n\n if (clEvent.getClosedLoopAlarmEnd() != null) {\n vcpeClosedLoopStatus.put(\"closedLoopAlarmEnd\", clEvent.getClosedLoopAlarmEnd().toEpochMilli());\n } else {\n vcpeClosedLoopStatus.put(\"closedLoopAlarmEnd\", java.lang.Long.valueOf(0));\n }\n\n executor.getContextAlbum(\"VCPEClosedLoopStatusAlbum\").put(vnfName.toString(), vcpeClosedLoopStatus);\n\n executor.logger.info(\"Created context information for new vCPE VNF \\\"\" + vnfName.toString() + \"\\\"\");\n }\n executor.outFields.put(\"requestID\", requestID);\n executor.outFields.put(\"vnfName\", vnfName);\n executor.logger.info(executor.outFields);\n}\n\ntrue;"
+ }
+ }
+ },
+ {
+ "key": {
+ "name": "GuardRequestTask",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "GuardRequestTask",
+ "version": "0.0.1"
+ },
+ "inputEvent": {
+ "key": {
+ "name": "VCPEStateUpdatedEvent",
+ "version": "0.0.1"
+ },
+ "nameSpace": "org.onap.policy.apex.onap.vcpe",
+ "source": "APEX",
+ "target": "APEX",
+ "parameter": {
+ "entry": [
+ {
+ "key": "requestID",
+ "value": {
+ "key": "requestID",
+ "fieldSchemaKey": {
+ "name": "UUIDType",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "vnfID",
+ "value": {
+ "key": "vnfID",
+ "fieldSchemaKey": {
+ "name": "UUIDType",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "vnfName",
+ "value": {
+ "key": "vnfName",
+ "fieldSchemaKey": {
+ "name": "SimpleStringType",
+ "version": "0.0.1"
+ },
+ "optional": true
+ }
+ }
+ ]
+ },
+ "toscaPolicyState": ""
+ },
+ "outputEvents": {
+ "entry": [
+ {
+ "key": "GuardRequestEvent",
+ "value": {
+ "key": {
+ "name": "GuardRequestEvent",
+ "version": "0.0.1"
+ },
+ "nameSpace": "org.onap.policy.apex.onap.vcpe",
+ "source": "APEX",
+ "target": "APEX",
+ "parameter": {
+ "entry": [
+ {
+ "key": "decisionAttributes",
+ "value": {
+ "key": "decisionAttributes",
+ "fieldSchemaKey": {
+ "name": "GuardDecisionAttributesType",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "onapName",
+ "value": {
+ "key": "onapName",
+ "fieldSchemaKey": {
+ "name": "SimpleStringType",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ }
+ ]
+ },
+ "toscaPolicyState": ""
+ }
+ }
+ ]
+ },
+ "taskParameters": {
+ "entry": []
+ },
+ "contextAlbumReference": [
+ {
+ "name": "ControlLoopExecutionIDAlbum",
+ "version": "0.0.1"
+ },
+ {
+ "name": "VCPEClosedLoopStatusAlbum",
+ "version": "0.0.1"
+ }
+ ],
+ "taskLogic": {
+ "key": "TaskLogic",
+ "logicFlavour": "JAVASCRIPT",
+ "logic": "/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2016-2018 Ericsson. All rights reserved.\n * Modifications Copyright (C) 2020 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(executor.subject.id);\nexecutor.logger.info(executor.inFields);\n\nvar vcpeClosedLoopStatus = executor.getContextAlbum(\"VCPEClosedLoopStatusAlbum\").get(\n executor.inFields.get(\"vnfID\").toString());\n\nvar guardDecisionAttributes = executor.subject.getOutFieldSchemaHelper(\"decisionAttributes\").createNewInstance();\n\nguardDecisionAttributes.put(\"actor\", \"APPC\");\nguardDecisionAttributes.put(\"recipe\", \"Restart\");\nguardDecisionAttributes.put(\"target\", executor.inFields.get(\"vnfID\").toString());\nguardDecisionAttributes.put(\"clname\", \"APEXvCPEImplementation\");\n\nexecutor.logger.info(guardDecisionAttributes);\n\nexecutor.outFields.put(\"decisionAttributes\", guardDecisionAttributes);\nexecutor.outFields.put(\"onapName\", \"PDPD\");\n\nexecutor.getContextAlbum(\"ControlLoopExecutionIDAlbum\").put(executor.executionId.toString(),\n executor.inFields.get(\"vnfID\"));\n\nexecutor.logger.info(executor.outFields);\n\ntrue;"
+ }
+ }
+ },
+ {
+ "key": {
+ "name": "GuardResponseTask",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "GuardResponseTask",
+ "version": "0.0.1"
+ },
+ "inputEvent": {
+ "key": {
+ "name": "GuardResponseEvent",
+ "version": "0.0.1"
+ },
+ "nameSpace": "org.onap.policy.apex.onap.vcpe",
+ "source": "APEX",
+ "target": "APEX",
+ "parameter": {
+ "entry": [
+ {
+ "key": "decision",
+ "value": {
+ "key": "decision",
+ "fieldSchemaKey": {
+ "name": "SimpleStringType",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "details",
+ "value": {
+ "key": "details",
+ "fieldSchemaKey": {
+ "name": "SimpleStringType",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ }
+ ]
+ },
+ "toscaPolicyState": ""
+ },
+ "outputEvents": {
+ "entry": [
+ {
+ "key": "VCPEStateUpdatedEvent",
+ "value": {
+ "key": {
+ "name": "VCPEStateUpdatedEvent",
+ "version": "0.0.1"
+ },
+ "nameSpace": "org.onap.policy.apex.onap.vcpe",
+ "source": "APEX",
+ "target": "APEX",
+ "parameter": {
+ "entry": [
+ {
+ "key": "requestID",
+ "value": {
+ "key": "requestID",
+ "fieldSchemaKey": {
+ "name": "UUIDType",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "vnfID",
+ "value": {
+ "key": "vnfID",
+ "fieldSchemaKey": {
+ "name": "UUIDType",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "vnfName",
+ "value": {
+ "key": "vnfName",
+ "fieldSchemaKey": {
+ "name": "SimpleStringType",
+ "version": "0.0.1"
+ },
+ "optional": true
+ }
+ }
+ ]
+ },
+ "toscaPolicyState": ""
+ }
+ }
+ ]
+ },
+ "taskParameters": {
+ "entry": []
+ },
+ "contextAlbumReference": [
+ {
+ "name": "ControlLoopExecutionIDAlbum",
+ "version": "0.0.1"
+ },
+ {
+ "name": "VCPEClosedLoopStatusAlbum",
+ "version": "0.0.1"
+ }
+ ],
+ "taskLogic": {
+ "key": "TaskLogic",
+ "logicFlavour": "JAVASCRIPT",
+ "logic": "/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2016-2018 Ericsson. All rights reserved.\n * Modifications Copyright (C) 2020 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(executor.subject.id);\nexecutor.logger.info(executor.inFields);\n\nvar vnfID = executor.getContextAlbum(\"ControlLoopExecutionIDAlbum\").remove(executor.executionId.toString());\n\nexecutor.logger.info(\"Continuing execution with VNF ID: \" + vnfID);\n\nvar vcpeClosedLoopStatus = executor.getContextAlbum(\"VCPEClosedLoopStatusAlbum\").get(vnfID.toString());\nexecutor.logger.info(vcpeClosedLoopStatus);\n\nvar guardResult = executor.inFields.get(\"decision\");\nvar returnValue = true;\n\nif (guardResult == \"PERMIT\") {\n vcpeClosedLoopStatus.put(\"notification\", \"OPERATION: GUARD_PERMIT\");\n} else if (guardResult == \"DENY\") {\n vcpeClosedLoopStatus.put(\"notification\", \"OPERATION: GUARD_DENY\");\n} else {\n executor.message = \"guard result must be either \\\"PERMIT\\\" or \\\"DENY\\\"\";\n returnValue = false;\n}\n\nvar uuidType = java.util.UUID;\nvar requestID = uuidType.fromString(vcpeClosedLoopStatus.get(\"requestID\"));\n\nexecutor.outFields.put(\"requestID\", requestID);\nexecutor.outFields.put(\"vnfID\", vnfID);\n\nexecutor.logger.info(executor.outFields);\n\n\nreturnValue;"
+ }
+ }
+ },
+ {
+ "key": {
+ "name": "NoAAILookupTask",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "NoAAILookupTask",
+ "version": "0.0.1"
+ },
+ "taskParameters": {
+ "entry": []
+ },
+ "contextAlbumReference": [],
+ "taskLogic": {
+ "key": "TaskLogic",
+ "logicFlavour": "JAVASCRIPT",
+ "logic": "/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2016-2018 Ericsson. All rights reserved.\n * Modifications Copyright (C) 2020 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(executor.subject.id);\nexecutor.logger.info(executor.inFields);\n\nexecutor.logger.info(executor.outFields);\n\ntrue;"
+ }
+ }
+ }
+ ]
+ }
+ },
+ "events": {
+ "key": {
+ "name": "ONAPvCPEPolicyModel_Events",
+ "version": "0.0.1"
+ },
+ "eventMap": {
+ "entry": [
+ {
+ "key": {
+ "name": "APPCRestartVNFRequestEvent",
+ "version": "2.0.0"
+ },
+ "value": {
+ "key": {
+ "name": "APPCRestartVNFRequestEvent",
+ "version": "2.0.0"
+ },
+ "nameSpace": "org.onap.policy.apex.onap.vcpe",
+ "source": "APEX",
+ "target": "APPC",
+ "parameter": {
+ "entry": [
+ {
+ "key": "APPCLCMRequestEvent",
+ "value": {
+ "key": "APPCLCMRequestEvent",
+ "fieldSchemaKey": {
+ "name": "APPCLCMRequestType",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ }
+ ]
+ },
+ "toscaPolicyState": ""
+ }
+ },
+ {
+ "key": {
+ "name": "APPCRestartVNFResponseEvent",
+ "version": "2.0.0"
+ },
+ "value": {
+ "key": {
+ "name": "APPCRestartVNFResponseEvent",
+ "version": "2.0.0"
+ },
+ "nameSpace": "org.onap.policy.apex.onap.vcpe",
+ "source": "APEX",
+ "target": "APPC",
+ "parameter": {
+ "entry": [
+ {
+ "key": "APPCLCMResponseEvent",
+ "value": {
+ "key": "APPCLCMResponseEvent",
+ "fieldSchemaKey": {
+ "name": "APPCLCMResponseType",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ }
+ ]
+ },
+ "toscaPolicyState": ""
+ }
+ },
+ {
+ "key": {
+ "name": "ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e",
+ "version": "1.0.2"
+ },
+ "value": {
+ "key": {
+ "name": "ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e",
+ "version": "1.0.2"
+ },
+ "nameSpace": "org.onap.policy.apex.onap.vcpe",
+ "source": "DCAE",
+ "target": "APEX",
+ "parameter": {
+ "entry": [
+ {
+ "key": "VirtualControlLoopEvent",
+ "value": {
+ "key": "VirtualControlLoopEvent",
+ "fieldSchemaKey": {
+ "name": "VirtualControlLoopEventType",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ }
+ ]
+ },
+ "toscaPolicyState": ""
+ }
+ },
+ {
+ "key": {
+ "name": "ControlLoopLogEvent",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "ControlLoopLogEvent",
+ "version": "0.0.1"
+ },
+ "nameSpace": "org.onap.policy.apex.onap.vcpe",
+ "source": "APEX",
+ "target": "APEX",
+ "parameter": {
+ "entry": [
+ {
+ "key": "VirtualControlLoopNotification",
+ "value": {
+ "key": "VirtualControlLoopNotification",
+ "fieldSchemaKey": {
+ "name": "VirtualControlLoopNotificationType",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ }
+ ]
+ },
+ "toscaPolicyState": ""
+ }
+ },
+ {
+ "key": {
+ "name": "GuardRequestEvent",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "GuardRequestEvent",
+ "version": "0.0.1"
+ },
+ "nameSpace": "org.onap.policy.apex.onap.vcpe",
+ "source": "APEX",
+ "target": "APEX",
+ "parameter": {
+ "entry": [
+ {
+ "key": "decisionAttributes",
+ "value": {
+ "key": "decisionAttributes",
+ "fieldSchemaKey": {
+ "name": "GuardDecisionAttributesType",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "onapName",
+ "value": {
+ "key": "onapName",
+ "fieldSchemaKey": {
+ "name": "SimpleStringType",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ }
+ ]
+ },
+ "toscaPolicyState": ""
+ }
+ },
+ {
+ "key": {
+ "name": "GuardResponseEvent",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "GuardResponseEvent",
+ "version": "0.0.1"
+ },
+ "nameSpace": "org.onap.policy.apex.onap.vcpe",
+ "source": "APEX",
+ "target": "APEX",
+ "parameter": {
+ "entry": [
+ {
+ "key": "decision",
+ "value": {
+ "key": "decision",
+ "fieldSchemaKey": {
+ "name": "SimpleStringType",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "details",
+ "value": {
+ "key": "details",
+ "fieldSchemaKey": {
+ "name": "SimpleStringType",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ }
+ ]
+ },
+ "toscaPolicyState": ""
+ }
+ },
+ {
+ "key": {
+ "name": "VCPEStateUpdatedEvent",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "VCPEStateUpdatedEvent",
+ "version": "0.0.1"
+ },
+ "nameSpace": "org.onap.policy.apex.onap.vcpe",
+ "source": "APEX",
+ "target": "APEX",
+ "parameter": {
+ "entry": [
+ {
+ "key": "requestID",
+ "value": {
+ "key": "requestID",
+ "fieldSchemaKey": {
+ "name": "UUIDType",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "vnfID",
+ "value": {
+ "key": "vnfID",
+ "fieldSchemaKey": {
+ "name": "UUIDType",
+ "version": "0.0.1"
+ },
+ "optional": false
+ }
+ },
+ {
+ "key": "vnfName",
+ "value": {
+ "key": "vnfName",
+ "fieldSchemaKey": {
+ "name": "SimpleStringType",
+ "version": "0.0.1"
+ },
+ "optional": true
+ }
+ }
+ ]
+ },
+ "toscaPolicyState": ""
+ }
+ }
+ ]
+ }
+ },
+ "albums": {
+ "key": {
+ "name": "ONAPvCPEPolicyModel_Albums",
+ "version": "0.0.1"
+ },
+ "albums": {
+ "entry": [
+ {
+ "key": {
+ "name": "ControlLoopExecutionIDAlbum",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "ControlLoopExecutionIDAlbum",
+ "version": "0.0.1"
+ },
+ "scope": "policy",
+ "isWritable": true,
+ "itemSchema": {
+ "name": "UUIDType",
+ "version": "0.0.1"
+ }
+ }
+ },
+ {
+ "key": {
+ "name": "RequestIDVNFIDAlbum",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "RequestIDVNFIDAlbum",
+ "version": "0.0.1"
+ },
+ "scope": "policy",
+ "isWritable": true,
+ "itemSchema": {
+ "name": "UUIDType",
+ "version": "0.0.1"
+ }
+ }
+ },
+ {
+ "key": {
+ "name": "VCPEClosedLoopStatusAlbum",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "VCPEClosedLoopStatusAlbum",
+ "version": "0.0.1"
+ },
+ "scope": "policy",
+ "isWritable": true,
+ "itemSchema": {
+ "name": "VCPEClosedLoopStatusType",
+ "version": "0.0.1"
+ }
+ }
+ }
+ ]
+ }
+ },
+ "schemas": {
+ "key": {
+ "name": "ONAPvCPEPolicyModel_Schemas",
+ "version": "0.0.1"
+ },
+ "schemas": {
+ "entry": [
+ {
+ "key": {
+ "name": "APPCLCMRequestType",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "APPCLCMRequestType",
+ "version": "0.0.1"
+ },
+ "schemaFlavour": "Java",
+ "schemaDefinition": "org.onap.policy.appclcm.AppcLcmDmaapWrapper"
+ }
+ },
+ {
+ "key": {
+ "name": "APPCLCMResponseType",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "APPCLCMResponseType",
+ "version": "0.0.1"
+ },
+ "schemaFlavour": "Java",
+ "schemaDefinition": "org.onap.policy.appclcm.AppcLcmDmaapWrapper"
+ }
+ },
+ {
+ "key": {
+ "name": "GuardDecisionAttributesType",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "GuardDecisionAttributesType",
+ "version": "0.0.1"
+ },
+ "schemaFlavour": "Avro",
+ "schemaDefinition": "{\n \"type\": \"record\",\n \"name\": \"GuardDecisionAttributes_Type\",\n \"namespace\": \"org.onap.policy.apex.onap.vcpe\",\n \"fields\": [\n {\n \"name\": \"actor\",\n \"type\": \"string\"\n },\n {\n \"name\": \"recipe\",\n \"type\": \"string\"\n },\n {\n \"name\": \"target\",\n \"type\": \"string\"\n },\n {\n \"name\": \"clname\",\n \"type\": \"string\"\n }\n ]\n}"
+ }
+ },
+ {
+ "key": {
+ "name": "SimpleBooleanType",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "SimpleBooleanType",
+ "version": "0.0.1"
+ },
+ "schemaFlavour": "Java",
+ "schemaDefinition": "java.lang.Boolean"
+ }
+ },
+ {
+ "key": {
+ "name": "SimpleLongType",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "SimpleLongType",
+ "version": "0.0.1"
+ },
+ "schemaFlavour": "Java",
+ "schemaDefinition": "java.lang.Long"
+ }
+ },
+ {
+ "key": {
+ "name": "SimpleStringType",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "SimpleStringType",
+ "version": "0.0.1"
+ },
+ "schemaFlavour": "Java",
+ "schemaDefinition": "java.lang.String"
+ }
+ },
+ {
+ "key": {
+ "name": "UUIDType",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "UUIDType",
+ "version": "0.0.1"
+ },
+ "schemaFlavour": "Java",
+ "schemaDefinition": "java.util.UUID"
+ }
+ },
+ {
+ "key": {
+ "name": "VCPEClosedLoopStatusType",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "VCPEClosedLoopStatusType",
+ "version": "0.0.1"
+ },
+ "schemaFlavour": "Avro",
+ "schemaDefinition": "{\n \"type\": \"record\",\n \"name\": \"VCPEClosedLoopStatus\",\n \"fields\": [\n {\n \"name\": \"AAI\",\n \"type\": {\n \"type\": \"record\",\n \"name\": \"VCPE_AAI_Type\",\n \"namespace\": \"org.onap.policy.apex.onap.vcpe\",\n \"fields\": [\n {\n \"name\": \"genericVnfResourceVersion\",\n \"type\": \"string\"\n },\n {\n \"name\": \"genericVnfVnfName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"genericVnfProvStatus\",\n \"type\": \"string\"\n },\n {\n \"name\": \"genericVnfIsClosedLoopDisabled\",\n \"type\": \"string\"\n },\n {\n \"name\": \"genericVnfOrchestrationStatus\",\n \"type\": \"string\"\n },\n {\n \"name\": \"genericVnfVnfType\",\n \"type\": \"string\"\n },\n {\n \"name\": \"genericVnfInMaint\",\n \"type\": \"string\"\n },\n {\n \"name\": \"genericVnfServiceId\",\n \"type\": \"string\"\n },\n {\n \"name\": \"genericVnfVnfId\",\n \"type\": \"string\"\n },\n {\n \"name\": \"vserverIsClosedLoopDisabled\",\n \"type\": \"string\"\n },\n {\n \"name\": \"vserverName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"vserverProvStatus\",\n \"type\": \"string\"\n }\n ]\n }\n },\n {\n \"name\": \"closedLoopAlarmStart\",\n \"type\": \"long\"\n },\n {\n \"name\": \"closedLoopAlarmEnd\",\n \"type\": \"long\"\n },\n {\n \"name\": \"closedLoopControlName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"version\",\n \"type\": \"string\"\n },\n {\n \"name\": \"requestID\",\n \"type\": \"string\"\n },\n {\n \"name\": \"closedLoopEventClient\",\n \"type\": \"string\"\n },\n {\n \"name\": \"closedLoopEventStatus\",\n \"type\": \"string\"\n },\n {\n \"name\": \"target_type\",\n \"type\": \"string\"\n },\n {\n \"name\": \"target\",\n \"type\": \"string\"\n },\n {\n \"name\": \"from\",\n \"type\": \"string\"\n },\n {\n \"name\": \"policyScope\",\n \"type\": \"string\"\n },\n {\n \"name\": \"policyName\",\n \"type\": \"string\"\n },\n {\n \"name\": \"policyVersion\",\n \"type\": \"string\"\n },\n {\n \"name\": \"notification\",\n \"type\": \"string\"\n },\n {\n \"name\": \"notificationTime\",\n \"type\": \"long\"\n },\n {\n \"name\": \"message\",\n \"type\": \"string\"\n }\n ]\n}"
+ }
+ },
+ {
+ "key": {
+ "name": "VirtualControlLoopEventType",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "VirtualControlLoopEventType",
+ "version": "0.0.1"
+ },
+ "schemaFlavour": "Java",
+ "schemaDefinition": "org.onap.policy.controlloop.VirtualControlLoopEvent"
+ }
+ },
+ {
+ "key": {
+ "name": "VirtualControlLoopNotificationType",
+ "version": "0.0.1"
+ },
+ "value": {
+ "key": {
+ "name": "VirtualControlLoopNotificationType",
+ "version": "0.0.1"
+ },
+ "schemaFlavour": "Java",
+ "schemaDefinition": "org.onap.policy.controlloop.VirtualControlLoopNotification"
+ }
+ }
+ ]
+ }
+ }
+}
diff --git a/model/policy-model/pom.xml b/model/policy-model/pom.xml
index 3fbf8b1dc..cde0fa83c 100644
--- a/model/policy-model/pom.xml
+++ b/model/policy-model/pom.xml
@@ -1,6 +1,7 @@
<!--
============LICENSE_START=======================================================
Copyright (C) 2018 Ericsson. All rights reserved.
+ Modifications Copyright (C) 2022 Nordix Foundation.
================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -50,30 +51,4 @@
<scope>test</scope>
</dependency>
</dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>generate-xml-schema</id>
- <phase>process-classes</phase>
- <goals>
- <goal>java</goal>
- </goals>
- <configuration>
- <mainClass>org.onap.policy.apex.model.basicmodel.handling.ApexSchemaGenerator</mainClass>
- <classpathScope>compile</classpathScope>
- <arguments>
- <argument>org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel</argument>
- <argument>${project.build.directory}/model/xml/apex-policy-model.xsd</argument>
- </arguments>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
</project>
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxLogic.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxLogic.java
index a7cb97a46..0564d5854 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxLogic.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxLogic.java
@@ -22,19 +22,12 @@
package org.onap.policy.apex.model.policymodel.concepts;
import java.util.List;
-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 javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
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.AxValidationMessage;
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.xml.AxReferenceKeyAdapter;
import org.onap.policy.common.utils.validation.Assertions;
/**
@@ -49,12 +42,6 @@ import org.onap.policy.common.utils.validation.Assertions;
* <p>Validation checks that the logic key is valid, that the logic flavour is defined and is valid when checked against
* the {@code LOGIC_FLAVOUR_REGEXP} regular expression, and that the specified logic string is not null or blank.
*/
-
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlRootElement(name = "apexLogic", namespace = "http://www.onap.org/policy/apex-pdp")
-@XmlType(name = "AxLogic", namespace = "http://www.onap.org/policy/apex-pdp", propOrder =
- { "key", "logicFlavour", "logic" })
-
public class AxLogic extends AxConcept {
private static final long serialVersionUID = -4260562004005697328L;
@@ -74,14 +61,8 @@ public class AxLogic extends AxConcept {
/** The maximum permissible size of a logic definition. */
public static final int MAX_LOGIC_SIZE = 32672; // The maximum size supported by Apache Derby
- @XmlElement(name = "key", required = true)
- @XmlJavaTypeAdapter(AxReferenceKeyAdapter.class)
private AxReferenceKey key;
-
- @XmlElement(required = true)
private String logicFlavour;
-
- @XmlElement(required = true)
private String logic;
/**
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicies.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicies.java
index 4073046ab..bb30f46cf 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicies.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicies.java
@@ -27,11 +27,6 @@ import java.util.Map.Entry;
import java.util.NavigableMap;
import java.util.Set;
import java.util.TreeMap;
-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.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
import org.onap.policy.apex.model.basicmodel.concepts.AxConceptGetter;
@@ -52,17 +47,10 @@ import org.onap.policy.common.utils.validation.Assertions;
* container. Each policy entry is checked to ensure that its key and value are not null and that the key matches the
* key in the map value. Each policy entry is then validated individually.
*/
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "AxPolicies", namespace = "http://www.onap.org/policy/apex-pdp", propOrder =
- { "key", "policyMap" })
-
public class AxPolicies extends AxConcept implements AxConceptGetter<AxPolicy> {
private static final long serialVersionUID = 4290442590545820316L;
- @XmlElement(name = "key", required = true)
private AxArtifactKey key;
-
- @XmlElement(required = true)
private Map<AxArtifactKey, AxPolicy> policyMap;
/**
@@ -95,7 +83,7 @@ public class AxPolicies extends AxConcept implements AxConceptGetter<AxPolicy> {
/**
* This Constructor creates a policy container with all of its fields defined.
*
- * @param key the policy container key
+ * @param key the policy container key
* @param policyMap the policies to be stored in the policy container
*/
public AxPolicies(final AxArtifactKey key, final Map<AxArtifactKey, AxPolicy> policyMap) {
@@ -109,22 +97,6 @@ public class AxPolicies extends AxConcept implements AxConceptGetter<AxPolicy> {
}
/**
- * When a model is unmarshalled from disk or from the database, the policy 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 unmarshaler the unmarshaler that is unmarshaling the model
- * @param parent the parent object of this object in the unmarshaler
- */
- public void afterUnmarshal(final Unmarshaller unmarshaler, final Object parent) {
- // The map must be navigable to allow name and version searching, unmarshaling returns a
- // hash map
- final NavigableMap<AxArtifactKey, AxPolicy> navigablePolicyMap = new TreeMap<>();
- navigablePolicyMap.putAll(policyMap);
- policyMap = navigablePolicyMap;
- }
-
- /**
* {@inheritDoc}.
*/
@Override
@@ -147,6 +119,18 @@ public class AxPolicies extends AxConcept implements AxConceptGetter<AxPolicy> {
}
/**
+ * {@inheritDoc}.
+ */
+ @Override
+ public void buildReferences() {
+ policyMap.entrySet().stream().forEach(policyEntry -> {
+ policyEntry.getValue().setKey(policyEntry.getKey());
+ policyEntry.getValue().buildReferences();
+ }
+ );
+ }
+
+ /**
* Sets the key of the policy container.
*
* @param key the policy container key
@@ -185,23 +169,23 @@ public class AxPolicies extends AxConcept implements AxConceptGetter<AxPolicy> {
if (key.equals(AxArtifactKey.getNullKey())) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "key is a null key"));
+ "key is a null key"));
}
result = key.validate(result);
if (policyMap.size() == 0) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "policyMap may not be empty"));
+ "policyMap may not be empty"));
} else {
for (final Entry<AxArtifactKey, AxPolicy> policyEntry : policyMap.entrySet()) {
final AxArtifactKey entryKey = policyEntry.getKey();
if (entryKey.equals(AxArtifactKey.getNullKey())) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "key on policy entry " + entryKey + " may not be the null key"));
+ "key on policy entry " + entryKey + " may not be the null key"));
} else if (policyEntry.getValue() == null) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "value on policy entry " + entryKey + " may not be null"));
+ "value on policy entry " + entryKey + " may not be null"));
} else {
validate(result, policyEntry, entryKey);
result = policyEntry.getValue().validate(result);
@@ -213,11 +197,11 @@ public class AxPolicies extends AxConcept implements AxConceptGetter<AxPolicy> {
}
private void validate(final AxValidationResult result, final Entry<AxArtifactKey, AxPolicy> policyEntry,
- final AxArtifactKey entryKey) {
+ final AxArtifactKey entryKey) {
if (!entryKey.equals(policyEntry.getValue().getKey())) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "key on policy entry key " + entryKey + " does not equal policy value key "
- + policyEntry.getValue().getKey()));
+ "key on policy entry key " + entryKey + " does not equal policy value key "
+ + policyEntry.getValue().getKey()));
}
}
@@ -354,7 +338,7 @@ public class AxPolicies extends AxConcept implements AxConceptGetter<AxPolicy> {
@Override
public AxPolicy get(final String conceptKeyName, final String conceptKeyVersion) {
return new AxConceptGetterImpl<>((NavigableMap<AxArtifactKey, AxPolicy>) policyMap).get(conceptKeyName,
- conceptKeyVersion);
+ conceptKeyVersion);
}
/**
@@ -371,6 +355,6 @@ public class AxPolicies extends AxConcept implements AxConceptGetter<AxPolicy> {
@Override
public Set<AxPolicy> getAll(final String conceptKeyName, final String conceptKeyVersion) {
return new AxConceptGetterImpl<>((NavigableMap<AxArtifactKey, AxPolicy>) policyMap).getAll(conceptKeyName,
- conceptKeyVersion);
+ conceptKeyVersion);
}
}
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicy.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicy.java
index 64785daef..a47afe4d6 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicy.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicy.java
@@ -21,17 +21,13 @@
package org.onap.policy.apex.model.policymodel.concepts;
+import com.google.gson.annotations.SerializedName;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
-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.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
@@ -60,38 +56,42 @@ import org.slf4j.ext.XLoggerFactory;
* <p>The template of a policy is a string that can be used by policy editors to store meta information on the policy
* that can be used at design time. The policy template string is not used during policy execution.
*
- * <p>During validation of a policy, the validation checks listed below are executed: <ol> <li>The policy key must not
- * be a null key <li>The policy key must be valid <li>If the policy template is not set, an observation is issued <li>At
- * least one state must be defined <li>Keys and values must all be defined, that is not null <li>The key on each entry
- * in the state map must match the key in the entry's value <li>The parent key of each state in the state map of a
- * policy must be the key of that policy <li>Each state must itself be valid, see validation in {@link AxState} <li>The
- * next state of the state output of each state must be defined as a state in the policy <li>The first state of a policy
- * must be set <li>The first state of a policy must be defined in the policy <li>If a state is defined but is not used
- * in a policy,a warning is issued <li>The state tree of the policy must be valid, see validation in {@link AxStateTree}
+ * <p>During validation of a policy, the validation checks listed below are executed:
+ * <ol>
+ * <li>The policy key must not
+ * be a null key
+ * <li>The policy key must be valid
+ * <li>If the policy template is not set, an observation is issued
+ * <li>At
+ * least one state must be defined
+ * <li>Keys and values must all be defined, that is not null
+ * <li>The key on each entry
+ * in the state map must match the key in the entry's value
+ * <li>The parent key of each state in the state map of a
+ * policy must be the key of that policy
+ * <li>Each state must itself be valid, see validation in {@link AxState}
+ * <li>The
+ * next state of the state output of each state must be defined as a state in the policy
+ * <li>The first state of a policy
+ * must be set
+ * <li>The first state of a policy must be defined in the policy
+ * <li>If a state is defined but is not used
+ * in a policy,a warning is issued
+ * <li>The state tree of the policy must be valid, see validation in {@link AxStateTree}
* </ol>
*/
-
-@XmlRootElement(name = "apexPolicy", namespace = "http://www.onap.org/policy/apex-pdp")
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "AxPolicy", namespace = "http://www.onap.org/policy/apex-pdp", propOrder =
- { "key", "template", "stateMap", "firstState" })
-
public class AxPolicy extends AxConcept {
private static final long serialVersionUID = -1775614096390365941L;
// Logger for this class
private static final XLogger LOGGER = XLoggerFactory.getXLogger(AxPolicy.class);
- @XmlElement(name = "policyKey", required = true)
+ @SerializedName("policyKey")
private AxArtifactKey key;
-
- @XmlElement(required = true)
private String template;
- @XmlElement(name = "state", required = true)
+ @SerializedName("state")
private Map<String, AxState> stateMap;
-
- @XmlElement(required = true)
private String firstState;
/**
@@ -116,15 +116,18 @@ public class AxPolicy extends AxConcept {
* @param key the key of the policy
*/
public AxPolicy(final AxArtifactKey key) {
- this(key, "", new TreeMap<>(), "");
+ this(key,
+ "",
+ new TreeMap<>(),
+ "");
}
/**
* This Constructor creates a policy with the given key and all its fields defined.
*
- * @param key the key of the policy
- * @param template the policy template for policy editor metadata
- * @param stateMap the state map containing the states of the policy
+ * @param key the key of the policy
+ * @param template the policy template for policy editor metadata
+ * @param stateMap the state map containing the states of the policy
* @param firstState the first state that will execute on this policy
*/
public AxPolicy(final AxArtifactKey key, final String template, final Map<String, AxState> stateMap,
@@ -172,6 +175,20 @@ public class AxPolicy extends AxConcept {
}
/**
+ * {@inheritDoc}.
+ */
+ @Override
+ public void buildReferences() {
+ stateMap.entrySet().stream().forEach(stateEntry -> {
+ if (!stateEntry.getValue().getKey().getLocalName().equals(AxKey.NULL_KEY_NAME)) {
+ stateEntry.getValue().getKey().setParentArtifactKey(key);
+ }
+ stateEntry.getValue().buildReferences();
+ }
+ );
+ }
+
+ /**
* Sets the key of the policy.
*
* @param key the key of the policy
@@ -246,20 +263,21 @@ public class AxPolicy extends AxConcept {
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 (template.trim().length() == 0) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.OBSERVATION,
- "a policy template has not been specified"));
+ "a policy template has not been specified"));
}
if (stateMap.size() == 0) {
- result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "stateMap may not be empty"));
+ result.addValidationMessage(
+ new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
+ "stateMap may not be empty"));
} else {
for (final Entry<String, AxState> stateEntry : stateMap.entrySet()) {
result = validateStateEntry(stateEntry, result);
@@ -275,11 +293,11 @@ public class AxPolicy extends AxConcept {
// We only check the unused states on models validated this far
if (firstState.trim().length() == 0) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "no first state specified, first state may not be blank"));
+ "no first state specified, first state may not be blank"));
} else {
if (!stateMap.containsKey(firstState)) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "first state not found in stateMap"));
+ "first state not found in stateMap"));
} else {
validateStateTree(result);
}
@@ -292,43 +310,42 @@ public class AxPolicy extends AxConcept {
* Validate a state entry.
*
* @param stateEntry the state entry to validate
- * @param result The validation result to append to
+ * @param result The validation result to append to
* @return The result of the validation
*/
- private AxValidationResult validateStateEntry(final Entry<String, AxState> stateEntry, AxValidationResult result) {
+ private AxValidationResult validateStateEntry(final Entry<String, AxState> stateEntry, AxValidationResult
+ result) {
if (stateEntry.getKey() == null || stateEntry.getKey().equals(AxKey.NULL_KEY_NAME)) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "key on state entry key " + stateEntry.getKey() + " may not be the null key"));
+ "key on state entry key " + stateEntry.getKey() + " may not be the null key"));
return result;
}
if (stateEntry.getValue() == null) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "value on state entry value " + stateEntry.getKey() + " may not be null"));
+ "value on state entry value " + stateEntry.getKey() + " may not be null"));
return result;
}
if (!stateEntry.getKey().equals(stateEntry.getValue().getKey().getLocalName())) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "key on state entry key " + stateEntry.getKey()
- + " does not equal state entry value local name "
- + stateEntry.getValue().getKey().getLocalName()));
+ "key on state entry key " + stateEntry.getKey() + " does not equal state entry value local name "
+ + stateEntry.getValue().getKey().getLocalName()));
}
if (!stateEntry.getValue().getKey().getParentArtifactKey().equals(key)) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "parent key on state entry key " + stateEntry.getValue().getKey()
- + " does not equal policy key"));
+ "parent key on state entry key " + stateEntry.getValue().getKey() + " does not equal policy key"));
}
result = stateEntry.getValue().validate(result);
for (final AxStateOutput stateOutput : stateEntry.getValue().getStateOutputs().values()) {
if (!stateOutput.getNextState().equals(AxReferenceKey.getNullKey())
- && !stateMap.containsKey(stateOutput.getNextState().getLocalName())) {
- result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- " nextState of state " + stateEntry.getKey() + " not found in StateMap: "
- + stateOutput.getNextState().getId()));
+ && !stateMap.containsKey(stateOutput.getNextState().getLocalName())) {
+ result.addValidationMessage(
+ new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID, " nextState of state "
+ + stateEntry.getKey() + " not found in StateMap: " + stateOutput.getNextState().getId()));
}
}
@@ -353,12 +370,11 @@ public class AxPolicy extends AxConcept {
for (final AxState unreferencedState : unreferencedStateSet) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.WARNING,
- "state " + unreferencedState.getKey()
- + " is not referenced in the policy execution tree"));
+ "state " + unreferencedState.getKey() + " is not referenced in the policy execution tree"));
}
} catch (PolicyRuntimeException pre) {
AxValidationMessage validationMessage = new AxValidationMessage(key, this.getClass(),
- ValidationResult.WARNING, "state tree in policy is invalid");
+ ValidationResult.WARNING, "state tree in policy is invalid");
LOGGER.trace(validationMessage.getMessage(), pre);
result.addValidationMessage(validationMessage);
}
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicyModel.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicyModel.java
index 38c08ed94..e119536fb 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicyModel.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicyModel.java
@@ -25,14 +25,6 @@ package org.onap.policy.apex.model.policymodel.concepts;
import java.util.List;
import java.util.Map.Entry;
-import javax.xml.bind.Marshaller;
-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.XmlRootElement;
-import javax.xml.bind.annotation.XmlType;
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
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.AxKey;
@@ -41,7 +33,6 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxModel;
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;
-import org.onap.policy.apex.model.basicmodel.handling.KeyInfoMarshalFilter;
import org.onap.policy.apex.model.basicmodel.service.ModelService;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums;
@@ -50,7 +41,6 @@ import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
import org.onap.policy.apex.model.eventmodel.concepts.AxEvent;
import org.onap.policy.apex.model.eventmodel.concepts.AxEvents;
import org.onap.policy.apex.model.eventmodel.concepts.AxField;
-import org.onap.policy.apex.model.policymodel.handling.EmptyAlbumsAdapter;
import org.onap.policy.common.utils.validation.Assertions;
/**
@@ -98,30 +88,23 @@ import org.onap.policy.common.utils.validation.Assertions;
* <li>All events referred to on direct state outputs must exist
* </ol>
*/
-@XmlRootElement(name = "apexPolicyModel", namespace = "http://www.onap.org/policy/apex-pdp")
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "AxPolicyModel", namespace = "http://www.onap.org/policy/apex-pdp",
- propOrder = {"policies", "tasks", "events", "albums", "schemas"})
-
public class AxPolicyModel extends AxModel {
+ // @formatter:off
+ private static final String SCHEMAS_TOKEN = "_Schemas";
+ private static final String KEY_INFO_TOKEN = "_KeyInfo";
+ private static final String EVENTS_TOKEN = "_Events";
+ private static final String ALBUMS_TOKEN = "_Albums";
+ private static final String TASKS_TOKEN = "_Tasks";
+ private static final String POLICIESS_TOKEN = "_Policies";
+
private static final String DOES_NOT_EXIST = " does not exist";
private static final long serialVersionUID = 8800599637708309945L;
- @XmlElement(name = "policies", required = true)
private AxPolicies policies;
-
- @XmlElement(name = "tasks", required = true)
private AxTasks tasks;
-
- @XmlElement(name = "events", required = true)
private AxEvents events;
-
- @XmlElement(name = "albums", required = false)
- @XmlJavaTypeAdapter(EmptyAlbumsAdapter.class)
private AxContextAlbums albums;
-
- @XmlElement(name = "schemas", required = true)
private AxContextSchemas schemas;
/**
@@ -148,12 +131,13 @@ public class AxPolicyModel extends AxModel {
* @param key the key
*/
public AxPolicyModel(final AxArtifactKey key) {
- this(key, new AxContextSchemas(new AxArtifactKey(key.getName() + "_Schemas", key.getVersion())),
- new AxKeyInformation(new AxArtifactKey(key.getName() + "_KeyInfo", key.getVersion())),
- new AxEvents(new AxArtifactKey(key.getName() + "_Events", key.getVersion())),
- new AxContextAlbums(new AxArtifactKey(key.getName() + "_Albums", key.getVersion())),
- new AxTasks(new AxArtifactKey(key.getName() + "_Tasks", key.getVersion())),
- new AxPolicies(new AxArtifactKey(key.getName() + "_Policies", key.getVersion())));
+ this(key,
+ new AxContextSchemas(new AxArtifactKey(key.getName() + SCHEMAS_TOKEN, key.getVersion())),
+ new AxKeyInformation(new AxArtifactKey(key.getName() + KEY_INFO_TOKEN, key.getVersion())),
+ new AxEvents(new AxArtifactKey(key.getName() + EVENTS_TOKEN, key.getVersion())),
+ new AxContextAlbums(new AxArtifactKey(key.getName() + ALBUMS_TOKEN, key.getVersion())),
+ new AxTasks(new AxArtifactKey(key.getName() + TASKS_TOKEN, key.getVersion())),
+ new AxPolicies(new AxArtifactKey(key.getName() + POLICIESS_TOKEN, key.getVersion())));
}
/**
@@ -168,7 +152,7 @@ public class AxPolicyModel extends AxModel {
* @param policies the policy container for the policy model
*/
public AxPolicyModel(final AxArtifactKey key, final AxContextSchemas schemas, final AxKeyInformation keyInformation,
- final AxEvents events, final AxContextAlbums albums, final AxTasks tasks, final AxPolicies policies) {
+ final AxEvents events, final AxContextAlbums albums, final AxTasks tasks, final AxPolicies policies) {
super(key, keyInformation);
Assertions.argumentNotNull(schemas, "schemas may not be null");
Assertions.argumentNotNull(events, "events may not be null");
@@ -334,7 +318,7 @@ public class AxPolicyModel extends AxModel {
validateEventKeys(result);
validateContextAlbumKeys(result);
- result = validateAllTaskKeys(result);
+ validateAllTaskKeys(result);
validatePolicyKeys(result);
return result;
@@ -384,7 +368,7 @@ public class AxPolicyModel extends AxModel {
*/
private AxValidationResult validateAllTaskKeys(AxValidationResult result) {
for (final AxTask task : tasks.getAll(null)) {
- result = validateTaskKeys(task, result);
+ validateTaskKeys(task, result);
}
return result;
}
@@ -496,7 +480,7 @@ public class AxPolicyModel extends AxModel {
* @param result the validation result to append to
*/
private void validateEventTaskFieldCompatibilityOnStateOutput(final AxState state, final AxTask task,
- final AxStateOutput stateOutput, AxValidationResult result) {
+ final AxStateOutput stateOutput, AxValidationResult result) {
if (stateOutput == null) {
result.addValidationMessage(new AxValidationMessage(state.getKey(), this.getClass(),
ValidationResult.INVALID, "state output on task reference for task " + task.getId() + " is null"));
@@ -512,38 +496,26 @@ public class AxPolicyModel extends AxModel {
}
/**
- * When a model is unmarshalled from disk or from the database, if the albums field was missing a blank
- * with a null key was added. This method is called by JAXB after unmarshalling and is
+ * When a model is deserialized, if the albums field was missing a blank
+ * with a null key was added. This method is called by JAXB after deserializing and is
* used to insert an appropriate key
- *
- * @param unmarshaller the unmarshaller that is unmarshalling the model
- * @param parent the parent object of this object in the unmarshaller
*/
- public void afterUnmarshal(final Unmarshaller unmarshaller, final Object parent) {
- new EmptyAlbumsAdapter().doAfterUnmarshal(this);
- }
-
- /**
- * When a model is marshalled from disk or database, if the albums field is empty/null, then the albums field
- * is not emitted. If the (empty) albums field is not emitted then it's keyinfo should also be suppressed
- * This method is called by JAXB before marshaling and is used to insert the appropriate filters
- *
- * @param marshaller the marshaller that is marshaller the model
- * @throws Exception if there is a problem with the marshalling
- */
- public void beforeMarshal(final Marshaller marshaller) throws Exception {
- EmptyAlbumsAdapter albumsfilter = new EmptyAlbumsAdapter();
- marshaller.setAdapter(EmptyAlbumsAdapter.class, albumsfilter);
- //get/create the keyinfofilter
- KeyInfoMarshalFilter keyinfoFilter = marshaller.getAdapter(KeyInfoMarshalFilter.class);
- if (keyinfoFilter == null) {
- keyinfoFilter = new KeyInfoMarshalFilter();
- }
- //if the albumsfilter would filter out this model's albums add the album's key to the keyinfofilter
- if (albumsfilter.marshal(this.albums) == null && this.albums != null) {
- keyinfoFilter.addFilterKey(this.albums.getKey());
+ @Override
+ public void buildReferences() {
+ getSchemas().buildReferences();
+ getEvents().buildReferences();
+ getAlbums().buildReferences();
+ getTasks().buildReferences();
+ getPolicies().buildReferences();
+ getKeyInformation().buildReferences();
+
+ AxArtifactKey nullAlbumskey = new AxArtifactKey(AxKey.NULL_KEY_NAME + ALBUMS_TOKEN, AxKey.NULL_KEY_VERSION);
+
+ if (AxArtifactKey.getNullKey().equals(getAlbums().getKey())
+ || nullAlbumskey.equals(getAlbums().getKey())) {
+ getAlbums().setKey(new AxArtifactKey(getKey().getName() + ALBUMS_TOKEN, getKey().getVersion()));
+ getKeyInformation().generateKeyInfo(getAlbums());
}
- marshaller.setAdapter(keyinfoFilter);
}
/**
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxState.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxState.java
index df07b0ea3..ae8efbff4 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxState.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxState.java
@@ -23,18 +23,13 @@
package org.onap.policy.apex.model.policymodel.concepts;
+import com.google.gson.annotations.SerializedName;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
-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.XmlRootElement;
-import javax.xml.bind.annotation.XmlType;
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.AxKey;
@@ -106,40 +101,27 @@ import org.onap.policy.common.utils.validation.Assertions;
* <li>Each State Finalizer logic instance in a state must be valid, see validation in {@link AxStateFinalizerLogic}
* </ol>
*/
-
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlRootElement(name = "apexState", namespace = "http://www.onap.org/policy/apex-pdp")
-@XmlType(name = "AxState", namespace = "http://www.onap.org/policy/apex-pdp", propOrder =
- { "key", "trigger", "stateOutputs", "contextAlbumReferenceSet", "taskSelectionLogic", "stateFinalizerLogicMap",
- "defaultTask", "taskReferenceMap" })
-
public class AxState extends AxConcept {
private static final String DOES_NOT_EQUAL_STATE_KEY = " does not equal state key";
private static final long serialVersionUID = 8041771382337655535L;
- @XmlElement(name = "stateKey", required = true)
+
+
+ @SerializedName("stateKey")
private AxReferenceKey key;
- @XmlElement(required = true)
private AxArtifactKey trigger;
-
- @XmlElement(name = "stateOutputs", required = true)
private Map<String, AxStateOutput> stateOutputs;
- @XmlElement(name = "contextAlbumReference")
+ @SerializedName("contextAlbumReference")
private Set<AxArtifactKey> contextAlbumReferenceSet;
- @XmlElement(required = true)
private AxTaskSelectionLogic taskSelectionLogic;
-
- @XmlElement(name = "stateFinalizerLogicMap", required = true)
private Map<String, AxStateFinalizerLogic> stateFinalizerLogicMap;
-
- @XmlElement(required = true)
private AxArtifactKey defaultTask;
- @XmlElement(name = "taskReferences", required = true)
+ @SerializedName("taskReferences")
private Map<AxArtifactKey, AxStateTaskReference> taskReferenceMap;
/**
@@ -210,29 +192,19 @@ public class AxState extends AxConcept {
// CHECKSTYLE:ON: checkstyle:parameterNumber
/**
- * When a state is unmarshalled from disk or from the database, the parent of contained objects is not defined. This
- * method is called by JAXB after unmarshaling and is used to set the parent keys of all
+ * When a state is deserialized from disk or from the database, the parent of contained objects is not defined. This
+ * method is called by JAXB after deserialized and is used to set the parent keys of all
* {@link AxTaskSelectionLogic}, {@link AxStateOutput}, and {@link AxStateFinalizerLogic} instance in the state.
- *
- * @param unmarshaler the unmarshaler that is unmarshaling the model
- * @param parent the parent object of this object in the unmarshaler
*/
- public void afterUnmarshal(final Unmarshaller unmarshaler, final Object parent) {
+ @Override
+ public void buildReferences() {
if (!taskSelectionLogic.getKey().getLocalName().equals(AxKey.NULL_KEY_NAME)) {
taskSelectionLogic.getKey().setParentReferenceKey(key);
}
- for (final Entry<String, AxStateOutput> soEntry : stateOutputs.entrySet()) {
- soEntry.getValue().getKey().setParentReferenceKey(key);
- }
-
- for (final Entry<String, AxStateFinalizerLogic> sflEntry : stateFinalizerLogicMap.entrySet()) {
- sflEntry.getValue().getKey().setParentReferenceKey(key);
- }
-
- for (final Entry<AxArtifactKey, AxStateTaskReference> trEntry : taskReferenceMap.entrySet()) {
- trEntry.getValue().getKey().setParentReferenceKey(key);
- }
+ stateOutputs.values().stream().forEach(output -> output.getKey().setParentReferenceKey(key));
+ stateFinalizerLogicMap.values().stream().forEach(output -> output.getKey().setParentReferenceKey(key));
+ taskReferenceMap.values().stream().forEach(output -> output.getKey().setParentReferenceKey(key));
}
/**
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateFinalizerLogic.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateFinalizerLogic.java
index 51ec51a8f..31ffedea8 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateFinalizerLogic.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateFinalizerLogic.java
@@ -21,10 +21,6 @@
package org.onap.policy.apex.model.policymodel.concepts;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlType;
import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
/**
@@ -39,10 +35,6 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
*
* <p>Validation uses standard Apex Logic validation, see validation in {@link AxLogic}.
*/
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlRootElement(name = "apexStateFinalizerLogic", namespace = "http://www.onap.org/policy/apex-pdp")
-@XmlType(name = "AxStateFinalizerLogic", namespace = "http://www.onap.org/policy/apex-pdp")
-
public class AxStateFinalizerLogic extends AxLogic {
private static final long serialVersionUID = 2090324845463750391L;
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateOutput.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateOutput.java
index b90f2c84d..7d4695290 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateOutput.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateOutput.java
@@ -23,13 +23,9 @@
package org.onap.policy.apex.model.policymodel.concepts;
+import com.google.gson.annotations.SerializedName;
import java.util.List;
import java.util.Set;
-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 lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
@@ -60,28 +56,20 @@ import org.onap.policy.common.utils.validation.Assertions;
* <li>The next state key must be valid, see validation in {@link AxReferenceKey}
* </ol>
*/
-
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlRootElement(name = "apexStateOutput", namespace = "http://www.onap.org/policy/apex-pdp")
-@XmlType(name = "AxStateOutput", namespace = "http://www.onap.org/policy/apex-pdp",
- propOrder = {"key", "outgoingEvent", "outgoingEventSet", "nextState"})
@Getter
@Setter
public class AxStateOutput extends AxConcept {
private static final long serialVersionUID = 8041771382337655535L;
- @XmlElement(name = "key", required = true)
@NonNull
private AxReferenceKey key;
- @XmlElement(required = true)
@NonNull
private AxArtifactKey outgoingEvent;
- @XmlElement(name = "outgoingEventReference", required = false)
+ @SerializedName("outgoingEventReference")
private Set<AxArtifactKey> outgoingEventSet;
- @XmlElement(required = true)
@NonNull
private AxReferenceKey nextState;
// @formatter:on
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateTaskOutputType.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateTaskOutputType.java
index 741eb8833..171747c0c 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateTaskOutputType.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateTaskOutputType.java
@@ -1,37 +1,31 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
package org.onap.policy.apex.model.policymodel.concepts;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlType;
-
/**
* This enumeration defines the type of state output selection that is defined for a task in a
* state. The {@link AxStateTaskReference} instance for each task uses this enumeration to decide
* what type of output selection to use when a task has completed execution.
*/
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "AxStateTaskOutputType", namespace = "http://www.onap.org/policy/apex-pdp")
-
public enum AxStateTaskOutputType {
/** The state output selection for the task has not been defined. */
UNDEFINED,
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateTaskReference.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateTaskReference.java
index 711e1842b..748eca92d 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateTaskReference.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateTaskReference.java
@@ -23,11 +23,6 @@
package org.onap.policy.apex.model.policymodel.concepts;
import java.util.List;
-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.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
@@ -61,22 +56,11 @@ import org.onap.policy.common.utils.validation.Assertions;
* {@link AxReferenceKey}
* </ol>
*/
-
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlRootElement(name = "apexStateTaskReference", namespace = "http://www.onap.org/policy/apex-pdp")
-@XmlType(name = "AxStateTaskReference", namespace = "http://www.onap.org/policy/apex-pdp",
- propOrder = {"key", "outputType", "output"})
-
public class AxStateTaskReference extends AxConcept {
private static final long serialVersionUID = 8041771382337655535L;
- @XmlElement(name = "key", required = true)
private AxReferenceKey key;
-
- @XmlElement(required = true)
private AxStateTaskOutputType outputType;
-
- @XmlElement(required = true)
private AxReferenceKey output;
/**
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTask.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTask.java
index 3911a1f97..c8b6baf4b 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTask.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTask.java
@@ -22,18 +22,13 @@
package org.onap.policy.apex.model.policymodel.concepts;
+import com.google.gson.annotations.SerializedName;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
-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.XmlRootElement;
-import javax.xml.bind.annotation.XmlType;
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
@@ -71,14 +66,6 @@ import org.onap.policy.common.utils.validation.Assertions;
* <li>The task logic must be valid, see validation in {@link AxTaskLogic}
* </ol>
*/
-
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlRootElement(name = "apexTask", namespace = "http://www.onap.org/policy/apex-pdp")
-@XmlType(
- name = "AxTask",
- namespace = "http://www.onap.org/policy/apex-pdp",
- propOrder = {"key", "inputEvent", "outputEvents", "taskParameters",
- "contextAlbumReferenceSet", "taskLogic"})
@Getter
@Setter
public class AxTask extends AxConcept {
@@ -86,24 +73,17 @@ public class AxTask extends AxConcept {
private static final long serialVersionUID = 5374237330697362762L;
- @XmlElement(name = "key", required = true)
@NonNull
private AxArtifactKey key;
- @XmlElement(name = "inputEvent", required = false)
private AxEvent inputEvent;
-
- @XmlElement(name = "outputEvents", required = false)
private Map<String, AxEvent> outputEvents;
-
- @XmlElement(name = "taskParameters", required = true)
private Map<String, AxTaskParameter> taskParameters;
- @XmlElement(name = "contextAlbumReference")
+ @SerializedName("contextAlbumReference")
@NonNull
private Set<AxArtifactKey> contextAlbumReferenceSet;
- @XmlElement(required = true)
@NonNull
private AxTaskLogic taskLogic;
@@ -163,18 +143,17 @@ public class AxTask extends AxConcept {
}
/**
- * When a task is unmarshalled from disk or from the database, the parent of contained objects
- * is not defined. This method is called by JAXB after unmarshaling and is used to set the
+ * When a task is deserialized from disk or from the database, the parent of contained objects
+ * is not defined. This method is called by JAXB after deserialization and is used to set the
* parent keys of all {@link AxTaskParameter} instance in the task.
- *
- * @param unmarshaler the unmarshaler that is unmarshaling the model
- * @param parent the parent object of this object in the unmarshaler
*/
- public void afterUnmarshal(final Unmarshaller unmarshaler, final Object parent) {
- taskLogic.getKey().setParentArtifactKey(key);
- for (final AxTaskParameter parameter : taskParameters.values()) {
- parameter.getKey().setParentArtifactKey(key);
+ @Override
+ public void buildReferences() {
+ if (!taskLogic.getKey().getLocalName().equals(AxKey.NULL_KEY_NAME)) {
+ taskLogic.getKey().setParentArtifactKey(key);
}
+
+ taskParameters.values().stream().forEach(parameter -> parameter.getKey().setParentArtifactKey(key));
}
/**
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTaskLogic.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTaskLogic.java
index 38c0d6daf..8665d9e3e 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTaskLogic.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTaskLogic.java
@@ -21,10 +21,6 @@
package org.onap.policy.apex.model.policymodel.concepts;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlType;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
@@ -38,10 +34,6 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
*
* <p>Validation uses standard Apex Logic validation, see validation in {@link AxLogic}.
*/
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlRootElement(name = "apexLogic", namespace = "http://www.onap.org/policy/apex-pdp")
-@XmlType(name = "AxTaskLogic", namespace = "http://www.onap.org/policy/apex-pdp")
-
public class AxTaskLogic extends AxLogic {
private static final long serialVersionUID = 2090324845463750391L;
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTaskParameter.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTaskParameter.java
index 7cb052a7f..a468ec499 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTaskParameter.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTaskParameter.java
@@ -22,11 +22,6 @@
package org.onap.policy.apex.model.policymodel.concepts;
import java.util.List;
-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.AxConcept;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
@@ -42,19 +37,10 @@ import org.onap.policy.common.utils.validation.Assertions;
* a default value. If the task parameter is not set in a configuration file, the task uses its
* default value.
*/
-
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlRootElement(name = "apexTaskParameter", namespace = "http://www.onap.org/policy/apex-pdp")
-@XmlType(name = "AxTaskParameter", namespace = "http://www.onap.org/policy/apex-pdp",
- propOrder = {"key", "defaultValue"})
-
public class AxTaskParameter extends AxConcept {
private static final long serialVersionUID = 7351688156934099977L;
- @XmlElement(name = "key", required = true)
private AxReferenceKey key;
-
- @XmlElement
private String defaultValue;
/**
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTaskSelectionLogic.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTaskSelectionLogic.java
index 43b8f11a6..b9cfd802d 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTaskSelectionLogic.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTaskSelectionLogic.java
@@ -21,10 +21,6 @@
package org.onap.policy.apex.model.policymodel.concepts;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlType;
import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
/**
@@ -37,10 +33,6 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
*
* <p>Validation uses standard Apex Logic validation, see validation in {@link AxLogic}.
*/
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlRootElement(name = "apexTaskSelectionLogic", namespace = "http://www.onap.org/policy/apex-pdp")
-@XmlType(name = "AxTaskSelectionLogic", namespace = "http://www.onap.org/policy/apex-pdp")
-
public class AxTaskSelectionLogic extends AxLogic {
private static final long serialVersionUID = 2090324845463750391L;
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTasks.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTasks.java
index bae50e061..f9ccafd54 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTasks.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTasks.java
@@ -27,11 +27,6 @@ import java.util.Map.Entry;
import java.util.NavigableMap;
import java.util.Set;
import java.util.TreeMap;
-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.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
import org.onap.policy.apex.model.basicmodel.concepts.AxConceptGetter;
@@ -52,15 +47,10 @@ import org.onap.policy.common.utils.validation.Assertions;
* in the container. Each task entry is checked to ensure that its key and value are not null and
* that the key matches the key in the map value. Each task entry is then validated individually.
*/
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "AxTasks", namespace = "http://www.onap.org/policy/apex-pdp", propOrder = {"key", "taskMap"})
public class AxTasks extends AxConcept implements AxConceptGetter<AxTask> {
private static final long serialVersionUID = 4290442590545820316L;
- @XmlElement(name = "key", required = true)
private AxArtifactKey key;
-
- @XmlElement(required = true)
private Map<AxArtifactKey, AxTask> taskMap;
/**
@@ -93,7 +83,7 @@ public class AxTasks extends AxConcept implements AxConceptGetter<AxTask> {
/**
* This Constructor creates a task container with all of its fields defined.
*
- * @param key the task container key
+ * @param key the task container key
* @param taskMap the tasks to be stored in the task container
*/
public AxTasks(final AxArtifactKey key, final Map<AxArtifactKey, AxTask> taskMap) {
@@ -107,23 +97,6 @@ public class AxTasks extends AxConcept implements AxConceptGetter<AxTask> {
}
/**
- * When a model is unmarshalled from disk or from the database, the task 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 unmarshaler the unmarshaler that is unmarshaling the model
- * @param parent the parent object of this object in the unmarshaler
- */
- public void afterUnmarshal(final Unmarshaller unmarshaler, final Object parent) {
- // The map must be navigable to allow name and version searching, unmarshaling returns a
- // hash map
- final NavigableMap<AxArtifactKey, AxTask> navigableTaskMap = new TreeMap<>();
- navigableTaskMap.putAll(taskMap);
- taskMap = navigableTaskMap;
- }
-
- /**
* {@inheritDoc}.
*/
@Override
@@ -146,6 +119,14 @@ public class AxTasks extends AxConcept implements AxConceptGetter<AxTask> {
}
/**
+ * {@inheritDoc}.
+ */
+ @Override
+ public void buildReferences() {
+ taskMap.values().stream().forEach(task -> task.buildReferences());
+ }
+
+ /**
* Sets the task container key.
*
* @param key the task container key
@@ -184,27 +165,27 @@ public class AxTasks extends AxConcept implements AxConceptGetter<AxTask> {
if (key.equals(AxArtifactKey.getNullKey())) {
result.addValidationMessage(
- new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID, "key is a null key"));
+ new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID, "key is a null key"));
}
result = key.validate(result);
if (taskMap.size() == 0) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "taskMap may not be empty"));
+ "taskMap may not be empty"));
} else {
for (final Entry<AxArtifactKey, AxTask> taskEntry : taskMap.entrySet()) {
if (taskEntry.getKey().equals(AxArtifactKey.getNullKey())) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "key on task entry " + taskEntry.getKey() + " may not be the null key"));
+ "key on task entry " + taskEntry.getKey() + " may not be the null key"));
} else if (taskEntry.getValue() == null) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "value on task entry " + taskEntry.getKey() + " may not be null"));
+ "value on task entry " + taskEntry.getKey() + " may not be null"));
} else {
if (!taskEntry.getKey().equals(taskEntry.getValue().getKey())) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(),
- ValidationResult.INVALID, "key on task entry key " + taskEntry.getKey()
- + " does not equal task value key " + taskEntry.getValue().getKey()));
+ ValidationResult.INVALID, "key on task entry key " + taskEntry.getKey()
+ + " does not equal task value key " + taskEntry.getValue().getKey()));
}
result = taskEntry.getValue().validate(result);
@@ -348,7 +329,7 @@ public class AxTasks extends AxConcept implements AxConceptGetter<AxTask> {
@Override
public AxTask get(final String conceptKeyName, final String conceptKeyVersion) {
return new AxConceptGetterImpl<>((NavigableMap<AxArtifactKey, AxTask>) taskMap).get(conceptKeyName,
- conceptKeyVersion);
+ conceptKeyVersion);
}
/**
@@ -365,6 +346,6 @@ public class AxTasks extends AxConcept implements AxConceptGetter<AxTask> {
@Override
public Set<AxTask> getAll(final String conceptKeyName, final String conceptKeyVersion) {
return new AxConceptGetterImpl<>((NavigableMap<AxArtifactKey, AxTask>) taskMap).getAll(conceptKeyName,
- conceptKeyVersion);
+ conceptKeyVersion);
}
}
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/package-info.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/package-info.java
index cc15a6af5..acf0e8221 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/package-info.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/package-info.java
@@ -1,19 +1,20 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
@@ -21,15 +22,7 @@
/**
* Contains the concepts required to specify policies and tasks in APEX. It defines the main Apex
* concepts of policies and tasks.
- *
+ *
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-
-@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.policy.apex.model.policymodel.concepts;
-
-import javax.xml.bind.annotation.XmlNs;
-import javax.xml.bind.annotation.XmlNsForm;
-import javax.xml.bind.annotation.XmlSchema;
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/handling/EmptyAlbumsAdapter.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/handling/EmptyAlbumsAdapter.java
deleted file mode 100644
index aa19edf0b..000000000
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/handling/EmptyAlbumsAdapter.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.model.policymodel.handling;
-
-import javax.xml.bind.annotation.adapters.XmlAdapter;
-import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums;
-import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
-
-/**
- * This class makes the albums field optional in marshaled Policy Models.
- * Empty albums are not marshaled to JSON/XML.
- * When unmarshaled, if no albums value is present then a new empty albums entry is created.
- *
- * @author John Keeney (john.keeney@ericsson.com)
- */
-public class EmptyAlbumsAdapter extends XmlAdapter<AxContextAlbums, AxContextAlbums> {
-
-
- /**
- * Decide whether to marshall a context albums entry. Non-empty context albums are always marshalled.
- * Empty albums are filtered.
- *
- * @param albums the albums entry
- * @return the albums entry, or null if empty
- * @throws Exception if there is a problem with the marshalling
- * @see javax.xml.bind.annotation.adapters.XmlAdapter#marshal(Object)
- */
- @Override
- public AxContextAlbums marshal(AxContextAlbums albums) throws Exception {
- if ((albums == null) || (albums.getAlbumsMap() == null) || (albums.getAlbumsMap().isEmpty())) {
- return null;
- } else {
- return albums;
- }
- }
-
- /**
- * Decide whether to unmarshall a context albums entry - Always.
- *
- * @param val the albums entry
- * @return the albums entry
- * @throws Exception if there is a problem with the unmarshalling
- * @see javax.xml.bind.annotation.adapters.XmlAdapter#unmarshal(Object)
- */
- @Override
- public AxContextAlbums unmarshal(AxContextAlbums val) throws Exception {
- return val;
- }
-
- /**
- * After unmarshalling has completed the model's context albums entry may be null/empty or default.
- * If so the key for the albums entry should updated to a sensible value and additional keyinfo
- * information should then be added for that key
- *
- * @param policyModel the policy model containing the possibly empty context albums entry
- * @see javax.xml.bind.annotation.adapters.XmlAdapter#unmarshal(Object)
- */
- public void doAfterUnmarshal(AxPolicyModel policyModel) {
- AxArtifactKey nullkey = new AxArtifactKey();
- AxArtifactKey blanknullalbumskey =
- new AxArtifactKey(nullkey.getKey().getName() + "_Albums", nullkey.getKey().getVersion());
- AxArtifactKey thisalbumskey = policyModel.getAlbums().getKey();
- AxArtifactKey thismodelkey = policyModel.getKey();
- AxContextAlbums thismodelalbums = policyModel.getAlbums();
-
- if (nullkey.equals(thisalbumskey) || blanknullalbumskey.equals(thisalbumskey)) {
- thismodelalbums.setKey(new AxArtifactKey(thismodelkey.getName() + "_Albums", thismodelkey.getVersion()));
- policyModel.getKeyInformation().generateKeyInfo(thismodelalbums);
- }
- }
-
-}
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PoliciesTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PoliciesTest.java
index e724a4663..526f5a628 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PoliciesTest.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PoliciesTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020,2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -190,9 +190,9 @@ public class PoliciesTest {
final AxState clonedState = new AxState(policyPN.getStateMap().get("state"));
clonedState.getKey().setLocalName("ClonedState");
- clonedState.afterUnmarshal(null, null);
savedStateMap.put(clonedState.getKey().getLocalName(), clonedState);
+ policyPN.buildReferences();
result = new AxValidationResult();
result = policyPN.validate(result);
assertEquals(ValidationResult.WARNING, result.getValidationResult());
@@ -213,7 +213,9 @@ public class PoliciesTest {
assertEquals(policyPN, policyPN); // NOSONAR
assertEquals(policyPN, clonedPolicy);
assertNotNull(policyPN);
- assertNotEquals(policyPN, (Object) "Hello");
+
+ Object helloObj = "Hello";
+ assertNotEquals(policyPN, helloObj);
assertNotEquals(policyPN,
new AxPolicy(AxArtifactKey.getNullKey(), savedTemplate, savedStateMap, savedFirstState));
assertNotEquals(policyPN, new AxPolicy(savedPolicyKey, "SomeTemplate", savedStateMap, savedFirstState));
@@ -287,7 +289,6 @@ public class PoliciesTest {
assertEquals(ValidationResult.VALID, result.getValidationResult());
policies.clean();
- policies.afterUnmarshal(null, null);
final AxPolicies clonedPolicies = new AxPolicies(policies);
assertEquals("AxPolicies:(key=AxArtifactKey:(name=PoliciesKey,version=0.0.",
@@ -298,7 +299,7 @@ public class PoliciesTest {
assertEquals(policies, policies); // NOSONAR
assertEquals(policies, clonedPolicies);
assertNotNull(policies);
- assertNotEquals(policies, (Object) "Hello");
+ assertNotEquals(policyPN, helloObj);
assertNotEquals(policies, new AxPolicies(new AxArtifactKey()));
assertEquals(0, policies.compareTo(policies));
@@ -324,7 +325,6 @@ public class PoliciesTest {
final AxState secondState = new AxState(policyPN.getStateMap().get("state"));
secondState.getKey().setLocalName("SecondState");
- secondState.afterUnmarshal(null, null);
policyPN.getStateMap().put("SecondState", secondState);
policyPN.getStateMap().get("state").getStateOutputs().get("stateOutput0").setNextState(secondState.getKey());
@@ -344,7 +344,6 @@ public class PoliciesTest {
final AxState thirdState = new AxState(policyPN.getStateMap().get("state"));
thirdState.getKey().setLocalName("ThirdState");
- thirdState.afterUnmarshal(null, null);
policyPN.getStateMap().put("ThirdState", thirdState);
policyPN.getStateMap().get("SecondState").getStateOutputs().get("stateOutput0")
.setNextState(thirdState.getKey());
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateTest.java
index 95a91325a..7fbe78078 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateTest.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2020,2022 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -147,10 +147,10 @@ public class StateTest {
state.setTaskReferences(trMap);
assertEquals(trMap, state.getTaskReferences());
- state.afterUnmarshal(null, null);
+ state.buildReferences();
assertEquals(state.getKey(), state.getKeys().get(0));
state.getTaskSelectionLogic().getKey().setLocalName(AxKey.NULL_KEY_NAME);
- state.afterUnmarshal(null, null);
+ state.buildReferences();
assertEquals(state.getKey(), state.getKeys().get(0));
final Set<String> stateSet = state.getNextStateSet();
@@ -387,7 +387,9 @@ public class StateTest {
assertEquals(state, state); // NOSONAR
assertEquals(state, clonedState);
assertNotNull(state);
- assertNotEquals(state, (Object) "Hello");
+
+ Object helloObj = "Hello";
+ assertNotEquals(state, helloObj);
assertNotEquals(state, new AxState(new AxStateParamsBuilder().key(new AxReferenceKey()).trigger(triggerKey)
.stateOutputs(soMap).contextAlbumReferenceSet(ctxtSet).taskSelectionLogic(tsl)
.stateFinalizerLogicMap(sflMap).defaultTask(defTaskKey).taskReferenceMap(trMap)));
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TasksTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TasksTest.java
index 89dc9a048..9c7866c85 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TasksTest.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TasksTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020,2022 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -85,7 +85,7 @@ public class TasksTest {
assertEquals("TaskName:0.0.1", task.getKey().getId());
assertEquals("TaskName:0.0.1", task.getKeys().get(0).getId());
- task.afterUnmarshal(null, null);
+ task.buildReferences();
assertEquals(1, task.getTaskParameters().size());
AxValidationResult result = new AxValidationResult();
@@ -154,7 +154,9 @@ public class TasksTest {
assertEquals(task, task); // NOSONAR
assertEquals(task, clonedTask);
assertNotNull(task);
- assertNotEquals(task, (Object) "Hello");
+
+ Object helloObj = "Hello";
+ assertNotEquals(task, helloObj);
assertNotEquals(task, new AxTask(new AxArtifactKey(), tpMap, ctxtSet, tl));
assertEquals(task, new AxTask(taskKey, tpMap, ctxtSet, tl));
assertNotEquals(task, new AxTask(taskKey, tpEmptyMap, ctxtSet, tl));
@@ -224,7 +226,6 @@ public class TasksTest {
assertEquals(ValidationResult.VALID, result.getValidationResult());
tasks.clean();
- tasks.afterUnmarshal(null, null);
final AxTasks clonedTasks = new AxTasks(tasks);
assertEquals("AxTasks:(key=AxArtifactKey:(name=TasksKey,version=0.0.1),tas",
@@ -236,7 +237,7 @@ public class TasksTest {
assertEquals(tasks, tasks); // NOSONAR
assertEquals(tasks, clonedTasks);
assertNotNull(tasks);
- assertNotEquals(tasks, (Object) "Hello");
+ assertNotEquals(tasks, helloObj);
assertNotEquals(tasks, new AxTasks(new AxArtifactKey()));
assertEquals(0, tasks.compareTo(tasks));
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java
index a2a997e8d..48e4f87f9 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java
@@ -132,11 +132,6 @@ public class ApexPolicyModelTest {
}
@Test
- public void testModelWriteReadXml() throws Exception {
- testApexModel.testApexModelWriteReadXml();
- }
-
- @Test
public void testModelWriteReadJson() throws Exception {
testApexModel.testApexModelWriteReadJson();
}