1 package org.openecomp.sdc.asdctool.simulator.tenant;
3 import java.util.HashMap;
5 import java.util.function.Consumer;
7 import org.openecomp.sdc.be.config.ConfigurationManager;
8 import org.openecomp.sdc.common.api.ConfigurationSource;
9 import org.openecomp.sdc.common.impl.ExternalConfiguration;
10 import org.openecomp.sdc.common.impl.FSConfigurationSource;
11 import org.slf4j.Logger;
12 import org.slf4j.LoggerFactory;
15 * Main class of utility imports CSV file into the specified table
16 * The old stuff of the table is removed.
18 * Accepts 3 mandatory arguments:
19 * 1. Path to configuration folder
20 * 2. Name of the table
21 * 3. Path to the CSV file
24 * \src\main\resources\config\ operationalenvironment "C:\Users\dr2032\Documents\env.csv"
26 * See relevant import handler for example of csv file line.
28 * The list of supported tables:
29 * 1. operationalenvironment
35 public class ImportCassandraTableTool {
36 private static final Logger LOGGER = LoggerFactory.getLogger(ImportCassandraTableTool.class);
38 private static Map<String, Consumer<String>> mapHandlers = new HashMap<>();
41 mapHandlers.put(OperationalEvnironmentImportHandler.getTableName().toLowerCase(), OperationalEvnironmentImportHandler::execute);
44 public static void main(String[] args) {
45 if(args.length == 3) {
46 String appConfigDir = args[0];
47 String tableName = args[1];
48 String fileName = args[2];
50 ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir);
51 new ConfigurationManager(configurationSource);
53 Consumer<String> executor = mapHandlers.get(tableName.toLowerCase());
54 if (executor != null) {
55 executor.accept(fileName);
58 LOGGER.warn("Import to table [{}] is not supported yet!", tableName);
62 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.");