52edb31a30611a884154211cd864901162884b85
[policy/apex-pdp.git] /
1 /*-
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  * SPDX-License-Identifier: Apache-2.0
20  * ============LICENSE_END=========================================================
21  */
22
23 package org.onap.policy.apex.examples.aadm.model;
24
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;
32
33 /**
34  * This class saves sample domain models to disk in XML and JSON format.
35  *
36  * @author Liam Fallon (liam.fallon@ericsson.com)
37  */
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);
42
43     /**
44      * Write the AADM model to args[0].
45      *
46      * @param args Not used
47      * @throws ApexException the apex exception
48      */
49     public static void main(final String[] args) throws ApexException {
50         if (args.length != 1) {
51             LOGGER.error("usage: " + AadmDomainModelSaver.class.getName() + " modelDirectory");
52             return;
53         }
54
55         // Save Java model
56         final AxPolicyModel aadmPolicyModel = new AadmDomainModelFactory().getAadmPolicyModel();
57         final ApexModelSaver<AxPolicyModel> aadmModelSaver = new ApexModelSaver<>(AxPolicyModel.class, aadmPolicyModel,
58                         args[0]);
59         aadmModelSaver.apexModelWriteJson();
60         aadmModelSaver.apexModelWriteXml();
61     }
62 }