Switch to unified view

a/src/main/java/net/timbusproject/extractors/modules/tavernaextractor/Main.java b/src/main/java/net/timbusproject/extractors/modules/tavernaextractor/Main.java
1
package net.timbusproject.extractors.modules.tavernaextractor;
1
package net.timbusproject.extractors.modules.tavernaextractor;
2
2
3
import java.io.BufferedReader;
3
import java.io.BufferedReader;
4
import java.io.File;
4
import java.io.File;
5
import java.io.FileInputStream;
6
import java.io.IOException;
5
import java.io.IOException;
7
import java.io.InputStream;
6
import java.io.InputStream;
8
import java.io.InputStreamReader;
7
import java.io.InputStreamReader;
9
import java.nio.file.Path;
8
import java.nio.file.Path;
10
import java.nio.file.Paths;
9
import java.nio.file.Paths;
...
...
57
                if (parse.hasOption("i") && parse.hasOption("o")) {
56
                if (parse.hasOption("i") && parse.hasOption("o")) {
58
57
59
                    String archimateOutputPath = parse.getOptionValue("o");
58
                    String archimateOutputPath = parse.getOptionValue("o");
60
                    String inputFileName = parse.getOptionValue("i");
59
                    String inputFileName = parse.getOptionValue("i");
61
60
62
                    // setup the extractor
63
                    TavernaExtractor extractor = null;
64
65
                    if (parse.hasOption("v"))
61
                    if (parse.hasOption("v"))
66
                        verbose = true;
62
                        verbose = true;
67
63
64
                    // setup the extractor
68
                    extractor = new TavernaExtractor(verbose);
65
                    TavernaExtractor extractor = new TavernaExtractor(verbose);
69
                    TavernaExtractor.setTavernaHome(Main.getTavernaHome(tavernaHome));
66
                    extractor.setTavernaHome(Main.getTavernaHome(tavernaHome));
70
                    TavernaExtractor.setArchimateOutputPath(Paths.get(archimateOutputPath));
67
                    extractor.setArchimateOutputPath(Paths.get(archimateOutputPath));
71
                    TavernaExtractor.setInputFileName(Paths.get(inputFileName));
68
                    extractor.setInputFileName(Paths.get(inputFileName));
72
                    TavernaExtractor.setDotLocation(Paths.get(dotExeLocation));
69
                    extractor.setDotLocation(Paths.get(dotExeLocation));
73
                    extractor.process(false); //false = local execution
70
                    extractor.process(false); //false = local execution
74
                }
71
                }
75
72
76
                // List all provenance entries OR Running DROID identification
73
                // List all provenance entries OR Running DROID identification
77
                if (parse.hasOption("p")) {
74
                if (parse.hasOption("p")) {
...
...
99
                            System.out.println("Your input '" + input + "' was not a valid number. Process stopped.");
96
                            System.out.println("Your input '" + input + "' was not a valid number. Process stopped.");
100
                        }
97
                        }
101
                    }
98
                    }
102
                }
99
                }
103
100
104
                // Generate report out of DROID profile file
105
//                if (parse.hasOption("cr")) {
106
//
107
//                    String droidProfileFile = parse.getOptionValue("cr");
108
//
109
//                    if (droidProfileFile != null) {
110
//
111
//                        ProvenanceAccessClient pac;
112
//                        if (tavernaT2DatabasePath != null && !tavernaT2DatabasePath.isEmpty()) {
113
//                            pac = new ProvenanceAccessClient(tavernaT2DatabasePath);
114
//                        } else {
115
//                            pac = new ProvenanceAccessClient();
116
//                        }
117
//                        pac.generateReport(new File(droidProfileFile));
118
//                    }
119
//                }
120
121
                // Extend DSO with PRONOM information
101
                // Extend DSO with PRONOM information
122
                if (parse.hasOption("ont") && parse.hasOption("r")) {
102
                if (parse.hasOption("ont") && parse.hasOption("r")) {
123
103
124
                    LOGGER.debug("Start extending ontology ...");
104
                    LOGGER.debug("Start extending ontology ...");
125
                    System.out.println("Start extending ontology ...");
105
                    System.out.println("Start extending ontology ...");
...
...
155
135
156
            } catch (ParseException exp) {
136
            } catch (ParseException exp) {
157
                helpFormater.printHelp("TavernaExtractor", createOptions());
137
                helpFormater.printHelp("TavernaExtractor", createOptions());
158
                LOGGER.error("ERROR: Wrong usage:" + exp.getMessage());
138
                LOGGER.error("ERROR: Wrong usage:" + exp.getMessage());
159
                exp.printStackTrace();
139
                exp.printStackTrace();
160
                return;
161
            }
140
            }
162
        } catch (Exception e) {
141
        } catch (Exception e) {
163
            LOGGER.error(e.getMessage());
142
            LOGGER.error(e.getMessage());
164
            // also print the error stack trace
143
            // also print the error stack trace
165
            if(verbose)
144
            if(verbose)
...
...
179
        OptionBuilder.withDescription("Specifies the taverna t2flow (input) file.");
158
        OptionBuilder.withDescription("Specifies the taverna t2flow (input) file.");
180
        OptionBuilder.hasArg();
159
        OptionBuilder.hasArg();
181
        OptionBuilder.withLongOpt("input-file");
160
        OptionBuilder.withLongOpt("input-file");
182
        options.addOption(OptionBuilder.create("i"));
161
        options.addOption(OptionBuilder.create("i"));
183
162
184
        //TODO : rename
185
        OptionBuilder.withDescription("Fetching processed files from workflow");
163
        OptionBuilder.withDescription("Fetching provenance information from a workflow execution");
164
        OptionBuilder.withArgName("\\path\\to\\copy\\provenance-trace");
186
        OptionBuilder.hasArg();
165
        OptionBuilder.hasArg();
187
        OptionBuilder.withLongOpt("provenance");
166
        OptionBuilder.withLongOpt("provenance");
188
        options.addOption(OptionBuilder.create("p"));
167
        options.addOption(OptionBuilder.create("p"));
189
168
190
//        OptionBuilder.withDescription("Generate CSV Report out of DROID profile.");
191
//        OptionBuilder.hasArg();
192
//        OptionBuilder.withLongOpt("create-report");
193
//        options.addOption(OptionBuilder.create("cr"));
194
195
        OptionBuilder.withDescription("The ontology file");
169
        OptionBuilder.withDescription("Ontology file");
196
        OptionBuilder.withArgName("\\path\\to\\myOntology.owl");
170
        OptionBuilder.withArgName("\\path\\to\\myOntology.owl");
197
        OptionBuilder.hasArg();
171
        OptionBuilder.hasArg();
198
        OptionBuilder.withLongOpt("ontology-file");
172
        OptionBuilder.withLongOpt("ontology-file");
199
        options.addOption(OptionBuilder.create("ont"));
173
        options.addOption(OptionBuilder.create("ont"));
200
174
201
        OptionBuilder.withDescription("output file");
175
        OptionBuilder.withDescription("DROID report file");
202
        OptionBuilder.withArgName("\\path\\to\\myDroidCSVreportFile.droid.csv");
176
        OptionBuilder.withArgName("\\path\\to\\myDroidCSVreportFile.droid.csv");
203
        OptionBuilder.hasArg();
177
        OptionBuilder.hasArg();
204
        OptionBuilder.withLongOpt("reportFile");
178
        OptionBuilder.withLongOpt("reportFile");
205
        options.addOption(OptionBuilder.create("r"));
179
        options.addOption(OptionBuilder.create("r"));
206
180
...
...
232
    }
206
    }
233
207
234
    private static Properties loadProperties() {
208
    private static Properties loadProperties() {
235
209
236
        Properties prop = new Properties();
210
        Properties prop = new Properties();
237
        InputStream input = null;
238
        try {
211
        try {
239
240
            input = Main.class.getClassLoader().getResourceAsStream("TavernaExtractor.properties");
212
            InputStream input = Main.class.getClassLoader().getResourceAsStream("TavernaExtractor.properties");
241
            prop.load(input);
213
            prop.load(input);
242
243
            LOGGER.debug("Load properties successfully.");
214
            LOGGER.debug("Load properties successfully.");
244
215
245
        } catch (IOException io) {
216
        } catch (IOException io) {
246
            LOGGER.error(io.getMessage());
217
            LOGGER.error(io.getMessage());
247
            io.printStackTrace();
218
            io.printStackTrace();