/** * Dumps the data to CSV * * @param c command * @param p cli parameters * @param ctx current context * @throws IOException IO issues * @throws InterruptedException internal problem with making file writable */ protected void dumpData(Command c, CliParams p, ProcessingContext ctx) throws IOException, InterruptedException { l.debug("Dumping data."); Connector cc = ctx.getConnectorMandatory(); String csvFile = c.getParamMandatory("csvFile"); c.paramsProcessed(); cc.dump(csvFile); l.info("Data dump finished. Data dumped into the file '" + csvFile + "'"); }
/** * Transfers the data to GoodData project * * @param c command * @param p cli parameters * @param ctx current context * @throws IOException IO issues * @throws InterruptedException internal problem with making file writable */ protected void transferData(Command c, CliParams p, ProcessingContext ctx) throws IOException, InterruptedException { l.debug("Transferring data."); Connector cc = ctx.getConnectorMandatory(); String pid = ctx.getProjectIdMandatory(); boolean waitForFinish = true; if (c.checkParam("waitForFinish")) { String w = c.getParam("waitForFinish"); if (w != null && w.equalsIgnoreCase("false")) waitForFinish = false; } cc.extractAndTransfer(c, pid, cc, waitForFinish, p, ctx); l.debug("Data transfer finished."); l.info("Data transfer finished."); }
/** * Generates the MAQL * * @param c command * @param p cli parameters * @param ctx current context * @throws IOException IO issues */ private void generateMAQL(Command c, CliParams p, ProcessingContext ctx) throws IOException { Connector cc = ctx.getConnectorMandatory(); String maqlFile = c.getParamMandatory("maqlFile"); c.paramsProcessed(); l.debug("Executing maql generation."); String maql = cc.generateMaqlCreate(); l.debug("Finished maql generation maql:\n" + maql); FileUtil.writeStringToFile(maql, maqlFile); l.info("MAQL script successfully generated into " + maqlFile); }
throws IOException, InterruptedException { String ssn = cc.getSchema().getName(); l.debug("Extracting data."); File tmpDir = FileUtil.createTempDir(); List<Column> columns = populateColumnsFromSchema(cc.getSchema()); cc.extract(tmpDir.getAbsolutePath()); cc.deploy(sli, columns, tmpDir.getAbsolutePath(), archivePath);
/** * Executes the commands in String * * @param commandsStr commands string */ public void execute(final String commandsStr) { List<Command> cmds = new ArrayList<Command>(); cmds.addAll(parseCmd(commandsStr)); for (Command command : cmds) { boolean processed = false; for (int i = 0; i < connectors.length && !processed; i++) { processed = connectors[i].processCommand(command, cliParams, context); } if (!processed) this.processCommand(command, cliParams, context); } }
final SourceSchema schema = cc.getSchema();
/** * Executes the commands in file * * @param scriptFile file with commands * @throws IOException in case of an IO issue */ public void execute(final File scriptFile) throws IOException { List<Command> cmds = new ArrayList<Command>(); cmds.addAll(parseCmd(FileUtil.readStringFromFile(scriptFile.getAbsolutePath()))); for (Command command : cmds) { boolean processed = false; for (int i = 0; i < connectors.length && !processed; i++) { processed = connectors[i].processCommand(command, cliParams, context); } if (!processed) processed = this.processCommand(command, cliParams, context); if (!processed) throw new InvalidCommandException("Unknown command '" + command.getCommand() + "'"); } }