2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 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.simulator.tenant;
23 import org.openecomp.sdc.be.config.ConfigurationManager;
24 import org.openecomp.sdc.common.api.ConfigurationSource;
25 import org.openecomp.sdc.common.impl.ExternalConfiguration;
26 import org.openecomp.sdc.common.impl.FSConfigurationSource;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
30 import java.util.HashMap;
32 import java.util.function.Consumer;
35 * Main class of utility imports CSV file into the specified table
36 * The old stuff of the table is removed.
38 * Accepts 3 mandatory arguments:
39 * 1. Path to configuration folder
40 * 2. Name of the table
41 * 3. Path to the CSV file
44 * \src\main\resources\config\ operationalenvironment "C:\Users\dr2032\Documents\env.csv"
46 * See relevant import handler for example of csv file line.
48 * The list of supported tables:
49 * 1. operationalenvironment
55 public class ImportCassandraTableTool {
56 private static final Logger LOGGER = LoggerFactory.getLogger(ImportCassandraTableTool.class);
58 private static Map<String, Consumer<String>> mapHandlers = new HashMap<>();
61 mapHandlers.put(OperationalEvnironmentImportHandler.getTableName().toLowerCase(), OperationalEvnironmentImportHandler::execute);
64 public static void main(String[] args) {
65 if(args.length == 3) {
66 String appConfigDir = args[0];
67 String tableName = args[1];
68 String fileName = args[2];
70 ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir);
71 new ConfigurationManager(configurationSource);
73 Consumer<String> executor = mapHandlers.get(tableName.toLowerCase());
74 if (executor != null) {
75 executor.accept(fileName);
78 LOGGER.warn("Import to table [{}] is not supported yet!", tableName);
82 LOGGER.warn("Invalid number of arguments. The 1st shoduld be path to config dir, the 2nd - table name and the 3rd - path to CSV file.");