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=========================================================
19 * Modifications copyright (c) 2018 Nokia
20 * ================================================================================
23 package org.openecomp.sdc.asdctool.main;
25 import org.openecomp.sdc.asdctool.impl.JanusGraphInitializer;
26 import org.openecomp.sdc.be.config.ConfigurationManager;
27 import org.openecomp.sdc.be.dao.cassandra.schema.SdcSchemaBuilder;
28 import org.openecomp.sdc.be.dao.cassandra.schema.SdcSchemaUtils;
29 import org.openecomp.sdc.common.api.ConfigurationSource;
30 import org.openecomp.sdc.common.impl.ExternalConfiguration;
31 import org.openecomp.sdc.common.impl.FSConfigurationSource;
32 import org.openecomp.sdc.common.log.wrappers.Logger;
34 public class DataSchemaMenu {
36 private static Logger log = Logger.getLogger(DataSchemaMenu.class.getName());
38 public static void main(String[] args) {
40 String operation = args[0];
42 String appConfigDir = args[1];
44 if (args == null || args.length < 2) {
48 ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir);
49 ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
51 SdcSchemaBuilder sdcSchemaBuilder = new SdcSchemaBuilder(new SdcSchemaUtils(),
52 ConfigurationManager.getConfigurationManager().getConfiguration()::getCassandraConfig);
54 switch (operation.toLowerCase()) {
55 case "create-cassandra-structures":
56 log.debug("Start create cassandra keyspace, tables and indexes");
57 if (sdcSchemaBuilder.createSchema()) {
58 log.debug("create cassandra keyspace, tables and indexes successfull");
61 log.debug("create cassandra keyspace, tables and indexes failed");
65 case "create-janusgraph-structures":
66 log.debug("Start create janusgraph keyspace");
67 String janusGraphCfg = 2 == args.length ? configurationManager.getConfiguration().getJanusGraphCfgFile() : args[2];
68 if (JanusGraphInitializer.createGraph(janusGraphCfg)) {
69 log.debug("create janusgraph keyspace successfull");
72 log.debug("create janusgraph keyspace failed");
76 case "clean-cassndra":
77 log.debug("Start clean keyspace, tables");
78 if (sdcSchemaBuilder.deleteSchema()) {
79 log.debug(" successfull");
92 private static void usageAndExit() {
97 private static void DataSchemeUsage() {
98 System.out.println("Usage: create-cassandra-structures <configuration dir> ");
99 System.out.println("Usage: create-janusgraph-structures <configuration dir> ");