Skip to content

Commit

Permalink
code refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Jagdish Kunwar committed Mar 17, 2023
1 parent 79a032c commit cc2a504
Showing 1 changed file with 13 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,26 +137,24 @@ private void createSchema(GlobalSettings gs, File atlasDir, String schemaId, JSO

// Write JSON to file
File file = new File(schemaDir, "definition.json");
try {
FileOutputStream fos = new FileOutputStream(file);
OutputStreamWriter osw = new OutputStreamWriter(fos);
try(FileOutputStream fos = new FileOutputStream(file);
OutputStreamWriter osw = new OutputStreamWriter(fos))
{
osw.write(formDefinition.toString(4).replace(" ", "\t"));
osw.flush();
fos.flush();
fos.close();
gs.getOutStream().println("Schema written to " + schemaDir.getAbsolutePath());

Options newOptions = new Options();
List<String> args = new ArrayList<String>();
args.add("update-schema");
args.add("--name");
args.add(groupName + "_" + schemaId);
newOptions.parseOptions(args);
CommandUpdateSchema cmdUpdateSchema = new CommandUpdateSchema();
cmdUpdateSchema.runCommand(gs, newOptions);
} catch (IOException e) {
gs.getOutStream().println("Could not write schema definition to " + file.getAbsolutePath());
throw new Exception("Could not write schema definition to " + file.getAbsolutePath());
}

Options newOptions = new Options();
List<String> args = new ArrayList<String>();
args.add("update-schema");
args.add("--name");
args.add(groupName + "_" + schemaId);
newOptions.parseOptions(args);
CommandUpdateSchema cmdUpdateSchema = new CommandUpdateSchema();
cmdUpdateSchema.runCommand(gs, newOptions);
}

private JSONObject schemaDefinitionFromForm(InReachForm form) throws Exception {
Expand Down

0 comments on commit cc2a504

Please sign in to comment.