Child: [05f15f] (diff)

Download this file

Main.java    70 lines (55 with data), 2.4 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package net.timbusproject.iermtoowl;
import net.timbusproject.iermtoowl.utils.OntologyMapper;
import net.timbusproject.iermtoowl.utils.UnifiedRiskReader;
import org.apache.commons.cli.BasicParser;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.semanticweb.owlapi.model.OWLOntologyStorageException;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
/**
* Created by miguel on 25-06-2014.
*/
public class Main {
public static void main(String[] args) throws IOException, OWLOntologyStorageException, ParseException {
String path = "/home/miguel/Documentos/ierm-bpmn-owl-project/ierm-owl/risk-output-forDPES.xml";
String riskPath = null;
String[] imports = null;
String destinationPath = null;
Options options = new Options();
options.addOption("help", false, "Show all options");
options.addOption("h", false, "Show all options");
options.addOption("r", true, "Choose risk file");
options.addOption("i", true, "Choose import file(s)");
options.addOption("d", true, "Choose destination file");
CommandLine cmd = new BasicParser().parse(options, args);
if (cmd.hasOption("h") || cmd.hasOption("help") ) {
System.out.println("-r\tChoose risk file - Mandatory\n-i\tChoose import file(s)\n-d\tChoose destination file");
System.exit(0);
}
if (cmd.hasOption("r"))
riskPath = cmd.getOptionValue("r");
else
throw new IllegalArgumentException("Risk file source (-r) is mandatory");
if (cmd.hasOption("i")) {
imports = cmd.getOptionValues("i");
}
if (cmd.hasOption("d")) {
destinationPath = cmd.getOptionValue("d");
}
UnifiedRiskReader reader = new UnifiedRiskReader();
OntologyMapper mapper = new OntologyMapper();
reader.readFromFile(path);
String owlString = mapper.run(imports);
File file;
if (destinationPath != null && !destinationPath.equals(""))
file = new File(destinationPath);
else
file = new File("outputTest.owl");
FileUtils.writeStringToFile(file, owlString);
}
}