Skip to content

Commit e95e6de

Browse files
committed
Fix some issues
1 parent 0032919 commit e95e6de

File tree

3 files changed

+36
-20
lines changed

3 files changed

+36
-20
lines changed

pom.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,20 @@
121121
</archive>
122122
</configuration>
123123
</plugin>
124+
<plugin>
125+
<groupId>org.codehaus.mojo</groupId>
126+
<artifactId>exec-maven-plugin</artifactId>
127+
<executions>
128+
<execution>
129+
<goals>
130+
<goal>java</goal>
131+
</goals>
132+
</execution>
133+
</executions>
134+
<configuration>
135+
<mainClass>tbx2rdf.Main</mainClass>
136+
</configuration>
137+
</plugin>
124138
<plugin>
125139
<artifactId>maven-resources-plugin</artifactId>
126140
<version>2.6</version>

src/java/tbx2rdf/Main.java

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
*/
3636
public class Main {
3737

38-
private final static Logger logger = Logger.getLogger(Main.class);
3938
//Determines whether it will be a stream-parsing (if big=true) or a block conversion (big=false)
4039
static boolean big = false;
4140
// Establishes the file with the mappings
@@ -62,11 +61,11 @@ public static void main(String[] args) throws ParserConfigurationException, IOEx
6261

6362
boolean ok = parseParams(args);
6463
if (!ok) {
65-
return;
64+
System.exit(-1);
6665
}
6766

6867
//READ MAPPINGS
69-
logger.info("Using mapping file: " + mapping_file + "\n");
68+
System.err.println("Using mapping file: " + mapping_file + "\n");
7069
mappings = Mappings.readInMappings(mapping_file);
7170

7271
if (big) {
@@ -85,18 +84,17 @@ public static boolean parseParams(String[] args) {
8584
for (String ejecutandox : args) {
8685
ejecutando += " " + ejecutandox;
8786
}
88-
logger.info(ejecutando);
8987
if (args.length == 0) {
90-
System.out.println("Usage: TBX2RDF_Converter <INPUT_FILE> (--output=<OUTPUT_FILE>)? (--mappings=<MAPPING_FILE>)? (--big=true)? (--datanamespace=<DATA_NAMESPACE>)?");
91-
System.out.println("If no OUTPUT_FILE is provided, then <OUTPUT FILE>s/.xml/.rdf/ will be assumed as output file.");
92-
System.out.println("If no MAPPING_FILE is provided, then mappings.default will be used.");
88+
System.err.println("Usage: TBX2RDF_Converter <INPUT_FILE> (--output=<OUTPUT_FILE>)? (--mappings=<MAPPING_FILE>)? (--big=true)? (--datanamespace=<DATA_NAMESPACE>)?");
89+
System.err.println("If no OUTPUT_FILE is provided, then <OUTPUT FILE>s/.xml/.rdf/ will be assumed as output file.");
90+
System.err.println("If no MAPPING_FILE is provided, then mappings.default will be used.");
9391
return false;
9492
}
9593
input_file = args[0]; //First argument, input file
9694
File file = new File(input_file);
9795
if (!file.exists())
9896
{
99-
logger.error("The file " + input_file + " does not exist");
97+
System.err.println("The file " + input_file + " does not exist");
10098
return false;
10199
}
102100

@@ -116,27 +114,27 @@ public static boolean parseParams(String[] args) {
116114
if (key.equals("output")) {
117115
output_file = value;
118116
bOutputInConsole = false;
119-
logger.info("OUTPUT_FILE set to" + output_file + "\n");
117+
System.err.println("OUTPUT_FILE set to" + output_file + "\n");
120118
}
121119
if (key.equals("mappings")) {
122120
mapping_file = value;
123-
logger.info("MAPPING_FILE set to" + mapping_file + "\n");
121+
System.err.println("MAPPING_FILE set to" + mapping_file + "\n");
124122
}
125123
if (key.equals("datanamespace")) {
126124
DATA_NAMESPACE = value;
127-
logger.info("DATA_NAMESPACE set to" + DATA_NAMESPACE + "\n");
125+
System.err.println("DATA_NAMESPACE set to" + DATA_NAMESPACE + "\n");
128126
}
129127
if (key.equals("big")) {
130128
if (value.equals("true")) {
131129
big = true;
132130
}
133-
logger.info("Processing large file");
131+
System.err.println("Processing large file");
134132
}
135133
if (key.equals("lenient")) {
136134
if (value.equals("true")) {
137135
lenient = true;
138136
}
139-
logger.info("Processing in lenient mode");
137+
System.err.println("Processing in lenient mode");
140138
}
141139
}
142140
}
@@ -150,7 +148,7 @@ public static boolean parseParams(String[] args) {
150148
public static boolean convertBigFile() {
151149
try {
152150
bOutputInConsole = false;
153-
logger.info("Doing the conversion of a big file\n");
151+
System.err.println("Doing the conversion of a big file\n");
154152
TBX2RDF_Converter converter = new TBX2RDF_Converter();
155153
PrintStream fos;
156154
if (output_file.isEmpty() || bOutputInConsole) {
@@ -159,12 +157,12 @@ public static boolean convertBigFile() {
159157
fos = new PrintStream(output_file, "UTF-8");
160158
}
161159
if (fos == null) {
162-
logger.error("output file could not be open");
160+
System.err.println("output file could not be open");
163161
return false;
164162
}
165163
converter.convertAndSerializeLargeFile(input_file, fos, mappings);
166164
} catch (Exception e) {
167-
logger.error(e.getMessage());
165+
System.err.println(e.getMessage());
168166
return false;
169167
}
170168
return true;
@@ -177,20 +175,20 @@ public static boolean convertBigFile() {
177175
*/
178176
public static boolean convertSmallFile() {
179177
try {
180-
logger.info("Doing the standard conversion (not a big file)\n");
178+
System.err.println("Doing the standard conversion (not a big file)\n");
181179
//READ TBX XML
182-
logger.info("Opening file " + input_file + "\n");
180+
System.err.println("Opening file " + input_file + "\n");
183181
BufferedReader reader = new BufferedReader(new FileReader(input_file));
184182
TBX2RDF_Converter converter = new TBX2RDF_Converter();
185183
TBX_Terminology terminology = converter.convert(reader, mappings);
186184
//WRITE. This one has been obtained from
187-
logger.info("Writting output to " + output_file + "\n");
185+
System.err.println("Writting output to " + output_file + "\n");
188186
// final Model model = terminology.getModel("file:" + output_file);
189187
final Model model = terminology.getModel(Main.DATA_NAMESPACE);
190188
RDFDataMgr.write(new FileOutputStream(output_file), model, Lang.TURTLE);
191189
reader.close();
192190
} catch (Exception e) {
193-
logger.error(e.getMessage());
191+
System.err.println(e.getMessage());
194192
return false;
195193
}
196194
return true;

tbx2rdf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
mvn -q exec:java -Dexec.args="$@"
4+

0 commit comments

Comments
 (0)