forked from kiegroup/drools-chance
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit of terms generator API/Maven plugin.
- Loading branch information
1 parent
379a6eb
commit 19369c3
Showing
18 changed files
with
892 additions
and
0 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
drools-shapes/drools-shapes-terms/drools-shapes-terms-generator-plugin/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/target | ||
/local | ||
|
||
# Eclipse, Netbeans and IntelliJ files | ||
/.* | ||
!.gitignore | ||
/nbproject | ||
/*.ipr | ||
/*.iws | ||
/*.iml | ||
|
||
# Repository wide ignore mac DS_Store files | ||
.DS_Store |
35 changes: 35 additions & 0 deletions
35
drools-shapes/drools-shapes-terms/drools-shapes-terms-generator-plugin/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Copyright 2014 Red Hat, Inc. and/or its affiliates. | ||
~ | ||
~ Licensed under the Eclipse Public License version 1.0, available at | ||
~ http://www.eclipse.org/legal/epl-v10.html | ||
--> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>drools-shapes-terms</artifactId> | ||
<groupId>org.drools</groupId> | ||
<version>6.3.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
<packaging>maven-plugin</packaging> | ||
|
||
<artifactId>drools-shapes-terms-generator-plugin</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.drools</groupId> | ||
<artifactId>drools-shapes-terms-generator</artifactId> | ||
<version>${project.parent.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.maven</groupId> | ||
<artifactId>maven-plugin-api</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
74 changes: 74 additions & 0 deletions
74
...r-plugin/src/main/java/org/drools/shapes/terms/generator/plugin/TermsGeneratorPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package org.drools.shapes.terms.generator.plugin; | ||
|
||
import org.apache.maven.plugin.AbstractMojo; | ||
import org.apache.maven.plugin.MojoExecutionException; | ||
import org.apache.maven.plugin.MojoFailureException; | ||
import org.drools.shapes.terms.generator.TerminologyGenerator; | ||
|
||
import java.io.File; | ||
import java.io.FileInputStream; | ||
|
||
/** | ||
* Goal | ||
* | ||
* @goal generate-terms | ||
* | ||
* @phase generate-sources | ||
* @requiresDependencyResolution compile | ||
*/ | ||
public class TermsGeneratorPlugin extends AbstractMojo { | ||
|
||
/** | ||
* @parameter | ||
*/ | ||
private String owlFile; | ||
|
||
public String getOwlFile() { | ||
return owlFile; | ||
} | ||
|
||
public void setOwlFile(String owlFile) { | ||
this.owlFile = owlFile; | ||
} | ||
|
||
/** | ||
* @parameter | ||
*/ | ||
private String packageName; | ||
|
||
public String getPackageName() { | ||
return packageName; | ||
} | ||
|
||
public void setPackageName(String packageName) { | ||
this.packageName = packageName; | ||
} | ||
|
||
/** | ||
* @parameter default-value="./target/generated-sources" | ||
*/ | ||
private File outputDirectory; | ||
|
||
public File getOutputDirectory() { | ||
return outputDirectory; | ||
} | ||
|
||
public void setOutputDirectory(File outputDirectory) { | ||
this.outputDirectory = outputDirectory; | ||
} | ||
|
||
public void execute() throws MojoExecutionException, MojoFailureException { | ||
try { | ||
new TerminologyGenerator().generate( | ||
new FileInputStream( this.owlFile ), | ||
this.packageName, | ||
this.outputDirectory ); | ||
} catch ( Exception e ) { | ||
System.err.println( e.getMessage() ); | ||
throw new MojoExecutionException( e.getMessage() ); | ||
} | ||
} | ||
} | ||
|
||
|
||
|
13 changes: 13 additions & 0 deletions
13
drools-shapes/drools-shapes-terms/drools-shapes-terms-generator/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/target | ||
/local | ||
|
||
# Eclipse, Netbeans and IntelliJ files | ||
/.* | ||
!.gitignore | ||
/nbproject | ||
/*.ipr | ||
/*.iws | ||
/*.iml | ||
|
||
# Repository wide ignore mac DS_Store files | ||
.DS_Store |
41 changes: 41 additions & 0 deletions
41
drools-shapes/drools-shapes-terms/drools-shapes-terms-generator/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Copyright 2014 Red Hat, Inc. and/or its affiliates. | ||
~ | ||
~ Licensed under the Eclipse Public License version 1.0, available at | ||
~ http://www.eclipse.org/legal/epl-v10.html | ||
--> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>drools-shapes-terms</artifactId> | ||
<groupId>org.drools</groupId> | ||
<version>6.3.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>drools-shapes-terms-generator</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.drools</groupId> | ||
<artifactId>drools-shapes-terms-api</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.github.ansell.pellet</groupId> | ||
<artifactId>pellet-jena</artifactId> | ||
<version>2.3.2</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.velocity</groupId> | ||
<artifactId>velocity</artifactId> | ||
<version>1.7</version> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
</project> |
130 changes: 130 additions & 0 deletions
130
...rms/drools-shapes-terms-generator/src/main/java/org/drools/shapes/terms/generator/CD.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
/* | ||
* Copyright 2014 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Eclipse Public License version 1.0, available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
|
||
package org.drools.shapes.terms.generator; | ||
|
||
import org.drools.drools_shapes.terms.ConceptDescriptor; | ||
|
||
import java.net.URI; | ||
|
||
public class CD implements ConceptDescriptor { | ||
|
||
private String valueSet; | ||
private String code; | ||
private String displayName; | ||
private String codeSystem; | ||
private String codeSystemName; | ||
private URI uri; | ||
|
||
public CD() { | ||
super(); | ||
} | ||
|
||
public CD(URI codeURI, String code, String displayName, String codeSystem, String codeSystemName) { | ||
this.code = code; | ||
this.displayName = displayName; | ||
this.codeSystem = codeSystem; | ||
this.codeSystemName = codeSystemName; | ||
this.uri = codeURI; | ||
} | ||
|
||
public CD(String codeURI, String code, String displayName, String codeSystem, String codeSystemName) { | ||
this( URI.create( codeURI ), code, displayName, codeSystem, codeSystemName ); | ||
} | ||
|
||
public CD(String code, String displayName, URI codeSystemURI, String codeSystem, String codeSystemName) { | ||
this( URI.create( codeSystemURI.toString() + code ), code, displayName, codeSystem, codeSystemName ); | ||
} | ||
|
||
|
||
@Override | ||
public String getCode() { | ||
return code; | ||
} | ||
|
||
@Override | ||
public void setCode( String code ) { | ||
this.code = code; | ||
} | ||
|
||
@Override | ||
public String getDisplayName() { | ||
return displayName; | ||
} | ||
|
||
@Override | ||
public void setDisplayName( String displayName ) { | ||
this.displayName = displayName; | ||
} | ||
|
||
@Override | ||
public String getCodeSystem() { | ||
return codeSystem; | ||
} | ||
|
||
@Override | ||
public void setCodeSystem( String codeSystem ) { | ||
this.codeSystem = codeSystem; | ||
} | ||
|
||
@Override | ||
public URI getUri() { | ||
if(uri == null) { | ||
return URI.create( this.codeSystem + this.code ); | ||
} else { | ||
return uri; | ||
} | ||
} | ||
|
||
@Override | ||
public void setUri( URI uri ) { | ||
this.uri = uri; | ||
} | ||
|
||
public String getCodeSystemName() { | ||
return codeSystemName; | ||
} | ||
|
||
public void setCodeSystemName( String codeSystemName ) { | ||
this.codeSystemName = codeSystemName; | ||
} | ||
|
||
@Override | ||
public String getValueSet() { | ||
return this.valueSet; | ||
} | ||
|
||
@Override | ||
public void setValueSet(String valueSet) { | ||
this.valueSet = valueSet; | ||
} | ||
|
||
@Override | ||
public boolean equals( Object o ) { | ||
if ( this == o ) return true; | ||
if ( !( o instanceof ConceptDescriptor ) ) return false; | ||
|
||
ConceptDescriptor cd = (ConceptDescriptor) o; | ||
|
||
if ( !uri.equals( cd.getUri() ) ) return false; | ||
|
||
return true; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return getUri().hashCode(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "CD{" + | ||
"code='" + code + '\'' + | ||
", displayName='" + displayName + '\'' + | ||
'}'; | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
...ls-shapes-terms-generator/src/main/java/org/drools/shapes/terms/generator/CodeSystem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package org.drools.shapes.terms.generator; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
public class CodeSystem { | ||
|
||
private Set<Concept> concepts = new HashSet<Concept>(); | ||
|
||
private String codeSystemName; | ||
|
||
private String codeSystemUri; | ||
|
||
public CodeSystem() { | ||
super(); | ||
} | ||
|
||
public CodeSystem(String codeSystemName, String codeSystemUri) { | ||
this.codeSystemName = codeSystemName; | ||
this.codeSystemUri = codeSystemUri; | ||
} | ||
|
||
public CodeSystem(Set<Concept> concepts, String codeSystemName, String codeSystemUri) { | ||
this.concepts = concepts; | ||
this.codeSystemName = codeSystemName; | ||
this.codeSystemUri = codeSystemUri; | ||
} | ||
|
||
public Set<Concept> getConcepts() { | ||
return concepts; | ||
} | ||
|
||
public void setConcepts(Set<Concept> concepts) { | ||
this.concepts = concepts; | ||
} | ||
|
||
public String getCodeSystemName() { | ||
return codeSystemName; | ||
} | ||
|
||
public void setCodeSystemName(String codeSystemName) { | ||
this.codeSystemName = codeSystemName; | ||
} | ||
|
||
public String getCodeSystemUri() { | ||
return codeSystemUri; | ||
} | ||
|
||
public void setCodeSystemUri(String codeSystemUri) { | ||
this.codeSystemUri = codeSystemUri; | ||
} | ||
} |
Oops, something went wrong.