summaryrefslogtreecommitdiffstats
path: root/examples/examples-pcvs/src/main/java
diff options
context:
space:
mode:
authorramverma <ram.krishna.verma@ericsson.com>2018-07-25 17:26:52 +0100
committerramverma <ram.krishna.verma@ericsson.com>2018-07-25 17:32:29 +0100
commitf8959f5c51e6338b62e23ea503eb86d9c65d7c74 (patch)
tree7a8afbbf61f7091c30aadfc1cace70fb6e65bff9 /examples/examples-pcvs/src/main/java
parentdccf9a9e0758be0a926c94bf1599ee625066100d (diff)
Renaming examples in apex-pdp
Renaming the examples as per what the documentation expects them. Otherwise the documents won't work. Change-Id: Ib9e30bf5a4cec0fec981372e1d9f3a0ee5d60f2f Issue-ID: POLICY-861 Signed-off-by: ramverma <ram.krishna.verma@ericsson.com>
Diffstat (limited to 'examples/examples-pcvs/src/main/java')
-rw-r--r--examples/examples-pcvs/src/main/java/org/onap/policy/apex/examples/pcvs/model/PCVSDomainModelFactory.java72
-rw-r--r--examples/examples-pcvs/src/main/java/org/onap/policy/apex/examples/pcvs/model/PCVSDomainModelSaver.java57
-rw-r--r--examples/examples-pcvs/src/main/java/org/onap/policy/apex/examples/pcvs/model/package-info.java30
3 files changed, 159 insertions, 0 deletions
diff --git a/examples/examples-pcvs/src/main/java/org/onap/policy/apex/examples/pcvs/model/PCVSDomainModelFactory.java b/examples/examples-pcvs/src/main/java/org/onap/policy/apex/examples/pcvs/model/PCVSDomainModelFactory.java
new file mode 100644
index 000000000..19825e335
--- /dev/null
+++ b/examples/examples-pcvs/src/main/java/org/onap/policy/apex/examples/pcvs/model/PCVSDomainModelFactory.java
@@ -0,0 +1,72 @@
+/*-
+ * ============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.examples.pcvs.model;
+
+import java.io.File;
+
+import org.onap.policy.apex.auth.clieditor.ApexCLIEditorMain;
+import org.onap.policy.apex.model.basicmodel.concepts.ApexRuntimeException;
+import org.onap.policy.apex.model.basicmodel.handling.ApexModelReader;
+import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
+import org.onap.policy.apex.model.utilities.ResourceUtils;
+
+/**
+ * A factory for creating PCVSDomainModel objects.
+ *
+ * @author Sven van der Meer (sven.van.der.meer@ericsson.com)
+ */
+public class PCVSDomainModelFactory {
+
+ /**
+ * Generates the PCVS VPN-SLA policy model from CLI commands and creates an APEX model.
+ *
+ * @param workingDirectory The working directory for the CLI editor for includes
+ *
+ * @return the PCVS VPN-SLA policy model
+ */
+ public AxPolicyModel getPCVVpnSlaSPolicyModel(final String workingDirectory) {
+ final String path = "target/model-gen/pcvs/vpnsla";
+ final String file = "policy.json";
+ final String full = path + "/" + file;
+
+ final File pathFile = new File(path);
+ pathFile.mkdirs();
+
+ final String[] args =
+ new String[] { "-c", "src/main/resources/org/onap/policy/apex/examples/pcvs/vpnsla/vpnsla.apex", "-wd",
+ workingDirectory, "-o", full };
+
+ final ApexCLIEditorMain cliEditor = new ApexCLIEditorMain(args);
+ if (cliEditor.getErrorCount() > 0) {
+ throw new ApexRuntimeException(
+ "Apex CLI editor execution failed with " + cliEditor.getErrorCount() + " errors");
+ }
+
+ java.util.TimeZone.getTimeZone("gmt");
+ try {
+ final ApexModelReader<AxPolicyModel> reader = new ApexModelReader<>(AxPolicyModel.class);
+ return reader.read(ResourceUtils.getResourceAsString(full));
+ } catch (final Exception e) {
+ throw new ApexRuntimeException("Failed to build PCVS SLA1 policy from path: " + full, e);
+ }
+ }
+
+}
diff --git a/examples/examples-pcvs/src/main/java/org/onap/policy/apex/examples/pcvs/model/PCVSDomainModelSaver.java b/examples/examples-pcvs/src/main/java/org/onap/policy/apex/examples/pcvs/model/PCVSDomainModelSaver.java
new file mode 100644
index 000000000..ee6277a8e
--- /dev/null
+++ b/examples/examples-pcvs/src/main/java/org/onap/policy/apex/examples/pcvs/model/PCVSDomainModelSaver.java
@@ -0,0 +1,57 @@
+/*-
+ * ============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.examples.pcvs.model;
+
+import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
+import org.onap.policy.apex.model.basicmodel.handling.ApexModelSaver;
+import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
+
+/**
+ * The Class PCVSDomainModelSaver.
+ *
+ * @author Sven van der Meer (sven.van.der.meer@ericsson.com)
+ */
+public final class PCVSDomainModelSaver {
+
+ /** Private constructor to prevent instantiation. */
+ private PCVSDomainModelSaver() {}
+
+ /**
+ * Write all PCVS models to args[0].
+ *
+ * @param args uses <code>arg[0]</code> for directory information
+ * @throws ApexException the apex exception
+ */
+ public static void main(final String[] args) throws ApexException {
+ if (args.length != 2) {
+ System.err.println(
+ "usage: " + PCVSDomainModelSaver.class.getCanonicalName() + " workingDirectory modelDirectory");
+ return;
+ }
+
+ final AxPolicyModel pcvsPolicyModel = new PCVSDomainModelFactory().getPCVVpnSlaSPolicyModel(args[0]);
+ final ApexModelSaver<AxPolicyModel> pcvsModelSaver =
+ new ApexModelSaver<>(AxPolicyModel.class, pcvsPolicyModel, args[1] + "vpnsla/");
+ pcvsModelSaver.apexModelWriteJSON();
+ pcvsModelSaver.apexModelWriteXML();
+
+ }
+}
diff --git a/examples/examples-pcvs/src/main/java/org/onap/policy/apex/examples/pcvs/model/package-info.java b/examples/examples-pcvs/src/main/java/org/onap/policy/apex/examples/pcvs/model/package-info.java
new file mode 100644
index 000000000..ff9b39730
--- /dev/null
+++ b/examples/examples-pcvs/src/main/java/org/onap/policy/apex/examples/pcvs/model/package-info.java
@@ -0,0 +1,30 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+/**
+ * Contains the model for Policy-controlled Video Streaming.
+ *
+ * @author Sven van der Meer (sven.van.der.meer@ericsson.com)
+ * @author Joseph McNamara (joseph.mcnamara@ericsson.com)
+ * @author John Keeney (john.keeney@ericsson.com)
+ */
+
+package org.onap.policy.apex.examples.pcvs.model;
+