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