Skip to content

Package: OWL2JavaMojo

OWL2JavaMojo

nameinstructionbranchcomplexitylinemethod
OWL2JavaMojo()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
execute()
M: 107 C: 0
0%
M: 8 C: 0
0%
M: 5 C: 0
0%
M: 18 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /**
2: * Copyright (C) 2016 Czech Technical University in Prague
3: *
4: * This program is free software: you can redistribute it and/or modify it under
5: * the terms of the GNU General Public License as published by the Free Software
6: * Foundation, either version 3 of the License, or (at your option) any
7: * later version.
8: *
9: * This program is distributed in the hope that it will be useful, but WITHOUT
10: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12: * details. You should have received a copy of the GNU General Public License
13: * along with this program. If not, see <http://www.gnu.org/licenses/>.
14: */
15: package cz.cvut.kbss.jopa.maven;
16:
17: import cz.cvut.kbss.jopa.owl2java.OWL2JavaTransformer;
18: import org.apache.maven.plugin.AbstractMojo;
19: import org.apache.maven.plugin.MojoExecutionException;
20: import org.apache.maven.plugin.MojoFailureException;
21: import org.apache.maven.plugins.annotations.Mojo;
22: import org.apache.maven.plugins.annotations.Parameter;
23:
24: @Mojo( name = "owl2java-transform" )
25: public class OWL2JavaMojo extends AbstractMojo {
26:
27: @Parameter(alias="mapping-file")
28: private String pMappingFile;
29:
30: @Parameter(alias="package")
31: private String pPackage;
32:
33: @Parameter(alias = "context-name")
34: private String pContextName;
35:
36: @Parameter(alias = "ontology-iri")
37: private String pOntologyIRI;
38:
39: @Parameter(alias = "output-directory")
40: private String pOutputDirectory;
41:
42: @Parameter(alias = "with-owlapi",defaultValue = "false")
43: private Boolean pWithOWLAPI;
44:
45: @Override
46: public void execute() throws MojoExecutionException, MojoFailureException {
47: OWL2JavaTransformer owl2java = new OWL2JavaTransformer();
48:
49: System.out.println(pMappingFile + ","
50: + pPackage + ","
51: + pContextName + ","
52: + pOntologyIRI + ","
53: + pOutputDirectory + ","
54: );
55:
56:• if ( pOntologyIRI == null ) {
57: getLog().error("The parameter 'ontology-iri' is invalid. Must not be null.");
58: getLog().error("Skipping OWL2Java transformation.");
59: return;
60: }
61:
62:• if ( pMappingFile != null && !pMappingFile.isEmpty() ) {
63: owl2java.setOntology(pOntologyIRI, pMappingFile, true);
64: } else {
65: owl2java.setOntology(pOntologyIRI, null, true);
66: }
67:
68:• if (!owl2java.listContexts().contains(pContextName)) {
69: getLog().error("The parameter '-c' is invalid. Found contexts: "
70: + owl2java.listContexts());
71: getLog().error("Skipping OWL2Java transformation.");
72: return;
73: }
74:
75: owl2java.transform(pContextName,
76: pPackage, pOutputDirectory, pWithOWLAPI);
77:
78: getLog().info( "OWL2Java successfully generated!" );
79: }
80: }