2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 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.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.asdctool.main;
23 import org.openecomp.sdc.asdctool.impl.GraphJsonValidator;
24 import org.openecomp.sdc.asdctool.impl.GraphMLConverter;
25 import org.openecomp.sdc.asdctool.impl.GraphMLDataAnalyzer;
27 public class ExportImportMenu {
29 private static void usageAndExit() {
38 private static void importUsage() {
39 System.out.println("Usage: import <janusgraph.properties> <graph file location>");
42 private static void validateJsonUsage() {
43 System.out.println("Usage: validate-json <export graph path>");
46 private static void exportUsage() {
47 System.out.println("Usage: export <janusgraph.properties> <output directory>");
50 private static void dataReportUsage() {
51 System.out.println("Usage: get-data-report-from-graph-ml <full path of .graphml file>");
54 private static void exportUsersUsage() {
55 System.out.println("Usage: exportusers <janusgraph.properties> <output directory>");
58 public static void main(String[] args) throws Exception {
60 if (args == null || args.length < 1) {
64 String operation = args[0];
65 GraphMLConverter graphMLConverter = new GraphMLConverter();
66 switch (operation.toLowerCase()) {
69 boolean isValid = verifyParamsLength(args, 3);
70 if (false == isValid) {
75 boolean result = graphMLConverter.exportGraph(args);
76 if (result == false) {
82 isValid = verifyParamsLength(args, 3);
83 if (false == isValid) {
87 result = graphMLConverter.importGraph(args);
88 if (result == false) {
94 isValid = verifyParamsLength(args, 3);
95 if (false == isValid) {
99 result = graphMLConverter.exportUsers(args);
100 if (result == false) {
106 isValid = verifyParamsLength(args, 3);
107 if (false == isValid) {
111 result = graphMLConverter.findErrorInJsonGraph(args);
112 if (result == false) {
116 case "validate-json":
117 String jsonFilePath = validateAndGetJsonFilePath(args);
118 GraphJsonValidator graphJsonValidator = new GraphJsonValidator();
119 if (graphJsonValidator.verifyJanusGraphJson(jsonFilePath)) {
124 case "export-as-graph-ml":
125 isValid = verifyParamsLength(args, 3);
126 if (false == isValid) {
130 String mlFile = graphMLConverter.exportGraphMl(args);
131 if (mlFile == null) {
135 case "export-as-graph-ml-with-data-report":
136 isValid = verifyParamsLength(args, 3);
137 if (false == isValid) {
141 mlFile = graphMLConverter.exportGraphMl(args);
142 if (mlFile == null) {
145 String[] dataArgs = new String[] { mlFile };
146 mlFile = new GraphMLDataAnalyzer().analyzeGraphMLData(dataArgs);
147 if (mlFile == null) {
151 case "get-data-report-from-graph-ml":
152 isValid = verifyParamsLength(args, 2);
153 if (false == isValid) {
157 dataArgs = new String[] { args[1] };
158 mlFile = new GraphMLDataAnalyzer().analyzeGraphMLData(dataArgs);
159 if (mlFile == null) {
169 private static String validateAndGetJsonFilePath(String[] args) {
171 isValid = verifyParamsLength(args, 2);
179 private static boolean verifyParamsLength(String[] args, int i) {
187 if (args.length >= i) {