2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2016-2018 Ericsson. All rights reserved.
4 * Modifications Copyright (C) 2019 Nordix Foundation.
5 * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 * SPDX-License-Identifier: Apache-2.0
20 * ============LICENSE_END=========================================================
23 package org.onap.policy.apex.examples.aadm.model;
25 import lombok.AccessLevel;
26 import lombok.NoArgsConstructor;
27 import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
28 import org.onap.policy.apex.model.basicmodel.handling.ApexModelSaver;
29 import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
30 import org.slf4j.ext.XLogger;
31 import org.slf4j.ext.XLoggerFactory;
34 * This class saves sample domain models to disk in XML and JSON format.
36 * @author Liam Fallon (liam.fallon@ericsson.com)
38 @NoArgsConstructor(access = AccessLevel.PRIVATE)
39 public final class AadmDomainModelSaver {
40 // Logger for this class
41 private static final XLogger LOGGER = XLoggerFactory.getXLogger(AadmDomainModelSaver.class);
44 * Write the AADM model to args[0].
46 * @param args Not used
47 * @throws ApexException the apex exception
49 public static void main(final String[] args) throws ApexException {
50 if (args.length != 1) {
51 LOGGER.error("usage: " + AadmDomainModelSaver.class.getName() + " modelDirectory");
56 final AxPolicyModel aadmPolicyModel = new AadmDomainModelFactory().getAadmPolicyModel();
57 final ApexModelSaver<AxPolicyModel> aadmModelSaver = new ApexModelSaver<>(AxPolicyModel.class, aadmPolicyModel,
59 aadmModelSaver.apexModelWriteJson();
60 aadmModelSaver.apexModelWriteXml();